@wjarka/cezarion 0.18.0-dev.6419 → 0.18.0-dev.6441

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 (40) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{activity-motion-u7cCOvIh.js → activity-motion-BeswQRe1.js} +1 -1
  3. package/web/dist/assets/{activity-route-BthlzLJS.js → activity-route-su3KawLr.js} +1 -1
  4. package/web/dist/assets/{agent-accounts-CbqP0u9A.js → agent-accounts-DseqHuGY.js} +1 -1
  5. package/web/dist/assets/attention-DlfFfWoj.js +1 -0
  6. package/web/dist/assets/{commit-diff-panel-B1FnfuXx.js → commit-diff-panel-DmhrguZk.js} +1 -1
  7. package/web/dist/assets/{diff-DwhVa59f.js → diff-DDwr1gUX.js} +2 -2
  8. package/web/dist/assets/{diff-view-C4JhxweA.js → diff-view-BNL7l7Vp.js} +1 -1
  9. package/web/dist/assets/{file-preview-xqxo9aYs.js → file-preview-Cm1jWwBy.js} +1 -1
  10. package/web/dist/assets/{git-toolbar-B5EhJG95.js → git-toolbar-Dya9briW.js} +1 -1
  11. package/web/dist/assets/{github-CGvl-B9Z.js → github-wWGhoE3O.js} +1 -1
  12. package/web/dist/assets/{global-activity-route-n_BdJZWx.js → global-activity-route-DpQr_eU9.js} +1 -1
  13. package/web/dist/assets/{index-O1VoICYw.js → index-DYx21hr3.js} +4 -4
  14. package/web/dist/assets/{preview-pane-connected-OWg6VXKi.js → preview-pane-connected-DSStovll.js} +1 -1
  15. package/web/dist/assets/{project-router-Coo_s3l-.js → project-router-uJ3SkX70.js} +1 -1
  16. package/web/dist/assets/{project-scope-context-WiGQMFsB.js → project-scope-context-X6-LgbYE.js} +1 -1
  17. package/web/dist/assets/{prompt-template-menu-Ch7UoIKH.js → prompt-template-menu-D5T9W-K3.js} +1 -1
  18. package/web/dist/assets/{queries-BLvbAnL8.js → queries-00V5jnAV.js} +1 -1
  19. package/web/dist/assets/{reference-chip-P6ytqWNt.js → reference-chip-AZWOlSRV.js} +1 -1
  20. package/web/dist/assets/{repo-git-ZeZnpwuR.js → repo-git-DJPSn50o.js} +1 -1
  21. package/web/dist/assets/{report-reader-D_uzPRmR.js → report-reader-kzlovTso.js} +1 -1
  22. package/web/dist/assets/{reports-C49_pROg.js → reports-Ds7nog_M.js} +1 -1
  23. package/web/dist/assets/{run-header-BR1PGTJB.js → run-header-skVwUvR-.js} +1 -1
  24. package/web/dist/assets/{skills-BHpdpRR-.js → skills-BJPLRZL5.js} +1 -1
  25. package/web/dist/assets/{tab-link-CONf2d_z.js → tab-link-h4IjTsRH.js} +1 -1
  26. package/web/dist/assets/{task-changes-DqcCJDTC.js → task-changes-Db3dmYAT.js} +1 -1
  27. package/web/dist/assets/{task-commits-Jmpz5NtV.js → task-commits-D4HdW5xE.js} +1 -1
  28. package/web/dist/assets/{task-files-BFSteFDh.js → task-files-sdaEBCfr.js} +1 -1
  29. package/web/dist/assets/{task-github-item-CIno99eX.js → task-github-item-DyZdbhco.js} +1 -1
  30. package/web/dist/assets/{task-thread-BKkxwKd_.js → task-thread-QKAKHYiJ.js} +1 -1
  31. package/web/dist/assets/{thread-state-Bwt_th_-.js → thread-state-hhRCETQT.js} +1 -1
  32. package/web/dist/assets/{use-desktop-CW-Femww.js → use-desktop-C3yCutND.js} +1 -1
  33. package/web/dist/assets/{use-hand-to-agent-state-XV1UwyxH.js → use-hand-to-agent-state-wGtVosbN.js} +1 -1
  34. package/web/dist/assets/{useInfiniteQuery-BgLdxmcZ.js → useInfiniteQuery-BcY0ra-k.js} +1 -1
  35. package/web/dist/assets/useQuery-C96hAjNV.js +1 -0
  36. package/web/dist/assets/{workflows-DUCROjgb.js → workflows-DRO8PcD-.js} +1 -1
  37. package/web/dist/assets/{ws-8bmD25V4.js → ws-BD6s7UXb.js} +1 -1
  38. package/web/dist/index.html +12 -12
  39. package/web/dist/assets/attention-CCx8Iagl.js +0 -1
  40. package/web/dist/assets/useQuery-CY8bJTYi.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{u as t}from"./button-Czdi8NqC.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{Ut as i}from"./queries-BLvbAnL8.js";import{P as a,S as o,a as s,o as c,r as l}from"./use-desktop-CW-Femww.js";import{K as u,rt as d,u as f}from"./design-icons-DmYTv2r1.js";import{c as p}from"./project-router-Coo_s3l-.js";import{B as m,I as h,L as g,P as _,R as v,V as y,z as b}from"./agent-accounts-CbqP0u9A.js";import{a as x}from"./skills-DFBiAuJG.js";var S=r();function C({className:e,...n}){return(0,S.jsx)(`div`,{"data-slot":`skeleton`,className:t(`animate-pulse rounded-md bg-accent`,e),...n})}var w=[`assigned`,`no-task`,`has-task`,`all`],T=[`review`,`mine`,`failing`,`all`],E=50,D=`is:open review-requested:@me`,O=`is:open status:failure`;function k(e,t){return e===`prs`&&(t===`review`||t===`failing`)}function A(e){return e===`review`?D:e===`failing`?O:null}function j(e,t){return t===null?null:(e===`issues`?w:T).includes(t)?t:`all`}function M(e,t,n,r=``){let i=`${n===void 0?e===`issues`?`/github`:`/github/prs`:`${e===`issues`?`/github/issues`:`/github/prs`}/${n}`}${r}`;return t===null?i:`${i}?filter=${encodeURIComponent(t)}`}function N(e,t){let n=t??`all`;return n===`all`?e===`issues`?`all`:`all-prs`:n}function P(e){return e===`all`?{view:`issues`,filter:`all`}:e===`all-prs`?{view:`prs`,filter:`all`}:{view:e===`review`||e===`mine`||e===`failing`?`prs`:`issues`,filter:e}}var F=[{id:`assigned`,label:`Assigned to me`},{id:`no-task`,label:`No task yet`},{id:`has-task`,label:`Has a task`},{id:`all`,label:`All open`}],I=[{id:`review`,label:`Review requested`},{id:`mine`,label:`Mine`},{id:`failing`,label:`Checks failing`},{id:`all-prs`,label:`All open`}],L=Object.fromEntries([...F,...I].map(e=>[e.id,e.label]));function R(e){return e===null?``:`${e.value}${e.bound===`atLeast`?`+`:``}`}function z(e,t){if(t?.bound===`atLeast`)return e===`review`||e===`failing`?`At least ${t.value}: GitHub search returns at most ${E} results.`:`At least ${t.value}: only the loaded pages are counted. Scroll to load more.`}var B=(e,t)=>e!==void 0&&t!==void 0&&e.toLowerCase()===t.toLowerCase();function V(e){try{let t=new URL(e).pathname.split(`/`).filter(Boolean);return t.length>=2?`${t[0]}/${t[1]}`.toLowerCase():null}catch{return null}}function H(e,t,n){return new Set(e.filter(e=>!e.archived).flatMap(e=>U(e,t,n)))}function U(e,t,n){let r=t?.toLowerCase();return o(e,void 0,n).filter(e=>e.kind===`Issue`&&(!e.url||r!==void 0&&V(e.url)===r)).map(e=>e.number)}function W(e,t,n,r){let i=new Map;for(let o of e)!a(o)&&U(o,n,r).includes(t)&&i.set(o.id,o);return[...i.values()].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt)||e.id.localeCompare(t.id))}function G(e,t){let n=new Map(t.map(e=>[e.number,e]));return e.map(e=>n.get(e.number)??e)}function K(e){return e?.available?{value:e.items.length,bound:e.truncated?`atLeast`:`exact`}:null}function q({gh:e,tasks:t,review:n,failing:r}){let a={assigned:null,"no-task":null,"has-task":null,all:null,review:K(n),mine:null,failing:K(r),"all-prs":null};if(!e?.available)return a;let o=!i(e,`issues`),s=!i(e,`prs`),c=(e,t)=>({value:e,bound:t?`atLeast`:`exact`}),l=t?e.issues.filter(e=>t.has(e.number)).length:null;return{...a,all:c(e.issuesTotal??e.issues.length,!1),"all-prs":c(e.prsTotal??e.prs.length,!1),assigned:e.viewerLogin?c(e.issues.filter(t=>t.assignees?.some(t=>B(t,e.viewerLogin))).length,o):null,mine:e.viewerLogin?c(e.prs.filter(t=>B(t.author,e.viewerLogin)).length,s):null,"has-task":l===null?null:c(l,o),"no-task":l===null?null:c(e.issues.length-l,o)}}var J=e(n(),1);function Y({templates:e,onInsert:n,triggerClassName:r,disabled:i,iconOnly:a=!1,label:o=`Template`}){let[C,w]=(0,J.useState)(!1),T=(0,J.useRef)(null),E=p();return e.length===0?null:(0,S.jsxs)(l,{open:C,onOpenChange:w,children:[(0,S.jsx)(c,{asChild:!0,children:(0,S.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-trigger`,"aria-label":`Insert a prompt template`,title:`Insert a prompt template`,disabled:i,className:t(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a?`w-[26px] justify-center px-0`:`h-11 gap-2 rounded-lg px-3 text-foreground`,r),children:[(0,S.jsx)(u,{"aria-hidden":`true`,className:a?`size-3 shrink-0 text-accent-icon`:`size-[18px] shrink-0 text-muted-foreground`}),a?null:(0,S.jsxs)(S.Fragment,{children:[o,(0,S.jsx)(f,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`})]})]})}),(0,S.jsx)(s,{align:`start`,sideOffset:8,"data-slot":`prompt-template-menu`,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,S.jsxs)(_,{filter:x,children:[(0,S.jsx)(v,{placeholder:`search templates…`,onInput:()=>T.current?.scrollTo(0,0)}),(0,S.jsxs)(m,{ref:T,"data-slot":`prompt-template-list-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,S.jsx)(h,{children:`Nothing matches.`}),(0,S.jsx)(g,{heading:`Insert a template`,children:e.map(e=>(0,S.jsxs)(b,{value:`template ${e.label} ${e.id}`,keywords:[e.text,...e.skills??[]],"data-slot":`prompt-template-option`,"data-template":e.id,title:e.text,className:`flex-col items-start gap-0.5`,onSelect:()=>{n(e.text),w(!1)},children:[(0,S.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:e.label}),e.skills&&e.skills.length>0?(0,S.jsxs)(`span`,{"data-slot":`prompt-template-assigned`,title:`Applied automatically with: ${e.skills.join(`, `)}`,className:`inline-flex shrink-0 items-center gap-0.5 text-[12px] font-medium text-accent-text`,children:[(0,S.jsx)(d,{"aria-hidden":`true`,className:`size-2.5`}),e.skills.length]}):null]}),(0,S.jsx)(`span`,{className:`line-clamp-1 text-[11px] text-soft-foreground`,children:e.text})]},e.id))}),(0,S.jsx)(y,{}),(0,S.jsx)(g,{children:(0,S.jsx)(b,{value:`edit prompt templates settings`,"data-slot":`prompt-template-settings`,className:`text-[12px] text-muted-foreground`,onSelect:()=>{w(!1),E(`/settings/prompt-templates`)},children:`Edit templates…`})})]})]})})]})}export{G as _,I as a,q as c,M as d,k as f,N as g,j as h,F as i,P as l,W as m,L as n,D as o,H as p,O as r,z as s,Y as t,R as u,A as v,C as y};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{u as t}from"./button-Czdi8NqC.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{Ut as i}from"./queries-00V5jnAV.js";import{P as a,S as o,a as s,o as c,r as l}from"./use-desktop-C3yCutND.js";import{K as u,rt as d,u as f}from"./design-icons-DmYTv2r1.js";import{c as p}from"./project-router-uJ3SkX70.js";import{B as m,I as h,L as g,P as _,R as v,V as y,z as b}from"./agent-accounts-DseqHuGY.js";import{a as x}from"./skills-DFBiAuJG.js";var S=r();function C({className:e,...n}){return(0,S.jsx)(`div`,{"data-slot":`skeleton`,className:t(`animate-pulse rounded-md bg-accent`,e),...n})}var w=[`assigned`,`no-task`,`has-task`,`all`],T=[`review`,`mine`,`failing`,`all`],E=50,D=`is:open review-requested:@me`,O=`is:open status:failure`;function k(e,t){return e===`prs`&&(t===`review`||t===`failing`)}function A(e){return e===`review`?D:e===`failing`?O:null}function j(e,t){return t===null?null:(e===`issues`?w:T).includes(t)?t:`all`}function M(e,t,n,r=``){let i=`${n===void 0?e===`issues`?`/github`:`/github/prs`:`${e===`issues`?`/github/issues`:`/github/prs`}/${n}`}${r}`;return t===null?i:`${i}?filter=${encodeURIComponent(t)}`}function N(e,t){let n=t??`all`;return n===`all`?e===`issues`?`all`:`all-prs`:n}function P(e){return e===`all`?{view:`issues`,filter:`all`}:e===`all-prs`?{view:`prs`,filter:`all`}:{view:e===`review`||e===`mine`||e===`failing`?`prs`:`issues`,filter:e}}var F=[{id:`assigned`,label:`Assigned to me`},{id:`no-task`,label:`No task yet`},{id:`has-task`,label:`Has a task`},{id:`all`,label:`All open`}],I=[{id:`review`,label:`Review requested`},{id:`mine`,label:`Mine`},{id:`failing`,label:`Checks failing`},{id:`all-prs`,label:`All open`}],L=Object.fromEntries([...F,...I].map(e=>[e.id,e.label]));function R(e){return e===null?``:`${e.value}${e.bound===`atLeast`?`+`:``}`}function z(e,t){if(t?.bound===`atLeast`)return e===`review`||e===`failing`?`At least ${t.value}: GitHub search returns at most ${E} results.`:`At least ${t.value}: only the loaded pages are counted. Scroll to load more.`}var B=(e,t)=>e!==void 0&&t!==void 0&&e.toLowerCase()===t.toLowerCase();function V(e){try{let t=new URL(e).pathname.split(`/`).filter(Boolean);return t.length>=2?`${t[0]}/${t[1]}`.toLowerCase():null}catch{return null}}function H(e,t,n){return new Set(e.filter(e=>!e.archived).flatMap(e=>U(e,t,n)))}function U(e,t,n){let r=t?.toLowerCase();return o(e,void 0,n).filter(e=>e.kind===`Issue`&&(!e.url||r!==void 0&&V(e.url)===r)).map(e=>e.number)}function W(e,t,n,r){let i=new Map;for(let o of e)!a(o)&&U(o,n,r).includes(t)&&i.set(o.id,o);return[...i.values()].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt)||e.id.localeCompare(t.id))}function G(e,t){let n=new Map(t.map(e=>[e.number,e]));return e.map(e=>n.get(e.number)??e)}function K(e){return e?.available?{value:e.items.length,bound:e.truncated?`atLeast`:`exact`}:null}function q({gh:e,tasks:t,review:n,failing:r}){let a={assigned:null,"no-task":null,"has-task":null,all:null,review:K(n),mine:null,failing:K(r),"all-prs":null};if(!e?.available)return a;let o=!i(e,`issues`),s=!i(e,`prs`),c=(e,t)=>({value:e,bound:t?`atLeast`:`exact`}),l=t?e.issues.filter(e=>t.has(e.number)).length:null;return{...a,all:c(e.issuesTotal??e.issues.length,!1),"all-prs":c(e.prsTotal??e.prs.length,!1),assigned:e.viewerLogin?c(e.issues.filter(t=>t.assignees?.some(t=>B(t,e.viewerLogin))).length,o):null,mine:e.viewerLogin?c(e.prs.filter(t=>B(t.author,e.viewerLogin)).length,s):null,"has-task":l===null?null:c(l,o),"no-task":l===null?null:c(e.issues.length-l,o)}}var J=e(n(),1);function Y({templates:e,onInsert:n,triggerClassName:r,disabled:i,iconOnly:a=!1,label:o=`Template`}){let[C,w]=(0,J.useState)(!1),T=(0,J.useRef)(null),E=p();return e.length===0?null:(0,S.jsxs)(l,{open:C,onOpenChange:w,children:[(0,S.jsx)(c,{asChild:!0,children:(0,S.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-trigger`,"aria-label":`Insert a prompt template`,title:`Insert a prompt template`,disabled:i,className:t(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a?`w-[26px] justify-center px-0`:`h-11 gap-2 rounded-lg px-3 text-foreground`,r),children:[(0,S.jsx)(u,{"aria-hidden":`true`,className:a?`size-3 shrink-0 text-accent-icon`:`size-[18px] shrink-0 text-muted-foreground`}),a?null:(0,S.jsxs)(S.Fragment,{children:[o,(0,S.jsx)(f,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`})]})]})}),(0,S.jsx)(s,{align:`start`,sideOffset:8,"data-slot":`prompt-template-menu`,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,S.jsxs)(_,{filter:x,children:[(0,S.jsx)(v,{placeholder:`search templates…`,onInput:()=>T.current?.scrollTo(0,0)}),(0,S.jsxs)(m,{ref:T,"data-slot":`prompt-template-list-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,S.jsx)(h,{children:`Nothing matches.`}),(0,S.jsx)(g,{heading:`Insert a template`,children:e.map(e=>(0,S.jsxs)(b,{value:`template ${e.label} ${e.id}`,keywords:[e.text,...e.skills??[]],"data-slot":`prompt-template-option`,"data-template":e.id,title:e.text,className:`flex-col items-start gap-0.5`,onSelect:()=>{n(e.text),w(!1)},children:[(0,S.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:e.label}),e.skills&&e.skills.length>0?(0,S.jsxs)(`span`,{"data-slot":`prompt-template-assigned`,title:`Applied automatically with: ${e.skills.join(`, `)}`,className:`inline-flex shrink-0 items-center gap-0.5 text-[12px] font-medium text-accent-text`,children:[(0,S.jsx)(d,{"aria-hidden":`true`,className:`size-2.5`}),e.skills.length]}):null]}),(0,S.jsx)(`span`,{className:`line-clamp-1 text-[11px] text-soft-foreground`,children:e.text})]},e.id))}),(0,S.jsx)(y,{}),(0,S.jsx)(g,{children:(0,S.jsx)(b,{value:`edit prompt templates settings`,"data-slot":`prompt-template-settings`,className:`text-[12px] text-muted-foreground`,onSelect:()=>{w(!1),E(`/settings/prompt-templates`)},children:`Edit templates…`})})]})]})})]})}export{G as _,I as a,q as c,M as d,k as f,N as g,j as h,F as i,P as l,W as m,L as n,D as o,H as p,O as r,z as s,Y as t,R as u,A as v,C as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{A as t,M as n}from"./button-Czdi8NqC.js";import{i as r}from"./react-runtime-CCIEwYL0.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$t as s,At as c,B as l,Br as u,Cn as d,Cr as f,Ct as p,Dn as m,Dt as h,F as g,Ft as _,Gr as v,H as y,Hr as ee,Ht as te,I as ne,Ir as re,It as ie,J as ae,Jt as oe,K as se,Kr as ce,L as le,Lr as ue,Lt as de,M as fe,Mt as pe,Nt as me,On as he,Or as ge,Ot as _e,Pt as ve,Q as ye,R as be,Rr as xe,Sn as Se,Sr as Ce,St as we,Tn as Te,U as Ee,Ur as De,V as Oe,Vr as ke,Vt as Ae,X as b,Xr as je,Y as Me,Yt as Ne,Z as Pe,Zr as Fe,_ as Ie,_n as Le,_r as x,_t as Re,ai as ze,at as Be,b as Ve,bt as He,c as Ue,cn as We,ct as Ge,dn as Ke,dt as qe,ei as Je,et as Ye,ft as Xe,g as Ze,gt as Qe,ht as $e,i as et,it as tt,j as nt,jt as rt,kt as it,li as at,ln as ot,lt as st,m as ct,mn as lt,mt as ut,ni as dt,nt as ft,ot as pt,pi as mt,pt as ht,r as gt,si as S,sn as _t,st as vt,tt as yt,ui as bt,un as xt,ut as St,v as Ct,vn as wt,vt as Tt,wt as Et,x as Dt,xt as Ot,yn as kt,yt as At,z as jt,zr as Mt}from"./project-scope-context-WiGQMFsB.js";import{I as C,L as Nt,N as Pt,ft as w}from"./live-protocol-DjH6ZQwI.js";import{t as T}from"./useInfiniteQuery-BgLdxmcZ.js";import{t as E}from"./useQuery-CY8bJTYi.js";import{n as Ft,r as D,t as It}from"./ws-8bmD25V4.js";import{n as Lt}from"./toaster-2NK3PogQ.js";var Rt=class extends je{#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||zt(),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=Fe({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),w.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function zt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Bt=class extends mt{#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),at(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Je(t.mutationKey)!==Je(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??zt();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){w.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 Vt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ht(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ut=class extends mt{#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,w.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||!at(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Vt(e,n).forEach(e=>{e.destroy()}),Vt(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=S(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 ce(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ht(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)&&w.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},O=e(r(),1);function k({queries:e,...t},n){let r=v(n),i=De(),a=ee(),o=O.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{re(e);let t=r.getQueryCache().get(e.queryHash);Mt(e,a,t)}),ke(a);let[s]=O.useState(()=>new Ut(r,o,t)),[c,l,d]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;O.useSyncExternalStore(O.useCallback(e=>f?s.subscribe(w.batchCalls(e)):ze,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),O.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>xe(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&xe(n,e)?ue(n,new ce(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&u({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(d())}function A(e,t){let n=v(t),[r]=O.useState(()=>new Bt(n,e));O.useEffect(()=>{r.setOptions(e)},[r,e]);let i=O.useSyncExternalStore(O.useCallback(e=>r.subscribe(w.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=O.useCallback((e,t)=>{r.mutate(e,t).catch(ze)},[r]);if(i.error&&bt(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function j(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function M(e,t={}){return{...j(t),runId:e}}var N=[`workspace`,`runs-index`],P=e=>[e.cacheScope,`runs`,`list`],F=e=>[e.cacheScope,`runs`,`detail`,e.runId],I=e=>typeof e==`function`?e():e;function Wt(e){let{seenAt:t,...n}=e;return n}function Gt(e,t){let n=Wt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function L(e,t,n){return t?{...e,seenAt:n}:Wt(e)}function Kt(e){let t=()=>{e.invalidateQueries({queryKey:N})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;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 o=f(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:P(I(n))}),await e.cancelQueries({queryKey:F(I(n))});let i=e.getQueryData(P(I(n))),a=e.getQueryData(F(I(n))),o=I(n).runId,s=new Date().toISOString();return e.setQueryData(P(I(n)),e=>e?.map(e=>e.id===o?L(e,r,s):e)),e.setQueryData(F(I(n)),e=>e&&L(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(P(I(n)),i),a&&e.setQueryData(F(I(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(P(I(n)),e=>e?.map(e=>e.id===o?Gt(e,t):e)),a&&e.setQueryData(F(I(n)),e=>e&&Gt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?L(e,r,i.seenAt):e;e.setQueryData(P(I(n)),e=>e?.map(a));let s={...I(n),runId:r?o:i.id};e.setQueryData(F(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:N});let i=e.getQueryData(N),a=n();return e.setQueryData(N,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(N,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function R(){let e=v();return(0,O.useMemo)(()=>Kt(e),[e])}function qt(e){return e.type===`run`?e.run.id:e.id}function z(e,t){return{...e,runs:t}}function Jt(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function Yt(e,t){let n=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),r=[...e];return r.splice(n<0?e.length:n,0,t),r}function Xt(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Zt(e,t,n){let{project:r}=t,i=qt(t),a=e.runs.findIndex(e=>e.projectId===r&&e.id===i),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(r);if(t.type===`deleted`)return o?{index:z(e,e.runs.filter((e,t)=>t!==a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:z(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!Xt(e,r,n))return{index:e,reconcile:!0};let l=S(o,{projectId:r,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=[...e.runs];t[a]=l;let n=o.archived!==l.archived&&(s||Jt(t,r)>e.perProjectLimit);return{index:z(e,t),reconcile:n}}if(s)return $t(e,l);let u=Yt(e.runs,l);return{index:z(e,u),reconcile:l.archived&&Jt(u,r)>e.perProjectLimit}}function Qt(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function $t(e,t){let n=Qt(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:z(e,Yt(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function en(e,t,n){let r=!1,i=e.runs.map(e=>{if(e.projectId!==t)return e;let i=n[e.id];if(i){let t=S(e.usage,i);return t===e.usage?e:(r=!0,{...e,usage:t})}if(e.usage===void 0)return e;r=!0;let{usage:a,...o}=e;return o});return r?z(e,i):e}function tn(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 nn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function rn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function an(e){e.stream=void 0}function on(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,qt(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function sn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function cn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function ln(e,t,n){if(!cn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=Zt(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var B=[`workspace`,`runs-index`],un=[`workspace`,`projects`],dn=6e4,fn=100,pn=new WeakMap;function V(e){let t=pn.get(e);return t||(t=vn(e),pn.set(e,t)),t}function mn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:V(t).merge(e)}function hn(e){let t=e.getQueryData(un)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function gn(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 _n(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 vn(e){let t=nn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(B,t)},h=()=>e.getQueryData(B),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:B,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:B,exact:!0}).then(()=>e.invalidateQueries({queryKey:B})):e.invalidateQueries({queryKey:B})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=hn(e),s=a,c=!1;for(let e of t){if(e.generation!==a.generation)continue;if(e.type===`usage`){l.has(e.project)||(s=en(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=Zt(s,e.change,o);s=t.index,c||=t.reconcile}s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,fn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){rn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){an(t)},run(e,r,i=!1){if(l.has(e))return;let a=_n(e,r);if(!on(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),sn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=tn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=ln(t,n,hn(e));for(let e of l)i.index=tn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),gn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var yn={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},bn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function xn(e){return typeof e==`string`&&Object.hasOwn(yn,e)}function Sn(e){return e!==void 0&&xn(e)?yn[e]:void 0}var Cn=`cez.reference-statuses.v1`,wn=`cez.reference-conflicts.v1`,H=new Map(Dn()),Tn=1e3;function U(e,t){if(H.get(e)!==t){for(H.delete(e),H.set(e,t);H.size>Tn;){let e=H.keys().next().value;if(e===void 0)break;H.delete(e)}An()}}var W=new Set(On());function En(e,t){if(W.has(e)!==t){if(t)for(W.add(e);W.size>Tn;){let e=W.values().next().value;if(e===void 0)break;W.delete(e)}else W.delete(e);An()}}function Dn(){try{let e=globalThis.sessionStorage?.getItem(Cn);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`&&xn(e[1])):[]}catch{return[]}}function On(){try{let e=globalThis.sessionStorage?.getItem(wn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var kn;function An(){kn===void 0&&(kn=setTimeout(()=>{kn=void 0;try{globalThis.sessionStorage?.setItem(Cn,JSON.stringify([...H])),globalThis.sessionStorage?.setItem(wn,JSON.stringify([...W]))}catch{}},250))}var G=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function K(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function jn(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function Mn(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;U(t,o),s!==void 0&&En(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Nn(e,t,n){let r=G(t),i=H.get(r),a=W.has(r)?!0:void 0,o=n.data;if(o?.available){Mn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...K(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...K(i,a)});return}e.set(r,{state:`loading`,...K(i,a)})}function Pn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of jn(i))Nn(n,e,t)}),n}function Fn(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 In(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 Ln(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 Rn(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 zn(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 Bn(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Vn(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function Hn(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){Vn(t.issues,a,r),Vn(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 q=e=>e.map(e=>e.number).join(`,`);function Un(e,t){let n=e[0];if(e.length>1&&n&&(q(n.issues)!==q(t.issues)||q(n.prs)!==q(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 J={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`]},get skills(){return[n(),`skills`]},get skillsReady(){return[n(),`skills`,`ready`]},get importableSkills(){return[n(),`skills`,`importable`]},get importableSkillsReady(){return[n(),`skills`,`importable`,`ready`]},get launchKey(){return[n(),`launch-key`]},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 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)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],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`]}},Y={models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:B,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountDetails:e=>[`workspace`,`agent-profiles`,`details`,e],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Y.fsBrowseRoot,e,t]};function X(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function Z(e,t=!0){let n=v();return(0,O.useEffect)(()=>{if(!t||e!==`cursor`)return;let r,i=()=>{let e=n.getQueryData(J.health)?.capabilities?.localHandoff===!0;e&&!r?r=It(`models:cursor`,e=>{let t=Nt.safeParse(e);t.success&&t.data.runner===`cursor`&&(n.cancelQueries({queryKey:Y.models(`cursor`)}),n.setQueryData(Y.models(`cursor`),t.data))}):!e&&r&&(r(),r=void 0)};i();let a=n.getQueryCache().subscribe(i);return()=>{a(),r?.()}},[t,e,n]),E({queryKey:Y.models(e),queryFn:({signal:t})=>C(e)?_e(e,{signal:t}):Promise.reject(Error(`${e} has no host model catalog`)),staleTime:300*1e3,enabled:t&&C(e)})}function Wn(e=!0){return{claude:Z(`claude`,e),codex:Z(`codex`,e),opencode:Z(`opencode`,e),pi:Z(`pi`,e),cursor:Z(`cursor`,e),omp:Z(`omp`,e)}}function Gn(){let e=v();return E({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await ht(!1,{signal:t});return x(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function Kn(){let e=v();return A({mutationFn:()=>ht(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>x(r,e,t)),X(e)}})}function qn(){let e=v();return A({mutationFn:({provider:e,authFailureId:t})=>lt(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>x(r,e,t,n.authFailureId)),C(n.provider)&&X(e,n.provider)}})}function Jn(e={}){return E({queryKey:Y.projects,queryFn:({signal:e})=>Xe({signal:e}),...e})}function Yn(e,t=!1){return E({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>Ue(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Xn(){let e=v();return A({mutationFn:e=>_t(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Zn(){let e=v();return A({mutationFn:e=>ot(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Y.projects})}})}function Qn(){let e=v();return A({mutationFn:e=>{let{id:t,...n}=e;return m(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Y.projects});let r=e.getQueryData(Y.projects);return e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?$n(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Y.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Y.projects})})}function $n(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?[]:Rn(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 Q(e){let t=v();return A({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Y.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Y.projects})})}function er(){return Q(e=>{let{projectId:t,...n}=e;return Dt(t,n)})}function tr(){return Q(e=>{let{projectId:t,webhookId:n,...r}=e;return he(t,n,r)})}function nr(){return Q(({projectId:e,webhookId:t})=>xt(e,t))}function rr(){return A({mutationFn:({projectId:e,webhookId:t})=>d(e,t),retry:!1})}function ir(e){let t=v();return A({mutationFn:t=>Ae(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function $(e){let t=v();return A({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Y.agentProfiles}),t.invalidateQueries({queryKey:Y.projects})])}})}function ar(){return $(e=>Ct(e))}function or(){return $(e=>{let{id:t,...n}=e;return Te(t,n)})}function sr(){return $(e=>We(e))}function cr(){return $(e=>wt(e))}function lr(e,t){return E({queryKey:Y.agentAccountDetails(e),queryFn:({signal:t})=>g(e,{signal:t}),enabled:t,staleTime:0,retry:!1})}function ur(e,t){return E({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>ne(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function dr(){let e=v();return A({mutationFn:({provider:e,profileId:t})=>Ze(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),C(n)?X(e,n,`none`):Promise.resolve()])}})}function fr(){let e=v();return A({mutationFn:e=>ne(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),C(t.status.provider)&&X(e,t.status.provider)}})}function pr(){return A({mutationFn:e=>{let{routeId:t,...n}=e;return te(t,n)},retry:!1})}function mr(){let e=v();return A({mutationFn:e=>ct(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function hr(){let e=v();return A({mutationFn:e=>Ve(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function gr({enabled:e}){return E({queryKey:Y.githubOwners,queryFn:({signal:e})=>yt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function _r(){let e=v();(0,O.useEffect)(()=>{let n,r=()=>{let r=e.getQueryData(J.health),i=r?.capabilities?.localHandoff===!0;r&&Ce({local:i,bootProject:r.bootProject??`default`,apiBase:t()}),i&&n===void 0?n=It(`health`,t=>{e.setQueryData(J.health,t)}):!i&&n!==void 0&&(n(),n=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),n?.(),ge()}},[e])}function vr(){return E({queryKey:J.health,queryFn:({signal:e})=>vt({signal:e})})}function yr(e,t){let n=vr().data,r=Jn(t).data?.projects,i=gt(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?Fn(n?.repo?.remote):void 0}function br(){return E({queryKey:J.openTargets,queryFn:({signal:e})=>qe({signal:e}),staleTime:5*6e4})}function xr(){return E({queryKey:J.runs.list(),queryFn:({signal:e})=>it(j(),{signal:e})})}function Sr(e,t){return T({queryKey:J.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>l({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 Cr(e){let t=e.trim();return E({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>Le(t,{signal:e}),enabled:t.length>=2,placeholderData:dt,staleTime:1e4})}function wr(e=!0,t=dn){let n=V(v());return D(`/api/v1/workspace/runs-index`,Y.runsIndex,a(e?t:!1),mn),E({queryKey:Y.runsIndex,queryFn:({signal:e})=>c({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function Tr(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>it(j({projectId:e,boot:n}),{signal:t}),enabled:t,placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function Er(e){let t=v();return A({mutationFn:e=>nt(e),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function Dr(e,t={}){return E({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>h(e,{signal:t}),enabled:t.enabled??!0})}function Or(e){return E({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>Tt(M(e),{signal:t}),enabled:!!e})}function kr(e,t,n=!0){return E({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Tt(M(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Ar(e){return E({queryKey:J.runs.diff(e??``),queryFn:({signal:t})=>we(e,{signal:t}),enabled:!!e})}function jr(e,t=!1){return D(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),a(t?4e3:!1)),E({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>At(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Mr(e,t){return E({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>p(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Nr(e,t){return E({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Me(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Pr(e,t){return E({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Oe(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Fr(e,t){return E({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>y(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ir(e){return E({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Ee(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Lr(e,t=!1){return D(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),a(t?5e3:!1)),E({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>Ot(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Rr(e,t){return E({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>He(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function zr(e,t=!0){return E({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>Et(M(e),{signal:t}),enabled:!!e&&t})}function Br(e,t,n){return E({queryKey:e===void 0?J.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Et(M(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Vr(e,t){let r=[...new Set(e)],i=k({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>se({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,O.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function Hr(){return E({queryKey:J.workflows,queryFn:({signal:e})=>ve({signal:e})})}function Ur(e=!0){let t=v(),n=J.skills,r=n[0],i=E({queryKey:n,queryFn:({signal:e})=>rt({signal:e}),enabled:e}),a=E({queryKey:J.skillsReady,queryFn:({signal:e})=>pe({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`],a.data)},[t,a.data,r]),i}function Wr(e=!0){let t=v(),n=J.importableSkills,r=n[0],i=E({queryKey:n,queryFn:({signal:e})=>Ge({signal:e}),enabled:e}),a=E({queryKey:J.importableSkillsReady,queryFn:({signal:e})=>st({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`,`importable`],a.data)},[t,a.data,r]),i}function Gr(){return E({queryKey:J.launchKey,queryFn:({signal:e})=>St({signal:e}),staleTime:1/0})}function Kr(){return E({queryKey:J.repo,queryFn:({signal:e})=>ut({signal:e})})}function qr(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>ut({signal:t},e)})}function Jr(){return E({queryKey:J.repoBranches,queryFn:({signal:e})=>$e({signal:e})})}function Yr(){return E({queryKey:J.repoChanges,queryFn:({signal:e})=>Qe({signal:e}),retry:!1})}function Xr(e){return E({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>Re(e,{signal:t}),enabled:!!e,retry:!1})}function Zr(){return E({queryKey:J.config,queryFn:({signal:e})=>ae({signal:e})})}function Qr(){return E({queryKey:J.worktrees,queryFn:({signal:e})=>de({signal:e})})}function $r(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>de({signal:t},e),staleTime:0})}function ei(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>me({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:Pt(e.sidebarLimits)},enabled:t})}function ti(){return ei(n())}function ni(){return E({queryKey:J.agentConfig,queryFn:({signal:e})=>le({signal:e})})}function ri(e){return E({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>be(e,{signal:t}),enabled:e!==null})}function ii(e){let t=v(),n=J.agentConfig,r=J.agentConfigFile(e);return A({mutationFn:t=>s(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function ai(){return E({queryKey:Y.uiState,queryFn:({signal:e})=>ie({signal:e})})}function oi(){return E({queryKey:Y.config,queryFn:({signal:e})=>_({signal:e})})}function si(){return E({queryKey:Y.agentProfiles,queryFn:({signal:e})=>jt({signal:e})})}function ci(e){let t=v();return A({mutationFn:t=>oe(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function li(e){let t=R(),n=e?.projectId,r=e?.cacheScope,i=A({mutationFn:e=>Se(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,O.useCallback)(e=>({...M(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,O.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,O.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,O.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function ui(){let e=R();return A({mutationFn:e=>Se(M(e),!1),onMutate:t=>e.patchRead(()=>M(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function di(e){let t=R();return A({mutationFn:({id:t,pinned:n})=>Ne(M(t,e),n),onError:e=>Lt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??j(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function fi(e,t){let n=R();return A({mutationFn:n=>kt(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof et&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function pi(e,t){let n=R();return A({mutationFn:(n={})=>Ie(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function mi(e){let t=v();return A({mutationFn:({msgId:t,message:n})=>fe(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function hi(e){let t=v();return A({mutationFn:t=>Ke(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function gi(e={},t=!0){let r=v(),i=J.github(e);D(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=E({queryKey:J.github(e),queryFn:({signal:t})=>b({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=E({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>tt(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{!s||!c.data&&!c.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==s||e.projectsState!==`refreshing`)return e;let t=c.data;return t?.generation&&t.generation!==s?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[r,s,c.data,c.error,i]),o}var _i=class extends Error{};function vi(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await b({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new _i(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>zn(e),retry:(e,t)=>!(t instanceof _i)&&!(t instanceof et&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function yi(e=50,t=!0){let r=v(),i=J.githubPages(e),o=J.githubPagesHead(e);D(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=T({...vi(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=E({queryKey:o,queryFn:({signal:t})=>b({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,O.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=Un(e.pages,c.data);t===`refetch`?l():r.setQueryData(i,{...e,pages:t})},[r,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=k({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>tt(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,O.useEffect)(()=>{d.forEach((e,t)=>{let n=u[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,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,O.useMemo)(()=>Hn(s.data?.pages??[]),[s.data])}}function bi(e,t=50,n=!0){let r=T({...vi([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,O.useMemo)(()=>Hn(r.data?.pages??[]),[r.data])}}function xi(e,t,n=!0){let r=k({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>ye(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,O.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 Si(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>pt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Ci(e,t=!0){return E({queryKey:J.githubChecks(e),queryFn:({signal:t})=>Pe(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function wi(e,t,n=!0){return E({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>pt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ti=100;function Ei(e){return[...e].sort((e,t)=>t-e).slice(0,Ti).sort((e,t)=>e-t)}function Di(){let e=gt(),t=vr();return e.projectId??t.data?.bootProject}function Oi(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))U(G({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))U(G({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var ki=5*6e4;function Ai(e){return e?e.recheckAfterMs:ki}function ji(e,t=!0){let n=(0,O.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:Ei(t.prs),issues:Ei(t.issues)}))},[e.map(G).sort().join(`|`)]),r=k({queries:n.map(e=>({queryKey:J.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>Be(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ai(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=v(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Ai(r[t]?.data)??!1})));(0,O.useEffect)(()=>{if(!t||i())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=J.githubRefStatus(t.projectId,t.prs,t.issues);return Ft({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,O.useMemo)(()=>Pn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,O.useCallback)(e=>{let t=G(e),n=s.get(t);if(n)return n;let r=H.get(t);return{state:`idle`,...r?{status:r}:{},...W.has(t)?{conflicting:!0}:{}}},[s])}function Mi(e,t,n=!0){return E({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>o(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ni(e,t,n=!0){return E({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>Ye(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Pi(e){return E({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>ft(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Jn as $,A as $t,gr as A,fi as At,ir as B,ai as Bt,Nr as C,Dr as Ct,xi as D,wr as Dt,Ci as E,xr as Et,_r as F,or as Ft,bi as G,Ln as Gt,br as H,Y as Ht,Wr as I,Qn as It,yr as J,Sn as Jt,Si as K,Fn as Kt,Gr as L,tr as Lt,Pi as M,Br as Mt,wi as N,rr as Nt,Mi as O,Cr as Ot,vr as P,ti as Pt,$r as Q,M as Qt,li as R,Hr as Rt,mi as S,zr as St,gi as T,Z as Tt,ci as U,Bn as Ut,pr as V,Qr as Vt,di as W,In as Wt,Tr as X,R as Xt,kr as Y,V as Yt,ei as Z,j as Zt,pi as _,jr as _t,ur as a,Kn as at,er as b,Ar as bt,si as c,Zn as ct,Fr as d,Kr as dt,Rt as en,Gn as et,Ir as f,Jr as ft,dr as g,Or as gt,Zr as h,qn as ht,lr as i,ji as it,yi as j,Ur as jt,Ni as k,cr as kt,Sr as l,nr as lt,mr as m,Xr as mt,J as n,fr as nt,ni as o,Xn as ot,Vr as p,Yr as pt,qr as q,bn as qt,Oi as r,Di as rt,ri as s,sr as st,X as t,ii as tt,Pr as u,hi as ut,ar as v,Rr as vt,Yn as w,Wn as wt,Er as x,Mr as xt,hr as y,Lr as yt,ui as z,oi as zt};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{A as t,M as n}from"./button-Czdi8NqC.js";import{i as r}from"./react-runtime-CCIEwYL0.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$t as s,At as c,B as l,Br as u,Cn as d,Cr as f,Ct as p,Dn as m,Dt as h,F as g,Ft as _,Gr as v,H as y,Hr as ee,Ht as te,I as ne,Ir as re,It as ie,J as ae,Jt as oe,K as se,Kr as ce,L as le,Lr as ue,Lt as de,M as fe,Mt as pe,Nt as me,On as he,Or as ge,Ot as _e,Pt as ve,Q as ye,R as be,Rr as xe,Sn as Se,Sr as Ce,St as we,Tn as Te,U as Ee,Ur as De,V as Oe,Vr as ke,Vt as Ae,X as b,Xr as je,Y as Me,Yt as Ne,Z as Pe,Zr as Fe,_ as Ie,_n as Le,_r as x,_t as Re,ai as ze,at as Be,b as Ve,bt as He,c as Ue,cn as We,ct as Ge,dn as Ke,dt as qe,ei as Je,et as Ye,ft as Xe,g as Ze,gt as Qe,ht as $e,i as et,it as tt,j as nt,jt as rt,kt as it,li as at,ln as ot,lt as st,m as ct,mn as lt,mt as ut,ni as dt,nt as ft,ot as pt,pi as mt,pt as ht,r as gt,si as S,sn as _t,st as vt,tt as yt,ui as bt,un as xt,ut as St,v as Ct,vn as wt,vt as Tt,wt as Et,x as Dt,xt as Ot,yn as kt,yt as At,z as jt,zr as Mt}from"./project-scope-context-X6-LgbYE.js";import{I as C,L as Nt,N as Pt,ft as w}from"./live-protocol-DjH6ZQwI.js";import{t as T}from"./useInfiniteQuery-BcY0ra-k.js";import{t as E}from"./useQuery-C96hAjNV.js";import{n as Ft,r as D,t as It}from"./ws-BD6s7UXb.js";import{n as Lt}from"./toaster-2NK3PogQ.js";var Rt=class extends je{#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||zt(),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=Fe({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),w.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function zt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Bt=class extends mt{#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),at(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Je(t.mutationKey)!==Je(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??zt();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){w.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 Vt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ht(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ut=class extends mt{#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,w.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||!at(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Vt(e,n).forEach(e=>{e.destroy()}),Vt(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=S(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 ce(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ht(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)&&w.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},O=e(r(),1);function k({queries:e,...t},n){let r=v(n),i=De(),a=ee(),o=O.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{re(e);let t=r.getQueryCache().get(e.queryHash);Mt(e,a,t)}),ke(a);let[s]=O.useState(()=>new Ut(r,o,t)),[c,l,d]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;O.useSyncExternalStore(O.useCallback(e=>f?s.subscribe(w.batchCalls(e)):ze,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),O.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>xe(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&xe(n,e)?ue(n,new ce(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&u({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(d())}function A(e,t){let n=v(t),[r]=O.useState(()=>new Bt(n,e));O.useEffect(()=>{r.setOptions(e)},[r,e]);let i=O.useSyncExternalStore(O.useCallback(e=>r.subscribe(w.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=O.useCallback((e,t)=>{r.mutate(e,t).catch(ze)},[r]);if(i.error&&bt(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function j(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function M(e,t={}){return{...j(t),runId:e}}var N=[`workspace`,`runs-index`],P=e=>[e.cacheScope,`runs`,`list`],F=e=>[e.cacheScope,`runs`,`detail`,e.runId],I=e=>typeof e==`function`?e():e;function Wt(e){let{seenAt:t,...n}=e;return n}function Gt(e,t){let n=Wt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function L(e,t,n){return t?{...e,seenAt:n}:Wt(e)}function Kt(e){let t=()=>{e.invalidateQueries({queryKey:N})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;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 o=f(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:P(I(n))}),await e.cancelQueries({queryKey:F(I(n))});let i=e.getQueryData(P(I(n))),a=e.getQueryData(F(I(n))),o=I(n).runId,s=new Date().toISOString();return e.setQueryData(P(I(n)),e=>e?.map(e=>e.id===o?L(e,r,s):e)),e.setQueryData(F(I(n)),e=>e&&L(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(P(I(n)),i),a&&e.setQueryData(F(I(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(P(I(n)),e=>e?.map(e=>e.id===o?Gt(e,t):e)),a&&e.setQueryData(F(I(n)),e=>e&&Gt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?L(e,r,i.seenAt):e;e.setQueryData(P(I(n)),e=>e?.map(a));let s={...I(n),runId:r?o:i.id};e.setQueryData(F(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:N});let i=e.getQueryData(N),a=n();return e.setQueryData(N,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(N,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function R(){let e=v();return(0,O.useMemo)(()=>Kt(e),[e])}function qt(e){return e.type===`run`?e.run.id:e.id}function z(e,t){return{...e,runs:t}}function Jt(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function Yt(e,t){let n=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),r=[...e];return r.splice(n<0?e.length:n,0,t),r}function Xt(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Zt(e,t,n){let{project:r}=t,i=qt(t),a=e.runs.findIndex(e=>e.projectId===r&&e.id===i),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(r);if(t.type===`deleted`)return o?{index:z(e,e.runs.filter((e,t)=>t!==a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:z(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!Xt(e,r,n))return{index:e,reconcile:!0};let l=S(o,{projectId:r,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=[...e.runs];t[a]=l;let n=o.archived!==l.archived&&(s||Jt(t,r)>e.perProjectLimit);return{index:z(e,t),reconcile:n}}if(s)return $t(e,l);let u=Yt(e.runs,l);return{index:z(e,u),reconcile:l.archived&&Jt(u,r)>e.perProjectLimit}}function Qt(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function $t(e,t){let n=Qt(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:z(e,Yt(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function en(e,t,n){let r=!1,i=e.runs.map(e=>{if(e.projectId!==t)return e;let i=n[e.id];if(i){let t=S(e.usage,i);return t===e.usage?e:(r=!0,{...e,usage:t})}if(e.usage===void 0)return e;r=!0;let{usage:a,...o}=e;return o});return r?z(e,i):e}function tn(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 nn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function rn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function an(e){e.stream=void 0}function on(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,qt(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function sn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function cn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function ln(e,t,n){if(!cn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=Zt(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var B=[`workspace`,`runs-index`],un=[`workspace`,`projects`],dn=6e4,fn=100,pn=new WeakMap;function V(e){let t=pn.get(e);return t||(t=vn(e),pn.set(e,t)),t}function mn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:V(t).merge(e)}function hn(e){let t=e.getQueryData(un)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function gn(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 _n(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 vn(e){let t=nn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(B,t)},h=()=>e.getQueryData(B),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:B,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:B,exact:!0}).then(()=>e.invalidateQueries({queryKey:B})):e.invalidateQueries({queryKey:B})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=hn(e),s=a,c=!1;for(let e of t){if(e.generation!==a.generation)continue;if(e.type===`usage`){l.has(e.project)||(s=en(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=Zt(s,e.change,o);s=t.index,c||=t.reconcile}s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,fn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){rn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){an(t)},run(e,r,i=!1){if(l.has(e))return;let a=_n(e,r);if(!on(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),sn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=tn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=ln(t,n,hn(e));for(let e of l)i.index=tn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),gn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var yn={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},bn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function xn(e){return typeof e==`string`&&Object.hasOwn(yn,e)}function Sn(e){return e!==void 0&&xn(e)?yn[e]:void 0}var Cn=`cez.reference-statuses.v1`,wn=`cez.reference-conflicts.v1`,H=new Map(Dn()),Tn=1e3;function U(e,t){if(H.get(e)!==t){for(H.delete(e),H.set(e,t);H.size>Tn;){let e=H.keys().next().value;if(e===void 0)break;H.delete(e)}An()}}var W=new Set(On());function En(e,t){if(W.has(e)!==t){if(t)for(W.add(e);W.size>Tn;){let e=W.values().next().value;if(e===void 0)break;W.delete(e)}else W.delete(e);An()}}function Dn(){try{let e=globalThis.sessionStorage?.getItem(Cn);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`&&xn(e[1])):[]}catch{return[]}}function On(){try{let e=globalThis.sessionStorage?.getItem(wn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var kn;function An(){kn===void 0&&(kn=setTimeout(()=>{kn=void 0;try{globalThis.sessionStorage?.setItem(Cn,JSON.stringify([...H])),globalThis.sessionStorage?.setItem(wn,JSON.stringify([...W]))}catch{}},250))}var G=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function K(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function jn(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function Mn(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;U(t,o),s!==void 0&&En(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Nn(e,t,n){let r=G(t),i=H.get(r),a=W.has(r)?!0:void 0,o=n.data;if(o?.available){Mn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...K(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...K(i,a)});return}e.set(r,{state:`loading`,...K(i,a)})}function Pn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of jn(i))Nn(n,e,t)}),n}function Fn(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 In(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 Ln(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 Rn(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 zn(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 Bn(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Vn(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function Hn(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){Vn(t.issues,a,r),Vn(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 q=e=>e.map(e=>e.number).join(`,`);function Un(e,t){let n=e[0];if(e.length>1&&n&&(q(n.issues)!==q(t.issues)||q(n.prs)!==q(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 J={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`]},get skills(){return[n(),`skills`]},get skillsReady(){return[n(),`skills`,`ready`]},get importableSkills(){return[n(),`skills`,`importable`]},get importableSkillsReady(){return[n(),`skills`,`importable`,`ready`]},get launchKey(){return[n(),`launch-key`]},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 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)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],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`]}},Y={models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:B,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountDetails:e=>[`workspace`,`agent-profiles`,`details`,e],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Y.fsBrowseRoot,e,t]};function X(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function Z(e,t=!0){let n=v();return(0,O.useEffect)(()=>{if(!t||e!==`cursor`)return;let r,i=()=>{let e=n.getQueryData(J.health)?.capabilities?.localHandoff===!0;e&&!r?r=It(`models:cursor`,e=>{let t=Nt.safeParse(e);t.success&&t.data.runner===`cursor`&&(n.cancelQueries({queryKey:Y.models(`cursor`)}),n.setQueryData(Y.models(`cursor`),t.data))}):!e&&r&&(r(),r=void 0)};i();let a=n.getQueryCache().subscribe(i);return()=>{a(),r?.()}},[t,e,n]),E({queryKey:Y.models(e),queryFn:({signal:t})=>C(e)?_e(e,{signal:t}):Promise.reject(Error(`${e} has no host model catalog`)),staleTime:300*1e3,enabled:t&&C(e)})}function Wn(e=!0){return{claude:Z(`claude`,e),codex:Z(`codex`,e),opencode:Z(`opencode`,e),pi:Z(`pi`,e),cursor:Z(`cursor`,e),omp:Z(`omp`,e)}}function Gn(){let e=v();return E({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await ht(!1,{signal:t});return x(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function Kn(){let e=v();return A({mutationFn:()=>ht(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>x(r,e,t)),X(e)}})}function qn(){let e=v();return A({mutationFn:({provider:e,authFailureId:t})=>lt(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>x(r,e,t,n.authFailureId)),C(n.provider)&&X(e,n.provider)}})}function Jn(e={}){return E({queryKey:Y.projects,queryFn:({signal:e})=>Xe({signal:e}),...e})}function Yn(e,t=!1){return E({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>Ue(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Xn(){let e=v();return A({mutationFn:e=>_t(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Zn(){let e=v();return A({mutationFn:e=>ot(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Y.projects})}})}function Qn(){let e=v();return A({mutationFn:e=>{let{id:t,...n}=e;return m(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Y.projects});let r=e.getQueryData(Y.projects);return e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?$n(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Y.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Y.projects})})}function $n(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?[]:Rn(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 Q(e){let t=v();return A({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Y.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Y.projects})})}function er(){return Q(e=>{let{projectId:t,...n}=e;return Dt(t,n)})}function tr(){return Q(e=>{let{projectId:t,webhookId:n,...r}=e;return he(t,n,r)})}function nr(){return Q(({projectId:e,webhookId:t})=>xt(e,t))}function rr(){return A({mutationFn:({projectId:e,webhookId:t})=>d(e,t),retry:!1})}function ir(e){let t=v();return A({mutationFn:t=>Ae(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function $(e){let t=v();return A({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Y.agentProfiles}),t.invalidateQueries({queryKey:Y.projects})])}})}function ar(){return $(e=>Ct(e))}function or(){return $(e=>{let{id:t,...n}=e;return Te(t,n)})}function sr(){return $(e=>We(e))}function cr(){return $(e=>wt(e))}function lr(e,t){return E({queryKey:Y.agentAccountDetails(e),queryFn:({signal:t})=>g(e,{signal:t}),enabled:t,staleTime:0,retry:!1})}function ur(e,t){return E({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>ne(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function dr(){let e=v();return A({mutationFn:({provider:e,profileId:t})=>Ze(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),C(n)?X(e,n,`none`):Promise.resolve()])}})}function fr(){let e=v();return A({mutationFn:e=>ne(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),C(t.status.provider)&&X(e,t.status.provider)}})}function pr(){return A({mutationFn:e=>{let{routeId:t,...n}=e;return te(t,n)},retry:!1})}function mr(){let e=v();return A({mutationFn:e=>ct(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function hr(){let e=v();return A({mutationFn:e=>Ve(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function gr({enabled:e}){return E({queryKey:Y.githubOwners,queryFn:({signal:e})=>yt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function _r(){let e=v();(0,O.useEffect)(()=>{let n,r=()=>{let r=e.getQueryData(J.health),i=r?.capabilities?.localHandoff===!0;r&&Ce({local:i,bootProject:r.bootProject??`default`,apiBase:t()}),i&&n===void 0?n=It(`health`,t=>{e.setQueryData(J.health,t)}):!i&&n!==void 0&&(n(),n=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),n?.(),ge()}},[e])}function vr(){return E({queryKey:J.health,queryFn:({signal:e})=>vt({signal:e})})}function yr(e,t){let n=vr().data,r=Jn(t).data?.projects,i=gt(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?Fn(n?.repo?.remote):void 0}function br(){return E({queryKey:J.openTargets,queryFn:({signal:e})=>qe({signal:e}),staleTime:5*6e4})}function xr(){return E({queryKey:J.runs.list(),queryFn:({signal:e})=>it(j(),{signal:e})})}function Sr(e,t){return T({queryKey:J.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>l({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 Cr(e){let t=e.trim();return E({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>Le(t,{signal:e}),enabled:t.length>=2,placeholderData:dt,staleTime:1e4})}function wr(e=!0,t=dn){let n=V(v());return D(`/api/v1/workspace/runs-index`,Y.runsIndex,a(e?t:!1),mn),E({queryKey:Y.runsIndex,queryFn:({signal:e})=>c({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function Tr(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>it(j({projectId:e,boot:n}),{signal:t}),enabled:t,placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function Er(e){let t=v();return A({mutationFn:e=>nt(e),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function Dr(e,t={}){return E({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>h(e,{signal:t}),enabled:t.enabled??!0})}function Or(e){return E({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>Tt(M(e),{signal:t}),enabled:!!e})}function kr(e,t,n=!0){return E({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Tt(M(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Ar(e){return E({queryKey:J.runs.diff(e??``),queryFn:({signal:t})=>we(e,{signal:t}),enabled:!!e})}function jr(e,t=!1){return D(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),a(t?4e3:!1)),E({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>At(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Mr(e,t){return E({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>p(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Nr(e,t){return E({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Me(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Pr(e,t){return E({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Oe(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Fr(e,t){return E({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>y(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ir(e){return E({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Ee(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Lr(e,t=!1){return D(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),a(t?5e3:!1)),E({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>Ot(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Rr(e,t){return E({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>He(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function zr(e,t=!0){return E({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>Et(M(e),{signal:t}),enabled:!!e&&t})}function Br(e,t,n){return E({queryKey:e===void 0?J.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Et(M(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Vr(e,t){let r=[...new Set(e)],i=k({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>se({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,O.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function Hr(){return E({queryKey:J.workflows,queryFn:({signal:e})=>ve({signal:e})})}function Ur(e=!0){let t=v(),n=J.skills,r=n[0],i=E({queryKey:n,queryFn:({signal:e})=>rt({signal:e}),enabled:e}),a=E({queryKey:J.skillsReady,queryFn:({signal:e})=>pe({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`],a.data)},[t,a.data,r]),i}function Wr(e=!0){let t=v(),n=J.importableSkills,r=n[0],i=E({queryKey:n,queryFn:({signal:e})=>Ge({signal:e}),enabled:e}),a=E({queryKey:J.importableSkillsReady,queryFn:({signal:e})=>st({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`,`importable`],a.data)},[t,a.data,r]),i}function Gr(){return E({queryKey:J.launchKey,queryFn:({signal:e})=>St({signal:e}),staleTime:1/0})}function Kr(){return E({queryKey:J.repo,queryFn:({signal:e})=>ut({signal:e})})}function qr(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>ut({signal:t},e)})}function Jr(){return E({queryKey:J.repoBranches,queryFn:({signal:e})=>$e({signal:e})})}function Yr(){return E({queryKey:J.repoChanges,queryFn:({signal:e})=>Qe({signal:e}),retry:!1})}function Xr(e){return E({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>Re(e,{signal:t}),enabled:!!e,retry:!1})}function Zr(){return E({queryKey:J.config,queryFn:({signal:e})=>ae({signal:e})})}function Qr(){return E({queryKey:J.worktrees,queryFn:({signal:e})=>de({signal:e})})}function $r(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>de({signal:t},e),staleTime:0})}function ei(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>me({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:Pt(e.sidebarLimits)},enabled:t})}function ti(){return ei(n())}function ni(){return E({queryKey:J.agentConfig,queryFn:({signal:e})=>le({signal:e})})}function ri(e){return E({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>be(e,{signal:t}),enabled:e!==null})}function ii(e){let t=v(),n=J.agentConfig,r=J.agentConfigFile(e);return A({mutationFn:t=>s(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function ai(){return E({queryKey:Y.uiState,queryFn:({signal:e})=>ie({signal:e})})}function oi(){return E({queryKey:Y.config,queryFn:({signal:e})=>_({signal:e})})}function si(){return E({queryKey:Y.agentProfiles,queryFn:({signal:e})=>jt({signal:e})})}function ci(e){let t=v();return A({mutationFn:t=>oe(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function li(e){let t=R(),n=e?.projectId,r=e?.cacheScope,i=A({mutationFn:e=>Se(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,O.useCallback)(e=>({...M(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,O.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,O.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,O.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function ui(){let e=R();return A({mutationFn:e=>Se(M(e),!1),onMutate:t=>e.patchRead(()=>M(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function di(e){let t=R();return A({mutationFn:({id:t,pinned:n})=>Ne(M(t,e),n),onError:e=>Lt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??j(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function fi(e,t){let n=R();return A({mutationFn:n=>kt(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof et&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function pi(e,t){let n=R();return A({mutationFn:(n={})=>Ie(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function mi(e){let t=v();return A({mutationFn:({msgId:t,message:n})=>fe(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function hi(e){let t=v();return A({mutationFn:t=>Ke(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function gi(e={},t=!0){let r=v(),i=J.github(e);D(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=E({queryKey:J.github(e),queryFn:({signal:t})=>b({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=E({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>tt(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{!s||!c.data&&!c.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==s||e.projectsState!==`refreshing`)return e;let t=c.data;return t?.generation&&t.generation!==s?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[r,s,c.data,c.error,i]),o}var _i=class extends Error{};function vi(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await b({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new _i(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>zn(e),retry:(e,t)=>!(t instanceof _i)&&!(t instanceof et&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function yi(e=50,t=!0){let r=v(),i=J.githubPages(e),o=J.githubPagesHead(e);D(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=T({...vi(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=E({queryKey:o,queryFn:({signal:t})=>b({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,O.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=Un(e.pages,c.data);t===`refetch`?l():r.setQueryData(i,{...e,pages:t})},[r,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=k({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>tt(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,O.useEffect)(()=>{d.forEach((e,t)=>{let n=u[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,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,O.useMemo)(()=>Hn(s.data?.pages??[]),[s.data])}}function bi(e,t=50,n=!0){let r=T({...vi([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,O.useMemo)(()=>Hn(r.data?.pages??[]),[r.data])}}function xi(e,t,n=!0){let r=k({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>ye(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,O.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 Si(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>pt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Ci(e,t=!0){return E({queryKey:J.githubChecks(e),queryFn:({signal:t})=>Pe(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function wi(e,t,n=!0){return E({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>pt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ti=100;function Ei(e){return[...e].sort((e,t)=>t-e).slice(0,Ti).sort((e,t)=>e-t)}function Di(){let e=gt(),t=vr();return e.projectId??t.data?.bootProject}function Oi(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))U(G({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))U(G({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var ki=5*6e4;function Ai(e){return e?e.recheckAfterMs:ki}function ji(e,t=!0){let n=(0,O.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:Ei(t.prs),issues:Ei(t.issues)}))},[e.map(G).sort().join(`|`)]),r=k({queries:n.map(e=>({queryKey:J.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>Be(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ai(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=v(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Ai(r[t]?.data)??!1})));(0,O.useEffect)(()=>{if(!t||i())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=J.githubRefStatus(t.projectId,t.prs,t.issues);return Ft({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,O.useMemo)(()=>Pn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,O.useCallback)(e=>{let t=G(e),n=s.get(t);if(n)return n;let r=H.get(t);return{state:`idle`,...r?{status:r}:{},...W.has(t)?{conflicting:!0}:{}}},[s])}function Mi(e,t,n=!0){return E({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>o(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ni(e,t,n=!0){return E({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>Ye(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Pi(e){return E({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>ft(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Jn as $,A as $t,gr as A,fi as At,ir as B,ai as Bt,Nr as C,Dr as Ct,xi as D,wr as Dt,Ci as E,xr as Et,_r as F,or as Ft,bi as G,Ln as Gt,br as H,Y as Ht,Wr as I,Qn as It,yr as J,Sn as Jt,Si as K,Fn as Kt,Gr as L,tr as Lt,Pi as M,Br as Mt,wi as N,rr as Nt,Mi as O,Cr as Ot,vr as P,ti as Pt,$r as Q,M as Qt,li as R,Hr as Rt,mi as S,zr as St,gi as T,Z as Tt,ci as U,Bn as Ut,pr as V,Qr as Vt,di as W,In as Wt,Tr as X,R as Xt,kr as Y,V as Yt,ei as Z,j as Zt,pi as _,jr as _t,ur as a,Kn as at,er as b,Ar as bt,si as c,Zn as ct,Fr as d,Kr as dt,Rt as en,Gn as et,Ir as f,Jr as ft,dr as g,Or as gt,Zr as h,qn as ht,lr as i,ji as it,yi as j,Ur as jt,Ni as k,cr as kt,Sr as l,nr as lt,mr as m,Xr as mt,J as n,fr as nt,ni as o,Xn as ot,Vr as p,Yr as pt,qr as q,bn as qt,Oi as r,Di as rt,ri as s,sr as st,X as t,ii as tt,Pr as u,hi as ut,ar as v,Rr as vt,Yn as w,Wn as wt,Er as x,Mr as xt,hr as y,Lr as yt,ui as z,oi as zt};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,p as n,u as r}from"./button-Czdi8NqC.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Jt as o,it as s,qt as c}from"./queries-BLvbAnL8.js";import{a as l,d as u,i as d,r as f}from"./use-desktop-CW-Femww.js";import{F as p,I as m,N as h,P as g,U as _,_ as v,ct as y,g as b,h as x,m as S,p as C}from"./design-icons-DmYTv2r1.js";import{t as w}from"./createLucideIcon-BHp8sXmF.js";var T=w(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agents`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function D(e,t=` → `){return E[e].join(t)}var O=e(i(),1),k=a(),A=(0,O.createContext)(null);function j({children:e}){let[t,n]=(0,O.useState)(()=>new Map),r=(0,O.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,O.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=s((0,O.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,O.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,k.jsx)(A.Provider,{value:o,children:e})}var M=(0,O.createContext)(null);function ee({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,O.useContext)(A),a=(0,O.useContext)(M),o=(0,O.useId)();(0,O.useEffect)(()=>{if(i)return i.publish(o,n),()=>i.retract(o)},[i,o,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=s(i?N:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,O.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,k.jsx)(M.Provider,{value:d,children:r})}var N=[];function P(e,t,n){let r=(0,O.useContext)(M),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function F(e,t){let n=(0,O.useContext)(M),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function I(){let e=(0,O.useContext)(M);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),ne={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},L={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},re={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},R={draft:p,"review-required":m,"changes-requested":_,"checks-pending":null,"checks-failing":v,ready:C,merged:h,closed:g,open:S,completed:C,"not-planned":b};function z(e){return e===`PR`?`pr-chip`:`issue-chip`}function B(e){return e?{"data-conflicting":`true`}:{}}function V(e,t,n,r){return!n||r!==void 0&&u({kind:e,number:t??0,url:n},r)}function H(e,t,n){return e===`PR`&&(t??n)===!0}function U({plain:e,inert:t,conflicting:n,className:i,tone:a}){return e?r(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,i):r(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,ne[a],i)}function W(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function G(e){return e===`PR`?`pull request`:`issue`}function K(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function q(e,t){return e&&t?L[t.tone]:void 0}function J(e,n){return!e&&(!n||!t(n))}function Y({conflicting:e,presentation:t,status:n,plain:i,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,k.jsxs)(k.Fragment,{children:[e?(0,k.jsx)(y,{className:r(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,k.jsx)($,{status:t?n:void 0,className:i?r(`size-2.5`,l):void 0}),i&&a?s===`PR`?(0,k.jsx)(m,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,k.jsx)(S,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,i?(0,k.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function ie({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,k.jsx)(`span`,{"data-slot":z(e),"data-status":t,"data-inert":`true`,...B(n),className:r,children:i})}function ae({kind:e,number:n,tooltip:r,url:i}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,n?` #${n}`:``,` · `,r.headline]}),(0,k.jsx)(`span`,{className:`block`,children:r.detail}),r.also?(0,k.jsx)(`span`,{className:`block opacity-70`,children:r.also}):null,i&&t(i)?(0,k.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function oe({reference:e,taskTitle:t,status:n,conflicting:i,conflictAction:a,projectId:s,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=I(),y=P(h,V(h,g,_,l??v.repoBase)?g:void 0,s),b=n??y.status,x=o(b),S=H(h,i,y.conflicting),C=S?c:x,w=C?.tone??`accent`,T=U({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=ue(y,C,S?x:void 0),D=W(h,g,p,f),O=G(h),A=K(O,g,t,C),j=(0,k.jsx)(Y,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:D,glyphClass:q(p,C)});if(m)return(0,k.jsx)(ie,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=J(u,_)?(0,k.jsx)(`span`,{"data-slot":z(h),"data-status":b,...B(S),"aria-label":C?`${O} ${D} — ${C.label}`:void 0,className:T,children:j}):(0,k.jsx)(se,{to:u,url:_,"data-slot":z(h),"data-status":b,...B(S),title:E?void 0:_,"aria-label":A,className:p?T:r(T,re[w]),children:j});return E?(0,k.jsx)(le,{chip:M,action:S?a:void 0,state:y.state,children:(0,k.jsx)(ae,{kind:h,number:g,tooltip:E,url:_})}):M}function se({to:e,url:t,children:r,...i}){return e?(0,k.jsx)(n,{to:e,...i,children:r}):(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...i,children:r})}var X=(0,O.createContext)(()=>{});function ce(){return(0,O.useContext)(X)}var Z=150,Q=120;function le({chip:e,action:t,state:n,children:r}){let[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(null),s=(0,O.useRef)(null),c=(0,O.useRef)(void 0),u=(0,O.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),p=(0,O.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,O.useEffect)(()=>()=>clearTimeout(c.current),[]);let m=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,k.jsxs)(f,{open:i,onOpenChange:e=>e?a(!0):p(),children:[(0,k.jsx)(d,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&u(!0,Z)},onPointerLeave:e=>{e.pointerType!==`touch`&&u(!1,Q)},onFocus:()=>a(!0),onBlur:e=>{m(e.relatedTarget)||p()},onKeyDown:e=>{if(e.key===`Escape`)return p();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,k.jsxs)(l,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),m(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&u(!1,Q)},children:[(0,k.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,k.jsx)(X.Provider,{value:p,children:t}):null]})]})}function ue(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${de(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function de(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fe({kind:e,number:t,className:n}){let i=P(e,t),a=o(i.status),s=e===`PR`&&i.conflicting===!0,l=s?c:a;if(!l)return null;let u=r(`size-2.5`,L[l.tone]);return(0,k.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":i.status,...s?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:r(`inline-flex items-center`,n),children:s?(0,k.jsx)(y,{className:r(`shrink-0`,u),"aria-hidden":`true`}):(0,k.jsx)($,{status:i.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,k.jsx)(x,{"data-slot":`status-dot`,"data-tone":`pending`,className:r(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=R[e];return n?(0,k.jsx)(n,{className:r(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{j as a,P as c,ee as i,D as l,fe as n,F as o,ce as r,I as s,oe as t,T as u};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,p as n,u as r}from"./button-Czdi8NqC.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Jt as o,it as s,qt as c}from"./queries-00V5jnAV.js";import{a as l,d as u,i as d,r as f}from"./use-desktop-C3yCutND.js";import{F as p,I as m,N as h,P as g,U as _,_ as v,ct as y,g as b,h as x,m as S,p as C}from"./design-icons-DmYTv2r1.js";import{t as w}from"./createLucideIcon-BHp8sXmF.js";var T=w(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agents`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function D(e,t=` → `){return E[e].join(t)}var O=e(i(),1),k=a(),A=(0,O.createContext)(null);function j({children:e}){let[t,n]=(0,O.useState)(()=>new Map),r=(0,O.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,O.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=s((0,O.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,O.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,k.jsx)(A.Provider,{value:o,children:e})}var M=(0,O.createContext)(null);function ee({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,O.useContext)(A),a=(0,O.useContext)(M),o=(0,O.useId)();(0,O.useEffect)(()=>{if(i)return i.publish(o,n),()=>i.retract(o)},[i,o,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=s(i?N:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,O.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,k.jsx)(M.Provider,{value:d,children:r})}var N=[];function P(e,t,n){let r=(0,O.useContext)(M),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function F(e,t){let n=(0,O.useContext)(M),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function I(){let e=(0,O.useContext)(M);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),ne={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},L={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},re={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},R={draft:p,"review-required":m,"changes-requested":_,"checks-pending":null,"checks-failing":v,ready:C,merged:h,closed:g,open:S,completed:C,"not-planned":b};function z(e){return e===`PR`?`pr-chip`:`issue-chip`}function B(e){return e?{"data-conflicting":`true`}:{}}function V(e,t,n,r){return!n||r!==void 0&&u({kind:e,number:t??0,url:n},r)}function H(e,t,n){return e===`PR`&&(t??n)===!0}function U({plain:e,inert:t,conflicting:n,className:i,tone:a}){return e?r(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,i):r(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,ne[a],i)}function W(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function G(e){return e===`PR`?`pull request`:`issue`}function K(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function q(e,t){return e&&t?L[t.tone]:void 0}function J(e,n){return!e&&(!n||!t(n))}function Y({conflicting:e,presentation:t,status:n,plain:i,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,k.jsxs)(k.Fragment,{children:[e?(0,k.jsx)(y,{className:r(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,k.jsx)($,{status:t?n:void 0,className:i?r(`size-2.5`,l):void 0}),i&&a?s===`PR`?(0,k.jsx)(m,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,k.jsx)(S,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,i?(0,k.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function ie({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,k.jsx)(`span`,{"data-slot":z(e),"data-status":t,"data-inert":`true`,...B(n),className:r,children:i})}function ae({kind:e,number:n,tooltip:r,url:i}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,n?` #${n}`:``,` · `,r.headline]}),(0,k.jsx)(`span`,{className:`block`,children:r.detail}),r.also?(0,k.jsx)(`span`,{className:`block opacity-70`,children:r.also}):null,i&&t(i)?(0,k.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function oe({reference:e,taskTitle:t,status:n,conflicting:i,conflictAction:a,projectId:s,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=I(),y=P(h,V(h,g,_,l??v.repoBase)?g:void 0,s),b=n??y.status,x=o(b),S=H(h,i,y.conflicting),C=S?c:x,w=C?.tone??`accent`,T=U({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=ue(y,C,S?x:void 0),D=W(h,g,p,f),O=G(h),A=K(O,g,t,C),j=(0,k.jsx)(Y,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:D,glyphClass:q(p,C)});if(m)return(0,k.jsx)(ie,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=J(u,_)?(0,k.jsx)(`span`,{"data-slot":z(h),"data-status":b,...B(S),"aria-label":C?`${O} ${D} — ${C.label}`:void 0,className:T,children:j}):(0,k.jsx)(se,{to:u,url:_,"data-slot":z(h),"data-status":b,...B(S),title:E?void 0:_,"aria-label":A,className:p?T:r(T,re[w]),children:j});return E?(0,k.jsx)(le,{chip:M,action:S?a:void 0,state:y.state,children:(0,k.jsx)(ae,{kind:h,number:g,tooltip:E,url:_})}):M}function se({to:e,url:t,children:r,...i}){return e?(0,k.jsx)(n,{to:e,...i,children:r}):(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...i,children:r})}var X=(0,O.createContext)(()=>{});function ce(){return(0,O.useContext)(X)}var Z=150,Q=120;function le({chip:e,action:t,state:n,children:r}){let[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(null),s=(0,O.useRef)(null),c=(0,O.useRef)(void 0),u=(0,O.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),p=(0,O.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,O.useEffect)(()=>()=>clearTimeout(c.current),[]);let m=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,k.jsxs)(f,{open:i,onOpenChange:e=>e?a(!0):p(),children:[(0,k.jsx)(d,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&u(!0,Z)},onPointerLeave:e=>{e.pointerType!==`touch`&&u(!1,Q)},onFocus:()=>a(!0),onBlur:e=>{m(e.relatedTarget)||p()},onKeyDown:e=>{if(e.key===`Escape`)return p();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,k.jsxs)(l,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),m(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&u(!1,Q)},children:[(0,k.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,k.jsx)(X.Provider,{value:p,children:t}):null]})]})}function ue(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${de(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function de(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fe({kind:e,number:t,className:n}){let i=P(e,t),a=o(i.status),s=e===`PR`&&i.conflicting===!0,l=s?c:a;if(!l)return null;let u=r(`size-2.5`,L[l.tone]);return(0,k.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":i.status,...s?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:r(`inline-flex items-center`,n),children:s?(0,k.jsx)(y,{className:r(`shrink-0`,u),"aria-hidden":`true`}):(0,k.jsx)($,{status:i.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,k.jsx)(x,{"data-slot":`status-dot`,"data-tone":`pending`,className:r(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=R[e];return n?(0,k.jsx)(n,{className:r(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{j as a,P as c,ee as i,D as l,fe as n,F as o,ce as r,I as s,oe as t,T as u};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,E as n,L as r,M as i,d as a,t as o,u as s}from"./button-Czdi8NqC.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{Gr as u,Gt as d,O as f,S as p,an as m,i as h,in as g,w as _}from"./project-scope-context-WiGQMFsB.js";import{ft as v}from"./live-protocol-DjH6ZQwI.js";import{$t as y,Et as b,H as ee,J as x,Jt as S,P as te,T as ne,Vt as re,dt as C,ft as w,mt as ie,n as T,pt as ae}from"./queries-BLvbAnL8.js";import{n as E,u as D}from"./use-desktop-CW-Femww.js";import{n as O}from"./toaster-2NK3PogQ.js";import{D as oe,I as se,M as ce,N as le,Q as ue,S as de,X as fe,Z as pe,c as me,ct as k,d as he,j as A,n as ge,st as _e,w as j,y as ve}from"./design-icons-DmYTv2r1.js";import{t as M}from"./createLucideIcon-BHp8sXmF.js";import{l as ye,n as be,y as xe}from"./nav-row-styles-DoZBu-jT.js";import{n as Se,r as Ce}from"./diff-controls-DzcrZF8L.js";import{i as we,r as Te,t as Ee}from"./git-toolbar-B5EhJG95.js";import{t as N}from"./info-DA1x_4bz.js";import{a as De,i as P}from"./format-BNCkW110.js";import{c as Oe,i as ke,l as Ae,t as je}from"./reference-chip-P6ytqWNt.js";import{i as F,l as Me,p as Ne,r as Pe,t as Fe}from"./dropdown-menu-BN2BI4R1.js";import{a as I,c as L,i as R,n as z,o as B,r as V,s as H,t as U}from"./alert-dialog-CPBKJTj_.js";import{t as W}from"./input-Dilvz-YI.js";import{t as G}from"./project-router-Coo_s3l-.js";import{t as K}from"./centered-state-8l6wvu0C.js";import{A as q,Yt as Ie,_n as J,_t as Le,ct as Re,dt as ze,ft as Be,gt as Ve,ht as He,k as Ue,ln as We,lt as Ge,mt as Ke,ot as qe,pt as Je,st as Ye,ut as Xe}from"./index-O1VoICYw.js";import{t as Ze}from"./markdown-BBDDg-4t.js";import{t as Qe}from"./diff-DwhVa59f.js";import{t as $e}from"./commit-diff-panel-B1FnfuXx.js";var Y=e(c(),1);function et(e,t){let n=u(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(v.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var tt=M(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),nt=M(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=l();function rt(){let e=i(),t=C(),n=u(),r=et({queryKey:T.repo})>0,a=t.data?.info?t.data:null,o=qe(e,a,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:be,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:s(ye,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:T.repo}),n.invalidateQueries({queryKey:T.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(pe,{size:17,"aria-hidden":`true`,className:s(`size-[17px]`,r&&`motion-safe:animate-spin`)})})]}),a?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ge,{scope:e,repo:a,info:a.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(Ye,{branch:a?.info?.branch??null,counts:o,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function it({repo:e,info:t}){let n=te(),r=w(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),a=u(),c=y({mutationFn:e=>p({name:e}),onSuccess:async e=>{O(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:T.repo}),a.invalidateQueries({queryKey:T.health})]),a.setQueryData(T.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(T.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>O(e.message,{tone:`danger`})}),[l,d]=(0,Y.useState)(``),[f,m]=(0,Y.useState)(``),h=f.trim().toLowerCase(),g=Q(e,r.data?.branches),_=h?g.filter(e=>e.toLowerCase().includes(h)):g;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(ue,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(W,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:f,onChange:e=>m(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[_.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(G,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:s(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(lt,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(o,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:c.isPending,onClick:()=>c.mutate(e),children:[(0,X.jsx)(A,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,f.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&c.mutate(t,{onSuccess:()=>d(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(W,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>d(e.target.value)}),(0,X.jsxs)(o,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||c.isPending,children:[(0,X.jsx)(fe,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(at,{}):null]})}function at(){let e=ne({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(ot,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function ot({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(se,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(st,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:s(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function st({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:s(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var ct={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function lt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:s(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:ct[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function ut(){let e=ae(),t=E(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof h&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>Te(f),[f]),m=(0,Y.useMemo)(()=>f.some(Ze),[f]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(Ee,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(Se,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),m?(0,X.jsx)(Ce,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(K,{icon:d?(0,X.jsx)(j,{size:16}):(0,X.jsx)(k,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(K,{icon:(0,X.jsx)(j,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(we,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Qe,{files:f,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function dt({repo:e,info:t}){let{sha:r}=n(),i=e.log,a=(0,Y.useMemo)(()=>Ve(i),[i]);if(r)return(0,X.jsx)(mt,{sha:r});let o=Ke(e,t),s=o&&o.behind>0?(0,X.jsx)(pt,{info:t,tracking:o}):null;return i.length===0?(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:s}):null,(0,X.jsx)(K,{icon:(0,X.jsx)(ce,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(G,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,Le(e.when)]})]})]}),(0,X.jsx)(ft,{source:e.source})]},e.hash))})]},e.label))]})}function ft({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;return e?(0,X.jsxs)(G,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:s(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(le,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function pt({info:e,tracking:t}){let n=ze(i(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(tt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(De,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ge,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(Xe,{checkout:n,returnFocus:r})]})}function mt({sha:e}){return(0,X.jsx)($e,{commit:ie(e),sha:e,backTo:E()?`/git`:Be,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function ht(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function gt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var _t={done:`success`,failed:`danger`,cancelled:`neutral`};function vt(){let e=w(),t=b(),n=i(),r=x(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(K,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=ht(e.data.branches),c=gt(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(G,{to:Je.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(ke,{projectId:n,repoBase:r,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(yt,{}),l,s.length===0?(0,X.jsx)(K,{icon:(0,X.jsx)(We,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(bt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(Tt,{entry:a,onClose:()=>o(null)})]})}function yt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:s(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function bt({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(Ct,{entry:e,finishedAt:t}),(0,X.jsx)(xt,{entry:e}),(0,X.jsx)(St,{entry:e,onDelete:n})]})}function xt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(je,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(wt,{entry:e})]}):null})}function St({entry:e,onDelete:t}){let n=u(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=y({mutationFn:()=>_(e.runId),onSuccess:e=>{O(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:T.repoBranches}),n.invalidateQueries({queryKey:T.runs.all})},onError:e=>O(e instanceof h&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>O(`Copied ${e.name}`),()=>O(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(G,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:s(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(nt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(ve,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Fe,{children:[(0,X.jsx)(Ne,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Pe,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(F,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(G,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(F,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(F,{className:s(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(Me,{className:`md:hidden`}),(0,X.jsx)(F,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Ct({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=P(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(xe,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Ie,{tone:e.runStatus&&_t[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[e.runId?(0,X.jsx)(G,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),(0,X.jsx)(Z,{entry:e})]})]})}function wt({entry:e}){let t=S(Oe(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function Tt({entry:e,onClose:t}){let n=u(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=y({mutationFn:e=>f({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;O(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:T.repo}),s()},onError:e=>O(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(U,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(R,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(L,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(I,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(W,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(V,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(z,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Et({base:e}){let t=w(),n=u(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],d=y({mutationFn:e=>f({names:e}),onSuccess:e=>{let t=e.refused.length;O(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:T.repo})},onError:e=>{n.invalidateQueries({queryKey:T.repo}),O(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||d.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[12px]`}),d.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Dt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Dt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(U,{open:a,onOpenChange:o,children:(0,X.jsxs)(R,{children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(L,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(I,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(V,{children:`Keep them`}),(0,X.jsxs)(z,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{d.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Dt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:s(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(G,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:P(e.lastCommit.at)})]},e.name))}):null]})}function Ot(){let e=re(),t=ee().data?.targets.find(e=>e.id===`finder`),n=y({mutationFn:e=>d(e,t.id),onError:e=>O(e.message,{tone:`danger`})}),r=u(),[i,a]=(0,Y.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:T.worktrees}),r.invalidateQueries({queryKey:T.repoBranches})]),s=y({mutationFn:e=>m(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);O(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>O(e.message,{tone:`danger`})}),c=y({mutationFn:e=>g(e.runId),onSuccess:(e,t)=>{o(),O(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),O(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:l,totalBytes:f,keep:p}=e.data,h=s.isPending||c.isPending,_=l.filter(e=>e.pastKeep),v=_.length>0,b=_.some(e=>e.sizeBytes===null)?null:_.reduce((e,t)=>e+(t.sizeBytes??0),0),x=v?b?`Reclaim ${D(b)} now`:`Reclaim ${_.length} now`:`Reclaim now`,S=f?D(f):null;return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,S?` · ${S}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[p===0?`Retention is unlimited (`:`Retention keeps the newest ${p} finished checkout${p===1?``:`s`} (`,(0,X.jsx)(G,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Ae(`worktrees`,` › `)}),p===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:h||!v,title:v?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[12px]`}),x]})]}),l.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:l.map(e=>(0,X.jsx)(jt,{worktree:e,keep:p,disabled:h,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,X.jsx)(U,{open:i,onOpenChange:a,children:(0,X.jsxs)(R,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(L,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(I,{children:[_.length,` finished worktree`,_.length===1?``:`s`,` beyond the keep limit`,b?` (${D(b)})`:``,` `,_.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(V,{children:`Keep them`}),(0,X.jsx)(z,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(_.length),a(!1)},children:x})]})]})})]})}var kt=new Set([`queued`,`running`,`waiting`,`review`]);function At(e,t){return kt.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function jt({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=At(e,t),c=P(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:s(`text-[11.5px]`,o.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:o.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:D(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(oe,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:a,className:d,children:(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Mt({section:e,index:n=!1}){let i=C(),a=E(),[o]=t();if(n&&!a&&o.get(`view`)!==`repo`)return(0,X.jsx)(rt,{});if(i.isPending)return(0,X.jsx)(Ue,{});if(i.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(q,{}),(0,X.jsx)(K,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:i.error.message})]});let s=i.data.info;return s?(0,X.jsx)(Nt,{repo:i.data,info:s,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(q,{}),(0,X.jsx)(K,{icon:(0,X.jsx)(A,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`${r(`cezar`)} is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Nt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(q,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Re(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Pt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(vt,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(Et,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(it,{repo:e,info:t}):(0,X.jsx)(ut,{})]})}function Pt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`no commits yet`:`latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${He(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Ft,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`nothing here can delete work that is not on `,r]})}}function Ft({repo:e,info:t}){let n=Q(e,w().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{Mt as RepoGitRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,E as n,L as r,M as i,d as a,t as o,u as s}from"./button-Czdi8NqC.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{Gr as u,Gt as d,O as f,S as p,an as m,i as h,in as g,w as _}from"./project-scope-context-X6-LgbYE.js";import{ft as v}from"./live-protocol-DjH6ZQwI.js";import{$t as y,Et as b,H as ee,J as x,Jt as S,P as te,T as ne,Vt as re,dt as C,ft as w,mt as ie,n as T,pt as ae}from"./queries-00V5jnAV.js";import{n as E,u as D}from"./use-desktop-C3yCutND.js";import{n as O}from"./toaster-2NK3PogQ.js";import{D as oe,I as se,M as ce,N as le,Q as ue,S as de,X as fe,Z as pe,c as me,ct as k,d as he,j as A,n as ge,st as _e,w as j,y as ve}from"./design-icons-DmYTv2r1.js";import{t as M}from"./createLucideIcon-BHp8sXmF.js";import{l as ye,n as be,y as xe}from"./nav-row-styles-DoZBu-jT.js";import{n as Se,r as Ce}from"./diff-controls-DzcrZF8L.js";import{i as we,r as Te,t as Ee}from"./git-toolbar-Dya9briW.js";import{t as N}from"./info-DA1x_4bz.js";import{a as De,i as P}from"./format-BNCkW110.js";import{c as Oe,i as ke,l as Ae,t as je}from"./reference-chip-AZWOlSRV.js";import{i as F,l as Me,p as Ne,r as Pe,t as Fe}from"./dropdown-menu-BN2BI4R1.js";import{a as I,c as L,i as R,n as z,o as B,r as V,s as H,t as U}from"./alert-dialog-CPBKJTj_.js";import{t as W}from"./input-Dilvz-YI.js";import{t as G}from"./project-router-uJ3SkX70.js";import{t as K}from"./centered-state-8l6wvu0C.js";import{A as q,Yt as Ie,_n as J,_t as Le,ct as Re,dt as ze,ft as Be,gt as Ve,ht as He,k as Ue,ln as We,lt as Ge,mt as Ke,ot as qe,pt as Je,st as Ye,ut as Xe}from"./index-DYx21hr3.js";import{t as Ze}from"./markdown-BBDDg-4t.js";import{t as Qe}from"./diff-DDwr1gUX.js";import{t as $e}from"./commit-diff-panel-DmhrguZk.js";var Y=e(c(),1);function et(e,t){let n=u(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(v.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var tt=M(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),nt=M(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=l();function rt(){let e=i(),t=C(),n=u(),r=et({queryKey:T.repo})>0,a=t.data?.info?t.data:null,o=qe(e,a,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:be,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:s(ye,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:T.repo}),n.invalidateQueries({queryKey:T.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(pe,{size:17,"aria-hidden":`true`,className:s(`size-[17px]`,r&&`motion-safe:animate-spin`)})})]}),a?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ge,{scope:e,repo:a,info:a.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(Ye,{branch:a?.info?.branch??null,counts:o,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function it({repo:e,info:t}){let n=te(),r=w(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),a=u(),c=y({mutationFn:e=>p({name:e}),onSuccess:async e=>{O(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:T.repo}),a.invalidateQueries({queryKey:T.health})]),a.setQueryData(T.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(T.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>O(e.message,{tone:`danger`})}),[l,d]=(0,Y.useState)(``),[f,m]=(0,Y.useState)(``),h=f.trim().toLowerCase(),g=Q(e,r.data?.branches),_=h?g.filter(e=>e.toLowerCase().includes(h)):g;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(ue,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(W,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:f,onChange:e=>m(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[_.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(G,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:s(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(lt,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(o,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:c.isPending,onClick:()=>c.mutate(e),children:[(0,X.jsx)(A,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,f.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&c.mutate(t,{onSuccess:()=>d(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(W,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>d(e.target.value)}),(0,X.jsxs)(o,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||c.isPending,children:[(0,X.jsx)(fe,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(at,{}):null]})}function at(){let e=ne({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(ot,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function ot({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(se,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(st,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:s(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function st({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:s(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var ct={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function lt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:s(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:ct[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function ut(){let e=ae(),t=E(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof h&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>Te(f),[f]),m=(0,Y.useMemo)(()=>f.some(Ze),[f]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(Ee,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(Se,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),m?(0,X.jsx)(Ce,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(K,{icon:d?(0,X.jsx)(j,{size:16}):(0,X.jsx)(k,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(K,{icon:(0,X.jsx)(j,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(we,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Qe,{files:f,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function dt({repo:e,info:t}){let{sha:r}=n(),i=e.log,a=(0,Y.useMemo)(()=>Ve(i),[i]);if(r)return(0,X.jsx)(mt,{sha:r});let o=Ke(e,t),s=o&&o.behind>0?(0,X.jsx)(pt,{info:t,tracking:o}):null;return i.length===0?(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:s}):null,(0,X.jsx)(K,{icon:(0,X.jsx)(ce,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(G,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,Le(e.when)]})]})]}),(0,X.jsx)(ft,{source:e.source})]},e.hash))})]},e.label))]})}function ft({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;return e?(0,X.jsxs)(G,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:s(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(le,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function pt({info:e,tracking:t}){let n=ze(i(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(tt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(De,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ge,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(Xe,{checkout:n,returnFocus:r})]})}function mt({sha:e}){return(0,X.jsx)($e,{commit:ie(e),sha:e,backTo:E()?`/git`:Be,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function ht(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function gt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var _t={done:`success`,failed:`danger`,cancelled:`neutral`};function vt(){let e=w(),t=b(),n=i(),r=x(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(K,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=ht(e.data.branches),c=gt(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(G,{to:Je.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(ke,{projectId:n,repoBase:r,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(yt,{}),l,s.length===0?(0,X.jsx)(K,{icon:(0,X.jsx)(We,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(bt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(Tt,{entry:a,onClose:()=>o(null)})]})}function yt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:s(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function bt({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(Ct,{entry:e,finishedAt:t}),(0,X.jsx)(xt,{entry:e}),(0,X.jsx)(St,{entry:e,onDelete:n})]})}function xt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(je,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(wt,{entry:e})]}):null})}function St({entry:e,onDelete:t}){let n=u(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=y({mutationFn:()=>_(e.runId),onSuccess:e=>{O(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:T.repoBranches}),n.invalidateQueries({queryKey:T.runs.all})},onError:e=>O(e instanceof h&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>O(`Copied ${e.name}`),()=>O(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(G,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:s(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(nt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(ve,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Fe,{children:[(0,X.jsx)(Ne,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Pe,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(F,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(G,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(F,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(F,{className:s(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(Me,{className:`md:hidden`}),(0,X.jsx)(F,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Ct({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=P(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(xe,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Ie,{tone:e.runStatus&&_t[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[e.runId?(0,X.jsx)(G,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),e.parentRunId?(0,X.jsx)(G,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-[11px] text-soft-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Z,{entry:e})]})]})}function wt({entry:e}){let t=S(Oe(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function Tt({entry:e,onClose:t}){let n=u(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=y({mutationFn:e=>f({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;O(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:T.repo}),s()},onError:e=>O(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(U,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(R,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(L,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(I,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(W,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(V,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(z,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Et({base:e}){let t=w(),n=u(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],d=y({mutationFn:e=>f({names:e}),onSuccess:e=>{let t=e.refused.length;O(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:T.repo})},onError:e=>{n.invalidateQueries({queryKey:T.repo}),O(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||d.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[12px]`}),d.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Dt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Dt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(U,{open:a,onOpenChange:o,children:(0,X.jsxs)(R,{children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(L,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(I,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(V,{children:`Keep them`}),(0,X.jsxs)(z,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{d.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Dt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:s(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(G,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:P(e.lastCommit.at)})]},e.name))}):null]})}function Ot(){let e=re(),t=ee().data?.targets.find(e=>e.id===`finder`),n=y({mutationFn:e=>d(e,t.id),onError:e=>O(e.message,{tone:`danger`})}),r=u(),[i,a]=(0,Y.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:T.worktrees}),r.invalidateQueries({queryKey:T.repoBranches})]),s=y({mutationFn:e=>m(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);O(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>O(e.message,{tone:`danger`})}),c=y({mutationFn:e=>g(e.runId),onSuccess:(e,t)=>{o(),O(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),O(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:l,totalBytes:f,keep:p}=e.data,h=s.isPending||c.isPending,_=l.filter(e=>e.pastKeep),v=_.length>0,b=_.some(e=>e.sizeBytes===null)?null:_.reduce((e,t)=>e+(t.sizeBytes??0),0),x=v?b?`Reclaim ${D(b)} now`:`Reclaim ${_.length} now`:`Reclaim now`,S=f?D(f):null;return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,S?` · ${S}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[p===0?`Retention is unlimited (`:`Retention keeps the newest ${p} finished checkout${p===1?``:`s`} (`,(0,X.jsx)(G,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Ae(`worktrees`,` › `)}),p===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:h||!v,title:v?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[12px]`}),x]})]}),l.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:l.map(e=>(0,X.jsx)(jt,{worktree:e,keep:p,disabled:h,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,X.jsx)(U,{open:i,onOpenChange:a,children:(0,X.jsxs)(R,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(L,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(I,{children:[_.length,` finished worktree`,_.length===1?``:`s`,` beyond the keep limit`,b?` (${D(b)})`:``,` `,_.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(V,{children:`Keep them`}),(0,X.jsx)(z,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(_.length),a(!1)},children:x})]})]})})]})}var kt=new Set([`queued`,`running`,`waiting`,`review`]);function At(e,t){return kt.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function jt({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=At(e,t),c=P(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:s(`text-[11.5px]`,o.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:o.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:D(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(oe,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:a,className:d,children:(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Mt({section:e,index:n=!1}){let i=C(),a=E(),[o]=t();if(n&&!a&&o.get(`view`)!==`repo`)return(0,X.jsx)(rt,{});if(i.isPending)return(0,X.jsx)(Ue,{});if(i.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(q,{}),(0,X.jsx)(K,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:i.error.message})]});let s=i.data.info;return s?(0,X.jsx)(Nt,{repo:i.data,info:s,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(q,{}),(0,X.jsx)(K,{icon:(0,X.jsx)(A,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`${r(`cezar`)} is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Nt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(q,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Re(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Pt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(vt,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(Et,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(it,{repo:e,info:t}):(0,X.jsx)(ut,{})]})}function Pt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`no commits yet`:`latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${He(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Ft,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`nothing here can delete work that is not on `,r]})}}function Ft({repo:e,info:t}){let n=Q(e,w().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{Mt as RepoGitRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,h as i,p as a,t as o,w as s}from"./button-Czdi8NqC.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{i as u,s as d}from"./project-scope-context-WiGQMFsB.js";import{C as f,u as p}from"./queries-BLvbAnL8.js";import{ct as m,r as h}from"./design-icons-DmYTv2r1.js";import{c as g,i as _,l as v,o as y,s as b,t as x}from"./file-preview-xqxo9aYs.js";import{t as S}from"./centered-state-8l6wvu0C.js";import{U as C,b as w,v as T,y as E}from"./index-O1VoICYw.js";var D=e(c(),1),O=l();function k(){let e=t(),n=s();return()=>{if(e.key==="default"||window.history.state?.idx===0){n({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let t=window.navigation,r=A(e.state);t?.canGoBack?t.back():r?n(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):n(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=n(),t=e.get(`path`),r=e.get(`artifact`);return{path:t,artifactId:r,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&r!==null||t===``||r===``}}function N(){let{id:e=``}=r(),n=M(),i=t(),a=k();return(0,O.jsx)(P,{runId:e,selection:n,fragment:i.hash,onBack:a,variant:`route`})}function P({runId:e,selection:n,fragment:r,onBack:a,variant:o,sourceLookup:s}){let{path:c,conflict:l,selected:u,result:d}=I(e,n,s),f=w(T,!0),p=w(E,!1),m=t(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(o===`route`&&L(_))return(0,O.jsx)(i,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,c),y=o===`pane`&&!p&&!f?`Conversation`:`Back`,b=o===`pane`&&!h&&R(_),x=F(m.pathname,e,n);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":o,onKeyDown:e=>{o!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),a())},className:o===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:a,backLabel:y,hideDownload:o===`pane`&&p,focusBack:o===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:l,selected:u,result:d,source:h,name:v,fragment:r,pane:o===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:a=!1}=t,o=n?.isPending||n?.isError,s=f(e,i||a||o?null:r),c=p(e,a||o?null:i),l=o&&n?{...n,data:void 0}:i?c:s;return{path:r,conflict:a,selected:r!==null||i!==null,result:l}}function L(e){return e!==null&&(!C(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let f=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(o,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,O.jsx)(h,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[f?`Published snapshot · ${new Date(f.createdAt).toLocaleString()}`:`Live file`,` · `,_(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(o,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,f&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:d(e,f.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:o,pane:s,filesHref:c}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let l=n.data;return l.type===`file`?s&&!C(l.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(a,{to:c,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):l.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:`Too large to preview`,subtitle:`${_(l.size)} is past the 500 kB preview limit. Download it to read it.`}):l.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(x,{path:l.path,text:l.content??``})}):(0,O.jsx)(y,{html:l.content??``,title:`Report: ${i}`,fragment:o,className:s?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:l.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:l.reason})}function H({result:e}){let t=e.error instanceof u&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(b,{}):(0,O.jsx)(m,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(o,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(S,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,h as i,p as a,t as o,w as s}from"./button-Czdi8NqC.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{i as u,s as d}from"./project-scope-context-X6-LgbYE.js";import{C as f,u as p}from"./queries-00V5jnAV.js";import{ct as m,r as h}from"./design-icons-DmYTv2r1.js";import{c as g,i as _,l as v,o as y,s as b,t as x}from"./file-preview-Cm1jWwBy.js";import{t as S}from"./centered-state-8l6wvu0C.js";import{U as C,b as w,v as T,y as E}from"./index-DYx21hr3.js";var D=e(c(),1),O=l();function k(){let e=t(),n=s();return()=>{if(e.key==="default"||window.history.state?.idx===0){n({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let t=window.navigation,r=A(e.state);t?.canGoBack?t.back():r?n(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):n(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=n(),t=e.get(`path`),r=e.get(`artifact`);return{path:t,artifactId:r,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&r!==null||t===``||r===``}}function N(){let{id:e=``}=r(),n=M(),i=t(),a=k();return(0,O.jsx)(P,{runId:e,selection:n,fragment:i.hash,onBack:a,variant:`route`})}function P({runId:e,selection:n,fragment:r,onBack:a,variant:o,sourceLookup:s}){let{path:c,conflict:l,selected:u,result:d}=I(e,n,s),f=w(T,!0),p=w(E,!1),m=t(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(o===`route`&&L(_))return(0,O.jsx)(i,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,c),y=o===`pane`&&!p&&!f?`Conversation`:`Back`,b=o===`pane`&&!h&&R(_),x=F(m.pathname,e,n);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":o,onKeyDown:e=>{o!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),a())},className:o===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:a,backLabel:y,hideDownload:o===`pane`&&p,focusBack:o===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:l,selected:u,result:d,source:h,name:v,fragment:r,pane:o===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:a=!1}=t,o=n?.isPending||n?.isError,s=f(e,i||a||o?null:r),c=p(e,a||o?null:i),l=o&&n?{...n,data:void 0}:i?c:s;return{path:r,conflict:a,selected:r!==null||i!==null,result:l}}function L(e){return e!==null&&(!C(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let f=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(o,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,O.jsx)(h,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[f?`Published snapshot · ${new Date(f.createdAt).toLocaleString()}`:`Live file`,` · `,_(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(o,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,f&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:d(e,f.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:o,pane:s,filesHref:c}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let l=n.data;return l.type===`file`?s&&!C(l.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(a,{to:c,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):l.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:`Too large to preview`,subtitle:`${_(l.size)} is past the 500 kB preview limit. Download it to read it.`}):l.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(x,{path:l.path,text:l.content??``})}):(0,O.jsx)(y,{html:l.content??``,title:`Report: ${i}`,fragment:o,className:s?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:l.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:l.reason})}function H({result:e}){let t=e.error instanceof u&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(b,{}):(0,O.jsx)(m,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(o,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(S,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};