@puddle-code/cli 0.0.12 → 0.0.14

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 (30) hide show
  1. package/CHANGELOG.md +41 -77
  2. package/README.md +4 -4
  3. package/dist/index.js +446 -166
  4. package/dist/public/assets/Dashboard-Ct5exI8s.js +1 -0
  5. package/dist/public/assets/{EditorTabClose-C3OCj0Ia.js → EditorTabClose-BhFjRoCZ.js} +1 -1
  6. package/dist/public/assets/{LazyTerminal-BihPI9J1.js → LazyTerminal-B0xYs2ul.js} +2 -2
  7. package/dist/public/assets/{ModelRefcount-wkKpjkKn.js → ModelRefcount-BY5Ul0p3.js} +1 -1
  8. package/dist/public/assets/{PaneEditorBody-DRR16vdx.js → PaneEditorBody-DLMtDiov.js} +1 -1
  9. package/dist/public/assets/SettingsDialog-WhQXNCmS.js +1 -0
  10. package/dist/public/assets/{Terminal-Ci3-2jXt.js → Terminal-DA8zjtmU.js} +1 -1
  11. package/dist/public/assets/Workspace-B0FDl771.js +6 -0
  12. package/dist/public/assets/{buffer-store-mErJ-u_7.js → buffer-store-BHJ82Nh3.js} +2 -2
  13. package/dist/public/assets/context-menu--H5GoapF.js +1 -0
  14. package/dist/public/assets/{cssMode-BxSU83en.js → cssMode-Ctq00nXG.js} +1 -1
  15. package/dist/public/assets/{htmlMode-BI3Fg8wV.js → htmlMode-pYCLPiZ_.js} +1 -1
  16. package/dist/public/assets/index-CjgsCY-C.css +2 -0
  17. package/dist/public/assets/index-RvCLpi9M.js +10 -0
  18. package/dist/public/assets/{jsonMode-Bsh_R96t.js → jsonMode-Ch5UticT.js} +1 -1
  19. package/dist/public/assets/{session-seed-BbO3y4XI.js → session-seed-DBxHPYBK.js} +1 -1
  20. package/dist/public/assets/ssh-mode-eNTVum_C.js +1 -0
  21. package/dist/public/assets/{tsMode-CV6x0W8w.js → tsMode-CeXrzlPn.js} +1 -1
  22. package/dist/public/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/public/assets/Dashboard-DOKOSPsG.js +0 -1
  25. package/dist/public/assets/SettingsDialog-CpnehH60.js +0 -1
  26. package/dist/public/assets/Workspace-D1XOZzcy.js +0 -6
  27. package/dist/public/assets/context-menu-DyvGbiNT.js +0 -1
  28. package/dist/public/assets/index-DIgA5eoW.js +0 -10
  29. package/dist/public/assets/index-WMJ9gBck.css +0 -2
  30. package/dist/public/assets/ssh-mode-BuFhqbL1.js +0 -1
