@wjarka/cezarion 0.18.0-dev.5912 → 0.18.0-dev.5918

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 (28) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{activity-motion-Dj3dlCYS.js → activity-motion-DuQh0btL.js} +1 -1
  3. package/web/dist/assets/{activity-route-CpjbEhk_.js → activity-route-DBgGn2gk.js} +1 -1
  4. package/web/dist/assets/{commit-diff-panel-DGx2t9Pw.js → commit-diff-panel-CDYnqb5F.js} +1 -1
  5. package/web/dist/assets/{control-locations-CD2r0mMU.js → control-locations-8n8XBQoO.js} +1 -1
  6. package/web/dist/assets/{diff-qq2vW6Xc.js → diff-BOJM5Vnh.js} +2 -2
  7. package/web/dist/assets/{diff-view-wanjAW5U.js → diff-view-zFJeZDy3.js} +1 -1
  8. package/web/dist/assets/{file-preview-YiP5f666.js → file-preview-BWZoviRB.js} +1 -1
  9. package/web/dist/assets/{git-toolbar-D0mTYtOj.js → git-toolbar-Ufh7JDw9.js} +1 -1
  10. package/web/dist/assets/{github-DizdAh0y.js → github-Q6SaVhUw.js} +1 -1
  11. package/web/dist/assets/{global-activity-route-DMbPEZPP.js → global-activity-route-Dd5783xw.js} +1 -1
  12. package/web/dist/assets/{index-D51Su-nT.js → index-TZr_ApUY.js} +4 -4
  13. package/web/dist/assets/{preview-pane-connected-DQYoGd9W.js → preview-pane-connected-C7S9mSP0.js} +1 -1
  14. package/web/dist/assets/{queries-C_DEjjv2.js → queries-D2SB1fF4.js} +1 -1
  15. package/web/dist/assets/{repo-git-CSTwuYJ5.js → repo-git-R5uZWz2q.js} +1 -1
  16. package/web/dist/assets/{report-reader-B8D_6si1.js → report-reader-CFYbIXtj.js} +1 -1
  17. package/web/dist/assets/{reports-Dr312nK-.js → reports-Cqa2quZ8.js} +1 -1
  18. package/web/dist/assets/{run-header-B8M6-fvb.js → run-header-VSaI_-E3.js} +1 -1
  19. package/web/dist/assets/{skills-Bz-itxvq.js → skills-Nkv9UM3W.js} +1 -1
  20. package/web/dist/assets/{task-changes-6F8fNE6I.js → task-changes-Sz3qOCQc.js} +1 -1
  21. package/web/dist/assets/{task-commits-1TKZD8tP.js → task-commits-BwED-qWV.js} +1 -1
  22. package/web/dist/assets/{task-files-BitTchRw.js → task-files-DzVYZGkF.js} +1 -1
  23. package/web/dist/assets/{task-github-item-ux8yQOHs.js → task-github-item-99ELrxxr.js} +1 -1
  24. package/web/dist/assets/{task-thread-DAnwO8BU.js → task-thread-D41GSplz.js} +1 -1
  25. package/web/dist/assets/{thread-state-COdb27sX.js → thread-state-BJy69cQG.js} +1 -1
  26. package/web/dist/assets/{use-hand-to-agent-state-CZK9cWMq.js → use-hand-to-agent-state-ChXWXvgV.js} +1 -1
  27. package/web/dist/assets/{workflows-CNnPn5Zx.js → workflows-BbPEoMV1.js} +1 -1
  28. package/web/dist/index.html +3 -3
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{L as t,t as n,u as r}from"./button-CS5tOblf.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Mr as o,Nr as s,Pr as c,mr as l}from"./project-scope-context-DbO9a0ii.js";import{n as u}from"./toaster-CRVRHlMR.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{t as f}from"./arrow-right-Dh_Lx3um.js";import{n as p,r as m,t as h}from"./hourglass-B0lPAJvT.js";import{t as g}from"./info-DA1x_4bz.js";import{a as _}from"./format-BNCkW110.js";import{t as v}from"./play-CmVAj_fu.js";import{c as y,n as ee,o as b,s as x}from"./thread-state-COdb27sX.js";import{s as te}from"./project-router-BLO2IxbU.js";import{a as S,c as C,i as w,l as T,p as E,r as D,s as O,t as k}from"./dropdown-menu-CjLqyqwB.js";import{At as ne,B as A,Ct as re,Et as ie,H as ae,St as oe,Tt as j,U as se,V as ce,ar as le,br as M,bt as N,dr as ue,fr as de,gr as P,hr as fe,ir as pe,jt as me,kt as he,lr as ge,or as _e,ur as F,vr as ve,wt as ye,xt as I,yr as be}from"./index-D51Su-nT.js";var xe=d(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),L=d(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),R=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),z=d(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),B=d(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),V=d(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Se=d(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Ce=d(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),H=d(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),U=d(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),W=d(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),G=d(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),K=d(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),q=d(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),we=d(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Te=d(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Ee=d(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),De=d(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),Oe=d(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(i(),1),ke=1e3,Ae=[500,1e3,2e3,4e3,8e3],je=1;function Me(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,i=null,a,c=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||o(),m=()=>{if(c||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,i=n,n.addEventListener(`open`,()=>{n===i&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==i)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=l.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==i||c)return;if(i=null,!u){if(d+=1,d>=2){c=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),a=setTimeout(m,ke);return}if(f>=5){c=!0,t.onTransport(`closed`);return}let e=Ae[Math.min(f,Ae.length-1)];f+=1,t.onTransport(`reconnecting`,f),a=setTimeout(m,e)})},h=s(e=>{if(!c)if(e)i||m();else{clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){i?.readyState===je&&i.send(JSON.stringify(e))},close(){c=!0,h(),clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}}}var Y=a();function Ne({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(ae,{children:(0,Y.jsxs)(A,{children:[(0,Y.jsx)(se,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,Y.jsx)(B,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ce,{children:`Experimental`})]})}):e?(0,Y.jsx)(ae,{children:(0,Y.jsxs)(A,{children:[(0,Y.jsx)(se,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(B,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ce,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(B,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Pe({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{L as t,t as n,u as r}from"./button-CS5tOblf.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Mr as o,Nr as s,Pr as c,mr as l}from"./project-scope-context-DbO9a0ii.js";import{n as u}from"./toaster-CRVRHlMR.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{t as f}from"./arrow-right-Dh_Lx3um.js";import{n as p,r as m,t as h}from"./hourglass-B0lPAJvT.js";import{t as g}from"./info-DA1x_4bz.js";import{a as _}from"./format-BNCkW110.js";import{t as v}from"./play-CmVAj_fu.js";import{c as y,n as ee,o as b,s as x}from"./thread-state-BJy69cQG.js";import{s as te}from"./project-router-BLO2IxbU.js";import{a as S,c as C,i as w,l as T,p as E,r as D,s as O,t as k}from"./dropdown-menu-CjLqyqwB.js";import{At as ne,B as A,Ct as re,Et as ie,H as ae,St as oe,Tt as j,U as se,V as ce,ar as le,br as M,bt as N,dr as ue,fr as de,gr as P,hr as fe,ir as pe,jt as me,kt as he,lr as ge,or as _e,ur as F,vr as ve,wt as ye,xt as I,yr as be}from"./index-TZr_ApUY.js";var xe=d(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),L=d(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),R=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),z=d(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),B=d(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),V=d(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Se=d(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Ce=d(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),H=d(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),U=d(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),W=d(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),G=d(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),K=d(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),q=d(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),we=d(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Te=d(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Ee=d(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),De=d(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),Oe=d(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(i(),1),ke=1e3,Ae=[500,1e3,2e3,4e3,8e3],je=1;function Me(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,i=null,a,c=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||o(),m=()=>{if(c||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,i=n,n.addEventListener(`open`,()=>{n===i&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==i)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=l.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==i||c)return;if(i=null,!u){if(d+=1,d>=2){c=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),a=setTimeout(m,ke);return}if(f>=5){c=!0,t.onTransport(`closed`);return}let e=Ae[Math.min(f,Ae.length-1)];f+=1,t.onTransport(`reconnecting`,f),a=setTimeout(m,e)})},h=s(e=>{if(!c)if(e)i||m();else{clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){i?.readyState===je&&i.send(JSON.stringify(e))},close(){c=!0,h(),clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}}}var Y=a();function Ne({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(ae,{children:(0,Y.jsxs)(A,{children:[(0,Y.jsx)(se,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,Y.jsx)(B,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ce,{children:`Experimental`})]})}):e?(0,Y.jsx)(ae,{children:(0,Y.jsxs)(A,{children:[(0,Y.jsx)(se,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(B,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ce,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(B,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Pe({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
2
2
  `);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(P,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Fe=/^([a-z][a-z0-9+.-]*):/i;function Ie(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Fe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Le(n):Le(`http://${n}`)}function Le(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Re(e){return e.replace(/^https?:\/\//i,``)}var ze=`https://github.com/hearsay-tools/squawk#environment-variables`;function Be({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(We,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(qe,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(Je,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(Ye,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`port-held`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)(tt,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(nt,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(rt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(at,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(ot,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(st,{actions:t});case`taken-over`:return(0,Y.jsx)(lt,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Ve({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(le,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${j(e.command)} in this task's worktree, on the host.`})]})}function He({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(P,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ue({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(N,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(Ve,{server:e})})]})}function We({state:e,actions:r}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(z,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:r.download,children:[(0,Y.jsx)(z,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(He,{command:e.installCommand,copy:r.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ge(e){return Math.round(e/1e6)}function Ke({state:e,actions:t}){let r=(0,J.useRef)(null);r.current??={at:Date.now(),received:e.received};let i=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,a=(Date.now()-r.current.at)/1e3,o=a>=1?(e.received-r.current.received)/a:0,s=o>0?Math.ceil((e.total-e.received)/o):void 0;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(z,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${i}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${Ge(e.received)} of ${Ge(e.total)} MB · ${i}%`}),s===void 0?null:(0,Y.jsx)(`span`,{children:`about ${s} s left`})]})]}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function qe({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(He,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(P,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Je({state:e,actions:r}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(we,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsxs)(Z,{children:[`The host blocks the sandbox Chromium needs. This usually means `,t(`cezar`),` runs as root, or inside a container without user namespaces.`]}),(0,Y.jsx)(Pe,{text:e.stderrTail,source:`chromium`,onCopy:r.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:r.retryBrowser,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>r.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(P,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Ye({state:e,actions:t}){let r=e.reason===`timeout`,i=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,a=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,o=r?`Chromium did not start in time`:`Chromium exited${i}`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:r?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Z,{children:r?`Chromium did not open its DevTools port in time. ${a}`:`Chromium exited unexpectedly${i}. ${a}`}),(0,Y.jsx)(Pe,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`${o}\n${e.stderrTail}`),children:[(0,Y.jsx)(P,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Xe=2;function Ze(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Qe({state:e,actions:r}){let{server:i,wasRunning:a}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:a?(0,Y.jsx)(De,{className:`text-pending-strong`}):(0,Y.jsx)(v,{}),title:a?`Nothing answers on :${i.port} anymore`:`${i.label} isn't running yet`,children:[(0,Y.jsx)(Z,{children:a?`${i.label} was running when the agent registered it, likely inside the agent's own session, which has ended. ${t(`cezar`)} can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(Ue,{server:i,status:a?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Run and open`]})})]})}function $e({state:e,actions:t}){let{server:r,ownerTitle:i}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-pending-strong`}),title:`${r.label} :${r.port} is in use by another task`,children:[(0,Y.jsx)(Z,{children:`Task "${i}" is running its own server on :${r.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function et({state:e,actions:r}){let{server:i}=e,a=Ze(1e3),o=Math.max(0,Math.floor((a-Date.parse(e.startedAt))/1e3)),[s,c]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>c(Date.now()),[e.attempt]);let l=Math.max(0,Math.ceil(Xe-(a-s)/1e3));return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(v,{}),title:`Starting ${i.label}`,children:[(0,Y.jsx)(Z,{children:`${t(`cezar`)} ran ${j(i.command)} in the worktree. The page opens as soon as :${i.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(_,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),l>0?`Attempt ${e.attempt} · next try in ${l} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${o} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(Pe,{text:e.logTail.join(`
3
3
  `),source:j(i.command),onCopy:r.copy}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:()=>r.stop(i.port),children:`Stop server`})})]})}function tt({state:e,actions:t}){let{server:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(h,{className:`text-pending-strong`}),title:`${r.label} is running, but :${r.port} is silent`,children:[(0,Y.jsx)(Z,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(Pe,{text:e.logTail,source:j(r.command),onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(n,{variant:`contrast`,onClick:()=>t.keepWaiting(r.port),children:`Keep waiting`}),(0,Y.jsx)(n,{variant:`outline`,onClick:()=>t.stop(r.port),children:`Stop server`})]})]})}function nt({state:e,actions:t}){let{server:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:e.exitCode===null?`${r.label} was stopped by a signal`:`${r.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Z,{children:`${j(r.command)} stopped.`}),(0,Y.jsx)(Pe,{text:e.logTail,source:j(r.command),onCopy:t.copy}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>t.run(r.port),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Ve,{server:r})]})}function rt({state:e,actions:r}){let{server:i}=e,a=e.reason===`idle`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(ge,{}),title:a?`Stopped after 15 min idle`:`${i.label} stopped`,children:[(0,Y.jsx)(Z,{children:a?`Nobody had this pane open for 15 min, so ${t(`cezar`)} stopped ${i.label} :${i.port} and the browser to free memory. Start again reopens ${Re(e.lastUrl)}.`:`You stopped ${i.label} :${i.port}. Start again reopens ${Re(e.lastUrl)}.`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Ve,{server:i})]})}var it=[`browser`,`page`,`frame`];function at({step:e,url:t}){let n=it.indexOf(e),i=t?Re(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,Y.jsx)(m,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(_,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(R,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function ot({state:e,actions:t,worktree:r}){let i=r?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(r)?.[0]:void 0,a=e.server?.label;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(V,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Z,{children:`${a??`The server`} ran in ${i??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(b,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function st({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Ne,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(G,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsxs)(Z,{children:[`The proxy in front of `,t(`cezar`),` didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in `,t(`cezar`),` keeps working.`]}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(n,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ct(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function lt({state:e,actions:t}){let r=ct(e.by);return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(W,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Z,{children:`Another tab took this browser${r?` (${r})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(z,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ut({attempt:e,exhausted:t,onReconnect:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(Oe,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(n,{variant:`outline`,onClick:r,children:t?`Reconnect`:`Reconnect now`})]})}function dt({servers:e,states:t,onOpen:r,agentLive:i=!1,agentIdle:a=!1,onOpenAgent:o}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":a?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Z,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),a?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(De,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,i&&o!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(N,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:o,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let i=re(e,t),a=ie(i);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(N,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a.text})]}),(0,Y.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>r(e.port),children:ye(i)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(g,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function ft({dialog:e,onResult:t}){let[r,i]=(0,J.useState)(e.defaultPrompt??``),a=e.type===`beforeunload`,o=(0,J.useRef)(null),s=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?s.current:o.current)?.focus()},[e.type]);let c=(0,J.useRef)(t);c.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),c.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let l=()=>t(e.type===`prompt`?{accept:!0,text:r}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-border bg-card p-4 shadow-lg`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(a?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(n,{variant:`outline`,onClick:()=>t({accept:!1}),children:a?`Stay`:`Cancel`}),(0,Y.jsx)(n,{ref:o,variant:`contrast`,onClick:l,children:a?`Leave`:`OK`})]})]})})}var pt=10,mt=500,ht=500,gt=4,_t=16,vt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function yt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function bt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var xt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=yt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:xt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:vt(n),...r}}var St=e=>e===0?0:-e;function Ct(e,t,n,r,i){let a=yt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:St(r/e.scale),deltaY:St(i/e.scale),modifiers:0}}function wt(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=pt)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[Ct(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=mt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[$(`mouseMoved`,t,a,{button:`none`,buttons:0}),$(`mousePressed`,t,a,{button:`left`,buttons:1}),$(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function Tt(e,t){if(e.pointerType===`touch`)return wt(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=ht&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=gt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[$(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[$(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[$(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Et(e,t,n){let r=yt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?_t:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:vt(e)}}var Dt={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Ot(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:vt(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Dt[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:vt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function kt(e){return e?{t:`insertText`,text:e}:void 0}var At=e=>e,jt=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function Mt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(bt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of Tt(At(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Et(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=kt(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(jt(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Ot(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Nt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Pt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:a,renderInput:s,children:c}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(a);m.current=a,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!o()))try{let i=await Nt(e);try{if(t!==l.current||!o()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),s?.({canvas:d.current,scale:g,viewport:h})]}):null,c]})}var Ft=`cez-preview-quality`,It=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function Lt(e){return It.find(t=>t.value===e)?.value??`normal`}var Rt=e=>It.find(t=>t.value===e)?.label??`Normal`;function zt(){try{return Lt(localStorage.getItem(Ft))}catch{return`normal`}}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}var Vt=[{w:390,h:844,icon:_e},{w:820,h:1180,icon:Te},{w:1440,h:900,icon:F}],Ht=`size-8 shrink-0 max-md:size-11`,Ut=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Wt(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Gt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Kt({stats:e,shrunk:t}){let n=Wt(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(N,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Gt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(N,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Gt(e)})]})}function qt({current:e,agentShown:t,...r}){let i=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`max-w-[11rem] min-w-0 gap-1.5 max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${i}`:`Server`,...r,children:[e||t?(0,Y.jsx)(N,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(x,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(ve,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function Jt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:n,children:[(0,Y.jsx)(N,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":`true`}):null]})}function Yt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Xt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Zt(e){let{compact:t=!1,navEnabled:r,loading:i=!1}=e,a=(0,J.useRef)(null),o=e.urlInputRef??a,s=(0,J.useRef)(!1),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),p=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Back`,disabled:!r,onClick:e.onBack,children:(0,Y.jsx)(xe,{"aria-hidden":`true`})}),m=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Forward`,disabled:!r,onClick:e.onForward,children:(0,Y.jsx)(f,{"aria-hidden":`true`})}),h=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Reload`,"aria-busy":i||void 0,disabled:!r||i,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(q,{"aria-hidden":`true`})}),g=e.onSession?(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(be,{"aria-hidden":`true`}),`Session`]}):null,_=i?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,v=(0,Y.jsx)($t,{props:e,input:o,draft:c,setDraft:l,focused:u,setFocused:d}),{agentListed:y}=Xt(e),ee=e.servers.length+ +!!y>=2,b=ee||e.adopted,x={back:p,forward:m,reload:h,address:v,more:(0,Y.jsx)(an,{props:e,compact:t,crowded:b}),session:g,progress:_};return t?(0,Y.jsx)(on,{props:e,elements:x}):(0,Y.jsx)(sn,{props:e,elements:x,switcher:ee,crowded:b,input:o,focusUrlAfterMenu:s})}function Qt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Xt(e);return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(qt,{current:i,agentShown:o})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(Jt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=ie(re(t,e.serverStates));return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(N,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(de,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function $t({props:e,input:n,draft:i,setDraft:a,focused:o,setFocused:s}){let{url:c,adopted:l}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,Y.jsx)(de,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:n,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:i??(o?c:Re(c)),title:c||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,l?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;s(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{s(!1),a(null)},onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(i??c),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),l&&!o?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(Ce,{className:`size-3`,"aria-hidden":`true`}),`Not started by `,t(`cezar`)]}):null]})}function en({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ut(t)}`,children:[t===`fit`?(0,Y.jsx)(U,{"aria-hidden":`true`}):(0,Y.jsx)(F,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ut(t)}),(0,Y.jsx)(ve,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(w,{className:`gap-2.5`,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(U,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":`true`}):null]}),Vt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(w,{className:`gap-2.5 font-mono`,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(M,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function tn({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(O,{value:e,onValueChange:e=>t(Lt(e)),children:It.map(e=>(0,Y.jsx)(C,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function nn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Rt(t)}`,children:[(0,Y.jsx)(Se,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Rt(t)}),(0,Y.jsx)(ve,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(tn,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function rn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Kt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(N,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function an({props:e,compact:r,crowded:i}){let{stats:a,navEnabled:o,url:s,current:c,adopted:l}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`More`,children:(0,Y.jsx)(fe,{"aria-hidden":`true`})})}),(0,Y.jsxs)(D,{align:`end`,className:`min-w-64`,children:[i&&a&&!r?(0,Y.jsx)(S,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Gt(a)}):null,(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!o,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(K,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:s===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(ue,{"aria-hidden":`true`}),`Copy page URL`]}),c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),l?(0,Y.jsxs)(w,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(H,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${c.label} :${c.port}`}),(0,Y.jsxs)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:[t(`cezar`),` didn't start this server, so it won't stop it. Stop it where it was started.`]})]})]}):(0,Y.jsxs)(w,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(c.port),children:[(0,Y.jsx)(L,{"aria-hidden":`true`}),`Stop server · ${c.label} :${c.port}`]})]}):null,r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(tn,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(pe,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function on({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Xt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(N,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Yt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function sn({props:e,elements:t,switcher:r,crowded:i,input:a,focusUrlAfterMenu:o}){let{badge:s=!0,stats:c,status:l}=e,{back:u,forward:d,reload:f,address:p,more:m,session:h,progress:g}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[h,u,d,f,r?(0,Y.jsx)(Qt,{props:e,input:a,focusUrlAfterMenu:o}):null,p,(0,Y.jsx)(en,{props:e}),(0,Y.jsx)(nn,{props:e}),(0,Y.jsx)(rn,{stats:c,status:l,crowded:i}),s?(0,Y.jsx)(Ne,{iconOnly:i,responsive:!i}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),m,(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(pe,{"aria-hidden":`true`})}),g]})}function cn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function ln(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(Be,{...n,actions:o})}case`empty`:return(0,Y.jsx)(dt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function un(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function dn(){let[e,t]=(0,J.useState)(un);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(un());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var fn=2e3,pn=500,mn=1e3;function hn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function gn(e){navigator.clipboard?.writeText(e).then(()=>u(`Copied`),()=>u(`Couldn't copy to the clipboard`,{tone:`danger`}))}var _n=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function vn(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function yn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function bn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:a}){let s=dn(),l=(0,J.useRef)(s);l.current=s;let u=c(),d=(0,J.useRef)(crypto.randomUUID()),f=(0,J.useRef)(!1),p=te(),m=ne(he,!1),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)({state:`connecting`,attempt:0}),[y,ee]=(0,J.useState)(!1),[b,x]=(0,J.useState)(void 0),[S,C]=(0,J.useState)(void 0),[w,T]=(0,J.useState)(``),[E,D]=(0,J.useState)(void 0),[O,k]=(0,J.useState)(!1),[A,re]=(0,J.useState)(void 0),[ie,ae]=(0,J.useState)(!1),[oe,j]=(0,J.useState)(!1),[se,ce]=(0,J.useState)(void 0),[le,M]=(0,J.useState)(void 0),[N,ue]=(0,J.useState)(void 0),[de,P]=(0,J.useState)(`fit`),[fe,pe]=(0,J.useState)(zt),[me,ge]=(0,J.useState)(null),[_e,F]=(0,J.useState)(void 0),[ve,ye]=(0,J.useState)(0),I=(0,J.useRef)(void 0),be=(0,J.useRef)(null),xe=(0,J.useRef)(null),L=(0,J.useRef)(void 0),R=(0,J.useRef)(void 0),z=(0,J.useRef)(fe);z.current=fe;let B=(0,J.useRef)({port:E,stage:S,agent:O});B.current={port:E,stage:S,agent:O};let V=(0,J.useRef)([]),Se=(0,J.useRef)(void 0),Ce=(0,J.useRef)(!1),H=(0,J.useRef)(!1),U=(0,J.useCallback)(e=>{H.current&&I.current?.send(e)},[]);(0,J.useEffect)(()=>{let t;return t=Me({projectId:p??`default`,runId:e.id},{onFrame(e){if(!o())return;let n=Date.now();V.current.push({at:n,bytes:e.size}),Ce.current||(Ce.current=!0,j(!0)),(be.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&ye(e=>e+1),R.current!==void 0&&hn(e,R.current)){let n=R.current;R.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return T(e.url);case`cursor`:return ce(e.cursor);case`dialog`:return M(e);case`pong`:Se.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:x(e.by),H.current=!1,t?.close();return}},onTransport(e,n){H.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(ee(!0),L.current&&(t?.send({t:`open`,target:L.current,viewerId:d.current,resume:f.current,quality:z.current,dpr:l.current}),f.current=!0))}}),I.current=t,()=>{H.current=!1,t?.close(),I.current===t&&(I.current=void 0)}},[p,e.id,h]);let W=u&&_.state===`open`&&b===void 0,G=m||de===`fit`?me:de;(0,J.useEffect)(()=>{G&&W&&(S?.stage===`streaming`||S?.stage===`loading`)&&U({t:`resize`,w:G.w,h:G.h,...s===1?{}:{dpr:s}})},[G?.w,G?.h,s,W,S?.stage,ve,U]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>U({t:`ping`,ts:Date.now()}),fn);return()=>clearInterval(e)},[W,U]);let K=W&&S?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){ue(void 0);return}let e=setInterval(()=>{let e=Date.now();V.current=V.current.filter(t=>e-t.at<=mn);let t={fps:V.current.length,kbps:Math.round(V.current.reduce((e,t)=>e+t.bytes,0)/1024),...Se.current===void 0?{}:{rttMs:Se.current},...V.current.length>0?{lastFrameAt:V.current.at(-1).at}:{}};ue(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},pn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{A&&r?.(A)},[A,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{L.current=e,R.current=n&&`port`in e?e.port:void 0,ae(!0),C(void 0),x(void 0),F(void 0),T(t),D(`port`in e?e.port:void 0),k(`agent`in e),re(yn(e)),U({t:`open`,target:e,viewerId:d.current,quality:z.current,dpr:l.current}),f.current=H.current},[U]),we=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?_n(r):`http://localhost:${e}`,n)},[t,q]),Te=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(B.current.agent&&B.current.stage?.stage===`streaming`)return;Te();return}if(n?.url!==void 0){let e=Ie(n.url,t);e.kind===`server`?we(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||B.current.port===n.port&&B.current.stage?.stage===`streaming`&&n.run!==!0||we(n.port,n.run===!0))},[n]);let Ee=!ie&&!b&&_.state!==`blocked`,De=vn(n,t);(0,J.useEffect)(()=>{Ee&&!De&&xe.current?.focus()},[Ee,De]);let Oe=e=>{let n=Ie(e,t);if(n.kind===`error`)return F(n.message);if(n.kind===`server`)return we(n.port);if(B.current.stage?.stage===`streaming`&&!B.current.agent)return L.current={url:n.url},R.current=void 0,D(void 0),re({url:n.url}),F(void 0),T(n.url),U({t:`nav`,url:n.url});q({url:n.url},n.url)},ke=(0,J.useCallback)(e=>{z.current=e,pe(e),Bt(e),U({t:`quality`,quality:e})},[U]),Ae=()=>{f.current=!1,x(void 0),v({state:`connecting`,attempt:0}),Ce.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:b,stage:S,url:w,port:E,agent:O,hasFrame:oe,cursor:se,dialog:le,setDialog:M,stats:N,viewport:de,setViewport:P,quality:fe,chooseQuality:ke,setStageSize:ge,addressError:_e,stageHandle:be,urlInput:xe,send:U,connected:W,streaming:K,openServer:we,openAgent:Te,empty:Ee,navigate:Oe,reconnect:Ae,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>U({t:`run`,port:e}),stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:a,useHere:Ae,copy:gn}),[U,a])}}function xn(e){return(0,Y.jsx)(me,{onClose:e.onClose,children:(0,Y.jsx)(wn,{...e})})}function Sn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Cn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Cn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function wn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=bn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:b,addressError:x,urlInput:te,send:S,streaming:C,openServer:w,openAgent:T,empty:E,navigate:D,actions:O}=s,k=n.find(e=>e.port===m),ne=f?.stage===`streaming`&&f.adopted,A=u&&(l.state===`reconnecting`||l.state===`closed`),{content:re,dim:ie}=cn({transport:l.state,takenOver:d,empty:E,stage:f,hasFrame:g,lost:A,url:p,worktree:t.worktreePath}),ae=ln(re,{servers:n,serverStates:r,agentLive:i,openServer:w,openAgent:T,actions:O});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Zt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:k,agentLive:i===!0,agentShown:h,adopted:ne,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:C,loading:f?.stage===`loading`,stats:C?_??{fps:0,kbps:0}:void 0,status:C?void 0:Sn(l,u,d!==void 0,f),urlInputRef:te,onSession:a,onNavigate:D,onBack:()=>S({t:`back`}),onForward:()=>S({t:`forward`}),onReload:e=>S({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>w(e),onPickAgent:T,onViewport:y,onQuality:b,onCopyUrl:()=>gn(p),onStop:e=>S({t:`stop`,port:e}),onClose:o}),x?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,Y.jsx)(Tn,{transportState:s,overlay:ae,dim:ie,lost:A})]})}function Tn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Pt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(Mt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(ut,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(ft,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function En(e){let{visibleEvents:t}=oe(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of ee(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function Dn(e){let t=En(e.run.id),n=I(e.run.id);return(0,Y.jsx)(xn,{...e,serverStates:t,agentLive:n})}export{Dn as ConnectedPreviewPane};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{A as t,M as n}from"./button-CS5tOblf.js";import{i as r}from"./react-runtime-CCIEwYL0.js";import{r as i,t as a}from"./live-refetch-C2xZHKkJ.js";import{$ as o,$t as s,At as c,B as l,Bn as u,Br as d,Cn as f,Cr as p,Ct as m,Dn as h,Dt as g,F as _,Fn as v,Ft as y,H as ee,Hr as te,Ht as ne,I as re,It as ie,J as ae,Jt as oe,K as se,Kr as b,L as ce,Lr as le,Lt as ue,M as de,Mt as fe,Nt as pe,On as me,Ot as he,Pt as ge,Q as _e,Qr as ve,R as ye,Rr as be,Sn as xe,St as Se,Tn as Ce,U as we,Ur as Te,V as Ee,Vr as De,Vt as Oe,Wn as ke,Wr as Ae,X as je,Y as Me,Yt as Ne,Z as Pe,Zr as Fe,_ as Ie,_n as Le,_t as Re,at as ze,b as Be,bt as Ve,c as He,ci as Ue,cn as We,ct as Ge,di as Ke,dn as qe,dt 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,kr as it,kt as at,ln as ot,lt as st,m as ct,mi as lt,mn as ut,mt as dt,nt as ft,oi as pt,or as x,ot as mt,pt as ht,qr as gt,r as _t,ri as vt,sn as yt,st as bt,ti as xt,tt as St,ui as Ct,un as wt,ut as Tt,v as Et,vn as Dt,vr as Ot,vt as kt,wr as At,wt as jt,x as Mt,xt as Nt,yn as Pt,yt as Ft,z as It,zr as Lt}from"./project-scope-context-DbO9a0ii.js";import{I as S,L as Rt,N as zt,lt as C}from"./live-protocol-BVn0UA_g.js";import{t as Bt}from"./useInfiniteQuery-DCWsxLiy.js";import{t as w}from"./useQuery-C2HBIY3e.js";import{n as Vt,r as T,t as Ht}from"./ws-BXdlGFIZ.js";import{n as Ut}from"./toaster-CRVRHlMR.js";var Wt=class extends Fe{#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||Gt(),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=ve({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),C.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Gt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Kt=class extends lt{#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),Ct(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&xt(t.mutationKey)!==xt(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??Gt();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){C.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 qt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Jt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Yt=class extends lt{#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,C.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||!Ct(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(qt(e,n).forEach(e=>{e.destroy()}),qt(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=Ue(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 gt(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Jt(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)&&C.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},E=e(r(),1);function D({queries:e,...t},n){let r=b(n),i=Ae(),a=Te(),o=E.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{le(e);let t=r.getQueryCache().get(e.queryHash);d(e,a,t)}),te(a);let[s]=E.useState(()=>new Yt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;E.useSyncExternalStore(E.useCallback(e=>f?s.subscribe(C.batchCalls(e)):pt,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),E.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>Lt(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Lt(n,e)?be(n,new gt(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&De({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function O(e,t){let n=b(t),[r]=E.useState(()=>new Kt(n,e));E.useEffect(()=>{r.setOptions(e)},[r,e]);let i=E.useSyncExternalStore(E.useCallback(e=>r.subscribe(C.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=E.useCallback((e,t)=>{r.mutate(e,t).catch(pt)},[r]);if(i.error&&Ke(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function k(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function A(e,t={}){return{...k(t),runId:e}}function Xt(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var j=[`workspace`,`runs-index`],M=e=>[e.cacheScope,`runs`,`list`],N=e=>[e.cacheScope,`runs`,`detail`,e.runId],P=e=>typeof e==`function`?e():e;function Zt(e){let{seenAt:t,...n}=e;return n}function Qt(e,t){let n=Zt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function $t(e,t,n){return t?{...e,seenAt:n}:Zt(e)}function en(e){let t=()=>{e.invalidateQueries({queryKey:j})};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=At(),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:M(P(n))}),await e.cancelQueries({queryKey:N(P(n))});let i=e.getQueryData(M(P(n))),a=e.getQueryData(N(P(n))),o=P(n).runId,s=new Date().toISOString();return e.setQueryData(M(P(n)),e=>e?.map(e=>e.id===o?$t(e,r,s):e)),e.setQueryData(N(P(n)),e=>e&&$t(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(M(P(n)),i),a&&e.setQueryData(N(P(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(M(P(n)),e=>e?.map(e=>e.id===o?Qt(e,t):e)),a&&e.setQueryData(N(P(n)),e=>e&&Qt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?$t(e,r,i.seenAt):e;e.setQueryData(M(P(n)),e=>e?.map(a));let s={...P(n),runId:r?o:i.id};e.setQueryData(N(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:j});let i=e.getQueryData(j),a=n();return e.setQueryData(j,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(j,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function F(){let e=b();return(0,E.useMemo)(()=>en(e),[e])}function tn(e){return e.type===`run`?e.run.id:e.id}function I(e,t){return{...e,runs:t}}function nn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function rn(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 an(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function on(e,t,n){let{project:r}=t,i=tn(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:I(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:I(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!an(e,r,n))return{index:e,reconcile:!0};let l=Ue(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||nn(t,r)>e.perProjectLimit);return{index:I(e,t),reconcile:n}}if(s)return cn(e,l);let u=rn(e.runs,l);return{index:I(e,u),reconcile:l.archived&&nn(u,r)>e.perProjectLimit}}function sn(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 cn(e,t){let n=sn(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:I(e,rn(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function ln(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=Ue(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?I(e,i):e}function un(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 dn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function fn(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 pn(e){e.stream=void 0}function mn(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,tn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function hn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function gn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function _n(e,t,n){if(!gn(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=on(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 L=[`workspace`,`runs-index`],vn=[`workspace`,`projects`],yn=6e4,bn=100,xn=new WeakMap;function R(e){let t=xn.get(e);return t||(t=En(e),xn.set(e,t)),t}function Sn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:R(t).merge(e)}function Cn(e){let t=e.getQueryData(vn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function wn(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 Tn(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 En(e){let t=dn(),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(L,t)},h=()=>e.getQueryData(L),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:L,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:L,exact:!0}).then(()=>e.invalidateQueries({queryKey:L})):e.invalidateQueries({queryKey:L})).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=Cn(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=ln(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=on(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,bn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){fn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){pn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Tn(e,r);if(!mn(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),hn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=un(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=_n(t,n,Cn(e));for(let e of l)i.index=un(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),wn(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 Dn={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`}},On={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function kn(e){return typeof e==`string`&&Object.hasOwn(Dn,e)}function An(e){return e!==void 0&&kn(e)?Dn[e]:void 0}var z=new Map(In()),jn=1e3;function Mn(e,t){if(z.get(e)!==t){for(z.delete(e),z.set(e,t);z.size>jn;){let e=z.keys().next().value;if(e===void 0)break;z.delete(e)}Rn()}}var B=new Set(Ln());function Nn(e,t){if(B.has(e)!==t){if(t)for(B.add(e);B.size>jn;){let e=B.values().next().value;if(e===void 0)break;B.delete(e)}else B.delete(e);Rn()}}var Pn=`cez.reference-statuses.v1`,Fn=`cez.reference-conflicts.v1`;function In(){try{let e=globalThis.sessionStorage?.getItem(Pn);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`&&kn(e[1])):[]}catch{return[]}}function Ln(){try{let e=globalThis.sessionStorage?.getItem(Fn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var V;function Rn(){V===void 0&&(V=setTimeout(()=>{V=void 0;try{globalThis.sessionStorage?.setItem(Pn,JSON.stringify([...z])),globalThis.sessionStorage?.setItem(Fn,JSON.stringify([...B]))}catch{}},250))}var H=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function zn(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Bn(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 Vn(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;Mn(t,o),s!==void 0&&Nn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Hn(e,t,n){let r=H(t),i=z.get(r),a=B.has(r)?!0:void 0,o=n.data;if(o?.available){Vn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...zn(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...zn(i,a)});return}e.set(r,{state:`loading`,...zn(i,a)})}function Un(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Bn(i))Hn(n,e,t)}),n}function Wn(e){return x(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Gn(e){return Wn(e)&&e.status!==`queued`}function Kn(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&ke(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var qn=[`done`,`failed`];function Jn(e){return e.archived||x(e)||!qn.includes(e.status)?!1:e.finishedAt!==void 0}function Yn(e){let t=e.finishedAt;return t===void 0||!Jn(e)?!1:e.seenAt===void 0||e.seenAt<t}function Xn(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function Zn(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?Xn(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var Qn=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:Zn},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function $n(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function er(e,t){if(t!==`phrase`)return $n(e);let n=e.trim().toLowerCase();return n===``?[]:[n]}function tr(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function nr(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.omit??[]:[],i=t.scope===`shown`?t.extras:{automation:tr(e,t.automationNames)},a=[],o=[],s=[],c={text:a,identifier:o,link:s},l=[];for(let t of Qn)if(!(!t.scopes.includes(n)||r.includes(t.id))){if(t.kind===`reference`){l.push(()=>t.numbers(e,i));continue}for(let n of t.texts(e,i))typeof n==`string`&&c[t.kind].push(n.toLowerCase())}let u;return{prose:a,ids:o,links:s,references:()=>u??=new Set(l.flatMap(e=>e().map(String)))}}function rr(e,t,n={}){let r=er(t,n.mode);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=nr(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var ir=[`Needs you`,`Finished`,`Working`,`Archived`],ar={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},or=3,U=e=>x(e)?or:ar[e.status]??9;function sr(e){let t=e=>v[u(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||U(e)-U(n))[0]}function cr(e,t){return t===`archived`?`Archived`:u(e).bucket===`waiting`?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function lr(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function ur(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function dr(e,t){return t!==void 0&&ur(e).ref===t}function fr(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function pr(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=U(e)-U(n);if(r!==0)return r;if(x(e)&&x(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function W(e){return e.delegation?.role===`worker`}function mr(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!W(n)?e:n.delegation?.parentRunId??e}function hr(e,t,n=fr(e)){let r=pr(e,t).filter(e=>!W(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(cr(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return ir.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function gr(e,t={}){let n=typeof t==`number`?{overall:t}:zt(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function _r(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function vr(e){let t=0,n=0,r=0;for(let i of e)if(!W(i)){if(i.archived){n+=1;continue}t+=1,u(i).bucket===`waiting`&&(r+=1)}return{active:t,archived:n,waiting:r}}function yr(e,t){let n=t===`automations`;return e.filter(e=>!e.archived&&ke(e)===n)}var G={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},br=Object.keys(G),xr=`section`;function Sr(e,t){return`/?origin=${t===`automations`?`automations`:`direct`}&${xr}=${G[e]}`}function Cr(e){return br.find(t=>G[t]===e)??null}function wr(e){let t={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let n of e){if(W(n)||n.archived)continue;let e=+(u(n).bucket===`waiting`);ke(n)?(t.automations+=1,t.automationsWaiting+=e):(t.active+=1,t.activeWaiting+=e)}return t}var Tr=new Set([`running`,`waiting`]);function K(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function Er(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function Dr(e,t=new Date){if(!x(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function Or(e){return e.steps?Xt({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function kr(e,t,n=()=>``){let r=e.filter(e=>!W(e));return t.trim()?r.filter(e=>rr(e,t,{scope:`shown`,mode:`phrase`,extras:{displayTitle:lr(e),automation:n(e),references:()=>Ar(e)}})):[...r]}function Ar(e){return q(e).map(e=>e.number)}function jr(e,t){return e.filter(e=>Kn(e,t)).length}function Mr(e){return jr(e)}function Nr(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 Pr(e){return Fr(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function Fr(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function Ir(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function Lr(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function q(e,t,n=e.projectId){let r=Fr(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>Wr(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:Ir(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(Wr(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Rr(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=Lr(a);o.has(c)||(o.add(c),s.push(a))}return s}function Rr(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function zr(e){return q(e)[0]}function Br(e,t){if(!e.url)return!0;if(!t)return!1;let n=Vr(t);return n!==void 0&&Vr(e.url)===n}function Vr(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function Hr(e,t){let n=[];for(let r of q(e,t)){if(!Br(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function Ur(e,t,n,r){if(Br(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function Wr(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function Gr(e,t){let n=Tr.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:K(n.rssBytes),kind:`live`}};let r=K(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function Kr(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 qr(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 Jr(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 Yr(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 Xr(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Zr(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function Qr(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){Zr(t.issues,a,r),Zr(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 J=e=>e.map(e=>e.number).join(`,`);function $r(e,t){let n=e[0];if(e.length>1&&n&&(J(n.issues)!==J(t.issues)||J(n.prs)!==J(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 Y={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`]}},X={models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:L,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)=>[...X.fsBrowseRoot,e,t]};function Z(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:X.models(t),refetchType:n})}function Q(e,t=!0){let n=b();return(0,E.useEffect)(()=>{if(!t||e!==`cursor`)return;let r,i=()=>{let e=n.getQueryData(Y.health)?.capabilities?.localHandoff===!0;e&&!r?r=Ht(`models:cursor`,e=>{let t=Rt.safeParse(e);t.success&&t.data.runner===`cursor`&&(n.cancelQueries({queryKey:X.models(`cursor`)}),n.setQueryData(X.models(`cursor`),t.data))}):!e&&r&&(r(),r=void 0)};i();let a=n.getQueryCache().subscribe(i);return()=>{a(),r?.()}},[t,e,n]),w({queryKey:X.models(e),queryFn:({signal:t})=>S(e)?he(e,{signal:t}):Promise.reject(Error(`${e} has no host model catalog`)),staleTime:300*1e3,enabled:t&&S(e)})}function ei(e=!0){return{claude:Q(`claude`,e),codex:Q(`codex`,e),opencode:Q(`opencode`,e),pi:Q(`pi`,e),cursor:Q(`cursor`,e),omp:Q(`omp`,e)}}function ti(){let e=b();return w({queryKey:X.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(X.providerStatus),r=await ht(!1,{signal:t});return Ot(n,e.getQueryData(X.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function ni(){let e=b();return O({mutationFn:()=>ht(!0),onMutate:()=>e.getQueryData(X.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(X.providerStatus,e=>Ot(r,e,t)),Z(e)}})}function ri(){let e=b();return O({mutationFn:({provider:e,authFailureId:t})=>ut(e,t),onMutate:()=>e.getQueryData(X.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(X.providerStatus,e=>Ot(r,e,t,n.authFailureId)),S(n.provider)&&Z(e,n.provider)}})}function ii(e={}){return w({queryKey:X.projects,queryFn:({signal:e})=>Xe({signal:e}),...e})}function ai(e,t=!1){return w({queryKey:X.fsBrowse(e,t),queryFn:({signal:n})=>He(e??void 0,{signal:n,showHidden:t}),retry:!1})}function oi(){let e=b();return O({mutationFn:e=>yt(e),onSuccess:()=>e.invalidateQueries({queryKey:X.projects})})}function si(){let e=b();return O({mutationFn:e=>ot(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:X.projects})}})}function ci(){let e=b();return O({mutationFn:e=>{let{id:t,...n}=e;return h(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:X.projects});let r=e.getQueryData(X.projects);return e.setQueryData(X.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?li(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(X.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(X.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:X.projects})})}function li(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?[]:Jr(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function ui(e){let t=b();return O({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(X.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:X.projects})})}function di(){return ui(e=>{let{projectId:t,...n}=e;return Mt(t,n)})}function fi(){return ui(e=>{let{projectId:t,webhookId:n,...r}=e;return me(t,n,r)})}function pi(){return ui(({projectId:e,webhookId:t})=>wt(e,t))}function mi(){return O({mutationFn:({projectId:e,webhookId:t})=>f(e,t),retry:!1})}function hi(e){let t=b();return O({mutationFn:t=>Oe(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:Y.runs.all})})}function $(e){let t=b();return O({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:X.agentProfiles}),t.invalidateQueries({queryKey:X.projects})])}})}function gi(){return $(e=>Et(e))}function _i(){return $(e=>{let{id:t,...n}=e;return Ce(t,n)})}function vi(){return $(e=>We(e))}function yi(){return $(e=>Dt(e))}function bi(e,t){return w({queryKey:X.agentAccountDetails(e),queryFn:({signal:t})=>_(e,{signal:t}),enabled:t,staleTime:0,retry:!1})}function xi(e,t){return w({queryKey:X.agentAccountStatus(e),queryFn:({signal:t})=>re(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Si(){let e=b();return O({mutationFn:({provider:e,profileId:t})=>Ze(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:X.agentProfiles}),e.invalidateQueries({queryKey:X.providerStatus}),S(n)?Z(e,n,`none`):Promise.resolve()])}})}function Ci(){let e=b();return O({mutationFn:e=>re(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(X.agentAccountStatus(n),t),e.invalidateQueries({queryKey:X.agentProfiles}),S(t.status.provider)&&Z(e,t.status.provider)}})}function wi(){return O({mutationFn:e=>{let{routeId:t,...n}=e;return ne(t,n)},retry:!1})}function Ti(){let e=b();return O({mutationFn:e=>ct(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:X.projects})})}function Ei(){let e=b();return O({mutationFn:e=>Be(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:X.projects})})}function Di({enabled:e}){return w({queryKey:X.githubOwners,queryFn:({signal:e})=>St({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Oi(){let e=b();(0,E.useEffect)(()=>{let n,r=()=>{let r=e.getQueryData(Y.health),i=r?.capabilities?.localHandoff===!0;r&&p({local:i,bootProject:r.bootProject??`default`,apiBase:t()}),i&&n===void 0?n=Ht(`health`,t=>{e.setQueryData(Y.health,t)}):!i&&n!==void 0&&(n(),n=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),n?.(),it()}},[e])}function ki(){return w({queryKey:Y.health,queryFn:({signal:e})=>bt({signal:e})})}function Ai(e,t){let n=ki().data,r=ii(t).data?.projects,i=_t(),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?Nr(n?.repo?.remote):void 0}function ji(){return w({queryKey:Y.openTargets,queryFn:({signal:e})=>Je({signal:e}),staleTime:5*6e4})}function Mi(){return w({queryKey:Y.runs.list(),queryFn:({signal:e})=>at(k(),{signal:e})})}function Ni(e,t){return Bt({queryKey:Y.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 Pi(e){let t=e.trim();return w({queryKey:X.runsSearch(t),queryFn:({signal:e})=>Le(t,{signal:e}),enabled:t.length>=2,placeholderData:vt,staleTime:1e4})}function Fi(e=!0,t=yn){let n=R(b());return T(`/api/v1/workspace/runs-index`,X.runsIndex,a(e?t:!1),Sn),w({queryKey:X.runsIndex,queryFn:({signal:e})=>c({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function Ii(e,t=!0,n=!1){return w({queryKey:[k({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>at(k({projectId:e,boot:n}),{signal:t}),enabled:t})}function Li(e){let t=b();return O({mutationFn:e=>nt(e),onSettled:()=>t.invalidateQueries({queryKey:Y.runs.relationships(e)})})}function Ri(e,t={}){return w({queryKey:Y.runs.relationships(e),queryFn:({signal:t})=>g(e,{signal:t}),enabled:t.enabled??!0})}function zi(e){return w({queryKey:Y.runs.detail(e??``),queryFn:({signal:t})=>kt(A(e),{signal:t}),enabled:!!e})}function Bi(e,t,n=!0){return w({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>kt(A(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Vi(e){return w({queryKey:Y.runs.diff(e??``),queryFn:({signal:t})=>Se(e,{signal:t}),enabled:!!e})}function Hi(e,t=!1){return T(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,Y.runs.changes(e??``),a(t?4e3:!1)),w({queryKey:Y.runs.changes(e??``),queryFn:({signal:t})=>Ft(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ui(e,t){return w({queryKey:Y.runs.file(e??``,t??``),queryFn:({signal:n})=>m(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Wi(e,t){return w({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Me(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Gi(e,t){return w({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Ee(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ki(e,t){return w({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>ee(e,t,{signal:n}),enabled:t!==null,retry:!1})}function qi(e){return w({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>we(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Ji(e,t=!1){return T(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,Y.runs.commits(e??``),a(t?5e3:!1)),w({queryKey:Y.runs.commits(e??``),queryFn:({signal:t})=>Nt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Yi(e,t){return w({queryKey:Y.runs.commit(e??``,t??``),queryFn:({signal:n})=>Ve(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Xi(e,t=!0){return w({queryKey:Y.runs.handoff(e??``),queryFn:({signal:t})=>jt(A(e),{signal:t}),enabled:!!e&&t})}function Zi(e,t,n){return w({queryKey:e===void 0?Y.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>jt(A(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Qi(e,t){let r=[...new Set(e)],i=D({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,E.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 $i(){return w({queryKey:Y.workflows,queryFn:({signal:e})=>ge({signal:e})})}function ea(e=!0){let t=b(),n=Y.skills,r=n[0],i=w({queryKey:n,queryFn:({signal:e})=>rt({signal:e}),enabled:e}),a=w({queryKey:Y.skillsReady,queryFn:({signal:e})=>fe({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,E.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`],a.data)},[t,a.data,r]),i}function ta(e=!0){let t=b(),n=Y.importableSkills,r=n[0],i=w({queryKey:n,queryFn:({signal:e})=>Ge({signal:e}),enabled:e}),a=w({queryKey:Y.importableSkillsReady,queryFn:({signal:e})=>st({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,E.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`,`importable`],a.data)},[t,a.data,r]),i}function na(){return w({queryKey:Y.launchKey,queryFn:({signal:e})=>Tt({signal:e}),staleTime:1/0})}function ra(){return w({queryKey:Y.repo,queryFn:({signal:e})=>dt({signal:e})})}function ia(e){return w({queryKey:[e,`repo`],queryFn:({signal:t})=>dt({signal:t},e)})}function aa(){return w({queryKey:Y.repoBranches,queryFn:({signal:e})=>$e({signal:e})})}function oa(){return w({queryKey:Y.repoChanges,queryFn:({signal:e})=>Qe({signal:e}),retry:!1})}function sa(e){return w({queryKey:Y.repoCommit(e??``),queryFn:({signal:t})=>Re(e,{signal:t}),enabled:!!e,retry:!1})}function ca(){return w({queryKey:Y.config,queryFn:({signal:e})=>ae({signal:e})})}function la(){return w({queryKey:Y.worktrees,queryFn:({signal:e})=>ue({signal:e})})}function ua(e){return w({queryKey:[e,`worktrees`],queryFn:({signal:t})=>ue({signal:t},e),staleTime:0})}function da(e,t=!0,n=!1){return w({queryKey:[k({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>pe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:zt(e.sidebarLimits)},enabled:t})}function fa(){return da(n())}function pa(){return w({queryKey:Y.agentConfig,queryFn:({signal:e})=>ce({signal:e})})}function ma(e){return w({queryKey:Y.agentConfigFile(e??``),queryFn:({signal:t})=>ye(e,{signal:t}),enabled:e!==null})}function ha(e){let t=b(),n=Y.agentConfig,r=Y.agentConfigFile(e);return O({mutationFn:t=>s(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function ga(){return w({queryKey:X.uiState,queryFn:({signal:e})=>ie({signal:e})})}function _a(){return w({queryKey:X.config,queryFn:({signal:e})=>y({signal:e})})}function va(){return w({queryKey:X.agentProfiles,queryFn:({signal:e})=>It({signal:e})})}function ya(e){let t=b();return O({mutationFn:t=>oe(e,t),onSuccess:()=>t.invalidateQueries({queryKey:Y.runs.all})})}function ba(e){let t=F(),n=e?.projectId,r=e?.cacheScope,i=O({mutationFn:e=>xe(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,E.useCallback)(e=>({...A(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,E.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,E.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,E.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function xa(){let e=F();return O({mutationFn:e=>xe(A(e),!1),onMutate:t=>e.patchRead(()=>A(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Sa(e){let t=F();return O({mutationFn:({id:t,pinned:n})=>Ne(A(t,e),n),onError:e=>Ut(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??k(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ca(e,t){let n=F();return O({mutationFn:n=>Pt(A(e,{projectId:t}),n),onMutate:()=>k({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 wa(e,t){let n=F();return O({mutationFn:(n={})=>Ie(A(e,{projectId:t}),n),onMutate:()=>k({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Ta(e){let t=b();return O({mutationFn:({msgId:t,message:n})=>de(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:Y.runs.all})})}function Ea(e){let t=b();return O({mutationFn:t=>qe(e,t),onSuccess:()=>t.invalidateQueries({queryKey:Y.runs.all})})}function Da(e={},t=!0){let r=b(),i=Y.github(e);T(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=w({queryKey:Y.github(e),queryFn:({signal:t})=>je({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=w({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,E.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 Oa=class extends Error{};function ka(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await je({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Oa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Yr(e),retry:(e,t)=>!(t instanceof Oa)&&!(t instanceof et&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Aa(e=50,t=!0){let r=b(),i=Y.githubPages(e),o=Y.githubPagesHead(e);T(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=Bt({...ka(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=w({queryKey:o,queryFn:({signal:t})=>je({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,E.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=$r(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=D({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>tt(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,E.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,E.useMemo)(()=>Qr(s.data?.pages??[]),[s.data])}}function ja(e,t=50,n=!0){let r=Bt({...ka([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,E.useMemo)(()=>Qr(r.data?.pages??[]),[r.data])}}function Ma(e,t,n=!0){let r=D({queries:t.filter(e=>e.length>0).map(t=>({queryKey:Y.githubCommentCounts(e,t),queryFn:({signal:n})=>_e(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,E.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 Na(e,t,n,r=!0){return w({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>mt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Pa(e,t=!0){return w({queryKey:Y.githubChecks(e),queryFn:({signal:t})=>Pe(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Fa(e,t,n=!0){return w({queryKey:Y.githubSearch(e,t),queryFn:({signal:n})=>mt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ia=100;function La(e){return[...e].sort((e,t)=>t-e).slice(0,Ia).sort((e,t)=>e-t)}function Ra(){let e=_t(),t=ki();return e.projectId??t.data?.bootProject}function za(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))Mn(H({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))Mn(H({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Ba=5*6e4;function Va(e){return e?e.recheckAfterMs:Ba}function Ha(e,t=!0){let n=(0,E.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:La(t.prs),issues:La(t.issues)}))},[e.map(H).sort().join(`|`)]),r=D({queries:n.map(e=>({queryKey:Y.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>ze(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Va(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Va(r[t]?.data)??!1})));(0,E.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=Y.githubRefStatus(t.projectId,t.prs,t.issues);return Vt({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,E.useMemo)(()=>Un(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,E.useCallback)(e=>{let t=H(e),n=s.get(t);if(n)return n;let r=z.get(t);return{state:`idle`,...r?{status:r}:{},...B.has(t)?{conflicting:!0}:{}}},[s])}function Ua(e,t,n=!0){return w({queryKey:Y.githubComments(e,t),queryFn:({signal:n})=>o(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Wa(e,t,n=!0){return w({queryKey:Y.githubItem(e,t),queryFn:({signal:n})=>Ye(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ga(e){return w({queryKey:Y.githubPrChanges(e??0),queryFn:({signal:t})=>ft(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{ii as $,Lr as $t,Di as A,_r as An,Ca as At,hi as B,F as Bn,ga as Bt,Wi as C,lr as Cn,Ri as Ct,Ma as D,yr as Dn,Fi as Dt,Pa as E,wr as En,Mi as Et,Oi as F,Kn as Fn,_i as Ft,ja as G,qr as Gt,ji as H,A as Hn,X as Ht,ta as I,Yn as In,ci as It,Ai as J,Er as Jt,Na as K,kr as Kt,na as L,On as Ln,fi as Lt,Ga as M,Jn as Mn,Zi as Mt,Fa as N,Wn as Nn,mi as Nt,Ua as O,pr as On,Pi as Ot,ki as P,Gn as Pn,fa as Pt,ua as Q,Wr as Qt,ba as R,An as Rn,$i as Rt,Ta as S,dr as Sn,Xi as St,Da as T,mr as Tn,Q as Tt,ya as U,O as Un,Xr as Ut,wi as V,k as Vn,la as Vt,Sa as W,Wt as Wn,Kr as Wt,Ii as X,Nr as Xt,Bi as Y,K as Yt,da as Z,Br as Zt,wa as _,W as _n,Hi as _t,xi as a,Hr as an,ni as at,di as b,Cr as bn,Vi as bt,va as c,q as cn,si as ct,Ki as d,ir as dn,ra as dt,Dr as en,ti as et,qi as f,xr as fn,aa as ft,Si as g,hr as gn,zi as gt,ca as h,gr as hn,ri as ht,bi as i,Ur as in,Ha as it,Aa as j,rr as jn,ea as jt,Wa as k,ur as kn,yi as kt,Ni as l,Gr as ln,pi as lt,Ti as m,cr as mn,sa as mt,Y as n,jr as nn,Ci as nt,pa as o,Pr as on,oi as ot,Qi as p,br as pn,oa as pt,ia as q,Mr as qt,za as r,Ir as rn,Ra as rt,ma as s,zr as sn,vi as st,Z as t,Ar as tn,ha as tt,Gi as u,Or as un,Ea as ut,gi as v,vr as vn,Yi as vt,ai as w,Sr as wn,ei as wt,Li as x,fr as xn,Ui as xt,Ei as y,sr as yn,Ji as yt,xa as z,R as zn,_a as zt};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{A as t,M as n}from"./button-CS5tOblf.js";import{i as r}from"./react-runtime-CCIEwYL0.js";import{r as i,t as a}from"./live-refetch-C2xZHKkJ.js";import{$ as o,$t as s,At as c,B as l,Bn as u,Br as d,Cn as f,Cr as p,Ct as m,Dn as h,Dt as g,F as _,Fn as v,Ft as y,H as ee,Hr as te,Ht as ne,I as re,It as ie,J as ae,Jt as oe,K as se,Kr as b,L as ce,Lr as le,Lt as ue,M as de,Mt as fe,Nt as pe,On as me,Ot as he,Pt as ge,Q as _e,Qr as ve,R as ye,Rr as be,Sn as xe,St as Se,Tn as Ce,U as we,Ur as Te,V as Ee,Vr as De,Vt as Oe,Wn as ke,Wr as Ae,X as je,Y as Me,Yt as Ne,Z as Pe,Zr as Fe,_ as Ie,_n as Le,_t as Re,at as ze,b as Be,bt as Ve,c as He,ci as Ue,cn as We,ct as Ge,di as Ke,dn as qe,dt 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,kr as it,kt as at,ln as ot,lt as st,m as ct,mi as lt,mn as ut,mt as dt,nt as ft,oi as pt,or as x,ot as mt,pt as ht,qr as gt,r as _t,ri as vt,sn as yt,st as bt,ti as xt,tt as St,ui as Ct,un as wt,ut as Tt,v as Et,vn as Dt,vr as Ot,vt as kt,wr as At,wt as jt,x as Mt,xt as Nt,yn as Pt,yt as Ft,z as It,zr as Lt}from"./project-scope-context-DbO9a0ii.js";import{I as S,L as Rt,N as zt,lt as C}from"./live-protocol-BVn0UA_g.js";import{t as Bt}from"./useInfiniteQuery-DCWsxLiy.js";import{t as w}from"./useQuery-C2HBIY3e.js";import{n as Vt,r as T,t as Ht}from"./ws-BXdlGFIZ.js";import{n as Ut}from"./toaster-CRVRHlMR.js";var Wt=class extends Fe{#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||Gt(),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=ve({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),C.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Gt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Kt=class extends lt{#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),Ct(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&xt(t.mutationKey)!==xt(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??Gt();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){C.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 qt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Jt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Yt=class extends lt{#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,C.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||!Ct(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(qt(e,n).forEach(e=>{e.destroy()}),qt(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=Ue(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 gt(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Jt(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)&&C.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},E=e(r(),1);function D({queries:e,...t},n){let r=b(n),i=Ae(),a=Te(),o=E.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{le(e);let t=r.getQueryCache().get(e.queryHash);d(e,a,t)}),te(a);let[s]=E.useState(()=>new Yt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;E.useSyncExternalStore(E.useCallback(e=>f?s.subscribe(C.batchCalls(e)):pt,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),E.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>Lt(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Lt(n,e)?be(n,new gt(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&De({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function O(e,t){let n=b(t),[r]=E.useState(()=>new Kt(n,e));E.useEffect(()=>{r.setOptions(e)},[r,e]);let i=E.useSyncExternalStore(E.useCallback(e=>r.subscribe(C.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=E.useCallback((e,t)=>{r.mutate(e,t).catch(pt)},[r]);if(i.error&&Ke(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function k(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function A(e,t={}){return{...k(t),runId:e}}function Xt(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var j=[`workspace`,`runs-index`],M=e=>[e.cacheScope,`runs`,`list`],N=e=>[e.cacheScope,`runs`,`detail`,e.runId],P=e=>typeof e==`function`?e():e;function Zt(e){let{seenAt:t,...n}=e;return n}function Qt(e,t){let n=Zt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function $t(e,t,n){return t?{...e,seenAt:n}:Zt(e)}function en(e){let t=()=>{e.invalidateQueries({queryKey:j})};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=At(),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:M(P(n))}),await e.cancelQueries({queryKey:N(P(n))});let i=e.getQueryData(M(P(n))),a=e.getQueryData(N(P(n))),o=P(n).runId,s=new Date().toISOString();return e.setQueryData(M(P(n)),e=>e?.map(e=>e.id===o?$t(e,r,s):e)),e.setQueryData(N(P(n)),e=>e&&$t(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(M(P(n)),i),a&&e.setQueryData(N(P(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(M(P(n)),e=>e?.map(e=>e.id===o?Qt(e,t):e)),a&&e.setQueryData(N(P(n)),e=>e&&Qt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?$t(e,r,i.seenAt):e;e.setQueryData(M(P(n)),e=>e?.map(a));let s={...P(n),runId:r?o:i.id};e.setQueryData(N(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:j});let i=e.getQueryData(j),a=n();return e.setQueryData(j,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(j,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function F(){let e=b();return(0,E.useMemo)(()=>en(e),[e])}function tn(e){return e.type===`run`?e.run.id:e.id}function I(e,t){return{...e,runs:t}}function nn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function rn(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 an(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function on(e,t,n){let{project:r}=t,i=tn(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:I(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:I(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!an(e,r,n))return{index:e,reconcile:!0};let l=Ue(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||nn(t,r)>e.perProjectLimit);return{index:I(e,t),reconcile:n}}if(s)return cn(e,l);let u=rn(e.runs,l);return{index:I(e,u),reconcile:l.archived&&nn(u,r)>e.perProjectLimit}}function sn(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 cn(e,t){let n=sn(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:I(e,rn(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function ln(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=Ue(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?I(e,i):e}function un(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 dn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function fn(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 pn(e){e.stream=void 0}function mn(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,tn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function hn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function gn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function _n(e,t,n){if(!gn(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=on(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 L=[`workspace`,`runs-index`],vn=[`workspace`,`projects`],yn=6e4,bn=100,xn=new WeakMap;function R(e){let t=xn.get(e);return t||(t=En(e),xn.set(e,t)),t}function Sn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:R(t).merge(e)}function Cn(e){let t=e.getQueryData(vn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function wn(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 Tn(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 En(e){let t=dn(),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(L,t)},h=()=>e.getQueryData(L),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:L,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:L,exact:!0}).then(()=>e.invalidateQueries({queryKey:L})):e.invalidateQueries({queryKey:L})).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=Cn(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=ln(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=on(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,bn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){fn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){pn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Tn(e,r);if(!mn(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),hn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=un(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=_n(t,n,Cn(e));for(let e of l)i.index=un(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),wn(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 Dn={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`}},On={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function kn(e){return typeof e==`string`&&Object.hasOwn(Dn,e)}function An(e){return e!==void 0&&kn(e)?Dn[e]:void 0}var z=new Map(In()),jn=1e3;function Mn(e,t){if(z.get(e)!==t){for(z.delete(e),z.set(e,t);z.size>jn;){let e=z.keys().next().value;if(e===void 0)break;z.delete(e)}Rn()}}var B=new Set(Ln());function Nn(e,t){if(B.has(e)!==t){if(t)for(B.add(e);B.size>jn;){let e=B.values().next().value;if(e===void 0)break;B.delete(e)}else B.delete(e);Rn()}}var Pn=`cez.reference-statuses.v1`,Fn=`cez.reference-conflicts.v1`;function In(){try{let e=globalThis.sessionStorage?.getItem(Pn);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`&&kn(e[1])):[]}catch{return[]}}function Ln(){try{let e=globalThis.sessionStorage?.getItem(Fn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var V;function Rn(){V===void 0&&(V=setTimeout(()=>{V=void 0;try{globalThis.sessionStorage?.setItem(Pn,JSON.stringify([...z])),globalThis.sessionStorage?.setItem(Fn,JSON.stringify([...B]))}catch{}},250))}var H=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function zn(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Bn(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 Vn(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;Mn(t,o),s!==void 0&&Nn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Hn(e,t,n){let r=H(t),i=z.get(r),a=B.has(r)?!0:void 0,o=n.data;if(o?.available){Vn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...zn(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...zn(i,a)});return}e.set(r,{state:`loading`,...zn(i,a)})}function Un(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Bn(i))Hn(n,e,t)}),n}function Wn(e){return x(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Gn(e){return Wn(e)&&e.status!==`queued`}function Kn(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&ke(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var qn=[`done`,`failed`];function Jn(e){return e.archived||x(e)||!qn.includes(e.status)?!1:e.finishedAt!==void 0}function Yn(e){let t=e.finishedAt;return t===void 0||!Jn(e)?!1:e.seenAt===void 0||e.seenAt<t}function Xn(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function Zn(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?Xn(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var Qn=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:Zn},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function $n(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function er(e,t){if(t!==`phrase`)return $n(e);let n=e.trim().toLowerCase();return n===``?[]:[n]}function tr(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function nr(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.omit??[]:[],i=t.scope===`shown`?t.extras:{automation:tr(e,t.automationNames)},a=[],o=[],s=[],c={text:a,identifier:o,link:s},l=[];for(let t of Qn)if(!(!t.scopes.includes(n)||r.includes(t.id))){if(t.kind===`reference`){l.push(()=>t.numbers(e,i));continue}for(let n of t.texts(e,i))typeof n==`string`&&c[t.kind].push(n.toLowerCase())}let u;return{prose:a,ids:o,links:s,references:()=>u??=new Set(l.flatMap(e=>e().map(String)))}}function rr(e,t,n={}){let r=er(t,n.mode);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=nr(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var ir=[`Needs you`,`Finished`,`Working`,`Archived`],ar={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},or=3,U=e=>x(e)?or:ar[e.status]??9;function sr(e){let t=e=>v[u(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||U(e)-U(n))[0]}function cr(e,t){return t===`archived`?`Archived`:u(e).bucket===`waiting`?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function lr(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function ur(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function dr(e,t){return t!==void 0&&ur(e).ref===t}function fr(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function pr(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=U(e)-U(n);if(r!==0)return r;if(x(e)&&x(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function W(e){return e.delegation?.role===`worker`}function mr(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!W(n)?e:n.delegation?.parentRunId??e}function hr(e,t,n=fr(e)){let r=pr(e,t).filter(e=>!W(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(cr(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return ir.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function gr(e,t={}){let n=typeof t==`number`?{overall:t}:zt(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function _r(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function vr(e){let t=0,n=0,r=0;for(let i of e)if(!W(i)){if(i.archived){n+=1;continue}t+=1,u(i).bucket===`waiting`&&(r+=1)}return{active:t,archived:n,waiting:r}}function yr(e,t){let n=t===`automations`;return e.filter(e=>!e.archived&&ke(e)===n)}var G={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},br=Object.keys(G),xr=`section`;function Sr(e,t){return`/?origin=${t===`automations`?`automations`:`direct`}&${xr}=${G[e]}`}function Cr(e){return br.find(t=>G[t]===e)??null}function wr(e){let t={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let n of e){if(W(n)||n.archived)continue;let e=+(u(n).bucket===`waiting`);ke(n)?(t.automations+=1,t.automationsWaiting+=e):(t.active+=1,t.activeWaiting+=e)}return t}var Tr=new Set([`running`,`waiting`]);function K(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function Er(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function Dr(e,t=new Date){if(!x(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function Or(e){return e.steps?Xt({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function kr(e,t,n=()=>``){let r=e.filter(e=>!W(e));return t.trim()?r.filter(e=>rr(e,t,{scope:`shown`,mode:`phrase`,extras:{displayTitle:lr(e),automation:n(e),references:()=>Ar(e)}})):[...r]}function Ar(e){return q(e).map(e=>e.number)}function jr(e,t){return e.filter(e=>Kn(e,t)).length}function Mr(e){return jr(e)}function Nr(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 Pr(e){return Fr(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function Fr(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function Ir(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function Lr(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function q(e,t,n=e.projectId){let r=Fr(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>Wr(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:Ir(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(Wr(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Rr(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=Lr(a);o.has(c)||(o.add(c),s.push(a))}return s}function Rr(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function zr(e){return q(e)[0]}function Br(e,t){if(!e.url)return!0;if(!t)return!1;let n=Vr(t);return n!==void 0&&Vr(e.url)===n}function Vr(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function Hr(e,t){let n=[];for(let r of q(e,t)){if(!Br(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function Ur(e,t,n,r){if(Br(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function Wr(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function Gr(e,t){let n=Tr.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:K(n.rssBytes),kind:`live`}};let r=K(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function Kr(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 qr(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 Jr(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 Yr(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 Xr(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Zr(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function Qr(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){Zr(t.issues,a,r),Zr(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 J=e=>e.map(e=>e.number).join(`,`);function $r(e,t){let n=e[0];if(e.length>1&&n&&(J(n.issues)!==J(t.issues)||J(n.prs)!==J(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 Y={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`]}},X={models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:L,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)=>[...X.fsBrowseRoot,e,t]};function Z(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:X.models(t),refetchType:n})}function Q(e,t=!0){let n=b();return(0,E.useEffect)(()=>{if(!t||e!==`cursor`)return;let r,i=()=>{let e=n.getQueryData(Y.health)?.capabilities?.localHandoff===!0;e&&!r?r=Ht(`models:cursor`,e=>{let t=Rt.safeParse(e);t.success&&t.data.runner===`cursor`&&(n.cancelQueries({queryKey:X.models(`cursor`)}),n.setQueryData(X.models(`cursor`),t.data))}):!e&&r&&(r(),r=void 0)};i();let a=n.getQueryCache().subscribe(i);return()=>{a(),r?.()}},[t,e,n]),w({queryKey:X.models(e),queryFn:({signal:t})=>S(e)?he(e,{signal:t}):Promise.reject(Error(`${e} has no host model catalog`)),staleTime:300*1e3,enabled:t&&S(e)})}function ei(e=!0){return{claude:Q(`claude`,e),codex:Q(`codex`,e),opencode:Q(`opencode`,e),pi:Q(`pi`,e),cursor:Q(`cursor`,e),omp:Q(`omp`,e)}}function ti(){let e=b();return w({queryKey:X.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(X.providerStatus),r=await ht(!1,{signal:t});return Ot(n,e.getQueryData(X.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function ni(){let e=b();return O({mutationFn:()=>ht(!0),onMutate:()=>e.getQueryData(X.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(X.providerStatus,e=>Ot(r,e,t)),Z(e)}})}function ri(){let e=b();return O({mutationFn:({provider:e,authFailureId:t})=>ut(e,t),onMutate:()=>e.getQueryData(X.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(X.providerStatus,e=>Ot(r,e,t,n.authFailureId)),S(n.provider)&&Z(e,n.provider)}})}function ii(e={}){return w({queryKey:X.projects,queryFn:({signal:e})=>Xe({signal:e}),...e})}function ai(e,t=!1){return w({queryKey:X.fsBrowse(e,t),queryFn:({signal:n})=>He(e??void 0,{signal:n,showHidden:t}),retry:!1})}function oi(){let e=b();return O({mutationFn:e=>yt(e),onSuccess:()=>e.invalidateQueries({queryKey:X.projects})})}function si(){let e=b();return O({mutationFn:e=>ot(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:X.projects})}})}function ci(){let e=b();return O({mutationFn:e=>{let{id:t,...n}=e;return h(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:X.projects});let r=e.getQueryData(X.projects);return e.setQueryData(X.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?li(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(X.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(X.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:X.projects})})}function li(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?[]:Jr(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function ui(e){let t=b();return O({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(X.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:X.projects})})}function di(){return ui(e=>{let{projectId:t,...n}=e;return Mt(t,n)})}function fi(){return ui(e=>{let{projectId:t,webhookId:n,...r}=e;return me(t,n,r)})}function pi(){return ui(({projectId:e,webhookId:t})=>wt(e,t))}function mi(){return O({mutationFn:({projectId:e,webhookId:t})=>f(e,t),retry:!1})}function hi(e){let t=b();return O({mutationFn:t=>Oe(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:Y.runs.all})})}function $(e){let t=b();return O({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:X.agentProfiles}),t.invalidateQueries({queryKey:X.projects})])}})}function gi(){return $(e=>Et(e))}function _i(){return $(e=>{let{id:t,...n}=e;return Ce(t,n)})}function vi(){return $(e=>We(e))}function yi(){return $(e=>Dt(e))}function bi(e,t){return w({queryKey:X.agentAccountDetails(e),queryFn:({signal:t})=>_(e,{signal:t}),enabled:t,staleTime:0,retry:!1})}function xi(e,t){return w({queryKey:X.agentAccountStatus(e),queryFn:({signal:t})=>re(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Si(){let e=b();return O({mutationFn:({provider:e,profileId:t})=>Ze(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:X.agentProfiles}),e.invalidateQueries({queryKey:X.providerStatus}),S(n)?Z(e,n,`none`):Promise.resolve()])}})}function Ci(){let e=b();return O({mutationFn:e=>re(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(X.agentAccountStatus(n),t),e.invalidateQueries({queryKey:X.agentProfiles}),S(t.status.provider)&&Z(e,t.status.provider)}})}function wi(){return O({mutationFn:e=>{let{routeId:t,...n}=e;return ne(t,n)},retry:!1})}function Ti(){let e=b();return O({mutationFn:e=>ct(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:X.projects})})}function Ei(){let e=b();return O({mutationFn:e=>Be(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:X.projects})})}function Di({enabled:e}){return w({queryKey:X.githubOwners,queryFn:({signal:e})=>St({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Oi(){let e=b();(0,E.useEffect)(()=>{let n,r=()=>{let r=e.getQueryData(Y.health),i=r?.capabilities?.localHandoff===!0;r&&p({local:i,bootProject:r.bootProject??`default`,apiBase:t()}),i&&n===void 0?n=Ht(`health`,t=>{e.setQueryData(Y.health,t)}):!i&&n!==void 0&&(n(),n=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),n?.(),it()}},[e])}function ki(){return w({queryKey:Y.health,queryFn:({signal:e})=>bt({signal:e})})}function Ai(e,t){let n=ki().data,r=ii(t).data?.projects,i=_t(),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?Nr(n?.repo?.remote):void 0}function ji(){return w({queryKey:Y.openTargets,queryFn:({signal:e})=>Je({signal:e}),staleTime:5*6e4})}function Mi(){return w({queryKey:Y.runs.list(),queryFn:({signal:e})=>at(k(),{signal:e})})}function Ni(e,t){return Bt({queryKey:Y.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 Pi(e){let t=e.trim();return w({queryKey:X.runsSearch(t),queryFn:({signal:e})=>Le(t,{signal:e}),enabled:t.length>=2,placeholderData:vt,staleTime:1e4})}function Fi(e=!0,t=yn){let n=R(b());return T(`/api/v1/workspace/runs-index`,X.runsIndex,a(e?t:!1),Sn),w({queryKey:X.runsIndex,queryFn:({signal:e})=>c({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function Ii(e,t=!0,n=!1){return w({queryKey:[k({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>at(k({projectId:e,boot:n}),{signal:t}),enabled:t,placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function Li(e){let t=b();return O({mutationFn:e=>nt(e),onSettled:()=>t.invalidateQueries({queryKey:Y.runs.relationships(e)})})}function Ri(e,t={}){return w({queryKey:Y.runs.relationships(e),queryFn:({signal:t})=>g(e,{signal:t}),enabled:t.enabled??!0})}function zi(e){return w({queryKey:Y.runs.detail(e??``),queryFn:({signal:t})=>kt(A(e),{signal:t}),enabled:!!e})}function Bi(e,t,n=!0){return w({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>kt(A(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Vi(e){return w({queryKey:Y.runs.diff(e??``),queryFn:({signal:t})=>Se(e,{signal:t}),enabled:!!e})}function Hi(e,t=!1){return T(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,Y.runs.changes(e??``),a(t?4e3:!1)),w({queryKey:Y.runs.changes(e??``),queryFn:({signal:t})=>Ft(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ui(e,t){return w({queryKey:Y.runs.file(e??``,t??``),queryFn:({signal:n})=>m(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Wi(e,t){return w({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Me(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Gi(e,t){return w({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Ee(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ki(e,t){return w({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>ee(e,t,{signal:n}),enabled:t!==null,retry:!1})}function qi(e){return w({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>we(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Ji(e,t=!1){return T(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,Y.runs.commits(e??``),a(t?5e3:!1)),w({queryKey:Y.runs.commits(e??``),queryFn:({signal:t})=>Nt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Yi(e,t){return w({queryKey:Y.runs.commit(e??``,t??``),queryFn:({signal:n})=>Ve(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Xi(e,t=!0){return w({queryKey:Y.runs.handoff(e??``),queryFn:({signal:t})=>jt(A(e),{signal:t}),enabled:!!e&&t})}function Zi(e,t,n){return w({queryKey:e===void 0?Y.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>jt(A(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Qi(e,t){let r=[...new Set(e)],i=D({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,E.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 $i(){return w({queryKey:Y.workflows,queryFn:({signal:e})=>ge({signal:e})})}function ea(e=!0){let t=b(),n=Y.skills,r=n[0],i=w({queryKey:n,queryFn:({signal:e})=>rt({signal:e}),enabled:e}),a=w({queryKey:Y.skillsReady,queryFn:({signal:e})=>fe({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,E.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`],a.data)},[t,a.data,r]),i}function ta(e=!0){let t=b(),n=Y.importableSkills,r=n[0],i=w({queryKey:n,queryFn:({signal:e})=>Ge({signal:e}),enabled:e}),a=w({queryKey:Y.importableSkillsReady,queryFn:({signal:e})=>st({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,E.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`,`importable`],a.data)},[t,a.data,r]),i}function na(){return w({queryKey:Y.launchKey,queryFn:({signal:e})=>Tt({signal:e}),staleTime:1/0})}function ra(){return w({queryKey:Y.repo,queryFn:({signal:e})=>dt({signal:e})})}function ia(e){return w({queryKey:[e,`repo`],queryFn:({signal:t})=>dt({signal:t},e)})}function aa(){return w({queryKey:Y.repoBranches,queryFn:({signal:e})=>$e({signal:e})})}function oa(){return w({queryKey:Y.repoChanges,queryFn:({signal:e})=>Qe({signal:e}),retry:!1})}function sa(e){return w({queryKey:Y.repoCommit(e??``),queryFn:({signal:t})=>Re(e,{signal:t}),enabled:!!e,retry:!1})}function ca(){return w({queryKey:Y.config,queryFn:({signal:e})=>ae({signal:e})})}function la(){return w({queryKey:Y.worktrees,queryFn:({signal:e})=>ue({signal:e})})}function ua(e){return w({queryKey:[e,`worktrees`],queryFn:({signal:t})=>ue({signal:t},e),staleTime:0})}function da(e,t=!0,n=!1){return w({queryKey:[k({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>pe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:zt(e.sidebarLimits)},enabled:t})}function fa(){return da(n())}function pa(){return w({queryKey:Y.agentConfig,queryFn:({signal:e})=>ce({signal:e})})}function ma(e){return w({queryKey:Y.agentConfigFile(e??``),queryFn:({signal:t})=>ye(e,{signal:t}),enabled:e!==null})}function ha(e){let t=b(),n=Y.agentConfig,r=Y.agentConfigFile(e);return O({mutationFn:t=>s(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function ga(){return w({queryKey:X.uiState,queryFn:({signal:e})=>ie({signal:e})})}function _a(){return w({queryKey:X.config,queryFn:({signal:e})=>y({signal:e})})}function va(){return w({queryKey:X.agentProfiles,queryFn:({signal:e})=>It({signal:e})})}function ya(e){let t=b();return O({mutationFn:t=>oe(e,t),onSuccess:()=>t.invalidateQueries({queryKey:Y.runs.all})})}function ba(e){let t=F(),n=e?.projectId,r=e?.cacheScope,i=O({mutationFn:e=>xe(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,E.useCallback)(e=>({...A(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,E.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,E.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,E.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function xa(){let e=F();return O({mutationFn:e=>xe(A(e),!1),onMutate:t=>e.patchRead(()=>A(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Sa(e){let t=F();return O({mutationFn:({id:t,pinned:n})=>Ne(A(t,e),n),onError:e=>Ut(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??k(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ca(e,t){let n=F();return O({mutationFn:n=>Pt(A(e,{projectId:t}),n),onMutate:()=>k({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 wa(e,t){let n=F();return O({mutationFn:(n={})=>Ie(A(e,{projectId:t}),n),onMutate:()=>k({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Ta(e){let t=b();return O({mutationFn:({msgId:t,message:n})=>de(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:Y.runs.all})})}function Ea(e){let t=b();return O({mutationFn:t=>qe(e,t),onSuccess:()=>t.invalidateQueries({queryKey:Y.runs.all})})}function Da(e={},t=!0){let r=b(),i=Y.github(e);T(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=w({queryKey:Y.github(e),queryFn:({signal:t})=>je({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=w({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,E.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 Oa=class extends Error{};function ka(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await je({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Oa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Yr(e),retry:(e,t)=>!(t instanceof Oa)&&!(t instanceof et&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Aa(e=50,t=!0){let r=b(),i=Y.githubPages(e),o=Y.githubPagesHead(e);T(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=Bt({...ka(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=w({queryKey:o,queryFn:({signal:t})=>je({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,E.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=$r(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=D({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>tt(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,E.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,E.useMemo)(()=>Qr(s.data?.pages??[]),[s.data])}}function ja(e,t=50,n=!0){let r=Bt({...ka([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,E.useMemo)(()=>Qr(r.data?.pages??[]),[r.data])}}function Ma(e,t,n=!0){let r=D({queries:t.filter(e=>e.length>0).map(t=>({queryKey:Y.githubCommentCounts(e,t),queryFn:({signal:n})=>_e(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,E.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 Na(e,t,n,r=!0){return w({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>mt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Pa(e,t=!0){return w({queryKey:Y.githubChecks(e),queryFn:({signal:t})=>Pe(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Fa(e,t,n=!0){return w({queryKey:Y.githubSearch(e,t),queryFn:({signal:n})=>mt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ia=100;function La(e){return[...e].sort((e,t)=>t-e).slice(0,Ia).sort((e,t)=>e-t)}function Ra(){let e=_t(),t=ki();return e.projectId??t.data?.bootProject}function za(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))Mn(H({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))Mn(H({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Ba=5*6e4;function Va(e){return e?e.recheckAfterMs:Ba}function Ha(e,t=!0){let n=(0,E.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:La(t.prs),issues:La(t.issues)}))},[e.map(H).sort().join(`|`)]),r=D({queries:n.map(e=>({queryKey:Y.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>ze(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Va(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Va(r[t]?.data)??!1})));(0,E.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=Y.githubRefStatus(t.projectId,t.prs,t.issues);return Vt({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,E.useMemo)(()=>Un(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,E.useCallback)(e=>{let t=H(e),n=s.get(t);if(n)return n;let r=z.get(t);return{state:`idle`,...r?{status:r}:{},...B.has(t)?{conflicting:!0}:{}}},[s])}function Ua(e,t,n=!0){return w({queryKey:Y.githubComments(e,t),queryFn:({signal:n})=>o(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Wa(e,t,n=!0){return w({queryKey:Y.githubItem(e,t),queryFn:({signal:n})=>Ye(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ga(e){return w({queryKey:Y.githubPrChanges(e??0),queryFn:({signal:t})=>ft(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{ii as $,Lr as $t,Di as A,_r as An,Ca as At,hi as B,F as Bn,ga as Bt,Wi as C,lr as Cn,Ri as Ct,Ma as D,yr as Dn,Fi as Dt,Pa as E,wr as En,Mi as Et,Oi as F,Kn as Fn,_i as Ft,ja as G,qr as Gt,ji as H,A as Hn,X as Ht,ta as I,Yn as In,ci as It,Ai as J,Er as Jt,Na as K,kr as Kt,na as L,On as Ln,fi as Lt,Ga as M,Jn as Mn,Zi as Mt,Fa as N,Wn as Nn,mi as Nt,Ua as O,pr as On,Pi as Ot,ki as P,Gn as Pn,fa as Pt,ua as Q,Wr as Qt,ba as R,An as Rn,$i as Rt,Ta as S,dr as Sn,Xi as St,Da as T,mr as Tn,Q as Tt,ya as U,O as Un,Xr as Ut,wi as V,k as Vn,la as Vt,Sa as W,Wt as Wn,Kr as Wt,Ii as X,Nr as Xt,Bi as Y,K as Yt,da as Z,Br as Zt,wa as _,W as _n,Hi as _t,xi as a,Hr as an,ni as at,di as b,Cr as bn,Vi as bt,va as c,q as cn,si as ct,Ki as d,ir as dn,ra as dt,Dr as en,ti as et,qi as f,xr as fn,aa as ft,Si as g,hr as gn,zi as gt,ca as h,gr as hn,ri as ht,bi as i,Ur as in,Ha as it,Aa as j,rr as jn,ea as jt,Wa as k,ur as kn,yi as kt,Ni as l,Gr as ln,pi as lt,Ti as m,cr as mn,sa as mt,Y as n,jr as nn,Ci as nt,pa as o,Pr as on,oi as ot,Qi as p,br as pn,oa as pt,ia as q,Mr as qt,za as r,Ir as rn,Ra as rt,ma as s,zr as sn,vi as st,Z as t,Ar as tn,ha as tt,Gi as u,Or as un,Ea as ut,gi as v,vr as vn,Yi as vt,ai as w,Sr as wn,ei as wt,Li as x,fr as xn,Ui as xt,Ei as y,sr as yn,Ji as yt,xa as z,R as zn,_a as zt};