@puddle-code/cli 0.1.2 → 0.1.4

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 (24) hide show
  1. package/CHANGELOG.md +4 -5
  2. package/dist/index.js +4 -2
  3. package/dist/public/assets/{Dashboard-BhJZAZkm.js → Dashboard-B8Hx3xxa.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-D5-9GTuN.js → EditorTabClose-DOvQ8kvf.js} +1 -1
  5. package/dist/public/assets/{LazyTerminal-DpW_dV8-.js → LazyTerminal-BYhuJK76.js} +2 -2
  6. package/dist/public/assets/{ModelRefcount-Bc70ux--.js → ModelRefcount-CCRR4bB-.js} +1 -1
  7. package/dist/public/assets/{PaneEditorBody-DPfYk1MG.js → PaneEditorBody-CRFah0Fn.js} +1 -1
  8. package/dist/public/assets/{SettingsDialog-C1YGjO8w.js → SettingsDialog-CME31mEV.js} +1 -1
  9. package/dist/public/assets/Terminal-q3Ry1DbU.js +60 -0
  10. package/dist/public/assets/{Workspace-HBspP42h.js → Workspace-BwvHtfuB.js} +3 -3
  11. package/dist/public/assets/{buffer-store-Ch_ccGob.js → buffer-store-eUpqFE4J.js} +2 -2
  12. package/dist/public/assets/{context-menu-BIpVA6AC.js → context-menu-DByGBkiO.js} +1 -1
  13. package/dist/public/assets/{cssMode-DP2qOqv1.js → cssMode-BL3M5qYD.js} +1 -1
  14. package/dist/public/assets/{drafts-CyZAHsxG.js → drafts-CKYJHEPP.js} +1 -1
  15. package/dist/public/assets/{file-links-DhiBZF5y.js → file-links-ezBU7rQX.js} +1 -1
  16. package/dist/public/assets/{htmlMode-DDBP46Y_.js → htmlMode-DLHzULSB.js} +1 -1
  17. package/dist/public/assets/{index-CzVID1ZA.js → index-CYm7O8SE.js} +3 -3
  18. package/dist/public/assets/{jsonMode-B-208CCp.js → jsonMode-CPjeUQaz.js} +1 -1
  19. package/dist/public/assets/{session-seed-YCLBYoEN.js → session-seed-BDCRZt-r.js} +1 -1
  20. package/dist/public/assets/{tsMode-BOmmwl1s.js → tsMode-DWv7nQWq.js} +1 -1
  21. package/dist/public/assets/{use-find-controls-Bs5HCbAh.js → use-find-controls-CT0S98qk.js} +1 -1
  22. package/dist/public/index.html +2 -2
  23. package/package.json +1 -1
  24. package/dist/public/assets/Terminal-DmMk3PAE.js +0 -60
@@ -1,7 +1,7 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-DPfYk1MG.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/x-BJOrp_m5.js","assets/hotkeys-CekBkaTu.js","assets/editor-context-DBjXfTll.js","assets/preload-helper-Czpn1I53.js","assets/use-find-controls-Bs5HCbAh.js","assets/file-links-DhiBZF5y.js","assets/index-CzVID1ZA.js","assets/dialog-DjL0qoAv.js","assets/LazyTerminal-DpW_dV8-.js","assets/index-BBk5N4Nn.css","assets/chevron-down-59O6CgEo.js","assets/editor.api2-4X9Vh9Zw.js","assets/editor-Br_kD0ds.css","assets/buffer-store-Ch_ccGob.js","assets/buffer-logic-BAkSBQT7.js","assets/drafts-CyZAHsxG.js","assets/editor-sync-W1bamxAP.js","assets/PaneEditorBody-Dz-67XSV.css","assets/ModelRefcount-Bc70ux--.js","assets/EditorTabClose-D5-9GTuN.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,o as i,r as a,t as o}from"./x-BJOrp_m5.js";import{B as s,C as c,D as l,Ht as u,K as d,L as f,O as p,Ot as m,R as h,St as g,T as _,X as v,_t as y,at as b,ct as x,dt as S,ft as C,gt as w,ht as T,k as E,kt as D,lt as O,nt as k,p as A,pt as j,q as M,qt as ee,st as te,tt as ne,u as N,ut as P,v as re,x as ie,xt as F,yt as I,zt as L}from"./hotkeys-CekBkaTu.js";import{B as ae,C as oe,D as se,E as R,I as ce,L as le,P as ue,R as de,S as fe,T as z,_ as pe,b as B,c as me,h as he,i as ge,j as V,k as _e,l as ve,o as ye,r as be,s as xe,t as Se,u as Ce,v as we,w as Te,x as Ee,y as De,z as Oe}from"./editor-context-DBjXfTll.js";import{t as ke}from"./preload-helper-Czpn1I53.js";import{A as Ae,C as je,D as Me,a as Ne,g as Pe,h as H,i as Fe,k as Ie,n as Le,o as Re,r as ze,t as Be,y as Ve}from"./dialog-DjL0qoAv.js";import{a as He,c as Ue,i as We,l as Ge,m as Ke,n as qe,o as Je,p as Ye,r as Xe,s as Ze,t as Qe}from"./LazyTerminal-DpW_dV8-.js";import{A as $e,C as et,D as tt,E as nt,M as rt,O as it,S as at,T as ot,_ as st,a as ct,b as lt,c as ut,d as dt,f as ft,g as pt,h as mt,i as ht,j as gt,k as _t,l as vt,m as yt,n as bt,o as xt,p as St,r as U,s as Ct,t as wt,u as Tt,v as Et,w as Dt,x as Ot,y as kt}from"./context-menu-BIpVA6AC.js";import{a as At,i as jt,o as Mt,r as Nt,s as Pt,t as Ft}from"./file-links-DhiBZF5y.js";import{a as It,i as Lt,n as Rt,o as zt,r as Bt,t as Vt}from"./session-seed-YCLBYoEN.js";import{t as Ht}from"./chevron-down-59O6CgEo.js";import{r as Ut}from"./dist-DDFe8e3m.js";import{A as Wt,At as W,B as Gt,Bt as G,C as Kt,D as qt,Dt as Jt,E as Yt,Et as Xt,F as Zt,Ft as Qt,Ht as K,It as $t,Lt as en,M as tn,N as q,Nt as nn,O as rn,Ot as an,Pt as on,Qt as sn,Rt as cn,S as ln,T as un,U as dn,V as fn,Vt as J,Xt as pn,Z as mn,Zt as hn,_ as gn,b as _n,bt as vn,c as yn,ct as bn,d as xn,dt as Sn,f as Cn,g as wn,gt as Tn,h as En,ht as Dn,i as On,it as kn,j as An,k as jn,kt as Mn,l as Nn,lt as Pn,m as Fn,mt as In,n as Ln,nt as Rn,o as zn,p as Bn,pt as Vn,s as Hn,st as Un,t as Wn,u as Gn,ut as Kn,v as qn,vt as Jn,w as Yn,x as Xn,xt as Zn,y as Qn,z as $n}from"./index-CzVID1ZA.js";import{a as er,t as tr}from"./drafts-CyZAHsxG.js";import{i as nr}from"./buffer-logic-BAkSBQT7.js";var rr=r(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),ir=r(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),ar=r(`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`}]]),or=r(`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`}]]),sr=r(`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`}]]),cr=r(`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`}]]),lr=r(`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`}]]),ur=r(`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`}]]),Y=r(`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`}]]),dr=r(`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`}]]),fr=r(`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`}]]),pr=r(`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`}]]),mr=r(`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`}]]),hr=r(`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`}]]),gr=r(`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`}]]),_r=r(`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`}]]),vr=r(`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`}]]),yr=r(`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`}]]),br=r(`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`}]]),xr=r(`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`}]]),Sr=r(`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`}]]),Cr=r(`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`}]]),wr=r(`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`}]]),Tr=r(`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`}]]),Er=r(`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`}]]),Dr=r(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),Or=r(`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`}]]),kr=r(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Ar=r(`message-circle-x`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),jr=r(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Mr=r(`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`}]]),Nr=r(`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`}]]),Pr=r(`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`}]]),Fr=r(`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`}]]),Ir=r(`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`}]]),Lr=r(`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`}]]),Rr=r(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),zr=r(`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`}]]),Br=r(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Vr=r(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Hr=r(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Ur=r(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Wr=r(`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`}]]),X=n(),Z=e(t(),1);function Gr(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Kr(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function qr(e){return e/100*window.innerHeight}function Jr(e){return e/100*window.innerWidth}function Yr(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 Xr({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Yr(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Kr(t,i);break;case`em`:r=Gr(t,i);break;case`vh`:r=qr(i);break;case`vw`:r=Jr(i);break}return r}function Zr(e){return parseFloat(e.toFixed(3))}function Qr({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 $r(e){let{panels:t}=e,n=Qr({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=Zr(Xr({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Zr(Xr({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Zr(Xr({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Zr(Xr({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 ei(e,t){return Array.from(t).sort(e===`horizontal`?ti:ni)}function ti(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function ni(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function ri(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function ii(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 ai({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}=ii(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Q(i,`No rect found`),i}var oi;function si(){return oi===void 0&&(oi=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),oi}function ci(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=ei(n,Array.from(t.children).filter(ri).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,ai({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=si()?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:Qr({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 li=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)}}},ui={cursorFlags:0,state:`inactive`},di=new li;function fi(){return ui}function pi(e){return di.addListener(`change`,e)}function mi(e){let t=ui,n={...ui};n.cursorFlags=e,ui=n,di.emit(`change`,{prev:t,next:n})}function hi(e){let t=ui;ui=e,di.emit(`change`,{prev:t,next:e})}var gi=e=>e,_i=()=>{},vi=1,yi=2,bi=4,xi=8,Si=3,Ci=12,wi;function Ti(){return wi===void 0&&(wi=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(wi=!0)),wi}function Ei({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&&Ti()){let t=(e&vi)!==0,n=(e&yi)!==0,r=(e&bi)!==0,i=(e&xi)!==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 Ti()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Di=new WeakMap;function Oi(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Di.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=fi();switch(r.state){case`active`:case`hover`:{let e=Ei({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}Di.set(e,{prevStyle:t,styleSheet:n})}var ki=new Map,Ai=new li;function ji(e){ki=new Map(ki),ki.delete(e)}function Mi(e,t){for(let[t]of ki)if(t.id===e)return t}function Ni(e,t){for(let[t,n]of ki)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Pi(){return ki}function Fi(e,t){return Ai.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Ii(e,t,n){let r=ki.get(e);ki=new Map(ki),ki.set(e,t),Ai.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Li(e){let t=fi(),n=!1;switch(t.state){case`active`:hi({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Oi(e),n=!0,t.hitRegions.forEach(e=>{let t=Ni(e.group.id,!0);Ii(e.group,t,{isUserInteraction:!0})}))}return n}function Ri(e){e.defaultPrevented||Li(e.currentTarget)}function zi(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=ii(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 Bi(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Vi(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:qi(e),b:qi(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:Ki(Gi(n.a)),b:Ki(Gi(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 Hi=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ui(e){let t=getComputedStyle(Ji(e)??e).display;return t===`flex`||t===`inline-flex`}function Wi(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Ui(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`||Hi.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Gi(e){let t=e.length;for(;t--;){let n=e[t];if(Q(n,`Missing node`),Wi(n))return n}return null}function Ki(e){return e&&Number(getComputedStyle(e).zIndex)||0}function qi(e){let t=[];for(;e;)t.push(e),e=Ji(e);return t}function Ji(e){let{parentNode:t}=e;return Bi(t)?t.host:t}function Yi(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 Xi({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!ri(n)||n.contains(e)||e.contains(n))return!0;if(Vi(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Yi(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Zi(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=ci(r),a=zi(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Xi({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Qi(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 $i(e,t,n=0){return Math.abs(Zr(e)-Zr(t))<=n}function ea(e,t){return $i(e,t)?0:e>t?1:-1}function ta({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(ea(r,c)<0)if(a){let e=(i+c)/2;r=ea(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Zr(r),r}function na({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if($i(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}`),$i(n,i)){let t=o-n;ea(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}`),$i(n,o)){let t=n-i;ea(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&&ea(i,c)<0)if(e>0){let t=c-o,n=t/2;ea(i+e,c)<0&&(e=ea(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;ea(i-e,c)<0&&(e=ea(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=ta({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=ta({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!$i(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(Qi(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=ta({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!$i(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=ta({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if($i(i,s)||(t-=s-i,l[r]=s),$i(t,0))break;e>0?r--:r++}}}if(!$i(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 ra(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||ea(e[n],t[n])!==0)return!1;return!0}function ia({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(!$i(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=ta({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!$i(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=ta({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,$i(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function aa({groupId:e,panelId:t}){let n=()=>{let t=Pi();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&&$i(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:Zr(100-e)}}return na({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=ia({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});ra(c,u)||Ii(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&&$i(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Qr({group:t}),o=Zr(Xr({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function oa(e){e.defaultPrevented||Zi(e,Pi()).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=aa({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function sa(e){let t=Pi();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 ca({groupId:e}){let t=()=>{let t=Pi();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=ia({layout:e,panelConstraints:r});return n?o:(ra(o,c)||Ii(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function la(e,t){let n=sa(e),r=Ni(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=ca({groupId:n.id}).getLayout(),c=ia({layout:na({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});ra(s,c)||Ii(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function ua(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=sa(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&la(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&la(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&la(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&la(t,-5);break;case`End`:e.preventDefault(),la(t,100);break;case`Enter`:{e.preventDefault();let n=sa(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=Ni(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];la(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=sa(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(),la(t,-100);break}}function da(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Pi(),n=Zi(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)}),hi({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function fa({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=na({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(ra(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?vi:yi;break;case`vertical`:s|=d<0?bi:xi;break}}else Ii(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Si:c|=s&Si,t.movementY===0?c|=o&Ci:c|=s&Ci,mi(c),Oi(e)}function pa(e){let t=Pi(),n=fi();switch(n.state){case`active`:fa({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function ma(e){if(e.defaultPrevented)return;let t=fi(),n=Pi();switch(t.state){case`active`:if(e.buttons===0){hi({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=Ni(e.group.id,!0);Ii(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)}fa({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Zi(e,n);r.length===0?t.state!==`inactive`&&hi({cursorFlags:0,state:`inactive`}):hi({cursorFlags:0,hitRegions:r,state:`hover`}),Oi(e.currentTarget);break}}}function ha(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(fi().state){case`hover`:hi({cursorFlags:0,state:`inactive`})}}function ga(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Li(e.currentTarget)&&e.preventDefault()}function _a(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Zr(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Zr((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function va(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Qr({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Zr(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function ya(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 ba({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=Zr(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]=Zr((r[e]??0)/a*l);else{let e=Zr(l/c.length);for(let t of c)u[t]=e}return u}function xa(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 Sa=new Map;function Ca(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=Qr({group:e});if(t===0)return;let n=Ni(e.id);if(!n)return;let r=$r(e),i=n.defaultLayoutDeferred?_a(r):n.layout,a=ia({layout:ba({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&ra(n.layout,a)&&ya(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Ii(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else va(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=Qr({group:e}),s=$r(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(xa(e.panels,l)||(l=void 0));let u=ia({layout:e.mutableState.layouts[c]??l??_a(s),panelConstraints:s}),d=e.element.ownerDocument;Sa.set(d,(Sa.get(d)??0)+1);let f=new Map;return ci(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Ii(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`,ua)}),Sa.get(d)===1&&(d.addEventListener(`contextmenu`,Ri,!0),d.addEventListener(`dblclick`,oa,!0),d.addEventListener(`pointerdown`,da,!0),d.addEventListener(`pointerleave`,pa),d.addEventListener(`pointermove`,ma),d.addEventListener(`pointerout`,ha),d.addEventListener(`pointerup`,ga,!0)),function(){t=!1,Sa.set(d,Math.max(0,(Sa.get(d)??0)-1)),ji(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,ua)}),Sa.get(d)||(d.removeEventListener(`contextmenu`,Ri,!0),d.removeEventListener(`dblclick`,oa,!0),d.removeEventListener(`pointerdown`,da,!0),d.removeEventListener(`pointerleave`,pa),d.removeEventListener(`pointermove`,ma),d.removeEventListener(`pointerout`,ha),d.removeEventListener(`pointerup`,ga,!0)),a.disconnect()}}function wa(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function Ta(e){let t=(0,Z.useId)();return`${e??t}`}var Ea=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function Da(e){let t=(0,Z.useRef)(e);return Ea(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function Oa(...e){return Da(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function ka(e){let t=(0,Z.useRef)({...e});return Ea(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Aa=(0,Z.createContext)(null);function ja(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:gi});(0,Z.useImperativeHandle)(t,()=>n.current,[]),Ea(()=>{Object.assign(n.current,ca({groupId:e}))})}function Ma({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,Z.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=Da(e=>{ra(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Da((e,t)=>{ra(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=Ta(s),v=(0,Z.useRef)(null),[y,b]=wa(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Oa(v,a);ja(_,o);let C=Da((e,t)=>{let r=fi(),i=Mi(e),a=Ni(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=ka({defaultLayout:n,disableCursor:r}),T=(0,Z.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=ei(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=ei(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=Mi(_),i=Ni(_);r&&i&&Ii(r,{...i,derivedPanelConstraints:$r(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,Z.useRef)(null);return Ea(()=>{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=Ca(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=Ni(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=Fi(_,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=$i(t.collapsedSize,i[t.panelId]),a=$i(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=fi().state!==`active`;h(i),o&&g(i,e.isUserInteraction)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,Z.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,X.jsx)(Aa.Provider,{value:T,children:(0,X.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})})}Ma.displayName=`Group`;function Na(){let e=(0,Z.useContext)(Aa);return Q(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Pa(e,t){let{id:n}=Na(),r=(0,Z.useRef)({collapse:_i,expand:_i,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:_i});(0,Z.useImperativeHandle)(t,()=>r.current,[]),Ea(()=>{Object.assign(r.current,aa({groupId:n,panelId:e}))})}function Fa({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=Ta(c),_=ka({disabled:a}),v=(0,Z.useRef)(null),y=Oa(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Na(),T=d!==null,E=Da((e,t,n)=>{d?.(e,c,n)});Ea(()=>{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,Z.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Pa(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Z.useSyncExternalStore)(e=>Fi(x,e),D,D),k;return k=O?JSON.parse(O):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,X.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Ia,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,X.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Fa.displayName=`Panel`;var Ia={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function La({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=ia({layout:na({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=ia({layout:na({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Ra({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=Ta(a),l=ka({disabled:n,disableDoubleClick:r}),[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(`inactive`),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=Oa(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=Na(),C=b===`horizontal`?`vertical`:`horizontal`;Ea(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=pi(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Fi(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(La({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,Z.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,X.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})}Ra.displayName=`Separator`;function za(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Ba(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Va(e){let t=e.split(`/`).filter(e=>e!==``);t.pop();let n=[];for(let e of t)n.push(Ua(n[n.length-1]??``,e));return n}function Ha(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function Ua(e,t){return e===``?t:`${e}/${t}`}function Wa(e,t){return t===``?e:`${e.replace(/\/+$/,``)}/${t}`}function Ga(e){let t=new Set(e);return e.filter(e=>{if(e===``)return!0;for(let n=Ba(e);;n=Ba(n)){if(t.has(n))return!1;if(n===``)return!0}})}var Ka=`application/x-puddle-paths`;function qa(e){return JSON.stringify(e)}function Ja(e){try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ya(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=Ua(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 Xa(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)}function Za(e){if(e===null)return!1;if($n(e)===`untitled`){let t=me(e.path);return t===void 0?!1:(ye({name:e.path,content:t}),!0)}return pe(we(e.session,e.path,e.root))}function Qa({request:e,targetSession:t,targetRoot:n,targetLabel:r,profileId:i,onClose:a,onSaved:o}){let[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&(c(e.name),u(null))},[e]);let p=async()=>{if(!e||!t)return;let a=s.trim().replace(/^\/+/,``).replace(/\/+$/,``);if(a===``){u(`Give the file a path.`);return}f(!0),u(null);try{let s=!0;try{await g(`GET`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Te(n)}`)}catch(e){if(e instanceof F&&e.status===404)s=!1;else if(e instanceof F&&e.status===413)s=!0;else throw e}if(s){u(`${a} already exists in ${r}.`);return}await g(`PUT`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Te(n)}`,{content:e.content}),i!==void 0&&await Ce(i,e.name).catch(()=>void 0),ge(e.name),o(e.name,t.id,a,n)}catch(e){u(e instanceof Error?e.message:`Save failed`)}finally{f(!1)}};return(0,X.jsx)(Be,{open:e!==null,onOpenChange:e=>!e&&a(),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Save draft into the worktree`}),(0,X.jsx)(ze,{children:t?(0,X.jsxs)(X.Fragment,{children:[`Saves into `,(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:r}),` — what the sidebar is bound to.`]}):`No worktree is bound — open or focus a session first.`})]}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(Ue,{htmlFor:`untitled-path`,children:`Worktree-relative path`}),(0,X.jsx)(Ge,{id:`untitled-path`,placeholder:`docs/notes.md`,value:s,onChange:e=>c(e.target.value),autoFocus:!0})]}),l&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:l}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{type:`button`,variant:`ghost`,onClick:a,children:`Cancel`}),(0,X.jsx)(H,{type:`submit`,disabled:d||!t,children:`Save`})]})]})]})})}function $a(e,t){return t??e.root??e.session?.worktree_path??null}function eo(e,t){return{...e,unpin(){t(),e.unpin()}}}function to(e){return{id:m,project_id:e.projectId,account_id:null,worktree_path:e.path,base_branch:e.defaultBranch,branch:e.defaultBranch,separate_branch:!1,kind:`terminal`,agent_type:null,agent_session_ref:null,title:e.name,status:`exited`,skip_permissions:!1,created_at:`1970-01-01T00:00:00.000Z`,updated_at:`1970-01-01T00:00:00.000Z`,last_activity_at:null}}function no(e,t,n,r=null){let i=n.snapshot.explorer_pin,a=i===null?null:e.find(e=>e.id===i&&e.status!==`archived`)??null,o=a??e.find(e=>e.id===t)??null,s=o===null&&r!==null;return{session:s?to(r):o,root:s?r.path:void 0,isProjectDirectory:s,pinned:a!==null,pin(e){n.update({explorer_pin:e})},unpin(){n.update({explorer_pin:null})}}}function ro(e,t){if(e.root===void 0)return{directory:t,path:e.path};let n=Wa(e.root,Ba(e.path));return{directory:n,path:za(e.path),browseRoot:n}}var io=null,ao=null;async function oo(){let[e,t]=await Promise.all([ke(()=>import(`./PaneEditorBody-DPfYk1MG.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])),ke(()=>import(`./ModelRefcount-Bc70ux--.js`),__vite__mapDeps([21,1,2,16,6,9,3,4,10,11,12,14,15,17]))]);io=e.PaneEditorBody,ao=t.ModelRefcount}var so=(0,Z.lazy)(()=>ke(()=>import(`./PaneEditorBody-DPfYk1MG.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,20])));function co(e){return io?(0,X.jsx)(io,{...e}):(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-xs text-fg-muted`,children:`Loading editor…`}),children:(0,X.jsx)(so,{...e})})}var lo=(0,Z.lazy)(()=>ke(()=>import(`./ModelRefcount-Bc70ux--.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([21,1,2,16,6,9,3,4,10,11,12,14,15,17])));function uo({buffers:e}){return ao?(0,X.jsx)(ao,{buffers:e}):(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(lo,{buffers:e})})}var fo=(0,Z.lazy)(()=>ke(()=>import(`./EditorTabClose-D5-9GTuN.js`).then(e=>({default:e.EditorDirtyDot})),__vite__mapDeps([22,1,2,3,10,16,6,9,4,11,12,14,15,17,18,19])));function po(e){return(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(fo,{...e})})}var mo=(0,Z.lazy)(()=>ke(()=>import(`./EditorTabClose-D5-9GTuN.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([22,1,2,3,10,16,6,9,4,11,12,14,15,17,18,19])));function ho(e){return(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onClose()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${e.label}`,children:`×`}),children:(0,X.jsx)(mo,{...e})})}var go=e(i(),1),_o=(0,Z.createContext)(null);function vo({tree:e,parked:t=[],onOpenFile:n,children:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(new Map).current,[o,s]=(0,Z.useState)(()=>new Set),c=(0,Z.useCallback)((e,t)=>{s(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),l=[...t].sort().join(`,`),u=(0,Z.useMemo)(()=>{let t=new Set;for(let n of En(e))for(let e of n.tabs)e.type===`terminal`&&t.add(e.session);for(let e of l===``?[]:l.split(`,`))t.add(e);return[...t].sort()},[e,l]),d=e=>{let t=`term:${e}`,n=a.get(t);return n||(n=document.createElement(`div`),n.className=`size-full`,a.set(t,n)),n};(0,Z.useEffect)(()=>{let e=new Set(u.map(e=>`term:${e}`));for(let e of u){let t=a.get(`term:${e}`);t&&!t.parentElement&&i.current?.appendChild(t)}for(let[t,n]of[...a])e.has(t)||(n.remove(),a.delete(t))},[u,a]);let f=(0,Z.useMemo)(()=>({parkingRef:i,containers:a,setAdopted:c}),[a,c]);return(0,X.jsxs)(_o.Provider,{value:f,children:[(0,X.jsx)(`div`,{ref:i,className:`hidden`,"aria-hidden":!0}),u.map(e=>(0,go.createPortal)((0,X.jsx)(Qe,{stream:e,paused:!o.has(`term:${e}`),onOpenFile:t=>n(e,t)}),d(e),e)),r]})}function yo(e){let t=(0,Z.useContext)(_o),n=(0,Z.useRef)(null);return(0,Z.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}var bo=null,xo=new Set;function So(e){bo=e,xo.forEach(t=>t(e))}function Co(e){return xo.add(e),bo&&e(bo),()=>xo.delete(e)}function wo(){bo=null}var To=20,Eo=new Map;function Do(e,t){let n=Eo.get(e)??[];n.push(t),n.length>To&&n.shift(),Eo.set(e,n)}function Oo(e,t){let n=Eo.get(e);for(;n&&n.length>0;){let e=n.pop();if(t(e.ref))return e}}function ko(e){let[t,n]=(0,Z.useState)(()=>window.matchMedia(e).matches);return(0,Z.useEffect)(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return n(t.matches),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Ao=`(max-width: 767px)`;function jo(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`number`)return;n[r]=t}return n}var Mo=`puddle.pane-height.`;function No(e){try{let t=localStorage.getItem(`${Mo}${e}`);if(t===null)return null;let n=Number(t);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function Po(e,t,{sized:n,min:r=64}){let[i,a]=(0,Z.useState)(()=>No(e)??t),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(i);return c.current=i,{height:i,handle:{dragging:o,onPointerDown:(0,Z.useCallback)(t=>{if(t.button!==0)return;t.preventDefault();let i=t.currentTarget,o=t.clientY,l=c.current,u=i.parentElement?.getBoundingClientRect().height??window.innerHeight,d=Math.max(r,u-96);i.setPointerCapture(t.pointerId),s(!0);let f=e=>{let t=e.clientY-o,i=n===`below`?l-t:l+t;a(Math.round(Math.min(d,Math.max(r,i))))},p=()=>{i.removeEventListener(`pointermove`,f),i.removeEventListener(`pointerup`,p),i.removeEventListener(`pointercancel`,p),s(!1);try{localStorage.setItem(`${Mo}${e}`,String(c.current))}catch{}};i.addEventListener(`pointermove`,f),i.addEventListener(`pointerup`,p),i.addEventListener(`pointercancel`,p)},[e,r,n])}}}function Fo({handle:e,label:t,className:n}){return(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":t,onPointerDown:e.onPointerDown,className:a(`relative h-px shrink-0 cursor-row-resize touch-none bg-border transition-colors hover:bg-accent`,e.dragging&&`bg-accent`,n),children:(0,X.jsx)(`div`,{className:`absolute inset-x-0 -top-1 h-[9px]`})})}var Io=80,Lo=180;function Ro(e){return Math.max(Lo,Math.round(e/Io*1e3))}function zo({text:e,hoverClass:t,className:n,containerClassName:r,title:i,children:o}){let s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>l(Math.max(0,e.scrollWidth-e.clientWidth));t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]),(0,X.jsx)(`span`,{className:a(`block min-w-0 flex-1 overflow-hidden`,r),children:(0,X.jsx)(`span`,{ref:s,title:i,className:a(`block whitespace-nowrap transition-transform ease-linear`,n,c>0&&t),style:c>0?{"--tail":`-${c}px`,transitionDuration:`${Ro(c)}ms`}:void 0,children:o??e})})}var Bo={added:{letter:`A`,label:`added`,colourClass:`text-success`},modified:{letter:`M`,label:`modified`,colourClass:`text-fg-secondary`},deleted:{letter:`D`,label:`deleted`,colourClass:`text-interrupted`},renamed:{letter:`R`,label:`renamed`,colourClass:`text-warning`}};function Vo(e){return Bo[e]}var Ho=[`modified`,`added`,`deleted`,`renamed`];function Uo(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return Ho.filter(e=>t.has(e)).map(e=>`${t.get(e)} ${Bo[e].label}`).join(` · `)}var Wo=[`var(--accent)`,`var(--status-running)`,`var(--status-waiting)`,`var(--ansi-magenta)`,`var(--ansi-cyan)`,`var(--status-interrupted)`];function Go(e){return Wo[e%Wo.length]}function Ko(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:Go(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=Go(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 qo=7,Jo=14,Yo=4,Xo=1.5,Zo=40,Qo=22,$o=`group-hover:[transform:translateX(var(--tail))]`;function es(e){return e*Jo+Jo/2}function ts(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 ns({row:e,width:t}){let n=Zo,r=n/2,i=es(e.col),a=new Set(e.created),o=[];for(let t of e.above){let n=es(t.col);t.sha===e.sha?o.push({d:ts(n,0,i,r),colour:t.colour}):o.push({d:ts(n,0,n,r),colour:t.colour})}for(let t of e.below){let e=es(t.col);a.has(t.col)?o.push({d:ts(i,r,e,n),colour:t.colour}):o.push({d:ts(e,r,e,n),colour:t.colour})}return(0,X.jsxs)(`svg`,{width:t,height:n,className:`shrink-0`,"aria-hidden":!0,children:[o.map((e,t)=>(0,X.jsx)(`path`,{d:e.d,fill:`none`,stroke:e.colour,strokeWidth:Xo},t)),(0,X.jsx)(`circle`,{cx:i,cy:r,r:Yo,fill:`var(--bg-surface)`,stroke:e.colour,strokeWidth:Xo})]})}function rs({lanes:e,width:t}){return(0,X.jsx)(`svg`,{width:t,height:Qo,className:`shrink-0`,"aria-hidden":!0,children:e.map(e=>{let t=es(e.col);return(0,X.jsx)(`path`,{d:`M ${t} 0 L ${t} ${Qo}`,fill:`none`,stroke:e.colour,strokeWidth:Xo},e.col)})})}function is({session:e,sha:t,root:n,lanes:r,gutterW:i,onOpen:o}){let s=se(e,t,n),c=e=>(0,X.jsxs)(`div`,{className:`flex items-center`,style:{height:Qo},children:[(0,X.jsx)(rs,{lanes:r,width:i}),(0,X.jsx)(`span`,{className:`px-2 text-2xs text-fg-muted`,children:e})]});return s.isPending?c(`…`):s.error?c(s.error instanceof Error?s.error.message:`Failed to load commit`):s.data.files.length===0?c(`No file changes.`):(0,X.jsx)(X.Fragment,{children:s.data.files.map(e=>{let s=Vo(e.status),c=e.status===`renamed`&&e.old_path?`${e.old_path} → ${e.path}`:e.path;return(0,X.jsxs)(`button`,{type:`button`,title:c,onClick:()=>{o(e.path,t),So({path:e.path,root:n})},onDoubleClick:()=>o(e.path,t,{preview:!1}),className:`group flex w-full items-center text-left transition-colors hover:bg-elevated`,style:{height:Qo},children:[(0,X.jsx)(rs,{lanes:r,width:i}),(0,X.jsx)(`span`,{className:a(`mr-1.5 w-3 shrink-0 text-center font-mono text-xs`,s.colourClass),children:s.letter}),(0,X.jsx)(zo,{text:c,className:`pr-3 text-2xs text-fg`,hoverClass:$o})]},`${e.status}:${e.old_path??``}:${e.path}`)})})}function as({session:e,root:t,onOpenCommitFile:n}){let r=le(e,{root:t}),[i,o]=(0,Z.useState)(null),s=(0,Z.useMemo)(()=>r.data?.pages.flatMap(e=>e.commits)??[],[r.data]),c=(0,Z.useMemo)(()=>Ko(s),[s]),l=Math.max(1,c.laneCount)*Jo+Jo/2;return r.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading history…`}):r.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load history`}):s.length===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No commits yet.`}):(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[c.rows.map((r,c)=>{let u=s[c],d=i===r.sha;return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(d?null:r.sha),className:a(`group flex w-full items-center text-left transition-colors hover:bg-elevated`,d&&`bg-selection`),style:{height:Zo},children:[(0,X.jsx)(ns,{row:r,width:l}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 pr-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-2xs text-fg-muted`,children:r.sha.slice(0,qo)}),(0,X.jsx)(zo,{text:u.subject,className:`text-xs text-fg`,hoverClass:$o})]}),(0,X.jsxs)(`span`,{className:`truncate text-2xs text-fg-muted`,children:[u.author_name,` ·`,` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:he(u.authored_at)})]})]})]}),d&&(0,X.jsx)(is,{session:e,sha:r.sha,root:t,lanes:r.below,gutterW:l,onOpen:n})]},r.sha)}),r.hasNextPage&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>void r.fetchNextPage(),disabled:r.isFetchingNextPage,className:`px-3 py-2 text-left text-xs text-fg-muted transition-colors hover:bg-elevated`,children:r.isFetchingNextPage?`Loading…`:`Show more`})]})}function os(){return{dirs:new Map,files:[]}}function ss(e){return e.path}function cs(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:cs(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 ls(e){let t=os();for(let n of e){let e=ss(n),r=e.split(`/`),i=r.pop(),a=t;for(let e of r){let t=a.dirs.get(e);t||(t=os(),a.dirs.set(e,t)),a=t}a.files.push({type:`file`,name:i,path:e,entry:n})}return cs(t,``)}function us(e){return e.map(e=>({type:`file`,name:ss(e).split(`/`).pop()??ss(e),path:ss(e),entry:e})).sort((e,t)=>e.path.localeCompare(t.path,void 0,{sensitivity:`base`}))}function ds(e){return e.type===`file`?[e.entry]:e.children.flatMap(ds)}var fs=`group-hover:[transform:translateX(var(--tail))]`;function ps({name:e,fullPath:t,status:n,depth:r,active:i,onOpen:o}){let s=Vo(n);return(0,X.jsxs)(`button`,{type:`button`,title:t,onClick:()=>o(t),onDoubleClick:()=>o(t,{preview:!1}),className:a(`group 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,X.jsx)(`span`,{className:a(`w-3 shrink-0 text-center font-mono text-xs`,s.colourClass),children:s.letter}),(0,X.jsx)(zo,{text:e,className:`text-xs text-fg`,hoverClass:fs})]})}function ms({nodes:e,depth:t,activePath:n,onOpen:r}){let[i,a]=(0,Z.useState)(new Set);return(0,X.jsx)(X.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,X.jsx)(ps,{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,X.jsxs)(`div`,{children:[(0,X.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:`group flex w-full items-center gap-1 py-1 pr-3 text-left transition-colors hover:bg-elevated`,style:{paddingLeft:8+t*12},title:e.path,children:[o?(0,X.jsx)(Ut,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,X.jsx)(Ht,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e.name,className:`text-xs text-fg-secondary`,hoverClass:fs})]}),!o&&(0,X.jsx)(ms,{nodes:e.children,depth:t+1,activePath:n,onOpen:r})]},e.path)})})}function hs({session:e,root:t,activePath:n,onOpen:r}){let[i,a]=(0,Z.useState)(!1),o=ue(e,{against:`head`,root:t}),s=o.data?.entries??[],c=(e,n)=>{r(e,n),So({path:e,root:t})},l=(0,Z.useMemo)(()=>i?null:ls(s),[i,s]),u=(0,Z.useMemo)(()=>i?us(s):null,[i,s]);return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 px-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Uncommitted`}),s.length>0&&(0,X.jsx)(`span`,{className:`truncate text-2xs text-fg-muted`,children:Uo(s)}),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":!i,onClick:()=>a(e=>!e),className:`ml-auto rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[i?(0,X.jsx)(Or,{className:`size-3.5`}):(0,X.jsx)(Cr,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:i?`Show as tree`:`Show as flat list`})]})}),(0,X.jsx)(J,{children:i?`Show as tree`:`Show as flat list`})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:o.isPending?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`Loading changes…`}):o.error?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:o.error instanceof Error?o.error.message:`Failed to load changes`}):s.length===0?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`No uncommitted changes.`}):i?u.map(e=>(0,X.jsx)(ps,{name:e.path,fullPath:e.path,status:e.entry.status,depth:0,active:n===e.path,onOpen:c},e.path)):(0,X.jsx)(ms,{nodes:l,depth:0,activePath:n,onOpen:c})})]})}var gs={untracked:{letter:`U`,colourClass:`text-success`},added:{letter:`A`,colourClass:`text-success`},modified:{letter:`M`,colourClass:`text-warning`},renamed:{letter:`R`,colourClass:`text-warning`},deleted:{letter:`D`,colourClass:`text-interrupted`},conflicted:{letter:`C`,colourClass:`text-interrupted`},ignored:{letter:``,colourClass:`text-fg-muted`}};function _s(e){return gs[e]}function vs(e){let t=new Map;for(let n of e)t.set(n.path,n.status);return t}var ys={conflicted:0,modified:1,renamed:2,deleted:3,added:4,untracked:5,ignored:6};function bs(e,t){let n=t===``?``:`${t}/`,r=null;for(let[t,i]of e)n!==``&&!t.startsWith(n)||i!==`ignored`&&(r===null||ys[i]<ys[r])&&(r=i);return r}function xs(e){let t=new Set;for(let n of e)t.add(n.path),n.old_path!==null&&t.add(n.old_path);return[...t]}var Ss=`group-hover:[transform:translateX(var(--tail))]`,Cs=`group-hover/repository:[transform:translateX(var(--tail))]`,ws=`group-hover:[transform:translateX(var(--tail))]`;function Ts({label:e,onClick:t,disabled:n,className:r,children:i}){return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":e,disabled:n,onClick:e=>{e.stopPropagation(),t()},className:a(`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,r),children:i})}),(0,X.jsx)(J,{children:e})]})}function Es({title:e,entries:t,area:n,activePath:r,action:i,busy:a,flat:o,onAction:s,onOpen:c}){let[l,u]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>o?null:ls(t),[t,o]);if(t.length===0)return null;let f=i===`stage`;return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`group flex h-7 items-center gap-1 px-3`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex min-w-0 flex-1 items-center gap-1 text-left text-2xs font-medium uppercase tracking-wide text-fg-gold transition-colors hover:text-fg`,children:[l?(0,X.jsx)(Ut,{className:`size-3`}):(0,X.jsx)(Ht,{className:`size-3`}),(0,X.jsx)(`span`,{className:`truncate`,children:e}),(0,X.jsx)(`span`,{className:`ml-1 text-fg-muted`,children:t.length})]}),(0,X.jsx)(Ts,{label:`${f?`Stage`:`Unstage`} all ${e.toLowerCase()}`,disabled:a,onClick:()=>s(xs(t)),children:f?(0,X.jsx)(W,{className:`size-3.5`}):(0,X.jsx)(jr,{className:`size-3.5`})})]}),!l&&(o?t.map(e=>(0,X.jsx)(Ds,{entry:e,name:e.path,depth:0,area:n,active:r===e.path,action:i,busy:a,onAction:s,onOpen:c},`${e.path}:${e.old_path??``}`)):(0,X.jsx)(Os,{nodes:d,depth:0,area:n,activePath:r,action:i,busy:a,onAction:s,onOpen:c}))]})}function Ds({entry:e,name:t,depth:n,area:r,active:i,action:o,busy:s,onAction:c,onOpen:l}){let u=_s(e.status),d=o===`stage`;return(0,X.jsxs)(`div`,{className:a(`group flex items-center gap-1 pr-3 transition-colors hover:bg-elevated`,i&&`bg-selection`),style:{paddingLeft:12+n*12},children:[(0,X.jsxs)(`button`,{type:`button`,title:e.path,onClick:()=>l(e.path,{root:void 0,gitArea:r}),onDoubleClick:()=>l(e.path,{preview:!1,root:void 0,gitArea:r}),className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left`,children:[(0,X.jsx)(`span`,{className:a(`w-3 shrink-0 text-center font-mono text-xs`,u.colourClass),children:u.letter}),(0,X.jsx)(zo,{text:t,className:`text-xs text-fg`,hoverClass:ws})]}),(0,X.jsx)(Ts,{label:`${d?`Stage`:`Unstage`} ${e.path}`,disabled:s,onClick:()=>c(xs([e])),children:d?(0,X.jsx)(W,{className:`size-3.5`}):(0,X.jsx)(jr,{className:`size-3.5`})})]})}function Os({nodes:e,depth:t,area:n,activePath:r,action:i,busy:a,onAction:o,onOpen:s}){let[c,l]=(0,Z.useState)(new Set),u=i===`stage`;return(0,X.jsx)(X.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,X.jsx)(Ds,{entry:e.entry,name:e.name,depth:t,area:n,active:r===e.path,action:i,busy:a,onAction:o,onOpen:s},`${e.entry.path}:${e.entry.old_path??``}`);let d=c.has(e.path);return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`group flex items-center gap-1 pr-3 transition-colors hover:bg-elevated`,style:{paddingLeft:12+t*12},children:[(0,X.jsxs)(`button`,{type:`button`,title:e.path,onClick:()=>l(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),className:`flex min-w-0 flex-1 items-center gap-1 py-1 text-left`,children:[d?(0,X.jsx)(Ut,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,X.jsx)(Ht,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e.name,className:`text-xs text-fg-secondary`,hoverClass:ws})]}),(0,X.jsx)(Ts,{label:`${u?`Stage`:`Unstage`} ${e.path}`,disabled:a,onClick:()=>o(xs(ds(e))),children:u?(0,X.jsx)(W,{className:`size-3.5`}):(0,X.jsx)(jr,{className:`size-3.5`})})]}),!d&&(0,X.jsx)(Os,{nodes:e.children,depth:t+1,area:n,activePath:r,action:i,busy:a,onAction:o,onOpen:s})]},e.path)})})}function ks(e){return e.detached?`Detached at ${e.head?.slice(0,8)??`HEAD`}`:e.branch??`Unborn branch`}function As(e){return[ks(e),e.upstream,e.ahead>0?`${e.ahead} ahead`:null,e.behind>0?`${e.behind} behind`:null].filter(e=>e!=null).join(` · `)}function js({session:e,targetRoot:t,repository:n,selected:r,activePath:i,onSelect:o,onOpen:s}){let[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),h=_e(e,t),g=[...n.conflicts,...n.staged,...n.unstaged],_=h.isPending,v=async(e,t)=>{try{await h.mutateAsync(e),u.success(t)}catch(e){u.error(e instanceof Error?e.message:`Git operation failed`)}},y=(e,t)=>{v({action:e,repository:n.root,paths:t},e===`stage`?`Staged`:`Unstaged`)},b=async()=>{let e=p.trim();if(!e||_)return;let t=!1;if(n.staged.length===0){if(n.conflicts.length>0){u.error(`Resolve and stage merge changes before committing`);return}if(n.unstaged.length===0){u.error(`There are no changes to commit`);return}if(t=window.confirm(`Nothing is staged. Stage every change and commit it?`),!t)return}try{await h.mutateAsync({action:`commit`,repository:n.root,message:e,stage_all:t}),m(``),u.success(`Committed`)}catch(e){u.error(e instanceof Error?e.message:`Commit failed`)}},x=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),b())},S=(e,t)=>s(e,{...t,root:n.root});return(0,X.jsxs)(`section`,{className:a(`py-0.5`,r&&`bg-surface/40`),onFocus:o,children:[(0,X.jsxs)(`div`,{className:`flex h-8 items-center gap-1 pl-2 pr-2`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{o(),l(e=>!e)},className:`group/repository flex min-w-0 flex-1 items-center gap-1.5 text-left transition-colors hover:text-fg`,children:[c?(0,X.jsx)(Ut,{className:`size-3 shrink-0`}):(0,X.jsx)(Ht,{className:`size-3 shrink-0`}),(0,X.jsxs)(zo,{text:`${n.name} ${n.relative_path}`,title:`${n.name} ${n.relative_path}`,className:`text-xs`,hoverClass:Cs,children:[(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.name}),` `,(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:n.relative_path})]}),g.length>0&&(0,X.jsx)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:g.length})]}),!c&&n.initialised&&g.length>0&&(0,X.jsx)(Ts,{label:d?`Show changes as tree`:`Show changes as flat list`,onClick:()=>f(e=>!e),children:d?(0,X.jsx)(Or,{className:`size-3.5`}):(0,X.jsx)(Cr,{className:`size-3.5`})})]}),!c&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`group flex min-h-7 items-center px-3 text-2xs text-fg-muted`,children:(0,X.jsx)(zo,{text:As(n),title:As(n),hoverClass:Ss})}),n.initialised?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`px-3 pb-1.5 pt-1`,children:[(0,X.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),onKeyDown:x,rows:2,placeholder:`Commit message`,"aria-label":`Commit message for ${n.name}`,className:`w-full resize-none rounded-sm bg-elevated px-2 py-1.5 text-xs text-fg outline-none placeholder:text-fg-muted focus:ring-1 focus:ring-focus`}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-0.5`,children:[n.has_remote&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ts,{label:`Fetch`,disabled:_,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void v({action:`fetch`,repository:n.root},`Fetched`),children:(0,X.jsx)(ae,{className:`size-3.5`})}),n.upstream&&(0,X.jsx)(Ts,{label:`Pull`,disabled:_,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void v({action:`pull`,repository:n.root},`Pulled`),children:(0,X.jsx)(Ur,{className:`size-3.5 rotate-180`})}),n.branch&&(0,X.jsx)(Ts,{label:n.upstream?`Push`:`Publish branch`,disabled:_,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void v({action:`push`,repository:n.root,set_upstream:!n.upstream},n.upstream?`Pushed`:`Branch published`),children:n.upstream?(0,X.jsx)(Rr,{className:`size-3.5`}):(0,X.jsx)(Ur,{className:`size-3.5`})})]}),(0,X.jsx)(`button`,{type:`button`,disabled:_||p.trim().length===0,onClick:()=>void b(),className:`flex h-7 min-w-0 flex-1 items-center justify-center rounded-sm bg-action px-2 text-xs text-action-ink transition-colors hover:bg-action-hover disabled:cursor-not-allowed disabled:opacity-40`,children:`Commit`})]})]}),(0,X.jsx)(Es,{title:`Merge Changes`,entries:n.conflicts,area:`unstaged`,activePath:i,action:`stage`,busy:_,flat:d,onAction:e=>y(`stage`,e),onOpen:S}),(0,X.jsx)(Es,{title:`Staged Changes`,entries:n.staged,area:`staged`,activePath:i,action:`unstage`,busy:_,flat:d,onAction:e=>y(`unstage`,e),onOpen:S}),(0,X.jsx)(Es,{title:`Changes`,entries:n.unstaged,area:`unstaged`,activePath:i,action:`stage`,busy:_,flat:d,onAction:e=>y(`stage`,e),onOpen:S}),g.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No changes.`})]}):(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Submodule not initialised.`})]})]})}function Ms({session:e,root:t,activeDiffPath:n,onOpenDiff:r,onOpenCommitFile:i}){let{height:a,handle:o}=Po(`changes-uncommitted`,240,{sized:`above`,min:80}),s=h(),c=s.data!==void 0&&Dn(s.data.protocol),l=V(e,{root:t,enabled:c}),[u,d]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!c||!l.data)return;let e=l.data.repositories;(!u||!e.some(e=>e.root===u))&&d(e[0]?.root??null)},[c,l.data,u]);let f=c?u??t:t;return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(`section`,{className:`flex shrink-0 flex-col`,style:{height:a,maxHeight:`70%`},children:c?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:l.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading repositories…`}):l.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:l.error instanceof Error?l.error.message:`Failed to load repositories`}):l.data.repositories.length===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No Git repositories.`}):l.data.repositories.map((i,a)=>(0,X.jsxs)(Z.Fragment,{children:[a>0&&(0,X.jsx)(`div`,{className:`mx-3 my-2 h-px bg-border`}),(0,X.jsx)(js,{session:e,targetRoot:t,repository:i,selected:u===i.root,activePath:n,onSelect:()=>d(i.root),onOpen:r})]},i.root))}):(0,X.jsx)(hs,{session:e,root:t,activePath:n,onOpen:r})}),(0,X.jsx)(Fo,{handle:o,label:`Resize the uncommitted changes`}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(`div`,{className:`flex h-7 shrink-0 items-center px-3`,children:(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`History`})}),(0,X.jsx)(as,{session:e,root:f,onOpenCommitFile:(e,t,n)=>i(e,t,{...n,root:f})})]})]})}function Ns(e,t,n){return e!==null&&e.id===t&&n-e.at<1500}var Ps=`puddle.explorerClipboard.v1`;function Fs(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.sid==`string`&&typeof t.directory==`string`&&(t.root===void 0||typeof t.root==`string`)&&(t.host===void 0||typeof t.host==`string`)}function Is(e){if(e===null)return null;try{let t=JSON.parse(e);return typeof t.id!=`string`||t.mode!==`cut`&&t.mode!==`copy`||!Array.isArray(t.paths)||t.paths.length===0||!t.paths.every(e=>typeof e==`string`)||!Fs(t.source)?null:t}catch{return null}}function Ls(){if(typeof localStorage>`u`)return null;try{return Is(localStorage.getItem(Ps))}catch{return null}}var Rs=Ls(),zs=new Set;function Bs(e,t){if(Rs=e,t&&typeof localStorage<`u`)try{e===null?localStorage.removeItem(Ps):localStorage.setItem(Ps,JSON.stringify(e))}catch{}for(let e of zs)e()}typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===Ps&&Bs(Is(e.newValue),!1)});function Vs(){return globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`}function Hs(e){return e?`${e.username}\0${e.hostname}\0${e.home}`:void 0}function Us(e,t){return e.directory===t.directory}function Ws(e,t){return e.host===void 0||t.host===void 0||e.host===t.host}function Gs(e,t){return e.host!==void 0&&e.host===t.host}function Ks(e,t,n){e.length!==0&&Bs({id:Vs(),paths:e,mode:t,source:n},!0)}function qs(e,t){Rs?.id!==e||Rs.mode!==`cut`||Bs(t.length===0?null:{...Rs,paths:t},!0)}function Js(e){return zs.add(e),()=>zs.delete(e)}function Ys(){return Rs}function Xs(){return(0,Z.useSyncExternalStore)(Js,Ys,()=>null)}async function Zs(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 Qs(e){return new Promise((t,n)=>e.file(t,n))}async function $s(e,t,n){if(e.isFile){let r=await Qs(e);n.push(t?new File([r],`${t}/${e.name}`,{type:r.type,lastModified:r.lastModified}):r)}else if(e.isDirectory){let r=await Zs(e),i=t?`${t}/${e.name}`:e.name;for(let e of r)await $s(e,i,n)}}function ec(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)&&u.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 $s(t,``,e):n&&e.push(n);return e})()}var tc=(e,t)=>e instanceof Error?e.message:t;function nc(e,t,n=t??``){let r=ee(),i=(0,Z.useCallback)(()=>{r.invalidateQueries({queryKey:[`wt-tree`,e]}),r.invalidateQueries({queryKey:[`wt-git-status`,e]})},[r,e]),a=(0,Z.useCallback)(e=>{r.invalidateQueries({queryKey:[`wt-tree`,e.sid]}),r.invalidateQueries({queryKey:[`wt-git-status`,e.sid]})},[r]);return(0,Z.useMemo)(()=>({async create(n,r,a){try{let o=await B(e,Ua(n,r),a,t);return i(),o.path}catch(e){return u.error(tc(e,`Couldn't create ${r}`)),null}},async rename(n,r){let a=Ua(n.includes(`/`)?n.slice(0,n.lastIndexOf(`/`)):``,r);try{let r=await oe(e,n,a,t);return i(),r.path}catch(e){return u.error(tc(e,`Couldn't rename ${za(n)}`)),null}},async move(n,r){let a=await Promise.allSettled(n.map(n=>oe(e,n,Ua(r,za(n)),t)));i();let o=a.filter(e=>e.status===`rejected`);o.length>0&&u.error(n.length===1?tc(o[0].reason,`Couldn't move ${za(n[0])}`):`Couldn't move ${o.length} item${o.length>1?`s`:``}`)},async remove(n){let r=await Promise.allSettled(n.map(n=>Ee(e,n,t)));i();let a=r.filter(e=>e.status===`rejected`).length;a>0?u.error(`Couldn't delete ${a} item${a>1?`s`:``}`):u.success(n.length===1?`Deleted ${za(n[0])}`:`Deleted ${n.length} items`)},async paste(r,o){let s={sid:e,root:t,directory:n},c=Us(r.source,s),l=await Promise.allSettled(r.paths.map(n=>{let i=Ua(o,za(n));return c?(r.mode===`cut`?oe:De)(e,n,i,t):z(e,{operation:r.mode===`cut`?`move`:`copy`,source:{session_id:r.source.sid,root:r.source.root},from:n,to:i},t)}));i(),!c&&r.mode===`cut`&&a(r.source);let d=r.paths.filter((e,t)=>l[t]?.status===`rejected`);return d.length>0&&u.error(`Couldn't paste ${d.length} item${d.length>1?`s`:``}`),d}}),[e,t,n,i,a])}function rc(e,t,n){return n&&n.type!==`dir`||(e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``)===t?!1:t===``||!`${t}/`.startsWith(`${e}/`)}var ic=(0,Z.createContext)(null);function ac(){let e=(0,Z.useContext)(ic);if(!e)throw Error(`explorer components must render inside <ExplorerProvider>`);return e}function oc(){return(0,Z.useContext)(ic)}function sc({session:e,root:t,readOnly:n=!1,onOpenFile:r,onOpenTerminal:i,activePath:a,children:o}){let s=e.id,c=ee(),l=t??e.worktree_path,d=nc(s,t,l),f=(0,Z.useCallback)(e=>t===void 0?[`wt-tree`,s,e]:[`wt-tree`,s,e,t],[s,t]),p=(0,Z.useCallback)((e,r)=>{r.length===0||n||R(s,e,r,t).then(()=>{c.invalidateQueries({queryKey:f(e)}),c.invalidateQueries({queryKey:[`wt-git-status`,s]}),u.success(r.length===1?`Uploaded ${r[0].name}`:`Uploaded ${r.length} files`)}).catch(e=>u.error(e instanceof Error?e.message:`Upload failed`))},[s,t,n,c,f]),m=h().data?.protocol,g=M(),_=(0,Z.useMemo)(()=>({sid:s,root:t,directory:l,host:Hs(g.data)}),[s,t,l,g.data]),v=!m||m.major>9||m.major===9&&m.minor>=2,y=(0,Z.useCallback)((e,t,n)=>{ec(t,n,v).then(t=>p(e,t)).catch(e=>u.error(e instanceof Error?e.message:`Couldn't read the dropped folder`))},[p,v]),[b,x]=(0,Z.useState)(new Set),[S,C]=(0,Z.useState)(new Set),[w,T]=(0,Z.useState)(null),E=Xs(),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,te]=(0,Z.useState)(null),ne=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=()=>A(null);return window.addEventListener(`dragend`,e),()=>window.removeEventListener(`dragend`,e)},[]);let N=ce(s,{root:t,enabled:t===void 0||m!==void 0&&Dn(m)}),P=(0,Z.useMemo)(()=>vs(N.data?.entries??[]),[N.data]),re=N.refetch,[ie,F]=(0,Z.useState)(0);(0,Z.useEffect)(()=>c.getQueryCache().subscribe(e=>{if(e.type!==`added`&&e.type!==`removed`&&e.type!==`updated`)return;let t=e.query.queryKey;Array.isArray(t)&&t[0]===`wt-tree`&&t[1]===s&&F(e=>e+1)}),[c,s]);let I=(0,Z.useMemo)(()=>Ya(e=>c.getQueryData(f(e)),b),[c,f,b,ie]),L=(0,Z.useCallback)(e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ae=(0,Z.useCallback)(e=>{x(t=>t.has(e)?t:new Set(t).add(e))},[]),oe=(0,Z.useCallback)(()=>x(new Set),[]),[se,le]=(0,Z.useState)(null);(0,Z.useEffect)(()=>Co(e=>{if(!(e.directory===void 0?e.root!==t:e.directory!==l)){wo();for(let t of Va(e.path))ae(t);e.expandTarget&&e.path!==``&&ae(e.path),C(new Set([e.path])),T(e.path),e.renameTarget&&!n&&O({mode:`rename`,path:e.path}),le(e.path)}}),[t,l,ae,n]),(0,Z.useEffect)(()=>{if(se===null)return;let e=document.querySelector(`[data-explorer-root] [data-path="${CSS.escape(se)}"]`);if(e){e.scrollIntoView({block:`nearest`}),le(null);return}let t=window.setTimeout(()=>le(null),4e3);return()=>window.clearTimeout(t)},[se,I]);let ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null),z=(0,Z.useCallback)(()=>{ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null)},[]);(0,Z.useEffect)(()=>z,[z]);let pe=(0,Z.useCallback)((e,t)=>{if(z(),T(e.path),t.metaKey||t.ctrlKey){C(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),ne.current=e.path;return}if(t.shiftKey&&ne.current){C(new Set(Xa(I,ne.current,e.path)));return}let i=Date.now(),a=de.current;if(de.current={id:e.path,at:i},e.type!==`dir`&&!n&&!D&&S.size===1&&S.has(e.path)&&Ns(a,e.path,i)){ue.current=window.setTimeout(()=>{ue.current=null,O({mode:`rename`,path:e.path})},500);return}C(new Set([e.path])),ne.current=e.path,e.type===`dir`?L(e.path):r?.(s,e.path)},[I,L,r,s,S,D,n,z]),B=(0,Z.useCallback)(e=>{z(),e.type!==`dir`&&r?.(s,e.path,{preview:!1})},[r,s,z]),me=(0,Z.useCallback)(e=>{C(new Set([e])),T(e),ne.current=e},[]),he=(0,Z.useCallback)(e=>Ks(Ga(e),`cut`,_),[_]),ge=(0,Z.useCallback)(e=>Ks(Ga(e),`copy`,_),[_]),V=E!==null&&Ws(E.source,_),_e=E!==null&&Us(E.source,_),ve=!n&&(V&&_e||E!==null&&Gs(E.source,_)&&Sn(m)),ye=(0,Z.useCallback)(e=>E?.mode===`cut`&&Ws(E.source,_)&&Us(E.source,_)&&E.paths.includes(e),[E,_]),be=(0,Z.useCallback)(e=>{if(!E||n)return;let t=Us(E.source,_);if(!Ws(E.source,_)){u.error(`That filetree clipboard belongs to another daemon host.`);return}if(!t&&!Gs(E.source,_)){u.error(`Copy again after daemon host information finishes loading.`);return}if(!t&&!Sn(m)){u.error(`Cross-filetree paste requires a daemon with protocol 16.3.`);return}d.paste(E,e).then(e=>{E.mode===`cut`&&qs(E.id,e)})},[E,d,m,n,_]),xe=(0,Z.useCallback)(e=>{n||O({mode:`rename`,path:e})},[n]),Se=(0,Z.useCallback)((e,t)=>{n||(e!==``&&ae(e),O({mode:`create`,parentDir:e,kind:t}))},[ae,n]),Ce=(0,Z.useCallback)(()=>O(null),[]),we=(0,Z.useCallback)(e=>{let t=e.trim(),n=D;if(O(null),!(!n||t===``))if(n.mode===`rename`){if(t===za(n.path))return;d.rename(n.path,t)}else d.create(n.parentDir,t,n.kind).then(e=>{e&&n.kind===`file`&&r?.(s,e)})},[D,d,r,s]),Te=(0,Z.useCallback)(e=>{if(n)return;let t=Ga(e);t.length>0&&te(t)},[n]),Ee=(0,Z.useCallback)(()=>{let e=j;te(null),e&&d.remove(e)},[j,d]),De=(0,Z.useCallback)(()=>te(null),[]),Oe=(0,Z.useCallback)((e,t)=>{let n=e.map(e=>t?e:Ua(l,e)).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-CRFah0Fn.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/x-BJOrp_m5.js","assets/hotkeys-CekBkaTu.js","assets/editor-context-DBjXfTll.js","assets/preload-helper-Czpn1I53.js","assets/use-find-controls-CT0S98qk.js","assets/file-links-ezBU7rQX.js","assets/index-CYm7O8SE.js","assets/dialog-DjL0qoAv.js","assets/LazyTerminal-BYhuJK76.js","assets/index-BBk5N4Nn.css","assets/chevron-down-59O6CgEo.js","assets/editor.api2-4X9Vh9Zw.js","assets/editor-Br_kD0ds.css","assets/buffer-store-eUpqFE4J.js","assets/buffer-logic-BAkSBQT7.js","assets/drafts-CKYJHEPP.js","assets/editor-sync-W1bamxAP.js","assets/PaneEditorBody-Dz-67XSV.css","assets/ModelRefcount-CCRR4bB-.js","assets/EditorTabClose-DOvQ8kvf.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,o as i,r as a,t as o}from"./x-BJOrp_m5.js";import{B as s,C as c,D as l,Ht as u,K as d,L as f,O as p,Ot as m,R as h,St as g,T as _,X as v,_t as y,at as b,ct as x,dt as S,ft as C,gt as w,ht as T,k as E,kt as D,lt as O,nt as k,p as A,pt as j,q as M,qt as ee,st as te,tt as ne,u as N,ut as P,v as re,x as ie,xt as F,yt as I,zt as L}from"./hotkeys-CekBkaTu.js";import{B as ae,C as oe,D as se,E as R,I as ce,L as le,P as ue,R as de,S as fe,T as z,_ as pe,b as B,c as me,h as he,i as ge,j as V,k as _e,l as ve,o as ye,r as be,s as xe,t as Se,u as Ce,v as we,w as Te,x as Ee,y as De,z as Oe}from"./editor-context-DBjXfTll.js";import{t as ke}from"./preload-helper-Czpn1I53.js";import{A as Ae,C as je,D as Me,a as Ne,g as Pe,h as H,i as Fe,k as Ie,n as Le,o as Re,r as ze,t as Be,y as Ve}from"./dialog-DjL0qoAv.js";import{a as He,c as Ue,i as We,l as Ge,m as Ke,n as qe,o as Je,p as Ye,r as Xe,s as Ze,t as Qe}from"./LazyTerminal-BYhuJK76.js";import{A as $e,C as et,D as tt,E as nt,M as rt,O as it,S as at,T as ot,_ as st,a as ct,b as lt,c as ut,d as dt,f as ft,g as pt,h as mt,i as ht,j as gt,k as _t,l as vt,m as yt,n as bt,o as xt,p as St,r as U,s as Ct,t as wt,u as Tt,v as Et,w as Dt,x as Ot,y as kt}from"./context-menu-DByGBkiO.js";import{a as At,i as jt,o as Mt,r as Nt,s as Pt,t as Ft}from"./file-links-ezBU7rQX.js";import{a as It,i as Lt,n as Rt,o as zt,r as Bt,t as Vt}from"./session-seed-BDCRZt-r.js";import{t as Ht}from"./chevron-down-59O6CgEo.js";import{r as Ut}from"./dist-DDFe8e3m.js";import{A as Wt,At as W,B as Gt,Bt as G,C as Kt,D as qt,Dt as Jt,E as Yt,Et as Xt,F as Zt,Ft as Qt,Ht as K,It as $t,Lt as en,M as tn,N as q,Nt as nn,O as rn,Ot as an,Pt as on,Qt as sn,Rt as cn,S as ln,T as un,U as dn,V as fn,Vt as J,Xt as pn,Z as mn,Zt as hn,_ as gn,b as _n,bt as vn,c as yn,ct as bn,d as xn,dt as Sn,f as Cn,g as wn,gt as Tn,h as En,ht as Dn,i as On,it as kn,j as An,k as jn,kt as Mn,l as Nn,lt as Pn,m as Fn,mt as In,n as Ln,nt as Rn,o as zn,p as Bn,pt as Vn,s as Hn,st as Un,t as Wn,u as Gn,ut as Kn,v as qn,vt as Jn,w as Yn,x as Xn,xt as Zn,y as Qn,z as $n}from"./index-CYm7O8SE.js";import{a as er,t as tr}from"./drafts-CKYJHEPP.js";import{i as nr}from"./buffer-logic-BAkSBQT7.js";var rr=r(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),ir=r(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),ar=r(`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`}]]),or=r(`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`}]]),sr=r(`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`}]]),cr=r(`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`}]]),lr=r(`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`}]]),ur=r(`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`}]]),Y=r(`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`}]]),dr=r(`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`}]]),fr=r(`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`}]]),pr=r(`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`}]]),mr=r(`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`}]]),hr=r(`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`}]]),gr=r(`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`}]]),_r=r(`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`}]]),vr=r(`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`}]]),yr=r(`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`}]]),br=r(`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`}]]),xr=r(`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`}]]),Sr=r(`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`}]]),Cr=r(`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`}]]),wr=r(`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`}]]),Tr=r(`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`}]]),Er=r(`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`}]]),Dr=r(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),Or=r(`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`}]]),kr=r(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Ar=r(`message-circle-x`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),jr=r(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Mr=r(`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`}]]),Nr=r(`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`}]]),Pr=r(`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`}]]),Fr=r(`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`}]]),Ir=r(`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`}]]),Lr=r(`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`}]]),Rr=r(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),zr=r(`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`}]]),Br=r(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Vr=r(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Hr=r(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Ur=r(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Wr=r(`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`}]]),X=n(),Z=e(t(),1);function Gr(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Kr(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function qr(e){return e/100*window.innerHeight}function Jr(e){return e/100*window.innerWidth}function Yr(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 Xr({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Yr(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Kr(t,i);break;case`em`:r=Gr(t,i);break;case`vh`:r=qr(i);break;case`vw`:r=Jr(i);break}return r}function Zr(e){return parseFloat(e.toFixed(3))}function Qr({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 $r(e){let{panels:t}=e,n=Qr({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=Zr(Xr({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Zr(Xr({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Zr(Xr({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Zr(Xr({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 ei(e,t){return Array.from(t).sort(e===`horizontal`?ti:ni)}function ti(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function ni(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function ri(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function ii(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 ai({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}=ii(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Q(i,`No rect found`),i}var oi;function si(){return oi===void 0&&(oi=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),oi}function ci(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=ei(n,Array.from(t.children).filter(ri).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,ai({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=si()?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:Qr({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 li=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)}}},ui={cursorFlags:0,state:`inactive`},di=new li;function fi(){return ui}function pi(e){return di.addListener(`change`,e)}function mi(e){let t=ui,n={...ui};n.cursorFlags=e,ui=n,di.emit(`change`,{prev:t,next:n})}function hi(e){let t=ui;ui=e,di.emit(`change`,{prev:t,next:e})}var gi=e=>e,_i=()=>{},vi=1,yi=2,bi=4,xi=8,Si=3,Ci=12,wi;function Ti(){return wi===void 0&&(wi=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(wi=!0)),wi}function Ei({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&&Ti()){let t=(e&vi)!==0,n=(e&yi)!==0,r=(e&bi)!==0,i=(e&xi)!==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 Ti()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Di=new WeakMap;function Oi(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Di.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=fi();switch(r.state){case`active`:case`hover`:{let e=Ei({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}Di.set(e,{prevStyle:t,styleSheet:n})}var ki=new Map,Ai=new li;function ji(e){ki=new Map(ki),ki.delete(e)}function Mi(e,t){for(let[t]of ki)if(t.id===e)return t}function Ni(e,t){for(let[t,n]of ki)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Pi(){return ki}function Fi(e,t){return Ai.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Ii(e,t,n){let r=ki.get(e);ki=new Map(ki),ki.set(e,t),Ai.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Li(e){let t=fi(),n=!1;switch(t.state){case`active`:hi({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Oi(e),n=!0,t.hitRegions.forEach(e=>{let t=Ni(e.group.id,!0);Ii(e.group,t,{isUserInteraction:!0})}))}return n}function Ri(e){e.defaultPrevented||Li(e.currentTarget)}function zi(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=ii(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 Bi(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Vi(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:qi(e),b:qi(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:Ki(Gi(n.a)),b:Ki(Gi(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 Hi=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ui(e){let t=getComputedStyle(Ji(e)??e).display;return t===`flex`||t===`inline-flex`}function Wi(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Ui(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`||Hi.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Gi(e){let t=e.length;for(;t--;){let n=e[t];if(Q(n,`Missing node`),Wi(n))return n}return null}function Ki(e){return e&&Number(getComputedStyle(e).zIndex)||0}function qi(e){let t=[];for(;e;)t.push(e),e=Ji(e);return t}function Ji(e){let{parentNode:t}=e;return Bi(t)?t.host:t}function Yi(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 Xi({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!ri(n)||n.contains(e)||e.contains(n))return!0;if(Vi(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Yi(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Zi(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=ci(r),a=zi(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Xi({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Qi(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 $i(e,t,n=0){return Math.abs(Zr(e)-Zr(t))<=n}function ea(e,t){return $i(e,t)?0:e>t?1:-1}function ta({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(ea(r,c)<0)if(a){let e=(i+c)/2;r=ea(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Zr(r),r}function na({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if($i(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}`),$i(n,i)){let t=o-n;ea(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}`),$i(n,o)){let t=n-i;ea(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&&ea(i,c)<0)if(e>0){let t=c-o,n=t/2;ea(i+e,c)<0&&(e=ea(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;ea(i-e,c)<0&&(e=ea(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=ta({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=ta({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!$i(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(Qi(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=ta({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!$i(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=ta({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if($i(i,s)||(t-=s-i,l[r]=s),$i(t,0))break;e>0?r--:r++}}}if(!$i(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 ra(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||ea(e[n],t[n])!==0)return!1;return!0}function ia({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(!$i(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=ta({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!$i(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=ta({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,$i(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function aa({groupId:e,panelId:t}){let n=()=>{let t=Pi();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&&$i(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:Zr(100-e)}}return na({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=ia({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});ra(c,u)||Ii(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&&$i(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Qr({group:t}),o=Zr(Xr({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function oa(e){e.defaultPrevented||Zi(e,Pi()).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=aa({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function sa(e){let t=Pi();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 ca({groupId:e}){let t=()=>{let t=Pi();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=ia({layout:e,panelConstraints:r});return n?o:(ra(o,c)||Ii(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function la(e,t){let n=sa(e),r=Ni(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=ca({groupId:n.id}).getLayout(),c=ia({layout:na({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});ra(s,c)||Ii(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function ua(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=sa(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&la(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&la(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&la(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&la(t,-5);break;case`End`:e.preventDefault(),la(t,100);break;case`Enter`:{e.preventDefault();let n=sa(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=Ni(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];la(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=sa(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(),la(t,-100);break}}function da(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Pi(),n=Zi(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)}),hi({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function fa({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=na({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(ra(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?vi:yi;break;case`vertical`:s|=d<0?bi:xi;break}}else Ii(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Si:c|=s&Si,t.movementY===0?c|=o&Ci:c|=s&Ci,mi(c),Oi(e)}function pa(e){let t=Pi(),n=fi();switch(n.state){case`active`:fa({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function ma(e){if(e.defaultPrevented)return;let t=fi(),n=Pi();switch(t.state){case`active`:if(e.buttons===0){hi({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=Ni(e.group.id,!0);Ii(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)}fa({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Zi(e,n);r.length===0?t.state!==`inactive`&&hi({cursorFlags:0,state:`inactive`}):hi({cursorFlags:0,hitRegions:r,state:`hover`}),Oi(e.currentTarget);break}}}function ha(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(fi().state){case`hover`:hi({cursorFlags:0,state:`inactive`})}}function ga(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Li(e.currentTarget)&&e.preventDefault()}function _a(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Zr(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Zr((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function va(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Qr({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Zr(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function ya(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 ba({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=Zr(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]=Zr((r[e]??0)/a*l);else{let e=Zr(l/c.length);for(let t of c)u[t]=e}return u}function xa(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 Sa=new Map;function Ca(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=Qr({group:e});if(t===0)return;let n=Ni(e.id);if(!n)return;let r=$r(e),i=n.defaultLayoutDeferred?_a(r):n.layout,a=ia({layout:ba({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&ra(n.layout,a)&&ya(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Ii(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else va(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=Qr({group:e}),s=$r(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(xa(e.panels,l)||(l=void 0));let u=ia({layout:e.mutableState.layouts[c]??l??_a(s),panelConstraints:s}),d=e.element.ownerDocument;Sa.set(d,(Sa.get(d)??0)+1);let f=new Map;return ci(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Ii(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`,ua)}),Sa.get(d)===1&&(d.addEventListener(`contextmenu`,Ri,!0),d.addEventListener(`dblclick`,oa,!0),d.addEventListener(`pointerdown`,da,!0),d.addEventListener(`pointerleave`,pa),d.addEventListener(`pointermove`,ma),d.addEventListener(`pointerout`,ha),d.addEventListener(`pointerup`,ga,!0)),function(){t=!1,Sa.set(d,Math.max(0,(Sa.get(d)??0)-1)),ji(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,ua)}),Sa.get(d)||(d.removeEventListener(`contextmenu`,Ri,!0),d.removeEventListener(`dblclick`,oa,!0),d.removeEventListener(`pointerdown`,da,!0),d.removeEventListener(`pointerleave`,pa),d.removeEventListener(`pointermove`,ma),d.removeEventListener(`pointerout`,ha),d.removeEventListener(`pointerup`,ga,!0)),a.disconnect()}}function wa(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function Ta(e){let t=(0,Z.useId)();return`${e??t}`}var Ea=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function Da(e){let t=(0,Z.useRef)(e);return Ea(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function Oa(...e){return Da(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function ka(e){let t=(0,Z.useRef)({...e});return Ea(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Aa=(0,Z.createContext)(null);function ja(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:gi});(0,Z.useImperativeHandle)(t,()=>n.current,[]),Ea(()=>{Object.assign(n.current,ca({groupId:e}))})}function Ma({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,Z.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=Da(e=>{ra(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Da((e,t)=>{ra(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=Ta(s),v=(0,Z.useRef)(null),[y,b]=wa(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Oa(v,a);ja(_,o);let C=Da((e,t)=>{let r=fi(),i=Mi(e),a=Ni(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=ka({defaultLayout:n,disableCursor:r}),T=(0,Z.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=ei(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=ei(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=Mi(_),i=Ni(_);r&&i&&Ii(r,{...i,derivedPanelConstraints:$r(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,Z.useRef)(null);return Ea(()=>{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=Ca(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=Ni(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=Fi(_,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=$i(t.collapsedSize,i[t.panelId]),a=$i(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=fi().state!==`active`;h(i),o&&g(i,e.isUserInteraction)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,Z.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,X.jsx)(Aa.Provider,{value:T,children:(0,X.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})})}Ma.displayName=`Group`;function Na(){let e=(0,Z.useContext)(Aa);return Q(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Pa(e,t){let{id:n}=Na(),r=(0,Z.useRef)({collapse:_i,expand:_i,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:_i});(0,Z.useImperativeHandle)(t,()=>r.current,[]),Ea(()=>{Object.assign(r.current,aa({groupId:n,panelId:e}))})}function Fa({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=Ta(c),_=ka({disabled:a}),v=(0,Z.useRef)(null),y=Oa(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Na(),T=d!==null,E=Da((e,t,n)=>{d?.(e,c,n)});Ea(()=>{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,Z.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Pa(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Z.useSyncExternalStore)(e=>Fi(x,e),D,D),k;return k=O?JSON.parse(O):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,X.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Ia,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,X.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Fa.displayName=`Panel`;var Ia={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function La({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=ia({layout:na({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=ia({layout:na({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Ra({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=Ta(a),l=ka({disabled:n,disableDoubleClick:r}),[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(`inactive`),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=Oa(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=Na(),C=b===`horizontal`?`vertical`:`horizontal`;Ea(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=pi(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Fi(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(La({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,Z.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,X.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})}Ra.displayName=`Separator`;function za(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Ba(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Va(e){let t=e.split(`/`).filter(e=>e!==``);t.pop();let n=[];for(let e of t)n.push(Ua(n[n.length-1]??``,e));return n}function Ha(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function Ua(e,t){return e===``?t:`${e}/${t}`}function Wa(e,t){return t===``?e:`${e.replace(/\/+$/,``)}/${t}`}function Ga(e){let t=new Set(e);return e.filter(e=>{if(e===``)return!0;for(let n=Ba(e);;n=Ba(n)){if(t.has(n))return!1;if(n===``)return!0}})}var Ka=`application/x-puddle-paths`;function qa(e){return JSON.stringify(e)}function Ja(e){try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ya(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=Ua(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 Xa(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)}function Za(e){if(e===null)return!1;if($n(e)===`untitled`){let t=me(e.path);return t===void 0?!1:(ye({name:e.path,content:t}),!0)}return pe(we(e.session,e.path,e.root))}function Qa({request:e,targetSession:t,targetRoot:n,targetLabel:r,profileId:i,onClose:a,onSaved:o}){let[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&(c(e.name),u(null))},[e]);let p=async()=>{if(!e||!t)return;let a=s.trim().replace(/^\/+/,``).replace(/\/+$/,``);if(a===``){u(`Give the file a path.`);return}f(!0),u(null);try{let s=!0;try{await g(`GET`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Te(n)}`)}catch(e){if(e instanceof F&&e.status===404)s=!1;else if(e instanceof F&&e.status===413)s=!0;else throw e}if(s){u(`${a} already exists in ${r}.`);return}await g(`PUT`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Te(n)}`,{content:e.content}),i!==void 0&&await Ce(i,e.name).catch(()=>void 0),ge(e.name),o(e.name,t.id,a,n)}catch(e){u(e instanceof Error?e.message:`Save failed`)}finally{f(!1)}};return(0,X.jsx)(Be,{open:e!==null,onOpenChange:e=>!e&&a(),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Save draft into the worktree`}),(0,X.jsx)(ze,{children:t?(0,X.jsxs)(X.Fragment,{children:[`Saves into `,(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:r}),` — what the sidebar is bound to.`]}):`No worktree is bound — open or focus a session first.`})]}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(Ue,{htmlFor:`untitled-path`,children:`Worktree-relative path`}),(0,X.jsx)(Ge,{id:`untitled-path`,placeholder:`docs/notes.md`,value:s,onChange:e=>c(e.target.value),autoFocus:!0})]}),l&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:l}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{type:`button`,variant:`ghost`,onClick:a,children:`Cancel`}),(0,X.jsx)(H,{type:`submit`,disabled:d||!t,children:`Save`})]})]})]})})}function $a(e,t){return t??e.root??e.session?.worktree_path??null}function eo(e,t){return{...e,unpin(){t(),e.unpin()}}}function to(e){return{id:m,project_id:e.projectId,account_id:null,worktree_path:e.path,base_branch:e.defaultBranch,branch:e.defaultBranch,separate_branch:!1,kind:`terminal`,agent_type:null,agent_session_ref:null,title:e.name,status:`exited`,skip_permissions:!1,created_at:`1970-01-01T00:00:00.000Z`,updated_at:`1970-01-01T00:00:00.000Z`,last_activity_at:null}}function no(e,t,n,r=null){let i=n.snapshot.explorer_pin,a=i===null?null:e.find(e=>e.id===i&&e.status!==`archived`)??null,o=a??e.find(e=>e.id===t)??null,s=o===null&&r!==null;return{session:s?to(r):o,root:s?r.path:void 0,isProjectDirectory:s,pinned:a!==null,pin(e){n.update({explorer_pin:e})},unpin(){n.update({explorer_pin:null})}}}function ro(e,t){if(e.root===void 0)return{directory:t,path:e.path};let n=Wa(e.root,Ba(e.path));return{directory:n,path:za(e.path),browseRoot:n}}var io=null,ao=null;async function oo(){let[e,t]=await Promise.all([ke(()=>import(`./PaneEditorBody-CRFah0Fn.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])),ke(()=>import(`./ModelRefcount-CCRR4bB-.js`),__vite__mapDeps([21,1,2,16,6,9,3,4,10,11,12,14,15,17]))]);io=e.PaneEditorBody,ao=t.ModelRefcount}var so=(0,Z.lazy)(()=>ke(()=>import(`./PaneEditorBody-CRFah0Fn.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,20])));function co(e){return io?(0,X.jsx)(io,{...e}):(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-xs text-fg-muted`,children:`Loading editor…`}),children:(0,X.jsx)(so,{...e})})}var lo=(0,Z.lazy)(()=>ke(()=>import(`./ModelRefcount-CCRR4bB-.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([21,1,2,16,6,9,3,4,10,11,12,14,15,17])));function uo({buffers:e}){return ao?(0,X.jsx)(ao,{buffers:e}):(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(lo,{buffers:e})})}var fo=(0,Z.lazy)(()=>ke(()=>import(`./EditorTabClose-DOvQ8kvf.js`).then(e=>({default:e.EditorDirtyDot})),__vite__mapDeps([22,1,2,3,10,16,6,9,4,11,12,14,15,17,18,19])));function po(e){return(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(fo,{...e})})}var mo=(0,Z.lazy)(()=>ke(()=>import(`./EditorTabClose-DOvQ8kvf.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([22,1,2,3,10,16,6,9,4,11,12,14,15,17,18,19])));function ho(e){return(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onClose()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${e.label}`,children:`×`}),children:(0,X.jsx)(mo,{...e})})}var go=e(i(),1),_o=(0,Z.createContext)(null);function vo({tree:e,parked:t=[],onOpenFile:n,children:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(new Map).current,[o,s]=(0,Z.useState)(()=>new Set),c=(0,Z.useCallback)((e,t)=>{s(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),l=[...t].sort().join(`,`),u=(0,Z.useMemo)(()=>{let t=new Set;for(let n of En(e))for(let e of n.tabs)e.type===`terminal`&&t.add(e.session);for(let e of l===``?[]:l.split(`,`))t.add(e);return[...t].sort()},[e,l]),d=e=>{let t=`term:${e}`,n=a.get(t);return n||(n=document.createElement(`div`),n.className=`size-full`,a.set(t,n)),n};(0,Z.useEffect)(()=>{let e=new Set(u.map(e=>`term:${e}`));for(let e of u){let t=a.get(`term:${e}`);t&&!t.parentElement&&i.current?.appendChild(t)}for(let[t,n]of[...a])e.has(t)||(n.remove(),a.delete(t))},[u,a]);let f=(0,Z.useMemo)(()=>({parkingRef:i,containers:a,setAdopted:c}),[a,c]);return(0,X.jsxs)(_o.Provider,{value:f,children:[(0,X.jsx)(`div`,{ref:i,className:`hidden`,"aria-hidden":!0}),u.map(e=>(0,go.createPortal)((0,X.jsx)(Qe,{stream:e,paused:!o.has(`term:${e}`),onOpenFile:t=>n(e,t)}),d(e),e)),r]})}function yo(e){let t=(0,Z.useContext)(_o),n=(0,Z.useRef)(null);return(0,Z.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}var bo=null,xo=new Set;function So(e){bo=e,xo.forEach(t=>t(e))}function Co(e){return xo.add(e),bo&&e(bo),()=>xo.delete(e)}function wo(){bo=null}var To=20,Eo=new Map;function Do(e,t){let n=Eo.get(e)??[];n.push(t),n.length>To&&n.shift(),Eo.set(e,n)}function Oo(e,t){let n=Eo.get(e);for(;n&&n.length>0;){let e=n.pop();if(t(e.ref))return e}}function ko(e){let[t,n]=(0,Z.useState)(()=>window.matchMedia(e).matches);return(0,Z.useEffect)(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return n(t.matches),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Ao=`(max-width: 767px)`;function jo(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`number`)return;n[r]=t}return n}var Mo=`puddle.pane-height.`;function No(e){try{let t=localStorage.getItem(`${Mo}${e}`);if(t===null)return null;let n=Number(t);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function Po(e,t,{sized:n,min:r=64}){let[i,a]=(0,Z.useState)(()=>No(e)??t),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(i);return c.current=i,{height:i,handle:{dragging:o,onPointerDown:(0,Z.useCallback)(t=>{if(t.button!==0)return;t.preventDefault();let i=t.currentTarget,o=t.clientY,l=c.current,u=i.parentElement?.getBoundingClientRect().height??window.innerHeight,d=Math.max(r,u-96);i.setPointerCapture(t.pointerId),s(!0);let f=e=>{let t=e.clientY-o,i=n===`below`?l-t:l+t;a(Math.round(Math.min(d,Math.max(r,i))))},p=()=>{i.removeEventListener(`pointermove`,f),i.removeEventListener(`pointerup`,p),i.removeEventListener(`pointercancel`,p),s(!1);try{localStorage.setItem(`${Mo}${e}`,String(c.current))}catch{}};i.addEventListener(`pointermove`,f),i.addEventListener(`pointerup`,p),i.addEventListener(`pointercancel`,p)},[e,r,n])}}}function Fo({handle:e,label:t,className:n}){return(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":t,onPointerDown:e.onPointerDown,className:a(`relative h-px shrink-0 cursor-row-resize touch-none bg-border transition-colors hover:bg-accent`,e.dragging&&`bg-accent`,n),children:(0,X.jsx)(`div`,{className:`absolute inset-x-0 -top-1 h-[9px]`})})}var Io=80,Lo=180;function Ro(e){return Math.max(Lo,Math.round(e/Io*1e3))}function zo({text:e,hoverClass:t,className:n,containerClassName:r,title:i,children:o}){let s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>l(Math.max(0,e.scrollWidth-e.clientWidth));t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]),(0,X.jsx)(`span`,{className:a(`block min-w-0 flex-1 overflow-hidden`,r),children:(0,X.jsx)(`span`,{ref:s,title:i,className:a(`block whitespace-nowrap transition-transform ease-linear`,n,c>0&&t),style:c>0?{"--tail":`-${c}px`,transitionDuration:`${Ro(c)}ms`}:void 0,children:o??e})})}var Bo={added:{letter:`A`,label:`added`,colourClass:`text-success`},modified:{letter:`M`,label:`modified`,colourClass:`text-fg-secondary`},deleted:{letter:`D`,label:`deleted`,colourClass:`text-interrupted`},renamed:{letter:`R`,label:`renamed`,colourClass:`text-warning`}};function Vo(e){return Bo[e]}var Ho=[`modified`,`added`,`deleted`,`renamed`];function Uo(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return Ho.filter(e=>t.has(e)).map(e=>`${t.get(e)} ${Bo[e].label}`).join(` · `)}var Wo=[`var(--accent)`,`var(--status-running)`,`var(--status-waiting)`,`var(--ansi-magenta)`,`var(--ansi-cyan)`,`var(--status-interrupted)`];function Go(e){return Wo[e%Wo.length]}function Ko(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:Go(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=Go(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 qo=7,Jo=14,Yo=4,Xo=1.5,Zo=40,Qo=22,$o=`group-hover:[transform:translateX(var(--tail))]`;function es(e){return e*Jo+Jo/2}function ts(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 ns({row:e,width:t}){let n=Zo,r=n/2,i=es(e.col),a=new Set(e.created),o=[];for(let t of e.above){let n=es(t.col);t.sha===e.sha?o.push({d:ts(n,0,i,r),colour:t.colour}):o.push({d:ts(n,0,n,r),colour:t.colour})}for(let t of e.below){let e=es(t.col);a.has(t.col)?o.push({d:ts(i,r,e,n),colour:t.colour}):o.push({d:ts(e,r,e,n),colour:t.colour})}return(0,X.jsxs)(`svg`,{width:t,height:n,className:`shrink-0`,"aria-hidden":!0,children:[o.map((e,t)=>(0,X.jsx)(`path`,{d:e.d,fill:`none`,stroke:e.colour,strokeWidth:Xo},t)),(0,X.jsx)(`circle`,{cx:i,cy:r,r:Yo,fill:`var(--bg-surface)`,stroke:e.colour,strokeWidth:Xo})]})}function rs({lanes:e,width:t}){return(0,X.jsx)(`svg`,{width:t,height:Qo,className:`shrink-0`,"aria-hidden":!0,children:e.map(e=>{let t=es(e.col);return(0,X.jsx)(`path`,{d:`M ${t} 0 L ${t} ${Qo}`,fill:`none`,stroke:e.colour,strokeWidth:Xo},e.col)})})}function is({session:e,sha:t,root:n,lanes:r,gutterW:i,onOpen:o}){let s=se(e,t,n),c=e=>(0,X.jsxs)(`div`,{className:`flex items-center`,style:{height:Qo},children:[(0,X.jsx)(rs,{lanes:r,width:i}),(0,X.jsx)(`span`,{className:`px-2 text-2xs text-fg-muted`,children:e})]});return s.isPending?c(`…`):s.error?c(s.error instanceof Error?s.error.message:`Failed to load commit`):s.data.files.length===0?c(`No file changes.`):(0,X.jsx)(X.Fragment,{children:s.data.files.map(e=>{let s=Vo(e.status),c=e.status===`renamed`&&e.old_path?`${e.old_path} → ${e.path}`:e.path;return(0,X.jsxs)(`button`,{type:`button`,title:c,onClick:()=>{o(e.path,t),So({path:e.path,root:n})},onDoubleClick:()=>o(e.path,t,{preview:!1}),className:`group flex w-full items-center text-left transition-colors hover:bg-elevated`,style:{height:Qo},children:[(0,X.jsx)(rs,{lanes:r,width:i}),(0,X.jsx)(`span`,{className:a(`mr-1.5 w-3 shrink-0 text-center font-mono text-xs`,s.colourClass),children:s.letter}),(0,X.jsx)(zo,{text:c,className:`pr-3 text-2xs text-fg`,hoverClass:$o})]},`${e.status}:${e.old_path??``}:${e.path}`)})})}function as({session:e,root:t,onOpenCommitFile:n}){let r=le(e,{root:t}),[i,o]=(0,Z.useState)(null),s=(0,Z.useMemo)(()=>r.data?.pages.flatMap(e=>e.commits)??[],[r.data]),c=(0,Z.useMemo)(()=>Ko(s),[s]),l=Math.max(1,c.laneCount)*Jo+Jo/2;return r.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading history…`}):r.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load history`}):s.length===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No commits yet.`}):(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[c.rows.map((r,c)=>{let u=s[c],d=i===r.sha;return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(d?null:r.sha),className:a(`group flex w-full items-center text-left transition-colors hover:bg-elevated`,d&&`bg-selection`),style:{height:Zo},children:[(0,X.jsx)(ns,{row:r,width:l}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 pr-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-2xs text-fg-muted`,children:r.sha.slice(0,qo)}),(0,X.jsx)(zo,{text:u.subject,className:`text-xs text-fg`,hoverClass:$o})]}),(0,X.jsxs)(`span`,{className:`truncate text-2xs text-fg-muted`,children:[u.author_name,` ·`,` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:he(u.authored_at)})]})]})]}),d&&(0,X.jsx)(is,{session:e,sha:r.sha,root:t,lanes:r.below,gutterW:l,onOpen:n})]},r.sha)}),r.hasNextPage&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>void r.fetchNextPage(),disabled:r.isFetchingNextPage,className:`px-3 py-2 text-left text-xs text-fg-muted transition-colors hover:bg-elevated`,children:r.isFetchingNextPage?`Loading…`:`Show more`})]})}function os(){return{dirs:new Map,files:[]}}function ss(e){return e.path}function cs(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:cs(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 ls(e){let t=os();for(let n of e){let e=ss(n),r=e.split(`/`),i=r.pop(),a=t;for(let e of r){let t=a.dirs.get(e);t||(t=os(),a.dirs.set(e,t)),a=t}a.files.push({type:`file`,name:i,path:e,entry:n})}return cs(t,``)}function us(e){return e.map(e=>({type:`file`,name:ss(e).split(`/`).pop()??ss(e),path:ss(e),entry:e})).sort((e,t)=>e.path.localeCompare(t.path,void 0,{sensitivity:`base`}))}function ds(e){return e.type===`file`?[e.entry]:e.children.flatMap(ds)}var fs=`group-hover:[transform:translateX(var(--tail))]`;function ps({name:e,fullPath:t,status:n,depth:r,active:i,onOpen:o}){let s=Vo(n);return(0,X.jsxs)(`button`,{type:`button`,title:t,onClick:()=>o(t),onDoubleClick:()=>o(t,{preview:!1}),className:a(`group 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,X.jsx)(`span`,{className:a(`w-3 shrink-0 text-center font-mono text-xs`,s.colourClass),children:s.letter}),(0,X.jsx)(zo,{text:e,className:`text-xs text-fg`,hoverClass:fs})]})}function ms({nodes:e,depth:t,activePath:n,onOpen:r}){let[i,a]=(0,Z.useState)(new Set);return(0,X.jsx)(X.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,X.jsx)(ps,{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,X.jsxs)(`div`,{children:[(0,X.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:`group flex w-full items-center gap-1 py-1 pr-3 text-left transition-colors hover:bg-elevated`,style:{paddingLeft:8+t*12},title:e.path,children:[o?(0,X.jsx)(Ut,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,X.jsx)(Ht,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e.name,className:`text-xs text-fg-secondary`,hoverClass:fs})]}),!o&&(0,X.jsx)(ms,{nodes:e.children,depth:t+1,activePath:n,onOpen:r})]},e.path)})})}function hs({session:e,root:t,activePath:n,onOpen:r}){let[i,a]=(0,Z.useState)(!1),o=ue(e,{against:`head`,root:t}),s=o.data?.entries??[],c=(e,n)=>{r(e,n),So({path:e,root:t})},l=(0,Z.useMemo)(()=>i?null:ls(s),[i,s]),u=(0,Z.useMemo)(()=>i?us(s):null,[i,s]);return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 px-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Uncommitted`}),s.length>0&&(0,X.jsx)(`span`,{className:`truncate text-2xs text-fg-muted`,children:Uo(s)}),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":!i,onClick:()=>a(e=>!e),className:`ml-auto rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[i?(0,X.jsx)(Or,{className:`size-3.5`}):(0,X.jsx)(Cr,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:i?`Show as tree`:`Show as flat list`})]})}),(0,X.jsx)(J,{children:i?`Show as tree`:`Show as flat list`})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:o.isPending?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`Loading changes…`}):o.error?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:o.error instanceof Error?o.error.message:`Failed to load changes`}):s.length===0?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`No uncommitted changes.`}):i?u.map(e=>(0,X.jsx)(ps,{name:e.path,fullPath:e.path,status:e.entry.status,depth:0,active:n===e.path,onOpen:c},e.path)):(0,X.jsx)(ms,{nodes:l,depth:0,activePath:n,onOpen:c})})]})}var gs={untracked:{letter:`U`,colourClass:`text-success`},added:{letter:`A`,colourClass:`text-success`},modified:{letter:`M`,colourClass:`text-warning`},renamed:{letter:`R`,colourClass:`text-warning`},deleted:{letter:`D`,colourClass:`text-interrupted`},conflicted:{letter:`C`,colourClass:`text-interrupted`},ignored:{letter:``,colourClass:`text-fg-muted`}};function _s(e){return gs[e]}function vs(e){let t=new Map;for(let n of e)t.set(n.path,n.status);return t}var ys={conflicted:0,modified:1,renamed:2,deleted:3,added:4,untracked:5,ignored:6};function bs(e,t){let n=t===``?``:`${t}/`,r=null;for(let[t,i]of e)n!==``&&!t.startsWith(n)||i!==`ignored`&&(r===null||ys[i]<ys[r])&&(r=i);return r}function xs(e){let t=new Set;for(let n of e)t.add(n.path),n.old_path!==null&&t.add(n.old_path);return[...t]}var Ss=`group-hover:[transform:translateX(var(--tail))]`,Cs=`group-hover/repository:[transform:translateX(var(--tail))]`,ws=`group-hover:[transform:translateX(var(--tail))]`;function Ts({label:e,onClick:t,disabled:n,className:r,children:i}){return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":e,disabled:n,onClick:e=>{e.stopPropagation(),t()},className:a(`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,r),children:i})}),(0,X.jsx)(J,{children:e})]})}function Es({title:e,entries:t,area:n,activePath:r,action:i,busy:a,flat:o,onAction:s,onOpen:c}){let[l,u]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>o?null:ls(t),[t,o]);if(t.length===0)return null;let f=i===`stage`;return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`group flex h-7 items-center gap-1 px-3`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex min-w-0 flex-1 items-center gap-1 text-left text-2xs font-medium uppercase tracking-wide text-fg-gold transition-colors hover:text-fg`,children:[l?(0,X.jsx)(Ut,{className:`size-3`}):(0,X.jsx)(Ht,{className:`size-3`}),(0,X.jsx)(`span`,{className:`truncate`,children:e}),(0,X.jsx)(`span`,{className:`ml-1 text-fg-muted`,children:t.length})]}),(0,X.jsx)(Ts,{label:`${f?`Stage`:`Unstage`} all ${e.toLowerCase()}`,disabled:a,onClick:()=>s(xs(t)),children:f?(0,X.jsx)(W,{className:`size-3.5`}):(0,X.jsx)(jr,{className:`size-3.5`})})]}),!l&&(o?t.map(e=>(0,X.jsx)(Ds,{entry:e,name:e.path,depth:0,area:n,active:r===e.path,action:i,busy:a,onAction:s,onOpen:c},`${e.path}:${e.old_path??``}`)):(0,X.jsx)(Os,{nodes:d,depth:0,area:n,activePath:r,action:i,busy:a,onAction:s,onOpen:c}))]})}function Ds({entry:e,name:t,depth:n,area:r,active:i,action:o,busy:s,onAction:c,onOpen:l}){let u=_s(e.status),d=o===`stage`;return(0,X.jsxs)(`div`,{className:a(`group flex items-center gap-1 pr-3 transition-colors hover:bg-elevated`,i&&`bg-selection`),style:{paddingLeft:12+n*12},children:[(0,X.jsxs)(`button`,{type:`button`,title:e.path,onClick:()=>l(e.path,{root:void 0,gitArea:r}),onDoubleClick:()=>l(e.path,{preview:!1,root:void 0,gitArea:r}),className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left`,children:[(0,X.jsx)(`span`,{className:a(`w-3 shrink-0 text-center font-mono text-xs`,u.colourClass),children:u.letter}),(0,X.jsx)(zo,{text:t,className:`text-xs text-fg`,hoverClass:ws})]}),(0,X.jsx)(Ts,{label:`${d?`Stage`:`Unstage`} ${e.path}`,disabled:s,onClick:()=>c(xs([e])),children:d?(0,X.jsx)(W,{className:`size-3.5`}):(0,X.jsx)(jr,{className:`size-3.5`})})]})}function Os({nodes:e,depth:t,area:n,activePath:r,action:i,busy:a,onAction:o,onOpen:s}){let[c,l]=(0,Z.useState)(new Set),u=i===`stage`;return(0,X.jsx)(X.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,X.jsx)(Ds,{entry:e.entry,name:e.name,depth:t,area:n,active:r===e.path,action:i,busy:a,onAction:o,onOpen:s},`${e.entry.path}:${e.entry.old_path??``}`);let d=c.has(e.path);return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`group flex items-center gap-1 pr-3 transition-colors hover:bg-elevated`,style:{paddingLeft:12+t*12},children:[(0,X.jsxs)(`button`,{type:`button`,title:e.path,onClick:()=>l(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),className:`flex min-w-0 flex-1 items-center gap-1 py-1 text-left`,children:[d?(0,X.jsx)(Ut,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,X.jsx)(Ht,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e.name,className:`text-xs text-fg-secondary`,hoverClass:ws})]}),(0,X.jsx)(Ts,{label:`${u?`Stage`:`Unstage`} ${e.path}`,disabled:a,onClick:()=>o(xs(ds(e))),children:u?(0,X.jsx)(W,{className:`size-3.5`}):(0,X.jsx)(jr,{className:`size-3.5`})})]}),!d&&(0,X.jsx)(Os,{nodes:e.children,depth:t+1,area:n,activePath:r,action:i,busy:a,onAction:o,onOpen:s})]},e.path)})})}function ks(e){return e.detached?`Detached at ${e.head?.slice(0,8)??`HEAD`}`:e.branch??`Unborn branch`}function As(e){return[ks(e),e.upstream,e.ahead>0?`${e.ahead} ahead`:null,e.behind>0?`${e.behind} behind`:null].filter(e=>e!=null).join(` · `)}function js({session:e,targetRoot:t,repository:n,selected:r,activePath:i,onSelect:o,onOpen:s}){let[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),h=_e(e,t),g=[...n.conflicts,...n.staged,...n.unstaged],_=h.isPending,v=async(e,t)=>{try{await h.mutateAsync(e),u.success(t)}catch(e){u.error(e instanceof Error?e.message:`Git operation failed`)}},y=(e,t)=>{v({action:e,repository:n.root,paths:t},e===`stage`?`Staged`:`Unstaged`)},b=async()=>{let e=p.trim();if(!e||_)return;let t=!1;if(n.staged.length===0){if(n.conflicts.length>0){u.error(`Resolve and stage merge changes before committing`);return}if(n.unstaged.length===0){u.error(`There are no changes to commit`);return}if(t=window.confirm(`Nothing is staged. Stage every change and commit it?`),!t)return}try{await h.mutateAsync({action:`commit`,repository:n.root,message:e,stage_all:t}),m(``),u.success(`Committed`)}catch(e){u.error(e instanceof Error?e.message:`Commit failed`)}},x=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),b())},S=(e,t)=>s(e,{...t,root:n.root});return(0,X.jsxs)(`section`,{className:a(`py-0.5`,r&&`bg-surface/40`),onFocus:o,children:[(0,X.jsxs)(`div`,{className:`flex h-8 items-center gap-1 pl-2 pr-2`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{o(),l(e=>!e)},className:`group/repository flex min-w-0 flex-1 items-center gap-1.5 text-left transition-colors hover:text-fg`,children:[c?(0,X.jsx)(Ut,{className:`size-3 shrink-0`}):(0,X.jsx)(Ht,{className:`size-3 shrink-0`}),(0,X.jsxs)(zo,{text:`${n.name} ${n.relative_path}`,title:`${n.name} ${n.relative_path}`,className:`text-xs`,hoverClass:Cs,children:[(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.name}),` `,(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:n.relative_path})]}),g.length>0&&(0,X.jsx)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:g.length})]}),!c&&n.initialised&&g.length>0&&(0,X.jsx)(Ts,{label:d?`Show changes as tree`:`Show changes as flat list`,onClick:()=>f(e=>!e),children:d?(0,X.jsx)(Or,{className:`size-3.5`}):(0,X.jsx)(Cr,{className:`size-3.5`})})]}),!c&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`group flex min-h-7 items-center px-3 text-2xs text-fg-muted`,children:(0,X.jsx)(zo,{text:As(n),title:As(n),hoverClass:Ss})}),n.initialised?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`px-3 pb-1.5 pt-1`,children:[(0,X.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),onKeyDown:x,rows:2,placeholder:`Commit message`,"aria-label":`Commit message for ${n.name}`,className:`w-full resize-none rounded-sm bg-elevated px-2 py-1.5 text-xs text-fg outline-none placeholder:text-fg-muted focus:ring-1 focus:ring-focus`}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-0.5`,children:[n.has_remote&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ts,{label:`Fetch`,disabled:_,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void v({action:`fetch`,repository:n.root},`Fetched`),children:(0,X.jsx)(ae,{className:`size-3.5`})}),n.upstream&&(0,X.jsx)(Ts,{label:`Pull`,disabled:_,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void v({action:`pull`,repository:n.root},`Pulled`),children:(0,X.jsx)(Ur,{className:`size-3.5 rotate-180`})}),n.branch&&(0,X.jsx)(Ts,{label:n.upstream?`Push`:`Publish branch`,disabled:_,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void v({action:`push`,repository:n.root,set_upstream:!n.upstream},n.upstream?`Pushed`:`Branch published`),children:n.upstream?(0,X.jsx)(Rr,{className:`size-3.5`}):(0,X.jsx)(Ur,{className:`size-3.5`})})]}),(0,X.jsx)(`button`,{type:`button`,disabled:_||p.trim().length===0,onClick:()=>void b(),className:`flex h-7 min-w-0 flex-1 items-center justify-center rounded-sm bg-action px-2 text-xs text-action-ink transition-colors hover:bg-action-hover disabled:cursor-not-allowed disabled:opacity-40`,children:`Commit`})]})]}),(0,X.jsx)(Es,{title:`Merge Changes`,entries:n.conflicts,area:`unstaged`,activePath:i,action:`stage`,busy:_,flat:d,onAction:e=>y(`stage`,e),onOpen:S}),(0,X.jsx)(Es,{title:`Staged Changes`,entries:n.staged,area:`staged`,activePath:i,action:`unstage`,busy:_,flat:d,onAction:e=>y(`unstage`,e),onOpen:S}),(0,X.jsx)(Es,{title:`Changes`,entries:n.unstaged,area:`unstaged`,activePath:i,action:`stage`,busy:_,flat:d,onAction:e=>y(`stage`,e),onOpen:S}),g.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No changes.`})]}):(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Submodule not initialised.`})]})]})}function Ms({session:e,root:t,activeDiffPath:n,onOpenDiff:r,onOpenCommitFile:i}){let{height:a,handle:o}=Po(`changes-uncommitted`,240,{sized:`above`,min:80}),s=h(),c=s.data!==void 0&&Dn(s.data.protocol),l=V(e,{root:t,enabled:c}),[u,d]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!c||!l.data)return;let e=l.data.repositories;(!u||!e.some(e=>e.root===u))&&d(e[0]?.root??null)},[c,l.data,u]);let f=c?u??t:t;return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(`section`,{className:`flex shrink-0 flex-col`,style:{height:a,maxHeight:`70%`},children:c?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:l.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading repositories…`}):l.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:l.error instanceof Error?l.error.message:`Failed to load repositories`}):l.data.repositories.length===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No Git repositories.`}):l.data.repositories.map((i,a)=>(0,X.jsxs)(Z.Fragment,{children:[a>0&&(0,X.jsx)(`div`,{className:`mx-3 my-2 h-px bg-border`}),(0,X.jsx)(js,{session:e,targetRoot:t,repository:i,selected:u===i.root,activePath:n,onSelect:()=>d(i.root),onOpen:r})]},i.root))}):(0,X.jsx)(hs,{session:e,root:t,activePath:n,onOpen:r})}),(0,X.jsx)(Fo,{handle:o,label:`Resize the uncommitted changes`}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(`div`,{className:`flex h-7 shrink-0 items-center px-3`,children:(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`History`})}),(0,X.jsx)(as,{session:e,root:f,onOpenCommitFile:(e,t,n)=>i(e,t,{...n,root:f})})]})]})}function Ns(e,t,n){return e!==null&&e.id===t&&n-e.at<1500}var Ps=`puddle.explorerClipboard.v1`;function Fs(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.sid==`string`&&typeof t.directory==`string`&&(t.root===void 0||typeof t.root==`string`)&&(t.host===void 0||typeof t.host==`string`)}function Is(e){if(e===null)return null;try{let t=JSON.parse(e);return typeof t.id!=`string`||t.mode!==`cut`&&t.mode!==`copy`||!Array.isArray(t.paths)||t.paths.length===0||!t.paths.every(e=>typeof e==`string`)||!Fs(t.source)?null:t}catch{return null}}function Ls(){if(typeof localStorage>`u`)return null;try{return Is(localStorage.getItem(Ps))}catch{return null}}var Rs=Ls(),zs=new Set;function Bs(e,t){if(Rs=e,t&&typeof localStorage<`u`)try{e===null?localStorage.removeItem(Ps):localStorage.setItem(Ps,JSON.stringify(e))}catch{}for(let e of zs)e()}typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===Ps&&Bs(Is(e.newValue),!1)});function Vs(){return globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`}function Hs(e){return e?`${e.username}\0${e.hostname}\0${e.home}`:void 0}function Us(e,t){return e.directory===t.directory}function Ws(e,t){return e.host===void 0||t.host===void 0||e.host===t.host}function Gs(e,t){return e.host!==void 0&&e.host===t.host}function Ks(e,t,n){e.length!==0&&Bs({id:Vs(),paths:e,mode:t,source:n},!0)}function qs(e,t){Rs?.id!==e||Rs.mode!==`cut`||Bs(t.length===0?null:{...Rs,paths:t},!0)}function Js(e){return zs.add(e),()=>zs.delete(e)}function Ys(){return Rs}function Xs(){return(0,Z.useSyncExternalStore)(Js,Ys,()=>null)}async function Zs(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 Qs(e){return new Promise((t,n)=>e.file(t,n))}async function $s(e,t,n){if(e.isFile){let r=await Qs(e);n.push(t?new File([r],`${t}/${e.name}`,{type:r.type,lastModified:r.lastModified}):r)}else if(e.isDirectory){let r=await Zs(e),i=t?`${t}/${e.name}`:e.name;for(let e of r)await $s(e,i,n)}}function ec(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)&&u.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 $s(t,``,e):n&&e.push(n);return e})()}var tc=(e,t)=>e instanceof Error?e.message:t;function nc(e,t,n=t??``){let r=ee(),i=(0,Z.useCallback)(()=>{r.invalidateQueries({queryKey:[`wt-tree`,e]}),r.invalidateQueries({queryKey:[`wt-git-status`,e]})},[r,e]),a=(0,Z.useCallback)(e=>{r.invalidateQueries({queryKey:[`wt-tree`,e.sid]}),r.invalidateQueries({queryKey:[`wt-git-status`,e.sid]})},[r]);return(0,Z.useMemo)(()=>({async create(n,r,a){try{let o=await B(e,Ua(n,r),a,t);return i(),o.path}catch(e){return u.error(tc(e,`Couldn't create ${r}`)),null}},async rename(n,r){let a=Ua(n.includes(`/`)?n.slice(0,n.lastIndexOf(`/`)):``,r);try{let r=await oe(e,n,a,t);return i(),r.path}catch(e){return u.error(tc(e,`Couldn't rename ${za(n)}`)),null}},async move(n,r){let a=await Promise.allSettled(n.map(n=>oe(e,n,Ua(r,za(n)),t)));i();let o=a.filter(e=>e.status===`rejected`);o.length>0&&u.error(n.length===1?tc(o[0].reason,`Couldn't move ${za(n[0])}`):`Couldn't move ${o.length} item${o.length>1?`s`:``}`)},async remove(n){let r=await Promise.allSettled(n.map(n=>Ee(e,n,t)));i();let a=r.filter(e=>e.status===`rejected`).length;a>0?u.error(`Couldn't delete ${a} item${a>1?`s`:``}`):u.success(n.length===1?`Deleted ${za(n[0])}`:`Deleted ${n.length} items`)},async paste(r,o){let s={sid:e,root:t,directory:n},c=Us(r.source,s),l=await Promise.allSettled(r.paths.map(n=>{let i=Ua(o,za(n));return c?(r.mode===`cut`?oe:De)(e,n,i,t):z(e,{operation:r.mode===`cut`?`move`:`copy`,source:{session_id:r.source.sid,root:r.source.root},from:n,to:i},t)}));i(),!c&&r.mode===`cut`&&a(r.source);let d=r.paths.filter((e,t)=>l[t]?.status===`rejected`);return d.length>0&&u.error(`Couldn't paste ${d.length} item${d.length>1?`s`:``}`),d}}),[e,t,n,i,a])}function rc(e,t,n){return n&&n.type!==`dir`||(e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``)===t?!1:t===``||!`${t}/`.startsWith(`${e}/`)}var ic=(0,Z.createContext)(null);function ac(){let e=(0,Z.useContext)(ic);if(!e)throw Error(`explorer components must render inside <ExplorerProvider>`);return e}function oc(){return(0,Z.useContext)(ic)}function sc({session:e,root:t,readOnly:n=!1,onOpenFile:r,onOpenTerminal:i,activePath:a,children:o}){let s=e.id,c=ee(),l=t??e.worktree_path,d=nc(s,t,l),f=(0,Z.useCallback)(e=>t===void 0?[`wt-tree`,s,e]:[`wt-tree`,s,e,t],[s,t]),p=(0,Z.useCallback)((e,r)=>{r.length===0||n||R(s,e,r,t).then(()=>{c.invalidateQueries({queryKey:f(e)}),c.invalidateQueries({queryKey:[`wt-git-status`,s]}),u.success(r.length===1?`Uploaded ${r[0].name}`:`Uploaded ${r.length} files`)}).catch(e=>u.error(e instanceof Error?e.message:`Upload failed`))},[s,t,n,c,f]),m=h().data?.protocol,g=M(),_=(0,Z.useMemo)(()=>({sid:s,root:t,directory:l,host:Hs(g.data)}),[s,t,l,g.data]),v=!m||m.major>9||m.major===9&&m.minor>=2,y=(0,Z.useCallback)((e,t,n)=>{ec(t,n,v).then(t=>p(e,t)).catch(e=>u.error(e instanceof Error?e.message:`Couldn't read the dropped folder`))},[p,v]),[b,x]=(0,Z.useState)(new Set),[S,C]=(0,Z.useState)(new Set),[w,T]=(0,Z.useState)(null),E=Xs(),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,te]=(0,Z.useState)(null),ne=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=()=>A(null);return window.addEventListener(`dragend`,e),()=>window.removeEventListener(`dragend`,e)},[]);let N=ce(s,{root:t,enabled:t===void 0||m!==void 0&&Dn(m)}),P=(0,Z.useMemo)(()=>vs(N.data?.entries??[]),[N.data]),re=N.refetch,[ie,F]=(0,Z.useState)(0);(0,Z.useEffect)(()=>c.getQueryCache().subscribe(e=>{if(e.type!==`added`&&e.type!==`removed`&&e.type!==`updated`)return;let t=e.query.queryKey;Array.isArray(t)&&t[0]===`wt-tree`&&t[1]===s&&F(e=>e+1)}),[c,s]);let I=(0,Z.useMemo)(()=>Ya(e=>c.getQueryData(f(e)),b),[c,f,b,ie]),L=(0,Z.useCallback)(e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ae=(0,Z.useCallback)(e=>{x(t=>t.has(e)?t:new Set(t).add(e))},[]),oe=(0,Z.useCallback)(()=>x(new Set),[]),[se,le]=(0,Z.useState)(null);(0,Z.useEffect)(()=>Co(e=>{if(!(e.directory===void 0?e.root!==t:e.directory!==l)){wo();for(let t of Va(e.path))ae(t);e.expandTarget&&e.path!==``&&ae(e.path),C(new Set([e.path])),T(e.path),e.renameTarget&&!n&&O({mode:`rename`,path:e.path}),le(e.path)}}),[t,l,ae,n]),(0,Z.useEffect)(()=>{if(se===null)return;let e=document.querySelector(`[data-explorer-root] [data-path="${CSS.escape(se)}"]`);if(e){e.scrollIntoView({block:`nearest`}),le(null);return}let t=window.setTimeout(()=>le(null),4e3);return()=>window.clearTimeout(t)},[se,I]);let ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null),z=(0,Z.useCallback)(()=>{ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null)},[]);(0,Z.useEffect)(()=>z,[z]);let pe=(0,Z.useCallback)((e,t)=>{if(z(),T(e.path),t.metaKey||t.ctrlKey){C(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),ne.current=e.path;return}if(t.shiftKey&&ne.current){C(new Set(Xa(I,ne.current,e.path)));return}let i=Date.now(),a=de.current;if(de.current={id:e.path,at:i},e.type!==`dir`&&!n&&!D&&S.size===1&&S.has(e.path)&&Ns(a,e.path,i)){ue.current=window.setTimeout(()=>{ue.current=null,O({mode:`rename`,path:e.path})},500);return}C(new Set([e.path])),ne.current=e.path,e.type===`dir`?L(e.path):r?.(s,e.path)},[I,L,r,s,S,D,n,z]),B=(0,Z.useCallback)(e=>{z(),e.type!==`dir`&&r?.(s,e.path,{preview:!1})},[r,s,z]),me=(0,Z.useCallback)(e=>{C(new Set([e])),T(e),ne.current=e},[]),he=(0,Z.useCallback)(e=>Ks(Ga(e),`cut`,_),[_]),ge=(0,Z.useCallback)(e=>Ks(Ga(e),`copy`,_),[_]),V=E!==null&&Ws(E.source,_),_e=E!==null&&Us(E.source,_),ve=!n&&(V&&_e||E!==null&&Gs(E.source,_)&&Sn(m)),ye=(0,Z.useCallback)(e=>E?.mode===`cut`&&Ws(E.source,_)&&Us(E.source,_)&&E.paths.includes(e),[E,_]),be=(0,Z.useCallback)(e=>{if(!E||n)return;let t=Us(E.source,_);if(!Ws(E.source,_)){u.error(`That filetree clipboard belongs to another daemon host.`);return}if(!t&&!Gs(E.source,_)){u.error(`Copy again after daemon host information finishes loading.`);return}if(!t&&!Sn(m)){u.error(`Cross-filetree paste requires a daemon with protocol 16.3.`);return}d.paste(E,e).then(e=>{E.mode===`cut`&&qs(E.id,e)})},[E,d,m,n,_]),xe=(0,Z.useCallback)(e=>{n||O({mode:`rename`,path:e})},[n]),Se=(0,Z.useCallback)((e,t)=>{n||(e!==``&&ae(e),O({mode:`create`,parentDir:e,kind:t}))},[ae,n]),Ce=(0,Z.useCallback)(()=>O(null),[]),we=(0,Z.useCallback)(e=>{let t=e.trim(),n=D;if(O(null),!(!n||t===``))if(n.mode===`rename`){if(t===za(n.path))return;d.rename(n.path,t)}else d.create(n.parentDir,t,n.kind).then(e=>{e&&n.kind===`file`&&r?.(s,e)})},[D,d,r,s]),Te=(0,Z.useCallback)(e=>{if(n)return;let t=Ga(e);t.length>0&&te(t)},[n]),Ee=(0,Z.useCallback)(()=>{let e=j;te(null),e&&d.remove(e)},[j,d]),De=(0,Z.useCallback)(()=>te(null),[]),Oe=(0,Z.useCallback)((e,t)=>{let n=e.map(e=>t?e:Ua(l,e)).join(`
3
3
  `);navigator.clipboard.writeText(n);let r=t?`Relative path`:`Path`;u.success(e.length>1?`${e.length} ${r.toLowerCase()}s copied`:`${r} copied`)},[l]),ke=(0,Z.useCallback)(e=>{(async()=>{for(let n of Ga(e))await fe(s,n,t)})().catch(e=>u.error(e instanceof Error?e.message:`Download failed`))},[s,t]),Ae=(0,Z.useCallback)(()=>{c.invalidateQueries({queryKey:[`wt-tree`,s]}),re()},[c,s,re]),je=(0,Z.useCallback)((e,t)=>{if(n)return;let r=Ga(t).filter(t=>rc(t,e));r.length>0&&d.move(r,e)},[d,n]),Me=(0,Z.useCallback)(()=>w&&S.has(w)?[...S]:w?[w]:[...S],[w,S]),Ne=(0,Z.useRef)({buffer:``,at:0}),Pe={sid:s,rootPath:l,root:t,readOnly:n,onOpenFile:r,onOpenTerminal:i,activePath:a,expanded:b,toggle:L,collapseAll:oe,statusMap:P,visibleRows:I,selection:S,focusedPath:w,onRowClick:pe,onRowDoubleClick:B,selectOnly:me,clipboard:E,canPaste:ve,isCut:ye,cut:he,copy:ge,paste:be,editing:D,beginRename:xe,beginCreate:Se,cancelEdit:Ce,commitEdit:we,requestDelete:Te,copyPathToClipboard:Oe,download:ke,refresh:Ae,onUpload:p,onDropUpload:y,dropTarget:k,setDropTarget:A,onInternalDrop:je,handleKeyDown:(0,Z.useCallback)(e=>{if(D)return;let t=I;if(t.length===0)return;let n=w?t.findIndex(e=>e.path===w):-1,i=(e,n)=>{let r=t[Math.max(0,Math.min(t.length-1,e))];r&&(T(r.path),n&&ne.current?C(new Set(Xa(t,ne.current,r.path))):(C(new Set([r.path])),ne.current=r.path))},a=n>=0?t[n]:void 0,o=e.metaKey||e.ctrlKey;switch(e.key){case`ArrowDown`:e.preventDefault(),i(n+1,e.shiftKey);return;case`ArrowUp`:e.preventDefault(),i(n<=0?0:n-1,e.shiftKey);return;case`ArrowRight`:e.preventDefault(),a?.type===`dir`&&!b.has(a.path)?ae(a.path):a?.type===`dir`&&i(n+1,!1);return;case`ArrowLeft`:if(e.preventDefault(),a?.type===`dir`&&b.has(a.path))L(a.path);else if(a){let e=t.findIndex(e=>e.path===a.parentDir);e>=0&&i(e,!1)}return;case`Enter`:case` `:if(e.preventDefault(),!a)return;a.type===`dir`?L(a.path):r?.(s,a.path);return;case`F2`:e.preventDefault(),a&&xe(a.path);return;case`Delete`:e.preventDefault(),Te(Me());return;case`Backspace`:o&&(e.preventDefault(),Te(Me()));return}if(o&&(e.key===`c`||e.key===`C`)){e.preventDefault();let t=Me();e.altKey?Oe(t,e.shiftKey):ge(t);return}if(o&&(e.key===`x`||e.key===`X`)){e.preventDefault(),he(Me());return}if(o&&(e.key===`v`||e.key===`V`)){e.preventDefault();let t=a?a.type===`dir`?a.path:a.parentDir:``;be(t);return}if(!o&&!e.altKey&&e.key.length===1&&/\S/.test(e.key)){let r=Date.now(),a=Ne.current;a.buffer=r-a.at>700?e.key:a.buffer+e.key,a.at=r;let o=a.buffer.toLowerCase(),s=n+1;for(let e=0;e<t.length;e++){let n=t[(s+e)%t.length];if(n.name.toLowerCase().startsWith(o)){i(t.findIndex(e=>e.path===n.path),!1);break}}}},[D,I,w,b,ae,L,r,s,xe,Te,Me,ge,he,be,Oe]),pendingDelete:j,confirmDelete:Ee,cancelDelete:De};return(0,X.jsx)(ic.Provider,{value:Pe,children:o})}function cc(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}var lc=`application/x-puddle-tab`;function uc(e){return JSON.stringify(e)}function dc(e){try{return D.parse(JSON.parse(e))}catch{return null}}function fc(e){return e.includes(lc)}var pc={"package.json":ur,"package-lock.json":hr,"pnpm-lock.yaml":hr,"yarn.lock":hr,"pnpm-workspace.yaml":dr,dockerfile:Y,".gitignore":dr,".gitattributes":dr,"readme.md":yr,license:yr,licence:yr},mc={ts:Y,tsx:Y,mts:Y,cts:Y,js:Y,jsx:Y,mjs:Y,cjs:Y,py:Y,rs:Y,go:Y,rb:Y,php:Y,java:Y,kt:Y,c:Y,h:Y,cpp:Y,hpp:Y,cc:Y,html:Y,htm:Y,xml:Y,vue:Y,sql:Y,json:ur,jsonc:ur,yml:dr,yaml:dr,toml:dr,ini:dr,cfg:dr,conf:dr,env:mr,lock:hr,csv:_r,tsv:_r,xlsx:_r,xls:_r,md:yr,mdx:yr,markdown:yr,txt:yr,rtf:yr,log:yr,pdf:yr,css:br,scss:br,sass:br,less:br,sh:vr,bash:vr,zsh:vr,fish:vr,svg:pr,png:pr,jpg:pr,jpeg:pr,gif:pr,webp:pr,bmp:pr,ico:pr,avif:pr,mp4:gr,mov:gr,webm:gr,mkv:gr,avi:gr,mp3:fr,wav:fr,flac:fr,ogg:fr,m4a:fr,zip:lr,tar:lr,gz:lr,tgz:lr,rar:lr,"7z":lr};function hc(e){let t=e.toLowerCase(),n=pc[t];if(n)return{Icon:n,generic:!1};let r=t.lastIndexOf(`.`);if(r>0){let e=mc[t.slice(r+1)];if(e)return{Icon:e,generic:!1}}return{Icon:xr,generic:!0}}function gc({name:e,dimmed:t}){let{Icon:n,generic:r}=hc(e);return(0,X.jsx)(n,{className:a(`size-3.5 shrink-0`,t||r?`text-fg-muted`:`text-fg`)})}function _c({children:e}){return(0,X.jsx)(`span`,{className:`ml-auto pl-6 text-2xs text-fg-muted tabular-nums`,children:e})}function vc({readOnly:e,canPaste:t,onCut:n,onCopy:r,onPaste:i,onCopyPath:a,onCopyRelativePath:o,onReveal:s,onRename:c,onDelete:l,onDownload:u}){return(0,X.jsxs)(X.Fragment,{children:[!e&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{onSelect:n,children:[`Cut `,(0,X.jsx)(_c,{children:`⌘X`})]}),(0,X.jsxs)(U,{onSelect:r,children:[`Copy `,(0,X.jsx)(_c,{children:`⌘C`})]}),(0,X.jsxs)(U,{disabled:!t,onSelect:i,children:[`Paste `,(0,X.jsx)(_c,{children:`⌘V`})]}),(0,X.jsx)(ht,{})]}),(0,X.jsxs)(U,{onSelect:a,children:[`Copy Path `,(0,X.jsx)(_c,{children:`⌥⌘C`})]}),(0,X.jsxs)(U,{onSelect:o,children:[`Copy Relative Path `,(0,X.jsx)(_c,{children:`⌥⇧⌘C`})]}),s&&(0,X.jsx)(U,{onSelect:s,children:`Reveal in Filetree`}),(0,X.jsx)(ht,{}),!e&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{onSelect:c,children:[`Rename… `,(0,X.jsx)(_c,{children:`F2`})]}),(0,X.jsxs)(U,{onSelect:l,children:[`Delete `,(0,X.jsx)(_c,{children:`⌘⌫`})]}),(0,X.jsx)(ht,{})]}),(0,X.jsx)(U,{onSelect:u,children:`Download`})]})}var yc=14,bc=`group-hover/treerow:[transform:translateX(var(--tail))]`;function xc(e,t){let n=document.createElement(`div`);n.textContent=`${t} items`,n.className=`fixed -top-12 left-0 rounded-md bg-elevated px-2 py-1 text-xs text-fg`,document.body.appendChild(n),e.dataTransfer.setDragImage(n,12,12),requestAnimationFrame(()=>n.remove())}function Sc({depth:e,initial:t,icon:n,onCommit:r,onCancel:i}){let a=(0,Z.useRef)(null),o=(0,Z.useRef)(!1);(0,Z.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,X.jsxs)(`div`,{className:`flex h-6 items-center gap-1 pr-2 compact:h-5`,style:{paddingLeft:e*yc+8},children:[(0,X.jsx)(`span`,{className:`size-3.5 shrink-0`}),n,(0,X.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 text-sm text-fg outline-none`})]})}function Cc({path:e,entry:t,depth:n}){let r=ac(),i=t.type===`dir`,o=i&&r.expanded.has(e),s=i&&r.dropTarget===e,c=!i&&e===r.activePath,l=r.selection.has(e),u=r.isCut(e),d={path:e,name:t.name,type:t.type,depth:n,parentDir:Ba(e)},f=r.statusMap.get(e),p=i?bs(r.statusMap,e):null,m=f?_s(f):p?_s(p):null,h=m?m.colourClass:t.name.startsWith(`.`)?`text-fg-muted`:`text-fg`,g=l&&r.selection.size>1?[...r.selection]:[e],_=i?e:Ba(e);return r.editing?.mode===`rename`&&r.editing.path===e?(0,X.jsx)(Sc,{depth:n,initial:t.name,icon:i?(0,X.jsx)(Sr,{className:`size-3.5 shrink-0 text-fg`}):(0,X.jsx)(gc,{name:t.name}),onCommit:r.commitEdit,onCancel:r.cancelEdit}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(wt,{children:[(0,X.jsx)(ut,{asChild:!0,children:(0,X.jsxs)(`div`,{role:`treeitem`,"data-path":e,"aria-expanded":i?o:void 0,"aria-selected":l,tabIndex:-1,draggable:!r.readOnly,onClick:e=>{e.currentTarget.closest(`[data-explorer-root]`)?.focus(),r.onRowClick(d,e)},onDoubleClick:()=>r.onRowDoubleClick(d),onContextMenu:()=>{l||r.selectOnly(e)},onDragStart:t=>{let n=Ga(g);t.dataTransfer.setData(Ka,qa(n)),n.length>1&&xc(t,n.length),!i&&n.length===1&&t.dataTransfer.setData(lc,uc({type:`editor`,tab:r.root===void 0?{kind:`file`,session:r.sid,path:e}:{kind:`external`,session:r.sid,path:e,root:r.root}})),t.dataTransfer.effectAllowed=`copyMove`},onDragOver:t=>{!i||r.readOnly||(t.preventDefault(),t.stopPropagation(),r.setDropTarget(e))},onDragLeave:e=>{i&&e.currentTarget===e.target&&r.setDropTarget(null)},onDrop:t=>{if(!i||r.readOnly)return;t.preventDefault(),t.stopPropagation(),r.setDropTarget(null);let n=Ja(t.dataTransfer.getData(Ka));n.length>0?r.onInternalDrop(e,n):r.onDropUpload(e,t.dataTransfer.items,t.dataTransfer.files)},style:{paddingLeft:n*yc+8},className:a(`group/treerow flex h-6 cursor-pointer items-center gap-1 pr-2 text-sm transition-colors hover:bg-elevated compact:h-5`,l?`bg-selection`:c&&`bg-elevated`,s&&`bg-selection`,u&&`opacity-50`),children:[i?(0,X.jsx)(Ut,{className:a(`size-3.5 shrink-0 text-fg-gold transition-transform duration-150`,o&&`rotate-90`)}):(0,X.jsx)(`span`,{className:`size-3.5 shrink-0`}),t.symlink||t.type===`symlink`?(0,X.jsx)(Er,{className:`size-3.5 shrink-0 text-fg`}):i?o?(0,X.jsx)(nn,{className:a(`size-3.5 shrink-0`,p?m?.colourClass:`text-fg`)}):(0,X.jsx)(Sr,{className:a(`size-3.5 shrink-0`,p?m?.colourClass:`text-fg`)}):(0,X.jsx)(gc,{name:t.name,dimmed:f===`ignored`}),(0,X.jsx)(zo,{text:t.name,className:h,hoverClass:bc}),f&&m&&m.letter&&(0,X.jsx)(`span`,{className:a(`shrink-0 font-mono text-2xs`,m.colourClass),children:m.letter})]})}),(0,X.jsxs)(bt,{onCloseAutoFocus:e=>{r.editing&&e.preventDefault()},children:[i&&!r.readOnly&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{onSelect:()=>r.beginCreate(e,`file`),children:`New File…`}),(0,X.jsx)(U,{onSelect:()=>r.beginCreate(e,`dir`),children:`New Folder…`}),r.onOpenTerminal&&(0,X.jsx)(U,{onSelect:()=>r.onOpenTerminal?.(e),children:`Open Terminal in Directory`}),(0,X.jsx)(ht,{})]}),(0,X.jsx)(vc,{readOnly:r.readOnly,canPaste:r.canPaste,onCut:()=>r.cut(g),onCopy:()=>r.copy(g),onPaste:()=>r.paste(_),onCopyPath:()=>r.copyPathToClipboard(g,!1),onCopyRelativePath:()=>r.copyPathToClipboard(g,!0),onRename:()=>r.beginRename(e),onDelete:()=>r.requestDelete(g),onDownload:()=>r.download(g)})]})]}),i&&o&&(0,X.jsx)(wc,{sid:r.sid,path:e,depth:n+1})]})}function wc({sid:e,path:t,depth:n}){let r=ac(),i=Oe(e,t,r.root),a={paddingLeft:n*yc+8},o=r.editing,s=o?.mode===`create`&&o.parentDir===t?(0,X.jsx)(Tc,{depth:n,kind:o.kind}):null;if(i.isLoading)return(0,X.jsxs)(X.Fragment,{children:[s,(0,X.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Loading…`})]});if(i.isError)return(0,X.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,X.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Empty`}):(0,X.jsxs)(X.Fragment,{children:[s,c.map(e=>(0,X.jsx)(Cc,{path:Ua(t,e.name),entry:e,depth:n},e.name))]})}function Tc({depth:e,kind:t}){let n=ac(),[r,i]=(0,Z.useState)(``);return(0,X.jsx)(Sc,{depth:e,initial:r,icon:t===`dir`?(0,X.jsx)(Sr,{className:`size-3.5 shrink-0 text-fg`}):(0,X.jsx)(gc,{name:r||`file`}),onCommit:e=>{i(e),n.commitEdit(e)},onCancel:n.cancelEdit})}function Ec(){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Dc,{}),(0,X.jsx)(Oc,{})]})}function Dc(){let e=ac(),t=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{!e.focusedPath||!t.current||t.current.querySelector(`[data-path="${CSS.escape(e.focusedPath)}"]`)?.scrollIntoView({block:`nearest`})},[e.focusedPath]),(0,X.jsxs)(wt,{children:[(0,X.jsx)(ut,{asChild:!0,children:(0,X.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=>{e.readOnly||(t.preventDefault(),e.setDropTarget(``))},onDragLeave:t=>{t.currentTarget===t.target&&e.setDropTarget(null)},onDrop:t=>{if(e.readOnly)return;t.preventDefault(),e.setDropTarget(null);let n=Ja(t.dataTransfer.getData(Ka));n.length>0?e.onInternalDrop(``,n):e.onDropUpload(``,t.dataTransfer.items,t.dataTransfer.files)},className:a(`h-full overflow-y-auto py-1 outline-none`,e.dropTarget===``&&`bg-selection`),children:(0,X.jsx)(wc,{sid:e.sid,path:``,depth:0})})}),(0,X.jsxs)(bt,{onCloseAutoFocus:t=>{e.editing&&t.preventDefault()},children:[!e.readOnly&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{onSelect:()=>e.beginCreate(``,`file`),children:`New File…`}),(0,X.jsx)(U,{onSelect:()=>e.beginCreate(``,`dir`),children:`New Folder…`}),e.onOpenTerminal&&(0,X.jsx)(U,{onSelect:()=>e.onOpenTerminal?.(``),children:`Open Terminal in Directory`}),(0,X.jsx)(ht,{}),(0,X.jsx)(U,{disabled:!e.canPaste,onSelect:()=>e.paste(``),children:`Paste`}),(0,X.jsx)(ht,{})]}),(0,X.jsx)(U,{onSelect:()=>e.copyPathToClipboard([``],!1),children:`Copy Path`}),(0,X.jsxs)(U,{onSelect:()=>e.download([``]),children:[`Download `,za(e.rootPath)||`folder`]})]})]})}function Oc(){let e=ac(),t=M().data?.home,n=e.pendingDelete;return(0,X.jsx)(Be,{open:n!==null,onOpenChange:t=>!t&&e.cancelDelete(),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsxs)(Re,{children:[`Delete `,n&&n.length===1?`“${za(n[0])}”`:`${n?.length??0} items`,`?`]}),(0,X.jsxs)(ze,{children:[`This permanently removes `,n&&n.length>1?`them`:`it`,` from`,` `,(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:cc(e.rootPath,t)}),`. There is no undo.`]})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:e.cancelDelete,children:`Cancel`}),(0,X.jsx)(H,{variant:`danger`,onClick:e.confirmDelete,children:`Delete`})]})]})})}function kc({session:e,root:t,readOnly:n,boundHeader:r,onNavigateUp:i,onReset:a,onOpenFile:o,activePath:s}){return(0,X.jsxs)(sc,{session:e,root:t,readOnly:n,onOpenFile:(e,t,n)=>o(t,n),activePath:s,children:[r,(0,X.jsx)(Ac,{root:t,onNavigateUp:i,onReset:a}),(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(Ec,{})})]},t)}function Ac({root:e,onNavigateUp:t,onReset:n}){return(0,X.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center px-2`,children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:t,disabled:e===`/`,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-1 py-1 text-left text-fg-gold transition-colors hover:bg-elevated hover:text-fg disabled:pointer-events-none disabled:opacity-40`,children:[(0,X.jsx)(on,{className:`size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`..`})]})}),(0,X.jsx)(J,{children:e===`/`?e:`Browse the parent directory`})]}),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`ml-1 shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,X.jsx)(Hr,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Back to the worktree`})]})}),(0,X.jsx)(J,{children:`Back to the worktree`})]})]})}var jc=/[.*+?^${}()|[\]\\]/g;function Mc(e){if(e.query.length===0)return null;try{let t=e.regex?e.query:e.query.replace(jc,`\\$&`);return e.wholeWord&&(t=`\\b(?:${t})\\b`),new RegExp(t,e.caseSensitive?`g`:`gi`)}catch{return null}}function Nc(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 Pc=240;function Fc(e){let t=e.replace(/^\s+/,``);return t.length>Pc?`${t.slice(0,Pc)}…`:t}var Ic=250,Lc=`group-hover:[transform:translateX(var(--tail))]`;function Rc({active:e,label:t,onClick:n,children:r}){return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:a(`rounded-sm p-1 transition-colors`,e?`bg-elevated text-accent`:`text-fg-muted hover:bg-elevated hover:text-fg`),children:[r,(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(J,{children:t})]})}function zc({session:e,root:t,onOpen:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=setTimeout(()=>o(r),Ic);return()=>clearTimeout(e)},[r]);let p={query:a,regex:s,caseSensitive:l,wholeWord:d},m=de(e,p,t),h=(0,Z.useMemo)(()=>Mc(p),[a,s,l,d]),g=m.data,_=!!g&&(g.files.length>0||g.content.length>0),v=(e,r,i=!0)=>{n(e,r,i?void 0:{preview:!1}),So({path:e,root:t})};return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 px-2 py-1.5`,children:[(0,X.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Search files and contents`,spellCheck:!1,autoComplete:`off`,className:`rounded-md bg-elevated px-2 py-1 text-xs text-fg outline-none placeholder:text-fg-muted`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(Rc,{active:l,label:`Match case`,onClick:()=>u(e=>!e),children:(0,X.jsx)(Pt,{className:`size-3.5`})}),(0,X.jsx)(Rc,{active:d,label:`Match whole word`,onClick:()=>f(e=>!e),children:(0,X.jsx)(At,{className:`size-3.5`})}),(0,X.jsx)(Rc,{active:s,label:`Use regular expression`,onClick:()=>c(e=>!e),children:(0,X.jsx)(Mt,{className:`size-3.5`})})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:a.length===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Search file names and contents.`}):m.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Searching…`}):m.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:m.error instanceof Error?m.error.message:`Search failed`}):_?(0,X.jsxs)(X.Fragment,{children:[g.files.length>0&&(0,X.jsxs)(`section`,{children:[(0,X.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,X.jsxs)(`button`,{type:`button`,title:e,onClick:()=>v(e),onDoubleClick:()=>v(e,void 0,!1),className:`group flex w-full items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-elevated`,children:[(0,X.jsx)(xr,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e,className:`text-xs text-fg`,hoverClass:Lc})]},e))]}),g.content.length>0&&(0,X.jsxs)(`section`,{children:[(0,X.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,X.jsxs)(`div`,{children:[(0,X.jsx)(`button`,{type:`button`,title:e.path,onClick:()=>v(e.path),onDoubleClick:()=>v(e.path,void 0,!1),className:`group flex w-full px-3 py-1 text-left transition-colors hover:bg-elevated`,children:(0,X.jsx)(zo,{text:e.path,className:`text-2xs text-fg-secondary`,hoverClass:Lc})}),e.matches.map((t,n)=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>v(e.path,t.line),onDoubleClick:()=>v(e.path,t.line,!1),className:`flex w-full items-baseline gap-2 py-0.5 pl-6 pr-3 text-left transition-colors hover:bg-elevated`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-2xs tabular-nums text-fg-muted`,children:t.line}),(0,X.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-secondary`,children:Nc(Fc(t.text),h).map((e,t)=>e.hit?(0,X.jsx)(`span`,{className:`text-accent`,children:e.text},t):(0,X.jsx)(`span`,{children:e.text},t))})]},`${t.line}:${n}`))]},e.path))]}),g.truncated&&(0,X.jsx)(`div`,{className:`px-3 py-2 text-2xs text-fg-muted`,children:`Showing the first results — refine the query for more.`})]}):(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No results.`})})]})}var Bc=new Set([`starting`,`running`,`waiting_input`]),Vc=`group-hover:[transform:translateX(var(--tail))]`;function Hc(e){return e.split(`/`).filter(Boolean).pop()??e}function Uc({children:e,className:t,title:n}){return(0,X.jsx)(`span`,{title:n,className:a(`shrink-0 text-2xs`,t),children:e})}function Wc({label:e,blockReason:t,onClick:n}){return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,disabled:t!==null,onClick:n,className:a(`-my-1 rounded-sm p-1 text-fg-gold transition-colors hover:text-danger`,t===null?`hidden group-hover:inline-flex pointer-coarse:inline-flex`:`hidden`),children:[(0,X.jsx)(Xt,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e})]})}),(0,X.jsx)(J,{children:t?`Can't ${e.toLowerCase()} — ${t}`:e})]})}function Gc({repoId:e,projectId:t,sessions:n}){let r=C(e),i=O(e,t),a=s(e,t),[o,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=i.isPending||a.isPending,f=(0,Z.useMemo)(()=>{let e=new Map;for(let t of n)Bc.has(t.status)&&e.set(t.worktree_path,(e.get(t.worktree_path)??0)+1);return e},[n]),p=(0,Z.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]),m=(0,Z.useMemo)(()=>[...r.data?.orphan_branches??[]].sort((e,t)=>e.name.localeCompare(t.name)),[r.data]);return r.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading worktrees…`}):r.error?(0,X.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,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[p.length===0&&m.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktrees.`}),p.map(([e,t])=>(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`group flex items-center gap-1.5 px-3 pb-0.5 pt-2 text-2xs text-fg-muted`,children:[(0,X.jsx)(Tr,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e,hoverClass:Vc})]}),t.map(e=>{let t=f.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,X.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 pl-6 transition-colors hover:bg-elevated`,children:[(0,X.jsx)(zo,{text:Hc(e.path),title:e.path,className:`text-xs text-fg`,hoverClass:Vc}),e.is_primary&&(0,X.jsx)(Uc,{className:`text-fg-muted`,children:`clone`}),e.dirty&&(0,X.jsx)(Uc,{className:`text-warning`,title:`Modified — uncommitted changes`,children:`M`}),t>0&&(0,X.jsx)(Uc,{className:`text-running`,title:`${t} running session${t>1?`s`:``}`,children:t}),(0,X.jsx)(Wc,{label:`Prune`,blockReason:n,onClick:()=>{u(null),c({kind:`worktree`,path:e.path,branch:e.branch})}})]},e.path)})]},`wt:${e}`)),m.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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`}),m.map(e=>(0,X.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 transition-colors hover:bg-elevated`,children:[(0,X.jsx)(Tr,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e.name,className:`text-xs text-fg`,hoverClass:Vc}),e.local_only&&(0,X.jsx)(Uc,{className:`text-warning`,children:`local only`}),(0,X.jsx)(Wc,{label:`Delete branch`,blockReason:null,onClick:()=>{u(null),c({kind:`branch`,name:e.name,localOnly:e.local_only})}})]},`br:${e.name}`))]}),(0,X.jsx)(Be,{open:o!==null,onOpenChange:e=>{e||c(null)},children:(0,X.jsxs)(Le,{children:[o?.kind===`branch`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Delete branch`}),(0,X.jsxs)(ze,{children:[`Delete branch `,(0,X.jsx)(`span`,{className:`text-fg`,children:o.name}),`? This removes the branch from the repository.`]})]}),o.localOnly&&(0,X.jsxs)(`p`,{className:`text-xs text-warning`,children:[(0,X.jsx)(`span`,{children:o.name}),` has commits on no remote — deleting it discards that work permanently.`]})]}):(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Prune worktree`}),(0,X.jsxs)(ze,{children:[`Remove `,(0,X.jsx)(`span`,{className:`text-fg`,children:o?Hc(o.path):``}),`? The working directory is deleted; the branch`,` `,(0,X.jsx)(`span`,{className:`text-fg`,children:o?.branch??``}),` is kept.`]})]}),l&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:l}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{type:`button`,variant:`ghost`,onClick:()=>c(null),children:`Cancel`}),(0,X.jsx)(H,{type:`button`,variant:`danger`,disabled:d,onClick:()=>{if(!o)return;u(null);let e=e=>u(e.message),t=()=>c(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 Kc=`DropdownMenu`,[qc,Jc]=Me(Kc,[nt]),Yc=nt(),[Xc,Zc]=qc(Kc),Qc=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Yc(t),l=Z.useRef(null),[u,d]=Pe({prop:i,defaultProp:a??!1,onChange:o,caller:Kc});return(0,X.jsx)(Xc,{scope:t,triggerId:Ve(),triggerRef:l,contentId:Ve(),open:u,onOpenChange:d,onOpenToggle:Z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,X.jsx)(Ot,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Qc.displayName=Kc;var $c=`DropdownMenuTrigger`,el=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Zc($c,n),o=Yc(n),s=Ie(t,a.triggerRef);return(0,X.jsx)(Tt,{asChild:!0,...o,children:(0,X.jsx)(je.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:Ae(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Ae(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});el.displayName=$c;var tl=`DropdownMenuPortal`,nl=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Yc(t);return(0,X.jsx)(Et,{...r,...n})};nl.displayName=tl;var rl=`DropdownMenuContent`,il=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Zc(rl,n),a=Yc(n),o=Z.useRef(!1);return(0,X.jsx)(St,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Ae(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Ae(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)`}})});il.displayName=rl;var al=`DropdownMenuGroup`,ol=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(yt,{...i,...r,ref:t})});ol.displayName=al;var sl=`DropdownMenuLabel`,cl=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(st,{...i,...r,ref:t})});cl.displayName=sl;var ll=`DropdownMenuItem`,ul=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(mt,{...i,...r,ref:t})});ul.displayName=ll;var dl=`DropdownMenuCheckboxItem`,fl=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(ft,{...i,...r,ref:t})});fl.displayName=dl;var pl=`DropdownMenuRadioGroup`,ml=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(kt,{...i,...r,ref:t})});ml.displayName=pl;var hl=`DropdownMenuRadioItem`,gl=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(lt,{...i,...r,ref:t})});gl.displayName=hl;var _l=`DropdownMenuItemIndicator`,vl=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(pt,{...i,...r,ref:t})});vl.displayName=_l;var yl=`DropdownMenuSeparator`,bl=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(at,{...i,...r,ref:t})});bl.displayName=yl;var xl=`DropdownMenuArrow`,Sl=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(dt,{...i,...r,ref:t})});Sl.displayName=xl;var Cl=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=Yc(t),[s,c]=Pe({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,X.jsx)(et,{...o,open:s,onOpenChange:c,children:n})},wl=`DropdownMenuSubTrigger`,Tl=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(ot,{...i,...r,ref:t})});Tl.displayName=wl;var El=`DropdownMenuSubContent`,Dl=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yc(n);return(0,X.jsx)(Dt,{...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)`}})});Dl.displayName=El;var Ol=Qc,kl=el,Al=nl,jl=il,Ml=ul,Nl=bl,Pl=Cl,Fl=Tl,Il=Dl,Ll=Ol,Rl=kl,zl=Pl;function Bl({className:e,sideOffset:t=4,...n}){return(0,X.jsx)(Al,{children:(0,X.jsx)(jl,{sideOffset:t,className:a(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...n})})}function Vl({className:e,...t}){return(0,X.jsx)(Ml,{className:a(Ke,Ye,`[&_svg]:size-3.5`,e),...t})}function Hl({className:e,children:t,...n}){return(0,X.jsxs)(Fl,{className:a(Ke,Ye,`data-[state=open]:bg-action data-[state=open]:text-action-ink [&_svg]:size-3.5`,e),...n,children:[t,(0,X.jsx)(Ut,{className:`ml-auto`})]})}function Ul({className:e,...t}){return(0,X.jsx)(Al,{children:(0,X.jsx)(Il,{className:a(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...t})})}function Wl({className:e,...t}){return(0,X.jsx)(Nl,{className:a(`-mx-1 my-1 h-px bg-border`,e),...t})}function Gl({name:e,session:t}){let n=re()??void 0,r=cn().projectBasedLayout,i=x(r?void 0:n),a=t?.kind===`agent`,o=_(a?n:void 0),s=i.data?.find(e=>e.id===t?.project_id)?.name,c=t?.account_id==null?void 0:o.data?.find(e=>e.id===t.account_id)?.label,l=[s,t?.branch].filter(Boolean).join(` · `);return(0,X.jsxs)(`span`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:e}),l!==``&&(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:l}),a&&(0,X.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-2xs text-fg-muted`,children:[(0,X.jsx)(dn,{type:t.agent_type??``,className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:t.agent_type}),c!==void 0&&(0,X.jsxs)(`span`,{children:[` · `,c]})]}),t?.kind===`terminal`&&(0,X.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-2xs text-fg-muted`,children:[(0,X.jsx)(Jt,{className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:`terminal`})]})]})}function Kl({text:e,className:t}){let n=(0,Z.useRef)(null);return(0,Z.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,X.jsx)(`div`,{ref:n,className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`span`,{className:a(`inline-block whitespace-nowrap`,t),children:e})})}function ql({sessions:e,target:t,showFileActions:n=!1,location:r}){let{session:i,pinned:o,pin:s,unpin:c,isProjectDirectory:l}=t,u=Rn(),d=M().data?.home,f=e.filter(e=>e.status!==`archived`),p=r??t.root??i?.worktree_path??null;return(0,X.jsxs)(`div`,{className:`group relative flex h-8 shrink-0 items-center px-2`,children:[(0,X.jsx)(Kl,{text:p?cc(p,d):`No worktree`,className:`text-xs text-fg-secondary`}),(0,X.jsxs)(`div`,{className:a(`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`,o&&`pointer-events-auto opacity-100`),children:[n&&i&&(0,X.jsx)(Yl,{}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":o,disabled:!i||l,title:l?`The project directory is the fallback binding — nothing to pin`:o?`Unpin — follow the active session`:`Pin the sidebar to this worktree`,onClick:()=>o?c():i&&s(i.id),className:a(`shrink-0 rounded-sm p-1 transition-colors disabled:pointer-events-none disabled:opacity-40`,o?`text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,X.jsx)(Ir,{className:a(`size-3.5`,o&&`fill-current`)}),(0,X.jsx)(`span`,{className:`sr-only`,children:o?`Unpin sidebar`:`Pin sidebar`})]}),(0,X.jsxs)(Ll,{children:[(0,X.jsx)(Rl,{asChild:!0,children:(0,X.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,X.jsx)(Ht,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Choose a worktree`})]})}),(0,X.jsx)(Bl,{align:`end`,children:f.length===0?(0,X.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-fg-muted`,children:`No sessions yet`}):f.map(e=>(0,X.jsx)(Vl,{onSelect:()=>s(e.id),className:`min-w-64 items-start`,children:(0,X.jsx)(Gl,{name:u(e),session:e})},e.id))})]})]})]})}var Jl=[{key:`refresh`,label:`Refresh`,icon:Mn},{key:`collapse`,label:`Collapse Folders`,icon:ir}];function Yl(){let e=oc();if(!e)return null;let t=t=>{t===`refresh`?e.refresh():t===`collapse`&&e.collapseAll()};return(0,X.jsx)(`div`,{className:`hidden shrink-0 items-center gap-0.5 group-hover:flex group-focus-within:flex`,children:Jl.map(({key:e,label:n,icon:r})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.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,X.jsx)(r,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,X.jsx)(J,{children:n})]},e))})}var Xl=[{key:`files`,label:`Files`,icon:Cr},{key:`search`,label:`Search`,icon:an},{key:`changes`,label:`Changes`,icon:Tr},{key:`worktrees`,label:`Worktrees`,icon:Ze}];function Zl(e){return e===`diff`||e===`history`||e===`changes`?`changes`:e===`search`?`search`:e===`worktrees`?`worktrees`:`files`}function Ql({mode:e,onExpand:t,onSelect:n}){return(0,X.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center gap-1 bg-surface py-1.5`,children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.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,X.jsx)(Nr,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Show sidebar`})]})}),(0,X.jsx)(J,{side:`right`,children:`Show sidebar`})]}),Xl.map(({key:t,label:r,icon:i})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-current":e===t?`page`:void 0,onClick:()=>n(t),className:a(`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,X.jsx)(i,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,X.jsx)(J,{side:`right`,children:r})]},t))]})}function $l({mode:e,onModeChange:t,onCollapse:n,projectId:r,repoId:i,sessions:o,target:s,browseRequest:c,onOpenFile:l,onOpenExternalFile:u,onOpenTerminalIn:d,activeFilePath:f,activeExternalTab:p,activeDiffPath:m,onOpenDiff:g,onOpenCommitFile:_,onOpenSearchFile:v}){let{session:y}=s,b=s.root,[x,S]=(0,Z.useState)(null),C=h().data?.protocol,w=!C||C.major>10||C.major===10&&C.minor>=2,T=!C||C.major>12||C.major===12&&C.minor>=3,E=w&&x!==null&&x.forSession===y?.id?x.root:null,D=E??b,O=$a(s,E),k=e=>{y&&(s.pinned||s.pin(y.id),S({forSession:y.id,root:e}))};(0,Z.useEffect)(()=>Co(e=>{let t=b??y?.worktree_path,n=e.directory===void 0?e.root===b:e.directory===t;x!==null&&n&&S(null)}),[x,y?.worktree_path,b]);let A=(0,Z.useRef)(0);(0,Z.useEffect)(()=>{!c||!w||A.current!==c.nonce&&(A.current=c.nonce,s.pin(c.session),S({forSession:c.session,root:c.root}))},[c,w,s]);let j=eo(s,()=>S(null)),M=`${y?.worktree_path??``}:${D??``}`;return(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:[Xl.map(({key:n,label:r,icon:i})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-current":e===n?`page`:void 0,onClick:()=>t(n),className:a(`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,X.jsx)(i,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,X.jsx)(J,{side:`bottom`,children:r})]},n)),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.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,X.jsx)(Mr,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Hide sidebar`})]})}),(0,X.jsx)(J,{side:`bottom`,children:`Hide sidebar`})]})]}),e!==`worktrees`&&e!==`files`&&(0,X.jsx)(ql,{sessions:o,target:j,location:O}),e===`worktrees`&&(0,X.jsx)(Gc,{repoId:i,projectId:r,sessions:o}),e===`files`&&(y&&E!==null?(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(kc,{session:y,root:E,readOnly:!T,boundHeader:(0,X.jsx)(ql,{sessions:o,target:j,showFileActions:!0,location:O}),onNavigateUp:()=>k(Ha(E)),onReset:j.unpin,onOpenFile:(e,t)=>u(y.id,e,E,t),activePath:p?.root===E?p.path:null})}):y?(0,X.jsxs)(sc,{session:y,root:b,onOpenFile:b===void 0?l:(e,t,n)=>u(e,t,b,n),onOpenTerminal:b===void 0?e=>d(y.id,e):void 0,activePath:b===void 0?f:p?.root===b?p.path:null,children:[(0,X.jsx)(ql,{sessions:o,target:j,showFileActions:!0,location:O}),w&&b===void 0&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>k(Ha(y.worktree_path)),title:`Browse the parent directory`,className:`flex shrink-0 items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-elevated`,children:[(0,X.jsx)(on,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`..`})]}),(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(Ec,{})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ql,{sessions:o,target:j,location:O}),(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})]})),e===`changes`&&(y?(0,X.jsx)(Ms,{session:y.id,root:D,activeDiffPath:m,onOpenDiff:g,onOpenCommitFile:_},M):(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})),e===`search`&&(y?(0,X.jsx)(zc,{session:y.id,root:D,onOpen:v},M):(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to search.`}))]})}function eu(e){return`${e.agent_type}/${e.label}`}function tu(e){return[...e].sort((e,t)=>eu(e).localeCompare(eu(t),void 0,{numeric:!0,sensitivity:`base`}))}function nu({projectId:e,repoId:t,open:n,kind:r=`agent`,seedAccountId:i,onOpenChange:o,onCreated:s}){let c=r===`terminal`,l=re(),u=_(l??void 0),d=b(l??void 0),p=j(),m=M(),h=f(),[g,v]=(0,Z.useState)(``),[y,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(!0),[k,A]=(0,Z.useState)(!0),[ee,te]=(0,Z.useState)(``),[ne,N]=(0,Z.useState)(``),[P,ie]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(null),L=x(l??void 0),ae=(0,Z.useMemo)(()=>(L.data??[]).filter(e=>!e.archived),[L.data]),oe=g||e,se=ae.find(e=>e.id===oe)?.repo_id??t,R=p.data?.find(e=>e.id===se),ce=S(n?se:void 0),le=C(n?se:void 0),ue=u.data?.find(e=>String(e.id)===y),de=d.data?.allowSkipPermissions===!0,fe=!c&&de&&ue?.skip_permissions_default===!0,z=T.trim()||R?.default_base_branch||``;(0,Z.useEffect)(()=>{n&&v(e)},[n,e]);let pe=(0,Z.useMemo)(()=>(le.data?.worktrees??[]).filter(e=>e.branch===z).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})),[le.data,z]),B=!D&&!k,me=pe.find(e=>e.is_primary)?.path??pe[0]?.path??``,he=ne||me,ge=(0,Z.useMemo)(()=>{let e=d.data?.default_account_id;return u.data?.find(e=>e.id===i)??u.data?.find(t=>typeof e==`number`&&t.id===e)??u.data?.[0]},[u.data,d.data,i]),V=y||(ge?String(ge.id):``),_e=(0,Z.useMemo)(()=>tu(u.data??[]),[u.data]);(0,Z.useEffect)(()=>{n&&i!==void 0&&w(String(i))},[n,i]);let ve=(0,Z.useRef)(d.data);ve.current=d.data,(0,Z.useEffect)(()=>{if(n){let e=Vt(c?`terminal`:`agent`,ve.current);E(e.baseBranch),O(e.separateBranch),A(e.separateWorktree),N(``)}},[n,c,oe]);let ye=R?.default_base_branch;(0,Z.useEffect)(()=>{!n||!ye||E(e=>e===``?ye:e)},[n,oe,ye]);let be=()=>{I(null),h.mutate({project_id:oe,...c?{kind:`terminal`}:{account_id:Number(V)},...T.trim()?{base_branch:T.trim()}:{},separate_branch:D,...D&&ee.trim()?{branch:ee.trim()}:{},...D?{}:{separate_worktree:k},...B&&he?{join_worktree:he}:{},...fe&&P?{skip_permissions:!0}:{}},{onSuccess:e=>{o(!1),te(``),ie(!1),s(e)},onError:e=>I(e.message)})},xe=c?`a shell`:`an agent`,Se=D?`on a new branch off ${z||`…`}, in its own directory`:B?`on ${z||`…`}, sharing an existing directory`:`on ${z||`…`}, in its own directory`;return(0,X.jsx)(Be,{open:n,onOpenChange:o,children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:c?`New terminal`:`New agent`}),(0,X.jsxs)(ze,{children:[c?`Opens`:`Spawns`,` `,xe,` in`,` `,(0,X.jsx)(ru,{projects:ae,value:oe,onChange:v}),` `,Se,`.`]})]}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),(c||V)&&be()},children:[!c&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(Ue,{children:`Account`}),u.data?.length===0?(0,X.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No accounts yet —`,` `,(0,X.jsx)(`button`,{type:`button`,className:`text-accent underline`,onClick:()=>Jn(`accounts`),children:`add one in settings`}),`.`]}):(0,X.jsxs)(Rt,{value:V,onValueChange:w,children:[(0,X.jsx)(It,{children:(0,X.jsx)(zt,{placeholder:`pick an account`})}),(0,X.jsx)(Bt,{children:_e.map(e=>(0,X.jsxs)(Lt,{value:String(e.id),children:[(0,X.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]}),!e.logged_in&&(0,X.jsx)(`span`,{className:`ml-2 text-2xs text-warning`,children:`not logged in`})]},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,X.jsx)(Ue,{htmlFor:`base-branch`,children:`Base branch`}),(0,X.jsx)(Xe,{id:`base-branch`,placeholder:R?.default_base_branch??`main`,value:T,onValueChange:E,hints:(ce.data?.branches??[]).filter(e=>e.name.toLowerCase().includes(T.trim().toLowerCase())).slice(0,20).map(e=>({value:e.name,badge:e.name===R?.default_base_branch?`default`:e.is_session?`session: ${e.session_title??`untitled`}`:void 0})),hintsClassName:`w-max min-w-full max-w-[36rem]`})]}),D&&(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(Ue,{htmlFor:`session-branch`,children:`New branch`}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`optional`})]}),(0,X.jsx)(Ge,{id:`session-branch`,placeholder:`leave blank for auto`,value:ee,onChange:e=>te(e.target.value)})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(fn,{id:`separate-branch`,checked:D,onCheckedChange:e=>{O(e),e&&A(!0)}}),(0,X.jsx)(Ue,{htmlFor:`separate-branch`,children:`Use separate branch`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(fn,{id:`separate-worktree`,checked:D?!0:k,disabled:D,onCheckedChange:A}),(0,X.jsx)(Ue,{htmlFor:`separate-worktree`,className:a(D&&`text-fg-muted`),children:`Use separate directory`})]})]}),B&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(Ue,{htmlFor:`join-dir`,children:`Directory to join`}),pe.length===0?(0,X.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No existing directory on`,` `,(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:z||`…`}),` — a shared one will be created for later sessions to join.`]}):(0,X.jsxs)(Rt,{value:he,onValueChange:N,children:[(0,X.jsx)(It,{id:`join-dir`,children:(0,X.jsx)(zt,{})}),(0,X.jsx)(Bt,{children:pe.map(e=>(0,X.jsx)(Lt,{value:e.path,title:e.path,detail:(0,X.jsx)(`span`,{className:`ml-auto min-w-0 truncate text-2xs text-fg-muted`,children:cc(e.path,m.data?.home)}),children:e.label},e.path))})]})]}),!D&&!c&&(0,X.jsxs)(`p`,{className:`text-xs text-warning`,children:[`The `,c?`shell`:`agent`,` commits straight to`,` `,(0,X.jsx)(`span`,{children:z||`…`}),B?` and shares its working directory with concurrent sessions — they can trample each other’s edits.`:`.`]}),fe&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface px-3 py-2`,children:[(0,X.jsx)(fn,{id:`skip-permissions`,checked:P,onCheckedChange:ie}),(0,X.jsx)(Ue,{htmlFor:`skip-permissions`,className:`text-warning`,children:`Skip permission prompts for this session`})]}),F&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:F}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:`Cancel`}),(0,X.jsx)(H,{type:`submit`,disabled:!c&&!V||h.isPending,children:c?`Open terminal`:`Start agent`})]})]})]})})}function ru({projects:e,value:t,onChange:n}){let r=e.find(e=>e.id===t)?.name??`this project`;return e.length<2?(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:r}):(0,X.jsxs)(Ll,{children:[(0,X.jsx)(Rl,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,title:`Choose the project`,className:`inline-flex items-center gap-0.5 text-fg-secondary transition-colors hover:text-fg`,children:[r,(0,X.jsx)(Ht,{className:`size-3 shrink-0`})]})}),(0,X.jsx)(Bl,{align:`start`,children:e.map(e=>(0,X.jsx)(Vl,{onSelect:()=>n(e.id),className:a(`truncate`,e.id===t&&`text-fg`),children:e.name},e.id))})]})}var iu=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function au(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function ou(e){return`nodeType`in e}function su(e){return e?au(e)?e:ou(e)?e.ownerDocument?.defaultView??window:window:window}function cu(e){let{Document:t}=su(e);return e instanceof t}function lu(e){return!au(e)&&e instanceof su(e).HTMLElement}function uu(e){return e instanceof su(e).SVGElement}function du(e){return e?au(e)?e.document:ou(e)?cu(e)?e:lu(e)||uu(e)?e.ownerDocument:document:document:document}var fu=iu?Z.useLayoutEffect:Z.useEffect;function pu(e){let t=(0,Z.useRef)(e);return fu(()=>{t.current=e}),(0,Z.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function mu(){let e=(0,Z.useRef)(null);return[(0,Z.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,Z.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function hu(e,t){t===void 0&&(t=[e]);let n=(0,Z.useRef)(e);return fu(()=>{n.current!==e&&(n.current=e)},t),n}function gu(e,t){let n=(0,Z.useRef)();return(0,Z.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function _u(e){let t=pu(e),n=(0,Z.useRef)(null);return[n,(0,Z.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function vu(e){let t=(0,Z.useRef)();return(0,Z.useEffect)(()=>{t.current=e},[e]),t.current}var yu={};function bu(e,t){return(0,Z.useMemo)(()=>{if(t)return t;let n=yu[e]==null?0:yu[e]+1;return yu[e]=n,e+`-`+n},[e,t])}function xu(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 Su=xu(1),Cu=xu(-1);function wu(e){return`clientX`in e&&`clientY`in e}function Tu(e){if(!e)return!1;let{KeyboardEvent:t}=su(e.target);return t&&e instanceof t}function Eu(e){if(!e)return!1;let{TouchEvent:t}=su(e.target);return t&&e instanceof t}function Du(e){if(Eu(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 wu(e)?{x:e.clientX,y:e.clientY}:null}var Ou=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[Ou.Translate.toString(e),Ou.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),ku=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Au(e){return e.matches(ku)?e:e.querySelector(ku)}var ju={display:`none`};function Mu(e){let{id:t,value:n}=e;return Z.createElement(`div`,{id:t,style:ju},n)}function Nu(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return Z.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 Pu(){let[e,t]=(0,Z.useState)(``);return{announce:(0,Z.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Fu=(0,Z.createContext)(null);function Iu(e){let t=(0,Z.useContext)(Fu);(0,Z.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Lu(){let[e]=(0,Z.useState)(()=>new Set),t=(0,Z.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,Z.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Ru={draggable:`
4
4
  To pick up a draggable item, press the space bar.
5
5
  While dragging, use the arrow keys to move the item.
6
6
  Press space again to drop the item in its new position, or press escape to cancel.
7
- `},zu={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 Bu(e){let{announcements:t=zu,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Ru}=e,{announce:a,announcement:o}=Pu(),s=bu(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),Iu((0,Z.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=Z.createElement(Z.Fragment,null,Z.createElement(Mu,{id:r,value:i.draggable}),Z.createElement(Nu,{id:s,announcement:o}));return n?(0,go.createPortal)(u,n):u}var Vu;(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`})(Vu||={});function Hu(){}function Uu(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Wu(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Gu=Object.freeze({x:0,y:0});function Ku(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function qu(e,t){let n=Du(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 Ju(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Yu(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Xu(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 Zu(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Qu(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 $u=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=Qu(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Yu)};function ed(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 td=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&&ed(r,a)){let n=Xu(a).reduce((e,t)=>e+Ku(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(Ju)};function nd(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function rd(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Gu}function id(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 ad=id(1);function od(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 sd(e,t,n){let r=od(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 cd={ignoreTransform:!1};function ld(e,t){t===void 0&&(t=cd);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=su(e).getComputedStyle(e);t&&(n=sd(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 ud(e){return ld(e,{ignoreTransform:!0})}function dd(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function fd(e,t){return t===void 0&&(t=su(e).getComputedStyle(e)),t.position===`fixed`}function pd(e,t){t===void 0&&(t=su(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 md(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(cu(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!lu(i)||uu(i)||n.includes(i))return n;let a=su(e).getComputedStyle(i);return i!==e&&pd(i,a)&&n.push(i),fd(i,a)?n:r(i.parentNode)}return e?r(e):n}function hd(e){let[t]=md(e,1);return t??null}function gd(e){return!iu||!e?null:au(e)?e:ou(e)?cu(e)||e===du(e).scrollingElement?window:lu(e)?e:null:null}function _d(e){return au(e)?e.scrollX:e.scrollLeft}function vd(e){return au(e)?e.scrollY:e.scrollTop}function yd(e){return{x:_d(e),y:vd(e)}}var bd;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(bd||={});function xd(e){return!iu||!e?!1:e===document.scrollingElement}function Sd(e){let t={x:0,y:0},n=xd(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 Cd={x:.2,y:.2};function wd(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Cd);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Sd(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=bd.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=bd.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=bd.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=bd.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Td(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 Ed(e){return e.reduce((e,t)=>Su(e,yd(t)),Gu)}function Dd(e){return e.reduce((e,t)=>e+_d(t),0)}function Od(e){return e.reduce((e,t)=>e+vd(t),0)}function kd(e,t){if(t===void 0&&(t=ld),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);hd(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Ad=[[`x`,[`left`,`right`],Dd],[`y`,[`top`,`bottom`],Od]],jd=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=md(t),r=Ed(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Ad)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})}},Md=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 Nd(e){let{EventTarget:t}=su(e);return e instanceof t?e:du(e)}function Pd(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 Fd;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Fd||={});function Id(e){e.preventDefault()}function Ld(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 Rd={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},zd=(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}}},Bd=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 Md(du(t)),this.windowListeners=new Md(su(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Fd.Resize,this.handleCancel),this.windowListeners.add(Fd.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Fd.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&kd(n),t(Gu)}handleKeyDown(e){if(Tu(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Rd,coordinateGetter:a=zd,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}:Gu;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Cu(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}=Sd(n),p=Td(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,Su(Cu(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()}};Bd.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Rd,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 Vd(e){return!!(e&&`distance`in e)}function Hd(e){return!!(e&&`delay`in e)}var Ud=class{constructor(e,t,n){n===void 0&&(n=Nd(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=du(i),this.documentListeners=new Md(this.document),this.listeners=new Md(n),this.windowListeners=new Md(su(i)),this.initialCoordinates=Du(r)??Gu,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(Fd.Resize,this.handleCancel),this.windowListeners.add(Fd.DragStart,Id),this.windowListeners.add(Fd.VisibilityChange,this.handleCancel),this.windowListeners.add(Fd.ContextMenu,Id),this.documentListeners.add(Fd.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Hd(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Vd(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(Fd.Click,Ld,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Fd.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=Du(e)??Gu,s=Cu(n,o);if(!t&&a){if(Vd(a)){if(a.tolerance!=null&&Pd(s,a.tolerance))return this.handleCancel();if(Pd(s,a.distance))return this.handleStart()}if(Hd(a)&&Pd(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()}},Wd={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Gd=class extends Ud{constructor(e){let{event:t}=e,n=du(t.target);super(e,Wd,n)}};Gd.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 Kd={move:{name:`mousemove`},end:{name:`mouseup`}},qd;(function(e){e[e.RightClick=2]=`RightClick`})(qd||={});var Jd=class extends Ud{constructor(e){super(e,Kd,du(e.event.target))}};Jd.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===qd.RightClick?!1:(r?.({event:n}),!0)}}];var Yd={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Xd=class extends Ud{constructor(e){super(e,Yd)}static setup(){return window.addEventListener(Yd.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Yd.move.name,e)};function e(){}}};Xd.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 Zd;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Zd||={});var Qd;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Qd||={});function $d(e){let{acceleration:t,activator:n=Zd.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Qd.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=tf({delta:d,disabled:!a}),[m,h]=mu(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case Zd.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Zd.DraggableRect:return i}},[n,i,c]),y=(0,Z.useRef)(null),b=(0,Z.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,Z.useMemo)(()=>s===Qd.TreeOrder?[...l].reverse():l,[s,l]);(0,Z.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}=wd(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 ef={x:{[bd.Backward]:!1,[bd.Forward]:!1},y:{[bd.Backward]:!1,[bd.Forward]:!1}};function tf(e){let{delta:t,disabled:n}=e,r=vu(t);return gu(e=>{if(n||!r||!e)return ef;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[bd.Backward]:e.x[bd.Backward]||i.x===-1,[bd.Forward]:e.x[bd.Forward]||i.x===1},y:{[bd.Backward]:e.y[bd.Backward]||i.y===-1,[bd.Forward]:e.y[bd.Forward]||i.y===1}}},[n,t,r])}function nf(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return gu(e=>t==null?null:r??e??null,[r,t])}function rf(e,t){return(0,Z.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 af;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(af||={});var of;(function(e){e.Optimized=`optimized`})(of||={});var sf=new Map;function cf(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,Z.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,Z.useRef)(e),d=g(),f=hu(d),p=(0,Z.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,Z.useRef)(null),h=gu(t=>{if(d&&!n)return sf;if(!t||t===sf||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 jd(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,Z.useEffect)(()=>{u.current=e},[e]),(0,Z.useEffect)(()=>{d||p()},[n,d]),(0,Z.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,Z.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 af.Always:return!1;case af.BeforeDragging:return n;default:return!n}}}function lf(e,t){return gu(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function uf(e,t){return lf(e,t)}function df(e){let{callback:t,disabled:n}=e,r=pu(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function ff(e){let{callback:t,disabled:n}=e,r=pu(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function pf(e){return new jd(ld(e),e)}function mf(e,t,n){t===void 0&&(t=pf);let[r,i]=(0,Z.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=df({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=ff({callback:a});return fu(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function hf(e){return rd(e,lf(e))}var gf=[];function _f(e){let t=(0,Z.useRef)(e),n=gu(n=>e?n&&n!==gf&&e&&t.current&&e.parentNode===t.current.parentNode?n:md(e):gf,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function vf(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=gd(e.target);t&&n(e=>e?(e.set(t,yd(t)),new Map(e)):null)},[]);return(0,Z.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=gd(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,yd(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=>{gd(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Su(e,t),Gu):Ed(e):Gu,[e,t])}function yf(e,t){t===void 0&&(t=[]);let n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{n.current=null},t),(0,Z.useEffect)(()=>{let t=e!==Gu;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Cu(e,n.current):Gu}function bf(e){(0,Z.useEffect)(()=>{if(!iu)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 xf(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Sf(e){return(0,Z.useMemo)(()=>e?dd(e):null,[e])}var Cf=[];function wf(e,t){t===void 0&&(t=ld);let[n]=e,r=Sf(n?su(n):null),[i,a]=(0,Z.useState)(Cf);function o(){a(()=>e.length?e.map(e=>xd(e)?r:new jd(t(e),e)):Cf)}let s=ff({callback:o});return fu(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Tf(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return lu(t)?t:e}function Ef(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=ff({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(lu(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=_u((0,Z.useCallback)(e=>{let n=Tf(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,Z.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Df=[{sensor:Gd,options:{}},{sensor:Bd,options:{}}],Of={current:{}},kf={draggable:{measure:ud},droppable:{measure:ud,strategy:af.WhileDragging,frequency:of.Optimized},dragOverlay:{measure:ld}},Af=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}},jf={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Af,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Hu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:kf,measureDroppableContainers:Hu,windowRect:null,measuringScheduled:!1},Mf={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Hu,draggableNodes:new Map,over:null,measureDroppableContainers:Hu},Nf=(0,Z.createContext)(Mf),Pf=(0,Z.createContext)(jf);function Ff(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Af}}}function If(e,t){switch(t.type){case Vu.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Vu.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 Vu.DragEnd:case Vu.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Vu.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Af(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Vu.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 Af(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Vu.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Af(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Lf(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(Nf),a=vu(r),o=vu(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Tu(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=Au(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Rf(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function zf(e){return(0,Z.useMemo)(()=>({draggable:{...kf.draggable,...e?.draggable},droppable:{...kf.droppable,...e?.droppable},dragOverlay:{...kf.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Bf(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,Z.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;fu(()=>{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=rd(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=hd(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Vf=(0,Z.createContext)({...Gu,scaleX:1,scaleY:1}),Hf;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Hf||={});var Uf=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Df,collisionDetection:o=$u,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(If,void 0,Ff),[f,p]=Lu(),[m,h]=(0,Z.useState)(Hf.Uninitialized),g=m===Hf.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,Z.useRef)({initial:null,translated:null}),C=(0,Z.useMemo)(()=>_==null?null:{id:_,data:x?.data??Of,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=hu(l,Object.values(l)),A=bu(`DndDescribedBy`,t),j=(0,Z.useMemo)(()=>b.getEnabled(),[b]),M=zf(s),{droppableRects:ee,measureDroppableContainers:te,measuringScheduled:ne}=cf(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),N=nf(v,_),P=(0,Z.useMemo)(()=>D?Du(D):null,[D]),re=De(),ie=uf(N,M.draggable.measure);Bf({activeNode:_==null?null:v.get(_),config:re.layoutShiftCompensation,initialRect:ie,measure:M.draggable.measure});let F=mf(N,M.draggable.measure,ie),I=mf(N?N.parentElement:null),L=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:N,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ae=b.getNodeFor(L.current.over?.id),oe=Ef({measure:M.dragOverlay.measure}),se=oe.nodeRef.current??N,R=g?oe.rect??F:null,ce=!!(oe.nodeRef.current&&oe.rect),le=hf(ce?null:F),ue=Sf(se?su(se):null),de=_f(g?ae??N:null),fe=wf(de),z=Rf(c,{transform:{x:y.x-le.x,y:y.y-le.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:F,containerNodeRect:I,draggingNodeRect:R,over:L.current.over,overlayNodeRect:oe.rect,scrollableAncestors:de,scrollableAncestorRects:fe,windowRect:ue}),pe=P?Su(P,y):null,B=vf(de),me=yf(B),he=yf(B,[F]),ge=Su(z,me),V=R?ad(R,z):null,_e=C&&V?o({active:C,collisionRect:V,droppableRects:ee,droppableContainers:j,pointerCoordinates:pe}):null,ve=Zu(_e,`id`),[ye,be]=(0,Z.useState)(null),xe=nd(ce?z:Su(z,he),ye?.rect??null,F),Se=(0,Z.useRef)(null),Ce=(0,Z.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:L,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.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}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,go.unstable_batchedUpdates)(()=>{r?.(i),h(Hf.Initializing),d({type:Vu.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Se.current),O(a)})},onMove(e){d({type:Vu.DragMove,coordinates:e})},onEnd:s(Vu.DragEnd),onCancel:s(Vu.DragCancel)});Se.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=L.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Vu.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Vu.DragCancel)}w.current=null,(0,go.unstable_batchedUpdates)(()=>{d({type:e}),h(Hf.Uninitialized),be(null),E(null),O(null),Se.current=null;let t=e===Vu.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),we=rf(a,(0,Z.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,Ce(n,t))},[v,Ce]));bf(a),fu(()=>{F&&m===Hf.Initializing&&h(Hf.Initialized)},[F,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=L.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,go.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=L.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ve),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,go.unstable_batchedUpdates)(()=>{be(s),a?.(c),f({type:`onDragOver`,event:c})})},[ve]),fu(()=>{L.current={activatorEvent:D,active:C,activeNode:N,collisionRect:V,collisions:_e,droppableRects:ee,draggableNodes:v,draggingNode:se,draggingNodeRect:R,droppableContainers:b,over:ye,scrollableAncestors:de,scrollAdjustedTranslate:ge},S.current={initial:R,translated:V}},[C,N,_e,V,v,se,R,ee,b,ye,de,ge]),$d({...re,delta:y,draggingRect:V,pointerCoordinates:pe,scrollableAncestors:de,scrollableAncestorRects:fe});let Te=(0,Z.useMemo)(()=>({active:C,activeNode:N,activeNodeRect:F,activatorEvent:D,collisions:_e,containerNodeRect:I,dragOverlay:oe,draggableNodes:v,droppableContainers:b,droppableRects:ee,over:ye,measureDroppableContainers:te,scrollableAncestors:de,scrollableAncestorRects:fe,measuringConfiguration:M,measuringScheduled:ne,windowRect:ue}),[C,N,F,D,_e,I,oe,v,b,ee,ye,te,de,fe,M,ne,ue]),Ee=(0,Z.useMemo)(()=>({activatorEvent:D,activators:we,active:C,activeNodeRect:F,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:ye,measureDroppableContainers:te}),[D,we,C,F,d,A,v,ye,te]);return Z.createElement(Fu.Provider,{value:p},Z.createElement(Nf.Provider,{value:Ee},Z.createElement(Pf.Provider,{value:Te},Z.createElement(Vf.Provider,{value:xe},i)),Z.createElement(Lf,{disabled:n?.restoreFocus===!1})),Z.createElement(Bu,{...n,hiddenTextDescribedById:A}));function De(){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}}}),Wf=(0,Z.createContext)(null),Gf=`button`,Kf=`Draggable`;function qf(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=bu(Kf),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(Nf),{role:p=Gf,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?Vf:Wf),[v,y]=_u(),[b,x]=_u(),S=xf(o,t),C=hu(n);return fu(()=>(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,Z.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Gf?!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 Jf(){return(0,Z.useContext)(Pf)}var Yf=`Droppable`,Xf={timeout:25};function Zf(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=bu(Yf),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(Nf),u=(0,Z.useRef)({disabled:n}),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Xf,...i},_=hu(h??r),v=ff({callback:(0,Z.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]=_u((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=hu(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:Vu.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Vu.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:Vu.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 Qf(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=vu(n);return!n&&!r&&s&&i(s),fu(()=>{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]),Z.createElement(Z.Fragment,null,n,r?(0,Z.cloneElement)(r,{ref:o}):null)}var $f={x:0,y:0,scaleX:1,scaleY:1};function ep(e){let{children:t}=e;return Z.createElement(Nf.Provider,{value:Mf},Z.createElement(Vf.Provider,{value:$f},t))}var tp={position:`fixed`,touchAction:`none`},np=e=>Tu(e)?`transform 250ms ease`:void 0,rp=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=np}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...tp,width:s.width,height:s.height,top:s.top,left:s.left,transform:Ou.Transform.toString(d),transformOrigin:i&&r?qu(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),ip={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Ou.Transform.toString(t)},{transform:Ou.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 ap(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return pu((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Tf(a);if(!c)return;let{transform:l}=su(a).getComputedStyle(a),u=od(l);if(!u)return;let d=typeof t==`function`?t:op(t);return kd(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 op(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...ip,...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 sp=0;function cp(e){return(0,Z.useMemo)(()=>{if(e!=null)return sp++,sp},[e])}var lp=Z.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}=Jf(),S=(0,Z.useContext)(Vf),C=cp(d?.id),w=Rf(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=lf(f),E=ap({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(ep,null,Z.createElement(Qf,{animation:E},d&&C?Z.createElement(rp,{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 up({status:e,kind:t=`agent`,agentType:n,stale:r=!1,className:i,iconClassName:o=`size-3`,iconStrokeScale:s=1}){let c=`${t===`terminal`?`terminal`:n??`agent`} — status: ${e.replace(`_`,` `)}${r?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,X.jsx)(`span`,{className:a(`status-glyph`,i),"data-status":e,"data-kind":t,"data-stale":r||void 0,role:`img`,title:r?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":c,children:t===`terminal`?(0,X.jsx)(Jt,{className:o,strokeWidth:2*s}):(0,X.jsx)(dn,{type:n??``,className:o,strokeScale:s})})}var dp=[`starting`,`running`,`waiting_input`],fp=[`exited`,`interrupted`],pp={Item:Vl,Separator:Wl,Sub:zl,SubTrigger:Hl,SubContent:Ul},mp={Item:U,Separator:ht,Sub:ct,SubTrigger:Ct,SubContent:xt};function hp(e,t){let n=T(`resume`),r=T(`kill`),i=p(),a=I(),o=P(),s=v(),c=d(),l=E(),m=f(),h=hn(),g=re(),y=_(g??void 0),x=b(g??void 0),[S,C]=(0,Z.useState)(null),[w,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(e.title??``),[A,j]=(0,Z.useState)(null),[M,ee]=(0,Z.useState)(null),te=(y.data??[]).filter(t=>t.agent_type===e.agent_type),ne=!e.worktree_missing&&e.status!==`archived`&&te.some(t=>t.id!==e.account_id),N=(y.data??[]).filter(t=>t.agent_type!==e.agent_type&&t.logged_in),ie=x.data?.default_account_id,F=typeof ie==`number`?ie:null,L=(y.data??[]).filter(e=>e.logged_in),ae=F===null?L:[...L.filter(e=>e.id===F),...L.filter(e=>e.id!==F)];return{menu:{session:e,resumable:fp.includes(e.status)&&!e.conversation_missing,live:dp.includes(e.status),archived:e.status===`archived`,canMigrate:ne,sameAgent:te,handoffTargets:!e.worktree_missing&&e.status!==`archived`?N:[],setHandoffTo:ee,resume:()=>n.mutate(e.id,{onError:e=>{let t=We(e);t?h(`/project/${t.projectId}/session/${t.sessionId}`):He(e)}}),kill:()=>r.mutate(e.id,{onError:e=>He(e)}),openClearEnv:()=>C(`clear-env`),openTerminal:()=>m.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void h(`/project/${e.project_id}/session/${e.id}`),onError:e=>He(e)}),spawnAccounts:ae,defaultAccountId:F,spawnAgent:t=>m.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void h(`/project/${e.project_id}/session/${e.id}`),onError:e=>He(e)}),openRename:()=>{k(e.title??``),D(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>He(e)}),unarchive:()=>a.mutate(e.id,{onError:e=>He(e)}),setMigrateTo:j},dialogs:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Be,{open:S===`clear-env`,onOpenChange:e=>{e||C(null)},children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Clear captured environment?`}),(0,X.jsx)(ze,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>C(null),children:`Cancel`}),(0,X.jsx)(H,{variant:`danger`,disabled:l.isPending,onClick:()=>l.mutate(e.id,{onSuccess:e=>{C(null),u.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{C(null),He(e)}}),children:`Clear captured env`})]})]})}),(0,X.jsx)(Be,{open:w,onOpenChange:D,children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Rename session`}),(0,X.jsx)(ze,{children:`Leave it empty to use the agent’s own session name.`})]}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:t=>{t.preventDefault(),o.mutate({sessionId:e.id,title:O.trim()},{onSuccess:()=>D(!1),onError:e=>He(e)})},children:[(0,X.jsx)(Ge,{value:O,onChange:e=>k(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{type:`button`,variant:`ghost`,onClick:()=>D(!1),children:`Cancel`}),(0,X.jsx)(H,{type:`submit`,disabled:o.isPending,children:`Rename`})]})]})]})}),(0,X.jsx)(Be,{open:A!==null,onOpenChange:e=>!e&&j(null),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsxs)(Re,{children:[`Move this session to `,A?.label,`?`]}),(0,X.jsx)(ze,{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,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>j(null),children:`Cancel`}),(0,X.jsx)(H,{disabled:s.isPending,onClick:()=>{A&&s.mutate({sessionId:e.id,accountId:A.id},{onSuccess:()=>{j(null),u.success(`Moved to ${A.label}`)},onError:e=>{j(null),He(e)}})},children:`Move session`})]})]})}),(0,X.jsx)(Be,{open:M!==null,onOpenChange:e=>!e&&ee(null),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsxs)(Re,{children:[`Hand off to `,M?.agent_type,`?`]}),(0,X.jsxs)(ze,{children:[`A new session starts in this worktree and branch on`,` `,(0,X.jsx)(`span`,{className:`text-fg`,children:M?.label}),`, opening with a summary of the conversation so far plus the branch’s commits and status. The conversation itself is summarised, not moved — the new agent will not have the old one’s reasoning. This session is left as it is.`]})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>ee(null),children:`Cancel`}),(0,X.jsx)(H,{disabled:c.isPending,onClick:()=>{M&&c.mutate({sessionId:e.id,accountId:M.id},{onSuccess:e=>{ee(null),u.success(`Handed off to ${M.agent_type}`),h(`/session/${e.id}`)},onError:e=>{ee(null),He(e)}})},children:`Hand off`})]})]})})]})}}function gp({kit:e,menu:t}){let{Item:n,Separator:r,Sub:i,SubTrigger:a,SubContent:o}=e,{session:s}=t;return(0,X.jsxs)(X.Fragment,{children:[t.resumable&&!s.worktree_missing&&(0,X.jsxs)(n,{onSelect:t.resume,children:[(0,X.jsx)(Lr,{}),` Resume`]}),t.live&&(0,X.jsxs)(n,{onSelect:t.kill,children:[(0,X.jsx)(Br,{}),` Kill`]}),(0,X.jsxs)(n,{onSelect:t.openRename,children:[(0,X.jsx)(Je,{}),` Rename`]}),!t.archived&&(0,X.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,X.jsx)(or,{}),` Clear captured env`]}),t.canMigrate&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Wr,{}),` Move to account…`]}),(0,X.jsx)(o,{children:t.sameAgent.map(e=>{let r=e.id===s.account_id;return(0,X.jsxs)(n,{disabled:r,onSelect:()=>t.setMigrateTo(e),children:[e.label,r&&(0,X.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:`current`})]},e.id)})})]}),t.handoffTargets.length>0&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(rr,{}),` Hand off to agent…`]}),(0,X.jsx)(o,{children:t.handoffTargets.map(e=>(0,X.jsxs)(n,{onSelect:()=>t.setHandoffTo(e),children:[(0,X.jsx)(dn,{type:e.agent_type,className:`size-4`}),e.agent_type,(0,X.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:e.label})]},e.id))})]}),!s.worktree_missing&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.openTerminal,children:[(0,X.jsx)(Jt,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Qt,{}),` Spawn agent in worktree`]}),(0,X.jsx)(o,{children:t.spawnAccounts.map(e=>(0,X.jsxs)(n,{onSelect:()=>t.spawnAgent(e.id),children:[(0,X.jsx)(dn,{type:e.agent_type,className:`size-4 shrink-0`}),e.agent_type,`/`,e.label,e.id===t.defaultAccountId&&(0,X.jsx)(`span`,{className:`ml-auto pl-3 text-fg-muted`,children:`default`})]},e.id))})]}),(0,X.jsxs)(n,{onSelect:()=>{window.location.href=Wn(`vscode`,s.worktree_path,Ln())},children:[(0,X.jsx)(sr,{}),` Open in VS Code`]}),(0,X.jsxs)(n,{onSelect:()=>{window.location.href=Wn(`cursor`,s.worktree_path,Ln())},children:[(0,X.jsx)(sr,{}),` Open in Cursor`]})]}),!t.archived&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.archive,children:[(0,X.jsx)(gt,{}),` Archive`]})]}),t.archived&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.unarchive,children:[(0,X.jsx)(rt,{}),` Unarchive`]})]})]})}function _p({menu:e}){return(0,X.jsxs)(Ll,{children:[(0,X.jsx)(Rl,{asChild:!0,children:(0,X.jsxs)(H,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:e=>e.preventDefault(),children:[(0,X.jsx)(ar,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,X.jsx)(Bl,{align:`end`,children:(0,X.jsx)(gp,{kit:pp,menu:e})})]})}function vp({session:e,onArchived:t,children:n}){let{menu:r,dialogs:i}=hp(e,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(wt,{children:[(0,X.jsx)(ut,{asChild:!0,children:typeof n==`function`?n(r):n}),(0,X.jsx)(bt,{children:(0,X.jsx)(gp,{kit:mp,menu:r})})]}),i]})}function yp({menu:e}){return(0,X.jsx)(bt,{children:(0,X.jsx)(gp,{kit:mp,menu:e})})}function bp(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=xp(t.x/e.width),i=xp(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 xp(e){return e<0?0:e>1?1:e}var Sp=(0,Z.createContext)(null);function Cp(){return(0,Z.useContext)(Sp)}var wp=(0,Z.createContext)(null);function Tp(){return(0,Z.useContext)(wp)}var Ep=`leaf:`,Dp=`tabdrop:`,Op=`strip:`,kp=`archive:`,Ap=e=>{let t=td(e);for(let e of[Dp,Op]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:$u(e)};function jp({onDrop:e,onArchive:t,renderOverlay:n,children:r}){let i=Wu(Uu(Gd,{activationConstraint:{distance:4}})),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(null),u=()=>{o(null),c(null),l.current=null};return(0,X.jsxs)(Uf,{sensors:i,collisionDetection:Ap,onDragStart:e=>c(e.active.data.current?.ref??null),onDragMove:e=>{let t=e.over,n=Mp(e),r=t&&n?Pp(String(t.id),t.rect,t.data.current,n):null;Np(l.current,r)||(l.current=r,o(r))},onDragEnd:n=>{let r=l.current,i=n.active.data.current?.ref,a=n.active.data.current?.fromLeafId,o=n.over===null?null:String(n.over.id);if(u(),o!==null&&o.startsWith(`archive:`)){i?.type===`terminal`&&t?.(i.session);return}r&&i&&a&&e({ref:i,fromLeafId:a,toLeafId:r.leafId,edge:r.zone,index:r.index})},onDragCancel:u,children:[(0,X.jsx)(Sp.Provider,{value:a,children:(0,X.jsx)(wp.Provider,{value:s,children:r})}),(0,X.jsx)(lp,{dropAnimation:null,children:s?n(s):null})]})}function Mp(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 Np(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function Pp(e,t,n,r){if(e.startsWith(Dp)){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(Op)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(Ep)){let n=bp({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 Fp=`application/x-puddle-project`,Ip=`group-hover:[transform:translateX(var(--tail))]`;function Lp({projectId:e,actions:t,editLabel:n}){return(0,X.jsxs)(bt,{children:[(0,X.jsxs)(U,{onSelect:()=>t.onNewSessionIn(e),children:[(0,X.jsx)(Qt,{}),`New agent`]}),(0,X.jsxs)(U,{onSelect:()=>t.onNewTerminalIn(e),children:[(0,X.jsx)(Jt,{}),`New terminal`]}),(0,X.jsx)(ht,{}),(0,X.jsxs)(U,{onSelect:n.onSelect,children:[(0,X.jsx)(Je,{}),n.label]})]})}function Rp(e,t){let{isOver:n,setNodeRef:r}=Zf({id:`${kp}${e}`}),i=Tp(),[a,o]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let e=()=>o(!1);return window.addEventListener(`dragend`,e),()=>window.removeEventListener(`dragend`,e)},[]),{setNodeRef:r,armed:a||n&&i?.type===`terminal`,props:{onDragOver:e=>{fc(e.dataTransfer.types)&&(e.preventDefault(),o(!0))},onDragLeave:()=>o(!1),onDrop:e=>{o(!1);let n=dc(e.dataTransfer.getData(lc));n?.type===`terminal`&&(e.preventDefault(),t(n.session))}}}}function zp({onArchiveDrop:e,onExpand:t}){let n=Rp(`rail`,e);return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{ref:n.setNodeRef,type:`button`,onClick:t,...n.props,className:a(`mt-1 flex shrink-0 items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg compact:p-1`,n.armed&&`bg-selection text-fg`),children:[(0,X.jsx)(gt,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Archived sessions`})]})}),(0,X.jsx)(J,{side:`left`,children:`Drop a session here to archive it`})]})}function Bp({collapsed:e,children:t}){return(0,X.jsx)(`div`,{className:a(`grid transition-[grid-template-rows] duration-200`,e?`grid-rows-[0fr]`:`grid-rows-[1fr]`),children:t})}function Vp({icon:e,label:t,onClick:n,active:r=!1,tooltipSide:i=`bottom`}){return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:a(`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,X.jsx)(e,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(J,{side:i,children:t})]})}function Hp({session:e,accountLabel:t}){return(0,X.jsxs)(`span`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:Rn()(e)}),(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.branch}),(0,X.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 text-2xs text-fg-muted`,children:e.kind===`terminal`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Jt,{className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:`terminal`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(dn,{type:e.agent_type??``,className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:e.agent_type}),t&&(0,X.jsxs)(`span`,{children:[` · `,t]})]})})]})}function Up({session:e,accountLabel:t,activeSessionId:n,onPromote:r,onArchived:i}){let{menu:o,dialogs:s}=hp(e,i),c=Rn();return(0,X.jsxs)(wt,{children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(ut,{asChild:!0,children:(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(pn,{draggable:!1,"aria-current":e.id===n?`true`:void 0,onDoubleClick:()=>r(e.id),to:`/project/${e.project_id}/session/${e.id}`,className:a(`flex items-center rounded-md p-1 transition-colors hover:bg-elevated`,e.id===n&&`bg-elevated`),children:[(0,X.jsx)(up,{status:e.status,kind:e.kind,agentType:e.agent_type,stale:e.stale_running,className:`size-4 compact:size-3`,iconClassName:`size-full`,iconStrokeScale:.75}),(0,X.jsx)(`span`,{className:`sr-only`,children:c(e)})]})})}),(0,X.jsx)(J,{side:`left`,children:(0,X.jsx)(Hp,{session:e,accountLabel:t})})]}),(0,X.jsx)(yp,{menu:o}),s]})}function Wp({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,onExpand:o,onNewTerminal:s,onNewSession:c,onArchived:l,onArchiveDrop:u,projectActions:d}){let[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),v=k(),y=new Map(t.map(e=>[e.id,e.label])),b=(t,n)=>{let i=it(e,t,n);i&&r(i)},x=(e,t)=>{_(null);let n=Un(t);!n||n===e.abbrev||v.mutate({id:e.projectId,abbrev:n},{onError:e=>He(e)})};return(0,X.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center bg-surface py-1.5 compact:py-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1 compact:gap-0.5`,children:[(0,X.jsx)(Vp,{icon:Fr,label:`Show sessions`,onClick:o,tooltipSide:`left`}),(0,X.jsx)(Vp,{icon:Qt,label:`New agent`,onClick:c,tooltipSide:`left`}),(0,X.jsx)(Vp,{icon:Jt,label:`New terminal`,onClick:s,tooltipSide:`left`})]}),(0,X.jsx)(`div`,{className:`no-scrollbar flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto compact:gap-0.5`,children:e.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1 compact:gap-0.5`,onDragOver:t=>{m&&(t.preventDefault(),m!==e.projectId&&d.onMoveProject(m,e.projectId))},children:[(0,X.jsx)(`div`,{className:`my-0.5 h-px w-7 shrink-0 bg-border`}),g===e.projectId?(0,X.jsx)(Zn,{initial:e.abbrev,maxLength:5,className:`w-7 text-center text-[8px] uppercase leading-3 text-fg`,onCommit:t=>x(e,t),onCancel:()=>_(null)}):(0,X.jsxs)(wt,{children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(ut,{asChild:!0,children:(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(pn,{to:`/project/${e.projectId}`,...vt(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Fp,e.projectId),h(e.projectId)},onDragEnd:()=>h(null),className:a(`w-7 truncate text-center text-[8px] uppercase leading-3 text-fg-muted transition-colors hover:text-fg`,m===e.projectId&&`opacity-50`),children:e.abbrev})})}),(0,X.jsx)(J,{side:`left`,children:e.name})]}),(0,X.jsx)(Lp,{projectId:e.projectId,actions:d,editLabel:{label:`Change project abbreviation`,onSelect:()=>_(e.projectId)}})]}),(0,X.jsx)(Bp,{collapsed:m!==null,children:(0,X.jsx)(`div`,{className:`flex flex-col items-center gap-1 overflow-hidden compact:gap-0.5`,children:e.sessions.map(e=>(0,X.jsx)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(lc,uc({type:`terminal`,session:e.id})),p(e.id)},onDragEnd:()=>p(null),onDragOver:t=>{t.preventDefault(),f&&f!==e.id&&b(f,e.id)},className:a(`transition-opacity`,f===e.id&&`opacity-50`),children:(0,X.jsx)(Up,{session:e,accountLabel:e.account_id===null?void 0:y.get(e.account_id),activeSessionId:n,onPromote:i,onArchived:l})},e.id))})})]},e.projectId))}),(0,X.jsx)(zp,{onArchiveDrop:u,onExpand:o})]})}function Gp({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,ellipsis:o,lastActive:s=!1}){let c=Rn(),l=e.kind===`terminal`?`terminal`:e.agent_type??`agent`,u=s?e.last_activity_at===null?``:` · ${he(e.last_activity_at)}`:e.account_id!==null&&n.has(e.account_id)?` · ${n.get(e.account_id)}`:``;return(0,X.jsx)(vp,{session:e,onArchived:i,children:n=>(0,X.jsxs)(pn,{draggable:!1,onDoubleClick:r&&(()=>r(e.id)),to:`/project/${e.project_id}/session/${e.id}`,className:a(`group flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-elevated compact:gap-1.5 compact:py-1`,e.id===t&&`bg-elevated`),children:[(0,X.jsx)(up,{status:e.status,kind:e.kind,agentType:e.agent_type,stale:e.stale_running}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(zo,{text:c(e),className:`font-sans text-xs text-fg`,hoverClass:Ip}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:[(0,X.jsx)(Tr,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e.branch,hoverClass:Ip})]}),(0,X.jsx)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:(0,X.jsx)(zo,{text:`${l}${u}`,hoverClass:Ip})})]}),e.skip_permissions&&(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(zr,{className:`size-3.5 shrink-0 text-warning`})}),(0,X.jsx)(J,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(wr,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(J,{children:`Worktree directory is gone — archive only`})]}),e.conversation_missing&&(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(Ar,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(J,{children:`Native conversation is missing — resume unavailable`})]}),e.native_sync===`fallback`&&e.status!==`archived`&&(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(Vr,{className:`size-3.5 shrink-0 text-fg-muted`})}),(0,X.jsx)(J,{children:`In-agent conversation switches are not synchronised`})]}),o&&(0,X.jsx)(`span`,{className:`hidden group-hover:inline-flex has-[[data-state=open]]:inline-flex pointer-coarse:inline-flex`,children:(0,X.jsx)(_p,{menu:n})})]})})}function Kp({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onNewSession:o,onNewTerminal:s,onCollapse:c,onArchived:l,onArchiveDrop:u,projectActions:d}){return(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 py-1.5`,children:[(0,X.jsx)(Vp,{icon:Pr,label:`Hide sessions`,onClick:c}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(Vp,{icon:Qt,label:`New agent`,onClick:o}),(0,X.jsx)(Vp,{icon:Jt,label:`New terminal`,onClick:s})]})]}),(0,X.jsx)(qp,{groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:l,onArchiveDrop:u,projectActions:d})]})}function qp({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:o,onArchived:s,onArchiveDrop:c,projectActions:l}){let[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),v=Rp(`list`,c),y=Tp(),b=u!==null||y?.type===`terminal`,x=k(),S=A(`palette.toggle`),C=new Map(t.map(e=>[e.id,e.label])),w=e.reduce((e,t)=>e+t.sessions.length,0),{height:T,handle:E}=Po(`sessions-archived`,200,{sized:`below`,min:96}),D=(0,Z.useMemo)(()=>{let t=new Set,n=e.map(e=>{let n=o.filter(t=>t.project_id===e.projectId);for(let e of n)t.add(e.id);return{...e,sessions:n}}),r=o.filter(e=>!t.has(e.id));return[...n.filter(e=>e.sessions.length>0),...r.length>0?[{projectId:``,name:``,abbrev:``,repoId:-1,sessions:r}]:[]]},[e,o]),O=(t,n)=>{let i=it(e,t,n);i&&r(i)},j=(e,t)=>{h(null);let n=t.trim();!n||n===e.name||x.mutate({id:e.projectId,name:n},{onError:e=>He(e)})};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto py-1.5`,children:[w===0&&o.length===0&&(0,X.jsxs)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`No sessions yet — press `,S,` to start one.`]}),e.map(e=>(0,X.jsxs)(`div`,{onDragOver:t=>{f&&(t.preventDefault(),f!==e.projectId&&l.onMoveProject(f,e.projectId))},children:[m===e.projectId?(0,X.jsx)(Zn,{initial:e.name,maxLength:100,className:`block w-full px-3 pb-1 pt-2 text-2xs font-medium tracking-wide text-fg`,onCommit:t=>j(e,t),onCancel:()=>h(null)}):(0,X.jsxs)(wt,{children:[(0,X.jsx)(ut,{asChild:!0,children:(0,X.jsx)(pn,{to:`/project/${e.projectId}`,...vt(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Fp,e.projectId),p(e.projectId)},onDragEnd:()=>p(null),className:a(`block truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold transition-colors hover:text-fg compact:pb-0.5 compact:pt-1.5`,f===e.projectId&&`opacity-50`),children:e.name})}),(0,X.jsx)(Lp,{projectId:e.projectId,actions:l,editLabel:{label:`Change project name`,onSelect:()=>h(e.projectId)}})]}),(0,X.jsx)(Bp,{collapsed:f!==null,children:(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 overflow-hidden compact:gap-0`,children:e.sessions.map(e=>(0,X.jsx)(`li`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(lc,uc({type:`terminal`,session:e.id})),d(e.id)},onDragEnd:()=>d(null),onDragOver:t=>{t.preventDefault(),u&&u!==e.id&&O(u,e.id)},className:a(`transition-opacity`,u===e.id&&`opacity-50`),children:(0,X.jsx)(Gp,{session:e,activeSessionId:n,accountLabel:C,onPromote:i,onArchived:s,ellipsis:!0})},e.id))})})]},e.projectId))]}),(o.length>0||b)&&(0,X.jsxs)(X.Fragment,{children:[g&&(0,X.jsx)(Fo,{handle:E,label:`Resize the archived sessions`}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col pb-1.5`,style:g?{height:T,maxHeight:`70%`}:void 0,children:[(0,X.jsxs)(`button`,{ref:v.setNodeRef,type:`button`,onClick:()=>_(e=>!e),...v.props,className:a(`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`,v.armed&&`bg-selection text-fg`),children:[(0,X.jsx)(Ut,{className:a(`size-3 transition-transform`,g&&`rotate-90`)}),(0,X.jsx)(gt,{className:`size-3`}),(0,X.jsx)(`span`,{children:`Archived`}),(0,X.jsx)(`span`,{className:`ml-auto tabular-nums`,children:o.length})]}),g&&(0,X.jsx)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto`,children:D.map(e=>(0,X.jsxs)(`div`,{children:[e.name!==``&&(0,X.jsx)(`div`,{className:`truncate px-3 pb-0.5 pt-1.5 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:e.name}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 compact:gap-0`,children:e.sessions.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Gp,{session:e,activeSessionId:n,accountLabel:C,onArchived:s,ellipsis:!0,lastActive:!0})},e.id))})]},e.projectId))})]})]})]})}function Jp({className:e}){return(0,X.jsx)(`svg`,{viewBox:`0 0 2000 2000`,fill:`none`,"aria-hidden":`true`,className:e,children:(0,X.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:110,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`line`,{x1:`491.66`,y1:`1916.78`,x2:`1558.47`,y2:`83.22`}),(0,X.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,X.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,X.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 Yp=[`running`,`waiting_input`];function Xp({sessionId:e,status:t}){let n=Yp.includes(t),{data:r}=w(e,n),i=r?.vars??[];if(!n||i.length===0)return null;let a=async(e,t)=>{try{await navigator.clipboard.writeText(t),u.success(`${e} value copied`)}catch{u.error(`Couldn't copy ${e} value`)}};return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3 font-mono text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:`env`}),(0,X.jsx)(`div`,{className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`div`,{className:`flex w-max items-center gap-1 whitespace-nowrap`,children:i.map(e=>{let t=e.value;return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:t===void 0?(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-fg-secondary`,children:e.name}):(0,X.jsx)(`button`,{type:`button`,"aria-label":`Copy ${e.name} environment variable value`,onClick:()=>void a(e.name,t),className:`cursor-pointer rounded px-1.5 py-0.5 text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,children:e.name})}),(0,X.jsxs)(J,{children:[e.bytes,` B ·`,` `,t===void 0?`value unavailable from this daemon`:`click to copy value`]})]},e.name)})})})]})}function Zp(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var Qp=[`running`,`waiting_input`];function $p({sessionId:e,status:t}){let n=Qp.includes(t),{data:r}=y(e,n),i=r?.ports??[];return!n||i.length===0?null:(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3 text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:`ports`}),(0,X.jsx)(`div`,{className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`div`,{className:`flex w-max items-center gap-1 whitespace-nowrap`,children:i.map(t=>(0,X.jsx)(em,{sessionId:e,port:t},t.port))})})]})}function em({sessionId:e,port:t}){let n=M().data;return(0,X.jsxs)(Ll,{children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(Rl,{asChild:!0,children:(0,X.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,X.jsxs)(J,{children:[t.command,` · pid `,t.pid]})]}),(0,X.jsxs)(Bl,{align:`start`,children:[jt()===null?(0,X.jsx)(Vl,{asChild:!0,children:(0,X.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,X.jsx)(Vl,{onSelect:()=>{window.open(`/proxy/${e}/${t.port}/?puddle_token=${L.get()??``}`,`_blank`,`noopener,noreferrer`)},children:`Open via proxy`}),(0,X.jsx)(Vl,{onSelect:()=>{n&&navigator.clipboard.writeText(Zp(t.port,n.username,n.hostname)).then(()=>u.success(`Copied`))},children:`Copy ssh -L`})]})]})}var tm=[`interrupted`,`exited`];function nm({session:e}){let t=T(`resume`),n=hn();return tm.includes(e.status)&&!e.worktree_missing&&!e.conversation_missing?(0,X.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 right-3 z-10`,children:(0,X.jsxs)(H,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>{let t=We(e);t?n(`/project/${t.projectId}/session/${t.sessionId}`):He(e)}}),children:[(0,X.jsx)(Lr,{}),`Resume`]})}):null}function rm({tab:e,directory:t,onReveal:n,onRename:r,editing:i,children:a}){let o=M(),s=h().data?.protocol,c=Xs(),l=nc(e.session,e.root,t),d=(0,Z.useMemo)(()=>({sid:e.session,root:e.root,directory:t,host:Hs(o.data)}),[e.session,e.root,t,o.data]),f=e.root!==void 0&&!Kn(s),p=c!==null&&Ws(c.source,d),m=c!==null&&Us(c.source,d),g=!f&&(p&&m||c!==null&&Gs(c.source,d)&&Sn(s)),[_,v]=(0,Z.useState)(!1),y=Wa(t,e.path),b=()=>{!c||!g||l.paste(c,Ba(e.path)).then(e=>{c.mode===`cut`&&qs(c.id,e)})},x=t=>{navigator.clipboard.writeText(t?e.path:y),u.success(t?`Relative path copied`:`Path copied`)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(wt,{children:[(0,X.jsx)(ut,{asChild:!0,children:a}),(0,X.jsx)(bt,{onCloseAutoFocus:e=>{i&&e.preventDefault()},children:(0,X.jsx)(vc,{readOnly:f,canPaste:g,onCut:()=>Ks([e.path],`cut`,d),onCopy:()=>Ks([e.path],`copy`,d),onPaste:b,onCopyPath:()=>x(!1),onCopyRelativePath:()=>x(!0),onReveal:n,onRename:r,onDelete:()=>v(!0),onDownload:()=>{fe(e.session,e.path,e.root).catch(e=>u.error(e instanceof Error?e.message:`Download failed`))}})})]}),(0,X.jsx)(Be,{open:_,onOpenChange:v,children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsxs)(Re,{children:[`Delete “`,za(e.path),`”?`]}),(0,X.jsxs)(ze,{children:[`This permanently removes it from `,t,`. There is no undo.`]})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>v(!1),children:`Cancel`}),(0,X.jsx)(H,{variant:`danger`,onClick:()=>{v(!1),l.remove([e.path])},children:`Delete`})]})]})})]})}var im=`group relative flex min-w-16 max-w-52 cursor-pointer select-none items-center gap-1.5 rounded-t-md px-2.5 text-xs transition-colors`,am=`group-hover:[transform:translateX(var(--tail))]`;function om({leaf:e,sessions:t,onActivate:n,onClose:r,onPromote:i,onArchived:a,onSetView:o,onNewFile:s,onRevealFile:c,onRenameFile:l}){let u=new Map(t.map(e=>[e.id,e.branch])),d=new Map(t.map(e=>[e.id,e.worktree_path])),f=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),p=Cp(),m=p?.leafId===e.id&&p.index!==void 0?p.index:null,{setNodeRef:h}=Zf({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),g=e=>{let t=nr(e.path,e.session,f,u,e.root,d);return $n(e)===`diff`?`${t} (diff)`:$n(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,X.jsxs)(`div`,{ref:h,className:`flex h-9 shrink-0 items-stretch gap-0.5 overflow-x-auto bg-surface px-1 pt-1`,onDoubleClick:e=>{e.target===e.currentTarget&&s()},children:[e.tabs.map((s,u)=>(0,X.jsxs)(Z.Fragment,{children:[m===u&&(0,X.jsx)(sm,{}),(0,X.jsx)(pm,{tab:s,leafId:e.id,index:u,active:q(s)===e.activeKey,preview:q(s)===e.previewKey,session:s.type===`terminal`?t.find(e=>e.id===s.session):void 0,fileSession:s.type===`editor`&&s.tab.root===void 0?t.find(e=>e.id===s.tab.session):void 0,fileDirectory:s.type===`editor`&&($n(s.tab)===`file`||$n(s.tab)===`external`)?s.tab.root??t.find(e=>e.id===s.tab.session)?.worktree_path:void 0,label:s.type===`editor`?g(s.tab):``,onActivate:()=>n(s),onClose:()=>r(s),onPromote:()=>i(s),onArchived:a,onSetView:e=>o(s,e),onRevealFile:()=>s.type===`editor`&&c(s.tab),onRenameFile:e=>s.type===`editor`?l(s.tab,e):Promise.resolve(!1)})]},q(s))),m===e.tabs.length&&(0,X.jsx)(sm,{})]})}function sm(){return(0,X.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function cm({active:e,children:t}){return(0,X.jsx)(`span`,{className:a(`pointer-events-none absolute inset-y-0 right-0 flex items-center gap-1 rounded-tr-md pl-5 pr-2.5`,`[&>*]:pointer-events-auto`,e?`group-hover:bg-[linear-gradient(to_right,transparent,var(--color-ground)_1.25rem)]`:`group-hover:bg-[linear-gradient(to_right,transparent,var(--color-elevated)_1.25rem)]`),children:t})}var lm={source:`preview`,preview:`linked`,linked:`locked`,locked:`source`},um={source:Y,preview:cr,linked:Dr,locked:kr},dm={source:`Source — switch to preview`,preview:`Preview — switch to linked preview`,linked:`Linked preview — switch to locked preview`,locked:`Locked preview — switch to source`};function fm({view:e,onSetView:t}){let n=um[e];return(0,X.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(lm[e])},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":dm[e],title:dm[e],children:(0,X.jsx)(n,{className:`size-3`})})}function pm({tab:e,leafId:t,index:n,active:r,preview:i,session:s,fileSession:c,fileDirectory:l,label:u,onActivate:d,onClose:f,onPromote:p,onArchived:m,onSetView:h,onRevealFile:g,onRenameFile:_}){let[v,y]=(0,Z.useState)(!1),b=Rn(),x=q(e),{attributes:S,listeners:C,setNodeRef:w,isDragging:T}=qf({id:`drag:${t}:${x}`,data:{ref:e,fromLeafId:t}}),{setNodeRef:E}=Zf({id:`tabdrop:${t}:${x}`,data:{leafId:t,index:n}}),D=e=>{w(e),E(e)},O=a(im,r?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`,i&&`italic`,T&&`opacity-40`),k=(0,X.jsx)(`div`,{ref:D,...v?{}:S,...v?{}:C,onClick:d,onDoubleClick:p,className:a(O,v&&`cursor-text select-text`),children:e.type===`terminal`?(0,X.jsxs)(X.Fragment,{children:[s&&(0,X.jsx)(up,{status:s.status,kind:s.kind,agentType:s.agent_type,stale:s.stale_running}),(0,X.jsx)(`span`,{className:`truncate`,children:s?b(s):e.session.slice(0,8)}),(0,X.jsx)(cm,{active:r,children:(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),f()},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":`Close tab`,children:(0,X.jsx)(o,{className:`size-3`})})})]}):(0,X.jsxs)(X.Fragment,{children:[e.tab.view===`linked`&&(0,X.jsx)(Dr,{className:`size-3 shrink-0 text-fg-muted`}),e.tab.view===`locked`&&(0,X.jsx)(kr,{className:`size-3 shrink-0 text-fg-muted`}),v?(0,X.jsx)(mm,{initial:e.tab.path.split(`/`).pop()??e.tab.path,onCommit:_,onCancel:()=>y(!1),onCommitted:()=>y(!1)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zo,{text:u,hoverClass:am,containerClassName:`flex-[0_1_auto]`,className:($n(e.tab)===`file`||$n(e.tab)===`external`)&&Zt(e.tab.path)!==null?`-mr-16 pr-16`:`-mr-11 pr-11`}),(0,X.jsx)(po,{session:e.tab.session,path:e.tab.path,kind:$n(e.tab),root:e.tab.root}),(0,X.jsxs)(cm,{active:r,children:[($n(e.tab)===`file`||$n(e.tab)===`external`)&&Zt(e.tab.path)!==null&&(0,X.jsx)(fm,{view:e.tab.view??`source`,onSetView:h}),(0,X.jsx)(ho,{session:e.tab.session,path:e.tab.path,kind:$n(e.tab),root:e.tab.root,label:u,onClose:f})]})]})]})}),A=(0,X.jsx)(J,{side:`bottom`,children:(0,X.jsx)(Gl,{name:e.type===`terminal`?s?b(s):e.session:u,session:e.type===`terminal`?s:c})});return e.type===`terminal`&&s?(0,X.jsxs)(G,{children:[(0,X.jsx)(vp,{session:s,onArchived:()=>m(e.session),children:(0,X.jsx)(K,{asChild:!0,children:k})}),A]}):e.type===`editor`&&l!==void 0&&($n(e.tab)===`file`||$n(e.tab)===`external`)?(0,X.jsxs)(G,{open:!v&&void 0,children:[(0,X.jsx)(rm,{tab:e.tab,directory:l,onReveal:g,onRename:()=>y(!0),editing:v,children:(0,X.jsx)(K,{asChild:!0,children:k})}),A]}):(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:k}),A]})}function mm({initial:e,onCommit:t,onCommitted:n,onCancel:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let t=i.current;if(!t)return;let n=()=>{t.focus();let n=e.lastIndexOf(`.`);t.setSelectionRange(0,n>0?n:e.length)};n();let r=requestAnimationFrame(()=>{document.activeElement!==t&&n()});return()=>cancelAnimationFrame(r)},[e]);let o=()=>{a.current||(a.current=!0,t(i.current?.value??``).then(e=>{if(e){n();return}a.current=!1,requestAnimationFrame(()=>i.current?.focus())}))};return(0,X.jsx)(`input`,{ref:i,defaultValue:e,spellCheck:!1,"aria-label":`Rename ${e}`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?o():e.key===`Escape`&&(a.current=!0,r())},onBlur:o,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`,style:{width:`${Math.max(8,Math.min(e.length,24))}ch`}})}function hm(e,t,n){return{focus:e===`press`,driveScroll:t&&n!==`linked`}}function gm({leaf:e,sessions:t,reveal:n,onActivateTab:r,onCloseTab:i,onPromoteTab:o,onArchived:s,onFocusLeaf:c,onScrollDrive:l,onDropTab:u,onSetTabView:d,onNewUntitled:f,onRevealFile:p,onRenameFile:m,focused:h,scrollDriver:g,scrollChannel:_}){let v=e.tabs.find(t=>q(t)===e.activeKey)??null,y=v?.type===`terminal`?q(v):null,b=v?.type===`terminal`?t.find(e=>e.id===v.session)??null:null,x=yo(y),{setNodeRef:S}=Zf({id:`leaf:${e.id}`}),C=Cp(),w=A(`palette.toggle`),T=v?.type===`editor`?v.tab:null,E=T?.view??`source`,D=T!==null&&($n(T)===`file`||$n(T)===`external`)&&Zt(T.path)!==null,O=g&&D&&E!==`linked`,k=!O&&(E===`locked`||D&&E===`source`),j=t=>{let n=hm(t,D,E);n.focus&&c(e.id),n.driveScroll&&l(e.id)},M=(0,Z.useRef)(null),ee=(0,Z.useRef)(()=>void 0);ee.current=()=>{v&&r(e.id,v)},(0,Z.useEffect)(()=>{let e=M.current;if(!e)return;let t=()=>ee.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[te,ne]=(0,Z.useState)(null),N=(0,Z.useRef)(u);return N.current=u,(0,Z.useEffect)(()=>{let t=M.current;if(!t)return;let n=e=>e.dataTransfer!==null&&fc(e.dataTransfer.types),r=e=>{let n=t.getBoundingClientRect();return bp({width:n.width,height:n.height},{x:e.clientX-n.left,y:e.clientY-n.top})},i=e=>{n(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),ne(r(e)))},a=e=>{t.contains(e.relatedTarget)||ne(null)},o=t=>{if(!n(t))return;t.preventDefault(),t.stopPropagation(),ne(null);let i=dc(t.dataTransfer?.getData(`application/x-puddle-tab`)??``);i&&N.current(e.id,i,r(t))},s=()=>ne(null);return t.addEventListener(`dragenter`,i,!0),t.addEventListener(`dragover`,i,!0),t.addEventListener(`dragleave`,a,!0),t.addEventListener(`drop`,o,!0),window.addEventListener(`dragend`,s),()=>{t.removeEventListener(`dragenter`,i,!0),t.removeEventListener(`dragover`,i,!0),t.removeEventListener(`dragleave`,a,!0),t.removeEventListener(`drop`,o,!0),window.removeEventListener(`dragend`,s)}},[e.id]),(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,onMouseDownCapture:()=>j(`press`),onWheelCapture:()=>j(`scroll`),children:[e.tabs.length>0&&(0,X.jsx)(om,{leaf:e,sessions:t,onActivate:t=>r(e.id,t),onClose:t=>i(e.id,t),onPromote:o,onArchived:s,onSetView:(t,n)=>d(e.id,t,n),onNewFile:()=>f(e),onRevealFile:p,onRenameFile:m}),(0,X.jsxs)(`div`,{ref:e=>{M.current=e,S(e)},className:`relative min-h-0 flex-1`,children:[v?.type===`editor`&&(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(co,{tab:v.tab,reveal:n,focused:h,scrollDriver:O,scrollReceiver:k,scrollChannel:_})}),(0,X.jsx)(`div`,{ref:x,className:a(`absolute inset-0 py-1 pl-4 pr-2`,!y&&`hidden`)}),C?.leafId===e.id&&C.index===void 0&&(0,X.jsx)(vm,{zone:C.zone}),te!==null&&(0,X.jsx)(vm,{zone:te}),b&&(0,X.jsx)(nm,{session:b}),!v&&(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,X.jsx)(Jp,{className:`size-24 text-fg-muted/40`}),(0,X.jsx)(`button`,{type:`button`,onClick:vn,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:w})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1 empty:hidden`,children:[b&&(0,X.jsx)(Xp,{sessionId:b.id,status:b.status}),b&&(0,X.jsx)($p,{sessionId:b.id,status:b.status})]})]})}var _m={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 vm({zone:e}){return(0,X.jsx)(`div`,{className:a(`pointer-events-none absolute z-20 bg-accent/20`,_m[e])})}var ym=`bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`;function bm({tree:e,...t}){let n=(0,Z.useMemo)(()=>{let t=new Set,n=[];for(let r of ln(e)){if(r.type!==`editor`||![`file`,`diff`,`external`].includes($n(r.tab)))continue;let e=`${r.tab.session}\0${r.tab.path}\0${r.tab.root??``}`;t.has(e)||(t.add(e),n.push({session:r.tab.session,path:r.tab.path,root:r.tab.root}))}return n},[e]);return(0,X.jsxs)(X.Fragment,{children:[n.length>0&&(0,X.jsx)(uo,{buffers:n}),(0,X.jsx)(xm,{node:e,...t})]})}function xm({node:e,...t}){if(e.kind===`leaf`)return(0,X.jsx)(gm,{leaf:e,sessions:t.sessions,reveal:t.reveal,onActivateTab:t.onActivateTab,onCloseTab:t.onCloseTab,onPromoteTab:t.onPromoteTab,onArchived:t.onArchived,onFocusLeaf:t.onFocusLeaf,onScrollDrive:t.onScrollDrive,onDropTab:t.onDropTab,onSetTabView:t.onSetTabView,onNewUntitled:t.onNewUntitled,onRevealFile:t.onRevealFile,onRenameFile:t.onRenameFile,focused:e.id===t.focusedLeafId,scrollDriver:e.id===t.scrollDriverLeafId,scrollChannel:t.scrollChannel});let n=e.direction===`row`?`horizontal`:`vertical`;return(0,X.jsx)(Ma,{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,X.jsxs)(Z.Fragment,{children:[r>0&&(0,X.jsx)(Ra,{className:n===`horizontal`?`w-px ${ym}`:`h-px ${ym}`}),(0,X.jsx)(Fa,{id:e.id,minSize:64,children:(0,X.jsx)(xm,{node:e,...t})})]},e.id))},e.id)}function Sm(e,t=`profile`){let n=e.snapshot,r=(0,Z.useRef)(null),i=(0,Z.useRef)(t),a=(0,Z.useRef)(!1);i.current!==t&&(i.current=t,r.current=null,a.current=!1),!n.layout_tree&&!r.current&&(r.current=gn(n));let o=n.layout_tree??r.current??un([]),s=(0,Z.useMemo)(()=>Qn(o),[o]),c=(0,Z.useCallback)(t=>e.update({layout_tree:t}),[e]),l=(0,Z.useRef)(c);l.current=c,(0,Z.useEffect)(()=>{a.current||e.loaded&&!n.layout_tree&&r.current&&(a.current=!0,ln(r.current).length>0&&l.current(r.current))},[e.loaded,n.layout_tree]),(0,Z.useEffect)(()=>{e.loaded&&s!==o&&n.layout_tree&&l.current(s)},[e.loaded,s,o,n.layout_tree]);let[u,d]=(0,Z.useState)(null),f=(u?Xn(s,u):null)??En(s)[0]??un([]),p=f.tabs.find(e=>q(e)===f.activeKey)??null,m=p?.type===`editor`?p.tab:null;return(0,Z.useMemo)(()=>({tree:s,focusedLeaf:f,activeEditorTab:m,focusLeaf:e=>d(e),activate:(e,t)=>{d(e);let n=q(t),r=Xn(s,e)?.activeKey===n,i=An(r?s:Kt(s,e,n),t);r&&i===s||c(i)},close:(e,t)=>{let n=qn(s,e,q(t)),r=Xn(n,e),i=r?.tabs.find(e=>q(e)===r.activeKey);c(i?An(n,i):n)},openEditor:(e,t)=>{let n=f.id;d(n);let r={type:`editor`,tab:e},i=t?.preview?Yt(s,n,r):Fn(s,n,r);c(An(i,r))},ensureTerminal:(e,t)=>{let n=`term:${e}`,r=Yn(s,n);if(r){d(r.id);let e=r.activeKey!==n,i=!t?.preview&&r.previewKey===n;if(e||i){let t=s;e&&(t=Kt(t,r.id,n)),i&&(t=qt(t,n)),c(t)}}else{let n=f.id;d(n);let r={type:`terminal`,session:e};c(t?.preview?Yt(s,n,r):Fn(s,n,r))}},promote:e=>c(qt(s,q(e))),setView:(e,t,n)=>{let r=tn(s,e,q(t),n),i=Xn(r,e),a=i?.tabs.find(e=>q(e)===i.activeKey);c(a?An(r,a):r)},renameFile:(e,t)=>{let n=jn(s,e,t);n!==s&&c(n)},removeTerminal:e=>{let t=Yn(s,`term:${e}`);t&&c(qn(s,t.id,`term:${e}`))},pruneSessions:e=>c(rn(s,wn(e))),resize:(e,t)=>c(Wt(s,e,t)),drop:e=>{d(e.toLeafId),c(An(_n(s,e),e.ref))}}),[s,f,m,c])}function Cm(e,t,n){return n>0?`● ${n} waiting — ${e} (${t})`:`${e} — ${t}`}function wm(){return(0,X.jsx)(Se,{children:(0,X.jsx)(Tm,{})})}function Tm(){let e=sn(),t=hn(),n=f(),r=e.id??``,i=/^[0-9a-f]{10}$/.test(r),a=e.sid??null,o=te(i?r:void 0),s=o.data?.project.id===r?o.data:void 0,d=_(o.data?.project.profile_id).data??[],g=Rn(),v=A(`editor.save`),y=h().data?.protocol,S=On(),C=l(),w=(0,Z.useMemo)(()=>s?.sessions??C.data?.filter(e=>e.project_id===r)??[],[s,C.data,r]),T=C.data??w,E=cn(),D=E.projectBasedLayout,O=E.showAllProjectSessions,k=D&&S.snapshot.layout_mode===`project`,P=Nn(S,r,k),re=(0,Z.useRef)(S);re.current=S;let F=(0,Z.useRef)(C.data);F.current=C.data;let I=o.data?.project.profile_id,L=x(I),ae=b(I),se=ne(I??``),R=s?.project??L.data?.find(e=>e.id===r),ce=(0,Z.useMemo)(()=>_t((L.data??(R?[R]:[])).filter(e=>!e.archived),ae.data?.projectOrder??[]),[L.data,R,ae.data]),le=(0,Z.useMemo)(()=>{let e=e=>e.status!==`archived`,t=C.data??w;return ce.map(n=>({projectId:n.id,name:n.name,abbrev:bn(n),repoId:n.repo_id,sessions:_t(t.filter(t=>t.project_id===n.id&&e(t)&&(O||n.id===r)),P.snapshot.session_order)}))},[O,w,r,P.snapshot.session_order,ce,C.data]),ue=(0,Z.useCallback)((e,t)=>{let n=ce.map(e=>e.id),r=$e(n,e,t);r.some((e,t)=>e!==n[t])&&se.mutate({projectOrder:r})},[ce,se]),de=(0,Z.useMemo)(()=>{let e=e=>Date.parse(e.last_activity_at??e.created_at)||0,t=t=>t.sort((t,n)=>e(n)-e(t)),n=e=>e.status===`archived`;if(k||!O)return t(w.filter(n));let r=C.data??w;return ce.flatMap(e=>t(r.filter(t=>t.project_id===e.id&&n(t))))},[O,k,w,C.data,ce]),fe=(0,Z.useRef)(ce);fe.current=ce;let z=(0,Z.useRef)(L.data);z.current=L.data,(0,Z.useEffect)(()=>{let e=re.current;if(!e.loaded)return;let t=e.current(),n=t.layout_mode??`profile`;if(D&&n!==`project`){if(!C.data||!L.data)return;let n=new Map(C.data.map(e=>[e.id,e.project_id])),i=Gn(t,L.data.map(e=>e.id),n,r);e.update({...i,project_layouts:Hn(i.project_layouts??{},t.project_layouts)})}else!D&&n===`project`&&e.update(xn(t,[r,...fe.current.map(e=>e.id)]))},[D,S.loaded,C.data,L.data,r]);let pe=k?`project:${r}`:`profile`,B=Sm(P,pe),[me,he]=(0,Z.useState)(null),V=(0,Z.useCallback)(e=>he({scopeKey:pe,leafId:e}),[pe]),_e=(me?.scopeKey===pe?Xn(B.tree,me.leafId):null)?.id??B.focusedLeaf.id;(0,Z.useEffect)(()=>{V(B.focusedLeaf.id)},[V,B.focusedLeaf.id,B.focusedLeaf.activeKey]);let ye=(0,Z.useCallback)(e=>{B.focusLeaf(e),V(e)},[B,V]),Se=S.snapshot.project_layouts,we=(0,Z.useMemo)(()=>k?yn(Se,r):[],[k,Se,r]),Te=(0,Z.useRef)(B);Te.current=B;let Ee=(0,Z.useRef)(P);Ee.current=P;let De=(0,Z.useCallback)(e=>Ee.current.update({session_order:tt(e,Ee.current.snapshot.session_order)}),[]),Oe=ko(Ao),Ae=(0,Z.useRef)(Oe);Ae.current=Oe;let[je,Me]=(0,Z.useState)(!1),[Pe,Ie]=(0,Z.useState)(!1),[Ve,Ue]=(0,Z.useState)(null),We=Ve===r,[Ge,Ke]=(0,Z.useState)(!1),[Je,Ye]=(0,Z.useState)(`agent`),[Xe,Ze]=(0,Z.useState)(void 0),[Qe,et]=(0,Z.useState)(null),nt=(0,Z.useCallback)((e=`agent`,t)=>{Ze(void 0),et(t??null),Ye(e),Ke(!0)},[]),rt=(0,Z.useCallback)((e,t)=>{let n=ce.find(e=>e.id===t);nt(e,n?{projectId:n.id,repoId:n.repo_id}:void 0)},[ce,nt]),it=(0,Z.useRef)(null),at=(0,Z.useRef)(null),{setHandler:ot}=mn();(0,Z.useEffect)(()=>{!i||!In(y)||c(r).catch(()=>void 0)},[y,r,i]),(0,Z.useEffect)(()=>Pn.onSessionSwitched(e=>{e.source_session===a&&(at.current={session:e.target_session,pin:!1},e.target_project===r&&Te.current.ensureTerminal(e.target_session,{preview:!0}),t(`/project/${e.target_project}/session/${e.target_session}`))}),[a,t,r]);let[st,ct]=(0,Z.useState)(null),lt=(0,Z.useCallback)((e,t,n)=>{V(B.focusedLeaf.id),B.openEditor(e,{preview:n?.preview}),Ae.current&&Me(!1),t&&(e.kind??`file`)===`file`&&ct({session:e.session,path:e.path,line:t.line,column:t.column,nonce:Date.now()})},[B,V]),ut=(0,Z.useCallback)((e,t,n,r)=>lt({...r?.root===void 0?{kind:`file`,session:e,path:t}:{kind:`external`,session:e,path:t,root:r.root},...r?.view?{view:r.view}:{}},n,r),[lt]);be(ut);let[dt,ft]=(0,Z.useState)(null),pt=(0,Z.useCallback)((e,t,n)=>ut(e,t,void 0,{preview:n?.preview??!0}),[ut]),mt=(0,Z.useCallback)((e,r)=>{let i=w.find(t=>t.id===e);i&&n.mutate({project_id:i.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:i.worktree_path,cwd:r},{onSuccess:e=>void t(`/project/${e.project_id}/session/${e.id}`),onError:e=>He(e)})},[w,n,t]),ht=(0,Z.useCallback)(e=>B.promote(e),[B]),gt=(0,Z.useCallback)((e,t,n,r)=>lt({kind:`external`,session:e,path:t,root:n},void 0,{preview:r?.preview??!0}),[lt]),vt=ee(),yt=Tn(y),bt=(0,Z.useCallback)(e=>{if(I!==void 0){if(!yt){u.error(`Untitled drafts need a newer daemon — refresh the connection to update it`);return}ve(I).then(({name:e})=>lt({kind:`untitled`,session:m,path:e})).catch(e=>u.error(e instanceof Error?e.message:`Could not create a draft`))}},[lt,I,yt]),[xt,St]=(0,Z.useState)(null);(0,Z.useEffect)(()=>(xe(St),()=>xe(null)),[]);let[U,Ct]=(0,Z.useState)(null),wt=()=>{let e=U;if(Ct(null),!e||e.ref.type!==`editor`)return;let t=e.ref.tab.path;I!==void 0&&Ce(I,t).catch(()=>void 0),ge(t),B.close(e.leafId,e.ref)},Tt=(e,t,n,r)=>{St(null);let i={type:`editor`,tab:{kind:`untitled`,session:m,path:e}},a=q(i);for(let e of En(Te.current.tree))e.tabs.some(e=>q(e)===a)&&Te.current.close(e.id,i);vt.invalidateQueries({queryKey:[`wt-tree`,t]}),setTimeout(()=>{Te.current.openEditor(r===void 0?{kind:`file`,session:t,path:n}:{kind:`external`,session:t,path:n,root:r})},0)};(0,Z.useEffect)(()=>(ot(e=>{Ze(e?.accountId),Ye(e?.kind??`agent`),Ke(!0)}),()=>ot(null)),[ot]);let[Et,Dt]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!P.loaded)return;let e=ln(Te.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?qe():void 0,e.some(e=>e.type===`editor`)?oo():void 0]).finally(()=>Dt(!0))},[P.loaded,pe]),(0,Z.useEffect)(()=>{if(We||!P.loaded||!s)return;Ue(r);let e=P.snapshot.active_session,n=w.find(t=>t.id===e);!a&&n&&n.status!==`archived`&&t(`/project/${r}/session/${n.id}`,{replace:!0})},[We,P,s,w,a,t,r]);let Ot=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(Ot.current||!P.loaded||!C.data)return;Ot.current=!0;let e=new Set(C.data.filter(e=>e.status!==`archived`).map(e=>e.id));Te.current.pruneSessions(e);let t=re.current,n=t.current().project_layouts;if(Object.keys(n).length>0){let r=wn(e);t.update({project_layouts:Object.fromEntries(Object.entries(n).map(([t,n])=>[t,{...n,layout_tree:n.layout_tree?rn(n.layout_tree,r):null,active_session:n.active_session!==null&&e.has(n.active_session)?n.active_session:null}]))})}let r=Ee.current.snapshot.session_order,i=r.filter(t=>e.has(t));i.length!==r.length&&Ee.current.update({session_order:i})},[P.loaded,C.data]),(0,Z.useEffect)(()=>{if(!We)return;if(Ie(!1),!a){it.current=null;return}if(a===it.current)return;it.current=null;let e=at.current;at.current=null,Te.current.ensureTerminal(a,{preview:e?.session!==a||!e.pin});let t=Ee.current;t.snapshot.active_session!==a&&t.update({active_session:a})},[We,a]);let kt=M();(0,Z.useEffect)(()=>{let e=ie(kt.data)??`Puddle`,t=w.filter(e=>e.status===`waiting_input`).length,n=R?.name??`Puddle`;return document.title=Cm(n,e,t),()=>{document.title=e}},[w,R?.name,kt.data]);let At=(0,Z.useCallback)(e=>{let n=a===e;n&&(it.current=e),B.removeTerminal(e),n&&(P.update({active_session:null}),t(`/project/${r}`))},[B,P,a,t,r]),jt=p(),Mt=(0,Z.useCallback)(e=>jt.mutate(e,{onSuccess:()=>At(e),onError:e=>He(e)}),[jt,At]),Pt=(0,Z.useCallback)((e,n)=>{if(V(e),B.activate(e,n),n.type===`terminal`&&n.session!==a){let e=T.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[B,t,T,a,V]),It=(0,Z.useCallback)((e,n)=>{if(n.type===`editor`&&$n(n.tab)===`untitled`){Ct({leafId:e,ref:n});return}let i=Xn(B.tree,e)?.tabs.findIndex(e=>q(e)===q(n))??-1;Do(pe,{leafId:e,index:Math.max(0,i),ref:n}),B.close(e,n),n.type===`terminal`&&n.session===a&&(it.current=n.session,P.update({active_session:null}),t(`/project/${r}`))},[B,a,P,t,r,pe]),Lt=(0,Z.useCallback)(()=>{let e=F.current,n=e?new Set(e.filter(e=>e.status!==`archived`).map(e=>e.id)):null,r=Oo(pe,e=>{if(n===null)return!0;let t=e.type===`terminal`?e.session:e.tab.session;return n.has(t)});if(!r)return;let{ref:i}=r,o=Xn(B.tree,r.leafId),s=o?r.leafId:B.focusedLeaf.id,c=o?r.index:void 0;if(B.drop({ref:i,fromLeafId:s,toLeafId:s,edge:`center`,index:c}),i.type===`terminal`&&i.session!==a){let e=T.find(e=>e.id===i.session)?.project_id;e&&t(`/project/${e}/session/${i.session}`)}},[B,pe,a,T,t]),Rt=(0,Z.useCallback)((e,n,i)=>{let o=n.type===`terminal`?T.find(e=>e.id===n.session)?.project_id:void 0;if(k&&o!==void 0&&o!==r&&n.type===`terminal`){at.current={session:n.session,pin:!0},t(`/project/${o}/session/${n.session}`);return}B.drop({ref:n,fromLeafId:e,toLeafId:e,edge:i,copy:!0}),n.type===`terminal`&&n.session!==a&&o!==void 0&&t(`/project/${o}/session/${n.session}`)},[B,a,T,t,k,r]),zt=B.focusedLeaf.tabs.find(e=>q(e)===B.focusedLeaf.activeKey)??null,Bt=zt===null?null:zt.type===`terminal`?zt.session:zt.tab.session,Vt=Bt===`00000000-0000-0000-0000-000000000000`?null:Bt,Ht=j().data?.find(e=>e.id===R?.repo_id),Ut=(0,Z.useMemo)(()=>Vn(y)&&Ht&&R?{path:Ht.path,projectId:R.id,name:R.name,defaultBranch:Ht.default_base_branch}:null,[y,Ht,R]),Wt=no(T,Vt??a,P,Ut),W=Wt.session,G=Wt.root,Kt=(0,Z.useCallback)(e=>{let t=T.find(t=>t.id===e.session);if(e.root===void 0&&!t)return;let n=ro(e,t?.worktree_path??e.root??``);if(Ae.current&&Me(!0),P.update({sidebar_mode:`files`,...Ae.current?{}:{sidebar_collapsed:!1}}),n.browseRoot!==void 0){let r=t?.id??W?.id??e.session;ft({session:r,root:n.browseRoot,nonce:Date.now()})}else(G??W?.worktree_path)!==n.directory&&Wt.pin(e.session);So({path:n.path,directory:n.directory})},[Wt,T,G,W?.worktree_path,P]),qt=(0,Z.useCallback)(async(e,t)=>{let n=t.trim();if(n===``||n===za(e.path))return!0;let r=Ua(Ba(e.path),n);try{let{rekeyBuffer:t}=await ke(async()=>{let{rekeyBuffer:e}=await import(`./buffer-store-Ch_ccGob.js`).then(e=>e.n);return{rekeyBuffer:e}},__vite__mapDeps([16,1,2,6,9,3,4,10,11,12,14,15,17])),n=await oe(e.session,e.path,r,e.root),i=t(e.session,e.path,n.path,e.root);return Te.current.renameFile(e,n.path),vt.invalidateQueries({queryKey:[`wt-tree`,e.session]}),vt.invalidateQueries({queryKey:[`wt-git-status`,e.session]}),setTimeout(()=>{(i?.dirty?er(e.session,n.path,i.content,i.baseMtimeMs,e.root):Promise.resolve()).then(()=>tr(e.session,e.path,e.root))},0),!0}catch(e){return He(e),!1}},[vt]),Jt=(0,Z.useCallback)((e,t)=>{if(t.kind===`dir`){Ae.current&&Me(!0),P.update({sidebar_mode:`files`,...Ae.current?{}:{sidebar_collapsed:!1}}),ft({session:e,root:t.path,nonce:Date.now()});return}let n=Ft(t,G);n!==null&&ft({session:e,root:n,nonce:Date.now()}),ut(e,t.path,t.line===void 0?void 0:{line:t.line,column:t.column},t.root===void 0?void 0:{root:t.root})},[ut,P,G]),Yt=W?.id??null,Xt=(0,Z.useCallback)(async e=>{if(Yt===null)throw Error(`No worktree is available for this project.`);let t=await Nt(Yt,e,{root:G}),n=t.kind===`file`&&t.root===void 0&&G!==void 0?{...t,root:G}:t;if(n.kind===`dir`&&n.relativePath!==void 0){Ae.current&&Me(!0),P.update({sidebar_mode:`files`,...Ae.current?{}:{sidebar_collapsed:!1}}),So({path:n.relativePath,root:G,expandTarget:!0});return}Jt(Yt,n)},[Yt,G,Jt]);(0,Z.useEffect)(()=>kn(Xt),[Xt]);let Zt=Zl(P.snapshot.sidebar_mode),Qt=P.snapshot.sidebar_collapsed,K=P.snapshot.sessions_collapsed,tn=(0,Z.useCallback)(e=>{let t=B.focusedLeaf,n=t.tabs.find(e=>q(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){u.error(`Focus a terminal or agent to insert`);return}Pn.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[B]);(0,Z.useEffect)(()=>(Gt(tn),()=>Gt(null)),[tn]);let nn=(0,Z.useCallback)(e=>{let t=re.current,n=F.current,i=z.current;if(!t.loaded||!n||!i)return!1;let{patch:a,projectBased:o}=zn(t.current(),e,{alive:new Set(n.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(n.map(e=>[e.id,e.project_id])),projectIds:i.map(e=>e.id),currentProject:r});return t.update(a),$t().projectBasedLayout!==o&&en({projectBasedLayout:o}),!0},[r]),an=k?`project`:`profile`,on=P.snapshot.layout_tree,un=P.snapshot.layout_ref,dn=S.snapshot.project_layouts;(0,Z.useEffect)(()=>{S.loaded&&Cn({scope:an,projectId:r,layoutRef:un,signature:Bn(on),slices:Object.fromEntries(Object.entries(dn).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:Bn(t.layout_tree)}])),capture:()=>{let e=Ee.current.current();return{layout_tree:e.layout_tree,active_session:e.active_session}},apply:nn})},[S.loaded,an,r,on,un,dn,nn]),(0,Z.useEffect)(()=>()=>Cn(null),[]);let fn=(0,Z.useRef)({}),J=e=>{let t=B.focusedLeaf;if(t.tabs.length<2)return;let n=t.tabs.findIndex(e=>q(e)===t.activeKey),r=n===-1?e===1?0:t.tabs.length-1:n+e,i=t.tabs[(r+t.tabs.length)%t.tabs.length];i&&Pt(t.id,i)},pn=e=>{Oe?(P.update({sidebar_mode:e}),Me(!0)):P.update({sidebar_mode:e,sidebar_collapsed:!1})};fn.current={"tab.close":()=>{let e=B.focusedLeaf,t=e.tabs.find(t=>q(t)===e.activeKey);t&&It(e.id,t)},"tab.reopen":Lt,"tab.newUntitled":()=>bt(B.focusedLeaf),"tab.next":()=>J(1),"tab.prev":()=>J(-1),"editor.save":()=>{Za(B.activeEditorTab)},"sidebar.left":()=>Oe?Me(e=>!e):P.update({sidebar_collapsed:!P.snapshot.sidebar_collapsed}),"sidebar.right":()=>Oe?Ie(e=>!e):P.update({sessions_collapsed:!P.snapshot.sessions_collapsed}),"nav.files":()=>pn(`files`),"nav.search":()=>pn(`search`),"nav.changes":()=>pn(`changes`),"nav.worktrees":()=>pn(`worktrees`),"session.newAgent":()=>nt(`agent`),"session.newTerminal":()=>nt(`terminal`)},(0,Z.useEffect)(()=>{let e=Object.keys(fn.current).map(e=>N(e,()=>fn.current[e]?.()));return()=>e.forEach(e=>e())},[]);let gn=B.activeEditorTab,_n=gn?.kind===`diff`&&W&&gn.session===W.id?gn.path:null,vn=gn&&(gn.kind??`file`)===`file`&&W&&gn.session===W.id?gn.path:null,Sn=gn?.kind===`external`&&gn.root!==void 0?{path:gn.path,root:gn.root}:null,Dn=e=>({preview:e?.preview??!0}),An=(e,t)=>{if(W){let n=t?.root??G,r=n===void 0?{}:{root:n};lt({kind:`diff`,session:W.id,path:e,...r,...t?.gitArea===void 0?{}:{git_area:t.gitArea}},void 0,Dn(t))}},jn=(e,t,n)=>{if(W){let r=n?.root??G,i=r===void 0?{}:{root:r};lt({kind:`commit`,session:W.id,path:e,sha:t,...i},void 0,Dn(n))}},Mn=(e,t,n)=>{if(!W)return;let r=t===void 0?void 0:{line:t,column:1};if(G!==void 0){lt({kind:`external`,session:W.id,path:e,root:G},r,Dn(n));return}ut(W.id,e,r,Dn(n))},Fn=(0,Z.useCallback)(e=>P.update({layout:{...P.snapshot.layout,...e}}),[P]),Ln=jo(P.snapshot.layout,[...Qt?[]:[`nav`],`main`,...K?[]:[`sessions`]]);if(!i)return null;if(!P.loaded||!R||!Et)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`});let Un=e=>(0,X.jsx)($l,{mode:Zt,onModeChange:e=>P.update({sidebar_mode:e}),onCollapse:e,projectId:r,repoId:R.repo_id,sessions:w,target:Wt,browseRequest:dt,onOpenFile:pt,onOpenExternalFile:gt,onOpenTerminalIn:mt,activeFilePath:vn,activeExternalTab:Sn,activeDiffPath:_n,onOpenDiff:An,onOpenCommitFile:jn,onOpenSearchFile:Mn}),Wn={onNewSessionIn:e=>rt(`agent`,e),onNewTerminalIn:e=>rt(`terminal`,e),onMoveProject:ue},Kn=e=>(0,X.jsx)(Kp,{groups:le,accounts:d,activeSessionId:a,onReorder:De,onPromote:e=>B.ensureTerminal(e),archived:de,onNewSession:()=>nt(`agent`),onNewTerminal:()=>nt(`terminal`),onCollapse:e,onArchived:At,onArchiveDrop:Mt,projectActions:Wn}),qn=(0,X.jsx)(`div`,{className:`flex h-full flex-col bg-ground`,children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(bm,{tree:B.tree,sessions:T,reveal:st,onActivateTab:Pt,onCloseTab:It,onPromoteTab:ht,onArchived:At,onFocusLeaf:ye,onScrollDrive:V,onResize:B.resize,onDropTab:Rt,onSetTabView:B.setView,onNewUntitled:bt,onRevealFile:Kt,onRenameFile:qt,focusedLeafId:B.focusedLeaf.id,scrollDriverLeafId:_e,scrollChannel:pe})})});return(0,X.jsx)(vo,{tree:B.tree,parked:we,onOpenFile:Jt,children:(0,X.jsx)(jp,{onDrop:B.drop,onArchive:Mt,renderOverlay:e=>{let t=e.type===`terminal`?T.find(t=>t.id===e.session):void 0;return(0,X.jsx)(`div`,{className:`rounded-md bg-elevated px-2.5 py-1 text-xs text-fg shadow-lg`,children:e.type===`terminal`?t?g(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,X.jsxs)(`div`,{className:`relative flex h-full`,children:[Oe?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ql,{mode:Zt,onExpand:()=>Me(!0),onSelect:e=>{P.update({sidebar_mode:e}),Me(!0)}}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:qn}),(0,X.jsx)(Wp,{groups:le,accounts:d,activeSessionId:a,onReorder:De,onPromote:e=>B.ensureTerminal(e),onExpand:()=>Ie(!0),onNewTerminal:()=>nt(`terminal`),onNewSession:()=>nt(`agent`),onArchived:At,onArchiveDrop:Mt,projectActions:Wn}),je&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close the navigator`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>Me(!1)}),(0,X.jsx)(`div`,{className:`absolute inset-y-0 left-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:Un(()=>Me(!1))})]}),Pe&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close the session list`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>Ie(!1)}),(0,X.jsx)(`div`,{className:`absolute inset-y-0 right-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:Kn(()=>Ie(!1))})]})]}):(0,X.jsxs)(X.Fragment,{children:[Qt&&(0,X.jsx)(Ql,{mode:Zt,onExpand:()=>P.update({sidebar_collapsed:!1}),onSelect:e=>P.update({sidebar_collapsed:!1,sidebar_mode:e})}),(0,X.jsxs)(Ma,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:Ln,onLayoutChanged:Fn,children:[!Qt&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fa,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,children:Un(()=>P.update({sidebar_collapsed:!0}))}),(0,X.jsx)(Ra,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`})]}),(0,X.jsx)(Fa,{id:`main`,children:qn}),!K&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ra,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`}),(0,X.jsx)(Fa,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,children:Kn(()=>P.update({sessions_collapsed:!0}))})]})]}),K&&(0,X.jsx)(Wp,{groups:le,accounts:d,activeSessionId:a,onReorder:De,onPromote:e=>B.ensureTerminal(e),onExpand:()=>P.update({sessions_collapsed:!1}),onNewTerminal:()=>nt(`terminal`),onNewSession:()=>nt(`agent`),onArchived:At,onArchiveDrop:Mt,projectActions:Wn})]}),(0,X.jsx)(nu,{projectId:Qe?.projectId??r,repoId:Qe?.repoId??R.repo_id,open:Ge,kind:Je,seedAccountId:Xe,onOpenChange:Ke,onCreated:e=>void t(`/project/${e.project_id}/session/${e.id}`)}),(0,X.jsx)(Qa,{request:xt,targetSession:W,targetRoot:G,targetLabel:W===null?``:G===void 0?W.branch:G,profileId:I,onClose:()=>St(null),onSaved:Tt}),(0,X.jsx)(Be,{open:U!==null,onOpenChange:e=>!e&&Ct(null),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Discard this draft?`}),(0,X.jsxs)(ze,{children:[`Closing an untitled tab deletes its draft — `,v,` saves it into the worktree instead.`]})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>Ct(null),children:`Keep editing`}),(0,X.jsx)(H,{variant:`danger`,onClick:wt,children:`Discard`})]})]})})]})})})}export{wm as Workspace};
7
+ `},zu={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 Bu(e){let{announcements:t=zu,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Ru}=e,{announce:a,announcement:o}=Pu(),s=bu(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),Iu((0,Z.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=Z.createElement(Z.Fragment,null,Z.createElement(Mu,{id:r,value:i.draggable}),Z.createElement(Nu,{id:s,announcement:o}));return n?(0,go.createPortal)(u,n):u}var Vu;(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`})(Vu||={});function Hu(){}function Uu(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Wu(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Gu=Object.freeze({x:0,y:0});function Ku(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function qu(e,t){let n=Du(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 Ju(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Yu(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Xu(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 Zu(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Qu(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 $u=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=Qu(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Yu)};function ed(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 td=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&&ed(r,a)){let n=Xu(a).reduce((e,t)=>e+Ku(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(Ju)};function nd(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function rd(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Gu}function id(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 ad=id(1);function od(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 sd(e,t,n){let r=od(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 cd={ignoreTransform:!1};function ld(e,t){t===void 0&&(t=cd);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=su(e).getComputedStyle(e);t&&(n=sd(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 ud(e){return ld(e,{ignoreTransform:!0})}function dd(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function fd(e,t){return t===void 0&&(t=su(e).getComputedStyle(e)),t.position===`fixed`}function pd(e,t){t===void 0&&(t=su(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 md(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(cu(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!lu(i)||uu(i)||n.includes(i))return n;let a=su(e).getComputedStyle(i);return i!==e&&pd(i,a)&&n.push(i),fd(i,a)?n:r(i.parentNode)}return e?r(e):n}function hd(e){let[t]=md(e,1);return t??null}function gd(e){return!iu||!e?null:au(e)?e:ou(e)?cu(e)||e===du(e).scrollingElement?window:lu(e)?e:null:null}function _d(e){return au(e)?e.scrollX:e.scrollLeft}function vd(e){return au(e)?e.scrollY:e.scrollTop}function yd(e){return{x:_d(e),y:vd(e)}}var bd;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(bd||={});function xd(e){return!iu||!e?!1:e===document.scrollingElement}function Sd(e){let t={x:0,y:0},n=xd(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 Cd={x:.2,y:.2};function wd(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Cd);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Sd(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=bd.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=bd.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=bd.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=bd.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Td(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 Ed(e){return e.reduce((e,t)=>Su(e,yd(t)),Gu)}function Dd(e){return e.reduce((e,t)=>e+_d(t),0)}function Od(e){return e.reduce((e,t)=>e+vd(t),0)}function kd(e,t){if(t===void 0&&(t=ld),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);hd(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Ad=[[`x`,[`left`,`right`],Dd],[`y`,[`top`,`bottom`],Od]],jd=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=md(t),r=Ed(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Ad)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})}},Md=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 Nd(e){let{EventTarget:t}=su(e);return e instanceof t?e:du(e)}function Pd(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 Fd;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Fd||={});function Id(e){e.preventDefault()}function Ld(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 Rd={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},zd=(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}}},Bd=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 Md(du(t)),this.windowListeners=new Md(su(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Fd.Resize,this.handleCancel),this.windowListeners.add(Fd.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Fd.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&kd(n),t(Gu)}handleKeyDown(e){if(Tu(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Rd,coordinateGetter:a=zd,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}:Gu;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Cu(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}=Sd(n),p=Td(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,Su(Cu(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()}};Bd.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Rd,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 Vd(e){return!!(e&&`distance`in e)}function Hd(e){return!!(e&&`delay`in e)}var Ud=class{constructor(e,t,n){n===void 0&&(n=Nd(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=du(i),this.documentListeners=new Md(this.document),this.listeners=new Md(n),this.windowListeners=new Md(su(i)),this.initialCoordinates=Du(r)??Gu,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(Fd.Resize,this.handleCancel),this.windowListeners.add(Fd.DragStart,Id),this.windowListeners.add(Fd.VisibilityChange,this.handleCancel),this.windowListeners.add(Fd.ContextMenu,Id),this.documentListeners.add(Fd.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Hd(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Vd(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(Fd.Click,Ld,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Fd.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=Du(e)??Gu,s=Cu(n,o);if(!t&&a){if(Vd(a)){if(a.tolerance!=null&&Pd(s,a.tolerance))return this.handleCancel();if(Pd(s,a.distance))return this.handleStart()}if(Hd(a)&&Pd(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()}},Wd={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Gd=class extends Ud{constructor(e){let{event:t}=e,n=du(t.target);super(e,Wd,n)}};Gd.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 Kd={move:{name:`mousemove`},end:{name:`mouseup`}},qd;(function(e){e[e.RightClick=2]=`RightClick`})(qd||={});var Jd=class extends Ud{constructor(e){super(e,Kd,du(e.event.target))}};Jd.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===qd.RightClick?!1:(r?.({event:n}),!0)}}];var Yd={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Xd=class extends Ud{constructor(e){super(e,Yd)}static setup(){return window.addEventListener(Yd.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Yd.move.name,e)};function e(){}}};Xd.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 Zd;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Zd||={});var Qd;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Qd||={});function $d(e){let{acceleration:t,activator:n=Zd.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Qd.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=tf({delta:d,disabled:!a}),[m,h]=mu(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case Zd.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Zd.DraggableRect:return i}},[n,i,c]),y=(0,Z.useRef)(null),b=(0,Z.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,Z.useMemo)(()=>s===Qd.TreeOrder?[...l].reverse():l,[s,l]);(0,Z.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}=wd(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 ef={x:{[bd.Backward]:!1,[bd.Forward]:!1},y:{[bd.Backward]:!1,[bd.Forward]:!1}};function tf(e){let{delta:t,disabled:n}=e,r=vu(t);return gu(e=>{if(n||!r||!e)return ef;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[bd.Backward]:e.x[bd.Backward]||i.x===-1,[bd.Forward]:e.x[bd.Forward]||i.x===1},y:{[bd.Backward]:e.y[bd.Backward]||i.y===-1,[bd.Forward]:e.y[bd.Forward]||i.y===1}}},[n,t,r])}function nf(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return gu(e=>t==null?null:r??e??null,[r,t])}function rf(e,t){return(0,Z.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 af;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(af||={});var of;(function(e){e.Optimized=`optimized`})(of||={});var sf=new Map;function cf(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,Z.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,Z.useRef)(e),d=g(),f=hu(d),p=(0,Z.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,Z.useRef)(null),h=gu(t=>{if(d&&!n)return sf;if(!t||t===sf||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 jd(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,Z.useEffect)(()=>{u.current=e},[e]),(0,Z.useEffect)(()=>{d||p()},[n,d]),(0,Z.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,Z.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 af.Always:return!1;case af.BeforeDragging:return n;default:return!n}}}function lf(e,t){return gu(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function uf(e,t){return lf(e,t)}function df(e){let{callback:t,disabled:n}=e,r=pu(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function ff(e){let{callback:t,disabled:n}=e,r=pu(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function pf(e){return new jd(ld(e),e)}function mf(e,t,n){t===void 0&&(t=pf);let[r,i]=(0,Z.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=df({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=ff({callback:a});return fu(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function hf(e){return rd(e,lf(e))}var gf=[];function _f(e){let t=(0,Z.useRef)(e),n=gu(n=>e?n&&n!==gf&&e&&t.current&&e.parentNode===t.current.parentNode?n:md(e):gf,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function vf(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=gd(e.target);t&&n(e=>e?(e.set(t,yd(t)),new Map(e)):null)},[]);return(0,Z.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=gd(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,yd(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=>{gd(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Su(e,t),Gu):Ed(e):Gu,[e,t])}function yf(e,t){t===void 0&&(t=[]);let n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{n.current=null},t),(0,Z.useEffect)(()=>{let t=e!==Gu;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Cu(e,n.current):Gu}function bf(e){(0,Z.useEffect)(()=>{if(!iu)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 xf(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Sf(e){return(0,Z.useMemo)(()=>e?dd(e):null,[e])}var Cf=[];function wf(e,t){t===void 0&&(t=ld);let[n]=e,r=Sf(n?su(n):null),[i,a]=(0,Z.useState)(Cf);function o(){a(()=>e.length?e.map(e=>xd(e)?r:new jd(t(e),e)):Cf)}let s=ff({callback:o});return fu(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Tf(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return lu(t)?t:e}function Ef(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=ff({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(lu(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=_u((0,Z.useCallback)(e=>{let n=Tf(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,Z.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Df=[{sensor:Gd,options:{}},{sensor:Bd,options:{}}],Of={current:{}},kf={draggable:{measure:ud},droppable:{measure:ud,strategy:af.WhileDragging,frequency:of.Optimized},dragOverlay:{measure:ld}},Af=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}},jf={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Af,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Hu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:kf,measureDroppableContainers:Hu,windowRect:null,measuringScheduled:!1},Mf={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Hu,draggableNodes:new Map,over:null,measureDroppableContainers:Hu},Nf=(0,Z.createContext)(Mf),Pf=(0,Z.createContext)(jf);function Ff(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Af}}}function If(e,t){switch(t.type){case Vu.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Vu.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 Vu.DragEnd:case Vu.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Vu.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Af(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Vu.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 Af(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Vu.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Af(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Lf(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(Nf),a=vu(r),o=vu(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Tu(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=Au(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Rf(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function zf(e){return(0,Z.useMemo)(()=>({draggable:{...kf.draggable,...e?.draggable},droppable:{...kf.droppable,...e?.droppable},dragOverlay:{...kf.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Bf(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,Z.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;fu(()=>{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=rd(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=hd(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Vf=(0,Z.createContext)({...Gu,scaleX:1,scaleY:1}),Hf;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Hf||={});var Uf=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Df,collisionDetection:o=$u,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(If,void 0,Ff),[f,p]=Lu(),[m,h]=(0,Z.useState)(Hf.Uninitialized),g=m===Hf.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,Z.useRef)({initial:null,translated:null}),C=(0,Z.useMemo)(()=>_==null?null:{id:_,data:x?.data??Of,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=hu(l,Object.values(l)),A=bu(`DndDescribedBy`,t),j=(0,Z.useMemo)(()=>b.getEnabled(),[b]),M=zf(s),{droppableRects:ee,measureDroppableContainers:te,measuringScheduled:ne}=cf(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),N=nf(v,_),P=(0,Z.useMemo)(()=>D?Du(D):null,[D]),re=De(),ie=uf(N,M.draggable.measure);Bf({activeNode:_==null?null:v.get(_),config:re.layoutShiftCompensation,initialRect:ie,measure:M.draggable.measure});let F=mf(N,M.draggable.measure,ie),I=mf(N?N.parentElement:null),L=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:N,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ae=b.getNodeFor(L.current.over?.id),oe=Ef({measure:M.dragOverlay.measure}),se=oe.nodeRef.current??N,R=g?oe.rect??F:null,ce=!!(oe.nodeRef.current&&oe.rect),le=hf(ce?null:F),ue=Sf(se?su(se):null),de=_f(g?ae??N:null),fe=wf(de),z=Rf(c,{transform:{x:y.x-le.x,y:y.y-le.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:F,containerNodeRect:I,draggingNodeRect:R,over:L.current.over,overlayNodeRect:oe.rect,scrollableAncestors:de,scrollableAncestorRects:fe,windowRect:ue}),pe=P?Su(P,y):null,B=vf(de),me=yf(B),he=yf(B,[F]),ge=Su(z,me),V=R?ad(R,z):null,_e=C&&V?o({active:C,collisionRect:V,droppableRects:ee,droppableContainers:j,pointerCoordinates:pe}):null,ve=Zu(_e,`id`),[ye,be]=(0,Z.useState)(null),xe=nd(ce?z:Su(z,he),ye?.rect??null,F),Se=(0,Z.useRef)(null),Ce=(0,Z.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:L,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.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}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,go.unstable_batchedUpdates)(()=>{r?.(i),h(Hf.Initializing),d({type:Vu.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Se.current),O(a)})},onMove(e){d({type:Vu.DragMove,coordinates:e})},onEnd:s(Vu.DragEnd),onCancel:s(Vu.DragCancel)});Se.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=L.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Vu.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Vu.DragCancel)}w.current=null,(0,go.unstable_batchedUpdates)(()=>{d({type:e}),h(Hf.Uninitialized),be(null),E(null),O(null),Se.current=null;let t=e===Vu.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),we=rf(a,(0,Z.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,Ce(n,t))},[v,Ce]));bf(a),fu(()=>{F&&m===Hf.Initializing&&h(Hf.Initialized)},[F,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=L.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,go.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=L.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ve),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,go.unstable_batchedUpdates)(()=>{be(s),a?.(c),f({type:`onDragOver`,event:c})})},[ve]),fu(()=>{L.current={activatorEvent:D,active:C,activeNode:N,collisionRect:V,collisions:_e,droppableRects:ee,draggableNodes:v,draggingNode:se,draggingNodeRect:R,droppableContainers:b,over:ye,scrollableAncestors:de,scrollAdjustedTranslate:ge},S.current={initial:R,translated:V}},[C,N,_e,V,v,se,R,ee,b,ye,de,ge]),$d({...re,delta:y,draggingRect:V,pointerCoordinates:pe,scrollableAncestors:de,scrollableAncestorRects:fe});let Te=(0,Z.useMemo)(()=>({active:C,activeNode:N,activeNodeRect:F,activatorEvent:D,collisions:_e,containerNodeRect:I,dragOverlay:oe,draggableNodes:v,droppableContainers:b,droppableRects:ee,over:ye,measureDroppableContainers:te,scrollableAncestors:de,scrollableAncestorRects:fe,measuringConfiguration:M,measuringScheduled:ne,windowRect:ue}),[C,N,F,D,_e,I,oe,v,b,ee,ye,te,de,fe,M,ne,ue]),Ee=(0,Z.useMemo)(()=>({activatorEvent:D,activators:we,active:C,activeNodeRect:F,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:ye,measureDroppableContainers:te}),[D,we,C,F,d,A,v,ye,te]);return Z.createElement(Fu.Provider,{value:p},Z.createElement(Nf.Provider,{value:Ee},Z.createElement(Pf.Provider,{value:Te},Z.createElement(Vf.Provider,{value:xe},i)),Z.createElement(Lf,{disabled:n?.restoreFocus===!1})),Z.createElement(Bu,{...n,hiddenTextDescribedById:A}));function De(){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}}}),Wf=(0,Z.createContext)(null),Gf=`button`,Kf=`Draggable`;function qf(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=bu(Kf),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(Nf),{role:p=Gf,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?Vf:Wf),[v,y]=_u(),[b,x]=_u(),S=xf(o,t),C=hu(n);return fu(()=>(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,Z.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Gf?!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 Jf(){return(0,Z.useContext)(Pf)}var Yf=`Droppable`,Xf={timeout:25};function Zf(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=bu(Yf),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(Nf),u=(0,Z.useRef)({disabled:n}),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Xf,...i},_=hu(h??r),v=ff({callback:(0,Z.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]=_u((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=hu(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:Vu.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Vu.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:Vu.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 Qf(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=vu(n);return!n&&!r&&s&&i(s),fu(()=>{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]),Z.createElement(Z.Fragment,null,n,r?(0,Z.cloneElement)(r,{ref:o}):null)}var $f={x:0,y:0,scaleX:1,scaleY:1};function ep(e){let{children:t}=e;return Z.createElement(Nf.Provider,{value:Mf},Z.createElement(Vf.Provider,{value:$f},t))}var tp={position:`fixed`,touchAction:`none`},np=e=>Tu(e)?`transform 250ms ease`:void 0,rp=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=np}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...tp,width:s.width,height:s.height,top:s.top,left:s.left,transform:Ou.Transform.toString(d),transformOrigin:i&&r?qu(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),ip={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Ou.Transform.toString(t)},{transform:Ou.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 ap(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return pu((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Tf(a);if(!c)return;let{transform:l}=su(a).getComputedStyle(a),u=od(l);if(!u)return;let d=typeof t==`function`?t:op(t);return kd(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 op(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...ip,...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 sp=0;function cp(e){return(0,Z.useMemo)(()=>{if(e!=null)return sp++,sp},[e])}var lp=Z.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}=Jf(),S=(0,Z.useContext)(Vf),C=cp(d?.id),w=Rf(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=lf(f),E=ap({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(ep,null,Z.createElement(Qf,{animation:E},d&&C?Z.createElement(rp,{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 up({status:e,kind:t=`agent`,agentType:n,stale:r=!1,className:i,iconClassName:o=`size-3`,iconStrokeScale:s=1}){let c=`${t===`terminal`?`terminal`:n??`agent`} — status: ${e.replace(`_`,` `)}${r?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,X.jsx)(`span`,{className:a(`status-glyph`,i),"data-status":e,"data-kind":t,"data-stale":r||void 0,role:`img`,title:r?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":c,children:t===`terminal`?(0,X.jsx)(Jt,{className:o,strokeWidth:2*s}):(0,X.jsx)(dn,{type:n??``,className:o,strokeScale:s})})}var dp=[`starting`,`running`,`waiting_input`],fp=[`exited`,`interrupted`],pp={Item:Vl,Separator:Wl,Sub:zl,SubTrigger:Hl,SubContent:Ul},mp={Item:U,Separator:ht,Sub:ct,SubTrigger:Ct,SubContent:xt};function hp(e,t){let n=T(`resume`),r=T(`kill`),i=p(),a=I(),o=P(),s=v(),c=d(),l=E(),m=f(),h=hn(),g=re(),y=_(g??void 0),x=b(g??void 0),[S,C]=(0,Z.useState)(null),[w,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(e.title??``),[A,j]=(0,Z.useState)(null),[M,ee]=(0,Z.useState)(null),te=(y.data??[]).filter(t=>t.agent_type===e.agent_type),ne=!e.worktree_missing&&e.status!==`archived`&&te.some(t=>t.id!==e.account_id),N=(y.data??[]).filter(t=>t.agent_type!==e.agent_type&&t.logged_in),ie=x.data?.default_account_id,F=typeof ie==`number`?ie:null,L=(y.data??[]).filter(e=>e.logged_in),ae=F===null?L:[...L.filter(e=>e.id===F),...L.filter(e=>e.id!==F)];return{menu:{session:e,resumable:fp.includes(e.status)&&!e.conversation_missing,live:dp.includes(e.status),archived:e.status===`archived`,canMigrate:ne,sameAgent:te,handoffTargets:!e.worktree_missing&&e.status!==`archived`?N:[],setHandoffTo:ee,resume:()=>n.mutate(e.id,{onError:e=>{let t=We(e);t?h(`/project/${t.projectId}/session/${t.sessionId}`):He(e)}}),kill:()=>r.mutate(e.id,{onError:e=>He(e)}),openClearEnv:()=>C(`clear-env`),openTerminal:()=>m.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void h(`/project/${e.project_id}/session/${e.id}`),onError:e=>He(e)}),spawnAccounts:ae,defaultAccountId:F,spawnAgent:t=>m.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void h(`/project/${e.project_id}/session/${e.id}`),onError:e=>He(e)}),openRename:()=>{k(e.title??``),D(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>He(e)}),unarchive:()=>a.mutate(e.id,{onError:e=>He(e)}),setMigrateTo:j},dialogs:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Be,{open:S===`clear-env`,onOpenChange:e=>{e||C(null)},children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Clear captured environment?`}),(0,X.jsx)(ze,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>C(null),children:`Cancel`}),(0,X.jsx)(H,{variant:`danger`,disabled:l.isPending,onClick:()=>l.mutate(e.id,{onSuccess:e=>{C(null),u.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{C(null),He(e)}}),children:`Clear captured env`})]})]})}),(0,X.jsx)(Be,{open:w,onOpenChange:D,children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Rename session`}),(0,X.jsx)(ze,{children:`Leave it empty to use the agent’s own session name.`})]}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:t=>{t.preventDefault(),o.mutate({sessionId:e.id,title:O.trim()},{onSuccess:()=>D(!1),onError:e=>He(e)})},children:[(0,X.jsx)(Ge,{value:O,onChange:e=>k(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{type:`button`,variant:`ghost`,onClick:()=>D(!1),children:`Cancel`}),(0,X.jsx)(H,{type:`submit`,disabled:o.isPending,children:`Rename`})]})]})]})}),(0,X.jsx)(Be,{open:A!==null,onOpenChange:e=>!e&&j(null),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsxs)(Re,{children:[`Move this session to `,A?.label,`?`]}),(0,X.jsx)(ze,{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,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>j(null),children:`Cancel`}),(0,X.jsx)(H,{disabled:s.isPending,onClick:()=>{A&&s.mutate({sessionId:e.id,accountId:A.id},{onSuccess:()=>{j(null),u.success(`Moved to ${A.label}`)},onError:e=>{j(null),He(e)}})},children:`Move session`})]})]})}),(0,X.jsx)(Be,{open:M!==null,onOpenChange:e=>!e&&ee(null),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsxs)(Re,{children:[`Hand off to `,M?.agent_type,`?`]}),(0,X.jsxs)(ze,{children:[`A new session starts in this worktree and branch on`,` `,(0,X.jsx)(`span`,{className:`text-fg`,children:M?.label}),`, opening with a summary of the conversation so far plus the branch’s commits and status. The conversation itself is summarised, not moved — the new agent will not have the old one’s reasoning. This session is left as it is.`]})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>ee(null),children:`Cancel`}),(0,X.jsx)(H,{disabled:c.isPending,onClick:()=>{M&&c.mutate({sessionId:e.id,accountId:M.id},{onSuccess:e=>{ee(null),u.success(`Handed off to ${M.agent_type}`),h(`/session/${e.id}`)},onError:e=>{ee(null),He(e)}})},children:`Hand off`})]})]})})]})}}function gp({kit:e,menu:t}){let{Item:n,Separator:r,Sub:i,SubTrigger:a,SubContent:o}=e,{session:s}=t;return(0,X.jsxs)(X.Fragment,{children:[t.resumable&&!s.worktree_missing&&(0,X.jsxs)(n,{onSelect:t.resume,children:[(0,X.jsx)(Lr,{}),` Resume`]}),t.live&&(0,X.jsxs)(n,{onSelect:t.kill,children:[(0,X.jsx)(Br,{}),` Kill`]}),(0,X.jsxs)(n,{onSelect:t.openRename,children:[(0,X.jsx)(Je,{}),` Rename`]}),!t.archived&&(0,X.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,X.jsx)(or,{}),` Clear captured env`]}),t.canMigrate&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Wr,{}),` Move to account…`]}),(0,X.jsx)(o,{children:t.sameAgent.map(e=>{let r=e.id===s.account_id;return(0,X.jsxs)(n,{disabled:r,onSelect:()=>t.setMigrateTo(e),children:[e.label,r&&(0,X.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:`current`})]},e.id)})})]}),t.handoffTargets.length>0&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(rr,{}),` Hand off to agent…`]}),(0,X.jsx)(o,{children:t.handoffTargets.map(e=>(0,X.jsxs)(n,{onSelect:()=>t.setHandoffTo(e),children:[(0,X.jsx)(dn,{type:e.agent_type,className:`size-4`}),e.agent_type,(0,X.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:e.label})]},e.id))})]}),!s.worktree_missing&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.openTerminal,children:[(0,X.jsx)(Jt,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Qt,{}),` Spawn agent in worktree`]}),(0,X.jsx)(o,{children:t.spawnAccounts.map(e=>(0,X.jsxs)(n,{onSelect:()=>t.spawnAgent(e.id),children:[(0,X.jsx)(dn,{type:e.agent_type,className:`size-4 shrink-0`}),e.agent_type,`/`,e.label,e.id===t.defaultAccountId&&(0,X.jsx)(`span`,{className:`ml-auto pl-3 text-fg-muted`,children:`default`})]},e.id))})]}),(0,X.jsxs)(n,{onSelect:()=>{window.location.href=Wn(`vscode`,s.worktree_path,Ln())},children:[(0,X.jsx)(sr,{}),` Open in VS Code`]}),(0,X.jsxs)(n,{onSelect:()=>{window.location.href=Wn(`cursor`,s.worktree_path,Ln())},children:[(0,X.jsx)(sr,{}),` Open in Cursor`]})]}),!t.archived&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.archive,children:[(0,X.jsx)(gt,{}),` Archive`]})]}),t.archived&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.unarchive,children:[(0,X.jsx)(rt,{}),` Unarchive`]})]})]})}function _p({menu:e}){return(0,X.jsxs)(Ll,{children:[(0,X.jsx)(Rl,{asChild:!0,children:(0,X.jsxs)(H,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:e=>e.preventDefault(),children:[(0,X.jsx)(ar,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,X.jsx)(Bl,{align:`end`,children:(0,X.jsx)(gp,{kit:pp,menu:e})})]})}function vp({session:e,onArchived:t,children:n}){let{menu:r,dialogs:i}=hp(e,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(wt,{children:[(0,X.jsx)(ut,{asChild:!0,children:typeof n==`function`?n(r):n}),(0,X.jsx)(bt,{children:(0,X.jsx)(gp,{kit:mp,menu:r})})]}),i]})}function yp({menu:e}){return(0,X.jsx)(bt,{children:(0,X.jsx)(gp,{kit:mp,menu:e})})}function bp(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=xp(t.x/e.width),i=xp(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 xp(e){return e<0?0:e>1?1:e}var Sp=(0,Z.createContext)(null);function Cp(){return(0,Z.useContext)(Sp)}var wp=(0,Z.createContext)(null);function Tp(){return(0,Z.useContext)(wp)}var Ep=`leaf:`,Dp=`tabdrop:`,Op=`strip:`,kp=`archive:`,Ap=e=>{let t=td(e);for(let e of[Dp,Op]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:$u(e)};function jp({onDrop:e,onArchive:t,renderOverlay:n,children:r}){let i=Wu(Uu(Gd,{activationConstraint:{distance:4}})),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(null),u=()=>{o(null),c(null),l.current=null};return(0,X.jsxs)(Uf,{sensors:i,collisionDetection:Ap,onDragStart:e=>c(e.active.data.current?.ref??null),onDragMove:e=>{let t=e.over,n=Mp(e),r=t&&n?Pp(String(t.id),t.rect,t.data.current,n):null;Np(l.current,r)||(l.current=r,o(r))},onDragEnd:n=>{let r=l.current,i=n.active.data.current?.ref,a=n.active.data.current?.fromLeafId,o=n.over===null?null:String(n.over.id);if(u(),o!==null&&o.startsWith(`archive:`)){i?.type===`terminal`&&t?.(i.session);return}r&&i&&a&&e({ref:i,fromLeafId:a,toLeafId:r.leafId,edge:r.zone,index:r.index})},onDragCancel:u,children:[(0,X.jsx)(Sp.Provider,{value:a,children:(0,X.jsx)(wp.Provider,{value:s,children:r})}),(0,X.jsx)(lp,{dropAnimation:null,children:s?n(s):null})]})}function Mp(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 Np(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function Pp(e,t,n,r){if(e.startsWith(Dp)){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(Op)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(Ep)){let n=bp({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 Fp=`application/x-puddle-project`,Ip=`group-hover:[transform:translateX(var(--tail))]`;function Lp({projectId:e,actions:t,editLabel:n}){return(0,X.jsxs)(bt,{children:[(0,X.jsxs)(U,{onSelect:()=>t.onNewSessionIn(e),children:[(0,X.jsx)(Qt,{}),`New agent`]}),(0,X.jsxs)(U,{onSelect:()=>t.onNewTerminalIn(e),children:[(0,X.jsx)(Jt,{}),`New terminal`]}),(0,X.jsx)(ht,{}),(0,X.jsxs)(U,{onSelect:n.onSelect,children:[(0,X.jsx)(Je,{}),n.label]})]})}function Rp(e,t){let{isOver:n,setNodeRef:r}=Zf({id:`${kp}${e}`}),i=Tp(),[a,o]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let e=()=>o(!1);return window.addEventListener(`dragend`,e),()=>window.removeEventListener(`dragend`,e)},[]),{setNodeRef:r,armed:a||n&&i?.type===`terminal`,props:{onDragOver:e=>{fc(e.dataTransfer.types)&&(e.preventDefault(),o(!0))},onDragLeave:()=>o(!1),onDrop:e=>{o(!1);let n=dc(e.dataTransfer.getData(lc));n?.type===`terminal`&&(e.preventDefault(),t(n.session))}}}}function zp({onArchiveDrop:e,onExpand:t}){let n=Rp(`rail`,e);return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{ref:n.setNodeRef,type:`button`,onClick:t,...n.props,className:a(`mt-1 flex shrink-0 items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg compact:p-1`,n.armed&&`bg-selection text-fg`),children:[(0,X.jsx)(gt,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Archived sessions`})]})}),(0,X.jsx)(J,{side:`left`,children:`Drop a session here to archive it`})]})}function Bp({collapsed:e,children:t}){return(0,X.jsx)(`div`,{className:a(`grid transition-[grid-template-rows] duration-200`,e?`grid-rows-[0fr]`:`grid-rows-[1fr]`),children:t})}function Vp({icon:e,label:t,onClick:n,active:r=!1,tooltipSide:i=`bottom`}){return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:a(`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,X.jsx)(e,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(J,{side:i,children:t})]})}function Hp({session:e,accountLabel:t}){return(0,X.jsxs)(`span`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:Rn()(e)}),(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.branch}),(0,X.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 text-2xs text-fg-muted`,children:e.kind===`terminal`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Jt,{className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:`terminal`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(dn,{type:e.agent_type??``,className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:e.agent_type}),t&&(0,X.jsxs)(`span`,{children:[` · `,t]})]})})]})}function Up({session:e,accountLabel:t,activeSessionId:n,onPromote:r,onArchived:i}){let{menu:o,dialogs:s}=hp(e,i),c=Rn();return(0,X.jsxs)(wt,{children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(ut,{asChild:!0,children:(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(pn,{draggable:!1,"aria-current":e.id===n?`true`:void 0,onDoubleClick:()=>r(e.id),to:`/project/${e.project_id}/session/${e.id}`,className:a(`flex items-center rounded-md p-1 transition-colors hover:bg-elevated`,e.id===n&&`bg-elevated`),children:[(0,X.jsx)(up,{status:e.status,kind:e.kind,agentType:e.agent_type,stale:e.stale_running,className:`size-4 compact:size-3`,iconClassName:`size-full`,iconStrokeScale:.75}),(0,X.jsx)(`span`,{className:`sr-only`,children:c(e)})]})})}),(0,X.jsx)(J,{side:`left`,children:(0,X.jsx)(Hp,{session:e,accountLabel:t})})]}),(0,X.jsx)(yp,{menu:o}),s]})}function Wp({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,onExpand:o,onNewTerminal:s,onNewSession:c,onArchived:l,onArchiveDrop:u,projectActions:d}){let[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),v=k(),y=new Map(t.map(e=>[e.id,e.label])),b=(t,n)=>{let i=it(e,t,n);i&&r(i)},x=(e,t)=>{_(null);let n=Un(t);!n||n===e.abbrev||v.mutate({id:e.projectId,abbrev:n},{onError:e=>He(e)})};return(0,X.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center bg-surface py-1.5 compact:py-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1 compact:gap-0.5`,children:[(0,X.jsx)(Vp,{icon:Fr,label:`Show sessions`,onClick:o,tooltipSide:`left`}),(0,X.jsx)(Vp,{icon:Qt,label:`New agent`,onClick:c,tooltipSide:`left`}),(0,X.jsx)(Vp,{icon:Jt,label:`New terminal`,onClick:s,tooltipSide:`left`})]}),(0,X.jsx)(`div`,{className:`no-scrollbar flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto compact:gap-0.5`,children:e.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1 compact:gap-0.5`,onDragOver:t=>{m&&(t.preventDefault(),m!==e.projectId&&d.onMoveProject(m,e.projectId))},children:[(0,X.jsx)(`div`,{className:`my-0.5 h-px w-7 shrink-0 bg-border`}),g===e.projectId?(0,X.jsx)(Zn,{initial:e.abbrev,maxLength:5,className:`w-7 text-center text-[8px] uppercase leading-3 text-fg`,onCommit:t=>x(e,t),onCancel:()=>_(null)}):(0,X.jsxs)(wt,{children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(ut,{asChild:!0,children:(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(pn,{to:`/project/${e.projectId}`,...vt(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Fp,e.projectId),h(e.projectId)},onDragEnd:()=>h(null),className:a(`w-7 truncate text-center text-[8px] uppercase leading-3 text-fg-muted transition-colors hover:text-fg`,m===e.projectId&&`opacity-50`),children:e.abbrev})})}),(0,X.jsx)(J,{side:`left`,children:e.name})]}),(0,X.jsx)(Lp,{projectId:e.projectId,actions:d,editLabel:{label:`Change project abbreviation`,onSelect:()=>_(e.projectId)}})]}),(0,X.jsx)(Bp,{collapsed:m!==null,children:(0,X.jsx)(`div`,{className:`flex flex-col items-center gap-1 overflow-hidden compact:gap-0.5`,children:e.sessions.map(e=>(0,X.jsx)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(lc,uc({type:`terminal`,session:e.id})),p(e.id)},onDragEnd:()=>p(null),onDragOver:t=>{t.preventDefault(),f&&f!==e.id&&b(f,e.id)},className:a(`transition-opacity`,f===e.id&&`opacity-50`),children:(0,X.jsx)(Up,{session:e,accountLabel:e.account_id===null?void 0:y.get(e.account_id),activeSessionId:n,onPromote:i,onArchived:l})},e.id))})})]},e.projectId))}),(0,X.jsx)(zp,{onArchiveDrop:u,onExpand:o})]})}function Gp({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,ellipsis:o,lastActive:s=!1}){let c=Rn(),l=e.kind===`terminal`?`terminal`:e.agent_type??`agent`,u=s?e.last_activity_at===null?``:` · ${he(e.last_activity_at)}`:e.account_id!==null&&n.has(e.account_id)?` · ${n.get(e.account_id)}`:``;return(0,X.jsx)(vp,{session:e,onArchived:i,children:n=>(0,X.jsxs)(pn,{draggable:!1,onDoubleClick:r&&(()=>r(e.id)),to:`/project/${e.project_id}/session/${e.id}`,className:a(`group flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-elevated compact:gap-1.5 compact:py-1`,e.id===t&&`bg-elevated`),children:[(0,X.jsx)(up,{status:e.status,kind:e.kind,agentType:e.agent_type,stale:e.stale_running}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(zo,{text:c(e),className:`font-sans text-xs text-fg`,hoverClass:Ip}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:[(0,X.jsx)(Tr,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(zo,{text:e.branch,hoverClass:Ip})]}),(0,X.jsx)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:(0,X.jsx)(zo,{text:`${l}${u}`,hoverClass:Ip})})]}),e.skip_permissions&&(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(zr,{className:`size-3.5 shrink-0 text-warning`})}),(0,X.jsx)(J,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(wr,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(J,{children:`Worktree directory is gone — archive only`})]}),e.conversation_missing&&(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(Ar,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(J,{children:`Native conversation is missing — resume unavailable`})]}),e.native_sync===`fallback`&&e.status!==`archived`&&(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(Vr,{className:`size-3.5 shrink-0 text-fg-muted`})}),(0,X.jsx)(J,{children:`In-agent conversation switches are not synchronised`})]}),o&&(0,X.jsx)(`span`,{className:`hidden group-hover:inline-flex has-[[data-state=open]]:inline-flex pointer-coarse:inline-flex`,children:(0,X.jsx)(_p,{menu:n})})]})})}function Kp({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onNewSession:o,onNewTerminal:s,onCollapse:c,onArchived:l,onArchiveDrop:u,projectActions:d}){return(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 py-1.5`,children:[(0,X.jsx)(Vp,{icon:Pr,label:`Hide sessions`,onClick:c}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(Vp,{icon:Qt,label:`New agent`,onClick:o}),(0,X.jsx)(Vp,{icon:Jt,label:`New terminal`,onClick:s})]})]}),(0,X.jsx)(qp,{groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:l,onArchiveDrop:u,projectActions:d})]})}function qp({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:o,onArchived:s,onArchiveDrop:c,projectActions:l}){let[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),v=Rp(`list`,c),y=Tp(),b=u!==null||y?.type===`terminal`,x=k(),S=A(`palette.toggle`),C=new Map(t.map(e=>[e.id,e.label])),w=e.reduce((e,t)=>e+t.sessions.length,0),{height:T,handle:E}=Po(`sessions-archived`,200,{sized:`below`,min:96}),D=(0,Z.useMemo)(()=>{let t=new Set,n=e.map(e=>{let n=o.filter(t=>t.project_id===e.projectId);for(let e of n)t.add(e.id);return{...e,sessions:n}}),r=o.filter(e=>!t.has(e.id));return[...n.filter(e=>e.sessions.length>0),...r.length>0?[{projectId:``,name:``,abbrev:``,repoId:-1,sessions:r}]:[]]},[e,o]),O=(t,n)=>{let i=it(e,t,n);i&&r(i)},j=(e,t)=>{h(null);let n=t.trim();!n||n===e.name||x.mutate({id:e.projectId,name:n},{onError:e=>He(e)})};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto py-1.5`,children:[w===0&&o.length===0&&(0,X.jsxs)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`No sessions yet — press `,S,` to start one.`]}),e.map(e=>(0,X.jsxs)(`div`,{onDragOver:t=>{f&&(t.preventDefault(),f!==e.projectId&&l.onMoveProject(f,e.projectId))},children:[m===e.projectId?(0,X.jsx)(Zn,{initial:e.name,maxLength:100,className:`block w-full px-3 pb-1 pt-2 text-2xs font-medium tracking-wide text-fg`,onCommit:t=>j(e,t),onCancel:()=>h(null)}):(0,X.jsxs)(wt,{children:[(0,X.jsx)(ut,{asChild:!0,children:(0,X.jsx)(pn,{to:`/project/${e.projectId}`,...vt(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Fp,e.projectId),p(e.projectId)},onDragEnd:()=>p(null),className:a(`block truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold transition-colors hover:text-fg compact:pb-0.5 compact:pt-1.5`,f===e.projectId&&`opacity-50`),children:e.name})}),(0,X.jsx)(Lp,{projectId:e.projectId,actions:l,editLabel:{label:`Change project name`,onSelect:()=>h(e.projectId)}})]}),(0,X.jsx)(Bp,{collapsed:f!==null,children:(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 overflow-hidden compact:gap-0`,children:e.sessions.map(e=>(0,X.jsx)(`li`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(lc,uc({type:`terminal`,session:e.id})),d(e.id)},onDragEnd:()=>d(null),onDragOver:t=>{t.preventDefault(),u&&u!==e.id&&O(u,e.id)},className:a(`transition-opacity`,u===e.id&&`opacity-50`),children:(0,X.jsx)(Gp,{session:e,activeSessionId:n,accountLabel:C,onPromote:i,onArchived:s,ellipsis:!0})},e.id))})})]},e.projectId))]}),(o.length>0||b)&&(0,X.jsxs)(X.Fragment,{children:[g&&(0,X.jsx)(Fo,{handle:E,label:`Resize the archived sessions`}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col pb-1.5`,style:g?{height:T,maxHeight:`70%`}:void 0,children:[(0,X.jsxs)(`button`,{ref:v.setNodeRef,type:`button`,onClick:()=>_(e=>!e),...v.props,className:a(`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`,v.armed&&`bg-selection text-fg`),children:[(0,X.jsx)(Ut,{className:a(`size-3 transition-transform`,g&&`rotate-90`)}),(0,X.jsx)(gt,{className:`size-3`}),(0,X.jsx)(`span`,{children:`Archived`}),(0,X.jsx)(`span`,{className:`ml-auto tabular-nums`,children:o.length})]}),g&&(0,X.jsx)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto`,children:D.map(e=>(0,X.jsxs)(`div`,{children:[e.name!==``&&(0,X.jsx)(`div`,{className:`truncate px-3 pb-0.5 pt-1.5 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:e.name}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 compact:gap-0`,children:e.sessions.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Gp,{session:e,activeSessionId:n,accountLabel:C,onArchived:s,ellipsis:!0,lastActive:!0})},e.id))})]},e.projectId))})]})]})]})}function Jp({className:e}){return(0,X.jsx)(`svg`,{viewBox:`0 0 2000 2000`,fill:`none`,"aria-hidden":`true`,className:e,children:(0,X.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:110,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`line`,{x1:`491.66`,y1:`1916.78`,x2:`1558.47`,y2:`83.22`}),(0,X.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,X.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,X.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 Yp=[`running`,`waiting_input`];function Xp({sessionId:e,status:t}){let n=Yp.includes(t),{data:r}=w(e,n),i=r?.vars??[];if(!n||i.length===0)return null;let a=async(e,t)=>{try{await navigator.clipboard.writeText(t),u.success(`${e} value copied`)}catch{u.error(`Couldn't copy ${e} value`)}};return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3 font-mono text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:`env`}),(0,X.jsx)(`div`,{className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`div`,{className:`flex w-max items-center gap-1 whitespace-nowrap`,children:i.map(e=>{let t=e.value;return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:t===void 0?(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-fg-secondary`,children:e.name}):(0,X.jsx)(`button`,{type:`button`,"aria-label":`Copy ${e.name} environment variable value`,onClick:()=>void a(e.name,t),className:`cursor-pointer rounded px-1.5 py-0.5 text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,children:e.name})}),(0,X.jsxs)(J,{children:[e.bytes,` B ·`,` `,t===void 0?`value unavailable from this daemon`:`click to copy value`]})]},e.name)})})})]})}function Zp(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var Qp=[`running`,`waiting_input`];function $p({sessionId:e,status:t}){let n=Qp.includes(t),{data:r}=y(e,n),i=r?.ports??[];return!n||i.length===0?null:(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3 text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:`ports`}),(0,X.jsx)(`div`,{className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`div`,{className:`flex w-max items-center gap-1 whitespace-nowrap`,children:i.map(t=>(0,X.jsx)(em,{sessionId:e,port:t},t.port))})})]})}function em({sessionId:e,port:t}){let n=M().data;return(0,X.jsxs)(Ll,{children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:(0,X.jsx)(Rl,{asChild:!0,children:(0,X.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,X.jsxs)(J,{children:[t.command,` · pid `,t.pid]})]}),(0,X.jsxs)(Bl,{align:`start`,children:[jt()===null?(0,X.jsx)(Vl,{asChild:!0,children:(0,X.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,X.jsx)(Vl,{onSelect:()=>{window.open(`/proxy/${e}/${t.port}/?puddle_token=${L.get()??``}`,`_blank`,`noopener,noreferrer`)},children:`Open via proxy`}),(0,X.jsx)(Vl,{onSelect:()=>{n&&navigator.clipboard.writeText(Zp(t.port,n.username,n.hostname)).then(()=>u.success(`Copied`))},children:`Copy ssh -L`})]})]})}var tm=[`interrupted`,`exited`];function nm({session:e}){let t=T(`resume`),n=hn();return tm.includes(e.status)&&!e.worktree_missing&&!e.conversation_missing?(0,X.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 right-3 z-10`,children:(0,X.jsxs)(H,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>{let t=We(e);t?n(`/project/${t.projectId}/session/${t.sessionId}`):He(e)}}),children:[(0,X.jsx)(Lr,{}),`Resume`]})}):null}function rm({tab:e,directory:t,onReveal:n,onRename:r,editing:i,children:a}){let o=M(),s=h().data?.protocol,c=Xs(),l=nc(e.session,e.root,t),d=(0,Z.useMemo)(()=>({sid:e.session,root:e.root,directory:t,host:Hs(o.data)}),[e.session,e.root,t,o.data]),f=e.root!==void 0&&!Kn(s),p=c!==null&&Ws(c.source,d),m=c!==null&&Us(c.source,d),g=!f&&(p&&m||c!==null&&Gs(c.source,d)&&Sn(s)),[_,v]=(0,Z.useState)(!1),y=Wa(t,e.path),b=()=>{!c||!g||l.paste(c,Ba(e.path)).then(e=>{c.mode===`cut`&&qs(c.id,e)})},x=t=>{navigator.clipboard.writeText(t?e.path:y),u.success(t?`Relative path copied`:`Path copied`)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(wt,{children:[(0,X.jsx)(ut,{asChild:!0,children:a}),(0,X.jsx)(bt,{onCloseAutoFocus:e=>{i&&e.preventDefault()},children:(0,X.jsx)(vc,{readOnly:f,canPaste:g,onCut:()=>Ks([e.path],`cut`,d),onCopy:()=>Ks([e.path],`copy`,d),onPaste:b,onCopyPath:()=>x(!1),onCopyRelativePath:()=>x(!0),onReveal:n,onRename:r,onDelete:()=>v(!0),onDownload:()=>{fe(e.session,e.path,e.root).catch(e=>u.error(e instanceof Error?e.message:`Download failed`))}})})]}),(0,X.jsx)(Be,{open:_,onOpenChange:v,children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsxs)(Re,{children:[`Delete “`,za(e.path),`”?`]}),(0,X.jsxs)(ze,{children:[`This permanently removes it from `,t,`. There is no undo.`]})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>v(!1),children:`Cancel`}),(0,X.jsx)(H,{variant:`danger`,onClick:()=>{v(!1),l.remove([e.path])},children:`Delete`})]})]})})]})}var im=`group relative flex min-w-16 max-w-52 cursor-pointer select-none items-center gap-1.5 rounded-t-md px-2.5 text-xs transition-colors`,am=`group-hover:[transform:translateX(var(--tail))]`;function om({leaf:e,sessions:t,onActivate:n,onClose:r,onPromote:i,onArchived:a,onSetView:o,onNewFile:s,onRevealFile:c,onRenameFile:l}){let u=new Map(t.map(e=>[e.id,e.branch])),d=new Map(t.map(e=>[e.id,e.worktree_path])),f=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),p=Cp(),m=p?.leafId===e.id&&p.index!==void 0?p.index:null,{setNodeRef:h}=Zf({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),g=e=>{let t=nr(e.path,e.session,f,u,e.root,d);return $n(e)===`diff`?`${t} (diff)`:$n(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,X.jsxs)(`div`,{ref:h,className:`flex h-9 shrink-0 items-stretch gap-0.5 overflow-x-auto bg-surface px-1 pt-1`,onDoubleClick:e=>{e.target===e.currentTarget&&s()},children:[e.tabs.map((s,u)=>(0,X.jsxs)(Z.Fragment,{children:[m===u&&(0,X.jsx)(sm,{}),(0,X.jsx)(pm,{tab:s,leafId:e.id,index:u,active:q(s)===e.activeKey,preview:q(s)===e.previewKey,session:s.type===`terminal`?t.find(e=>e.id===s.session):void 0,fileSession:s.type===`editor`&&s.tab.root===void 0?t.find(e=>e.id===s.tab.session):void 0,fileDirectory:s.type===`editor`&&($n(s.tab)===`file`||$n(s.tab)===`external`)?s.tab.root??t.find(e=>e.id===s.tab.session)?.worktree_path:void 0,label:s.type===`editor`?g(s.tab):``,onActivate:()=>n(s),onClose:()=>r(s),onPromote:()=>i(s),onArchived:a,onSetView:e=>o(s,e),onRevealFile:()=>s.type===`editor`&&c(s.tab),onRenameFile:e=>s.type===`editor`?l(s.tab,e):Promise.resolve(!1)})]},q(s))),m===e.tabs.length&&(0,X.jsx)(sm,{})]})}function sm(){return(0,X.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function cm({active:e,children:t}){return(0,X.jsx)(`span`,{className:a(`pointer-events-none absolute inset-y-0 right-0 flex items-center gap-1 rounded-tr-md pl-5 pr-2.5`,`[&>*]:pointer-events-auto`,e?`group-hover:bg-[linear-gradient(to_right,transparent,var(--color-ground)_1.25rem)]`:`group-hover:bg-[linear-gradient(to_right,transparent,var(--color-elevated)_1.25rem)]`),children:t})}var lm={source:`preview`,preview:`linked`,linked:`locked`,locked:`source`},um={source:Y,preview:cr,linked:Dr,locked:kr},dm={source:`Source — switch to preview`,preview:`Preview — switch to linked preview`,linked:`Linked preview — switch to locked preview`,locked:`Locked preview — switch to source`};function fm({view:e,onSetView:t}){let n=um[e];return(0,X.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(lm[e])},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":dm[e],title:dm[e],children:(0,X.jsx)(n,{className:`size-3`})})}function pm({tab:e,leafId:t,index:n,active:r,preview:i,session:s,fileSession:c,fileDirectory:l,label:u,onActivate:d,onClose:f,onPromote:p,onArchived:m,onSetView:h,onRevealFile:g,onRenameFile:_}){let[v,y]=(0,Z.useState)(!1),b=Rn(),x=q(e),{attributes:S,listeners:C,setNodeRef:w,isDragging:T}=qf({id:`drag:${t}:${x}`,data:{ref:e,fromLeafId:t}}),{setNodeRef:E}=Zf({id:`tabdrop:${t}:${x}`,data:{leafId:t,index:n}}),D=e=>{w(e),E(e)},O=a(im,r?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`,i&&`italic`,T&&`opacity-40`),k=(0,X.jsx)(`div`,{ref:D,...v?{}:S,...v?{}:C,onClick:d,onDoubleClick:p,className:a(O,v&&`cursor-text select-text`),children:e.type===`terminal`?(0,X.jsxs)(X.Fragment,{children:[s&&(0,X.jsx)(up,{status:s.status,kind:s.kind,agentType:s.agent_type,stale:s.stale_running}),(0,X.jsx)(`span`,{className:`truncate`,children:s?b(s):e.session.slice(0,8)}),(0,X.jsx)(cm,{active:r,children:(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),f()},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":`Close tab`,children:(0,X.jsx)(o,{className:`size-3`})})})]}):(0,X.jsxs)(X.Fragment,{children:[e.tab.view===`linked`&&(0,X.jsx)(Dr,{className:`size-3 shrink-0 text-fg-muted`}),e.tab.view===`locked`&&(0,X.jsx)(kr,{className:`size-3 shrink-0 text-fg-muted`}),v?(0,X.jsx)(mm,{initial:e.tab.path.split(`/`).pop()??e.tab.path,onCommit:_,onCancel:()=>y(!1),onCommitted:()=>y(!1)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zo,{text:u,hoverClass:am,containerClassName:`flex-[0_1_auto]`,className:($n(e.tab)===`file`||$n(e.tab)===`external`)&&Zt(e.tab.path)!==null?`-mr-16 pr-16`:`-mr-11 pr-11`}),(0,X.jsx)(po,{session:e.tab.session,path:e.tab.path,kind:$n(e.tab),root:e.tab.root}),(0,X.jsxs)(cm,{active:r,children:[($n(e.tab)===`file`||$n(e.tab)===`external`)&&Zt(e.tab.path)!==null&&(0,X.jsx)(fm,{view:e.tab.view??`source`,onSetView:h}),(0,X.jsx)(ho,{session:e.tab.session,path:e.tab.path,kind:$n(e.tab),root:e.tab.root,label:u,onClose:f})]})]})]})}),A=(0,X.jsx)(J,{side:`bottom`,children:(0,X.jsx)(Gl,{name:e.type===`terminal`?s?b(s):e.session:u,session:e.type===`terminal`?s:c})});return e.type===`terminal`&&s?(0,X.jsxs)(G,{children:[(0,X.jsx)(vp,{session:s,onArchived:()=>m(e.session),children:(0,X.jsx)(K,{asChild:!0,children:k})}),A]}):e.type===`editor`&&l!==void 0&&($n(e.tab)===`file`||$n(e.tab)===`external`)?(0,X.jsxs)(G,{open:!v&&void 0,children:[(0,X.jsx)(rm,{tab:e.tab,directory:l,onReveal:g,onRename:()=>y(!0),editing:v,children:(0,X.jsx)(K,{asChild:!0,children:k})}),A]}):(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{asChild:!0,children:k}),A]})}function mm({initial:e,onCommit:t,onCommitted:n,onCancel:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let t=i.current;if(!t)return;let n=()=>{t.focus();let n=e.lastIndexOf(`.`);t.setSelectionRange(0,n>0?n:e.length)};n();let r=requestAnimationFrame(()=>{document.activeElement!==t&&n()});return()=>cancelAnimationFrame(r)},[e]);let o=()=>{a.current||(a.current=!0,t(i.current?.value??``).then(e=>{if(e){n();return}a.current=!1,requestAnimationFrame(()=>i.current?.focus())}))};return(0,X.jsx)(`input`,{ref:i,defaultValue:e,spellCheck:!1,"aria-label":`Rename ${e}`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?o():e.key===`Escape`&&(a.current=!0,r())},onBlur:o,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`,style:{width:`${Math.max(8,Math.min(e.length,24))}ch`}})}function hm(e,t,n){return{focus:e===`press`,driveScroll:t&&n!==`linked`}}function gm({leaf:e,sessions:t,reveal:n,onActivateTab:r,onCloseTab:i,onPromoteTab:o,onArchived:s,onFocusLeaf:c,onScrollDrive:l,onDropTab:u,onSetTabView:d,onNewUntitled:f,onRevealFile:p,onRenameFile:m,focused:h,scrollDriver:g,scrollChannel:_}){let v=e.tabs.find(t=>q(t)===e.activeKey)??null,y=v?.type===`terminal`?q(v):null,b=v?.type===`terminal`?t.find(e=>e.id===v.session)??null:null,x=yo(y),{setNodeRef:S}=Zf({id:`leaf:${e.id}`}),C=Cp(),w=A(`palette.toggle`),T=v?.type===`editor`?v.tab:null,E=T?.view??`source`,D=T!==null&&($n(T)===`file`||$n(T)===`external`)&&Zt(T.path)!==null,O=g&&D&&E!==`linked`,k=!O&&(E===`locked`||D&&E===`source`),j=t=>{let n=hm(t,D,E);n.focus&&c(e.id),n.driveScroll&&l(e.id)},M=(0,Z.useRef)(null),ee=(0,Z.useRef)(()=>void 0);ee.current=()=>{v&&r(e.id,v)},(0,Z.useEffect)(()=>{let e=M.current;if(!e)return;let t=()=>ee.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[te,ne]=(0,Z.useState)(null),N=(0,Z.useRef)(u);return N.current=u,(0,Z.useEffect)(()=>{let t=M.current;if(!t)return;let n=e=>e.dataTransfer!==null&&fc(e.dataTransfer.types),r=e=>{let n=t.getBoundingClientRect();return bp({width:n.width,height:n.height},{x:e.clientX-n.left,y:e.clientY-n.top})},i=e=>{n(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),ne(r(e)))},a=e=>{t.contains(e.relatedTarget)||ne(null)},o=t=>{if(!n(t))return;t.preventDefault(),t.stopPropagation(),ne(null);let i=dc(t.dataTransfer?.getData(`application/x-puddle-tab`)??``);i&&N.current(e.id,i,r(t))},s=()=>ne(null);return t.addEventListener(`dragenter`,i,!0),t.addEventListener(`dragover`,i,!0),t.addEventListener(`dragleave`,a,!0),t.addEventListener(`drop`,o,!0),window.addEventListener(`dragend`,s),()=>{t.removeEventListener(`dragenter`,i,!0),t.removeEventListener(`dragover`,i,!0),t.removeEventListener(`dragleave`,a,!0),t.removeEventListener(`drop`,o,!0),window.removeEventListener(`dragend`,s)}},[e.id]),(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,onMouseDownCapture:()=>j(`press`),onWheelCapture:()=>j(`scroll`),children:[e.tabs.length>0&&(0,X.jsx)(om,{leaf:e,sessions:t,onActivate:t=>r(e.id,t),onClose:t=>i(e.id,t),onPromote:o,onArchived:s,onSetView:(t,n)=>d(e.id,t,n),onNewFile:()=>f(e),onRevealFile:p,onRenameFile:m}),(0,X.jsxs)(`div`,{ref:e=>{M.current=e,S(e)},className:`relative min-h-0 flex-1`,children:[v?.type===`editor`&&(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(co,{tab:v.tab,reveal:n,focused:h,scrollDriver:O,scrollReceiver:k,scrollChannel:_})}),(0,X.jsx)(`div`,{ref:x,className:a(`absolute inset-0 py-1 pl-4 pr-2`,!y&&`hidden`)}),C?.leafId===e.id&&C.index===void 0&&(0,X.jsx)(vm,{zone:C.zone}),te!==null&&(0,X.jsx)(vm,{zone:te}),b&&(0,X.jsx)(nm,{session:b}),!v&&(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,X.jsx)(Jp,{className:`size-24 text-fg-muted/40`}),(0,X.jsx)(`button`,{type:`button`,onClick:vn,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:w})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1 empty:hidden`,children:[b&&(0,X.jsx)(Xp,{sessionId:b.id,status:b.status}),b&&(0,X.jsx)($p,{sessionId:b.id,status:b.status})]})]})}var _m={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 vm({zone:e}){return(0,X.jsx)(`div`,{className:a(`pointer-events-none absolute z-20 bg-accent/20`,_m[e])})}var ym=`bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`;function bm({tree:e,...t}){let n=(0,Z.useMemo)(()=>{let t=new Set,n=[];for(let r of ln(e)){if(r.type!==`editor`||![`file`,`diff`,`external`].includes($n(r.tab)))continue;let e=`${r.tab.session}\0${r.tab.path}\0${r.tab.root??``}`;t.has(e)||(t.add(e),n.push({session:r.tab.session,path:r.tab.path,root:r.tab.root}))}return n},[e]);return(0,X.jsxs)(X.Fragment,{children:[n.length>0&&(0,X.jsx)(uo,{buffers:n}),(0,X.jsx)(xm,{node:e,...t})]})}function xm({node:e,...t}){if(e.kind===`leaf`)return(0,X.jsx)(gm,{leaf:e,sessions:t.sessions,reveal:t.reveal,onActivateTab:t.onActivateTab,onCloseTab:t.onCloseTab,onPromoteTab:t.onPromoteTab,onArchived:t.onArchived,onFocusLeaf:t.onFocusLeaf,onScrollDrive:t.onScrollDrive,onDropTab:t.onDropTab,onSetTabView:t.onSetTabView,onNewUntitled:t.onNewUntitled,onRevealFile:t.onRevealFile,onRenameFile:t.onRenameFile,focused:e.id===t.focusedLeafId,scrollDriver:e.id===t.scrollDriverLeafId,scrollChannel:t.scrollChannel});let n=e.direction===`row`?`horizontal`:`vertical`;return(0,X.jsx)(Ma,{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,X.jsxs)(Z.Fragment,{children:[r>0&&(0,X.jsx)(Ra,{className:n===`horizontal`?`w-px ${ym}`:`h-px ${ym}`}),(0,X.jsx)(Fa,{id:e.id,minSize:64,children:(0,X.jsx)(xm,{node:e,...t})})]},e.id))},e.id)}function Sm(e,t=`profile`){let n=e.snapshot,r=(0,Z.useRef)(null),i=(0,Z.useRef)(t),a=(0,Z.useRef)(!1);i.current!==t&&(i.current=t,r.current=null,a.current=!1),!n.layout_tree&&!r.current&&(r.current=gn(n));let o=n.layout_tree??r.current??un([]),s=(0,Z.useMemo)(()=>Qn(o),[o]),c=(0,Z.useCallback)(t=>e.update({layout_tree:t}),[e]),l=(0,Z.useRef)(c);l.current=c,(0,Z.useEffect)(()=>{a.current||e.loaded&&!n.layout_tree&&r.current&&(a.current=!0,ln(r.current).length>0&&l.current(r.current))},[e.loaded,n.layout_tree]),(0,Z.useEffect)(()=>{e.loaded&&s!==o&&n.layout_tree&&l.current(s)},[e.loaded,s,o,n.layout_tree]);let[u,d]=(0,Z.useState)(null),f=(u?Xn(s,u):null)??En(s)[0]??un([]),p=f.tabs.find(e=>q(e)===f.activeKey)??null,m=p?.type===`editor`?p.tab:null;return(0,Z.useMemo)(()=>({tree:s,focusedLeaf:f,activeEditorTab:m,focusLeaf:e=>d(e),activate:(e,t)=>{d(e);let n=q(t),r=Xn(s,e)?.activeKey===n,i=An(r?s:Kt(s,e,n),t);r&&i===s||c(i)},close:(e,t)=>{let n=qn(s,e,q(t)),r=Xn(n,e),i=r?.tabs.find(e=>q(e)===r.activeKey);c(i?An(n,i):n)},openEditor:(e,t)=>{let n=f.id;d(n);let r={type:`editor`,tab:e},i=t?.preview?Yt(s,n,r):Fn(s,n,r);c(An(i,r))},ensureTerminal:(e,t)=>{let n=`term:${e}`,r=Yn(s,n);if(r){d(r.id);let e=r.activeKey!==n,i=!t?.preview&&r.previewKey===n;if(e||i){let t=s;e&&(t=Kt(t,r.id,n)),i&&(t=qt(t,n)),c(t)}}else{let n=f.id;d(n);let r={type:`terminal`,session:e};c(t?.preview?Yt(s,n,r):Fn(s,n,r))}},promote:e=>c(qt(s,q(e))),setView:(e,t,n)=>{let r=tn(s,e,q(t),n),i=Xn(r,e),a=i?.tabs.find(e=>q(e)===i.activeKey);c(a?An(r,a):r)},renameFile:(e,t)=>{let n=jn(s,e,t);n!==s&&c(n)},removeTerminal:e=>{let t=Yn(s,`term:${e}`);t&&c(qn(s,t.id,`term:${e}`))},pruneSessions:e=>c(rn(s,wn(e))),resize:(e,t)=>c(Wt(s,e,t)),drop:e=>{d(e.toLeafId),c(An(_n(s,e),e.ref))}}),[s,f,m,c])}function Cm(e,t,n){return n>0?`● ${n} waiting — ${e} (${t})`:`${e} — ${t}`}function wm(){return(0,X.jsx)(Se,{children:(0,X.jsx)(Tm,{})})}function Tm(){let e=sn(),t=hn(),n=f(),r=e.id??``,i=/^[0-9a-f]{10}$/.test(r),a=e.sid??null,o=te(i?r:void 0),s=o.data?.project.id===r?o.data:void 0,d=_(o.data?.project.profile_id).data??[],g=Rn(),v=A(`editor.save`),y=h().data?.protocol,S=On(),C=l(),w=(0,Z.useMemo)(()=>s?.sessions??C.data?.filter(e=>e.project_id===r)??[],[s,C.data,r]),T=C.data??w,E=cn(),D=E.projectBasedLayout,O=E.showAllProjectSessions,k=D&&S.snapshot.layout_mode===`project`,P=Nn(S,r,k),re=(0,Z.useRef)(S);re.current=S;let F=(0,Z.useRef)(C.data);F.current=C.data;let I=o.data?.project.profile_id,L=x(I),ae=b(I),se=ne(I??``),R=s?.project??L.data?.find(e=>e.id===r),ce=(0,Z.useMemo)(()=>_t((L.data??(R?[R]:[])).filter(e=>!e.archived),ae.data?.projectOrder??[]),[L.data,R,ae.data]),le=(0,Z.useMemo)(()=>{let e=e=>e.status!==`archived`,t=C.data??w;return ce.map(n=>({projectId:n.id,name:n.name,abbrev:bn(n),repoId:n.repo_id,sessions:_t(t.filter(t=>t.project_id===n.id&&e(t)&&(O||n.id===r)),P.snapshot.session_order)}))},[O,w,r,P.snapshot.session_order,ce,C.data]),ue=(0,Z.useCallback)((e,t)=>{let n=ce.map(e=>e.id),r=$e(n,e,t);r.some((e,t)=>e!==n[t])&&se.mutate({projectOrder:r})},[ce,se]),de=(0,Z.useMemo)(()=>{let e=e=>Date.parse(e.last_activity_at??e.created_at)||0,t=t=>t.sort((t,n)=>e(n)-e(t)),n=e=>e.status===`archived`;if(k||!O)return t(w.filter(n));let r=C.data??w;return ce.flatMap(e=>t(r.filter(t=>t.project_id===e.id&&n(t))))},[O,k,w,C.data,ce]),fe=(0,Z.useRef)(ce);fe.current=ce;let z=(0,Z.useRef)(L.data);z.current=L.data,(0,Z.useEffect)(()=>{let e=re.current;if(!e.loaded)return;let t=e.current(),n=t.layout_mode??`profile`;if(D&&n!==`project`){if(!C.data||!L.data)return;let n=new Map(C.data.map(e=>[e.id,e.project_id])),i=Gn(t,L.data.map(e=>e.id),n,r);e.update({...i,project_layouts:Hn(i.project_layouts??{},t.project_layouts)})}else!D&&n===`project`&&e.update(xn(t,[r,...fe.current.map(e=>e.id)]))},[D,S.loaded,C.data,L.data,r]);let pe=k?`project:${r}`:`profile`,B=Sm(P,pe),[me,he]=(0,Z.useState)(null),V=(0,Z.useCallback)(e=>he({scopeKey:pe,leafId:e}),[pe]),_e=(me?.scopeKey===pe?Xn(B.tree,me.leafId):null)?.id??B.focusedLeaf.id;(0,Z.useEffect)(()=>{V(B.focusedLeaf.id)},[V,B.focusedLeaf.id,B.focusedLeaf.activeKey]);let ye=(0,Z.useCallback)(e=>{B.focusLeaf(e),V(e)},[B,V]),Se=S.snapshot.project_layouts,we=(0,Z.useMemo)(()=>k?yn(Se,r):[],[k,Se,r]),Te=(0,Z.useRef)(B);Te.current=B;let Ee=(0,Z.useRef)(P);Ee.current=P;let De=(0,Z.useCallback)(e=>Ee.current.update({session_order:tt(e,Ee.current.snapshot.session_order)}),[]),Oe=ko(Ao),Ae=(0,Z.useRef)(Oe);Ae.current=Oe;let[je,Me]=(0,Z.useState)(!1),[Pe,Ie]=(0,Z.useState)(!1),[Ve,Ue]=(0,Z.useState)(null),We=Ve===r,[Ge,Ke]=(0,Z.useState)(!1),[Je,Ye]=(0,Z.useState)(`agent`),[Xe,Ze]=(0,Z.useState)(void 0),[Qe,et]=(0,Z.useState)(null),nt=(0,Z.useCallback)((e=`agent`,t)=>{Ze(void 0),et(t??null),Ye(e),Ke(!0)},[]),rt=(0,Z.useCallback)((e,t)=>{let n=ce.find(e=>e.id===t);nt(e,n?{projectId:n.id,repoId:n.repo_id}:void 0)},[ce,nt]),it=(0,Z.useRef)(null),at=(0,Z.useRef)(null),{setHandler:ot}=mn();(0,Z.useEffect)(()=>{!i||!In(y)||c(r).catch(()=>void 0)},[y,r,i]),(0,Z.useEffect)(()=>Pn.onSessionSwitched(e=>{e.source_session===a&&(at.current={session:e.target_session,pin:!1},e.target_project===r&&Te.current.ensureTerminal(e.target_session,{preview:!0}),t(`/project/${e.target_project}/session/${e.target_session}`))}),[a,t,r]);let[st,ct]=(0,Z.useState)(null),lt=(0,Z.useCallback)((e,t,n)=>{V(B.focusedLeaf.id),B.openEditor(e,{preview:n?.preview}),Ae.current&&Me(!1),t&&(e.kind??`file`)===`file`&&ct({session:e.session,path:e.path,line:t.line,column:t.column,nonce:Date.now()})},[B,V]),ut=(0,Z.useCallback)((e,t,n,r)=>lt({...r?.root===void 0?{kind:`file`,session:e,path:t}:{kind:`external`,session:e,path:t,root:r.root},...r?.view?{view:r.view}:{}},n,r),[lt]);be(ut);let[dt,ft]=(0,Z.useState)(null),pt=(0,Z.useCallback)((e,t,n)=>ut(e,t,void 0,{preview:n?.preview??!0}),[ut]),mt=(0,Z.useCallback)((e,r)=>{let i=w.find(t=>t.id===e);i&&n.mutate({project_id:i.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:i.worktree_path,cwd:r},{onSuccess:e=>void t(`/project/${e.project_id}/session/${e.id}`),onError:e=>He(e)})},[w,n,t]),ht=(0,Z.useCallback)(e=>B.promote(e),[B]),gt=(0,Z.useCallback)((e,t,n,r)=>lt({kind:`external`,session:e,path:t,root:n},void 0,{preview:r?.preview??!0}),[lt]),vt=ee(),yt=Tn(y),bt=(0,Z.useCallback)(e=>{if(I!==void 0){if(!yt){u.error(`Untitled drafts need a newer daemon — refresh the connection to update it`);return}ve(I).then(({name:e})=>lt({kind:`untitled`,session:m,path:e})).catch(e=>u.error(e instanceof Error?e.message:`Could not create a draft`))}},[lt,I,yt]),[xt,St]=(0,Z.useState)(null);(0,Z.useEffect)(()=>(xe(St),()=>xe(null)),[]);let[U,Ct]=(0,Z.useState)(null),wt=()=>{let e=U;if(Ct(null),!e||e.ref.type!==`editor`)return;let t=e.ref.tab.path;I!==void 0&&Ce(I,t).catch(()=>void 0),ge(t),B.close(e.leafId,e.ref)},Tt=(e,t,n,r)=>{St(null);let i={type:`editor`,tab:{kind:`untitled`,session:m,path:e}},a=q(i);for(let e of En(Te.current.tree))e.tabs.some(e=>q(e)===a)&&Te.current.close(e.id,i);vt.invalidateQueries({queryKey:[`wt-tree`,t]}),setTimeout(()=>{Te.current.openEditor(r===void 0?{kind:`file`,session:t,path:n}:{kind:`external`,session:t,path:n,root:r})},0)};(0,Z.useEffect)(()=>(ot(e=>{Ze(e?.accountId),Ye(e?.kind??`agent`),Ke(!0)}),()=>ot(null)),[ot]);let[Et,Dt]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!P.loaded)return;let e=ln(Te.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?qe():void 0,e.some(e=>e.type===`editor`)?oo():void 0]).finally(()=>Dt(!0))},[P.loaded,pe]),(0,Z.useEffect)(()=>{if(We||!P.loaded||!s)return;Ue(r);let e=P.snapshot.active_session,n=w.find(t=>t.id===e);!a&&n&&n.status!==`archived`&&t(`/project/${r}/session/${n.id}`,{replace:!0})},[We,P,s,w,a,t,r]);let Ot=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(Ot.current||!P.loaded||!C.data)return;Ot.current=!0;let e=new Set(C.data.filter(e=>e.status!==`archived`).map(e=>e.id));Te.current.pruneSessions(e);let t=re.current,n=t.current().project_layouts;if(Object.keys(n).length>0){let r=wn(e);t.update({project_layouts:Object.fromEntries(Object.entries(n).map(([t,n])=>[t,{...n,layout_tree:n.layout_tree?rn(n.layout_tree,r):null,active_session:n.active_session!==null&&e.has(n.active_session)?n.active_session:null}]))})}let r=Ee.current.snapshot.session_order,i=r.filter(t=>e.has(t));i.length!==r.length&&Ee.current.update({session_order:i})},[P.loaded,C.data]),(0,Z.useEffect)(()=>{if(!We)return;if(Ie(!1),!a){it.current=null;return}if(a===it.current)return;it.current=null;let e=at.current;at.current=null,Te.current.ensureTerminal(a,{preview:e?.session!==a||!e.pin});let t=Ee.current;t.snapshot.active_session!==a&&t.update({active_session:a})},[We,a]);let kt=M();(0,Z.useEffect)(()=>{let e=ie(kt.data)??`Puddle`,t=w.filter(e=>e.status===`waiting_input`).length,n=R?.name??`Puddle`;return document.title=Cm(n,e,t),()=>{document.title=e}},[w,R?.name,kt.data]);let At=(0,Z.useCallback)(e=>{let n=a===e;n&&(it.current=e),B.removeTerminal(e),n&&(P.update({active_session:null}),t(`/project/${r}`))},[B,P,a,t,r]),jt=p(),Mt=(0,Z.useCallback)(e=>jt.mutate(e,{onSuccess:()=>At(e),onError:e=>He(e)}),[jt,At]),Pt=(0,Z.useCallback)((e,n)=>{if(V(e),B.activate(e,n),n.type===`terminal`&&n.session!==a){let e=T.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[B,t,T,a,V]),It=(0,Z.useCallback)((e,n)=>{if(n.type===`editor`&&$n(n.tab)===`untitled`){Ct({leafId:e,ref:n});return}let i=Xn(B.tree,e)?.tabs.findIndex(e=>q(e)===q(n))??-1;Do(pe,{leafId:e,index:Math.max(0,i),ref:n}),B.close(e,n),n.type===`terminal`&&n.session===a&&(it.current=n.session,P.update({active_session:null}),t(`/project/${r}`))},[B,a,P,t,r,pe]),Lt=(0,Z.useCallback)(()=>{let e=F.current,n=e?new Set(e.filter(e=>e.status!==`archived`).map(e=>e.id)):null,r=Oo(pe,e=>{if(n===null)return!0;let t=e.type===`terminal`?e.session:e.tab.session;return n.has(t)});if(!r)return;let{ref:i}=r,o=Xn(B.tree,r.leafId),s=o?r.leafId:B.focusedLeaf.id,c=o?r.index:void 0;if(B.drop({ref:i,fromLeafId:s,toLeafId:s,edge:`center`,index:c}),i.type===`terminal`&&i.session!==a){let e=T.find(e=>e.id===i.session)?.project_id;e&&t(`/project/${e}/session/${i.session}`)}},[B,pe,a,T,t]),Rt=(0,Z.useCallback)((e,n,i)=>{let o=n.type===`terminal`?T.find(e=>e.id===n.session)?.project_id:void 0;if(k&&o!==void 0&&o!==r&&n.type===`terminal`){at.current={session:n.session,pin:!0},t(`/project/${o}/session/${n.session}`);return}B.drop({ref:n,fromLeafId:e,toLeafId:e,edge:i,copy:!0}),n.type===`terminal`&&n.session!==a&&o!==void 0&&t(`/project/${o}/session/${n.session}`)},[B,a,T,t,k,r]),zt=B.focusedLeaf.tabs.find(e=>q(e)===B.focusedLeaf.activeKey)??null,Bt=zt===null?null:zt.type===`terminal`?zt.session:zt.tab.session,Vt=Bt===`00000000-0000-0000-0000-000000000000`?null:Bt,Ht=j().data?.find(e=>e.id===R?.repo_id),Ut=(0,Z.useMemo)(()=>Vn(y)&&Ht&&R?{path:Ht.path,projectId:R.id,name:R.name,defaultBranch:Ht.default_base_branch}:null,[y,Ht,R]),Wt=no(T,Vt??a,P,Ut),W=Wt.session,G=Wt.root,Kt=(0,Z.useCallback)(e=>{let t=T.find(t=>t.id===e.session);if(e.root===void 0&&!t)return;let n=ro(e,t?.worktree_path??e.root??``);if(Ae.current&&Me(!0),P.update({sidebar_mode:`files`,...Ae.current?{}:{sidebar_collapsed:!1}}),n.browseRoot!==void 0){let r=t?.id??W?.id??e.session;ft({session:r,root:n.browseRoot,nonce:Date.now()})}else(G??W?.worktree_path)!==n.directory&&Wt.pin(e.session);So({path:n.path,directory:n.directory})},[Wt,T,G,W?.worktree_path,P]),qt=(0,Z.useCallback)(async(e,t)=>{let n=t.trim();if(n===``||n===za(e.path))return!0;let r=Ua(Ba(e.path),n);try{let{rekeyBuffer:t}=await ke(async()=>{let{rekeyBuffer:e}=await import(`./buffer-store-eUpqFE4J.js`).then(e=>e.n);return{rekeyBuffer:e}},__vite__mapDeps([16,1,2,6,9,3,4,10,11,12,14,15,17])),n=await oe(e.session,e.path,r,e.root),i=t(e.session,e.path,n.path,e.root);return Te.current.renameFile(e,n.path),vt.invalidateQueries({queryKey:[`wt-tree`,e.session]}),vt.invalidateQueries({queryKey:[`wt-git-status`,e.session]}),setTimeout(()=>{(i?.dirty?er(e.session,n.path,i.content,i.baseMtimeMs,e.root):Promise.resolve()).then(()=>tr(e.session,e.path,e.root))},0),!0}catch(e){return He(e),!1}},[vt]),Jt=(0,Z.useCallback)((e,t)=>{if(t.kind===`dir`){Ae.current&&Me(!0),P.update({sidebar_mode:`files`,...Ae.current?{}:{sidebar_collapsed:!1}}),ft({session:e,root:t.path,nonce:Date.now()});return}let n=Ft(t,G);n!==null&&ft({session:e,root:n,nonce:Date.now()}),ut(e,t.path,t.line===void 0?void 0:{line:t.line,column:t.column},t.root===void 0?void 0:{root:t.root})},[ut,P,G]),Yt=W?.id??null,Xt=(0,Z.useCallback)(async e=>{if(Yt===null)throw Error(`No worktree is available for this project.`);let t=await Nt(Yt,e,{root:G}),n=t.kind===`file`&&t.root===void 0&&G!==void 0?{...t,root:G}:t;if(n.kind===`dir`&&n.relativePath!==void 0){Ae.current&&Me(!0),P.update({sidebar_mode:`files`,...Ae.current?{}:{sidebar_collapsed:!1}}),So({path:n.relativePath,root:G,expandTarget:!0});return}Jt(Yt,n)},[Yt,G,Jt]);(0,Z.useEffect)(()=>kn(Xt),[Xt]);let Zt=Zl(P.snapshot.sidebar_mode),Qt=P.snapshot.sidebar_collapsed,K=P.snapshot.sessions_collapsed,tn=(0,Z.useCallback)(e=>{let t=B.focusedLeaf,n=t.tabs.find(e=>q(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){u.error(`Focus a terminal or agent to insert`);return}Pn.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[B]);(0,Z.useEffect)(()=>(Gt(tn),()=>Gt(null)),[tn]);let nn=(0,Z.useCallback)(e=>{let t=re.current,n=F.current,i=z.current;if(!t.loaded||!n||!i)return!1;let{patch:a,projectBased:o}=zn(t.current(),e,{alive:new Set(n.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(n.map(e=>[e.id,e.project_id])),projectIds:i.map(e=>e.id),currentProject:r});return t.update(a),$t().projectBasedLayout!==o&&en({projectBasedLayout:o}),!0},[r]),an=k?`project`:`profile`,on=P.snapshot.layout_tree,un=P.snapshot.layout_ref,dn=S.snapshot.project_layouts;(0,Z.useEffect)(()=>{S.loaded&&Cn({scope:an,projectId:r,layoutRef:un,signature:Bn(on),slices:Object.fromEntries(Object.entries(dn).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:Bn(t.layout_tree)}])),capture:()=>{let e=Ee.current.current();return{layout_tree:e.layout_tree,active_session:e.active_session}},apply:nn})},[S.loaded,an,r,on,un,dn,nn]),(0,Z.useEffect)(()=>()=>Cn(null),[]);let fn=(0,Z.useRef)({}),J=e=>{let t=B.focusedLeaf;if(t.tabs.length<2)return;let n=t.tabs.findIndex(e=>q(e)===t.activeKey),r=n===-1?e===1?0:t.tabs.length-1:n+e,i=t.tabs[(r+t.tabs.length)%t.tabs.length];i&&Pt(t.id,i)},pn=e=>{Oe?(P.update({sidebar_mode:e}),Me(!0)):P.update({sidebar_mode:e,sidebar_collapsed:!1})};fn.current={"tab.close":()=>{let e=B.focusedLeaf,t=e.tabs.find(t=>q(t)===e.activeKey);t&&It(e.id,t)},"tab.reopen":Lt,"tab.newUntitled":()=>bt(B.focusedLeaf),"tab.next":()=>J(1),"tab.prev":()=>J(-1),"editor.save":()=>{Za(B.activeEditorTab)},"sidebar.left":()=>Oe?Me(e=>!e):P.update({sidebar_collapsed:!P.snapshot.sidebar_collapsed}),"sidebar.right":()=>Oe?Ie(e=>!e):P.update({sessions_collapsed:!P.snapshot.sessions_collapsed}),"nav.files":()=>pn(`files`),"nav.search":()=>pn(`search`),"nav.changes":()=>pn(`changes`),"nav.worktrees":()=>pn(`worktrees`),"session.newAgent":()=>nt(`agent`),"session.newTerminal":()=>nt(`terminal`)},(0,Z.useEffect)(()=>{let e=Object.keys(fn.current).map(e=>N(e,()=>fn.current[e]?.()));return()=>e.forEach(e=>e())},[]);let gn=B.activeEditorTab,_n=gn?.kind===`diff`&&W&&gn.session===W.id?gn.path:null,vn=gn&&(gn.kind??`file`)===`file`&&W&&gn.session===W.id?gn.path:null,Sn=gn?.kind===`external`&&gn.root!==void 0?{path:gn.path,root:gn.root}:null,Dn=e=>({preview:e?.preview??!0}),An=(e,t)=>{if(W){let n=t?.root??G,r=n===void 0?{}:{root:n};lt({kind:`diff`,session:W.id,path:e,...r,...t?.gitArea===void 0?{}:{git_area:t.gitArea}},void 0,Dn(t))}},jn=(e,t,n)=>{if(W){let r=n?.root??G,i=r===void 0?{}:{root:r};lt({kind:`commit`,session:W.id,path:e,sha:t,...i},void 0,Dn(n))}},Mn=(e,t,n)=>{if(!W)return;let r=t===void 0?void 0:{line:t,column:1};if(G!==void 0){lt({kind:`external`,session:W.id,path:e,root:G},r,Dn(n));return}ut(W.id,e,r,Dn(n))},Fn=(0,Z.useCallback)(e=>P.update({layout:{...P.snapshot.layout,...e}}),[P]),Ln=jo(P.snapshot.layout,[...Qt?[]:[`nav`],`main`,...K?[]:[`sessions`]]);if(!i)return null;if(!P.loaded||!R||!Et)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`});let Un=e=>(0,X.jsx)($l,{mode:Zt,onModeChange:e=>P.update({sidebar_mode:e}),onCollapse:e,projectId:r,repoId:R.repo_id,sessions:w,target:Wt,browseRequest:dt,onOpenFile:pt,onOpenExternalFile:gt,onOpenTerminalIn:mt,activeFilePath:vn,activeExternalTab:Sn,activeDiffPath:_n,onOpenDiff:An,onOpenCommitFile:jn,onOpenSearchFile:Mn}),Wn={onNewSessionIn:e=>rt(`agent`,e),onNewTerminalIn:e=>rt(`terminal`,e),onMoveProject:ue},Kn=e=>(0,X.jsx)(Kp,{groups:le,accounts:d,activeSessionId:a,onReorder:De,onPromote:e=>B.ensureTerminal(e),archived:de,onNewSession:()=>nt(`agent`),onNewTerminal:()=>nt(`terminal`),onCollapse:e,onArchived:At,onArchiveDrop:Mt,projectActions:Wn}),qn=(0,X.jsx)(`div`,{className:`flex h-full flex-col bg-ground`,children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(bm,{tree:B.tree,sessions:T,reveal:st,onActivateTab:Pt,onCloseTab:It,onPromoteTab:ht,onArchived:At,onFocusLeaf:ye,onScrollDrive:V,onResize:B.resize,onDropTab:Rt,onSetTabView:B.setView,onNewUntitled:bt,onRevealFile:Kt,onRenameFile:qt,focusedLeafId:B.focusedLeaf.id,scrollDriverLeafId:_e,scrollChannel:pe})})});return(0,X.jsx)(vo,{tree:B.tree,parked:we,onOpenFile:Jt,children:(0,X.jsx)(jp,{onDrop:B.drop,onArchive:Mt,renderOverlay:e=>{let t=e.type===`terminal`?T.find(t=>t.id===e.session):void 0;return(0,X.jsx)(`div`,{className:`rounded-md bg-elevated px-2.5 py-1 text-xs text-fg shadow-lg`,children:e.type===`terminal`?t?g(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,X.jsxs)(`div`,{className:`relative flex h-full`,children:[Oe?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ql,{mode:Zt,onExpand:()=>Me(!0),onSelect:e=>{P.update({sidebar_mode:e}),Me(!0)}}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:qn}),(0,X.jsx)(Wp,{groups:le,accounts:d,activeSessionId:a,onReorder:De,onPromote:e=>B.ensureTerminal(e),onExpand:()=>Ie(!0),onNewTerminal:()=>nt(`terminal`),onNewSession:()=>nt(`agent`),onArchived:At,onArchiveDrop:Mt,projectActions:Wn}),je&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close the navigator`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>Me(!1)}),(0,X.jsx)(`div`,{className:`absolute inset-y-0 left-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:Un(()=>Me(!1))})]}),Pe&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close the session list`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>Ie(!1)}),(0,X.jsx)(`div`,{className:`absolute inset-y-0 right-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:Kn(()=>Ie(!1))})]})]}):(0,X.jsxs)(X.Fragment,{children:[Qt&&(0,X.jsx)(Ql,{mode:Zt,onExpand:()=>P.update({sidebar_collapsed:!1}),onSelect:e=>P.update({sidebar_collapsed:!1,sidebar_mode:e})}),(0,X.jsxs)(Ma,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:Ln,onLayoutChanged:Fn,children:[!Qt&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fa,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,children:Un(()=>P.update({sidebar_collapsed:!0}))}),(0,X.jsx)(Ra,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`})]}),(0,X.jsx)(Fa,{id:`main`,children:qn}),!K&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ra,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`}),(0,X.jsx)(Fa,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,children:Kn(()=>P.update({sessions_collapsed:!0}))})]})]}),K&&(0,X.jsx)(Wp,{groups:le,accounts:d,activeSessionId:a,onReorder:De,onPromote:e=>B.ensureTerminal(e),onExpand:()=>P.update({sessions_collapsed:!1}),onNewTerminal:()=>nt(`terminal`),onNewSession:()=>nt(`agent`),onArchived:At,onArchiveDrop:Mt,projectActions:Wn})]}),(0,X.jsx)(nu,{projectId:Qe?.projectId??r,repoId:Qe?.repoId??R.repo_id,open:Ge,kind:Je,seedAccountId:Xe,onOpenChange:Ke,onCreated:e=>void t(`/project/${e.project_id}/session/${e.id}`)}),(0,X.jsx)(Qa,{request:xt,targetSession:W,targetRoot:G,targetLabel:W===null?``:G===void 0?W.branch:G,profileId:I,onClose:()=>St(null),onSaved:Tt}),(0,X.jsx)(Be,{open:U!==null,onOpenChange:e=>!e&&Ct(null),children:(0,X.jsxs)(Le,{children:[(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Re,{children:`Discard this draft?`}),(0,X.jsxs)(ze,{children:[`Closing an untitled tab deletes its draft — `,v,` saves it into the worktree instead.`]})]}),(0,X.jsxs)(Fe,{children:[(0,X.jsx)(H,{variant:`ghost`,onClick:()=>Ct(null),children:`Keep editing`}),(0,X.jsx)(H,{variant:`danger`,onClick:wt,children:`Discard`})]})]})})]})})})}export{wm as Workspace};