@@ -1,6 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-DRR16vdx.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/editor-tabs-D0_DZriG.js","assets/poll-focus-B7dQPFj6.js","assets/api-Bh5IJ30S.js","assets/createLucideIcon-DyMAgLa3.js","assets/index-DIgA5eoW.js","assets/preload-helper-Czpn1I53.js","assets/dialog-B43iKmfK.js","assets/utils-B6KiDbIe.js","assets/LazyTerminal-BihPI9J1.js","assets/index-WMJ9gBck.css","assets/editor.api2-4X9Vh9Zw.js","assets/editor-Br_kD0ds.css","assets/buffer-store-mErJ-u_7.js","assets/buffer-logic-BrpRsL1b.js","assets/editor-sync-F3Wyveaa.js","assets/debounce-B9DrqirV.js","assets/ModelRefcount-wkKpjkKn.js","assets/EditorTabClose-C3OCj0Ia.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{o as i}from"./poll-focus-B7dQPFj6.js";import{C as a,S as o,a as s,d as c,f as l,g as u,h as d,l as f,m as p,n as m,p as h,r as g,s as _,t as v,u as y,w as b,x,y as S}from"./editor-tabs-D0_DZriG.js";import{t as C}from"./preload-helper-Czpn1I53.js";import{c as w,l as T,v as E,x as D}from"./api-Bh5IJ30S.js";import{A as ee,O,_ as k,a as te,b as A,g as j,h as ne,i as re,j as M,n as N,o as P,r as ie,t as F,w as ae}from"./dialog-B43iKmfK.js";import{A as oe,B as se,C as ce,G as I,H as le,J as ue,K as de,M as fe,Q as L,S as pe,T as R,U as me,W as he,X as ge,Z as _e,c as z,d as ve,et as ye,h as be,l as B,m as xe,n as Se,nt as Ce,o as we,ot as Te,p as Ee,q as De,r as Oe,s as ke,st as Ae,t as je,tt as Me}from"./LazyTerminal-BihPI9J1.js";import{t as V}from"./utils-B6KiDbIe.js";import{t as H}from"./createLucideIcon-DyMAgLa3.js";import{A as Ne,C as Pe,D as Fe,E as Ie,O as Le,S as Re,T as ze,_ as Be,a as Ve,b as He,c as Ue,d as We,f as Ge,g as Ke,h as qe,i as Je,j as Ye,l as Xe,m as Ze,n as Qe,o as $e,p as et,r as U,s as tt,t as nt,u as rt,v as it,w as at,x as ot,y as st}from"./context-menu-DyvGbiNT.js";import{a as ct,i as lt,n as ut,o as dt,r as ft,s as pt,t as mt}from"./session-seed-BbO3y4XI.js";import{i as ht,r as gt}from"./dist-VDiYuPKw.js";import{$ as _t,G as vt,I as yt,K as bt,P as xt,Q as St,R as Ct,S as wt,U as Tt,W as Et,X as Dt,Z as Ot,_ as kt,a as At,ct as jt,et as Mt,g as Nt,i as Pt,j as Ft,lt as It,n as Lt,s as Rt,t as zt,ut as Bt,w as Vt}from"./index-DIgA5eoW.js";import{t as Ht}from"./debounce-B9DrqirV.js";import{i as Ut}from"./buffer-logic-BrpRsL1b.js";import{t as Wt}from"./ssh-mode-BuFhqbL1.js";var Gt=H(`case-sensitive`,[[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M22 9v7`,key:`pvm9v3`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}],[`circle`,{cx:`18.5`,cy:`12.5`,r:`3.5`,key:`z97x68`}]]),Kt=H(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),qt=H(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Jt=H(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),Yt=H(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Xt=H(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Zt=H(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),Qt=H(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),W=H(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),$t=H(`file-cog`,[[`path`,{d:`M15 8a1 1 0 0 1-1-1V2a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8z`,key:`1ckgky`}],[`path`,{d:`M20 8v12a2 2 0 0 1-2 2h-4.182`,key:`1726p0`}],[`path`,{d:`m3.305 19.53.923-.382`,key:`ao1pio`}],[`path`,{d:`M4 10.592V4a2 2 0 0 1 2-2h8`,key:`1foop0`}],[`path`,{d:`m4.228 16.852-.924-.383`,key:`1fv9zy`}],[`path`,{d:`m5.852 15.228-.383-.923`,key:`1a9hc2`}],[`path`,{d:`m5.852 20.772-.383.924`,key:`1sh9ke`}],[`path`,{d:`m8.148 15.228.383-.923`,key:`4yu6lf`}],[`path`,{d:`m8.53 21.696-.382-.924`,key:`18b0s9`}],[`path`,{d:`m9.773 16.852.922-.383`,key:`ti6xop`}],[`path`,{d:`m9.773 19.148.922.383`,key:`rws47d`}],[`circle`,{cx:`7`,cy:`18`,r:`3`,key:`lvkj7j`}]]),en=H(`file-headphone`,[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]]),tn=H(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),nn=H(`file-key`,[[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M4 12v6`,key:`bg1pfk`}],[`path`,{d:`M4 14h2`,key:`1sf9f8`}],[`path`,{d:`M9.65 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v4`,key:`d56i0q`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),rn=H(`file-lock`,[[`path`,{d:`M4 9.8V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3`,key:`1432pc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 17v-2a2 2 0 0 0-4 0v2`,key:`168m41`}],[`rect`,{width:`8`,height:`5`,x:`3`,y:`17`,rx:`1`,key:`o8vfew`}]]),an=H(`file-play`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z`,key:`1tzo1f`}]]),on=H(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),sn=H(`file-spreadsheet`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),cn=H(`file-terminal`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m8 16 2-2-2-2`,key:`10vzyd`}],[`path`,{d:`M12 18h4`,key:`1wd2n7`}]]),ln=H(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),un=H(`file-type`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M11 18h2`,key:`12mj7e`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5`,key:`qbrxap`}]]),dn=H(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),fn=H(`folder-closed`,[[`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:`M2 10h20`,key:`1ir3d8`}]]),pn=H(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),mn=H(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),hn=H(`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`}]]),gn=H(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),_n=H(`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`}]]),vn=H(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),yn=H(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),bn=H(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),xn=H(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),Sn=H(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),Cn=H(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),wn=H(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Tn=H(`regex`,[[`path`,{d:`M17 3v10`,key:`15fgeh`}],[`path`,{d:`m12.67 5.5 8.66 5`,key:`1gpheq`}],[`path`,{d:`m12.67 10.5 8.66-5`,key:`1dkfa6`}],[`path`,{d:`M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z`,key:`swwfx4`}]]),En=H(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Dn=H(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),On=H(`user-round-cog`,[[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`m15.228 16.852-.923-.383`,key:`npixar`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`M2 21a8 8 0 0 1 10.434-7.62`,key:`1yezr2`}],[`path`,{d:`m20.772 16.852.924-.383`,key:`htqkph`}],[`path`,{d:`m20.772 19.148.924.383`,key:`9w9pjp`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]]),kn=H(`whole-word`,[[`circle`,{cx:`7`,cy:`12`,r:`3`,key:`12clwm`}],[`path`,{d:`M10 9v6`,key:`17i7lo`}],[`circle`,{cx:`17`,cy:`12`,r:`3`,key:`gl7c2s`}],[`path`,{d:`M14 7v8`,key:`dl84cr`}],[`path`,{d:`M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1`,key:`lt2kga`}]]),G=r(),K=e(t(),1);function An(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function jn(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function Mn(e){return e/100*window.innerHeight}function Nn(e){return e/100*window.innerWidth}function Pn(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function Fn({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Pn(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=jn(t,i);break;case`em`:r=An(t,i);break;case`vh`:r=Mn(i);break;case`vw`:r=Nn(i);break}return r}function In(e){return parseFloat(e.toFixed(3))}function Ln({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Rn(e){let{panels:t}=e,n=Ln({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=In(Fn({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=In(Fn({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=In(Fn({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=In(Fn({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function q(e,t=`Assertion error`){if(!e)throw Error(t)}function zn(e,t){return Array.from(t).sort(e===`horizontal`?Bn:Vn)}function Bn(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Vn(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Hn(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Un(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Wn({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=Un(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return q(i,`No rect found`),i}var Gn;function Kn(){return Gn===void 0&&(Gn=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),Gn}function qn(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=zn(n,Array.from(t.children).filter(Hn).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Wn({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Kn()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Ln({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Jn=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},Yn={cursorFlags:0,state:`inactive`},Xn=new Jn;function Zn(){return Yn}function Qn(e){return Xn.addListener(`change`,e)}function $n(e){let t=Yn,n={...Yn};n.cursorFlags=e,Yn=n,Xn.emit(`change`,{prev:t,next:n})}function er(e){let t=Yn;Yn=e,Xn.emit(`change`,{prev:t,next:e})}var tr=e=>e,nr=()=>{},rr=1,ir=2,ar=4,or=8,sr=3,cr=12,lr;function ur(){return lr===void 0&&(lr=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(lr=!0)),lr}function dr({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&ur()){let t=(e&rr)!==0,n=(e&ir)!==0,r=(e&ar)!==0,i=(e&or)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return ur()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var fr=new WeakMap;function pr(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=fr.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=Zn();switch(r.state){case`active`:case`hover`:{let e=dr({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}fr.set(e,{prevStyle:t,styleSheet:n})}var mr=new Map,hr=new Jn;function gr(e){mr=new Map(mr),mr.delete(e)}function _r(e,t){for(let[t]of mr)if(t.id===e)return t}function vr(e,t){for(let[t,n]of mr)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function yr(){return mr}function br(e,t){return hr.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function xr(e,t,n){let r=mr.get(e);mr=new Map(mr),mr.set(e,t),hr.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Sr(e){let t=Zn(),n=!1;switch(t.state){case`active`:er({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(pr(e),n=!0,t.hitRegions.forEach(e=>{let t=vr(e.group.id,!0);xr(e.group,t,{isUserInteraction:!0})}))}return n}function Cr(e){e.defaultPrevented||Sr(e.currentTarget)}function wr(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Un(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Tr(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Er(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Mr(e),b:Mr(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();q(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:jr(Ar(n.a)),b:jr(Ar(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Dr=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Or(e){let t=getComputedStyle(Nr(e)??e).display;return t===`flex`||t===`inline-flex`}function kr(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Or(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Dr.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Ar(e){let t=e.length;for(;t--;){let n=e[t];if(q(n,`Missing node`),kr(n))return n}return null}function jr(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Mr(e){let t=[];for(;e;)t.push(e),e=Nr(e);return t}function Nr(e){let{parentNode:t}=e;return Tr(t)?t.host:t}function Pr(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Fr({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Hn(n)||n.contains(e)||e.contains(n))return!0;if(Er(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Pr(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Ir(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=qn(r),a=wr(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Fr({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Lr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function J(e,t,n=0){return Math.abs(In(e)-In(t))<=n}function Rr(e,t){return J(e,t)?0:e>t?1:-1}function zr({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(Rr(r,c)<0)if(a){let e=(i+c)/2;r=Rr(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=In(r),r}function Br({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(J(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;q(u!=null,`Invalid first pivot index`),q(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];q(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(q(n!=null,`Previous layout not found for panel index ${t}`),J(n,i)){let t=o-n;Rr(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];q(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(q(n!=null,`Previous layout not found for panel index ${t}`),J(n,o)){let t=n-i;Rr(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];q(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&Rr(i,c)<0)if(e>0){let t=c-o,n=t/2;Rr(i+e,c)<0&&(e=Rr(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Rr(i-e,c)<0&&(e=Rr(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];q(e!=null,`Previous layout not found for panel index ${r}`);let a=zr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];q(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=zr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!J(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Lr(c,l))return i;{let t=e<0?d:u,r=s[t];q(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=zr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!J(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];q(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=zr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(J(i,s)||(t-=s-i,l[r]=s),J(t,0))break;e>0?r--:r++}}}if(!J(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function Vr(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Rr(e[n],t[n])!==0)return!1;return!0}function Hr({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!J(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];q(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];q(i!=null,`No layout data found for index ${e}`);let o=r[e];q(o!=null,`No layout data found for index ${e}`);let s=zr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!J(a,0))for(let e=0;e<t.length;e++){let n=r[e];q(n!=null,`No layout data found for index ${e}`);let i=n+a,o=zr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,J(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Ur({groupId:e,panelId:t}){let n=()=>{let t=yr();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&J(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:In(100-e)}}return Br({delta:l?o-e:e-o,initialLayout:r,panelConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedPanelConstraints:r,group:i,groupSize:s,layout:c,separatorToPanels:l}=n(),u=Hr({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});Vr(c,u)||xr(i,{defaultLayoutDeferred:t,derivedPanelConstraints:r,groupSize:s,layout:u,separatorToPanels:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&J(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Ln({group:t}),o=In(Fn({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function Wr(e){e.defaultPrevented||Ir(e,yr()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=Ur({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Gr(e){let t=yr();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Kr({groupId:e}){let t=()=>{let t=yr();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=Hr({layout:e,panelConstraints:r});return n?o:(Vr(o,c)||xr(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function qr(e,t){let n=Gr(e),r=vr(n.id,!0),i=n.separators.find(t=>t.element===e);q(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);q(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Kr({groupId:n.id}).getLayout(),c=Hr({layout:Br({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Vr(s,c)||xr(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function Jr(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Gr(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&qr(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&qr(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&qr(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&qr(t,-5);break;case`End`:e.preventDefault(),qr(t,100);break;case`Enter`:{e.preventDefault();let n=Gr(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=vr(n.id,!0),o=n.separators.find(e=>e.element===t);q(o,`Matching separator not found`);let s=a.get(o);q(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(q(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];qr(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Gr(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);q(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),qr(t,-100);break}}function Yr(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=yr(),n=Ir(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),er({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function Xr({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=Br({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Vr(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?rr:ir;break;case`vertical`:s|=d<0?ar:or;break}}else xr(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&sr:c|=s&sr,t.movementY===0?c|=o&cr:c|=s&cr,$n(c),pr(e)}function Zr(e){let t=yr(),n=Zn();switch(n.state){case`active`:Xr({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Qr(e){if(e.defaultPrevented)return;let t=Zn(),n=yr();switch(t.state){case`active`:if(e.buttons===0){er({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=vr(e.group.id,!0);xr(e.group,t,{isUserInteraction:!0})});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}Xr({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Ir(e,n);r.length===0?t.state!==`inactive`&&er({cursorFlags:0,state:`inactive`}):er({cursorFlags:0,hitRegions:r,state:`hover`}),pr(e.currentTarget);break}}}function $r(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Zn().state){case`hover`:er({cursorFlags:0,state:`inactive`})}}function ei(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Sr(e.currentTarget)&&e.preventDefault()}function ti(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=In(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=In((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function ni(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Ln({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:In(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function ri(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ii({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=In(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=In((r[e]??0)/a*l);else{let e=In(l/c.length);for(let t of c)u[t]=e}return u}function ai(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var oi=new Map;function si(e){let t=!0;q(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Ln({group:e});if(t===0)return;let n=vr(e.id);if(!n)return;let r=Rn(e),i=n.defaultLayoutDeferred?ti(r):n.layout,a=Hr({layout:ii({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Vr(n.layout,a)&&ri(n.derivedPanelConstraints,r)&&n.groupSize===t)return;xr(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else ni(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{q(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Ln({group:e}),s=Rn(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(ai(e.panels,l)||(l=void 0));let u=Hr({layout:e.mutableState.layouts[c]??l??ti(s),panelConstraints:s}),d=e.element.ownerDocument;oi.set(d,(oi.get(d)??0)+1);let f=new Map;return qn(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),xr(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{q(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Jr)}),oi.get(d)===1&&(d.addEventListener(`contextmenu`,Cr,!0),d.addEventListener(`dblclick`,Wr,!0),d.addEventListener(`pointerdown`,Yr,!0),d.addEventListener(`pointerleave`,Zr),d.addEventListener(`pointermove`,Qr),d.addEventListener(`pointerout`,$r),d.addEventListener(`pointerup`,ei,!0)),function(){t=!1,oi.set(d,Math.max(0,(oi.get(d)??0)-1)),gr(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Jr)}),oi.get(d)||(d.removeEventListener(`contextmenu`,Cr,!0),d.removeEventListener(`dblclick`,Wr,!0),d.removeEventListener(`pointerdown`,Yr,!0),d.removeEventListener(`pointerleave`,Zr),d.removeEventListener(`pointermove`,Qr),d.removeEventListener(`pointerout`,$r),d.removeEventListener(`pointerup`,ei,!0)),a.disconnect()}}function ci(){let[e,t]=(0,K.useState)({});return[e,(0,K.useCallback)(()=>t({}),[])]}function li(e){let t=(0,K.useId)();return`${e??t}`}var ui=typeof window<`u`?K.useLayoutEffect:K.useEffect;function di(e){let t=(0,K.useRef)(e);return ui(()=>{t.current=e},[e]),(0,K.useCallback)((...e)=>t.current?.(...e),[t])}function fi(...e){return di(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function pi(e){let t=(0,K.useRef)({...e});return ui(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var mi=(0,K.createContext)(null);function hi(e,t){let n=(0,K.useRef)({getLayout:()=>({}),setLayout:tr});(0,K.useImperativeHandle)(t,()=>n.current,[]),ui(()=>{Object.assign(n.current,Kr({groupId:e}))})}function gi({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,K.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=di(e=>{Vr(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=di((e,t)=>{Vr(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=li(s),v=(0,K.useRef)(null),[y,b]=ci(),x=(0,K.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=fi(v,a);hi(_,o);let C=di((e,t)=>{let r=Zn(),i=_r(e),a=vr(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=pi({defaultLayout:n,disableCursor:r}),T=(0,K.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=zn(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=zn(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=_r(_),i=vr(_);r&&i&&xr(r,{...i,derivedPanelConstraints:Rn(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,K.useRef)(null);return ui(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=si(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=vr(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=br(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=J(t.collapsedSize,i[t.panelId]),a=J(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Zn().state!==`active`;h(i),o&&g(i,e.isUserInteraction)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,K.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,G.jsx)(mi.Provider,{value:T,children:(0,G.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}gi.displayName=`Group`;function _i(){let e=(0,K.useContext)(mi);return q(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function vi(e,t){let{id:n}=_i(),r=(0,K.useRef)({collapse:nr,expand:nr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:nr});(0,K.useImperativeHandle)(t,()=>r.current,[]),ui(()=>{Object.assign(r.current,Ur({groupId:n,panelId:e}))})}function yi({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=li(c),_=pi({disabled:a}),v=(0,K.useRef)(null),y=fi(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=_i(),T=d!==null,E=di((e,t,n)=>{d?.(e,c,n)});ui(()=>{let e=v.current;if(e!==null){let t={element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}};return C(t)}},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,K.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),vi(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},ee=(0,K.useSyncExternalStore)(e=>br(x,e),D,D),O;return O=ee?JSON.parse(ee):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,G.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...bi,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...O},children:(0,G.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}yi.displayName=`Panel`;var bi={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function xi({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Hr({layout:Br({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Hr({layout:Br({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Si({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=li(a),l=pi({disabled:n,disableDoubleClick:r}),[u,d]=(0,K.useState)({}),[f,p]=(0,K.useState)(`inactive`),[m,h]=(0,K.useState)(!1),g=(0,K.useRef)(null),_=fi(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=_i(),C=b===`horizontal`?`vertical`:`horizontal`;ui(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=Qn(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=br(y,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(xi({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,K.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,G.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Si.displayName=`Separator`;function Ci(e,t,n){let r=n.snapshot.explorer_pin,i=r===null?null:e.find(e=>e.id===r&&e.status!==`archived`)??null;return{session:i??e.find(e=>e.id===t)??null,pinned:i!==null,pin(e){n.update({explorer_pin:e})},unpin(){n.update({explorer_pin:null})}}}var wi=null,Ti=null;async function Ei(){let[e,t]=await Promise.all([C(()=>import(`./PaneEditorBody-DRR16vdx.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),C(()=>import(`./ModelRefcount-wkKpjkKn.js`),__vite__mapDeps([20,1,2,16,9,8,3,5,6,10,11,7,12,13,14,15,17]))]);wi=e.PaneEditorBody,Ti=t.ModelRefcount}var Di=(0,K.lazy)(()=>C(()=>import(`./PaneEditorBody-DRR16vdx.js`).then(e=>({default:e.PaneEditorBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function Oi(e){return wi?(0,G.jsx)(wi,{...e}):(0,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-xs text-fg-muted`,children:`Loading editor…`}),children:(0,G.jsx)(Di,{...e})})}var ki=(0,K.lazy)(()=>C(()=>import(`./ModelRefcount-wkKpjkKn.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([20,1,2,16,9,8,3,5,6,10,11,7,12,13,14,15,17])));function Ai({buffers:e}){return Ti?(0,G.jsx)(Ti,{buffers:e}):(0,G.jsx)(K.Suspense,{fallback:null,children:(0,G.jsx)(ki,{buffers:e})})}var ji=(0,K.lazy)(()=>C(()=>import(`./EditorTabClose-C3OCj0Ia.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([21,1,2,3,10,11,7,16,9,8,5,6,12,13,14,15,17,18,19])));function Mi(e){return(0,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onClose()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,"aria-label":`Close ${e.label}`,children:`×`}),children:(0,G.jsx)(ji,{...e})})}var Ni=e(n(),1);function Pi(){return crypto.randomUUID()}function Y(e){return e.type===`terminal`?`term:${e.session}`:`editor:${v(e.tab)}`}function Fi(e,t){return Y(e)===Y(t)}function Ii(e){return e.type===`terminal`}function Li(e=[],t){let n=e.map(Y),r=t&&n.includes(t)?t:n.length>0?n[0]:null;return{kind:`leaf`,id:Pi(),tabs:e,activeKey:r,previewKey:null}}function Ri(e,t,n){return{kind:`split`,id:Pi(),direction:e,children:t,sizes:n??t.map(()=>100/Math.max(1,t.length))}}function zi(e,t){if(e.kind===`leaf`)return e.id===t?e:null;for(let n of e.children){let e=zi(n,t);if(e)return e}return null}function Bi(e,t){if(e.kind===`leaf`)return e.tabs.some(e=>Y(e)===t)?e:null;for(let n of e.children){let e=Bi(n,t);if(e)return e}return null}function Vi(e){return e.kind===`leaf`?[e]:e.children.flatMap(Vi)}function Hi(e){return Vi(e).flatMap(e=>e.tabs)}function Ui(e){let t=e.tabs.map(Y),n=e.activeKey&&t.includes(e.activeKey)?e.activeKey:t[0]??null,r=e.previewKey&&t.includes(e.previewKey)?e.previewKey:null;return n===e.activeKey&&r===(e.previewKey??null)?e:{...e,activeKey:n,previewKey:r}}function Wi(e){if(e.kind===`leaf`)return Ui(e);let t=e.children.map(Wi),n=[],r=[];t.forEach((t,i)=>{let a=e.sizes[i]??1;if(t.kind===`split`&&t.direction===e.direction){let e=t.sizes.reduce((e,t)=>e+t,0)||t.children.length;t.children.forEach((i,o)=>{n.push(i),r.push(a*(t.sizes[o]??1)/e)})}else n.push(t),r.push(a)});let i=[],a=[];return n.forEach((e,t)=>{e.kind===`leaf`&&e.tabs.length===0||(i.push(e),a.push(r[t]??1))}),i.length===0?Li([]):i.length===1?i[0]:{...e,children:i,sizes:a}}function Gi(e,t,n){return e.kind===`leaf`?e.id===t?n(e):e:{...e,children:e.children.map(e=>Gi(e,t,n))}}function Ki(e,t){if(e.kind===`leaf`){if(!e.tabs.some(e=>Y(e)===t))return e;let n=e.tabs.filter(e=>Y(e)!==t),r=e.activeKey===t?qi(e,t):e.activeKey;return{...e,tabs:n,activeKey:r}}return{...e,children:e.children.map(e=>Ki(e,t))}}function qi(e,t){let n=e.tabs.findIndex(e=>Y(e)===t);if(n===-1)return e.activeKey;let r=e.tabs.filter(e=>Y(e)!==t);return r.length===0?null:Y(r[Math.min(n,r.length-1)])}function Ji(e,t,n){let r=e.tabs.filter(e=>!Fi(e,t)),i=n===void 0?r.length:Math.max(0,Math.min(n,r.length)),a=[...r.slice(0,i),t,...r.slice(i)];return{...e,tabs:a,activeKey:Y(t)}}function Yi(e,t,n,r){let i=n===`left`||n===`right`?`row`:`col`,a=n===`left`||n===`top`;return Wi(Gi(e,t,e=>{let t=Li([r]);return Ri(i,a?[t,e]:[e,t],[50,50])}))}function Xi(e,t){let{ref:n,toLeafId:r,edge:i}=t,a=Y(n),o=t.index;if(i===`center`&&o!==void 0){let t=zi(e,r)?.tabs.findIndex(e=>Y(e)===a)??-1;t!==-1&&t<o&&--o}let s=Ki(e,a);if(i===`center`){let e=Gi(s,r,e=>Ji(e,n,o));return!zi(e,r)&&!Bi(e,a)?ta(Wi(Zi(e,n)),a):ta(Wi(e),a)}return zi(s,r)?ta(Yi(s,r,i,n),a):Wi(Li([n]))}function Zi(e,t){let n=Vi(e)[0];return n?Gi(e,n.id,e=>Ji(e,t)):Li([t])}function Qi(e,t,n){return Wi(Gi(e,t,e=>e.tabs.some(e=>Y(e)===n)?{...e,tabs:e.tabs.filter(e=>Y(e)!==n),activeKey:e.activeKey===n?qi(e,n):e.activeKey}:e))}function $i(e,t,n){let r=Y(n);return Wi(Gi(e,t,e=>{let t=e.previewKey===r?null:e.previewKey;return e.tabs.some(e=>Fi(e,n))?{...e,activeKey:r,previewKey:t}:{...e,tabs:[...e.tabs,n],activeKey:r,previewKey:t}}))}function ea(e,t,n){let r=Y(n);return Wi(Gi(e,t,e=>{if(e.tabs.some(e=>Fi(e,n)))return{...e,activeKey:r};let t=e.previewKey?e.tabs.findIndex(t=>Y(t)===e.previewKey):-1,i=t>=0&&!Ii(e.tabs[t])?e.tabs.map((e,r)=>r===t?n:e):[...e.tabs,n];return{...e,tabs:i,activeKey:r,previewKey:r}}))}function ta(e,t){let n=e=>e.kind===`leaf`?e.previewKey===t?{...e,previewKey:null}:e:{...e,children:e.children.map(n)};return n(e)}function na(e,t,n){let r=e=>e.kind===`leaf`?{...e,tabs:e.tabs.map(e=>e.type===`editor`&&Y(e)===t?{...e,tab:{...e.tab,view:n}}:e)}:{...e,children:e.children.map(r)};return r(e)}function ra(e,t,n){return Gi(e,t,e=>e.tabs.some(e=>Y(e)===n)?{...e,activeKey:n}:e)}function ia(e,t,n){function r(e){return e.kind===`leaf`?e:e.id===t&&n.length===e.children.length?{...e,children:e.children.map(r),sizes:[...n]}:{...e,children:e.children.map(r)}}return r(e)}function aa(e,t){let n=e=>e.kind===`leaf`?{...e,tabs:e.tabs.filter(t)}:{...e,children:e.children.map(n)};return Wi(n(e))}function oa(e){let t=e.editor_tabs.map(e=>({type:`editor`,tab:e})),n=e.session_tabs.map(e=>({type:`terminal`,session:e})),r=e.active_editor_tab?Y({type:`editor`,tab:e.active_editor_tab}):null,i=e.active_session?`term:${e.active_session}`:null;if(t.length===0&&n.length===0)return Li([]);if(t.length===0)return Li(n,i);if(n.length===0)return Li(t,r);let a=e.layout,o=typeof a.editor==`number`?a.editor:40,s=typeof a.session==`number`?a.session:60;return Wi(Ri(`col`,[Li(t,r),Li(n,i)],[o,s]))}var sa=(0,K.createContext)(null);function ca({tree:e,onOpenFile:t,children:n}){let r=(0,K.useRef)(null),i=(0,K.useRef)(new Map).current,[a,o]=(0,K.useState)(()=>new Set),s=(0,K.useCallback)((e,t)=>{o(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),c=(0,K.useMemo)(()=>{let t=new Set;for(let n of Vi(e))for(let e of n.tabs)e.type===`terminal`&&t.add(e.session);return[...t]},[e]),l=e=>{let t=`term:${e}`,n=i.get(t);return n||(n=document.createElement(`div`),n.className=`size-full`,i.set(t,n)),n};(0,K.useEffect)(()=>{let e=new Set(c.map(e=>`term:${e}`));for(let e of c){let t=i.get(`term:${e}`);t&&!t.parentElement&&r.current?.appendChild(t)}for(let[t,n]of[...i])e.has(t)||(n.remove(),i.delete(t))},[c,i]);let u=(0,K.useMemo)(()=>({parkingRef:r,containers:i,setAdopted:s}),[i,s]);return(0,G.jsxs)(sa.Provider,{value:u,children:[(0,G.jsx)(`div`,{ref:r,className:`hidden`,"aria-hidden":!0}),c.map(e=>(0,Ni.createPortal)((0,G.jsx)(je,{stream:e,paused:!a.has(`term:${e}`),onOpenFile:(n,r,i)=>t(e,n,r,i)}),l(e),e)),n]})}function la(e){let t=(0,K.useContext)(sa),n=(0,K.useRef)(null);return(0,K.useEffect)(()=>{let r=n.current;if(!t||!e||!r)return;let i=t.containers.get(e);return i&&(r.appendChild(i),t.setAdopted(e,!0)),()=>{let n=t.parkingRef.current;i&&n&&i.parentElement===r&&n.appendChild(i),i&&t.setAdopted(e,!1)}},[t,e]),n}function ua(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`number`)return;n[r]=t}return n}var da={added:{letter:`A`,label:`added`,colourClass:`text-running`},modified:{letter:`M`,label:`modified`,colourClass:`text-fg-secondary`},deleted:{letter:`D`,label:`deleted`,colourClass:`text-interrupted`},renamed:{letter:`R`,label:`renamed`,colourClass:`text-waiting`}};function fa(e){return da[e]}var pa=[`modified`,`added`,`deleted`,`renamed`];function ma(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return pa.filter(e=>t.has(e)).map(e=>`${t.get(e)} ${da[e].label}`).join(` · `)}var ha=[`var(--accent)`,`var(--status-running)`,`var(--status-waiting)`,`var(--ansi-magenta)`,`var(--ansi-cyan)`,`var(--status-interrupted)`];function ga(e){return ha[e%ha.length]}function _a(e){let t=[],n=0,r=0,i=()=>{let e=t.indexOf(null);return e===-1?t.length:e},a=()=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];r&&e.push({col:n,sha:r.sha,colour:ga(r.colourIdx)})}return e},o=[],s=[];for(let c of e){let e=c.parents??[],l=[];for(let e=0;e<t.length;e++)t[e]?.sha===c.sha&&l.push(e);let u,d;l.length>0?(u=l[0],d=t[u].colourIdx):(u=i(),d=n++);let f=ga(d);for(let e of l)t[e]=null;for(;t.length<=u;)t.push(null);let p=[];if(e.length>0){t[u]={sha:e[0],colourIdx:d},p.push(u);for(let r=1;r<e.length;r++){let a=e[r],o=t.findIndex(e=>e?.sha===a);if(o===-1){for(o=i();t.length<=o;)t.push(null);t[o]={sha:a,colourIdx:n++}}p.push(o)}}else t[u]=null;let m=a();o.push({sha:c.sha,col:u,colour:f,above:s,below:m,created:p}),s=m,r=Math.max(r,t.length)}return{rows:o,laneCount:r}}var va=7,ya=14,ba=4,xa=1.5,Sa=40,Ca=22;function wa(e){return e*ya+ya/2}function Ta(e,t,n,r){if(e===n)return`M ${e} ${t} L ${n} ${r}`;let i=(t+r)/2;return`M ${e} ${t} C ${e} ${i}, ${n} ${i}, ${n} ${r}`}function Ea({row:e,width:t}){let n=Sa,r=n/2,i=wa(e.col),a=new Set(e.created),o=[];for(let t of e.above){let n=wa(t.col);t.sha===e.sha?o.push({d:Ta(n,0,i,r),colour:t.colour}):o.push({d:Ta(n,0,n,r),colour:t.colour})}for(let t of e.below){let e=wa(t.col);a.has(t.col)?o.push({d:Ta(i,r,e,n),colour:t.colour}):o.push({d:Ta(e,r,e,n),colour:t.colour})}return(0,G.jsxs)(`svg`,{width:t,height:n,className:`shrink-0`,"aria-hidden":!0,children:[o.map((e,t)=>(0,G.jsx)(`path`,{d:e.d,fill:`none`,stroke:e.colour,strokeWidth:xa},t)),(0,G.jsx)(`circle`,{cx:i,cy:r,r:ba,fill:`var(--bg-surface)`,stroke:e.colour,strokeWidth:xa})]})}function Da({lanes:e,width:t}){return(0,G.jsx)(`svg`,{width:t,height:Ca,className:`shrink-0`,"aria-hidden":!0,children:e.map(e=>{let t=wa(e.col);return(0,G.jsx)(`path`,{d:`M ${t} 0 L ${t} ${Ca}`,fill:`none`,stroke:e.colour,strokeWidth:xa},e.col)})})}function Oa({session:e,sha:t,lanes:n,gutterW:r,onOpen:i}){let a=u(e,t),o=e=>(0,G.jsxs)(`div`,{className:`flex items-center`,style:{height:Ca},children:[(0,G.jsx)(Da,{lanes:n,width:r}),(0,G.jsx)(`span`,{className:`px-2 text-2xs text-fg-muted`,children:e})]});return a.isPending?o(`…`):a.error?o(a.error instanceof Error?a.error.message:`Failed to load commit`):a.data.files.length===0?o(`No file changes.`):(0,G.jsx)(G.Fragment,{children:a.data.files.map(e=>{let a=fa(e.status),o=e.status===`renamed`&&e.old_path?`${e.old_path} → ${e.path}`:e.path;return(0,G.jsxs)(`button`,{type:`button`,title:o,onClick:()=>i(e.path,t),className:`flex w-full items-center text-left transition-colors hover:bg-elevated`,style:{height:Ca},children:[(0,G.jsx)(Da,{lanes:n,width:r}),(0,G.jsx)(`span`,{className:V(`mr-1.5 w-3 shrink-0 text-center font-mono text-xs`,a.colourClass),children:a.letter}),(0,G.jsx)(`span`,{className:`truncate pr-3 font-mono text-2xs text-fg`,children:o})]},`${e.status}:${e.old_path??``}:${e.path}`)})})}function ka({session:e,onOpenCommitFile:t}){let n=o(e),[r,i]=(0,K.useState)(null),a=(0,K.useMemo)(()=>n.data?.pages.flatMap(e=>e.commits)??[],[n.data]),s=(0,K.useMemo)(()=>_a(a),[a]),c=Math.max(1,s.laneCount)*ya+ya/2;return n.isPending?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading history…`}):n.error?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load history`}):a.length===0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No commits yet.`}):(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[s.rows.map((n,o)=>{let s=a[o],l=r===n.sha;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(l?null:n.sha),className:V(`flex w-full items-center text-left transition-colors hover:bg-elevated`,l&&`bg-selection`),style:{height:Sa},children:[(0,G.jsx)(Ea,{row:n,width:c}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 pr-3`,children:[(0,G.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-2xs text-fg-muted`,children:n.sha.slice(0,va)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg`,children:s.subject})]}),(0,G.jsxs)(`span`,{className:`truncate text-2xs text-fg-muted`,children:[s.author_name,` ·`,` `,(0,G.jsx)(`span`,{className:`tabular-nums`,children:f(s.authored_at)})]})]})]}),l&&(0,G.jsx)(Oa,{session:e,sha:n.sha,lanes:n.below,gutterW:c,onOpen:t})]},n.sha)}),n.hasNextPage&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void n.fetchNextPage(),disabled:n.isFetchingNextPage,className:`px-3 py-2 text-left font-mono text-xs text-fg-muted transition-colors hover:bg-elevated`,children:n.isFetchingNextPage?`Loading…`:`Show more`})]})}function Aa(){return{dirs:new Map,files:[]}}function ja(e){return e.path}function Ma(e,t){let n=[];for(let[r,i]of e.dirs){let e=t?`${t}/${r}`:r,a={type:`dir`,name:r,path:e,children:Ma(i,e)};for(;a.children.length===1&&a.children[0].type===`dir`;){let e=a.children[0];a={type:`dir`,name:`${a.name}/${e.name}`,path:e.path,children:e.children}}n.push(a)}n.sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}));let r=[...e.files].sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}));return[...n,...r]}function Na(e){let t=Aa();for(let n of e){let e=ja(n),r=e.split(`/`),i=r.pop(),a=t;for(let e of r){let t=a.dirs.get(e);t||(t=Aa(),a.dirs.set(e,t)),a=t}a.files.push({type:`file`,name:i,path:e,entry:n})}return Ma(t,``)}function Pa(e){return e.map(e=>({type:`file`,name:ja(e).split(`/`).pop()??ja(e),path:ja(e),entry:e})).sort((e,t)=>e.path.localeCompare(t.path,void 0,{sensitivity:`base`}))}function Fa({name:e,fullPath:t,status:n,depth:r,active:i,onOpen:a}){let o=fa(n);return(0,G.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:V(`flex w-full items-center gap-1.5 py-1 pr-3 text-left transition-colors hover:bg-elevated`,i&&`bg-selection`),style:{paddingLeft:8+r*12},children:[(0,G.jsx)(`span`,{className:V(`w-3 shrink-0 text-center font-mono text-xs`,o.colourClass),children:o.letter}),(0,G.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e})]})}function Ia({nodes:e,depth:t,activePath:n,onOpen:r}){let[i,a]=(0,K.useState)(new Set);return(0,G.jsx)(G.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,G.jsx)(Fa,{name:e.name,fullPath:e.path,status:e.entry.status,depth:t,active:n===e.path,onOpen:r},e.path);let o=i.has(e.path);return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),className:`flex w-full items-center gap-1 py-1 pr-3 text-left transition-colors hover:bg-elevated`,style:{paddingLeft:8+t*12},children:[o?(0,G.jsx)(ht,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,G.jsx)(pt,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,G.jsx)(`span`,{className:`truncate font-mono text-xs text-fg-secondary`,children:e.name})]}),!o&&(0,G.jsx)(Ia,{nodes:e.children,depth:t+1,activePath:n,onOpen:r})]},e.path)})})}function La({session:e,activePath:t,onOpen:n}){let[r,i]=(0,K.useState)(!1),a=S(e,{against:`head`}),o=a.data?.entries??[],s=(0,K.useMemo)(()=>r?null:Na(o),[r,o]),c=(0,K.useMemo)(()=>r?Pa(o):null,[r,o]);return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 px-3`,children:[(0,G.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Uncommitted`}),o.length>0&&(0,G.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-muted`,children:ma(o)}),(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":!r,onClick:()=>i(e=>!e),className:`ml-auto rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[r?(0,G.jsx)(vn,{className:`size-3.5`}):(0,G.jsx)(mn,{className:`size-3.5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:r?`Show as tree`:`Show as flat list`})]})}),(0,G.jsx)(_t,{children:r?`Show as tree`:`Show as flat list`})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:a.isPending?(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`Loading changes…`}):a.error?(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load changes`}):o.length===0?(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`No uncommitted changes.`}):r?c.map(e=>(0,G.jsx)(Fa,{name:e.path,fullPath:e.path,status:e.entry.status,depth:0,active:t===e.path,onOpen:n},e.path)):(0,G.jsx)(Ia,{nodes:s,depth:0,activePath:t,onOpen:n})})]})}function Ra({session:e,activeDiffPath:t,onOpenDiff:n,onOpenCommitFile:r}){return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsx)(`section`,{className:`flex max-h-[45%] min-h-0 flex-col`,children:(0,G.jsx)(La,{session:e,activePath:t,onOpen:n})}),(0,G.jsx)(`div`,{className:`h-px shrink-0 bg-border`}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsx)(`div`,{className:`flex h-7 shrink-0 items-center px-3`,children:(0,G.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`History`})}),(0,G.jsx)(ka,{session:e,onOpenCommitFile:r})]})]})}async function za(e){let t=e.createReader(),n=[];for(;;){let e=await new Promise((e,n)=>t.readEntries(e,n));if(e.length===0)return n;n.push(...e)}}function Ba(e){return new Promise((t,n)=>e.file(t,n))}async function Va(e,t,n){if(e.isFile){let r=await Ba(e);n.push(t?new File([r],`${t}/${e.name}`,{type:r.type,lastModified:r.lastModified}):r)}else if(e.isDirectory){let r=await za(e),i=t?`${t}/${e.name}`:e.name;for(let e of r)await Va(e,i,n)}}function Ha(e,t,n){let r=Array.from(e??[]).map(e=>({entry:e.webkitGetAsEntry?.()??null,file:e.kind===`file`?e.getAsFile():null})),i=Array.from(t);return(async()=>{if(r.every(({entry:e,file:t})=>e===null&&t===null))return i;if(!n)return r.some(({entry:e})=>e?.isDirectory)&&D.error(`This daemon can't take folders — update it, or zip them first`),r.filter(({entry:e})=>e?.isDirectory!==!0).map(({file:e})=>e).filter(e=>e!==null);let e=[];for(let{entry:t,file:n}of r)t?.isDirectory?await Va(t,``,e):n&&e.push(n);return e})()}var Ua={untracked:{letter:`U`,colourClass:`text-running`},added:{letter:`A`,colourClass:`text-running`},modified:{letter:`M`,colourClass:`text-waiting`},renamed:{letter:`R`,colourClass:`text-waiting`},deleted:{letter:`D`,colourClass:`text-interrupted`},conflicted:{letter:`C`,colourClass:`text-interrupted`},ignored:{letter:``,colourClass:`text-fg-muted`}};function Wa(e){return Ua[e]}function Ga(e){let t=new Map;for(let n of e)t.set(n.path,n.status);return t}var Ka={conflicted:0,modified:1,renamed:2,deleted:3,added:4,untracked:5,ignored:6};function qa(e,t){let n=t===``?``:`${t}/`,r=null;for(let[t,i]of e)n!==``&&!t.startsWith(n)||i!==`ignored`&&(r===null||Ka[i]<Ka[r])&&(r=i);return r}function Ja(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Ya(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Xa(e,t){return e===``?t:`${e}/${t}`}function Za(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=Xa(i,e.name);n.push({path:o,name:e.name,type:e.type,depth:a,parentDir:i}),e.type===`dir`&&t.has(o)&&r(o,a+1)}};return r(``,0),n}function Qa(e,t,n){let r=e.findIndex(e=>e.path===t),i=e.findIndex(e=>e.path===n);if(r===-1||i===-1)return n?[n]:[];let[a,o]=r<=i?[r,i]:[i,r];return e.slice(a,o+1).map(e=>e.path)}var $a=(e,t)=>e instanceof Error?e.message:t;function eo(e){let t=i(),n=(0,K.useCallback)(()=>{t.invalidateQueries({queryKey:[`wt-tree`,e]}),t.invalidateQueries({queryKey:[`wt-git-status`,e]})},[t,e]);return(0,K.useMemo)(()=>({async create(t,r,i){try{let a=await c(e,Xa(t,r),i);return n(),a.path}catch(e){return D.error($a(e,`Couldn't create ${r}`)),null}},async rename(t,r){let i=Xa(t.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):``,r);try{let r=await p(e,t,i);return n(),r.path}catch(e){return D.error($a(e,`Couldn't rename ${Ja(t)}`)),null}},async move(t,r){try{let i=await p(e,t,Xa(r,Ja(t)));return n(),i.path}catch(e){return D.error($a(e,`Couldn't move ${Ja(t)}`)),null}},async remove(t){let r=await Promise.allSettled(t.map(t=>l(e,t)));n();let i=r.filter(e=>e.status===`rejected`).length;i>0?D.error(`Couldn't delete ${i} item${i>1?`s`:``}`):D.success(t.length===1?`Deleted ${Ja(t[0])}`:`Deleted ${t.length} items`)},async paste(t,r){let i=t.mode===`cut`?p:y,a=await Promise.allSettled(t.paths.map(t=>i(e,t,Xa(r,Ja(t)))));n();let o=a.filter(e=>e.status===`rejected`).length;o>0&&D.error(`Couldn't paste ${o} item${o>1?`s`:``}`)}}),[e,n])}function to(e,t,n){return n&&n.type!==`dir`||(e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``)===t?!1:t===``||!`${t}/`.startsWith(`${e}/`)}var no=(0,K.createContext)(null);function ro(){let e=(0,K.useContext)(no);if(!e)throw Error(`explorer components must render inside <ExplorerProvider>`);return e}function io(){return(0,K.useContext)(no)}function ao({session:e,onOpenFile:t,activePath:n,children:r}){let a=e.id,o=i(),s=eo(a),c=(0,K.useCallback)((e,t)=>{t.length!==0&&d(a,e,t).then(()=>{o.invalidateQueries({queryKey:[`wt-tree`,a,e]}),o.invalidateQueries({queryKey:[`wt-git-status`,a]}),D.success(t.length===1?`Uploaded ${t[0].name}`:`Uploaded ${t.length} files`)}).catch(e=>D.error(e instanceof Error?e.message:`Upload failed`))},[a,o]),l=ce().data?.protocol,u=!l||l.major>9||l.major===9&&l.minor>=2,f=(0,K.useCallback)((e,t,n)=>{Ha(t,n,u).then(t=>c(e,t)).catch(e=>D.error(e instanceof Error?e.message:`Couldn't read the dropped folder`))},[c,u]),[p,m]=(0,K.useState)(new Set),[g,_]=(0,K.useState)(new Set),[v,y]=(0,K.useState)(null),[b,S]=(0,K.useState)(null),[C,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(null),[ee,O]=(0,K.useState)(null),k=(0,K.useRef)(null),te=x(a),A=(0,K.useMemo)(()=>Ga(te.data?.entries??[]),[te.data]),[j,ne]=(0,K.useState)(0);(0,K.useEffect)(()=>o.getQueryCache().subscribe(e=>{let t=e.query.queryKey;Array.isArray(t)&&t[0]===`wt-tree`&&t[1]===a&&ne(e=>e+1)}),[o,a]);let re=(0,K.useMemo)(()=>Za(e=>o.getQueryData([`wt-tree`,a,e]),p),[o,a,p,j]),M=(0,K.useCallback)(e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),N=(0,K.useCallback)(e=>{m(t=>t.has(e)?t:new Set(t).add(e))},[]),P=(0,K.useCallback)(()=>m(new Set),[]),ie=(0,K.useCallback)((e,n)=>{if(y(e.path),n.metaKey||n.ctrlKey){_(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),k.current=e.path;return}if(n.shiftKey&&k.current){_(new Set(Qa(re,k.current,e.path)));return}_(new Set([e.path])),k.current=e.path,e.type===`dir`?M(e.path):t?.(a,e.path)},[re,M,t,a]),F=(0,K.useCallback)(e=>{e.type!==`dir`&&t?.(a,e.path,{preview:!1})},[t,a]),ae=(0,K.useCallback)(e=>{_(new Set([e])),y(e),k.current=e},[]),oe=(0,K.useCallback)(e=>S({paths:e,mode:`cut`}),[]),se=(0,K.useCallback)(e=>S({paths:e,mode:`copy`}),[]),I=(0,K.useCallback)(e=>{b&&s.paste(b,e).then(()=>{b.mode===`cut`&&S(null)})},[b,s]),le=(0,K.useCallback)(e=>w({mode:`rename`,path:e}),[]),ue=(0,K.useCallback)((e,t)=>{e!==``&&N(e),w({mode:`create`,parentDir:e,kind:t})},[N]),de=(0,K.useCallback)(()=>w(null),[]),fe=(0,K.useCallback)(e=>{let n=e.trim(),r=C;if(w(null),!(!r||n===``))if(r.mode===`rename`){if(n===Ja(r.path))return;s.rename(r.path,n)}else s.create(r.parentDir,n,r.kind).then(e=>{e&&r.kind===`file`&&t?.(a,e)})},[C,s,t,a]),L=(0,K.useCallback)(e=>{e.length>0&&O(e)},[]),pe=(0,K.useCallback)(()=>{let e=ee;O(null),e&&s.remove(e)},[ee,s]),R=(0,K.useCallback)(()=>O(null),[]),me=(0,K.useCallback)((t,n)=>{let r=n?t:Xa(e.worktree_path,t);navigator.clipboard.writeText(r),D.success(n?`Relative path copied`:`Path copied`)},[e.worktree_path]),he=(0,K.useCallback)(e=>{h(a,e).catch(e=>D.error(e instanceof Error?e.message:`Download failed`))},[a]),ge=(0,K.useCallback)(()=>{o.invalidateQueries({queryKey:[`wt-tree`,a]}),o.invalidateQueries({queryKey:[`wt-git-status`,a]})},[o,a]),_e=(0,K.useCallback)((e,t)=>{to(t,e)&&s.move(t,e)},[s]),z=(0,K.useCallback)(()=>v&&g.has(v)?[...g]:v?[v]:[...g],[v,g]),ve=(0,K.useRef)({buffer:``,at:0}),ye=(0,K.useCallback)(e=>{if(C)return;let n=re;if(n.length===0)return;let r=v?n.findIndex(e=>e.path===v):-1,i=(e,t)=>{let r=n[Math.max(0,Math.min(n.length-1,e))];r&&(y(r.path),t&&k.current?_(new Set(Qa(n,k.current,r.path))):(_(new Set([r.path])),k.current=r.path))},o=r>=0?n[r]:void 0,s=e.metaKey||e.ctrlKey;switch(e.key){case`ArrowDown`:e.preventDefault(),i(r+1,e.shiftKey);return;case`ArrowUp`:e.preventDefault(),i(r<=0?0:r-1,e.shiftKey);return;case`ArrowRight`:e.preventDefault(),o?.type===`dir`&&!p.has(o.path)?N(o.path):o?.type===`dir`&&i(r+1,!1);return;case`ArrowLeft`:if(e.preventDefault(),o?.type===`dir`&&p.has(o.path))M(o.path);else if(o){let e=n.findIndex(e=>e.path===o.parentDir);e>=0&&i(e,!1)}return;case`Enter`:case` `:if(e.preventDefault(),!o)return;o.type===`dir`?M(o.path):t?.(a,o.path);return;case`F2`:e.preventDefault(),o&&le(o.path);return;case`Delete`:e.preventDefault(),L(z());return;case`Backspace`:s&&(e.preventDefault(),L(z()));return}if(s&&(e.key===`c`||e.key===`C`)){e.preventDefault();let t=z();e.altKey?me(t[0]??``,e.shiftKey):se(t);return}if(s&&(e.key===`x`||e.key===`X`)){e.preventDefault(),oe(z());return}if(s&&(e.key===`v`||e.key===`V`)){e.preventDefault();let t=o?o.type===`dir`?o.path:o.parentDir:``;I(t);return}if(!s&&!e.altKey&&e.key.length===1&&/\S/.test(e.key)){let t=Date.now(),a=ve.current;a.buffer=t-a.at>700?e.key:a.buffer+e.key,a.at=t;let o=a.buffer.toLowerCase(),s=r+1;for(let e=0;e<n.length;e++){let t=n[(s+e)%n.length];if(t.name.toLowerCase().startsWith(o)){i(n.findIndex(e=>e.path===t.path),!1);break}}}},[C,re,v,p,N,M,t,a,le,L,z,se,oe,I,me]),be={sid:a,worktreePath:e.worktree_path,onOpenFile:t,activePath:n,expanded:p,toggle:M,collapseAll:P,statusMap:A,visibleRows:re,selection:g,focusedPath:v,onRowClick:ie,onRowDoubleClick:F,selectOnly:ae,clipboard:b,cut:oe,copy:se,paste:I,editing:C,beginRename:le,beginCreate:ue,cancelEdit:de,commitEdit:fe,requestDelete:L,copyPathToClipboard:me,download:he,refresh:ge,onUpload:c,onDropUpload:f,dropTarget:T,setDropTarget:E,onInternalDrop:_e,handleKeyDown:ye,pendingDelete:ee,confirmDelete:pe,cancelDelete:R};return(0,G.jsx)(no.Provider,{value:be,children:r})}var oo=`application/x-puddle-tab`;function so(e){return JSON.stringify(e)}function co(e){try{return w.parse(JSON.parse(e))}catch{return null}}function lo(e){return e.includes(oo)}var uo={"package.json":Qt,"package-lock.json":rn,"pnpm-lock.yaml":rn,"yarn.lock":rn,"pnpm-workspace.yaml":$t,dockerfile:W,".gitignore":$t,".gitattributes":$t,"readme.md":ln,license:ln,licence:ln},fo={ts:W,tsx:W,mts:W,cts:W,js:W,jsx:W,mjs:W,cjs:W,py:W,rs:W,go:W,rb:W,php:W,java:W,kt:W,c:W,h:W,cpp:W,hpp:W,cc:W,html:W,htm:W,xml:W,vue:W,sql:W,json:Qt,jsonc:Qt,yml:$t,yaml:$t,toml:$t,ini:$t,cfg:$t,conf:$t,env:nn,lock:rn,csv:sn,tsv:sn,xlsx:sn,xls:sn,md:ln,mdx:ln,markdown:ln,txt:ln,rtf:ln,log:ln,pdf:ln,css:un,scss:un,sass:un,less:un,sh:cn,bash:cn,zsh:cn,fish:cn,svg:tn,png:tn,jpg:tn,jpeg:tn,gif:tn,webp:tn,bmp:tn,ico:tn,avif:tn,mp4:an,mov:an,webm:an,mkv:an,avi:an,mp3:en,wav:en,flac:en,ogg:en,m4a:en,zip:Zt,tar:Zt,gz:Zt,tgz:Zt,rar:Zt,"7z":Zt};function po(e){let t=e.toLowerCase(),n=uo[t];if(n)return{Icon:n,generic:!1};let r=t.lastIndexOf(`.`);if(r>0){let e=fo[t.slice(r+1)];if(e)return{Icon:e,generic:!1}}return{Icon:dn,generic:!0}}function mo({name:e,dimmed:t}){let{Icon:n,generic:r}=po(e);return(0,G.jsx)(n,{className:V(`size-3.5 shrink-0`,t||r?`text-fg-muted`:`text-fg`)})}var ho=14,go=`application/x-puddle-path`;function _o({children:e}){return(0,G.jsx)(`span`,{className:`ml-auto pl-6 text-2xs text-fg-muted tabular-nums`,children:e})}function vo({depth:e,initial:t,icon:n,onCommit:r,onCancel:i}){let a=(0,K.useRef)(null),o=(0,K.useRef)(!1);(0,K.useEffect)(()=>{let e=a.current;if(!e)return;let n=()=>{e.focus();let n=t.lastIndexOf(`.`);e.setSelectionRange(0,n>0?n:t.length)};n();let r=requestAnimationFrame(()=>{document.activeElement!==e&&n()});return()=>cancelAnimationFrame(r)},[t]);let s=()=>{o.current||(o.current=!0,r(a.current?.value??``))};return(0,G.jsxs)(`div`,{className:`flex h-6 items-center gap-1 pr-2`,style:{paddingLeft:e*ho+8},children:[(0,G.jsx)(`span`,{className:`size-3.5 shrink-0`}),n,(0,G.jsx)(`input`,{ref:a,defaultValue:t,spellCheck:!1,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?s():e.key===`Escape`&&(o.current=!0,i())},onBlur:s,className:`min-w-0 flex-1 bg-surface font-mono text-sm text-fg outline-none`})]})}function yo({path:e,entry:t,depth:n}){let r=ro(),i=t.type===`dir`,a=i&&r.expanded.has(e),o=i&&r.dropTarget===e,s=!i&&e===r.activePath,c=r.selection.has(e),l=r.clipboard?.mode===`cut`&&r.clipboard.paths.includes(e),u={path:e,name:t.name,type:t.type,depth:n,parentDir:Ya(e)},d=r.statusMap.get(e),f=i?qa(r.statusMap,e):null,p=d?Wa(d):f?Wa(f):null,m=p?p.colourClass:t.name.startsWith(`.`)?`text-fg-muted`:`text-fg`,h=c&&r.selection.size>1?[...r.selection]:[e],g=i?e:Ya(e),_=r.clipboard!==null;return r.editing?.mode===`rename`&&r.editing.path===e?(0,G.jsx)(vo,{depth:n,initial:t.name,icon:i?(0,G.jsx)(fn,{className:`size-3.5 shrink-0 text-fg`}):(0,G.jsx)(mo,{name:t.name}),onCommit:r.commitEdit,onCancel:r.cancelEdit}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(nt,{children:[(0,G.jsx)(Ue,{asChild:!0,children:(0,G.jsxs)(`div`,{role:`treeitem`,"data-path":e,"aria-expanded":i?a:void 0,"aria-selected":c,tabIndex:-1,draggable:!0,onClick:e=>{e.currentTarget.closest(`[data-explorer-root]`)?.focus(),r.onRowClick(u,e)},onDoubleClick:()=>r.onRowDoubleClick(u),onContextMenu:()=>{c||r.selectOnly(e)},onDragStart:t=>{t.dataTransfer.setData(go,e),i||t.dataTransfer.setData(oo,so({type:`editor`,tab:{kind:`file`,session:r.sid,path:e}})),t.dataTransfer.effectAllowed=`copyMove`},onDragOver:t=>{i&&(t.preventDefault(),t.stopPropagation(),r.setDropTarget(e))},onDragLeave:e=>{i&&e.currentTarget===e.target&&r.setDropTarget(null)},onDrop:t=>{if(!i)return;t.preventDefault(),t.stopPropagation(),r.setDropTarget(null);let n=t.dataTransfer.getData(go);n?r.onInternalDrop(e,n):r.onDropUpload(e,t.dataTransfer.items,t.dataTransfer.files)},style:{paddingLeft:n*ho+8},className:V(`flex h-6 cursor-pointer items-center gap-1 pr-2 text-sm transition-colors hover:bg-elevated`,c?`bg-selection`:s&&`bg-elevated`,o&&`bg-selection`,l&&`opacity-50`),children:[i?(0,G.jsx)(ht,{className:V(`size-3.5 shrink-0 text-fg-gold transition-transform duration-150`,a&&`rotate-90`)}):(0,G.jsx)(`span`,{className:`size-3.5 shrink-0`}),t.symlink||t.type===`symlink`?(0,G.jsx)(_n,{className:`size-3.5 shrink-0 text-fg`}):i?a?(0,G.jsx)(Dt,{className:V(`size-3.5 shrink-0`,f?p?.colourClass:`text-fg`)}):(0,G.jsx)(fn,{className:V(`size-3.5 shrink-0`,f?p?.colourClass:`text-fg`)}):(0,G.jsx)(mo,{name:t.name,dimmed:d===`ignored`}),(0,G.jsx)(`span`,{className:V(`min-w-0 flex-1 truncate font-mono`,m),children:t.name}),d&&p&&p.letter&&(0,G.jsx)(`span`,{className:V(`shrink-0 font-mono text-2xs`,p.colourClass),children:p.letter})]})}),(0,G.jsxs)(Qe,{onCloseAutoFocus:e=>{r.editing&&e.preventDefault()},children:[i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(U,{onSelect:()=>r.beginCreate(e,`file`),children:`New File…`}),(0,G.jsx)(U,{onSelect:()=>r.beginCreate(e,`dir`),children:`New Folder…`}),(0,G.jsx)(Je,{})]}),(0,G.jsxs)(U,{onSelect:()=>r.cut(h),children:[`Cut `,(0,G.jsx)(_o,{children:`⌘X`})]}),(0,G.jsxs)(U,{onSelect:()=>r.copy(h),children:[`Copy `,(0,G.jsx)(_o,{children:`⌘C`})]}),(0,G.jsxs)(U,{disabled:!_,onSelect:()=>r.paste(g),children:[`Paste `,(0,G.jsx)(_o,{children:`⌘V`})]}),(0,G.jsx)(Je,{}),(0,G.jsxs)(U,{onSelect:()=>r.copyPathToClipboard(e,!1),children:[`Copy Path `,(0,G.jsx)(_o,{children:`⌥⌘C`})]}),(0,G.jsxs)(U,{onSelect:()=>r.copyPathToClipboard(e,!0),children:[`Copy Relative Path `,(0,G.jsx)(_o,{children:`⌥⇧⌘C`})]}),(0,G.jsx)(Je,{}),(0,G.jsxs)(U,{onSelect:()=>r.beginRename(e),children:[`Rename… `,(0,G.jsx)(_o,{children:`F2`})]}),(0,G.jsxs)(U,{onSelect:()=>r.requestDelete(h),children:[`Delete `,(0,G.jsx)(_o,{children:`⌘⌫`})]}),(0,G.jsx)(Je,{}),(0,G.jsx)(U,{onSelect:()=>r.download(e),children:`Download`})]})]}),i&&a&&(0,G.jsx)(bo,{sid:r.sid,path:e,depth:n+1})]})}function bo({sid:e,path:t,depth:n}){let r=ro(),i=b(e,t),a={paddingLeft:n*ho+8},o=r.editing,s=o?.mode===`create`&&o.parentDir===t?(0,G.jsx)(xo,{depth:n,kind:o.kind}):null;if(i.isLoading)return(0,G.jsxs)(G.Fragment,{children:[s,(0,G.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Loading…`})]});if(i.isError)return(0,G.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Couldn't load this folder.`});let c=i.data?.entries??[];return c.length===0&&!s?(0,G.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Empty`}):(0,G.jsxs)(G.Fragment,{children:[s,c.map(e=>(0,G.jsx)(yo,{path:Xa(t,e.name),entry:e,depth:n},e.name))]})}function xo({depth:e,kind:t}){let n=ro(),[r,i]=(0,K.useState)(``);return(0,G.jsx)(vo,{depth:e,initial:r,icon:t===`dir`?(0,G.jsx)(fn,{className:`size-3.5 shrink-0 text-fg`}):(0,G.jsx)(mo,{name:r||`file`}),onCommit:e=>{i(e),n.commitEdit(e)},onCancel:n.cancelEdit})}function So(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Co,{}),(0,G.jsx)(wo,{})]})}function Co(){let e=ro(),t=(0,K.useRef)(null);(0,K.useEffect)(()=>{!e.focusedPath||!t.current||t.current.querySelector(`[data-path="${CSS.escape(e.focusedPath)}"]`)?.scrollIntoView({block:`nearest`})},[e.focusedPath]);let n=e.clipboard!==null;return(0,G.jsxs)(nt,{children:[(0,G.jsx)(Ue,{asChild:!0,children:(0,G.jsx)(`div`,{ref:t,"data-explorer-root":!0,role:`tree`,tabIndex:0,onKeyDown:e.handleKeyDown,onPaste:t=>e.onDropUpload(``,t.clipboardData.items,t.clipboardData.files),onDragOver:t=>{t.preventDefault(),e.setDropTarget(``)},onDragLeave:t=>{t.currentTarget===t.target&&e.setDropTarget(null)},onDrop:t=>{t.preventDefault(),e.setDropTarget(null);let n=t.dataTransfer.getData(`application/x-puddle-path`);n?e.onInternalDrop(``,n):e.onDropUpload(``,t.dataTransfer.items,t.dataTransfer.files)},className:V(`h-full overflow-y-auto py-1 outline-none`,e.dropTarget===``&&`bg-selection`),children:(0,G.jsx)(bo,{sid:e.sid,path:``,depth:0})})}),(0,G.jsxs)(Qe,{onCloseAutoFocus:t=>{e.editing&&t.preventDefault()},children:[(0,G.jsx)(U,{onSelect:()=>e.beginCreate(``,`file`),children:`New File…`}),(0,G.jsx)(U,{onSelect:()=>e.beginCreate(``,`dir`),children:`New Folder…`}),(0,G.jsx)(Je,{}),(0,G.jsx)(U,{disabled:!n,onSelect:()=>e.paste(``),children:`Paste`}),(0,G.jsx)(Je,{}),(0,G.jsx)(U,{onSelect:()=>e.copyPathToClipboard(``,!1),children:`Copy Path`}),(0,G.jsx)(U,{onSelect:()=>e.download(``),children:`Download worktree`})]})]})}function wo(){let e=ro(),t=e.pendingDelete;return(0,G.jsx)(F,{open:t!==null,onOpenChange:t=>!t&&e.cancelDelete(),children:(0,G.jsxs)(N,{children:[(0,G.jsxs)(te,{children:[(0,G.jsxs)(P,{children:[`Delete `,t&&t.length===1?`“${Ja(t[0])}”`:`${t?.length??0} items`,`?`]}),(0,G.jsxs)(ie,{children:[`This permanently removes `,t&&t.length>1?`them`:`it`,` from the worktree. There is no undo.`]})]}),(0,G.jsxs)(re,{children:[(0,G.jsx)(j,{variant:`ghost`,onClick:e.cancelDelete,children:`Cancel`}),(0,G.jsx)(j,{variant:`danger`,onClick:e.confirmDelete,children:`Delete`})]})]})})}var To=/[.*+?^${}()|[\]\\]/g;function Eo(e){if(e.query.length===0)return null;try{let t=e.regex?e.query:e.query.replace(To,`\\$&`);return e.wholeWord&&(t=`\\b(?:${t})\\b`),new RegExp(t,e.caseSensitive?`g`:`gi`)}catch{return null}}function Do(e,t){if(!t)return[{text:e,hit:!1}];let n=[],r=0;t.lastIndex=0;let i;for(;(i=t.exec(e))!==null;){if(i[0].length===0){t.lastIndex++;continue}i.index>r&&n.push({text:e.slice(r,i.index),hit:!1}),n.push({text:i[0],hit:!0}),r=i.index+i[0].length}return r<e.length&&n.push({text:e.slice(r),hit:!1}),n.length>0?n:[{text:e,hit:!1}]}var Oo=240;function ko(e){let t=e.replace(/^\s+/,``);return t.length>Oo?`${t.slice(0,Oo)}…`:t}var Ao=250;function jo({active:e,label:t,onClick:n,children:r}){return(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:V(`rounded-sm p-1 transition-colors`,e?`bg-elevated text-accent`:`text-fg-muted hover:bg-elevated hover:text-fg`),children:[r,(0,G.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,G.jsx)(_t,{children:t})]})}function Mo({session:e,onOpen:t}){let[n,r]=(0,K.useState)(``),[i,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(!1);(0,K.useEffect)(()=>{let e=setTimeout(()=>o(n),Ao);return()=>clearTimeout(e)},[n]);let p={query:i,regex:s,caseSensitive:l,wholeWord:d},m=a(e,p),h=(0,K.useMemo)(()=>Eo(p),[i,s,l,d]),g=m.data,_=!!g&&(g.files.length>0||g.content.length>0);return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 px-2 py-1.5`,children:[(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Search files and contents`,spellCheck:!1,autoComplete:`off`,className:`rounded-md bg-elevated px-2 py-1 font-mono text-xs text-fg outline-none placeholder:text-fg-muted`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(jo,{active:l,label:`Match case`,onClick:()=>u(e=>!e),children:(0,G.jsx)(Gt,{className:`size-3.5`})}),(0,G.jsx)(jo,{active:d,label:`Match whole word`,onClick:()=>f(e=>!e),children:(0,G.jsx)(kn,{className:`size-3.5`})}),(0,G.jsx)(jo,{active:s,label:`Use regular expression`,onClick:()=>c(e=>!e),children:(0,G.jsx)(Tn,{className:`size-3.5`})})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:i.length===0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Search file names and contents.`}):m.isPending?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Searching…`}):m.error?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:m.error instanceof Error?m.error.message:`Search failed`}):_?(0,G.jsxs)(G.Fragment,{children:[g.files.length>0&&(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`px-3 pb-0.5 pt-1.5 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Files`}),g.files.map(e=>(0,G.jsxs)(`button`,{type:`button`,title:e,onClick:()=>t(e),className:`flex w-full items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-elevated`,children:[(0,G.jsx)(dn,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,G.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e})]},e))]}),g.content.length>0&&(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`px-3 pb-0.5 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Contents`}),g.content.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`truncate px-3 py-1 font-mono text-2xs text-fg-secondary`,title:e.path,children:e.path}),e.matches.map((n,r)=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e.path,n.line),className:`flex w-full items-baseline gap-2 py-0.5 pl-6 pr-3 text-left transition-colors hover:bg-elevated`,children:[(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-2xs tabular-nums text-fg-muted`,children:n.line}),(0,G.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-secondary`,children:Do(ko(n.text),h).map((e,t)=>e.hit?(0,G.jsx)(`span`,{className:`text-accent`,children:e.text},t):(0,G.jsx)(`span`,{children:e.text},t))})]},`${n.line}:${r}`))]},e.path))]}),g.truncated&&(0,G.jsx)(`div`,{className:`px-3 py-2 text-2xs text-fg-muted`,children:`Showing the first results — refine the query for more.`})]}):(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No results.`})})]})}function No({text:e,hoverClass:t,className:n,title:r}){let i=(0,K.useRef)(null),[a,o]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>o(Math.max(0,e.scrollWidth-e.clientWidth));t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,G.jsx)(`span`,{ref:i,title:r,className:V(`block whitespace-nowrap transition-transform duration-[900ms] ease-linear`,n,a>0&&t),style:a>0?{"--tail":`-${a}px`}:void 0,children:e})})}var Po=new Set([`starting`,`running`,`waiting_input`]),Fo=`group-hover:[transform:translateX(var(--tail))]`;function Io(e){return e.split(`/`).filter(Boolean).pop()??e}function Lo({children:e,className:t,title:n}){return(0,G.jsx)(`span`,{title:n,className:V(`shrink-0 text-2xs`,t),children:e})}function Ro({label:e,blockReason:t,onClick:n}){return(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,disabled:t!==null,onClick:n,className:V(`-my-1 rounded-sm p-1 text-fg-gold transition-colors hover:text-danger`,t===null?`hidden group-hover:inline-flex`:`hidden`),children:[(0,G.jsx)(Tt,{className:`size-3.5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:e})]})}),(0,G.jsx)(_t,{children:t?`Can't ${e.toLowerCase()} — ${t}`:e})]})}function zo({repoId:e,projectId:t,sessions:n}){let r=De(e),i=he(e,t),a=R(e,t),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),u=i.isPending||a.isPending,d=(0,K.useMemo)(()=>{let e=new Map;for(let t of n)Po.has(t.status)&&e.set(t.worktree_path,(e.get(t.worktree_path)??0)+1);return e},[n]),f=(0,K.useMemo)(()=>{let e=new Map;for(let t of r.data?.worktrees??[]){let n=t.branch??`(detached)`;(e.get(n)??e.set(n,[]).get(n)).push(t)}return[...e.entries()].sort(([,e],[,t])=>!e.some(e=>e.is_primary)-+!t.some(e=>e.is_primary)||(e[0]?.branch??``).localeCompare(t[0]?.branch??``))},[r.data]),p=(0,K.useMemo)(()=>[...r.data?.orphan_branches??[]].sort((e,t)=>e.name.localeCompare(t.name)),[r.data]);return r.isPending?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading worktrees…`}):r.error?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load worktrees`}):(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[f.length===0&&p.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktrees.`}),f.map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`group flex items-center gap-1.5 px-3 pb-0.5 pt-2 text-2xs text-fg-muted`,children:[(0,G.jsx)(gn,{className:`size-3 shrink-0 text-fg-gold`}),(0,G.jsx)(No,{text:e,className:`font-mono`,hoverClass:Fo})]}),t.map(e=>{let t=d.get(e.path)??0,n=e.is_primary?`the repository clone`:e.dirty?`uncommitted changes`:t>0?`${t} running session${t>1?`s`:``}`:null;return(0,G.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 pl-6 transition-colors hover:bg-elevated`,children:[(0,G.jsx)(No,{text:Io(e.path),title:e.path,className:`font-mono text-xs text-fg`,hoverClass:Fo}),e.is_primary&&(0,G.jsx)(Lo,{className:`text-fg-muted`,children:`clone`}),e.dirty&&(0,G.jsx)(Lo,{className:`text-waiting`,title:`Modified — uncommitted changes`,children:`M`}),t>0&&(0,G.jsx)(Lo,{className:`text-running`,title:`${t} running session${t>1?`s`:``}`,children:t}),(0,G.jsx)(Ro,{label:`Prune`,blockReason:n,onClick:()=>{l(null),s({kind:`worktree`,path:e.path,branch:e.branch})}})]},e.path)})]},`wt:${e}`)),p.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-3 pb-0.5 pt-3 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Branches without a worktree`}),p.map(e=>(0,G.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 transition-colors hover:bg-elevated`,children:[(0,G.jsx)(gn,{className:`size-3 shrink-0 text-fg-gold`}),(0,G.jsx)(No,{text:e.name,className:`font-mono text-xs text-fg`,hoverClass:Fo}),e.local_only&&(0,G.jsx)(Lo,{className:`text-waiting`,children:`local only`}),(0,G.jsx)(Ro,{label:`Delete branch`,blockReason:null,onClick:()=>{l(null),s({kind:`branch`,name:e.name,localOnly:e.local_only})}})]},`br:${e.name}`))]}),(0,G.jsx)(F,{open:o!==null,onOpenChange:e=>{e||s(null)},children:(0,G.jsxs)(N,{children:[o?.kind===`branch`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(te,{children:[(0,G.jsx)(P,{children:`Delete branch`}),(0,G.jsxs)(ie,{children:[`Delete branch `,(0,G.jsx)(`span`,{className:`font-mono`,children:o.name}),`? This removes the branch from the repository.`]})]}),o.localOnly&&(0,G.jsxs)(`p`,{className:`text-xs text-waiting`,children:[(0,G.jsx)(`span`,{className:`font-mono`,children:o.name}),` has commits on no remote — deleting it discards that work permanently.`]})]}):(0,G.jsxs)(te,{children:[(0,G.jsx)(P,{children:`Prune worktree`}),(0,G.jsxs)(ie,{children:[`Remove `,(0,G.jsx)(`span`,{className:`font-mono`,children:o?Io(o.path):``}),`? The working directory is deleted; the branch`,` `,(0,G.jsx)(`span`,{className:`font-mono`,children:o?.branch??``}),` is kept.`]})]}),c&&(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:c}),(0,G.jsxs)(re,{children:[(0,G.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>s(null),children:`Cancel`}),(0,G.jsx)(j,{type:`button`,variant:`danger`,disabled:u,onClick:()=>{if(!o)return;l(null);let e=e=>l(e.message),t=()=>s(null);o.kind===`worktree`?i.mutate(o.path,{onSuccess:t,onError:e}):a.mutate({name:o.name,confirm:!0},{onSuccess:t,onError:e})},children:o?.kind===`branch`?`Delete`:`Prune`})]})]})})]})}var Bo=`DropdownMenu`,[Vo,Ho]=O(Bo,[ze]),X=ze(),[Uo,Wo]=Vo(Bo),Go=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=X(t),l=K.useRef(null),[u,d]=k({prop:i,defaultProp:a??!1,onChange:o,caller:Bo});return(0,G.jsx)(Uo,{scope:t,triggerId:A(),triggerRef:l,contentId:A(),open:u,onOpenChange:d,onOpenToggle:K.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,G.jsx)(He,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Go.displayName=Bo;var Ko=`DropdownMenuTrigger`,qo=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Wo(Ko,n),o=X(n),s=ee(t,a.triggerRef);return(0,G.jsx)(Xe,{asChild:!0,...o,children:(0,G.jsx)(ae.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:M(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:M(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});qo.displayName=Ko;var Jo=`DropdownMenuPortal`,Yo=e=>{let{__scopeDropdownMenu:t,...n}=e,r=X(t);return(0,G.jsx)(Be,{...r,...n})};Yo.displayName=Jo;var Xo=`DropdownMenuContent`,Zo=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Wo(Xo,n),a=X(n),o=K.useRef(!1);return(0,G.jsx)(Ge,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:M(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:M(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Zo.displayName=Xo;var Qo=`DropdownMenuGroup`,$o=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(et,{...i,...r,ref:t})});$o.displayName=Qo;var es=`DropdownMenuLabel`,ts=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(Ke,{...i,...r,ref:t})});ts.displayName=es;var ns=`DropdownMenuItem`,rs=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(Ze,{...i,...r,ref:t})});rs.displayName=ns;var is=`DropdownMenuCheckboxItem`,as=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(We,{...i,...r,ref:t})});as.displayName=is;var os=`DropdownMenuRadioGroup`,ss=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(it,{...i,...r,ref:t})});ss.displayName=os;var cs=`DropdownMenuRadioItem`,ls=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(st,{...i,...r,ref:t})});ls.displayName=cs;var us=`DropdownMenuItemIndicator`,ds=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(qe,{...i,...r,ref:t})});ds.displayName=us;var fs=`DropdownMenuSeparator`,ps=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(ot,{...i,...r,ref:t})});ps.displayName=fs;var ms=`DropdownMenuArrow`,hs=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(rt,{...i,...r,ref:t})});hs.displayName=ms;var gs=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=X(t),[s,c]=k({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,G.jsx)(Re,{...o,open:s,onOpenChange:c,children:n})},_s=`DropdownMenuSubTrigger`,vs=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(at,{...i,...r,ref:t})});vs.displayName=_s;var ys=`DropdownMenuSubContent`,bs=K.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,G.jsx)(Pe,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});bs.displayName=ys;var xs=Go,Ss=qo,Cs=Yo,ws=Zo,Ts=rs,Es=ps,Ds=gs,Os=vs,ks=bs,As=xs,js=Ss,Ms=Ds;function Ns({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(Cs,{children:(0,G.jsx)(ws,{sideOffset:t,className:V(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...n})})}function Ps({className:e,...t}){return(0,G.jsx)(Ts,{className:V(Ae,Te,`[&_svg]:size-3.5`,e),...t})}function Fs({className:e,children:t,...n}){return(0,G.jsxs)(Os,{className:V(Ae,Te,`data-[state=open]:bg-action data-[state=open]:text-action-ink [&_svg]:size-3.5`,e),...n,children:[t,(0,G.jsx)(ht,{className:`ml-auto`})]})}function Is({className:e,...t}){return(0,G.jsx)(Cs,{children:(0,G.jsx)(ks,{className:V(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...t})})}function Ls({className:e,...t}){return(0,G.jsx)(Es,{className:V(`-mx-1 my-1 h-px bg-border`,e),...t})}function Rs(e,t){if(!t)return e;let n=t.endsWith(`/`)?t.slice(0,-1):t;return n===``||n===`/`?e:e===n?`~`:e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function zs({text:e,className:t}){let n=(0,K.useRef)(null);return(0,K.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[e]),(0,G.jsx)(`div`,{ref:n,className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,G.jsx)(`span`,{className:V(`inline-block whitespace-nowrap`,t),children:e})})}function Bs({sessions:e,target:t,showFileActions:n=!1,showPath:r=!1}){let{session:i,pinned:a,pin:o,unpin:s}=t,c=oe().data?.home,l=e.filter(e=>e.status!==`archived`),u=i?i.branch||Vt(i):`No worktree`,d=i?Rs(i.worktree_path,c):`No worktree`;return(0,G.jsxs)(`div`,{className:`group relative flex h-8 shrink-0 items-center px-2`,children:[(0,G.jsx)(zs,{text:r?d:u,className:`font-mono text-xs text-fg-secondary`}),(0,G.jsxs)(`div`,{className:V(`absolute inset-y-0 right-1 flex items-center gap-1 bg-surface pl-2 opacity-0 transition-opacity`,`pointer-events-none focus-within:pointer-events-auto focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`,a&&`pointer-events-auto opacity-100`),children:[n&&i&&(0,G.jsx)(Hs,{}),(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":a,disabled:!i,title:a?`Unpin — follow the active session`:`Pin the sidebar to this worktree`,onClick:()=>a?s():i&&o(i.id),className:V(`shrink-0 rounded-sm p-1 transition-colors disabled:pointer-events-none disabled:opacity-40`,a?`text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,G.jsx)(Cn,{className:V(`size-3.5`,a&&`fill-current`)}),(0,G.jsx)(`span`,{className:`sr-only`,children:a?`Unpin sidebar`:`Pin sidebar`})]}),(0,G.jsxs)(As,{children:[(0,G.jsx)(js,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,title:`Bind a different worktree`,className:`shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,G.jsx)(pt,{className:`size-3.5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Choose a worktree`})]})}),(0,G.jsx)(Ns,{align:`end`,children:l.length===0?(0,G.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-fg-muted`,children:`No sessions yet`}):l.map(e=>(0,G.jsx)(Ps,{onSelect:()=>o(e.id),children:(0,G.jsxs)(`span`,{className:`truncate font-mono`,children:[e.branch,` — `,Vt(e)]})},e.id))})]})]})]})}var Vs=[{key:`new-file`,label:`New File`,icon:on},{key:`new-folder`,label:`New Folder`,icon:pn},{key:`refresh`,label:`Refresh`,icon:bt},{key:`collapse`,label:`Collapse Folders`,icon:Kt}];function Hs(){let e=io();if(!e)return null;let t=t=>{t===`new-file`?e.beginCreate(``,`file`):t===`new-folder`?e.beginCreate(``,`dir`):t===`refresh`?e.refresh():t===`collapse`&&e.collapseAll()};return(0,G.jsx)(`div`,{className:`hidden shrink-0 items-center gap-0.5 group-hover:flex group-focus-within:flex`,children:Vs.map(({key:e,label:n,icon:r})=>(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,G.jsx)(r,{className:`size-3.5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,G.jsx)(_t,{children:n})]},e))})}var Us=[{key:`files`,label:`Files`,icon:mn},{key:`search`,label:`Search`,icon:vt},{key:`changes`,label:`Changes`,icon:gn},{key:`worktrees`,label:`Worktrees`,icon:gt}];function Ws(e){return e===`diff`||e===`history`||e===`changes`?`changes`:e===`search`?`search`:e===`worktrees`?`worktrees`:`files`}function Gs({mode:e,onExpand:t,onSelect:n}){return(0,G.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center gap-1 bg-surface py-1.5`,children:[(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center rounded-md p-1.5 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,G.jsx)(bn,{className:`size-4`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Show sidebar`})]})}),(0,G.jsx)(_t,{side:`right`,children:`Show sidebar`})]}),Us.map(({key:t,label:r,icon:i})=>(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"aria-current":e===t?`page`:void 0,onClick:()=>n(t),className:V(`flex items-center rounded-md p-1.5 transition-colors`,e===t?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,G.jsx)(i,{className:`size-4`}),(0,G.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,G.jsx)(_t,{side:`right`,children:r})]},t))]})}function Ks({mode:e,onModeChange:t,onCollapse:n,projectId:r,repoId:i,sessions:a,target:o,onOpenFile:s,activeFilePath:c,activeDiffPath:l,onOpenDiff:u,onOpenCommitFile:d,onOpenSearchFile:f}){let{session:p}=o;return(0,G.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:[Us.map(({key:n,label:r,icon:i})=>(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"aria-current":e===n?`page`:void 0,onClick:()=>t(n),className:V(`flex items-center rounded-md p-1.5 transition-colors`,e===n?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,G.jsx)(i,{className:`size-4`}),(0,G.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,G.jsx)(_t,{children:r})]},n)),(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`ml-auto flex items-center rounded-md p-1.5 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,G.jsx)(yn,{className:`size-4`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Hide sidebar`})]})}),(0,G.jsx)(_t,{children:`Hide sidebar`})]})]}),e!==`worktrees`&&e!==`files`&&(0,G.jsx)(Bs,{sessions:a,target:o,showPath:e===`search`}),e===`worktrees`&&(0,G.jsx)(zo,{repoId:i,projectId:r,sessions:a}),e===`files`&&(p?(0,G.jsxs)(ao,{session:p,onOpenFile:s,activePath:c,children:[(0,G.jsx)(Bs,{sessions:a,target:o,showFileActions:!0,showPath:!0}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(So,{})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Bs,{sessions:a,target:o}),(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})]})),e===`changes`&&(p?(0,G.jsx)(Ra,{session:p.id,activeDiffPath:l,onOpenDiff:u,onOpenCommitFile:d},p.id):(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})),e===`search`&&(p?(0,G.jsx)(Mo,{session:p.id,onOpen:f},p.id):(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to search.`}))]})}function qs({projectId:e,repoId:t,open:n,kind:r=`agent`,seedAccountId:i,onOpenChange:a,onCreated:o}){let s=r===`terminal`,c=we(),l=ve(c??void 0),u=se(c??void 0),d=ue(),f=oe(),p=pe(),[m,h]=(0,K.useState)(``),[g,_]=(0,K.useState)(``),[v,y]=(0,K.useState)(!0),[b,x]=(0,K.useState)(!0),[S,C]=(0,K.useState)(``),[w,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(!1),[ee,O]=(0,K.useState)(null),k=d.data?.find(e=>e.id===t),A=de(n?t:void 0),ne=De(n?t:void 0),M=l.data?.find(e=>String(e.id)===m),ae=u.data?.allowSkipPermissions===!0,ce=!s&&ae&&M?.skip_permissions_default===!0,I=g.trim()||k?.default_base_branch||``,le=(0,K.useMemo)(()=>(ne.data?.worktrees??[]).filter(e=>e.branch===I).map(e=>({path:e.path,is_primary:e.is_primary,label:e.is_primary?`${e.path.split(`/`).filter(Boolean).pop()??e.path} (clone)`:e.path.split(`/`).filter(Boolean).pop()??e.path})),[ne.data,I]),fe=!v&&!b,L=le.find(e=>e.is_primary)?.path??le[0]?.path??``,R=w||L,me=(0,K.useMemo)(()=>{let e=u.data?.default_account_id;return l.data?.find(e=>e.id===i)??l.data?.find(t=>typeof e==`number`&&t.id===e)??l.data?.[0]},[l.data,u.data,i]),he=m||(me?String(me.id):``);(0,K.useEffect)(()=>{n&&i!==void 0&&h(String(i))},[n,i]);let ge=(0,K.useRef)(u.data);ge.current=u.data,(0,K.useEffect)(()=>{if(n){let e=mt(s?`terminal`:`agent`,ge.current);_(e.baseBranch),y(e.separateBranch),x(e.separateWorktree),T(``)}},[n,s]);let _e=()=>{O(null),p.mutate({project_id:e,...s?{kind:`terminal`}:{account_id:Number(he)},...g.trim()?{base_branch:g.trim()}:{},separate_branch:v,...v&&S.trim()?{branch:S.trim()}:{},...v?{}:{separate_worktree:b},...fe&&R?{join_worktree:R}:{},...ce&&E?{skip_permissions:!0}:{}},{onSuccess:e=>{a(!1),C(``),D(!1),o(e)},onError:e=>O(e.message)})},z=s?`a shell`:`an agent`,ye=v?`on a new branch off ${I||`…`}, in its own directory`:fe?`on ${I||`…`}, sharing an existing directory`:`on ${I||`…`}, in its own directory`;return(0,G.jsx)(F,{open:n,onOpenChange:a,children:(0,G.jsxs)(N,{children:[(0,G.jsxs)(te,{children:[(0,G.jsx)(P,{children:s?`New terminal`:`New agent`}),(0,G.jsxs)(ie,{children:[s?`Opens`:`Spawns`,` `,z,` `,ye,`.`]})]}),(0,G.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),(s||he)&&_e()},children:[!s&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(Me,{children:`Account`}),l.data?.length===0?(0,G.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No accounts yet —`,` `,(0,G.jsx)(`button`,{type:`button`,className:`text-accent underline`,onClick:()=>yt(`accounts`),children:`add one in settings`}),`.`]}):(0,G.jsxs)(ut,{value:he,onValueChange:h,children:[(0,G.jsx)(ct,{children:(0,G.jsx)(dt,{placeholder:`pick an account`})}),(0,G.jsx)(ft,{children:l.data?.map(e=>(0,G.jsxs)(lt,{value:String(e.id),children:[(0,G.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]}),!e.logged_in&&(0,G.jsx)(`span`,{className:`ml-2 text-2xs text-waiting`,children:`not logged in`})]},e.id))})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,G.jsx)(Me,{htmlFor:`base-branch`,children:`Base branch`}),(0,G.jsx)(Oe,{id:`base-branch`,placeholder:k?.default_base_branch??`main`,value:g,onValueChange:_,hints:(A.data?.branches??[]).filter(e=>e.name.toLowerCase().includes(g.trim().toLowerCase())).slice(0,20).map(e=>({value:e.name,badge:e.name===k?.default_base_branch?`default`:e.is_session?`session: ${e.session_title??`untitled`}`:void 0})),className:`font-mono`,hintsClassName:`w-max min-w-full max-w-[36rem]`})]}),v&&(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(Me,{htmlFor:`session-branch`,children:`New branch`}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`optional`})]}),(0,G.jsx)(Ce,{id:`session-branch`,placeholder:`leave blank for auto`,value:S,onChange:e=>C(e.target.value),className:`font-mono`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(At,{id:`separate-branch`,checked:v,onCheckedChange:e=>{y(e),e&&x(!0)}}),(0,G.jsx)(Me,{htmlFor:`separate-branch`,children:`Use separate branch`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(At,{id:`separate-worktree`,checked:v?!0:b,disabled:v,onCheckedChange:x}),(0,G.jsx)(Me,{htmlFor:`separate-worktree`,className:V(v&&`text-fg-muted`),children:`Use separate directory`})]})]}),fe&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(Me,{htmlFor:`join-dir`,children:`Directory to join`}),le.length===0?(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No existing directory on `,(0,G.jsx)(`span`,{className:`font-mono`,children:I||`…`}),` — a shared one will be created for later sessions to join.`]}):(0,G.jsxs)(ut,{value:R,onValueChange:T,children:[(0,G.jsx)(ct,{id:`join-dir`,children:(0,G.jsx)(dt,{})}),(0,G.jsx)(ft,{children:le.map(e=>(0,G.jsx)(lt,{value:e.path,title:e.path,detail:(0,G.jsx)(`span`,{className:`ml-auto min-w-0 truncate font-mono text-2xs text-fg-muted`,children:Rs(e.path,f.data?.home)}),children:e.label},e.path))})]})]}),!v&&!s&&(0,G.jsxs)(`p`,{className:`text-xs text-waiting`,children:[`The `,s?`shell`:`agent`,` commits straight to`,` `,(0,G.jsx)(`span`,{className:`font-mono`,children:I||`…`}),fe?` and shares its working directory with concurrent sessions — they can trample each other’s edits.`:`.`]}),ce&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface px-3 py-2`,children:[(0,G.jsx)(At,{id:`skip-permissions`,checked:E,onCheckedChange:D}),(0,G.jsx)(Me,{htmlFor:`skip-permissions`,className:`text-waiting`,children:`Skip permission prompts for this session`})]}),ee&&(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:ee}),(0,G.jsxs)(re,{children:[(0,G.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>a(!1),children:`Cancel`}),(0,G.jsx)(j,{type:`submit`,disabled:!s&&!he||p.isPending,children:s?`Open terminal`:`Start agent`})]})]})]})})}function Js({status:e,kind:t=`agent`,stale:n=!1,className:r}){let i=`${t===`terminal`?`terminal `:``}status: ${e.replace(`_`,` `)}${n?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,G.jsx)(`span`,{className:V(`status-dot`,r),"data-status":e,"data-kind":t,"data-stale":n||void 0,role:`img`,title:n?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":i})}var Ys=[`starting`,`running`,`waiting_input`],Xs=[`exited`,`interrupted`],Zs={Item:Ps,Separator:Ls,Sub:Ms,SubTrigger:Fs,SubContent:Is},Qs={Item:U,Separator:Je,Sub:Ve,SubTrigger:tt,SubContent:$e};function $s(e,t){let n=ge(`resume`),r=ge(`kill`),i=xe(),a=ye(),o=I(),s=fe(),c=be(),l=pe(),u=It(),d=we(),f=ve(d??void 0),p=se(d??void 0),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(e.title??``),[b,x]=(0,K.useState)(null),S=(f.data??[]).filter(t=>t.agent_type===e.agent_type),C=!e.worktree_missing&&e.status!==`archived`&&S.some(t=>t.id!==e.account_id),w=p.data?.default_account_id,T=typeof w==`number`?w:null,E=(f.data??[]).filter(e=>e.logged_in),ee=T===null?E:[...E.filter(e=>e.id===T),...E.filter(e=>e.id!==T)];return{menu:{session:e,resumable:Xs.includes(e.status),live:Ys.includes(e.status),archived:e.status===`archived`,canMigrate:C,sameAgent:S,resume:()=>n.mutate(e.id,{onError:e=>D.error(e.message)}),kill:()=>r.mutate(e.id,{onError:e=>D.error(e.message)}),openClearEnv:()=>h(`clear-env`),openTerminal:()=>l.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void u(`/project/${e.project_id}/session/${e.id}`),onError:e=>D.error(e.message)}),spawnAccounts:ee,defaultAccountId:T,spawnAgent:t=>l.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void u(`/project/${e.project_id}/session/${e.id}`),onError:e=>D.error(e.message)}),openRename:()=>{y(e.title??``),_(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>D.error(e.message)}),unarchive:()=>a.mutate(e.id,{onError:e=>D.error(e.message)}),setMigrateTo:x},dialogs:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(F,{open:m===`clear-env`,onOpenChange:e=>{e||h(null)},children:(0,G.jsxs)(N,{children:[(0,G.jsxs)(te,{children:[(0,G.jsx)(P,{children:`Clear captured environment?`}),(0,G.jsx)(ie,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,G.jsxs)(re,{children:[(0,G.jsx)(j,{variant:`ghost`,onClick:()=>h(null),children:`Cancel`}),(0,G.jsx)(j,{variant:`danger`,disabled:c.isPending,onClick:()=>c.mutate(e.id,{onSuccess:e=>{h(null),D.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{h(null),D.error(e.message)}}),children:`Clear captured env`})]})]})}),(0,G.jsx)(F,{open:g,onOpenChange:_,children:(0,G.jsxs)(N,{children:[(0,G.jsxs)(te,{children:[(0,G.jsx)(P,{children:`Rename session`}),(0,G.jsx)(ie,{children:`Leave it empty to use the agent’s own session name.`})]}),(0,G.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:t=>{t.preventDefault(),o.mutate({sessionId:e.id,title:v.trim()},{onSuccess:()=>_(!1),onError:e=>D.error(e.message)})},children:[(0,G.jsx)(Ce,{value:v,onChange:e=>y(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,G.jsxs)(re,{children:[(0,G.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,G.jsx)(j,{type:`submit`,disabled:o.isPending,children:`Rename`})]})]})]})}),(0,G.jsx)(F,{open:b!==null,onOpenChange:e=>!e&&x(null),children:(0,G.jsxs)(N,{children:[(0,G.jsxs)(te,{children:[(0,G.jsxs)(P,{children:[`Move this session to `,b?.label,`?`]}),(0,G.jsx)(ie,{children:`The conversation continues under that account’s credentials. If the session is running it is stopped first, then resumed on the new account.`})]}),(0,G.jsxs)(re,{children:[(0,G.jsx)(j,{variant:`ghost`,onClick:()=>x(null),children:`Cancel`}),(0,G.jsx)(j,{disabled:s.isPending,onClick:()=>{b&&s.mutate({sessionId:e.id,accountId:b.id},{onSuccess:()=>{x(null),D.success(`Moved to ${b.label}`)},onError:e=>{x(null),D.error(e.message)}})},children:`Move session`})]})]})})]})}}function ec({kit:e,menu:t}){let{Item:n,Separator:r,Sub:i,SubTrigger:a,SubContent:o}=e,{session:s}=t;return(0,G.jsxs)(G.Fragment,{children:[t.resumable&&!s.worktree_missing&&(0,G.jsxs)(n,{onSelect:t.resume,children:[(0,G.jsx)(wn,{}),` Resume`]}),t.live&&(0,G.jsxs)(n,{onSelect:t.kill,children:[(0,G.jsx)(Dn,{}),` Kill`]}),(0,G.jsxs)(n,{onSelect:t.openRename,children:[(0,G.jsx)(ke,{}),` Rename`]}),!t.archived&&(0,G.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,G.jsx)(Jt,{}),` Clear captured env`]}),t.canMigrate&&(0,G.jsxs)(i,{children:[(0,G.jsxs)(a,{children:[(0,G.jsx)(On,{}),` Move to account…`]}),(0,G.jsx)(o,{children:t.sameAgent.map(e=>{let r=e.id===s.account_id;return(0,G.jsxs)(n,{disabled:r,onSelect:()=>t.setMigrateTo(e),children:[e.label,r&&(0,G.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:`current`})]},e.id)})})]}),!s.worktree_missing&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(r,{}),(0,G.jsxs)(n,{onSelect:t.openTerminal,children:[(0,G.jsx)(Et,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,G.jsxs)(i,{children:[(0,G.jsxs)(a,{children:[(0,G.jsx)(Ot,{}),` Spawn agent in worktree`]}),(0,G.jsx)(o,{children:t.spawnAccounts.map(e=>(0,G.jsxs)(n,{onSelect:()=>t.spawnAgent(e.id),children:[(0,G.jsx)(Rt,{type:e.agent_type,className:`size-4 shrink-0`}),e.agent_type,`/`,e.label,e.id===t.defaultAccountId&&(0,G.jsx)(`span`,{className:`ml-auto pl-3 text-fg-muted`,children:`default`})]},e.id))})]}),(0,G.jsxs)(n,{onSelect:()=>{window.location.href=zt(`vscode`,s.worktree_path,Lt())},children:[(0,G.jsx)(Yt,{}),` Open in VS Code`]}),(0,G.jsxs)(n,{onSelect:()=>{window.location.href=zt(`cursor`,s.worktree_path,Lt())},children:[(0,G.jsx)(Yt,{}),` Open in Cursor`]})]}),!t.archived&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(r,{}),(0,G.jsxs)(n,{onSelect:t.archive,children:[(0,G.jsx)(Ne,{}),` Archive`]})]}),t.archived&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(r,{}),(0,G.jsxs)(n,{onSelect:t.unarchive,children:[(0,G.jsx)(Ye,{}),` Unarchive`]})]})]})}function tc({menu:e}){return(0,G.jsxs)(As,{children:[(0,G.jsx)(js,{asChild:!0,children:(0,G.jsxs)(j,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:e=>e.preventDefault(),children:[(0,G.jsx)(qt,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,G.jsx)(Ns,{align:`end`,children:(0,G.jsx)(ec,{kit:Zs,menu:e})})]})}function nc({session:e,onArchived:t,children:n}){let{menu:r,dialogs:i}=$s(e,t);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(nt,{children:[(0,G.jsx)(Ue,{asChild:!0,children:typeof n==`function`?n(r):n}),(0,G.jsx)(Qe,{children:(0,G.jsx)(ec,{kit:Qs,menu:r})})]}),i]})}function rc({menu:e}){return(0,G.jsx)(Qe,{children:(0,G.jsx)(ec,{kit:Qs,menu:e})})}function ic({icon:e,label:t,onClick:n,active:r=!1}){return(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:V(`flex items-center rounded-md p-1.5 transition-colors`,r?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,G.jsx)(e,{className:`size-4`}),(0,G.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,G.jsx)(_t,{children:t})]})}function ac({session:e}){return(0,G.jsxs)(`span`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{children:wt()(e)}),(0,G.jsx)(`span`,{className:`font-mono text-2xs text-fg-muted`,children:e.branch})]})}function oc({session:e,activeSessionId:t,onPromote:n,onArchived:r}){let{menu:i,dialogs:a}=$s(e,r),o=wt();return(0,G.jsxs)(nt,{children:[(0,G.jsxs)(St,{children:[(0,G.jsx)(Ue,{asChild:!0,children:(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsxs)(jt,{draggable:!1,"aria-current":e.id===t?`true`:void 0,onDoubleClick:()=>n(e.id),to:`/project/${e.project_id}/session/${e.id}`,className:V(`flex items-center rounded-md p-1.5 transition-colors hover:bg-elevated`,e.id===t&&`bg-elevated`),children:[(0,G.jsx)(Js,{status:e.status,kind:e.kind,stale:e.stale_running,className:`[--puddle-ripple-scale:2.3]`}),(0,G.jsx)(`span`,{className:`sr-only`,children:o(e)})]})})}),(0,G.jsx)(_t,{children:(0,G.jsx)(ac,{session:e})})]}),(0,G.jsx)(rc,{menu:i}),a]})}function sc({groups:e,activeSessionId:t,onReorder:n,onPromote:r,onExpand:i,onNewTerminal:a,onNewSession:o,onArchived:s}){let[c,l]=(0,K.useState)(null),u=e.filter(e=>e.sessions.length>0),d=(e,t)=>{let r=Fe(u,e,t);r&&n(r)};return(0,G.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center bg-surface py-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,G.jsx)(ic,{icon:Sn,label:`Show sessions`,onClick:i}),(0,G.jsx)(ic,{icon:Ot,label:`New agent`,onClick:o}),(0,G.jsx)(ic,{icon:Et,label:`New terminal`,onClick:a})]}),(0,G.jsx)(`div`,{className:`no-scrollbar flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto`,children:u.map(e=>(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,G.jsx)(`div`,{className:`my-0.5 h-px w-5 shrink-0 bg-border`}),e.sessions.map(e=>(0,G.jsx)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(oo,so({type:`terminal`,session:e.id})),l(e.id)},onDragEnd:()=>l(null),onDragOver:t=>{t.preventDefault(),c&&c!==e.id&&d(c,e.id)},className:V(`transition-opacity`,c===e.id&&`opacity-50`),children:(0,G.jsx)(oc,{session:e,activeSessionId:t,onPromote:r,onArchived:s})},e.id))]},e.projectId))})]})}function cc({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,ellipsis:a}){let o=wt();return(0,G.jsx)(nc,{session:e,onArchived:i,children:i=>(0,G.jsxs)(jt,{draggable:!1,onDoubleClick:r&&(()=>r(e.id)),to:`/project/${e.project_id}/session/${e.id}`,className:V(`group flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-elevated`,e.id===t&&`bg-elevated`),children:[(0,G.jsx)(Js,{status:e.status,kind:e.kind,stale:e.stale_running}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate font-sans text-xs text-fg`,children:o(e)}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1 truncate font-mono text-2xs text-fg-muted`,children:[(0,G.jsx)(gn,{className:`size-3 shrink-0 text-fg-gold`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.branch})]}),e.account_id!==null&&n.has(e.account_id)&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 truncate font-mono text-2xs text-fg-muted`,children:[(0,G.jsx)(Rt,{type:e.agent_type??``,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:n.get(e.account_id)})]})]}),e.skip_permissions&&(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsx)(En,{className:`size-3.5 shrink-0 text-waiting`})}),(0,G.jsx)(_t,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsx)(hn,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,G.jsx)(_t,{children:`Worktree directory is gone — archive only`})]}),a&&(0,G.jsx)(`span`,{className:`hidden group-hover:inline-flex has-[[data-state=open]]:inline-flex`,children:(0,G.jsx)(tc,{menu:i})})]})})}function lc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onNewSession:o,onNewTerminal:s,onCollapse:c,onArchived:l}){return(0,G.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 py-1.5`,children:[(0,G.jsx)(ic,{icon:xn,label:`Hide sessions`,onClick:c}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,G.jsx)(ic,{icon:Ot,label:`New agent`,onClick:o}),(0,G.jsx)(ic,{icon:Et,label:`New terminal`,onClick:s})]})]}),(0,G.jsx)(uc,{groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:l})]})}function uc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:o}){let[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(!1),d=new Map(t.map(e=>[e.id,e.label])),f=e.filter(e=>e.sessions.length>0),p=f.reduce((e,t)=>e+t.sessions.length,0),m=(e,t)=>{let n=Fe(f,e,t);n&&r(n)};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto py-1.5`,children:[p===0&&a.length===0&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:`No sessions yet — press ⌘K to start one.`}),f.map(e=>(0,G.jsxs)(`div`,{children:[e.name!==null&&(0,G.jsx)(`div`,{className:`truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e.name}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sessions.map(e=>(0,G.jsx)(`li`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(oo,so({type:`terminal`,session:e.id})),c(e.id)},onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&m(s,e.id)},className:V(`transition-opacity`,s===e.id&&`opacity-50`),children:(0,G.jsx)(cc,{session:e,activeSessionId:n,accountLabel:d,onPromote:i,onArchived:o,ellipsis:!0})},e.id))})]},e.projectId))]}),a.length>0&&(0,G.jsxs)(`div`,{className:`shrink-0 pb-1.5`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex w-full items-center gap-1.5 px-3 py-1.5 text-2xs uppercase tracking-wide text-fg-gold transition-colors hover:text-fg`,children:[(0,G.jsx)(ht,{className:V(`size-3 transition-transform`,l&&`rotate-90`)}),(0,G.jsx)(Ne,{className:`size-3`}),(0,G.jsx)(`span`,{children:`Archived`}),(0,G.jsx)(`span`,{className:`ml-auto tabular-nums`,children:a.length})]}),l&&(0,G.jsx)(`ul`,{className:`no-scrollbar flex max-h-48 flex-col gap-0.5 overflow-y-auto`,children:a.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(cc,{session:e,activeSessionId:n,accountLabel:d,onArchived:o,ellipsis:!0})},e.id))})]})]})}var dc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function fc(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function pc(e){return`nodeType`in e}function mc(e){return e?fc(e)?e:pc(e)?e.ownerDocument?.defaultView??window:window:window}function hc(e){let{Document:t}=mc(e);return e instanceof t}function gc(e){return!fc(e)&&e instanceof mc(e).HTMLElement}function _c(e){return e instanceof mc(e).SVGElement}function vc(e){return e?fc(e)?e.document:pc(e)?hc(e)?e:gc(e)||_c(e)?e.ownerDocument:document:document:document}var yc=dc?K.useLayoutEffect:K.useEffect;function bc(e){let t=(0,K.useRef)(e);return yc(()=>{t.current=e}),(0,K.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function xc(){let e=(0,K.useRef)(null);return[(0,K.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,K.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Sc(e,t){t===void 0&&(t=[e]);let n=(0,K.useRef)(e);return yc(()=>{n.current!==e&&(n.current=e)},t),n}function Cc(e,t){let n=(0,K.useRef)();return(0,K.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function wc(e){let t=bc(e),n=(0,K.useRef)(null);return[n,(0,K.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Tc(e){let t=(0,K.useRef)();return(0,K.useEffect)(()=>{t.current=e},[e]),t.current}var Ec={};function Dc(e,t){return(0,K.useMemo)(()=>{if(t)return t;let n=Ec[e]==null?0:Ec[e]+1;return Ec[e]=n,e+`-`+n},[e,t])}function Oc(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var kc=Oc(1),Ac=Oc(-1);function jc(e){return`clientX`in e&&`clientY`in e}function Mc(e){if(!e)return!1;let{KeyboardEvent:t}=mc(e.target);return t&&e instanceof t}function Nc(e){if(!e)return!1;let{TouchEvent:t}=mc(e.target);return t&&e instanceof t}function Pc(e){if(Nc(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return jc(e)?{x:e.clientX,y:e.clientY}:null}var Fc=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[Fc.Translate.toString(e),Fc.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Ic=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Lc(e){return e.matches(Ic)?e:e.querySelector(Ic)}var Rc={display:`none`};function zc(e){let{id:t,value:n}=e;return K.createElement(`div`,{id:t,style:Rc},n)}function Bc(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return K.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function Vc(){let[e,t]=(0,K.useState)(``);return{announce:(0,K.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Hc=(0,K.createContext)(null);function Uc(e){let t=(0,K.useContext)(Hc);(0,K.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Wc(){let[e]=(0,K.useState)(()=>new Set),t=(0,K.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,K.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Gc={draggable:`
3
- To pick up a draggable item, press the space bar.
4
- While dragging, use the arrow keys to move the item.
5
- Press space again to drop the item in its new position, or press escape to cancel.
6
- `},Kc={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function qc(e){let{announcements:t=Kc,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Gc}=e,{announce:a,announcement:o}=Vc(),s=Dc(`DndLiveRegion`),[c,l]=(0,K.useState)(!1);if((0,K.useEffect)(()=>{l(!0)},[]),Uc((0,K.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=K.createElement(K.Fragment,null,K.createElement(zc,{id:r,value:i.draggable}),K.createElement(Bc,{id:s,announcement:o}));return n?(0,Ni.createPortal)(u,n):u}var Z;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(Z||={});function Jc(){}function Yc(e,t){return(0,K.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Xc(){var e=[...arguments];return(0,K.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Zc=Object.freeze({x:0,y:0});function Qc(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function $c(e,t){let n=Pc(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function el(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function tl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function nl(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function rl(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function il(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var al=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=il(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(tl)};function ol(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var sl=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&ol(r,a)){let n=nl(a).reduce((e,t)=>e+Qc(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(el)};function cl(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function ll(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Zc}function ul(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var dl=ul(1);function fl(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function pl(e,t,n){let r=fl(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var ml={ignoreTransform:!1};function hl(e,t){t===void 0&&(t=ml);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=mc(e).getComputedStyle(e);t&&(n=pl(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function gl(e){return hl(e,{ignoreTransform:!0})}function _l(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function vl(e,t){return t===void 0&&(t=mc(e).getComputedStyle(e)),t.position===`fixed`}function yl(e,t){t===void 0&&(t=mc(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function bl(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(hc(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!gc(i)||_c(i)||n.includes(i))return n;let a=mc(e).getComputedStyle(i);return i!==e&&yl(i,a)&&n.push(i),vl(i,a)?n:r(i.parentNode)}return e?r(e):n}function xl(e){let[t]=bl(e,1);return t??null}function Sl(e){return!dc||!e?null:fc(e)?e:pc(e)?hc(e)||e===vc(e).scrollingElement?window:gc(e)?e:null:null}function Cl(e){return fc(e)?e.scrollX:e.scrollLeft}function wl(e){return fc(e)?e.scrollY:e.scrollTop}function Tl(e){return{x:Cl(e),y:wl(e)}}var Q;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Q||={});function El(e){return!dc||!e?!1:e===document.scrollingElement}function Dl(e){let t={x:0,y:0},n=El(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Ol={x:.2,y:.2};function kl(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Ol);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Dl(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Q.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Q.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Q.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Q.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Al(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function jl(e){return e.reduce((e,t)=>kc(e,Tl(t)),Zc)}function Ml(e){return e.reduce((e,t)=>e+Cl(t),0)}function Nl(e){return e.reduce((e,t)=>e+wl(t),0)}function Pl(e,t){if(t===void 0&&(t=hl),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);xl(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Fl=[[`x`,[`left`,`right`],Ml],[`y`,[`top`,`bottom`],Nl]],Il=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=bl(t),r=jl(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Fl)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Ll=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Rl(e){let{EventTarget:t}=mc(e);return e instanceof t?e:vc(e)}function zl(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var Bl;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Bl||={});function Vl(e){e.preventDefault()}function Hl(e){e.stopPropagation()}var $;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})($||={});var Ul={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},Wl=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case $.Right:return{...n,x:n.x+25};case $.Left:return{...n,x:n.x-25};case $.Down:return{...n,y:n.y+25};case $.Up:return{...n,y:n.y-25}}},Gl=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Ll(vc(t)),this.windowListeners=new Ll(mc(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Bl.Resize,this.handleCancel),this.windowListeners.add(Bl.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Bl.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Pl(n),t(Zc)}handleKeyDown(e){if(Mc(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Ul,coordinateGetter:a=Wl,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:Zc;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Ac(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Dl(n),p=Al(n),m={x:Math.min(i===$.Right?p.right-p.width/2:p.right,Math.max(i===$.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===$.Down?p.bottom-p.height/2:p.bottom,Math.max(i===$.Down?p.top:p.top+p.height/2,u.y))},h=i===$.Right&&!s||i===$.Left&&!c,g=i===$.Down&&!l||i===$.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===$.Right&&e<=d.x||i===$.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===$.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===$.Down&&e<=d.y||i===$.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===$.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,kc(Ac(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Gl.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Ul,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Kl(e){return!!(e&&`distance`in e)}function ql(e){return!!(e&&`delay`in e)}var Jl=class{constructor(e,t,n){n===void 0&&(n=Rl(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=vc(i),this.documentListeners=new Ll(this.document),this.listeners=new Ll(n),this.windowListeners=new Ll(mc(i)),this.initialCoordinates=Pc(r)??Zc,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Bl.Resize,this.handleCancel),this.windowListeners.add(Bl.DragStart,Vl),this.windowListeners.add(Bl.VisibilityChange,this.handleCancel),this.windowListeners.add(Bl.ContextMenu,Vl),this.documentListeners.add(Bl.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ql(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Kl(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Bl.Click,Hl,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Bl.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Pc(e)??Zc,s=Ac(n,o);if(!t&&a){if(Kl(a)){if(a.tolerance!=null&&zl(s,a.tolerance))return this.handleCancel();if(zl(s,a.distance))return this.handleStart()}if(ql(a)&&zl(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===$.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Yl={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Xl=class extends Jl{constructor(e){let{event:t}=e,n=vc(t.target);super(e,Yl,n)}};Xl.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Zl={move:{name:`mousemove`},end:{name:`mouseup`}},Ql;(function(e){e[e.RightClick=2]=`RightClick`})(Ql||={});var $l=class extends Jl{constructor(e){super(e,Zl,vc(e.event.target))}};$l.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Ql.RightClick?!1:(r?.({event:n}),!0)}}];var eu={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},tu=class extends Jl{constructor(e){super(e,eu)}static setup(){return window.addEventListener(eu.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(eu.move.name,e)};function e(){}}};tu.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var nu;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(nu||={});var ru;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(ru||={});function iu(e){let{acceleration:t,activator:n=nu.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=ru.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=ou({delta:d,disabled:!a}),[m,h]=xc(),g=(0,K.useRef)({x:0,y:0}),_=(0,K.useRef)({x:0,y:0}),v=(0,K.useMemo)(()=>{switch(n){case nu.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case nu.DraggableRect:return i}},[n,i,c]),y=(0,K.useRef)(null),b=(0,K.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,K.useMemo)(()=>s===ru.TreeOrder?[...l].reverse():l,[s,l]);(0,K.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=kl(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var au={x:{[Q.Backward]:!1,[Q.Forward]:!1},y:{[Q.Backward]:!1,[Q.Forward]:!1}};function ou(e){let{delta:t,disabled:n}=e,r=Tc(t);return Cc(e=>{if(n||!r||!e)return au;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Q.Backward]:e.x[Q.Backward]||i.x===-1,[Q.Forward]:e.x[Q.Forward]||i.x===1},y:{[Q.Backward]:e.y[Q.Backward]||i.y===-1,[Q.Forward]:e.y[Q.Forward]||i.y===1}}},[n,t,r])}function su(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Cc(e=>t==null?null:r??e??null,[r,t])}function cu(e,t){return(0,K.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var lu;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(lu||={});var uu;(function(e){e.Optimized=`optimized`})(uu||={});var du=new Map;function fu(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,K.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,K.useRef)(e),d=g(),f=Sc(d),p=(0,K.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,K.useRef)(null),h=Cc(t=>{if(d&&!n)return du;if(!t||t===du||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Il(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,K.useEffect)(()=>{u.current=e},[e]),(0,K.useEffect)(()=>{d||p()},[n,d]),(0,K.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,K.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case lu.Always:return!1;case lu.BeforeDragging:return n;default:return!n}}}function pu(e,t){return Cc(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function mu(e,t){return pu(e,t)}function hu(e){let{callback:t,disabled:n}=e,r=bc(t),i=(0,K.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,K.useEffect)(()=>()=>i?.disconnect(),[i]),i}function gu(e){let{callback:t,disabled:n}=e,r=bc(t),i=(0,K.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,K.useEffect)(()=>()=>i?.disconnect(),[i]),i}function _u(e){return new Il(hl(e),e)}function vu(e,t,n){t===void 0&&(t=_u);let[r,i]=(0,K.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=hu({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=gu({callback:a});return yc(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function yu(e){return ll(e,pu(e))}var bu=[];function xu(e){let t=(0,K.useRef)(e),n=Cc(n=>e?n&&n!==bu&&e&&t.current&&e.parentNode===t.current.parentNode?n:bl(e):bu,[e]);return(0,K.useEffect)(()=>{t.current=e},[e]),n}function Su(e){let[t,n]=(0,K.useState)(null),r=(0,K.useRef)(e),i=(0,K.useCallback)(e=>{let t=Sl(e.target);t&&n(e=>e?(e.set(t,Tl(t)),new Map(e)):null)},[]);return(0,K.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Sl(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Tl(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Sl(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,K.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>kc(e,t),Zc):jl(e):Zc,[e,t])}function Cu(e,t){t===void 0&&(t=[]);let n=(0,K.useRef)(null);return(0,K.useEffect)(()=>{n.current=null},t),(0,K.useEffect)(()=>{let t=e!==Zc;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Ac(e,n.current):Zc}function wu(e){(0,K.useEffect)(()=>{if(!dc)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Tu(e,t){return(0,K.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Eu(e){return(0,K.useMemo)(()=>e?_l(e):null,[e])}var Du=[];function Ou(e,t){t===void 0&&(t=hl);let[n]=e,r=Eu(n?mc(n):null),[i,a]=(0,K.useState)(Du);function o(){a(()=>e.length?e.map(e=>El(e)?r:new Il(t(e),e)):Du)}let s=gu({callback:o});return yc(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function ku(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return gc(t)?t:e}function Au(e){let{measure:t}=e,[n,r]=(0,K.useState)(null),i=gu({callback:(0,K.useCallback)(e=>{for(let{target:n}of e)if(gc(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=wc((0,K.useCallback)(e=>{let n=ku(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,K.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var ju=[{sensor:Xl,options:{}},{sensor:Gl,options:{}}],Mu={current:{}},Nu={draggable:{measure:gl},droppable:{measure:gl,strategy:lu.WhileDragging,frequency:uu.Optimized},dragOverlay:{measure:hl}},Pu=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Fu={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Pu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Jc},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Nu,measureDroppableContainers:Jc,windowRect:null,measuringScheduled:!1},Iu={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Jc,draggableNodes:new Map,over:null,measureDroppableContainers:Jc},Lu=(0,K.createContext)(Iu),Ru=(0,K.createContext)(Fu);function zu(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Pu}}}function Bu(e,t){switch(t.type){case Z.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Z.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Z.DragEnd:case Z.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Z.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Pu(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Z.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Pu(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Z.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Pu(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Vu(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,K.useContext)(Lu),a=Tc(r),o=Tc(n?.id);return(0,K.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Mc(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Lc(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Hu(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Uu(e){return(0,K.useMemo)(()=>({draggable:{...Nu.draggable,...e?.draggable},droppable:{...Nu.droppable,...e?.droppable},dragOverlay:{...Nu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Wu(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,K.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;yc(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=ll(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=xl(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Gu=(0,K.createContext)({...Zc,scaleX:1,scaleY:1}),Ku;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Ku||={});var qu=(0,K.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=ju,collisionDetection:o=al,measuring:s,modifiers:c,...l}=e,[u,d]=(0,K.useReducer)(Bu,void 0,zu),[f,p]=Wc(),[m,h]=(0,K.useState)(Ku.Uninitialized),g=m===Ku.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,K.useRef)({initial:null,translated:null}),C=(0,K.useMemo)(()=>_==null?null:{id:_,data:x?.data??Mu,rect:S},[_,x]),w=(0,K.useRef)(null),[T,E]=(0,K.useState)(null),[D,ee]=(0,K.useState)(null),O=Sc(l,Object.values(l)),k=Dc(`DndDescribedBy`,t),te=(0,K.useMemo)(()=>b.getEnabled(),[b]),A=Uu(s),{droppableRects:j,measureDroppableContainers:ne,measuringScheduled:re}=fu(te,{dragging:g,dependencies:[y.x,y.y],config:A.droppable}),M=su(v,_),N=(0,K.useMemo)(()=>D?Pc(D):null,[D]),P=Oe(),ie=mu(M,A.draggable.measure);Wu({activeNode:_==null?null:v.get(_),config:P.layoutShiftCompensation,initialRect:ie,measure:A.draggable.measure});let F=vu(M,A.draggable.measure,ie),ae=vu(M?M.parentElement:null),oe=(0,K.useRef)({activatorEvent:null,active:null,activeNode:M,collisionRect:null,collisions:null,droppableRects:j,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=b.getNodeFor(oe.current.over?.id),ce=Au({measure:A.dragOverlay.measure}),I=ce.nodeRef.current??M,le=g?ce.rect??F:null,ue=!!(ce.nodeRef.current&&ce.rect),de=yu(ue?null:F),fe=Eu(I?mc(I):null),L=xu(g?se??M:null),pe=Ou(L),R=Hu(c,{transform:{x:y.x-de.x,y:y.y-de.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:F,containerNodeRect:ae,draggingNodeRect:le,over:oe.current.over,overlayNodeRect:ce.rect,scrollableAncestors:L,scrollableAncestorRects:pe,windowRect:fe}),me=N?kc(N,y):null,he=Su(L),ge=Cu(he),_e=Cu(he,[F]),z=kc(R,ge),ve=le?dl(le,R):null,ye=C&&ve?o({active:C,collisionRect:ve,droppableRects:j,droppableContainers:te,pointerCoordinates:me}):null,be=rl(ye,`id`),[B,xe]=(0,K.useState)(null),Se=cl(ue?R:kc(R,_e),B?.rect??null,F),Ce=(0,K.useRef)(null),we=(0,K.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:oe,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=O.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=O.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=O.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,Ni.unstable_batchedUpdates)(()=>{r?.(i),h(Ku.Initializing),d({type:Z.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Ce.current),ee(a)})},onMove(e){d({type:Z.DragMove,coordinates:e})},onEnd:s(Z.DragEnd),onCancel:s(Z.DragCancel)});Ce.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=oe.current,o=null;if(t&&i){let{cancelDrop:s}=O.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Z.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Z.DragCancel)}w.current=null,(0,Ni.unstable_batchedUpdates)(()=>{d({type:e}),h(Ku.Uninitialized),xe(null),E(null),ee(null),Ce.current=null;let t=e===Z.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=O.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Te=cu(a,(0,K.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,we(n,t))},[v,we]));wu(a),yc(()=>{F&&m===Ku.Initializing&&h(Ku.Initialized)},[F,m]),(0,K.useEffect)(()=>{let{onDragMove:e}=O.current,{active:t,activatorEvent:n,collisions:r,over:i}=oe.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:z.x,y:z.y},over:i};(0,Ni.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[z.x,z.y]),(0,K.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=oe.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=O.current,o=r.get(be),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,Ni.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[be]),yc(()=>{oe.current={activatorEvent:D,active:C,activeNode:M,collisionRect:ve,collisions:ye,droppableRects:j,draggableNodes:v,draggingNode:I,draggingNodeRect:le,droppableContainers:b,over:B,scrollableAncestors:L,scrollAdjustedTranslate:z},S.current={initial:le,translated:ve}},[C,M,ye,ve,v,I,le,j,b,B,L,z]),iu({...P,delta:y,draggingRect:ve,pointerCoordinates:me,scrollableAncestors:L,scrollableAncestorRects:pe});let Ee=(0,K.useMemo)(()=>({active:C,activeNode:M,activeNodeRect:F,activatorEvent:D,collisions:ye,containerNodeRect:ae,dragOverlay:ce,draggableNodes:v,droppableContainers:b,droppableRects:j,over:B,measureDroppableContainers:ne,scrollableAncestors:L,scrollableAncestorRects:pe,measuringConfiguration:A,measuringScheduled:re,windowRect:fe}),[C,M,F,D,ye,ae,ce,v,b,j,B,ne,L,pe,A,re,fe]),De=(0,K.useMemo)(()=>({activatorEvent:D,activators:Te,active:C,activeNodeRect:F,ariaDescribedById:{draggable:k},dispatch:d,draggableNodes:v,over:B,measureDroppableContainers:ne}),[D,Te,C,F,d,k,v,B,ne]);return K.createElement(Hc.Provider,{value:p},K.createElement(Lu.Provider,{value:De},K.createElement(Ru.Provider,{value:Ee},K.createElement(Gu.Provider,{value:Se},i)),K.createElement(Vu,{disabled:n?.restoreFocus===!1})),K.createElement(qc,{...n,hiddenTextDescribedById:k}));function Oe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Ju=(0,K.createContext)(null),Yu=`button`,Xu=`Draggable`;function Zu(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Dc(Xu),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,K.useContext)(Lu),{role:p=Yu,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,K.useContext)(g?Gu:Ju),[v,y]=wc(),[b,x]=wc(),S=Tu(o,t),C=Sc(n);return yc(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,K.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Yu?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function Qu(){return(0,K.useContext)(Ru)}var $u=`Droppable`,ed={timeout:25};function td(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Dc($u),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,K.useContext)(Lu),u=(0,K.useRef)({disabled:n}),d=(0,K.useRef)(!1),f=(0,K.useRef)(null),p=(0,K.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...ed,...i},_=Sc(h??r),v=gu({callback:(0,K.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=wc((0,K.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Sc(t);return(0,K.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,K.useEffect)(()=>(s({type:Z.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Z.UnregisterDroppable,key:a,id:r})),[r]),(0,K.useEffect)(()=>{n!==u.current.disabled&&(s({type:Z.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function nd(e){let{animation:t,children:n}=e,[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(null),s=Tc(n);return!n&&!r&&s&&i(s),yc(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),K.createElement(K.Fragment,null,n,r?(0,K.cloneElement)(r,{ref:o}):null)}var rd={x:0,y:0,scaleX:1,scaleY:1};function id(e){let{children:t}=e;return K.createElement(Lu.Provider,{value:Iu},K.createElement(Gu.Provider,{value:rd},t))}var ad={position:`fixed`,touchAction:`none`},od=e=>Mc(e)?`transform 250ms ease`:void 0,sd=(0,K.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=od}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...ad,width:s.width,height:s.height,top:s.top,left:s.left,transform:Fc.Transform.toString(d),transformOrigin:i&&r?$c(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return K.createElement(n,{className:o,style:f,ref:t},a)}),cd={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Fc.Transform.toString(t)},{transform:Fc.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function ld(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return bc((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=ku(a);if(!c)return;let{transform:l}=mc(a).getComputedStyle(a),u=fl(l);if(!u)return;let d=typeof t==`function`?t:ud(t);return Pl(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function ud(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...cd,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var dd=0;function fd(e){return(0,K.useMemo)(()=>{if(e!=null)return dd++,dd},[e])}var pd=K.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=Qu(),S=(0,K.useContext)(Gu),C=fd(d?.id),w=Hu(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=pu(f),E=ld({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return K.createElement(id,null,K.createElement(nd,{animation:E},d&&C?K.createElement(sd,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function md({className:e}){return(0,G.jsx)(`svg`,{viewBox:`0 0 2000 2000`,fill:`none`,"aria-hidden":`true`,className:e,children:(0,G.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:110,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,G.jsx)(`line`,{x1:`491.66`,y1:`1916.78`,x2:`1558.47`,y2:`83.22`}),(0,G.jsx)(`path`,{d:`M491.66,1916.78c-329.28-191.58-441.36-613.07-250.32-941.41,191.04-328.34,612.84-439.21,942.13-247.62`}),(0,G.jsx)(`path`,{d:`M1558.47,83.22c279.53,162.64,376.25,517.72,216.03,793.09-160.22,275.38-516.71,366.77-796.24,204.13`}),(0,G.jsx)(`path`,{d:`M497.55,1881.96c-222.81-129.63-298.64-414.83-169.38-637,129.26-222.17,414.67-297.19,637.48-167.55`})]})})}var hd=[`running`,`waiting_input`];function gd({sessionId:e,status:t}){let n=hd.includes(t),{data:r}=_e(e,n),i=r?.vars??[];return!n||i.length===0?null:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1 font-mono text-xs`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`env`}),(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:i.map(e=>(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsx)(`span`,{className:`cursor-default rounded px-1.5 py-0.5 text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,children:e.name})}),(0,G.jsxs)(_t,{children:[e.bytes,` B · captured from this session's shell — re-injected into new shells and agent restarts`]})]},e.name))})]})}function _d(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var vd=[`running`,`waiting_input`];function yd({sessionId:e,status:t}){let n=vd.includes(t),{data:r}=L(e,n),i=r?.ports??[];return!n||i.length===0?null:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1 font-mono text-xs`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`ports`}),(0,G.jsx)(`div`,{className:`flex items-center gap-1`,children:i.map(t=>(0,G.jsx)(bd,{sessionId:e,port:t},t.port))})]})}function bd({sessionId:e,port:t}){let n=oe().data;return(0,G.jsxs)(As,{children:[(0,G.jsxs)(St,{children:[(0,G.jsx)(Mt,{asChild:!0,children:(0,G.jsx)(js,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,className:`cursor-pointer rounded px-1.5 py-0.5 tabular-nums text-fg-secondary outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:bg-elevated focus-visible:text-fg`,children:t.port})})}),(0,G.jsxs)(_t,{children:[t.command,` · pid `,t.pid]})]}),(0,G.jsxs)(Ns,{align:`start`,children:[Wt()===null?(0,G.jsx)(Ps,{asChild:!0,children:(0,G.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,G.jsx)(Ps,{onSelect:()=>{window.open(`/proxy/${e}/${t.port}/?puddle_token=${E.get()??``}`,`_blank`,`noopener,noreferrer`)},children:`Open via proxy`}),(0,G.jsx)(Ps,{onSelect:()=>{n&&navigator.clipboard.writeText(_d(t.port,n.username,n.hostname)).then(()=>D.success(`Copied`))},children:`Copy ssh -L`})]})]})}function xd(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=Sd(t.x/e.width),i=Sd(t.y/e.height);if(r>n&&r<1-n&&i>n&&i<1-n)return`center`;let a=r,o=1-r,s=i,c=1-i,l=Math.min(a,o,s,c);return l===s?`top`:l===c?`bottom`:l===a?`left`:`right`}function Sd(e){return e<0?0:e>1?1:e}var Cd=[`interrupted`,`exited`];function wd({session:e}){let t=ge(`resume`);return Cd.includes(e.status)&&!e.worktree_missing?(0,G.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 right-3 z-10`,children:(0,G.jsxs)(j,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>D.error(e.message)}),children:[(0,G.jsx)(wn,{}),`Resume`]})}):null}var Td=(0,K.createContext)(null);function Ed(){return(0,K.useContext)(Td)}var Dd=`leaf:`,Od=`tabdrop:`,kd=`strip:`,Ad=e=>{let t=sl(e);for(let e of[Od,kd]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:al(e)};function jd({onDrop:e,renderOverlay:t,children:n}){let r=Xc(Yc(Xl,{activationConstraint:{distance:4}})),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(null),c=(0,K.useRef)(null),l=()=>{a(null),s(null),c.current=null};return(0,G.jsxs)(qu,{sensors:r,collisionDetection:Ad,onDragStart:e=>s(e.active.data.current?.ref??null),onDragMove:e=>{let t=e.over,n=Md(e),r=t&&n?Pd(String(t.id),t.rect,t.data.current,n):null;Nd(c.current,r)||(c.current=r,a(r))},onDragEnd:t=>{let n=c.current,r=t.active.data.current?.ref,i=t.active.data.current?.fromLeafId;l(),n&&r&&i&&e({ref:r,fromLeafId:i,toLeafId:n.leafId,edge:n.zone,index:n.index})},onDragCancel:l,children:[(0,G.jsx)(Td.Provider,{value:i,children:n}),(0,G.jsx)(pd,{dropAnimation:null,children:o?t(o):null})]})}function Md(e){let t=e.activatorEvent;return typeof t.clientX!=`number`||typeof t.clientY!=`number`?null:{x:t.clientX+e.delta.x,y:t.clientY+e.delta.y}}function Nd(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function Pd(e,t,n,r){if(e.startsWith(Od)){let e=n;if(!e)return null;let i=r.x>t.left+t.width/2;return{leafId:e.leafId,zone:`center`,index:e.index+ +!!i}}if(e.startsWith(kd)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(Dd)){let n=xd({width:t.width,height:t.height},{x:r.x-t.left,y:r.y-t.top});return{leafId:e.slice(5),zone:n}}return null}var Fd=`group flex min-w-0 max-w-52 cursor-pointer items-center gap-1.5 rounded-t-md px-2.5 text-xs transition-colors`;function Id({leaf:e,sessions:t,onActivate:n,onClose:r,onPromote:i,onArchived:a,onSetView:o}){let s=new Map(t.map(e=>[e.id,e.branch])),c=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),l=Ed(),u=l?.leafId===e.id&&l.index!==void 0?l.index:null,{setNodeRef:d}=td({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),f=e=>{let t=Ut(e.path,e.session,c,s);return m(e)===`diff`?`${t} (diff)`:m(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,G.jsxs)(`div`,{ref:d,className:`flex h-9 shrink-0 items-stretch gap-0.5 overflow-x-auto bg-surface px-1 pt-1`,children:[e.tabs.map((s,c)=>(0,G.jsxs)(K.Fragment,{children:[u===c&&(0,G.jsx)(Ld,{}),(0,G.jsx)(zd,{tab:s,leafId:e.id,index:c,active:Y(s)===e.activeKey,preview:Y(s)===e.previewKey,session:s.type===`terminal`?t.find(e=>e.id===s.session):void 0,label:s.type===`editor`?f(s.tab):``,onActivate:()=>n(s),onClose:()=>r(s),onPromote:()=>i(s),onArchived:a,onSetView:e=>o(s,e)})]},Y(s))),u===e.tabs.length&&(0,G.jsx)(Ld,{})]})}function Ld(){return(0,G.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function Rd({view:e,onSetView:t}){let n=e===`preview`;return(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t(n?`source`:`preview`)},className:`rounded-sm p-0.5 text-fg-muted opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,"aria-label":n?`Show source`:`Show preview`,title:n?`Show source`:`Show preview`,children:n?(0,G.jsx)(W,{className:`size-3`}):(0,G.jsx)(Xt,{className:`size-3`})})}function zd({tab:e,leafId:t,index:n,active:r,preview:i,session:a,label:o,onActivate:s,onClose:c,onPromote:l,onArchived:u,onSetView:d}){let f=wt(),p=Y(e),{attributes:h,listeners:_,setNodeRef:v,isDragging:y}=Zu({id:`drag:${t}:${p}`,data:{ref:e,fromLeafId:t}}),{setNodeRef:b}=td({id:`tabdrop:${t}:${p}`,data:{leafId:t,index:n}}),x=e=>{v(e),b(e)},S=V(Fd,r?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`,i&&`italic`,y&&`opacity-40`),C=(0,G.jsx)(`div`,{ref:x,...h,..._,onClick:s,onDoubleClick:l,className:S,children:e.type===`terminal`?(0,G.jsxs)(G.Fragment,{children:[a&&(0,G.jsx)(Js,{status:a.status,kind:a.kind,stale:a.stale_running}),(0,G.jsx)(`span`,{className:`truncate font-mono`,children:a?f(a):e.session.slice(0,8)}),(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},className:`rounded-sm p-0.5 text-fg-muted opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,"aria-label":`Close tab`,children:(0,G.jsx)(ne,{className:`size-3`})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`truncate font-mono`,children:o}),m(e.tab)===`file`&&g(e.tab.path)!==null&&(0,G.jsx)(Rd,{view:e.tab.view??`source`,onSetView:d}),(0,G.jsx)(Mi,{session:e.tab.session,path:e.tab.path,kind:m(e.tab),label:o,onClose:c})]})});return e.type===`terminal`&&a?(0,G.jsx)(nc,{session:a,onArchived:()=>u(e.session),children:C}):C}function Bd({leaf:e,sessions:t,reveal:n,onActivateTab:r,onCloseTab:i,onPromoteTab:a,onArchived:o,onFocusLeaf:s,onDropTab:c,onSetTabView:l}){let u=e.tabs.find(t=>Y(t)===e.activeKey)??null,d=u?.type===`terminal`?Y(u):null,f=u?.type===`terminal`?t.find(e=>e.id===u.session)??null:null,p=la(d),{setNodeRef:m}=td({id:`leaf:${e.id}`}),h=Ed(),g=(0,K.useRef)(null),_=(0,K.useRef)(()=>void 0);_.current=()=>{u&&r(e.id,u)},(0,K.useEffect)(()=>{let e=g.current;if(!e)return;let t=()=>_.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[v,y]=(0,K.useState)(null),b=e=>{let t=e.currentTarget.getBoundingClientRect();return xd({width:t.width,height:t.height},{x:e.clientX-t.left,y:e.clientY-t.top})};return(0,G.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,onMouseDownCapture:()=>s(e.id),children:[e.tabs.length>0&&(0,G.jsx)(Id,{leaf:e,sessions:t,onActivate:t=>r(e.id,t),onClose:t=>i(e.id,t),onPromote:a,onArchived:o,onSetView:l}),(0,G.jsxs)(`div`,{ref:e=>{g.current=e,m(e)},className:`relative min-h-0 flex-1`,onDragOver:e=>{lo(e.dataTransfer.types)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,y(b(e)))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||y(null)},onDrop:t=>{if(!lo(t.dataTransfer.types))return;t.preventDefault(),y(null);let n=co(t.dataTransfer.getData(oo));n&&c(e.id,n,b(t))},children:[u?.type===`editor`&&(0,G.jsx)(`div`,{className:`absolute inset-0`,children:(0,G.jsx)(Oi,{tab:u.tab,reveal:n})}),(0,G.jsx)(`div`,{ref:p,className:V(`absolute inset-0 py-1 pl-4 pr-2`,!d&&`hidden`)}),h?.leafId===e.id&&h.index===void 0&&(0,G.jsx)(Hd,{zone:h.zone}),v!==null&&(0,G.jsx)(Hd,{zone:v}),f&&(0,G.jsx)(wd,{session:f}),!u&&(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,G.jsx)(md,{className:`size-24 text-fg-muted/40`}),(0,G.jsx)(`button`,{type:`button`,onClick:Ct,className:`rounded-md bg-elevated px-3 py-1.5 font-mono text-xs text-fg-muted transition-colors hover:bg-border hover:text-fg-secondary`,children:`⌘K`})]})]}),f&&(0,G.jsx)(gd,{sessionId:f.id,status:f.status}),f&&(0,G.jsx)(yd,{sessionId:f.id,status:f.status})]})}var Vd={center:`inset-0`,left:`inset-y-0 left-0 w-1/2`,right:`inset-y-0 right-0 w-1/2`,top:`inset-x-0 top-0 h-1/2`,bottom:`inset-x-0 bottom-0 h-1/2`};function Hd({zone:e}){return(0,G.jsx)(`div`,{className:V(`pointer-events-none absolute z-20 bg-accent/20`,Vd[e])})}var Ud=`bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`;function Wd({tree:e,...t}){let n=(0,K.useMemo)(()=>{let t=new Set,n=[];for(let r of Hi(e)){if(r.type!==`editor`||m(r.tab)===`commit`)continue;let e=`${r.tab.session}${r.tab.path}`;t.has(e)||(t.add(e),n.push({session:r.tab.session,path:r.tab.path}))}return n},[e]);return(0,G.jsxs)(G.Fragment,{children:[n.length>0&&(0,G.jsx)(Ai,{buffers:n}),(0,G.jsx)(Gd,{node:e,...t})]})}function Gd({node:e,...t}){if(e.kind===`leaf`)return(0,G.jsx)(Bd,{leaf:e,sessions:t.sessions,reveal:t.reveal,onActivateTab:t.onActivateTab,onCloseTab:t.onCloseTab,onPromoteTab:t.onPromoteTab,onArchived:t.onArchived,onFocusLeaf:t.onFocusLeaf,onDropTab:t.onDropTab,onSetTabView:t.onSetTabView});let n=e.direction===`row`?`horizontal`:`vertical`;return(0,G.jsx)(gi,{orientation:n,className:`size-full`,defaultLayout:Object.fromEntries(e.children.map((t,n)=>[t.id,e.sizes[n]??100/e.children.length])),onLayoutChanged:n=>t.onResize(e.id,e.children.map(e=>n[e.id]??0)),children:e.children.map((e,r)=>(0,G.jsxs)(K.Fragment,{children:[r>0&&(0,G.jsx)(Si,{className:n===`horizontal`?`w-px ${Ud}`:`h-px ${Ud}`}),(0,G.jsx)(yi,{id:e.id,minSize:64,children:(0,G.jsx)(Gd,{node:e,...t})})]},e.id))},e.id)}function Kd(e){let t=e.snapshot,n=(0,K.useRef)(null);!t.layout_tree&&!n.current&&(n.current=oa(t));let r=t.layout_tree??n.current??Li([]),i=(0,K.useCallback)(t=>e.update({layout_tree:t}),[e]),a=(0,K.useRef)(i);a.current=i;let o=(0,K.useRef)(!1);(0,K.useEffect)(()=>{o.current||e.loaded&&!t.layout_tree&&n.current&&(o.current=!0,Hi(n.current).length>0&&a.current(n.current))},[e.loaded,t.layout_tree]);let[s,c]=(0,K.useState)(null),l=(s?zi(r,s):null)??Vi(r)[0]??Li([]),u=l.tabs.find(e=>Y(e)===l.activeKey)??null,d=u?.type===`editor`?u.tab:null;return(0,K.useMemo)(()=>({tree:r,focusedLeaf:l,activeEditorTab:d,focusLeaf:e=>c(e),activate:(e,t)=>{c(e);let n=Y(t),a=zi(r,e);a&&a.activeKey===n||i(ra(r,e,n))},close:(e,t)=>i(Qi(r,e,Y(t))),openEditor:(e,t)=>{let n=l.id;c(n);let a={type:`editor`,tab:e};i(t?.preview?ea(r,n,a):$i(r,n,a))},ensureTerminal:(e,t)=>{let n=`term:${e}`,a=Bi(r,n);if(a){c(a.id);let e=a.activeKey!==n,o=!t?.preview&&a.previewKey===n;if(e||o){let t=r;e&&(t=ra(t,a.id,n)),o&&(t=ta(t,n)),i(t)}}else{let n=l.id;c(n);let a={type:`terminal`,session:e};i(t?.preview?ea(r,n,a):$i(r,n,a))}},promote:e=>i(ta(r,Y(e))),setView:(e,t)=>i(na(r,Y(e),t)),removeTerminal:e=>{let t=Bi(r,`term:${e}`);t&&i(Qi(r,t.id,`term:${e}`))},pruneSessions:e=>i(aa(r,t=>t.type===`terminal`?e.has(t.session):e.has(t.tab.session))),resize:(e,t)=>i(ia(r,e,t)),drop:e=>{c(e.toLeafId),i(Xi(r,e))}}),[r,l,d,i])}var qd=2e3,Jd=T.parse({});function Yd(e){return`puddle.ws.${e}`}function Xd(e){if(e===null)return{kind:`absent`};try{return{kind:`present`,snapshot:T.parse(JSON.parse(e))}}catch{return{kind:`corrupt`}}}function Zd(){let e=we(),[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(Jd),a=(0,K.useRef)(r);a.current=r;let o=(0,K.useRef)(null),s=(0,K.useMemo)(()=>Ht((e,t)=>{B(e,t).catch(e=>console.warn(`ui-state save failed: ${e.message}`))},qd),[]);return(0,K.useEffect)(()=>{if(e===null){o.current=null;return}let t=Yd(e);o.current=t;let r=!1;n(!1),i(Jd);let a;try{a=Xd(sessionStorage.getItem(t)),a.kind===`corrupt`&&sessionStorage.removeItem(t)}catch(e){console.warn(`ui-state read failed: ${e.message}`),a={kind:`absent`}}return a.kind===`present`?(i(a.snapshot),n(!0)):z(e).then(e=>{r||(e&&i(e.ui_state),n(!0))}).catch(e=>{console.warn(`ui-state load failed: ${e.message}`),r||n(!0)}),()=>{r=!0,s.flush()}},[e,s]),{loaded:t,snapshot:r,update(t){if(e===null)return;let n={...a.current,...t};a.current=n,i(n);let r=o.current??Yd(e);s(e,n);try{sessionStorage.setItem(r,JSON.stringify(n))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}}}}function Qd(){return(0,G.jsx)(s,{children:(0,G.jsx)($d,{})})}function $d(){let e=Bt(),t=It(),n=e.id??``,r=/^[0-9a-f]{10}$/.test(n),i=e.sid??null,a=le(r?n:void 0),o=(0,K.useMemo)(()=>a.data?.sessions??[],[a.data]),s=ve(a.data?.project.profile_id).data??[],c=wt(),l=Zd(),u=Ee(),d=u.data??o,f=a.data?.project.profile_id,p=Nt().showAllProjectSessions,m=me(p?f:void 0),h=se(p?f:void 0),g=(0,K.useMemo)(()=>{let e=e=>e.status!==`archived`;if(!p)return[{projectId:n,name:null,sessions:Le(o.filter(e),l.snapshot.session_order)}];let t=Le((m.data??[]).filter(e=>!e.archived),h.data?.projectOrder??[]),r=u.data??o;return t.map(t=>({projectId:t.id,name:t.name,sessions:Le(r.filter(n=>n.project_id===t.id&&e(n)),l.snapshot.session_order)}))},[p,o,n,l.snapshot.session_order,m.data,h.data,u.data]),v=(0,K.useMemo)(()=>o.filter(e=>e.status===`archived`),[o]),y=Kd(l),b=(0,K.useRef)(y);b.current=y;let x=(0,K.useRef)(l);x.current=l;let S=(0,K.useCallback)(e=>x.current.update({session_order:Ie(e,x.current.snapshot.session_order)}),[]),[C,w]=(0,K.useState)(!1),[T,E]=(0,K.useState)(!1),[ee,O]=(0,K.useState)(`agent`),[k,te]=(0,K.useState)(void 0),A=(0,K.useCallback)((e=`agent`)=>{te(void 0),O(e),E(!0)},[]),j=(0,K.useRef)(null),{setHandler:ne}=kt(),[re,M]=(0,K.useState)(null),N=(0,K.useCallback)((e,t,n)=>{y.openEditor(e,{preview:n?.preview}),t&&(e.kind??`file`)===`file`&&M({session:e.session,path:e.path,line:t.line,column:t.column,nonce:Date.now()})},[y]),P=(0,K.useCallback)((e,t,n,r)=>N({kind:`file`,session:e,path:t,...r?.view?{view:r.view}:{}},n,r),[N]);_(P);let ie=(0,K.useCallback)((e,t,n)=>P(e,t,void 0,{preview:n?.preview??!0}),[P]),F=(0,K.useCallback)(e=>y.promote(e),[y]);(0,K.useEffect)(()=>(ne(e=>{te(e?.accountId),O(e?.kind??`agent`),E(!0)}),()=>ne(null)),[ne]);let[ae,oe]=(0,K.useState)(!1);(0,K.useEffect)(()=>{if(!l.loaded||ae)return;let e=Hi(b.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?Se():void 0,e.some(e=>e.type===`editor`)?Ei():void 0]).finally(()=>oe(!0))},[l.loaded,ae]),(0,K.useEffect)(()=>{if(C||!l.loaded||!a.data)return;w(!0);let e=l.snapshot.active_session,r=o.find(t=>t.id===e);!i&&r&&r.status!==`archived`&&t(`/project/${n}/session/${r.id}`,{replace:!0})},[C,l,a.data,o,i,t,n]);let ce=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(ce.current||!l.loaded||!u.data)return;ce.current=!0;let e=new Set(u.data.filter(e=>e.status!==`archived`).map(e=>e.id));b.current.pruneSessions(e);let t=x.current.snapshot.session_order,n=t.filter(t=>e.has(t));n.length!==t.length&&x.current.update({session_order:n})},[l.loaded,u.data]),(0,K.useEffect)(()=>{if(!C)return;if(!i){j.current=null;return}if(i===j.current)return;j.current=null,b.current.ensureTerminal(i,{preview:!0});let e=x.current;e.snapshot.active_session!==i&&e.update({active_session:i})},[C,i]),(0,K.useEffect)(()=>{let e=o.filter(e=>e.status===`waiting_input`).length,t=a.data?.project.name??`puddle`;return document.title=e>0?`● ${e} waiting — ${t}`:`${t} — puddle`,()=>{document.title=`puddle`}},[o,a.data?.project.name]);let I=(0,K.useCallback)(e=>{let r=i===e;r&&(j.current=e),y.removeTerminal(e),r&&(l.update({active_session:null}),t(`/project/${n}`))},[y,l,i,t,n]),ue=(0,K.useCallback)((e,n)=>{if(y.activate(e,n),n.type===`terminal`&&n.session!==i){let e=d.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[y,t,d,i]),de=(0,K.useCallback)((e,r)=>{y.close(e,r),r.type===`terminal`&&r.session===i&&(j.current=r.session,l.update({active_session:null}),t(`/project/${n}`))},[y,i,l,t,n]),fe=(0,K.useCallback)((e,n,r)=>{if(y.drop({ref:n,fromLeafId:e,toLeafId:e,edge:r}),n.type===`terminal`&&n.session!==i){let e=d.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[y,i,d,t]),L=y.focusedLeaf.tabs.find(e=>Y(e)===y.focusedLeaf.activeKey)??null,pe=Ci(d,(L===null?null:L.type===`terminal`?L.session:L.tab.session)??i,l),R=pe.session,he=Ws(l.snapshot.sidebar_mode),ge=l.snapshot.sidebar_collapsed,_e=l.snapshot.sessions_collapsed,z=(0,K.useCallback)(e=>{let t=y.focusedLeaf,n=t.tabs.find(e=>Y(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){D.error(`Focus a terminal or agent to insert`);return}xt.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[y]);(0,K.useEffect)(()=>(Pt(z),()=>Pt(null)),[z]);let ye=(0,K.useRef)({}),be=e=>l.update({sidebar_mode:e,sidebar_collapsed:!1});ye.current={"tab.close":()=>{let e=y.focusedLeaf,t=e.tabs.find(t=>Y(t)===e.activeKey);t&&de(e.id,t)},"sidebar.left":()=>l.update({sidebar_collapsed:!l.snapshot.sidebar_collapsed}),"sidebar.right":()=>l.update({sessions_collapsed:!l.snapshot.sessions_collapsed}),"nav.files":()=>be(`files`),"nav.search":()=>be(`search`),"nav.changes":()=>be(`changes`),"nav.worktrees":()=>be(`worktrees`),"session.newAgent":()=>A(`agent`),"session.newTerminal":()=>A(`terminal`)},(0,K.useEffect)(()=>{let e=Object.keys(ye.current).map(e=>Ft(e,()=>ye.current[e]?.()));return()=>e.forEach(e=>e())},[]);let B=y.activeEditorTab,xe=B?.kind===`diff`&&R&&B.session===R.id?B.path:null,Ce=B&&(B.kind??`file`)===`file`&&R&&B.session===R.id?B.path:null,we=e=>{R&&N({kind:`diff`,session:R.id,path:e})},Te=(e,t)=>{R&&N({kind:`commit`,session:R.id,path:e,sha:t})},De=(e,t)=>{R&&P(R.id,e,t===void 0?void 0:{line:t,column:1})},Oe=(0,K.useCallback)(e=>l.update({layout:{...l.snapshot.layout,...e}}),[l]),ke=ua(l.snapshot.layout,[...ge?[]:[`nav`],`main`,..._e?[]:[`sessions`]]);return r?!l.loaded||!a.data||!ae?(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`}):(0,G.jsxs)(`div`,{className:`flex h-full`,children:[ge&&(0,G.jsx)(Gs,{mode:he,onExpand:()=>l.update({sidebar_collapsed:!1}),onSelect:e=>l.update({sidebar_collapsed:!1,sidebar_mode:e})}),(0,G.jsxs)(gi,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:ke,onLayoutChanged:Oe,children:[!ge&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,children:(0,G.jsx)(Ks,{mode:he,onModeChange:e=>l.update({sidebar_mode:e}),onCollapse:()=>l.update({sidebar_collapsed:!0}),projectId:n,repoId:a.data.project.repo_id,sessions:o,target:pe,onOpenFile:ie,activeFilePath:Ce,activeDiffPath:xe,onOpenDiff:we,onOpenCommitFile:Te,onOpenSearchFile:De})}),(0,G.jsx)(Si,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`})]}),(0,G.jsx)(yi,{id:`main`,children:(0,G.jsx)(ca,{tree:y.tree,onOpenFile:(e,t,n,r)=>P(e,t,n===void 0?void 0:{line:n,column:r}),children:(0,G.jsx)(`div`,{className:`flex h-full flex-col bg-ground`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(jd,{onDrop:y.drop,renderOverlay:e=>{let t=e.type===`terminal`?d.find(t=>t.id===e.session):void 0;return(0,G.jsx)(`div`,{className:`rounded-md bg-elevated px-2.5 py-1 text-xs font-mono text-fg shadow-lg`,children:e.type===`terminal`?t?c(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,G.jsx)(Wd,{tree:y.tree,sessions:d,reveal:re,onActivateTab:ue,onCloseTab:de,onPromoteTab:F,onArchived:I,onFocusLeaf:y.focusLeaf,onResize:y.resize,onDropTab:fe,onSetTabView:y.setView})})})})})}),!_e&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Si,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`}),(0,G.jsx)(yi,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,children:(0,G.jsx)(lc,{groups:g,accounts:s,activeSessionId:i,onReorder:S,onPromote:e=>y.ensureTerminal(e),archived:v,onNewSession:()=>A(`agent`),onNewTerminal:()=>A(`terminal`),onCollapse:()=>l.update({sessions_collapsed:!0}),onArchived:I})})]}),(0,G.jsx)(qs,{projectId:n,repoId:a.data.project.repo_id,open:T,kind:ee,seedAccountId:k,onOpenChange:E,onCreated:e=>void t(`/project/${n}/session/${e.id}`)})]}),_e&&(0,G.jsx)(sc,{groups:g,activeSessionId:i,onReorder:S,onPromote:e=>y.ensureTerminal(e),onExpand:()=>l.update({sessions_collapsed:!1}),onNewTerminal:()=>A(`terminal`),onNewSession:()=>A(`agent`),onArchived:I})]}):null}export{Qd as Workspace};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{A as r,C as i,E as a,O as o,S as s,T as c,_ as l,b as u,d,f,j as p,m,p as h,v as g,w as _,x as ee,y as v}from"./dialog-B43iKmfK.js";import{ct as y,dt as b,ft as x,lt as S,ot as C,st as w,ut as T}from"./LazyTerminal-BihPI9J1.js";import{t as E}from"./utils-B6KiDbIe.js";import{t as D}from"./createLucideIcon-DyMAgLa3.js";import{i as te,n as O,t as ne}from"./dist-VDiYuPKw.js";var k=D(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),A=D(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]);function re(e){let t=Date.parse(e.created_at);return Number.isNaN(t)?0:t}function j(e,t){let n=new Map(t.map((e,t)=>[e,t])),r=[],i=[];for(let t of e)(n.has(t.id)?r:i).push(t);return r.sort((e,t)=>n.get(e.id)-n.get(t.id)),i.sort((e,t)=>re(t)-re(e)),[...i,...r]}function M(e,t,n){if(t===n)return[...e];let r=e.filter(e=>e!==t),i=r.indexOf(n);return i===-1?[...e]:(r.splice(i,0,t),r)}function N(e,t,n){if(t===n)return null;let r=e.find(e=>e.sessions.some(e=>e.id===t));if(!r||!r.sessions.some(e=>e.id===n))return null;let i=e.flatMap(e=>e.sessions.map(e=>e.id)),a=M(i,t,n);return a.some((e,t)=>e!==i[t])?a:null}function ie(e,t){let n=new Set(e);return[...e,...t.filter(e=>!n.has(e))]}var P=e(t(),1),F=!1;function ae(){let[e,t]=P.useState(F);return P.useEffect(()=>{F||(F=!0,t(!0))},[]),e}var I=P.useSyncExternalStore;function oe(){return()=>{}}function se(){return I(oe,()=>!0,()=>!1)}var ce=typeof I==`function`?se:ae,L=n(),le=`rovingFocusGroup.onEntryFocus`,ue={bubbles:!1,cancelable:!0},R=`RovingFocusGroup`,[de,fe,pe]=O(R),[me,he]=o(R,[pe]),[ge,_e]=me(R),ve=P.forwardRef((e,t)=>(0,L.jsx)(de.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(de.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(ye,{...e,ref:t})})}));ve.displayName=R;var ye=P.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:a,loop:o=!1,dir:s,currentTabStopId:c,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:m=!1,...h}=e,g=P.useRef(null),ee=r(t,g),v=ne(s),[y,b]=l({prop:c,defaultProp:u??null,onChange:d,caller:R}),[x,S]=P.useState(!1),C=i(f),w=fe(n),T=P.useRef(!1),[E,D]=P.useState(0);return P.useEffect(()=>{let e=g.current;if(e)return e.addEventListener(le,C),()=>e.removeEventListener(le,C)},[C]),(0,L.jsx)(ge,{scope:n,orientation:a,dir:v,loop:o,currentTabStopId:y,onItemFocus:P.useCallback(e=>b(e),[b]),onItemShiftTab:P.useCallback(()=>S(!0),[]),onFocusableItemAdd:P.useCallback(()=>D(e=>e+1),[]),onFocusableItemRemove:P.useCallback(()=>D(e=>e-1),[]),children:(0,L.jsx)(_.div,{tabIndex:x||E===0?-1:0,"data-orientation":a,...h,ref:ee,style:{outline:`none`,...e.style},onMouseDown:p(e.onMouseDown,()=>{T.current=!0}),onFocus:p(e.onFocus,e=>{let t=!T.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(le,ue);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=w().filter(e=>e.focusable);Te([e.find(e=>e.active),e.find(e=>e.id===y),...e].filter(Boolean).map(e=>e.ref.current),m)}}T.current=!1}),onBlur:p(e.onBlur,()=>S(!1))})})}),be=`RovingFocusGroupItem`,xe=P.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=u(),l=a||c,d=_e(be,n),f=d.currentTabStopId===l,m=fe(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:v}=d,y=ce();return ee(()=>{if(!(!y||!r))return h(),()=>g()},[y,r,h,g]),P.useEffect(()=>{if(!(y||!r))return h(),()=>g()},[y,r,h,g]),(0,L.jsx)(de.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,L.jsx)(_.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...s,ref:t,onMouseDown:p(e.onMouseDown,e=>{r?d.onItemFocus(l):e.preventDefault()}),onFocus:p(e.onFocus,()=>d.onItemFocus(l)),onKeyDown:p(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=we(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=m().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?Ee(n,r+1):n.slice(r+1)}setTimeout(()=>Te(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:v!=null}):o})})});xe.displayName=be;var Se={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ce(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function we(e,t,n){let r=Ce(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Se[r]}function Te(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ee(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var De=ve,Oe=xe,ke=[`Enter`,` `],Ae=[`ArrowDown`,`PageUp`,`Home`],je=[`ArrowUp`,`PageDown`,`End`],Me=[...Ae,...je],Ne={ltr:[...ke,`ArrowRight`],rtl:[...ke,`ArrowLeft`]},Pe={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},z=`Menu`,[B,Fe,Ie]=O(z),[V,Le]=o(z,[Ie,x,he]),H=x(),Re=he(),[ze,U]=V(z),[Be,W]=V(z),Ve=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:o,modal:s=!0}=e,c=H(t),[l,u]=P.useState(null),d=P.useRef(!1),f=i(o),p=ne(a);return P.useEffect(()=>{let e=()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),P.useEffect(()=>{if(!n)return;let e=()=>f(!1);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,f]),(0,L.jsx)(b,{...c,children:(0,L.jsx)(ze,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:(0,L.jsx)(Be,{scope:t,onClose:P.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:s,children:r})})})};Ve.displayName=z;var He=`MenuAnchor`,Ue=P.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=H(n);return(0,L.jsx)(y,{...i,...r,ref:t})});Ue.displayName=He;var We=`MenuPortal`,[Ge,Ke]=V(We,{forceMount:void 0}),qe=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=U(We,t);return(0,L.jsx)(Ge,{scope:t,forceMount:n,children:(0,L.jsx)(g,{present:n||a.open,children:(0,L.jsx)(v,{asChild:!0,container:i,children:r})})})};qe.displayName=We;var G=`MenuContent`,[Je,Ye]=V(G),Xe=P.forwardRef((e,t)=>{let n=Ke(G,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=U(G,e.__scopeMenu),o=W(G,e.__scopeMenu);return(0,L.jsx)(B.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(g,{present:r||a.open,children:(0,L.jsx)(B.Slot,{scope:e.__scopeMenu,children:o.modal?(0,L.jsx)(Ze,{...i,ref:t}):(0,L.jsx)(Qe,{...i,ref:t})})})})}),Ze=P.forwardRef((e,t)=>{let n=U(G,e.__scopeMenu),i=P.useRef(null),a=r(t,i);return P.useEffect(()=>{let e=i.current;if(e)return d(e)},[]),(0,L.jsx)(et,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:p(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Qe=P.forwardRef((e,t)=>{let n=U(G,e.__scopeMenu);return(0,L.jsx)(et,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),$e=a(`MenuContent.ScrollLock`),et=P.forwardRef((e,t)=>{let{__scopeMenu:n,loop:i=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:c,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:g,onFocusOutside:_,onInteractOutside:ee,onDismiss:v,disableOutsideScroll:y,...b}=e,x=U(G,n),S=W(G,n),C=H(n),w=Re(n),E=Fe(n),[D,te]=P.useState(null),O=P.useRef(null),ne=r(t,O,x.onContentChange),k=P.useRef(0),A=P.useRef(``),re=P.useRef(0),j=P.useRef(null),M=P.useRef(`right`),N=P.useRef(0),ie=y?f:P.Fragment,F=y?{as:$e,allowPinchZoom:!0}:void 0,ae=e=>{let t=A.current+e,n=E().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Pt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){A.current=t,window.clearTimeout(k.current),t!==``&&(k.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};P.useEffect(()=>()=>window.clearTimeout(k.current),[]),h();let I=P.useCallback(e=>M.current===j.current?.side&&It(e,j.current?.area),[]);return(0,L.jsx)(Je,{scope:n,searchRef:A,onItemEnter:P.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:P.useCallback(e=>{I(e)||(O.current?.focus(),te(null))},[I]),onTriggerLeave:P.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:re,onPointerGraceIntentChange:P.useCallback(e=>{j.current=e},[]),children:(0,L.jsx)(ie,{...F,children:(0,L.jsx)(m,{asChild:!0,trapped:a,onMountAutoFocus:p(o,e=>{e.preventDefault(),O.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:(0,L.jsx)(s,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:g,onFocusOutside:_,onInteractOutside:ee,onDismiss:v,children:(0,L.jsx)(De,{asChild:!0,...w,dir:S.dir,orientation:`vertical`,loop:i,currentTabStopId:D,onCurrentTabStopIdChange:te,onEntryFocus:p(u,e=>{S.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,L.jsx)(T,{role:`menu`,"aria-orientation":`vertical`,"data-state":At(x.open),"data-radix-menu-content":``,dir:S.dir,...C,...b,ref:ne,style:{outline:`none`,...b.style},onKeyDown:p(b.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ae(e.key));let i=O.current;if(e.target!==i||!Me.includes(e.key))return;e.preventDefault();let a=E().filter(e=>!e.disabled).map(e=>e.ref.current);je.includes(e.key)&&a.reverse(),Mt(a)}),onBlur:p(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(k.current),A.current=``)}),onPointerMove:p(e.onPointerMove,X(e=>{let t=e.target,n=N.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>N.current?`right`:`left`;M.current=t,N.current=e.clientX}}))})})})})})})});Xe.displayName=G;var tt=`MenuGroup`,nt=P.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(_.div,{role:`group`,...r,ref:t})});nt.displayName=tt;var rt=`MenuLabel`,it=P.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(_.div,{...r,ref:t})});it.displayName=rt;var K=`MenuItem`,at=`menu.itemSelect`,q=P.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:i,...a}=e,o=P.useRef(null),s=W(K,e.__scopeMenu),l=Ye(K,e.__scopeMenu),u=r(t,o),d=P.useRef(!1),f=()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(at,{bubbles:!0,cancelable:!0});e.addEventListener(at,e=>i?.(e),{once:!0}),c(e,t),t.defaultPrevented?d.current=!1:s.onClose()}};return(0,L.jsx)(ot,{...a,ref:u,disabled:n,onClick:p(e.onClick,f),onPointerDown:t=>{e.onPointerDown?.(t),d.current=!0},onPointerUp:p(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:p(e.onKeyDown,e=>{n||e.target!==e.currentTarget||l.searchRef.current!==``&&e.key===` `||ke.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});q.displayName=K;var ot=P.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:i=!1,textValue:a,...o}=e,s=Ye(K,n),c=Re(n),l=P.useRef(null),u=r(t,l),[d,f]=P.useState(!1),[m,h]=P.useState(``);return P.useEffect(()=>{let e=l.current;e&&h((e.textContent??``).trim())},[o.children]),(0,L.jsx)(B.ItemSlot,{scope:n,disabled:i,textValue:a??m,children:(0,L.jsx)(Oe,{asChild:!0,...c,focusable:!i,children:(0,L.jsx)(_.div,{role:`menuitem`,"data-highlighted":d?``:void 0,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,...o,ref:u,onPointerMove:p(e.onPointerMove,X(e=>{i?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:p(e.onPointerLeave,X(e=>s.onItemLeave(e))),onFocus:p(e.onFocus,()=>f(!0)),onBlur:p(e.onBlur,()=>f(!1))})})})}),st=`MenuCheckboxItem`,ct=P.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,L.jsx)(gt,{scope:e.__scopeMenu,checked:n,children:(0,L.jsx)(q,{role:`menuitemcheckbox`,"aria-checked":Y(n)?`mixed`:n,...i,ref:t,"data-state":jt(n),onSelect:p(i.onSelect,()=>r?.(Y(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ct.displayName=st;var lt=`MenuRadioGroup`,[ut,dt]=V(lt,{value:void 0,onValueChange:()=>{}}),ft=P.forwardRef((e,t)=>{let{value:n,onValueChange:r,...a}=e,o=i(r);return(0,L.jsx)(ut,{scope:e.__scopeMenu,value:n,onValueChange:o,children:(0,L.jsx)(nt,{...a,ref:t})})});ft.displayName=lt;var pt=`MenuRadioItem`,mt=P.forwardRef((e,t)=>{let{value:n,...r}=e,i=dt(pt,e.__scopeMenu),a=n===i.value;return(0,L.jsx)(gt,{scope:e.__scopeMenu,checked:a,children:(0,L.jsx)(q,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":jt(a),onSelect:p(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});mt.displayName=pt;var ht=`MenuItemIndicator`,[gt,_t]=V(ht,{checked:!1}),vt=P.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=_t(ht,n);return(0,L.jsx)(g,{present:r||Y(a.checked)||a.checked===!0,children:(0,L.jsx)(_.span,{...i,ref:t,"data-state":jt(a.checked)})})});vt.displayName=ht;var yt=`MenuSeparator`,bt=P.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(_.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});bt.displayName=yt;var xt=`MenuArrow`,St=P.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=H(n);return(0,L.jsx)(S,{...i,...r,ref:t})});St.displayName=xt;var Ct=`MenuSub`,[wt,Tt]=V(Ct),Et=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:a}=e,o=U(Ct,t),s=H(t),[c,l]=P.useState(null),[d,f]=P.useState(null),p=i(a);return P.useEffect(()=>(o.open===!1&&p(!1),()=>p(!1)),[o.open,p]),(0,L.jsx)(b,{...s,children:(0,L.jsx)(ze,{scope:t,open:r,onOpenChange:p,content:d,onContentChange:f,children:(0,L.jsx)(wt,{scope:t,contentId:u(),triggerId:u(),trigger:c,onTriggerChange:l,children:n})})})};Et.displayName=Ct;var J=`MenuSubTrigger`,Dt=P.forwardRef((e,t)=>{let n=U(J,e.__scopeMenu),i=W(J,e.__scopeMenu),a=Tt(J,e.__scopeMenu),o=Ye(J,e.__scopeMenu),s=P.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:l}=o,u={__scopeMenu:e.__scopeMenu},d=P.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);P.useEffect(()=>d,[d]),P.useEffect(()=>{let e=c.current;return()=>{window.clearTimeout(e),l(null)}},[c,l]);let f=r(t,a.onTriggerChange);return(0,L.jsx)(Ue,{asChild:!0,...u,children:(0,L.jsx)(ot,{id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?a.contentId:void 0,"data-state":At(n.open),...e,ref:f,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:p(e.onPointerMove,X(t=>{o.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:p(e.onPointerLeave,X(e=>{d();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,a=i?-5:5,s=t[i?`left`:`right`],l=t[i?`right`:`left`];o.onPointerGraceIntentChange({area:[{x:e.clientX+a,y:e.clientY},{x:s,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:s,y:t.bottom}],side:r}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:p(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||o.searchRef.current!==``&&t.key===` `||Ne[i.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Dt.displayName=J;var Ot=`MenuSubContent`,kt=P.forwardRef((e,t)=>{let n=Ke(G,e.__scopeMenu),{forceMount:i=n.forceMount,align:a=`start`,...o}=e,s=U(G,e.__scopeMenu),c=W(G,e.__scopeMenu),l=Tt(Ot,e.__scopeMenu),u=P.useRef(null),d=r(t,u);return(0,L.jsx)(B.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(g,{present:i||s.open,children:(0,L.jsx)(B.Slot,{scope:e.__scopeMenu,children:(0,L.jsx)(et,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:d,align:a,side:c.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{c.isUsingKeyboardRef.current&&u.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:p(e.onFocusOutside,e=>{e.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:p(e.onEscapeKeyDown,e=>{c.onClose(),e.preventDefault()}),onKeyDown:p(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Pe[c.dir].includes(e.key);t&&n&&(s.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});kt.displayName=Ot;function At(e){return e?`open`:`closed`}function Y(e){return e===`indeterminate`}function jt(e){return Y(e)?`indeterminate`:e?`checked`:`unchecked`}function Mt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Nt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Pt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Nt(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Ft(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function It(e,t){return t?Ft({x:e.clientX,y:e.clientY},t):!1}function X(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Lt=Ve,Rt=Ue,zt=qe,Bt=Xe,Vt=nt,Ht=it,Ut=q,Wt=ct,Gt=ft,Kt=mt,qt=vt,Jt=bt,Yt=St,Xt=Et,Zt=Dt,Qt=kt,Z=`ContextMenu`,[$t,en]=o(Z,[Le]),Q=Le(),[tn,nn]=$t(Z),rn=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,dir:a,modal:o=!0}=e,s=P.useRef(!1);{let e=P.useRef(!1);P.useEffect(()=>{i===!0&&!s.current&&!e.current&&(e.current=!0,console.warn("ContextMenu: The `open` prop has been set to `true` before the user has interacted with the trigger, so its position is indeterminate. This is likely unintended and will result in the menu being anchored to the top-left corner of the viewport."))},[i])}let[c,u]=l({prop:i,defaultProp:!1,onChange:r,caller:Z}),d=Q(t);return(0,L.jsx)(tn,{scope:t,open:c,onOpenChange:u,modal:o,hasInteractedRef:s,children:(0,L.jsx)(Lt,{...d,dir:a,open:c,onOpenChange:u,modal:o,children:n})})};rn.displayName=Z;var an=`ContextMenuTrigger`,on=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=nn(an,n),o=Q(n),[s,c]=P.useState({x:0,y:0}),l=P.useMemo(()=>({current:{getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s})}}),[s]),u=P.useRef(0),d=P.useCallback(()=>window.clearTimeout(u.current),[]),f=e=>{a.hasInteractedRef.current=!0,c({x:e.clientX,y:e.clientY}),a.onOpenChange(!0)};return P.useEffect(()=>d,[d]),P.useEffect(()=>void(r&&d()),[r,d]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Rt,{...o,virtualRef:l}),(0,L.jsx)(_.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:p(e.onContextMenu,e=>{d(),f(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:p(e.onPointerDown,$(e=>{d(),a.open&&a.onOpenChange(!1),u.current=window.setTimeout(()=>f(e),700)})),onPointerMove:r?e.onPointerMove:p(e.onPointerMove,$(d)),onPointerCancel:r?e.onPointerCancel:p(e.onPointerCancel,$(d)),onPointerUp:r?e.onPointerUp:p(e.onPointerUp,$(d))})]})});on.displayName=an;var sn=`ContextMenuPortal`,cn=e=>{let{__scopeContextMenu:t,...n}=e,r=Q(t);return(0,L.jsx)(zt,{...r,...n})};cn.displayName=sn;var ln=`ContextMenuContent`,un=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=nn(ln,n),a=Q(n),o=P.useRef(!1);return(0,L.jsx)(Bt,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});un.displayName=ln;var dn=`ContextMenuGroup`,fn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Vt,{...i,...r,ref:t})});fn.displayName=dn;var pn=`ContextMenuLabel`,mn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Ht,{...i,...r,ref:t})});mn.displayName=pn;var hn=`ContextMenuItem`,gn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Ut,{...i,...r,ref:t})});gn.displayName=hn;var _n=`ContextMenuCheckboxItem`,vn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Wt,{...i,...r,ref:t})});vn.displayName=_n;var yn=`ContextMenuRadioGroup`,bn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Gt,{...i,...r,ref:t})});bn.displayName=yn;var xn=`ContextMenuRadioItem`,Sn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Kt,{...i,...r,ref:t})});Sn.displayName=xn;var Cn=`ContextMenuItemIndicator`,wn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(qt,{...i,...r,ref:t})});wn.displayName=Cn;var Tn=`ContextMenuSeparator`,En=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Jt,{...i,...r,ref:t})});En.displayName=Tn;var Dn=`ContextMenuArrow`,On=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Yt,{...i,...r,ref:t})});On.displayName=Dn;var kn=`ContextMenuSub`,An=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:a}=e,o=Q(t),[s,c]=l({prop:i,defaultProp:a??!1,onChange:r,caller:kn});return(0,L.jsx)(Xt,{...o,open:s,onOpenChange:c,children:n})};An.displayName=kn;var jn=`ContextMenuSubTrigger`,Mn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Zt,{...i,...r,ref:t})});Mn.displayName=jn;var Nn=`ContextMenuSubContent`,Pn=P.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Q(n);return(0,L.jsx)(Qt,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Pn.displayName=Nn;function $(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var Fn=rn,In=on,Ln=cn,Rn=un,zn=gn,Bn=En,Vn=An,Hn=Mn,Un=Pn,Wn=Fn,Gn=In,Kn=Vn;function qn({className:e,...t}){return(0,L.jsx)(Ln,{children:(0,L.jsx)(Rn,{className:E(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...t})})}function Jn({className:e,...t}){return(0,L.jsx)(zn,{className:E(w,C,`[&_svg]:size-3.5`,e),...t})}function Yn({className:e,children:t,...n}){return(0,L.jsxs)(Hn,{className:E(w,C,`data-[state=open]:bg-action data-[state=open]:text-action-ink [&_svg]:size-3.5`,e),...n,children:[t,(0,L.jsx)(te,{className:`ml-auto`})]})}function Xn({className:e,...t}){return(0,L.jsx)(Ln,{children:(0,L.jsx)(Un,{className:E(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...t})})}function Zn({className:e,...t}){return(0,L.jsx)(Bn,{className:E(`-mx-1 my-1 h-px bg-border`,e),...t})}export{A,Qt as C,N as D,ie as E,j as O,Xt as S,Le as T,zt as _,Kn as a,Lt as b,Gn as c,Wt as d,Bt as f,Ht as g,qt as h,Zn as i,k as j,M as k,Rt as l,Ut as m,qn as n,Xn as o,Vt as p,Jn as r,Yn as s,Wn as t,Yt as u,Gt as v,Zt as w,Jt as x,Kt as y};