@hearsay-tools/squawk 0.19.0-pr4622.9212 → 0.19.0-pr4622.9213

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 (91) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/delegation/routes.d.ts +78 -78
  3. package/dist/features/hosts/routes.d.ts +64 -64
  4. package/dist/features/reports/routes.d.ts +2 -2
  5. package/dist/features/webhooks/routes.d.ts +38 -38
  6. package/dist/server/activity-routes.d.ts +23 -23
  7. package/dist/server/models-routes.d.ts +12 -12
  8. package/dist/server/project-settings-routes.d.ts +107 -107
  9. package/dist/server/projects-routes.d.ts +41 -41
  10. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  11. package/dist/server/providers-routes.d.ts +58 -58
  12. package/dist/server/runner-install-routes.d.ts +10 -10
  13. package/dist/server/runners-routes.d.ts +10 -10
  14. package/dist/server/runs-routes.d.ts +333 -333
  15. package/dist/server/server.d.ts +1170 -1170
  16. package/dist/server/workspace-identity-routes.d.ts +5 -5
  17. package/dist/server/workspace-live-routes.d.ts +5 -5
  18. package/dist/server/workspace-routes.d.ts +85 -85
  19. package/package.json +4 -4
  20. package/web/dist/assets/{accounts-section-BinzShaf.js → accounts-section-BwVLJgxK.js} +1 -1
  21. package/web/dist/assets/{activity-motion-BvqTKSqo.js → activity-motion-tBH9QmZu.js} +1 -1
  22. package/web/dist/assets/{activity-route-DPk44gEy.js → activity-route-CkXs29ji.js} +1 -1
  23. package/web/dist/assets/{agent-accounts-ChU4vfBl.js → agent-accounts-DQ_JY8H9.js} +1 -1
  24. package/web/dist/assets/{agent-config-section-CcQAu9b7.js → agent-config-section-Bii12by6.js} +1 -1
  25. package/web/dist/assets/{agent-defaults-section-CSqx1479.js → agent-defaults-section-BpiqyCUf.js} +1 -1
  26. package/web/dist/assets/{appearance-DH-VN7Hg.js → appearance-B_765RRk.js} +1 -1
  27. package/web/dist/assets/{archive-on-merge-field-CqTj_p3K.js → archive-on-merge-field-B6O9ruku.js} +1 -1
  28. package/web/dist/assets/{ask-card-Dn7OYHTC.js → ask-card-Cd0Xc7Uq.js} +1 -1
  29. package/web/dist/assets/{automations-route-DWfE1BUv.js → automations-route-CcVVZs26.js} +1 -1
  30. package/web/dist/assets/{commit-list-CqWkVSfv.js → commit-list-Dcd0WekD.js} +1 -1
  31. package/web/dist/assets/{diff-CO4Md6Jv.js → diff-B_cIEbs-.js} +2 -2
  32. package/web/dist/assets/{diff-controls-C-wQd4Ib.js → diff-controls-BTGIDnSs.js} +1 -1
  33. package/web/dist/assets/{diff-view-KejwMx_e.js → diff-view-J684vGFE.js} +1 -1
  34. package/web/dist/assets/{discard-changes-dialog-DJcvcxDg.js → discard-changes-dialog-BtnFyMRT.js} +1 -1
  35. package/web/dist/assets/{file-preview-BSAsYRmQ.js → file-preview-B3jXfVP7.js} +1 -1
  36. package/web/dist/assets/{folder-browser-BvE0XQDC.js → folder-browser-sYsHX_an.js} +1 -1
  37. package/web/dist/assets/{git-toolbar-BoP7hEiL.js → git-toolbar-SKqi4XfU.js} +1 -1
  38. package/web/dist/assets/{github-Brwd2u17.js → github-T6wolZwH.js} +1 -1
  39. package/web/dist/assets/{global-activity-route-ylRv5i0B.js → global-activity-route-Dx-kvhpz.js} +1 -1
  40. package/web/dist/assets/{hosts-BIgzlJ2i.js → hosts-DeyANWdw.js} +1 -1
  41. package/web/dist/assets/{index-Cf0HK2YW.js → index-6oRe52sM.js} +5 -5
  42. package/web/dist/assets/label-BXbOoPSF.js +1 -0
  43. package/web/dist/assets/{markdown-_RWbSoHA.js → markdown-TRVPj3Mg.js} +1 -1
  44. package/web/dist/assets/{open-in-menu-zrukT4IK.js → open-in-menu-g5K4vTnb.js} +1 -1
  45. package/web/dist/assets/{option-select-BtavcdtM.js → option-select-B76TaZGm.js} +1 -1
  46. package/web/dist/assets/{preferences-section-DBoTeoB0.js → preferences-section-DZRKsK2E.js} +1 -1
  47. package/web/dist/assets/{preview-pane-connected-CqZ7qR53.js → preview-pane-connected-CM10_MPC.js} +1 -1
  48. package/web/dist/assets/{project-location-DQob1g0E.js → project-location-F5rU1iQp.js} +1 -1
  49. package/web/dist/assets/{projects-section-ClWFVviV.js → projects-section-DvYKR18b.js} +1 -1
  50. package/web/dist/assets/{prompt-templates-section-C32HXWo3.js → prompt-templates-section-DFiGQ_kP.js} +1 -1
  51. package/web/dist/assets/queries-DQVUxiSU.js +1 -0
  52. package/web/dist/assets/{read-state-B1VLxOM6.js → read-state-DlkdVJHO.js} +1 -1
  53. package/web/dist/assets/{reference-chip-Bj_PKUc4.js → reference-chip-DTWd5NlK.js} +1 -1
  54. package/web/dist/assets/{remote-settings-notice-C8VV_iw0.js → remote-settings-notice-4jnKyzkr.js} +1 -1
  55. package/web/dist/assets/{repo-git-CjUQ0g26.js → repo-git-bpVnYJKi.js} +1 -1
  56. package/web/dist/assets/{report-reader-C_yAYPmW.js → report-reader-DMyNCIiX.js} +1 -1
  57. package/web/dist/assets/{report-selection-D-asrNb1.js → report-selection-BJgUwTp3.js} +1 -1
  58. package/web/dist/assets/{reports-DtdpSXDD.js → reports-CBzt0Dmc.js} +1 -1
  59. package/web/dist/assets/{resources-section-PEx4v01N.js → resources-section-DrFTKHSn.js} +1 -1
  60. package/web/dist/assets/{review-notes-drafts-C2MYGz6Z.js → review-notes-drafts-N0GgOh1J.js} +1 -1
  61. package/web/dist/assets/{review-panel-I3KgOMmg.js → review-panel-BhyjEDJC.js} +1 -1
  62. package/web/dist/assets/{review-strip-OOHBg4No.js → review-strip-DoWuOvcF.js} +1 -1
  63. package/web/dist/assets/{run-detail-refresh-CoCrbq8v.js → run-detail-refresh-Bx9zlPFP.js} +1 -1
  64. package/web/dist/assets/{run-diff-DlyvdCr9.js → run-diff-BqvMg-mp.js} +1 -1
  65. package/web/dist/assets/{run-header-CC-99Rq_.js → run-header-Bg2x1hvz.js} +1 -1
  66. package/web/dist/assets/{select-DaeMMrqM.js → select-Cbi8vDBU.js} +1 -1
  67. package/web/dist/assets/{session-context-section-DkPFGHH0.js → session-context-section-BnezEi_b.js} +1 -1
  68. package/web/dist/assets/{settings-agent-picker-wN3FpFa5.js → settings-agent-picker-DCmAHz6j.js} +1 -1
  69. package/web/dist/assets/{settings-save-bar-PHQFfhCk.js → settings-save-bar-De7cR5EO.js} +1 -1
  70. package/web/dist/assets/{settings-shell-Z0rNc1xx.js → settings-shell-kQCF-IMK.js} +1 -1
  71. package/web/dist/assets/{sidebar-section-BE5SSKrX.js → sidebar-section-BZHg8W-H.js} +1 -1
  72. package/web/dist/assets/{skills-Dm5hGdd8.js → skills-DUOE73c3.js} +1 -1
  73. package/web/dist/assets/{task-changes-CS1uSQfH.js → task-changes-fRMZxCzG.js} +1 -1
  74. package/web/dist/assets/{task-commits-DCbUyMTZ.js → task-commits-Cenv0zsB.js} +1 -1
  75. package/web/dist/assets/{task-file-scope-CcmDJfUC.js → task-file-scope-K1Ban5eN.js} +1 -1
  76. package/web/dist/assets/{task-files-CO9gRC8O.js → task-files-EU03WHnV.js} +1 -1
  77. package/web/dist/assets/{task-github-item-C7Qtl-R4.js → task-github-item-Dhte1Ixh.js} +1 -1
  78. package/web/dist/assets/{task-groups-1B3qWNle.js → task-groups-DcQL5SKa.js} +1 -1
  79. package/web/dist/assets/{task-thread-BXPhkg3D.js → task-thread-DDMomGRh.js} +1 -1
  80. package/web/dist/assets/{thread-state-Co15rrhn.js → thread-state-K3qTs1EO.js} +1 -1
  81. package/web/dist/assets/{use-finish-run-BAu374MO.js → use-finish-run-C8c9NAvg.js} +1 -1
  82. package/web/dist/assets/{use-hand-to-agent-state-BO7f9Vja.js → use-hand-to-agent-state-BIvAHKwY.js} +1 -1
  83. package/web/dist/assets/use-path-bases-DxT4eodL.js +1 -0
  84. package/web/dist/assets/{use-workspace-config-save-y-EQHm5n.js → use-workspace-config-save-D6M-r6_i.js} +1 -1
  85. package/web/dist/assets/{workflows-Bawt8WPJ.js → workflows-jSPeMWLl.js} +1 -1
  86. package/web/dist/assets/{workspace-tools-Bjxxd-mY.js → workspace-tools-DmZ9LMQc.js} +1 -1
  87. package/web/dist/assets/{worktrees-section-CqdaU9Rf.js → worktrees-section-CsXzXEwX.js} +1 -1
  88. package/web/dist/index.html +12 -12
  89. package/web/dist/assets/label-D6E1lpRI.js +0 -1
  90. package/web/dist/assets/queries-CNjDebHy.js +0 -1
  91. package/web/dist/assets/use-path-bases-DQnmY-WP.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{an as r,cn as i,dn as a,fn as o,gn as s,hn as c,in as l,ln as u,mn as d,on as f,pn as p,rn as m,sn as h,un as g,wn as _,yt as v}from"./queries-CNjDebHy.js";import{f as y,h as b,m as x,u as S}from"./host-context-iTMFRMT5.js";import{Fn as ee,Ji as C,Nn as te,ar as w,ji as ne,or as T,rr as E,tr as re}from"./toaster-Dglox5F-.js";import{i as D,r as O}from"./cez-idle-C0drOeLs.js";import{o as k}from"./dist-CCX8mhHc.js";import{n as A,t as j}from"./hosts-BIgzlJ2i.js";import{n as ie,r as M,t as ae}from"./run-detail-refresh-CoCrbq8v.js";import{h as N}from"./es2015-BHonSvOU.js";var P=class extends EventTarget{readyState=0;release;constructor(e,t){super(),this.release=this.subscribe()}subscribe(){let e=()=>queueMicrotask(()=>{this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event(`open`)))});return w({kind:`workspace`},{ready:e,reset:()=>{this.readyState!==2&&(this.readyState=0,e())},frame:t=>{if(`data`in t&&t.event===`reconnect`){this.readyState=0,e();return}if(`data`in t&&t.event===`disconnect`){this.readyState===1&&(this.readyState=0,this.dispatchEvent(new Event(`error`)));return}`data`in t&&t.event===`ready`&&T(),`data`in t&&this.dispatchEvent(new MessageEvent(t.event,{data:t.data}))}})}requestReady(){return this.readyState!==2&&E()}close(){this.readyState=2,this.release()}},F=e(t(),1);function I(e,t,n,r){let i=m(t,n,r);return e.isMutating({mutationKey:i,exact:!0})>0||e.getMutationCache().getAll().some(e=>{if(e.state.status!==`pending`)return!1;let i=e.state.variables;return i?.hostId===t&&i?.projectId===n&&i?.runId===r})}function L(e,t){if(S()||t)return[];let n=[h(e).reconcile()];e.getQueryState(j.hosts)&&n.push(e.invalidateQueries({queryKey:j.hosts,exact:!0}));let r=e.getQueryState(j.hostsProjects);return r&&A(r.data,r.status===`error`)&&n.push(e.invalidateQueries({queryKey:j.hostsProjects,exact:!0})),n}function oe(e,t,n){if(!S())for(let r of g)e.addEventListener(r,e=>{let i=c(r,e.data);if(i)if(i.type===`host-run-summary`||i.type===`host-run-deleted`){n.run(i);let e=i.type===`host-run-summary`?i.summary.id:i.id,r=m(i.hostId,i.project,e);t.getQueryState(r)&&!I(t,i.hostId,i.project,e)&&(i.type===`host-run-deleted`?t.removeQueries({queryKey:r,exact:!0}):t.invalidateQueries({queryKey:r,exact:!0}))}else i.type===`host-usage`?n.usage(i.hostId,i.project,i.usage):(i.stateChanged&&t.invalidateQueries({queryKey:j.hosts,exact:!0}),(i.stateChanged||i.indexChanged)&&t.invalidateQueries({queryKey:j.hostsProjects,exact:!0}),i.indexChanged&&n.reconcileHosts(i.hostIds))})}var R=n(),se=`/workspace/events?runs=summary`,z=2,ce=3e3,le=[`run-summary`,`run-deleted`,`usage`,`ping`,`ready`],ue=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`project-ready`],B=new Set;function V(e){return B.add(e),()=>{B.delete(e)}}function H(e){return e[1]===`runs`&&e[2]===`list`}function U(e,t){return e.cancelQueries({queryKey:t}).then(()=>e.invalidateQueries({queryKey:t}))}function W(e){return e.invalidateQueries({predicate:e=>H(e.queryKey),refetchType:`none`}),e.getQueryCache().findAll({predicate:e=>H(e.queryKey)&&(e.state.data!==void 0||e.state.fetchStatus!==`idle`)}).map(t=>U(e,t.queryKey))}var de=1e3,G=new WeakMap;function K(e){let t=l.repoBranches,n=G.get(e);if(n){n.set(JSON.stringify(t),t);return}G.set(e,new Map([[JSON.stringify(t),t]])),setTimeout(()=>{let t=G.get(e);G.delete(e);for(let n of t?.values()??[])e.invalidateQueries({queryKey:n})},de)}function q(e,t,n=!1){if(t?.aborted)return Promise.resolve();let a=[l.runs.all,r.runsIndex,r.projects,l.health,l.worktrees,l.repoBranches,r.providerStatus],o=S()||n?[]:[j.hosts,j.hostsProjects,f],s=()=>{for(let t of a)e.cancelQueries({queryKey:t});for(let t of o)e.cancelQueries({queryKey:t,exact:!0})};return t?.addEventListener(`abort`,s,{once:!0}),D(()=>{for(let t of e.getQueryCache().findAll({predicate:e=>H(e.queryKey)}))t.state.data===void 0&&t.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t.queryKey,exact:!0});return[e.invalidateQueries({queryKey:l.runs.all,...n?{predicate:e=>[`list`,`detail`,`relationships`,`archived`].includes(String(e.queryKey[2]))}:{}}),e.invalidateQueries({predicate:e=>H(e.queryKey)}),i(e).reconcile(),...L(e,n),e.invalidateQueries({queryKey:r.projects}),U(e,l.health),e.invalidateQueries({queryKey:l.worktrees}),e.invalidateQueries({queryKey:l.repoBranches}),e.invalidateQueries({queryKey:r.providerStatus}),n?void 0:e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})]}).finally(()=>t?.removeEventListener(`abort`,s))}function J(e){return x()??Y(e)}function Y(e){let t=e.getQueryData(r.projects);if(t?.bootProject!==null)return typeof t?.bootProject==`string`&&t.bootProject!==``?t.bootProject:e.getQueryData(l.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject??void 0}function fe(e,t){return[_({projectId:e,boot:e===t}).cacheScope,`runs`,`list`]}function pe(e){let t=new Map,n=new Map,r=t=>{let r=n.get(JSON.stringify(t));if(!r)return;let i=e.getQueryCache().find({queryKey:t,exact:!0}),a=i?.promise;r.phase=`awaiting-fetch`,r.dirty=!1,e.invalidateQueries({queryKey:t,exact:!0}),i?.promise&&i.promise!==a&&(r.phase=`fetching`)},i=e.getQueryCache().subscribe(t=>{if(!n.size||t.type!==`updated`)return;let i=JSON.stringify(t.query.queryKey),a=n.get(i);if(a){if(t.action.type===`setState`){t.query.state.isInvalidated||e.invalidateQueries({queryKey:a.key,exact:!0,refetchType:`none`});return}if(t.action.type===`fetch`){a.phase===`awaiting-fetch`&&(a.phase=`fetching`),a.dirty=!1;return}if(t.action.type===`success`){if(!t.action.manual){a.phase===`fetching`&&!a.dirty?n.delete(i):r(a.key);return}a.phase!==`needs-start`&&(a.phase===`fetching`&&(a.dirty=!0),e.invalidateQueries({queryKey:a.key,exact:!0},{cancelRefetch:!1}))}}}),s=(t,r)=>{let i=JSON.stringify(t),a=e.getQueryCache().find({queryKey:t,exact:!0});if(!a)return;let o=n.get(i);!o&&(a.state.fetchStatus!==`idle`||a.state.isInvalidated)||o&&a.state.fetchStatus===`idle`?(n.set(i,{key:t,phase:`needs-start`,dirty:!1}),a.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t,exact:!0}),r.some(e=>JSON.stringify(e)===i)||r.push(t)):o?.phase===`fetching`&&(o.dirty=!0)},c,u,d=(i=!1)=>{u!==void 0&&clearTimeout(u),u=void 0,c!==void 0&&cancelAnimationFrame(c),c=void 0;let a=[];for(let{key:r,baseList:i,baseQuery:c,baseUpdateCount:l,runs:u}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==c||t?.state.dataUpdateCount!==l||t?.state.data!==i){a.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}s(r,a),e.setQueryData(r,e=>{let t=e;for(let e of u.values())t=o(t,e);return t})}if(t.clear(),!i)for(let e of a)r(e);return a},f=t=>{let n=[fe(t,Y(e))],r=[t,`runs`,`list`];return(t===J(e)||e.getQueryState(r))&&n.push(r),t===J(e)&&n.push(l.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,l){let p=f(i);if(l.type===`run-summary`&&l.summary.archived&&p.every(t=>!e.getQueryData(t)?.find(e=>e.id===l.summary.id)?.archived)&&l.type===`run-summary`){for(let r of p){let i=JSON.stringify(r),a=n.get(i);a?.phase===`fetching`&&(a.dirty=!0);let o=t.get(i);if(!o){let n=e.getQueryCache().find({queryKey:r,exact:!0});o={key:r,baseList:n?.state.data,baseQuery:n,baseUpdateCount:n?.state.dataUpdateCount,runs:new Map},t.set(i,o)}o.runs.set(l.summary.id,l.summary)}u===void 0&&(u=setTimeout(()=>{d()},50),typeof requestAnimationFrame==`function`&&(c=requestAnimationFrame(()=>{d()})));return}let m=d(!0);for(let t of p)s(t,m),l.type===`run-summary`?e.setQueryData(t,e=>o(e,l.summary)):e.setQueryData(t,e=>a(e,l.id));for(let e of m)r(e)},flush:d,cancel(){i(),n.clear()}}}var me=400;function he(e){let t=new Map,n=new Map,r=(t,r)=>{if(r&&!e.getQueryState(t))return;let i=JSON.stringify(t);n.has(i)||n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:t})},me))};return{onSummary(e,n){let i=e.delegation?.role===`worker`?e.delegation.parentRunId:void 0,a=e.delegation?.role===`worker`?e.delegation.supervisorRunId:void 0,o=t.get(e.id);if(t.set(e.id,{shape:n,...i===void 0?{}:{parentRunId:i},...a===void 0?{}:{supervisorRunId:a}}),o?.shape!==n){r(l.runs.relationships(e.id),!0);for(let e of[i,a])e!==void 0&&r(l.runs.relationships(e),!0)}},onDeleted(n){let i=t.get(n);t.delete(n),e.removeQueries({queryKey:l.runs.relationships(n)}),i?.supervisorRunId!==void 0&&r(l.runs.relationships(i.supervisorRunId),!0),i?.parentRunId===void 0?r([...l.runs.all,`relationships`],!1):r(l.runs.relationships(i.parentRunId),!0)},cancel(){for(let e of n.values())clearTimeout(e);n.clear(),t.clear()}}}var X={predicate:e=>e.queryKey[1]===`runs`&&e.queryKey[2]===`archived`};function ge(e,t){if(t.delegation?.role===`worker`)return;let n=!1;for(let r of e.getQueryCache().findAll(X)){let i=r.state.data;i&&(i.pages.some(e=>e.runs.some(e=>e.id===t.id))?(e.setQueryData(r.queryKey,{...i,pages:i.pages.map(e=>({...e,runs:e.runs.map(e=>e.id===t.id?t:e)}))}),(!t.archived||r.queryKey[3]!==``)&&(n=!0)):t.archived&&(n=!0))}n&&e.invalidateQueries(X)}function _e(e,t,n,r,i){switch(n.type){case`run-summary`:{let t=n.summary;if(ge(e,t),i.onSummary(t,n.relationships),r.fetcher.onEvent(t.id),t.delegation?.role===`worker`){let n=t.delegation.parentRunId;M(e,l.runs.detail(n)),r.refreshParent(n)}let a=l.runs.changes(t.id);e.getQueryData(a)!==void 0&&e.invalidateQueries({queryKey:a}),e.invalidateQueries({queryKey:l.worktrees}),K(e);return}case`run-deleted`:i.onDeleted(n.id),r.fetcher.forget(n.id),e.removeQueries({queryKey:l.runs.detail(n.id)}),e.removeQueries({queryKey:l.runs.diff(n.id)}),e.setQueriesData(X,e=>e&&e.pages.some(e=>e.runs.some(e=>e.id===n.id))?{...e,pages:e.pages.map(e=>({...e,runs:e.runs.filter(e=>e.id!==n.id)}))}:e),e.invalidateQueries(X),e.invalidateQueries({queryKey:l.worktrees}),K(e);return;case`usage`:t.set(n.usage);return;case`ping`:case`ready`:return}}function ve(e,t,n,r){if(n!==b()){if(r.type===`run-summary`){let i=r.summary;if(t.fetcher.onEvent(i.id,n),i.delegation?.role===`worker`){let r=i.delegation.parentRunId;M(e,[n,`runs`,`detail`,r]),t.refreshParent(r,n)}return}t.fetcher.forget(r.id,n),e.removeQueries({queryKey:[n,`runs`,`detail`,r.id]}),e.removeQueries({queryKey:[n,`runs`,`diff`,r.id]})}}function ye(e,t=y(se)){let n=C();(0,F.useEffect)(()=>{let a=P;if(typeof a!=`function`)return;let o=null,c=i(n),u=S()?null:h(n),f=()=>{let e=o?.requestReady;return typeof e==`function`&&e.call(o)};c.setUnknownGenerationHandler(f),u?.setUnknownGenerationHandler(f);let p=ie(n),m=ae(n),g={fetcher:m,refreshParent:p.refresh},_=d(),v=pe(n),y=he(n),b=!1,x,C=!1,w=!1,T=!1,E=!1,k=()=>{T=!0,E=!1;let e=r.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(w||!E){T=!1;return}k()})},M=()=>{w||x!==void 0||(x=setTimeout(()=>{x=void 0,w||N()},ce))},N=()=>{o?.close(),o=new a(t,{withCredentials:!0}),o.addEventListener(`open`,()=>{b=!0,_.reset(),c.detach(),u?.detach(),O(!1),C&&(v.flush(),q(n)),C||(D(()=>W(n)),n.cancelQueries({queryKey:l.health}).then(()=>{w||n.invalidateQueries({queryKey:l.health})}),c.reconcile()),C=!0});for(let t of le)o.addEventListener(t,r=>{let i=s(t,r.data);if(!i)return;if(i.event.type===`ready`){let e=_.ready(i.event.seq);c.ready(i.event.generation,i.event.seq),u?.ready(i.event.generation),e&&(v.flush(),q(n));return}let a=(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&_.frame(i.event.seq);i.event.type===`ping`&&b&&(b=!1,D(()=>W(n)),O(!0)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`?c.run(i.project,i.event,a):i.event.type===`usage`&&c.usage(i.project,i.event.usage)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&(v.onEvent(i.project,i.event),ve(n,g,i.project,i.event)),(i.project===null||i.project===J(n))&&_e(n,e,i.event,g,y),a&&(v.flush(),q(n))});u&&oe(o,n,u);for(let e of ue)o.addEventListener(e,t=>{let i;try{i=JSON.parse(t.data)}catch{return}if(e===`project-ready`)c.reconcile({hold:!0});else if(e!==`checkout-progress`&&e!==`automation-change`){n.invalidateQueries({queryKey:r.projects});let e=n.getQueryState(j.hostsProjects);e&&A(e.data,e.status===`error`)&&n.invalidateQueries({queryKey:j.hostsProjects,exact:!0})}if(e===`project-added`){let e=i?.project?.id;typeof e==`string`&&e!==``&&c.restoreProject(e),c.reconcile({hold:!0})}if(e===`project-removed`){let e=i?.id;typeof e==`string`&&e!==``&&c.dropProject(e)}for(let t of[...B])t(e,i)});o.addEventListener(`health`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=ne.safeParse(t);r.success&&(n.cancelQueries({queryKey:l.health}),n.setQueryData(l.health,r.data))}),o.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let i=ee(t);if(!i)return;let a=r.providerStatus,o=te(n.getQueryData(a),i);if(o!==void 0){n.setQueryData(a,o);return}if(T){E=!0;return}k()}),o.addEventListener(`error`,()=>{O(!1),c.detach(),u?.detach(),o?.readyState===z&&M()})},F=()=>{document.visibilityState===`visible`&&(v.flush(),c.flush(),u?.flush(),(!o||o.readyState===z)&&(clearTimeout(x),x=void 0,N()))},I=()=>{clearTimeout(x),x=void 0,v.flush()};document.addEventListener(`visibilitychange`,F),window.addEventListener(`pagehide`,I);let L=re((e,t)=>(v.flush(),q(n,e,t)));return N(),()=>{L(),w=!0,O(!1),clearTimeout(x),v.flush(),v.cancel(),c.stop(),u?.stop(),p.cancel(),m.cancel(),c.setUnknownGenerationHandler(void 0),u?.setUnknownGenerationHandler(void 0),y.cancel(),document.removeEventListener(`visibilitychange`,F),window.removeEventListener(`pagehide`,I),o?.close(),o=null}},[n,e,t])}var Z=(0,F.createContext)(null);function be({children:e}){let[t]=(0,F.useState)(p);return ye(t),v(),(0,R.jsx)(Z.Provider,{value:t,children:e})}function xe(e){let t=(0,F.useContext)(Z),n=t?t.get:Se;return(0,F.useSyncExternalStore)(t?t.subscribe:Q,()=>e?n()[e]:void 0,()=>void 0)}var Q=()=>()=>void 0,Se=()=>u,Ce=`Label`,$=F.forwardRef((e,t)=>(0,R.jsx)(N.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));$.displayName=Ce;var we=$;function Te({className:e,...t}){return(0,R.jsx)(we,{"data-slot":`label`,className:k(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}export{xe as i,be as n,V as r,Te as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{h as n,n as r,p as i}from"./host-context-iTMFRMT5.js";import{$ as a,$n as o,$t as s,A as c,An as l,Ar as u,Bi as d,Br as f,C as p,Cn as m,Cr as ee,Ct as h,D as g,Dn as _,Dr as v,Dt as y,E as te,En as b,Er as x,Et as S,F as ne,Fr as re,G as ie,Gi as C,Hi as ae,Ht as oe,Ii as se,Ir as ce,It as le,J as ue,Ji as w,Jt as de,K as T,Kt as fe,L as pe,Li as E,Mn as me,Mr as he,Mt as ge,N as _e,Nr as ve,Nt as ye,O as be,Ot as xe,Pi as Se,Pn as Ce,Pr as we,Pt as Te,Q as Ee,Qi as De,Qn as Oe,Qt as ke,Ri as Ae,Rr as je,S as Me,Sn as Ne,St as Pe,Tn as Fe,Tr as Ie,Ui as Le,Vi as Re,Vr as ze,Vt as Be,Wi as Ve,Wt as He,X as Ue,Xn as We,Xt as Ge,Y as Ke,Yi as qe,Yt as Je,Zi as Ye,Zt as Xe,_n as Ze,_t as Qe,a as $e,an as et,ar as tt,b as nt,bn as rt,bt as it,ca as D,ci as at,cn as ot,ct as st,da as ct,en as lt,et as ut,fn as dt,gn as ft,gt as pt,h as mt,hn as ht,in as gt,ir as _t,jn as vt,jr as yt,k as bt,kn as xt,kt as St,ln as Ct,m as wt,ma as Tt,mn as Et,n as Dt,nn as Ot,oa as kt,on as At,pn as jt,pt as Mt,q as Nt,qt as Pt,ra as Ft,sn as It,ta as Lt,tn as Rt,ua as zt,v as Bt,vt as Vt,wn as Ht,wt as Ut,x as Wt,xn as Gt,xt as Kt,y as qt,yn as Jt,yt as Yt,zi as Xt,zr as Zt}from"./toaster-Dglox5F-.js";import{A as Qt,B as O,F as k,H as A,I as j,N as M,P as N,W as P,Z as F,a as $t,j as I,z as L}from"./live-protocol-CNUmr-VT.js";import{c as en}from"./dist-CCX8mhHc.js";import{t as tn}from"./host-storage-Cr_NKfWy.js";function nn(e,t){return e??t}function rn(e,t){let n=nn(e,t);return n===`1`||n===`true`}function an(e,t,n){return e?.trim()||nn(t,n)||``}var on=class extends Ye{#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||sn(),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=De({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),F.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function sn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var cn=class extends Tt{#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),zt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Lt(t.mutationKey)!==Lt(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??sn();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){F.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 ln(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function un(e,t,n){let r=e.slice(0);return r[t]=n,r}var dn=class extends Tt{#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,F.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||!zt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(ln(e,n).forEach(e=>{e.destroy()}),ln(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=D(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 qe(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=un(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)&&F.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},R=e(t(),1);function z({queries:e,...t},n){let r=w(n),i=C(),a=Ve(),o=R.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ae(e);let t=r.getQueryCache().get(e.queryHash);Re(e,a,t)}),Le(a);let[s]=R.useState(()=>new dn(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;R.useSyncExternalStore(R.useCallback(e=>f?s.subscribe(F.batchCalls(e)):kt,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),R.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>d(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&d(n,e)?Xt(n,new qe(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&ae({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function B(e,t){let n=w(t),[r]=R.useState(()=>new cn(n,e));R.useEffect(()=>{r.setOptions(e)},[r,e]);let i=R.useSyncExternalStore(R.useCallback(e=>r.subscribe(F.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=R.useCallback((e,t)=>{r.mutate(e,t).catch(kt)},[r]);if(i.error&&ct(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function V(e={}){let t=e.projectId??n(),r=e.cacheScope??(e.boot?`default`:t);return e.hostId===void 0?{projectId:t,cacheScope:r}:{projectId:t,cacheScope:r,hostId:e.hostId}}function H(e,t={}){return{...V(t),runId:e}}function fn(){return rn(void 0,void 0)}function U(e){return!fn()&&e}async function pn(e){return l(await _.api.v1.health.$get({},b(e)),`/health`)}async function mn(e){return vt(await _.api.v1.hosts.$get({},b(e)),`/hosts`,we)}async function hn(e){return vt(await _.api.v1.hosts.projects.$get({},b(e)),`/hosts/projects`,re)}async function gn(e){return vt(await _.api.v1.hosts[`runs-index`].$get({query:e?.hostId?{hostId:e.hostId}:{}},b(e)),`/hosts/runs-index`,ce)}async function _n(e){return l(await _.api.v1.workspace[`ui-state`].$get({},b(e)),`/workspace/ui-state`)}async function vn(e,t={}){return l(await _.api.v1.workspace[`ui-state`].$put({json:e},{init:{...en({keepalive:t.keepalive})}}),`/workspace/ui-state`)}O({runs:j(`summary`).optional()});var yn=P().min(1),bn=L().int().positive(),xn=O({project:yn,seq:bn,run:ze,relationships:P().min(1)}),Sn=O({project:yn,seq:bn,id:P().min(1)}),Cn=O({generation:P().min(1),seq:L().int().nonnegative()}),wn=O({project:yn,usage:A(P(),je)});O({runs:M(f),referenceStatuses:Zt,perProjectLimit:L(),truncated:M(P()),generation:P().min(1),eventSeq:L().int().nonnegative()});function Tn(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=xn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=Sn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=wn.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=Cn.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}var En=[x,Ie,v,ee];function Dn(e,t){let n;try{n=JSON.parse(t)}catch{return null}switch(e){case x:{let e=yt.safeParse(n);return e.success?{type:`host-run-summary`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,summary:e.data.run}:null}case Ie:{let e=u.safeParse(n);return e.success?{type:`host-run-deleted`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,id:e.data.id}:null}case v:{let e=he.safeParse(n);return e.success?{type:`host-usage`,hostId:e.data.hostId,project:e.data.project,usage:e.data.usage}:null}case ee:{let e=ve.safeParse(n);return e.success?{type:`hosts-changed`,...e.data}:null}default:return null}}function On(){let e,t;return{ready(n){t=void 0;let r=e!==void 0&&n>e;return e=n,r},frame(n){if(t!==void 0&&n<=t)return!1;let r=e!==void 0&&n!==e+1;return e=n,r},seed(n){t=t===void 0?n:Math.max(t,n),e=e===void 0?n:Math.max(e,n)},reset(){e=void 0,t=void 0}}}function kn(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function An(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var jn=Object.freeze({});function Mn(){let e=jn,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}function Nn(e){return e.type===`run`?e.run.id:e.id}function Pn(e,t){return{...e,runs:t}}function Fn(e,t){let n=0;for(let r of e)t(r)&&r.archived&&(n+=1);return n}var In=new WeakMap,Ln=new WeakMap;function Rn(e,t){let n=new Map,r=new Map;for(let i=0;i<e.length;i+=1){let a=e[i],o=t(a),s=n.get(o);if(s||(s=new Map,n.set(o,s)),s.set(a.id,i),a.usage!==void 0){let e=r.get(o);e||(e=new Set,r.set(o,e)),e.add(a.id)}}return In.set(e,n),Ln.set(e,r),{positions:n,liveUsage:r}}var zn=class{runs;copied=!1;positions;liveUsage;liveUsageCopied=!1;scopeOf;constructor(e,t){this.runs=e,this.scopeOf=t;let n=In.get(e),r=Ln.get(e);if(n&&r)this.positions=n,this.liveUsage=r;else{let n=Rn(e,t);this.positions=n.positions,this.liveUsage=n.liveUsage}}reindex(){let e=Rn(this.runs,this.scopeOf);this.positions=e.positions,this.liveUsage=e.liveUsage,this.liveUsageCopied=!0}mutableLiveUsage(){if(!this.liveUsageCopied){let e=new Map;for(let[t,n]of this.liveUsage)e.set(t,new Set(n));this.liveUsage=e,this.liveUsageCopied=!0,this.copied&&Ln.set(this.runs,this.liveUsage)}return this.liveUsage}at(e,t){return this.positions.get(e)?.get(t)??-1}liveUsageIds(e){return this.liveUsage.get(e)}setLiveUsage(e,t,n){let r=this.mutableLiveUsage();if(n){let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(t)}else{let n=r.get(e);if(!n)return;n.delete(t),n.size===0&&r.delete(e)}}mutable(){return this.copied||(this.runs=[...this.runs],this.copied=!0,In.set(this.runs,this.positions),Ln.set(this.runs,this.liveUsage)),this.runs}replace(e,t){let n=this.runs[e];return this.mutable()[e]=t,n?.usage!==void 0!=(t.usage!==void 0)&&this.setLiveUsage(this.scopeOf(t),t.id,t.usage!==void 0),this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}},Bn=e=>e.projectId,Vn=(e,t)=>`${e}\u0000${t}`,Hn=e=>Vn(e.hostId,e.projectId);function Un(e,t,n){let r=new zn(e.runs,Bn),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=Zn(i,e.project,e.usage,r);else{let t=qn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function Wn(e,t,n){let r=new zn(e.runs,Hn),i=e.runs,a=new Set,o=!1;for(let s of t){if(s.type===`usage`){i=Xn(i,Vn(s.hostId,s.project),s.usage,r);continue}let{hostId:t,project:c}=s.change,l=e.hosts.find(e=>e.id===t);if(!l||!l.loaded){a.add(t);continue}let u=n?.(t,c);s.change.type===`run`&&u===!1&&(o=!0);let d=Kn(i,s.change,{scope:Vn(t,c),id:Nn(s.change),inScope:e=>e.hostId===t&&e.projectId===c,truncated:l.truncated.includes(c),perProjectLimit:l.perProjectLimit,isKnownScope:()=>!0,buildRow:e=>({hostId:t,projectId:c,...e})},r);i=d.runs,d.reconcile&&a.add(t)}return{index:i===e.runs?e:{...e,runs:i},reconcile:!1,reconcileHosts:[...a],refreshProjects:o}}function Gn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Kn(e,t,n,r){let i=r.at(n.scope,n.id),a=i>=0?e[i]:void 0;if(t.type===`deleted`)return a?{runs:r.remove(i),reconcile:n.truncated&&a.archived}:{runs:e,reconcile:!1};let{run:o}=t;if(o.delegation?.role===`worker`)return a?{runs:r.remove(i),reconcile:!1}:{runs:e,reconcile:!1};if(!a&&!n.isKnownScope())return{runs:e,reconcile:!0};let s=D(a,n.buildRow(o));if(a){if(s===a)return{runs:e,reconcile:!1};let t=r.replace(i,s);return{runs:t,reconcile:a.archived!==s.archived&&(n.truncated||n.perProjectLimit!==void 0&&Fn(t,n.inScope)>n.perProjectLimit)}}if(n.truncated)return Yn(e,s,n.inScope,r);let c=r.insert(s);return{runs:c,reconcile:s.archived&&n.perProjectLimit!==void 0&&Fn(c,n.inScope)>n.perProjectLimit}}function qn(e,t,n,r){let{project:i}=t,a=Kn(e.runs,t,{scope:i,id:Nn(t),inScope:e=>e.projectId===i,truncated:e.truncated.includes(i),perProjectLimit:e.perProjectLimit,isKnownScope:()=>Gn(e,i,n),buildRow:e=>({projectId:i,...e})},r);return{index:a.runs===e.runs?e:Pn(e,a.runs),reconcile:a.reconcile}}function Jn(e,t){let n;for(let r of e)t(r)&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function Yn(e,t,n,r){let i=Jn(e,n),a=i!==void 0&&t.createdAt>i;return t.archived&&!a?{runs:e,reconcile:!1}:{runs:r.insert(t),reconcile:t.archived||i===void 0||t.createdAt<i}}function Xn(e,t,n,r){let i=!1;for(let[e,a]of Object.entries(n)){let n=r.at(t,e);if(n<0)continue;let o=r.runs[n],s=D(o.usage,a);s!==o.usage&&(r.replace(n,{...o,usage:s}),i=!0)}let a=r.liveUsageIds(t);if(a)for(let e of[...a]){if(Object.prototype.hasOwnProperty.call(n,e))continue;let a=r.at(t,e);if(a<0)continue;let o=r.runs[a];if(o.usage===void 0)continue;let{usage:s,...c}=o;r.replace(a,c),i=!0}return i?r.runs:e}function Zn(e,t,n,r){let i=Xn(e.runs,t,n,r);return i===e.runs?e:Pn(e,i)}function Qn(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function $n(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function er(e,t,n){if(e.lastStream===t)e.floor=n===void 0?void 0:Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function tr(e){e.stream=void 0}function nr(e,t){return`hostId`in t?JSON.stringify([e,t.hostId,t.project,Nn(t)]):JSON.stringify([e,t.project,Nn(t)])}function rr(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=nr(r,t),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}var ir=1e3;function ar(e,t=ir){if(e.changes.size<=t)return;let n=[...e.changes.entries()].sort((e,t)=>e[1].seq-t[1].seq),r=n.length-t,i;for(let t=0;t<r;t+=1){let[r,a]=n[t];e.changes.delete(r),a.generation===e.lastStream&&(i=i===void 0?a.seq:Math.max(i,a.seq))}i!==void 0&&(e.floor=e.floor===void 0?i:Math.max(e.floor,i))}function or(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function sr(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function cr(e,t,n){if(e.stream!==void 0&&e.stream!==t){let n=e.mismatch!==t;return e.mismatch=t,{mismatch:!0,first:n}}let r=e.lastStream===t&&e.floor!==void 0,i=r&&n<e.floor,a=[...e.changes.entries()].filter(([,e])=>e.generation===t);return{mismatch:!1,covered:r,missed:i,own:a,newer:a.map(([,e])=>e).filter(e=>e.seq>n).sort((e,t)=>e.seq-t.seq)}}function lr(e,t,n){if(!sr(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t,a=cr(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first};let o=Un(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return a.covered&&!a.missed&&(e.floor=i),{index:o.index,reconcile:a.missed||o.reconcile}}function ur(e,t,n){if(!sr(t))return{index:t,reconcile:!1,reconcileHosts:[]};let{generation:r,eventSeq:i}=t,a=cr(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first,reconcileHosts:[]};let o=Wn(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return(a.covered&&!a.missed||e.lastStream===r&&e.floor===void 0)&&(e.floor=i),{index:o.index,reconcile:a.missed,reconcileHosts:o.reconcileHosts,refreshProjects:o.refreshProjects}}function dr(e,t,n){if(e.length===0)return t;let r=In.get(e)??Rn(e,n).positions,i=e.length===t.length,a=!1,o=[];for(let s=0;s<t.length;s+=1){let c=t[s],l=r.get(n(c))?.get(c.id),u=l===void 0?void 0:e[l],d=u===void 0?c:D(u,c);d===u&&(a=!0),i&&d!==e[s]&&(i=!1),o.push(d)}return i?e:a?o:t}function fr(e,t){if(!e||e.generation!==t.generation)return t;let n=dr(e.runs,t.runs,Bn),r=D(e.referenceStatuses,t.referenceStatuses),i=D(e.truncated,t.truncated);return n===e.runs&&r===e.referenceStatuses&&i===e.truncated&&t.perProjectLimit===e.perProjectLimit&&t.eventSeq===e.eventSeq?e:n===t.runs&&r===t.referenceStatuses&&i===t.truncated?t:{...t,runs:n,referenceStatuses:r,truncated:i}}function pr(e,t){if(!e||e.generation!==t.generation)return t;let n=dr(e.runs,t.runs,Hn),r=D(e.hosts,t.hosts);return n===e.runs&&r===e.hosts&&t.eventSeq===e.eventSeq&&t.warning===e.warning?e:n===t.runs&&r===t.hosts?t:{...t,runs:n,hosts:r}}function mr(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)(e[r].createdAt??``)>=t[i].createdAt?n.push(e[r++]):n.push(t[i++]);for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}function hr(e,t,n,r,i){if(t.generation!==e.generation||r.stream!==void 0&&r.stream!==t.generation)return{index:e,fullReconcile:!0,reconcileHosts:[]};let a=[...r.changes.entries()].filter(([,e])=>e.generation===t.generation&&e.hostId===n),o=Wn(t,a.map(([,e])=>e).filter(e=>e.seq>t.eventSeq).sort((e,t)=>e.seq-t.seq).map(e=>({type:`change`,change:e})),i);for(let[e,n]of a)n.seq<=t.eventSeq&&r.changes.delete(e);let s=o.index.hosts.find(e=>e.id===n),c=e.hosts.some(e=>e.id===n),l=s?c?e.hosts.map(e=>e.id===n?s:e):[...e.hosts,s]:e.hosts.filter(e=>e.id!==n);return{index:{runs:mr(e.runs.filter(e=>e.hostId!==n),o.index.runs.filter(e=>e.hostId===n)),hosts:l,generation:e.generation,eventSeq:e.eventSeq,...t.warning===void 0?{}:{warning:t.warning}},fullReconcile:!1,reconcileHosts:o.reconcileHosts}}var gr=[`workspace`,`runs-index`],W=[`main`,`hosts`,`runs-index`],_r=[`workspace`,`projects`],vr=[`main`,`hosts`,`projects`],yr=6e4,br=100,xr=new WeakMap,Sr=new WeakMap;function Cr(e){let t=xr.get(e);return t||(t=Pr(e),xr.set(e,t)),t}function wr(e){let t=Sr.get(e);return t||(t=Rr(e),Sr.set(e,t)),t}function Tr(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cr(t).merge(e)}function Er(e){let t=e.getQueryData(_r)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function Dr(e){let t=e.getQueryData(vr)?.hosts;if(!t)return;let n=new Map;for(let e of t)e.projects!==null&&n.set(e.id,new Set(e.projects.map(e=>e.id)));return(e,t)=>n.get(e)?.has(t)}function Or(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function kr(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function Ar(e){return e.type===`host-run-summary`?{type:`run`,hostId:e.hostId,project:e.project,seq:e.seq,run:e.summary}:{type:`deleted`,hostId:e.hostId,project:e.project,seq:e.seq,id:e.id}}function jr(e){let t,n,r=-1/0;return{markWrite(){r=Date.now()},cancelPending:()=>{t!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),t=void 0,clearTimeout(n),n=void 0},schedule(){if(n!==void 0)return;let i=r+250-Date.now();if(i>0){n=setTimeout(e,i);return}n=setTimeout(e,br),typeof requestAnimationFrame==`function`&&(t=requestAnimationFrame(e))}}}function Mr(e){let t,n,r=!1,i=()=>{clearTimeout(t),t=void 0;let a=e().catch(()=>void 0).finally(()=>{n===a&&(n=void 0,r&&(r=!1,i()))});return n=a,a};return{isInFlight(){return n!==void 0},reconcile(e={}){return n?(r=!0,n):e.hold?(t??=setTimeout(()=>{i()},400),Promise.resolve()):i()},stop(){clearTimeout(t),t=void 0,r=!1}}}function Nr(e,t){let n=e.getQueryCache().find({queryKey:t,exact:!0});return n!==void 0&&n.state.data===void 0&&n.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:t,exact:!0}).then(()=>e.invalidateQueries({queryKey:t})):e.invalidateQueries({queryKey:t})}function Pr(e){let t=$n(),n=[],r=new Set,i=!1,a,o=!1,s=()=>e.getQueryData(gr),c=Mr(()=>Nr(e,gr)),l=()=>{if(!i){if(i=!0,a?.()){o=!0;return}c.reconcile({hold:!0})}},u=()=>{d.cancelPending();let t=n;n=[];let i=s();if(!i||t.length===0)return;let a=Er(e),{index:o,reconcile:l}=Un(i,t.filter(e=>e.generation===i.generation?e.type===`usage`?!r.has(e.project):!r.has(e.change.project)&&e.change.seq>i.eventSeq:!1),a);o!==i&&f(o),l&&c.reconcile({hold:!0})},d=jr(u),f=t=>{d.markWrite(),e.setQueryData(gr,t)};return{ready(e,n){er(t,e,n),i=!1,o&&(o=!1,c.reconcile({hold:!0}))},detach(){tr(t)},run(e,i,a=!1){if(r.has(e))return;let o=kr(e,i);if(!rr(t,o,a)){l();return}n.push({type:`change`,change:o,generation:t.stream}),d.schedule()},usage(e,i){if(!r.has(e)){if(t.stream===void 0){l();return}n.push({type:`usage`,project:e,usage:i,generation:t.stream}),d.schedule()}},dropProject(e){r.add(e),or(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let i=s();if(!i)return;let a=Qn(i,e);a!==i&&f(a)},setUnknownGenerationHandler(e){a=e},restoreProject(e){r.delete(e)},merge(n){let i=s(),a=lr(t,n,Er(e));for(let e of r)a.index=Qn(a.index,e);return a.reconcile&&queueMicrotask(()=>{c.reconcile({hold:!0})}),Or(i,n,t.stream)??fr(i,a.index)},reconcile:c.reconcile,flush:u,stop(){d.cancelPending(),c.stop(),n=[]}}}var Fr=[1e3,2e3,4e3,8e3,15e3],Ir=6e4;function Lr(e,t){e.setQueryData(W,e=>{if(!e)return e;let n=e.hosts.find(e=>e.id===t);return!n||n.stale?e:{...e,hosts:e.hosts.map(e=>e.id===t?{...e,stale:!0}:e)}})}function Rr(e,t=e=>gn({hostId:e}),n=Fr,r=Ir,i=e=>gn({signal:e})){let a=$n(),o=On(),s=new Map,c=new Map,l=new Map,u=[],d=!1,f,p=!1,m=!1,ee=!1,h,g,_,v=!1,y=0,te=0,b=new Map,x=()=>e.getQueryData(W),S=()=>e.getQueryCache().find({queryKey:W,exact:!0}),ne=()=>{ee||(ee=!0,e.invalidateQueries({queryKey:vr,exact:!0}).finally(()=>{ee=!1}))},re=e=>{let t=l.get(e);t!==void 0&&(clearTimeout(t),l.delete(e))},ie=()=>{for(let e of l.values())clearTimeout(e);l.clear(),c.clear()},C=Mr(()=>S()?(m=!0,Nr(e,W)):Promise.resolve()),ae=()=>{if(!d){if(d=!0,f?.()){p=!0;return}C.reconcile({hold:!0})}},oe=t=>{if(Lr(e,t),(S()?.getObserversCount()??0)===0)return;let i=c.get(t)??0,a=n[i]??r;c.set(t,i+1),re(t),l.set(t,setTimeout(()=>{l.delete(t),w([t])},a))},se=(t,n)=>{let r=x();if(!r)return!1;if(n.generation!==r.generation||a.stream!==void 0&&a.stream!==n.generation)return C.reconcile(),!0;let i=s.get(t)??r.eventSeq;if(n.eventSeq<i)return oe(t),!1;let o=hr(r,n,t,a,Dr(e));if(o.fullReconcile)return C.reconcile(),!0;re(t),c.delete(t),o.index.hosts.some(e=>e.id===t)?s.set(t,n.eventSeq):s.delete(t);let l=pr(r,o.index);return l!==r&&fe(l),!1},ce=(t={})=>{let n=S();if(!n)return Promise.resolve();if(n.getObserversCount()===0)return e.invalidateQueries({queryKey:W,exact:!0,refetchType:`none`}),Promise.resolve();if(!x())return C.reconcile(t)},le=()=>{let t=S();return!t||t.state.fetchStatus!==`fetching`?Promise.resolve():new Promise(n=>{let r=e.getQueryCache().subscribe(e=>{e.query===t&&t.state.fetchStatus!==`fetching`&&(r(),n())})})},ue=()=>{clearTimeout(h),h=void 0;let e=y;if(_||v)return(_??Promise.resolve()).then(()=>{if(!(y!==e||b.size===0))return ue()});if(g)return g;let n=[...b.entries()];if(b.clear(),n.length===0)return Promise.resolve();let r=ce();if(r)return r;let i=(async()=>{for(let r=0;r<n.length;r+=1){let[i,a]=n[r];if(y!==e)break;if(v){for(let e=r;e<n.length;e+=1){let[t,r]=n[e];b.has(t)||b.set(t,r)}break}try{let n=await t(i);if(y!==e||se(i,n))break}catch{y===e&&(v?b.has(i)||b.set(i,a):oe(i))}}})().finally(()=>{g===i&&(g=void 0,!v&&!_&&y===e&&b.size>0&&ue())});return g=i,i},w=(e,t={})=>{if(e.length===0)return Promise.resolve();let n=ce(t);if(n)return n;for(let t of e)b.set(t,++te);return g||(t.hold&&!_&&!v?(h??=setTimeout(()=>{ue()},400),Promise.resolve()):ue())},de=()=>{T.cancelPending();let t=u;u=[];let n=x();if(!n||t.length===0)return;let{index:r,reconcileHosts:i,refreshProjects:a}=Wn(n,t.filter(e=>{if(e.generation!==n.generation)return!1;if(e.type===`usage`)return!0;let t=s.get(e.change.hostId)??n.eventSeq;return e.change.seq>t}),Dr(e));r!==n&&fe(r),a&&ne(),i.length>0&&w(i,{hold:!0})},T=jr(de),fe=t=>{T.markWrite(),e.setQueryData(W,t)},pe=t=>{let n=x(),r=ur(a,t,Dr(e)),i=Or(n,t,a.stream)??(s.clear(),ie(),(a.stream===t.generation||a.lastStream===t.generation)&&o.seed(t.eventSeq),pr(n,r.index));return r.refreshProjects&&queueMicrotask(ne),r.reconcile?queueMicrotask(()=>{C.reconcile({hold:!0})}):r.reconcileHosts.length>0&&queueMicrotask(()=>{w(r.reconcileHosts,{hold:!0})}),i};return{ready(e){let t=a.lastStream;er(a,e),d=!1;let n=x(),r=t!==void 0&&t!==e||n!==void 0&&n.generation!==e,i=t===void 0&&(n!==void 0||S()?.state.fetchStatus===`fetching`),s=m&&C.isInFlight();m=!1,r?o.reset():i&&n&&o.seed(n.eventSeq),(r||p||i)&&!s?(p=!1,C.reconcile({hold:!0})):s&&(p=!1)},detach(){tr(a),o.reset(),m=!1},run(e){let t=o.frame(e.seq),n=Ar(e);if(!rr(a,n,t)){ae();return}ar(a),u.push({type:`change`,change:n,generation:a.stream}),T.schedule(),t&&C.reconcile({hold:!0})},usage(e,t,n){if(a.stream===void 0){ae();return}u.push({type:`usage`,hostId:e,project:t,usage:n,generation:a.stream}),T.schedule()},setUnknownGenerationHandler(e){f=e},fetchFull:e=>{v=!0,clearTimeout(h),h=void 0;let t=y,n=_,r=g,a=(async()=>{if(n&&await n,r&&await r.catch(()=>void 0),e?.aborted)throw e.reason??new DOMException(`Aborted`,`AbortError`);let t=te,a=await i(e);for(let[e,n]of[...b.entries()])n<=t&&b.delete(e);return pe(a)})(),o;return o=a.then(()=>le(),()=>void 0).then(()=>{_===o&&(_=void 0,v=!1,y===t&&b.size>0&&ue())}),_=o,a},merge:pe,reconcile:C.reconcile,reconcileHosts:w,reconcileFinite(){let t=x();if(!t)return C.reconcile();let n=e.getQueryData(vr)?.hosts??[],r=[...new Set([...t.hosts.map(e=>e.id),...n.map(e=>e.id)])];return r.length===0?C.reconcile():w(r)},flush:de,stop(){y+=1,v=!1,_=void 0,g=void 0,T.cancelPending(),C.stop(),clearTimeout(h),h=void 0,ie(),b.clear(),u=[]}}}var zr=(e,t,n)=>[`host`,e,t,`runs`,`detail`,n],G={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t,r=n())=>[r,`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n,r)=>{let i=[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)];return r===void 0?i:[`host`,r,...i]},githubComments:(e,t)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},K={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:gr,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...K.fsBrowseRoot,e,t]};function Br(e,t=!0,n=!1,r){return E({queryKey:[V({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>ye(V({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function q(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:K.models(t),refetchType:n})}function Vr(e,t=!0,n){return E({...Hr(e,n),enabled:t})}var Hr=(e,t)=>({queryKey:K.models(e,t),queryFn:({signal:n})=>me(e,{signal:n},t),staleTime:300*1e3});function Ur(e,t=!0){let n=z({queries:e.map(e=>({...Hr(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var Wr=I([`own`,`provider-spanning`]),Gr=O({suggested:M(O({id:P(),label:P(),desc:P()})),retired:M(P())}),Kr=O({id:I([`settings`,`mcp`,`memory`]),label:P(),note:P().optional(),empty:P().optional(),showsUserMcp:j(!0).optional()}),qr=O({label:P(),note:P().optional(),groups:M(Kr)}),Jr=O({runners:M(O({id:Se,displayName:P(),modelListName:P(),modelIdScope:Wr,pickerLabel:P(),pickerDescription:P(),icon:P(),installHint:P(),loginCommand:P(),terminalLogin:N().optional(),browserLogin:N().optional(),managedInstall:j(!0).optional(),accountFolderExample:P().optional(),models:Gr,agentConfig:qr}))}),Yr=[`workspace`,`runners`];async function Xr(e){return vt(await Ht.api.v1.runners.$get({},b(e)),`/runners`,Jr)}var Zr={queryKey:Yr,queryFn:({signal:e})=>Xr({signal:e}),staleTime:1/0};function Qr(){return E(Zr)}function $r(e){return e?.runners??[]}function ei(e){return $r(e).map(e=>e.id)}function ti(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function ni(e){let t=Qr();return{runner:t.isSuccess?ti(e,ei(t.data))??e:e,ready:!t.isPending}}function ri(e,t){return e?.runners.find(e=>e.id===t)}function ii(e,t){return ri(e,t)?.displayName??t}function ai(e,t){return ri(e,t)?.pickerLabel??t}function oi(e,t){return ri(e,t)?.modelListName}function si(e,t,r=!0,i){let a=io(i,r),o=oa(),{runner:s,ready:c}=ni(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??n(),d=E({queryKey:G.runnerSkills(s,l,u),queryFn:({signal:e})=>te(s,l,{signal:e,projectId:u}),enabled:r&&c&&(e!==void 0||!a.isPending)&&(!t||!o.isPending),retry:!1});return{...d,runner:s,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var ci={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},li={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function ui(e){return typeof e==`string`&&Object.hasOwn(ci,e)}function di(e){return e!==void 0&&ui(e)?ci[e]:void 0}var fi=`cez.reference-statuses.v1`,pi=`cez.reference-conflicts.v1`,J=new Map(yi()),mi=1e3,Y=new Set(bi()),hi=r()??`__local__`;function gi(){let e=r()??`__local__`;if(hi!==e){hi=e,clearTimeout(xi),xi=void 0,J.clear();for(let[e,t]of yi())J.set(e,t);Y.clear();for(let e of bi())Y.add(e)}}function _i(e,t){if(gi(),J.get(e)!==t){for(J.delete(e),J.set(e,t);J.size>mi;){let e=J.keys().next().value;if(e===void 0)break;J.delete(e)}Si()}}function vi(e,t){if(gi(),Y.has(e)!==t){if(t)for(Y.add(e);Y.size>mi;){let e=Y.values().next().value;if(e===void 0)break;Y.delete(e)}else Y.delete(e);Si()}}function yi(){try{let e=globalThis.sessionStorage?.getItem(tn(fi));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&ui(e[1])):[]}catch{return[]}}function bi(){try{let e=globalThis.sessionStorage?.getItem(tn(pi));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var xi;function Si(){if(xi!==void 0)return;let e=tn(fi),t=tn(pi);xi=setTimeout(()=>{xi=void 0;try{globalThis.sessionStorage?.setItem(e,JSON.stringify([...J])),globalThis.sessionStorage?.setItem(t,JSON.stringify([...Y]))}catch{}},250)}var Ci=e=>e.hostId===void 0?`${e.projectId}\u0000${e.kind}#${e.number}`:`host:${e.hostId}\u0000${e.projectId}\u0000${e.kind}#${e.number}`;function wi(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Ti(e){let t=e.hostId===void 0?{}:{hostId:e.hostId};return[...e.prs.map(n=>({...t,projectId:e.projectId,kind:`PR`,number:n})),...e.issues.map(n=>({...t,projectId:e.projectId,kind:`Issue`,number:n}))]}function Ei(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;_i(t,o),s!==void 0&&vi(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Di(e,t,n){gi();let r=Ci(t),i=J.get(r),a=Y.has(r)?!0:void 0,o=n.data;if(o?.available){Ei(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...wi(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...wi(i,a)});return}e.set(r,{state:`loading`,...wi(i,a)})}function Oi(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Ti(i))Di(n,e,t)}),n}function ki(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function Ai(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function ji(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function Mi(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Ni(e,t){return tt({kind:`topic`,topic:e},{value:t})}function Pi(){let e=w();return E({queryKey:K.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(K.providerStatus),r=await It(!1,{signal:t});return Ce(n,e.getQueryData(K.providerStatus),r)},staleTime:5*6e4,refetchInterval:U(!1),refetchOnWindowFocus:!0})}function Fi(){let e=w();return B({mutationFn:()=>It(!0),onMutate:()=>e.getQueryData(K.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(K.providerStatus,e=>Ce(r,e,t)),q(e)}})}function Ii(){let e=w();return B({mutationFn:({provider:e,authFailureId:t})=>ft(e,t),onMutate:()=>e.getQueryData(K.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(K.providerStatus,e=>Ce(r,e,t,n.authFailureId)),q(e,n.provider)}})}function Li(e={}){return E({queryKey:K.projects,queryFn:({signal:e})=>At({signal:e}),...e})}function Ri(e,t=!1){return E({queryKey:K.fsBrowse(e,t),queryFn:({signal:n})=>Je(e??void 0,{signal:n,showHidden:t}),retry:!1})}function zi(){let e=w();return B({mutationFn:e=>dt(e),onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function Bi(){let e=w();return B({mutationFn:e=>Et(e),retry:!1,onSuccess:(t,n)=>{e.setQueryData(K.projects,e=>e&&{...e,projects:e.projects.filter(e=>e.id!==n)}),e.invalidateQueries({queryKey:K.projects})}})}function Vi(){let e=w();return B({mutationFn:e=>{let{id:t,...n}=e;return Gt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:K.projects});let r=e.getQueryData(K.projects);return e.setQueryData(K.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Hi(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(K.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(K.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:K.projects})})}function Hi(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:Mi(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Ui(e){let t=w();return B({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(K.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:K.projects})})}function Wi(){return Ui(e=>{let{projectId:t,...n}=e;return lt(t,n)})}function Gi(){return Ui(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function Ki(){return Ui(({projectId:e,webhookId:t})=>ht(e,t))}function qi(){return B({mutationFn:({projectId:e,webhookId:t})=>Jt(e,t),retry:!1})}function Ji(e){let t=w();return B({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:K.agentProfiles}),t.invalidateQueries({queryKey:K.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),q(t)])},onError:()=>{t.invalidateQueries({queryKey:G.health}),t.invalidateQueries({queryKey:K.agentProfiles,exact:!0})}})}function Yi(){return Ji(e=>ke(e))}function Xi(){return Ji(e=>{let{id:t,...n}=e;return rt(t,n)})}function Zi(){return Ji(e=>jt(e))}function Qi(){return Ji(e=>Ze(e))}function $i(e,t){return E({queryKey:K.agentAccountStatus(e),queryFn:({signal:t})=>Rt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function ea(){let e=w();return B({mutationFn:({provider:e,profileId:t})=>Xe(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:K.agentProfiles}),e.invalidateQueries({queryKey:K.providerStatus}),q(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:G.health}),e.invalidateQueries({queryKey:K.agentProfiles,exact:!0})}})}function ta(){let e=w();return B({mutationFn:e=>Rt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(K.agentAccountStatus(n),t),e.invalidateQueries({queryKey:K.agentProfiles}),q(e,t.status.provider)}})}function na(){let e=w();return B({mutationFn:e=>Ge(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function ra(){let e=w();return B({mutationFn:e=>s(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function ia({enabled:e}){return E({queryKey:K.githubOwners,queryFn:({signal:e})=>gt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function aa(){let e=w();(0,R.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(G.health);n&&(Oe({bootProject:n.bootProject===void 0?`default`:n.bootProject,apiBase:i()}),t??=Ni(`health`,t=>{e.setQueryData(G.health,t)}))};n();let r=e.getQueryCache().subscribe(n);return()=>{r(),t?.(),_t()}},[e])}function oa(){return E({queryKey:G.health,queryFn:({signal:e})=>et({signal:e})})}function sa(e,t){let n=oa().data,r=Li(t).data?.projects,i=$e(),a=e??i.projectId,o=a??n?.bootProject??void 0,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:n?.bootProject!==null&&(a===null||a===n?.bootProject)?ki(n?.repo?.remote):void 0}function ca(e=!0){return E({queryKey:K.uiState,queryFn:({signal:e})=>Ct({signal:e}),enabled:e})}function la(){return E({queryKey:K.config,queryFn:({signal:e})=>ot({signal:e})})}function ua(){return E({queryKey:K.agentProfiles,queryFn:({signal:e})=>Ot({signal:e})})}var da=[`workspace`,`runs-index`],X=e=>[e.cacheScope,`runs`,`list`],Z=e=>e.hostId===void 0?[e.cacheScope,`runs`,`detail`,e.runId]:zr(e.hostId,e.projectId,e.runId),Q=e=>typeof e==`function`?e():e;function fa(e){let{seenAt:t,...n}=e;return n}function pa(e,t){let n=fa(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function ma(e,t,n){return t?{...e,seenAt:n}:fa(e)}function ha(e,t,n){let r={...e},i=t;for(let e of n)Object.prototype.hasOwnProperty.call(i,e)&&i[e]!==void 0?r[e]=i[e]:delete r[e];return r}function ga(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r=[];for(let i of n)Object.is(e[i],t[i])||r.push(i);return r}function _a(e){let t=()=>{e.invalidateQueries({queryKey:da})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(a.hostId!==void 0)return r===`indexed`?void 0:e.invalidateQueries({queryKey:[`host`,a.hostId,a.projectId,`runs`]});if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let s=o(),c=[a.projectId,a.cacheScope],l=s!==void 0&&c.some(e=>e===s||e==="default")?[s,`default`]:[],u=new Set([...c,...l,n()]);return Promise.all([...u].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}let i=(e,t,n)=>r=>r.id===(e?t:n.id)?ma(r,e,n.seenAt):r;async function a(t,n){let r=t.runId,a=new Date().toISOString(),o=e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===r,s=t=>{e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>o(e)?t(e):e)})},c=e.getQueryData(Z(t)),l=e.getQueryData(W)?.runs.find(o);return e.setQueryData(Z(t),e=>e&&ma(e,n,a)),s(e=>ma(e,n,a)),{id:r,prevList:void 0,prevDetail:c,rollback(){c&&e.setQueryData(Z(t),e=>e&&pa(e,c)),l&&s(e=>pa(e,l))},settle(a){let o=i(n,r,a);e.setQueryData(Z(t),e=>e?o(e):a),s(o)}}}async function s(n,r){let o=Q(n);if(o.hostId!==void 0)return a(o,r);await e.cancelQueries({queryKey:X(Q(n))}),await e.cancelQueries({queryKey:Z(Q(n))});let s=e.getQueryData(X(Q(n))),c=e.getQueryData(Z(Q(n))),l=Q(n).runId,u=new Date().toISOString();return e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===l?ma(e,r,u):e)),e.setQueryData(Z(Q(n)),e=>e&&ma(e,r,u)),{id:l,prevList:s,prevDetail:c,rollback(){if(!r){s&&e.setQueryData(X(Q(n)),s),c&&e.setQueryData(Z(Q(n)),c);return}let t=s?.find(e=>e.id===l);t&&e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===l?pa(e,t):e)),c&&e.setQueryData(Z(Q(n)),e=>e&&pa(e,c))},settle(a){let o=i(r,l,a);e.setQueryData(X(Q(n)),e=>e?.map(o));let s={...Q(n),runId:r?l:a.id};e.setQueryData(Z(s),e=>e?o(e):a),t()}}}async function c(t,n){if(t.hostId!==void 0){let r=e.getQueryData(W),i=r?.runs.find(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId),a=n(),o=i?a(i):void 0,s=i&&o?ga(i,o):[];return e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?{...a(e),hostId:e.hostId}:e)}),{previous:r,rollback(){!i||s.length===0||e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?ha(e,i,s):e)})},settle(){}}}await e.cancelQueries({queryKey:da});let i=e.getQueryData(da),a=n();return e.setQueryData(da,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(da,i)},settle(){r(`indexed`,t)}}}return{patchRead:s,patchIndex:c,invalidateAfter:r}}function $(){let e=w();return(0,R.useMemo)(()=>_a(e),[e])}function va(e,t){if(!$t(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),tt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function ya(e,t,n,r){let i=w(),a=JSON.stringify(t),o=(0,R.useMemo)(()=>JSON.parse(a),[a]);(0,R.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=va({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function ba(e,t=!1){return l(await Ht.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),xt(e,`/worker-destroy`))}function xa(){return E({queryKey:G.openTargets,queryFn:({signal:e})=>Kt({signal:e}),staleTime:5*6e4})}function Sa(e=!0,t){return E({queryKey:t?G.runs.list(t):G.runs.list(),queryFn:({signal:e})=>ye(V(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function Ca(e,t){return se({queryKey:G.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>pt({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function wa(e){let t=e.trim();return E({queryKey:K.runsSearch(t),queryFn:({signal:e})=>fe(t,{signal:e}),enabled:t.length>=2,placeholderData:Ft,staleTime:1e4})}function Ta(e=!0,t=yr,n){let r=Cr(w());return ya(`/api/v1/workspace/runs-index`,K.runsIndex,U(e?t:!1),Tr),E({queryKey:K.runsIndex,queryFn:({signal:e})=>Te({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},structuralSharing:!1,staleTime:3e4,refetchInterval:!1})}function Ea(e){let t=w();return B({mutationFn:({workerId:e,discardWork:t=!1})=>ba(e,t),onSettled:()=>t.invalidateQueries({queryKey:G.runs.relationships(e)})})}function Da(e,t={}){return E({queryKey:G.runs.relationships(e),queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t.enabled??!0})}function Oa(e){return E({queryKey:G.runs.detail(e??``),queryFn:({signal:t})=>Pe(H(e),{signal:t}),enabled:!!e})}function ka(e,t,n=!0,r){let i=r?.hostId;return E({queryKey:i===void 0?[e??`default`,`runs`,`detail`,t??``]:zr(i,e??`default`,t??``),queryFn:({signal:n})=>Pe(H(t,{projectId:e,hostId:i}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function Aa(e,t){return E({queryKey:t?[t,`runs`,`diff`,e??``]:G.runs.diff(e??``),queryFn:({signal:n})=>y(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ja(e,t=!1){return ya(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,G.runs.changes(e??``),U(t?4e3:!1)),E({queryKey:G.runs.changes(e??``),queryFn:({signal:t})=>h(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ma(e,t){return E({queryKey:G.runs.file(e??``,t??``),queryFn:({signal:n})=>xe(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Na(e,t){return E({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>it(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Pa(e,t){return E({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Qe(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Fa(e,t){return E({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Vt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ia(e){return E({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Yt(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function La(e,t=!1){return ya(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,G.runs.commits(e??``),U(t?5e3:!1)),E({queryKey:G.runs.commits(e??``),queryFn:({signal:t})=>S(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Ra(e,t){return E({queryKey:G.runs.commit(e??``,t??``),queryFn:({signal:n})=>Ut(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function za(e,t=!0){return E({queryKey:G.runs.handoff(e??``),queryFn:({signal:t})=>St(H(e),{signal:t}),enabled:!!e&&t})}function Ba(e,t,n,r){return E({queryKey:r===void 0?e===void 0?G.runs.handoff(t):[e,`runs`,`handoff`,t]:[`host`,r,e??`default`,`runs`,`handoff`,t],queryFn:({signal:n})=>St(H(t,{projectId:e,hostId:r}),{signal:n}),enabled:n,staleTime:15e3})}function Va(e){return typeof e==`object`&&e?{projectId:e.projectId,hostId:e.hostId}:{projectId:e,hostId:void 0}}function Ha(e,t){let r=new Map;for(let t of e){let e=Va(t);r.set(JSON.stringify([e.hostId??null,e.projectId??null]),e)}let i=[...r.values()],a=z({queries:i.map(({projectId:e,hostId:r})=>({queryKey:r===void 0?[e??n(),`automations`,`names`]:[`host`,r,e??n(),`automations`,`names`],queryFn:({signal:t})=>Bt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e},...r===void 0?{}:{hostId:r}}),enabled:t,staleTime:6e4,retry:!1}))}),o=a.map(e=>e.data);return(0,R.useMemo)(()=>{let e=new Map;return o.forEach((t,n)=>{if(!t?.available)return;let r=i[n];for(let n of t.automations)e.set(JSON.stringify([r.hostId??null,r.projectId??null,n.id]),n.name)}),(t,n,r)=>e.get(JSON.stringify([r??null,t??null,n]))},[JSON.stringify([i,a.map(e=>e.dataUpdatedAt)])])}function Ua(e){let t=w();return B({mutationFn:t=>le(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Wa(e){let t=w();return B({mutationFn:t=>Be(e,t),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Ga(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId,a=B({mutationFn:e=>de(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),o=(0,R.useCallback)(e=>({...H(e,{projectId:n,cacheScope:r,hostId:i}),id:e}),[n,r,i]),s=(0,R.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:c,mutateAsync:l}=a,u=(0,R.useCallback)((e,t)=>c(o(e),s(t)),[c,o,s]),d=(0,R.useCallback)((e,t)=>l(o(e),s(t)),[l,o,s]);return{...a,variables:a.variables?.id,mutate:u,mutateAsync:d}}function Ka(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId;return B({mutationFn:e=>de(H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onMutate:e=>t.patchRead(()=>H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function qa(e){let t=$();return B({mutationFn:({id:t,pinned:n})=>oe(H(t,e),n),onError:e=>Dt(`Could not update pin. ${Fe(e)} Please retry.`,{tone:`danger`}),onMutate:()=>e??V(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ja(e,t,r){let i=$();return B({...r===void 0?{}:{mutationKey:zr(r,t??n(),e)},mutationFn:n=>Pt(H(e,{projectId:t,hostId:r}),n),onMutate:()=>V({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`send`,n),onError:(e,t,n)=>{e instanceof m&&e.status===409&&n&&i.invalidateAfter(`send`,n)}})}function Ya(e,t,r){let i=$();return B({...r===void 0?{}:{mutationKey:zr(r,t??n(),e)},mutationFn:(n={})=>st(H(e,{projectId:t,hostId:r}),n),onMutate:()=>V({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`continue`,n)})}function Xa(e){let t=w();return B({mutationFn:({msgId:t,message:n})=>Mt(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Za(e){let t=w();return B({mutationFn:t=>He(e,t),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Qa(){return E({queryKey:G.workflows,queryFn:({signal:e})=>bt({signal:e})})}function $a(e){return E({queryKey:e?[e,`repo`]:G.repo,queryFn:({signal:t})=>nt({signal:t},e)})}function eo(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>nt({signal:t},e)})}function to(){return E({queryKey:G.repoBranches,queryFn:({signal:e})=>Wt({signal:e})})}function no(){return E({queryKey:G.repoChanges,queryFn:({signal:e})=>Me({signal:e}),retry:!1})}function ro(e){return E({queryKey:G.repoCommit(e??``),queryFn:({signal:t})=>p(e,{signal:t}),enabled:!!e,retry:!1})}function io(e,t=!0){return E({queryKey:e?[e,`config`]:G.config,queryFn:({signal:t})=>qt({signal:t,...e?{projectId:e}:{}}),enabled:t})}function ao(){return E({queryKey:G.worktrees,queryFn:({signal:e})=>c({signal:e})})}function oo(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>c({signal:t},e),staleTime:0})}function so(e,t=!0,n=!1){return E({queryKey:[V({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>be({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:We(e.sidebarLimits)},enabled:t})}function co(e=!0,t){return so(t??n(),e)}function lo(){return E({queryKey:G.agentConfig,queryFn:({signal:e})=>wt({signal:e})})}function uo(e){return E({queryKey:G.agentConfigFile(e??``),queryFn:({signal:t})=>mt(e,{signal:t}),enabled:e!==null})}function fo(){return E({queryKey:G.sessionContext,queryFn:({signal:e})=>g({signal:e})})}function po(e,t,n=``){return E({queryKey:G.sessionContextPreview(e,t,n),queryFn:({signal:n})=>_e({content:e,role:t},{signal:n}),placeholderData:Ft,staleTime:0,retry:!1})}function mo(){let e=w();return B({onMutate:()=>({fileKey:G.sessionContext}),mutationFn:e=>pe(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function ho(e){let t=w(),n=G.agentConfig,r=G.agentConfigFile(e);return B({mutationFn:t=>ne(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var go=I([`passing`,`failing`,`pending`]).nullable(),_o=O({kind:I([`issue`,`pr`]),number:L(),title:P(),author:P(),createdAt:P(),labels:M(P()),body:P().optional(),url:P(),comments:L(),assignees:M(P()).optional(),projectIds:M(P()).optional(),isDraft:N().optional(),additions:L().optional(),deletions:L().optional(),checks:go.optional()});k(`available`,[O({available:j(!0),item:_o.nullable(),labelColors:A(P(),P()).optional()}),O({available:j(!1),reason:P()})]),O({kind:I([`issue`,`pr`]),number:Qt().int().positive().safe()});var vo=O({id:P(),title:P(),url:P()});O({available:N(),reason:P().optional(),repo:P().optional(),syncedAt:P().optional(),issues:M(_o),prs:M(_o),labelColors:A(P(),P()).optional(),viewerLogin:P().optional(),projects:M(vo).optional(),projectsReason:P().optional(),projectsState:I([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:P().optional(),issuesTotal:L().int().nonnegative().optional(),prsTotal:L().int().nonnegative().optional(),issuesNextCursor:P().nullable().optional(),prsNextCursor:P().nullable().optional(),commentsDeferred:j(!0).optional()});var yo=P().min(1).max(2e3).optional();O({limit:P().optional(),refresh:P().optional(),issuesCursor:yo,prsCursor:yo,issuesDone:j(`1`).optional(),prsDone:j(`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`})}),O({kind:I([`issue`,`pr`]),numbers:P().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:j(`1`).optional()}),k(`available`,[O({available:j(!0),counts:A(L(),L().int().nonnegative())}),O({available:j(!1),reason:P()})]),k(`available`,[O({available:j(!0),checks:A(L(),go)}),O({available:j(!1),reason:P()})]),O({kind:I([`issue`,`pr`]),q:P().trim().min(1).max(256),limit:Qt().int().positive().max(50).optional()}),O({available:N(),projectsReason:P().optional(),reason:P().optional(),items:M(_o),truncated:N().optional(),labelColors:A(P(),P()).optional()});var bo=L().nullable();k(`available`,[O({available:j(!0),prs:A(L(),at),issues:A(L(),at),conflicts:M(L()).optional(),recheckAfterMs:bo}),O({available:j(!1),reason:P(),recheckAfterMs:bo})]);var xo=O({id:L(),author:P(),avatarUrl:P().optional(),createdAt:P(),body:P(),kind:I([`comment`,`review`]),reviewState:I([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:P()}),So=I([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),Co=O({id:P(),kind:So,actor:P(),avatarUrl:P().optional(),createdAt:P(),url:P().optional(),sha:P().optional(),message:P().optional(),checks:go.optional(),label:O({name:P(),color:P().optional()}).optional(),subject:P().optional(),refNumber:L().optional(),refTitle:P().optional(),refIsPr:N().optional()});O({available:N(),reason:P().optional(),comments:M(xo),truncated:N().optional(),events:M(Co).optional(),detail:O({body:P(),additions:L().int().nonnegative().optional(),deletions:L().int().nonnegative().optional()}).optional()});var wo=I([`merge`,`squash`,`rebase`]),To=O({name:P(),state:I([`passing`,`failing`,`pending`,`unknown`]),required:N().nullable(),url:P().optional()}),Eo=O({number:L(),title:P(),url:P(),state:I([`open`,`closed`,`merged`]),isDraft:N(),headRef:P(),baseRef:P(),headSha:P(),mergeable:I([`mergeable`,`conflicting`,`unknown`]),reviewDecision:I([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:M(To),methods:M(wo),defaultMethod:wo.nullable(),eligibility:I([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:M(O({code:P(),message:P()})),canMerge:N(),canOverride:N()});k(`available`,[O({available:j(!0),mergeState:Eo}),O({available:j(!1),reason:P()})]),O({merged:j(!0),number:L(),url:P(),method:wo,mergeCommitSha:P().optional()});var Do=O({path:P(),previousPath:P().optional(),status:I([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:L(),deletions:L(),patch:P().optional(),patchUnavailableReason:I([`binary`,`too-large`,`not-provided`]).optional(),truncated:N().optional()});k(`available`,[O({available:j(!0),number:L(),headSha:P(),files:M(Do),additions:L(),deletions:L(),truncated:N(),reason:P().optional()}),O({available:j(!1),reason:P()})]),O({generation:P().uuid()}),k(`state`,[O({generation:P().uuid(),state:j(`ready`),projects:M(vo),membership:A(P(),M(P()))}),O({generation:P().uuid(),state:j(`unavailable`),reason:P()})]);function Oo(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function ko(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Ao(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function jo(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){Ao(t.issues,a,r),Ao(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var Mo=e=>e.map(e=>e.number).join(`,`);function No(e,t){let n=e[0];if(e.length>1&&n&&(Mo(n.issues)!==Mo(t.issues)||Mo(n.prs)!==Mo(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}var Po=class extends Error{};function Fo(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await ie({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Po(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Oo(e),retry:(e,t)=>!(t instanceof Po)&&!(t instanceof m&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Io(e=50,t=!0){let r=w(),i=G.githubPages(e),a=G.githubPagesHead(e);ya(`/api/v1/p/${n()}/github?limit=${e}`,a,U(t?6e4:!1));let o=se({...Fo(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=E({queryKey:a,queryFn:({signal:t})=>ie({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,R.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=No(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=z({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Ee(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,R.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,R.useMemo)(()=>jo(o.data?.pages??[]),[o.data])}}function Lo(e,t=50,n=!0){let r=se({...Fo([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,R.useMemo)(()=>jo(r.data?.pages??[]),[r.data])}}function Ro(e,t,n=!0){let r=z({queries:t.filter(e=>e.length>0).map(t=>({queryKey:G.githubCommentCounts(e,t),queryFn:({signal:n})=>Nt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,R.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function zo(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>ut(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Bo(e,t=!0){return E({queryKey:G.githubChecks(e),queryFn:({signal:t})=>T(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Vo(e,t,n=!0){return E({queryKey:G.githubSearch(e,t),queryFn:({signal:n})=>ut(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ho=100;function Uo(e){return[...e].sort((e,t)=>t-e).slice(0,Ho).sort((e,t)=>e-t)}function Wo(){let e=$e(),t=oa();return e.projectId??t.data?.bootProject??void 0}function Go(e,t){let n=t===void 0?{}:{hostId:t};for(let[t,r]of Object.entries(e)){for(let[e,i]of Object.entries(r.prs))_i(Ci({...n,projectId:t,kind:`PR`,number:Number(e)}),i);for(let[e,i]of Object.entries(r.issues))_i(Ci({...n,projectId:t,kind:`Issue`,number:Number(e)}),i)}}var Ko=5*6e4;function qo(e){return e?e.recheckAfterMs:Ko}function Jo(e,t=!0){let n=(0,R.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.hostId===void 0?n.projectId:`host:${n.hostId}\u0000${n.projectId}`,r=t.get(e)??{...n.hostId===void 0?{}:{hostId:n.hostId},projectId:n.projectId,prs:new Set,issues:new Set};r[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(e,r)}return[...t.values()].map(e=>({...e.hostId===void 0?{}:{hostId:e.hostId},projectId:e.projectId,prs:Uo(e.prs),issues:Uo(e.issues)}))},[e.map(Ci).sort().join(`|`)]),r=z({queries:n.map(e=>({queryKey:G.githubRefStatus(e.projectId,e.prs,e.issues,e.hostId),queryFn:({signal:t})=>a(e.projectId,{prs:e.prs,issues:e.issues},{signal:t,...e.hostId===void 0?{}:{hostId:e.hostId}}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>qo(e.state.data)??1/0,refetchInterval:e.hostId===void 0?!1:e=>U(t&&!fn()?qo(e.state.data)??!1:!1),refetchOnWindowFocus:!0}))}),i=w(),o=JSON.stringify(n.flatMap((e,t)=>e.hostId===void 0?[{projectId:e.projectId,prs:e.prs,issues:e.issues,interval:qo(r[t]?.data)??!1}]:[]));(0,R.useEffect)(()=>{if(!t||fn())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=G.githubRefStatus(t.projectId,t.prs,t.issues);return va({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,i]);let s=(0,R.useMemo)(()=>Oi(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,R.useCallback)(e=>{let t=Ci(e),n=s.get(t);if(n)return n;let r=J.get(t);return{state:`idle`,...r?{status:r}:{},...Y.has(t)?{conflicting:!0}:{}}},[s])}function Yo(e,t,n=!0){return E({queryKey:G.githubComments(e,t),queryFn:({signal:n})=>ue(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Xo(e,t,n=!0){return E({queryKey:G.githubItem(e,t),queryFn:({signal:n})=>Ke(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Zo(e){return E({queryKey:G.githubPrChanges(e??0),queryFn:({signal:t})=>Ue(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Ma as $,q as $t,ao as A,Qi as At,Ga as B,ki as Bt,to as C,fn as Cn,ta as Ct,po as D,z as Dn,Bi as Dt,fo as E,B as En,Zi as Et,Ha as F,la as Ft,qa as G,ii as Gt,Ua as H,di as Ht,Ya as I,ca as It,Oa as J,ei as Jt,ka as K,$r as Kt,Ea as L,Ni as Lt,Pa as M,Xi as Mt,Fa as N,Vi as Nt,co as O,on as On,Ki as Ot,Ia as P,Gi as Pt,Aa as Q,Qr as Qt,Xa as R,Ai as Rt,$a as S,U as Sn,Pi as St,ro as T,H as Tn,zi as Tt,xa as U,si as Ut,Ka as V,li as Vt,Wa as W,ti as Wt,Ra as X,ai as Xt,ja as Y,oi as Yt,La as Z,ni as Zt,eo as _,pn as _n,ia as _t,Xo as a,K as an,Ja as at,ho as b,_n as bn,sa as bt,Vo as c,Cr as cn,$ as ct,Wo as d,An as dn,na as dt,Ur as en,za as et,Jo as f,kn as fn,ea as ft,io as g,Tn as gn,Ri as gt,uo as h,Dn as hn,Wi as ht,Yo as i,G as in,wa as it,Ca as j,qi as jt,Qa as k,an as kn,Ii as kt,Lo as l,jn as ln,$i as lt,lo as m,On as mn,ra as mt,Bo as n,Br as nn,Sa as nt,Io as o,W as on,Ba as ot,ko as p,Mn as pn,Yi as pt,Za as q,ri as qt,Ro as r,zr as rn,Ta as rt,Zo as s,wr as sn,va as st,Go as t,Vr as tn,Da as tt,zo as u,En as un,ua as ut,so as v,mn as vn,oa as vt,no as w,V as wn,Fi as wt,mo as x,vn as xn,Li as xt,oo as y,hn as yn,aa as yt,Na as z,ji as zt};
@@ -1 +0,0 @@
1
- import{Ft as e}from"./queries-CNjDebHy.js";import{n as t}from"./project-location-DQob1g0E.js";function n(){return{home:e().data?.homeDir??null,root:t()}}export{n as t};