@puddle-code/cli 0.3.4 → 0.3.6
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.
- package/CHANGELOG.md +4 -13
- package/dist/host-control.mjs +5 -1
- package/dist/index.js +10 -4
- package/dist/public/assets/{App-CwV0Dizo.js → App-Duewv-oi.js} +2 -2
- package/dist/public/assets/{Dashboard-fA7E3Mr1.js → Dashboard-7gBsrB7q.js} +1 -1
- package/dist/public/assets/{EditorTabClose-DNWGZZN8.js → EditorTabClose-BV-zQyHT.js} +1 -1
- package/dist/public/assets/{LazyTerminal-CAvxgexS.js → LazyTerminal-gX1-vBQf.js} +2 -2
- package/dist/public/assets/{ModelRefcount-CJK-g5rf.js → ModelRefcount-BasPzO4R.js} +1 -1
- package/dist/public/assets/{NewProjectDialog-eDAOcbIM.js → NewProjectDialog-CDYUPliQ.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-Cxn0s84L.js → PaneEditorBody-CqLkAxM1.js} +3 -3
- package/dist/public/assets/{PdfViewer-BY5xRKk1.js → PdfViewer-DAAfA9OC.js} +1 -1
- package/dist/public/assets/{SettingsDialog-Sd6i7Plz.js → SettingsDialog-DiwhE5dK.js} +1 -1
- package/dist/public/assets/{Terminal-CqjwbNAI.js → Terminal-DmlEI-h7.js} +3 -3
- package/dist/public/assets/{Workspace-C-M1AjMn.js → Workspace-cfjpv0xU.js} +4 -4
- package/dist/public/assets/{auth-cjbSLnao.js → auth-BxExwqPW.js} +1 -1
- package/dist/public/assets/{buffer-store-BAQjeFXg.js → buffer-store-CYe-IdNO.js} +1 -1
- package/dist/public/assets/{copy-Df7qIcX6.js → copy-CjatFFf8.js} +1 -1
- package/dist/public/assets/{disclosure-C2uTs3Vm.js → disclosure-7lu23NnB.js} +1 -1
- package/dist/public/assets/{dist-Cl5AP2As.js → dist-7fft9rhQ.js} +1 -1
- package/dist/public/assets/{errors-BiS6nBXL.js → errors-DhRwiizF.js} +1 -1
- package/dist/public/assets/{index-CW1P_8TN.js → index-BRywm-gU.js} +3 -3
- package/dist/public/assets/{markdown-mermaid-JPAETK2Y.js → markdown-mermaid-CF9txXiK.js} +1 -1
- package/dist/public/assets/{media-refresh-store-CHnqDJWI.js → media-refresh-store-DLtYZTP9.js} +1 -1
- package/dist/public/assets/{notification-delivery-Lz-hnQG7.js → notification-delivery-CoCRZRSK.js} +1 -1
- package/dist/public/assets/{project-abbrev-Bz8ZEwrb.js → project-abbrev-DX_a_ySv.js} +1 -1
- package/dist/public/assets/{protocol-support-CJIxbQCB.js → protocol-support-gmAQBWF3.js} +1 -1
- package/dist/public/assets/{scroll-restoration-r--43sOx.js → scroll-restoration-hg7BYUz2.js} +1 -1
- package/dist/public/assets/{selection-actions-C2udLSyj.js → selection-actions-BZy4596m.js} +1 -1
- package/dist/public/assets/{switch-DwMO1AUH.js → switch-OD1b2aeq.js} +1 -1
- package/dist/public/assets/{use-ui-state-Crvfdw4F.js → use-ui-state-C2LCTPRw.js} +1 -1
- package/dist/public/assets/{ws-B1kcYo2j.js → ws-oU1ansI7.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/pudl.js +6 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{A as i,D as a,E as o,W as s,Y as c,_ as l,a as u,b as d,k as f,o as p,x as m,y as h}from"./auth-cjbSLnao.js";import{a as g,c as _,f as v,i as y,l as b,n as x,o as S,p as C,r as w,s as T,t as E}from"./LazyTerminal-CAvxgexS.js";import{i as D,r as ee,t as O}from"./client-settings-CwqpIric.js";import{t as k}from"./preload-helper-Czpn1I53.js";import{l as te,u as A}from"./index-CW1P_8TN.js";import{i as j,n as M,r as ne}from"./dist-Cl5AP2As.js";import{At as N,B as P,C as re,Ct as ie,Dt as F,E as ae,Et as I,I as oe,It as se,J as ce,M as le,Nt as ue,Ot as de,P as fe,R as pe,St as L,Y as me,Z as he,a as ge,bt as R,d as _e,f as ve,ft as ye,gt as be,i as xe,it as Se,k as Ce,l as we,p as Te,pt as z,r as Ee,rt as De,s as Oe,st as ke,t as Ae,vt as je,wt as Me,xt as Ne,yt as Pe,z as Fe}from"./protocol-support-CJIxbQCB.js";import{r as Ie}from"./copy-Df7qIcX6.js";import{$ as Le,A as Re,B as ze,D as Be,F as Ve,G as He,I as Ue,J as We,L as Ge,N as Ke,O as qe,P as B,Q as Je,R as Ye,T as Xe,U as Ze,V as Qe,X as $e,Z as et,_ as tt,a as nt,at as rt,b as it,c as at,d as ot,et as st,g as ct,i as lt,it as ut,j as dt,k as ft,l as pt,m as mt,nt as ht,o as gt,p as _t,r as vt,rt as yt,s as bt,t as xt,tt as St,u as Ct,v as wt,y as Tt,z as Et}from"./media-refresh-store-CHnqDJWI.js";import{a as Dt,d as Ot,l as kt,n as At,r as jt,t as Mt,u as Nt}from"./project-abbrev-Bz8ZEwrb.js";import{n as V,t as Pt}from"./x-DCpy1q13.js";import{n as Ft,r as It}from"./dist-BCwJL3w9.js";import{A as Lt,B as Rt,C as zt,D as Bt,E as Vt,F as Ht,I as Ut,J as Wt,K as Gt,L as Kt,M as qt,N as Jt,O as Yt,P as Xt,Q as Zt,R as Qt,S as $t,T as en,V as tn,Y as nn,Z as rn,_ as an,a as on,b as sn,c as cn,et as ln,g as un,h as dn,i as fn,it as pn,j as mn,k as hn,l as gn,n as _n,nt as vn,o as yn,ot as H,rt as U,s as bn,u as xn,v as Sn,w as Cn,x as wn,y as Tn,z as W}from"./use-ui-state-Crvfdw4F.js";import{t as G}from"./button-Chvl9hcE.js";import{t as K}from"./createLucideIcon-DyMAgLa3.js";import{a as En,c as Dn,d as On,f as kn,h as An,i as jn,l as Mn,m as Nn,n as Pn,o as Fn,p as In,r as q,s as Ln,t as Rn,u as zn}from"./context-menu-DVUv5Z6a.js";import{c as Bn,i as Vn,l as Hn,o as Un,t as Wn,u as Gn}from"./switch-DwMO1AUH.js";import{n as Kn,r as qn,t as Jn}from"./whole-word-2m2pmAFT.js";import{a as Yn,i as Xn,n as Zn,r as Qn,t as $n}from"./select-YFIOZ3zx.js";import{t as J}from"./chevron-down--sjpQEHH.js";import{r as er}from"./dist-DmyIHyF9.js";import{b as tr,c as nr,d as rr,g as ir,h as ar,l as or,o as sr,p as cr,r as lr,s as ur,t as dr,u as fr,y as pr}from"./selection-actions-C2udLSyj.js";import{n as mr,t as hr}from"./errors-BiS6nBXL.js";import{t as gr}from"./ws-B1kcYo2j.js";import{a as _r,i as vr,n as yr,o as br,r as xr,t as Sr}from"./dialog-Bnex_wlx.js";import{n as Cr,o as wr}from"./preview-kind-CJ9RTgbs.js";import{a as Tr,t as Er}from"./drafts-B_tChlzR.js";import{i as Dr}from"./buffer-logic-BAkSBQT7.js";import{i as Or,r as kr,t as Ar}from"./scroll-restoration-r--43sOx.js";import{a as jr,c as Mr,d as Nr,l as Pr,n as Fr,o as Ir,r as Lr,t as Rr,u as zr}from"./disclosure-C2uTs3Vm.js";var Br=K(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Vr=K(`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`}]]),Hr=K(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Ur=K(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Wr=K(`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`}]]),Gr=K(`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`}]]),Kr=K(`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`}]]),qr=K(`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=K(`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`}]]),Jr=K(`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`}]]),Yr=K(`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`}]]),Xr=K(`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`}]]),Zr=K(`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`}]]),Qr=K(`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`}]]),$r=K(`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`}]]),ei=K(`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`}]]),ti=K(`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`}]]),ni=K(`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`}]]),ri=K(`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`}]]),ii=K(`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`}]]),ai=K(`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`}]]),oi=K(`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`}]]),si=K(`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`}]]),ci=K(`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`}]]),li=K(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),ui=K(`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`}]]),di=K(`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`}]]),fi=K(`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`}]]),pi=K(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),mi=K(`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`}]]),hi=K(`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`}]]),gi=K(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),_i=K(`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`}]]),vi=K(`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`}]]),yi=K(`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`}]]),bi=K(`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`}]]),xi=K(`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`}]]),Si=K(`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`}]]),Ci=K(`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`}]]),wi=K(`text-cursor-input`,[[`path`,{d:`M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6`,key:`1528k5`}],[`path`,{d:`M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7`,key:`13ksps`}],[`path`,{d:`M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1`,key:`1n9rhb`}],[`path`,{d:`M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1`,key:`1mj8rg`}],[`path`,{d:`M9 6v12`,key:`velyjx`}]]),Ti=K(`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`}]]),Ei=K(`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`}]]),Di=K(`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`}]]),Oi=K(`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=r(),Z=e(t(),1);function ki(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Ai(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function ji(e){return e/100*window.innerHeight}function Mi(e){return e/100*window.innerWidth}function Ni(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 Pi({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Ni(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Ai(t,i);break;case`em`:r=ki(t,i);break;case`vh`:r=ji(i);break;case`vw`:r=Mi(i);break}return r}function Fi(e){return parseFloat(e.toFixed(3))}function Ii({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 Li(e){let{panels:t}=e,n=Ii({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=Fi(Pi({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Fi(Pi({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Fi(Pi({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Fi(Pi({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 Ri(e,t){return Array.from(t).sort(e===`horizontal`?zi:Bi)}function zi(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Bi(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Vi(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Hi(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 Ui({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}=Hi(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Q(i,`No rect found`),i}var Wi;function Gi(){return Wi===void 0&&(Wi=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),Wi}function Ki(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Ri(n,Array.from(t.children).filter(Vi).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,Ui({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=Gi()?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:Ii({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 qi=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)}}},Ji={cursorFlags:0,state:`inactive`},Yi=new qi;function Xi(){return Ji}function Zi(e){return Yi.addListener(`change`,e)}function Qi(e){let t=Ji,n={...Ji};n.cursorFlags=e,Ji=n,Yi.emit(`change`,{prev:t,next:n})}function $i(e){let t=Ji;Ji=e,Yi.emit(`change`,{prev:t,next:e})}var ea=e=>e,ta=()=>{},na=1,ra=2,ia=4,aa=8,oa=3,sa=12,ca;function la(){return ca===void 0&&(ca=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(ca=!0)),ca}function ua({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&&la()){let t=(e&na)!==0,n=(e&ra)!==0,r=(e&ia)!==0,i=(e&aa)!==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 la()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var da=new WeakMap;function fa(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=da.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=Xi();switch(r.state){case`active`:case`hover`:{let e=ua({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}da.set(e,{prevStyle:t,styleSheet:n})}var pa=new Map,ma=new qi;function ha(e){pa=new Map(pa),pa.delete(e)}function ga(e,t){for(let[t]of pa)if(t.id===e)return t}function _a(e,t){for(let[t,n]of pa)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function va(){return pa}function ya(e,t){return ma.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function ba(e,t,n){let r=pa.get(e);pa=new Map(pa),pa.set(e,t),ma.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function xa(e){let t=Xi(),n=!1;switch(t.state){case`active`:$i({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(fa(e),n=!0,t.hitRegions.forEach(e=>{let t=_a(e.group.id,!0);ba(e.group,t,{isUserInteraction:!0})}))}return n}function Sa(e){e.defaultPrevented||xa(e.currentTarget)}function Ca(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Hi(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 wa(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ta(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:ja(e),b:ja(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:Aa(ka(n.a)),b:Aa(ka(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 Ea=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Da(e){let t=getComputedStyle(Ma(e)??e).display;return t===`flex`||t===`inline-flex`}function Oa(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Da(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`||Ea.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function ka(e){let t=e.length;for(;t--;){let n=e[t];if(Q(n,`Missing node`),Oa(n))return n}return null}function Aa(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ja(e){let t=[];for(;e;)t.push(e),e=Ma(e);return t}function Ma(e){let{parentNode:t}=e;return wa(t)?t.host:t}function Na(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 Pa({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Vi(n)||n.contains(e)||e.contains(n))return!0;if(Ta(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Na(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Fa(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Ki(r),a=Ca(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Pa({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Ia(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 La(e,t,n=0){return Math.abs(Fi(e)-Fi(t))<=n}function Ra(e,t){return La(e,t)?0:e>t?1:-1}function za({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(Ra(r,c)<0)if(a){let e=(i+c)/2;r=Ra(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Fi(r),r}function Ba({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(La(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}`),La(n,i)){let t=o-n;Ra(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}`),La(n,o)){let t=n-i;Ra(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&&Ra(i,c)<0)if(e>0){let t=c-o,n=t/2;Ra(i+e,c)<0&&(e=Ra(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Ra(i-e,c)<0&&(e=Ra(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=za({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=za({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!La(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(Ia(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=za({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!La(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=za({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(La(i,s)||(t-=s-i,l[r]=s),La(t,0))break;e>0?r--:r++}}}if(!La(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 Va(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Ra(e[n],t[n])!==0)return!1;return!0}function Ha({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(!La(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=za({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!La(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=za({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,La(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Ua({groupId:e,panelId:t}){let n=()=>{let t=va();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&&La(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:Fi(100-e)}}return Ba({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=Ha({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});Va(c,u)||ba(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&&La(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Ii({group:t}),o=Fi(Pi({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function Wa(e){e.defaultPrevented||Fa(e,va()).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=Ua({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Ga(e){let t=va();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 Ka({groupId:e}){let t=()=>{let t=va();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=Ha({layout:e,panelConstraints:r});return n?o:(Va(o,c)||ba(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function qa(e,t){let n=Ga(e),r=_a(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=Ka({groupId:n.id}).getLayout(),c=Ha({layout:Ba({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Va(s,c)||ba(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function Ja(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Ga(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&qa(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&qa(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&qa(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&qa(t,-5);break;case`End`:e.preventDefault(),qa(t,100);break;case`Enter`:{e.preventDefault();let n=Ga(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=_a(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];qa(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Ga(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(),qa(t,-100);break}}function Ya(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=va(),n=Fa(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)}),$i({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function Xa({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=Ba({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Va(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?na:ra;break;case`vertical`:s|=d<0?ia:aa;break}}else ba(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&oa:c|=s&oa,t.movementY===0?c|=o&sa:c|=s&sa,Qi(c),fa(e)}function Za(e){let t=va(),n=Xi();switch(n.state){case`active`:Xa({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Qa(e){if(e.defaultPrevented)return;let t=Xi(),n=va();switch(t.state){case`active`:if(e.buttons===0){$i({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=_a(e.group.id,!0);ba(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)}Xa({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Fa(e,n);r.length===0?t.state!==`inactive`&&$i({cursorFlags:0,state:`inactive`}):$i({cursorFlags:0,hitRegions:r,state:`hover`}),fa(e.currentTarget);break}}}function $a(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Xi().state){case`hover`:$i({cursorFlags:0,state:`inactive`})}}function eo(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||xa(e.currentTarget)&&e.preventDefault()}function to(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Fi(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Fi((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function no(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Ii({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Fi(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function ro(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 io({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=Fi(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]=Fi((r[e]??0)/a*l);else{let e=Fi(l/c.length);for(let t of c)u[t]=e}return u}function ao(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 oo=new Map;function so(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=Ii({group:e});if(t===0)return;let n=_a(e.id);if(!n)return;let r=Li(e),i=n.defaultLayoutDeferred?to(r):n.layout,a=Ha({layout:io({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Va(n.layout,a)&&ro(n.derivedPanelConstraints,r)&&n.groupSize===t)return;ba(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else no(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=Ii({group:e}),s=Li(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(ao(e.panels,l)||(l=void 0));let u=Ha({layout:e.mutableState.layouts[c]??l??to(s),panelConstraints:s}),d=e.element.ownerDocument;oo.set(d,(oo.get(d)??0)+1);let f=new Map;return Ki(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),ba(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`,Ja)}),oo.get(d)===1&&(d.addEventListener(`contextmenu`,Sa,!0),d.addEventListener(`dblclick`,Wa,!0),d.addEventListener(`pointerdown`,Ya,!0),d.addEventListener(`pointerleave`,Za),d.addEventListener(`pointermove`,Qa),d.addEventListener(`pointerout`,$a),d.addEventListener(`pointerup`,eo,!0)),function(){t=!1,oo.set(d,Math.max(0,(oo.get(d)??0)-1)),ha(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Ja)}),oo.get(d)||(d.removeEventListener(`contextmenu`,Sa,!0),d.removeEventListener(`dblclick`,Wa,!0),d.removeEventListener(`pointerdown`,Ya,!0),d.removeEventListener(`pointerleave`,Za),d.removeEventListener(`pointermove`,Qa),d.removeEventListener(`pointerout`,$a),d.removeEventListener(`pointerup`,eo,!0)),a.disconnect()}}function co(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function lo(e){let t=(0,Z.useId)();return`${e??t}`}var uo=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function fo(e){let t=(0,Z.useRef)(e);return uo(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function po(...e){return fo(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function mo(e){let t=(0,Z.useRef)({...e});return uo(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var ho=(0,Z.createContext)(null);function go(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:ea});(0,Z.useImperativeHandle)(t,()=>n.current,[]),uo(()=>{Object.assign(n.current,Ka({groupId:e}))})}function _o({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=fo(e=>{Va(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=fo((e,t)=>{Va(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=lo(s),v=(0,Z.useRef)(null),[y,b]=co(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=po(v,a);go(_,o);let C=fo((e,t)=>{let r=Xi(),i=ga(e),a=_a(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=mo({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=Ri(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Ri(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=ga(_),i=_a(_);r&&i&&ba(r,{...i,derivedPanelConstraints:Li(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 uo(()=>{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=so(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=_a(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=ya(_,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=La(t.collapsedSize,i[t.panelId]),a=La(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Xi().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)(ho.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})})}_o.displayName=`Group`;function vo(){let e=(0,Z.useContext)(ho);return Q(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function yo(e,t){let{id:n}=vo(),r=(0,Z.useRef)({collapse:ta,expand:ta,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:ta});(0,Z.useImperativeHandle)(t,()=>r.current,[]),uo(()=>{Object.assign(r.current,Ua({groupId:n,panelId:e}))})}function bo({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=lo(c),_=mo({disabled:a}),v=(0,Z.useRef)(null),y=po(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=vo(),T=d!==null,E=fo((e,t,n)=>{d?.(e,c,n)});uo(()=>{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]),yo(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},ee=(0,Z.useSyncExternalStore)(e=>ya(x,e),D,D),O;return O=ee?JSON.parse(ee):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,X.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...xo,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...O},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})})}bo.displayName=`Panel`;var xo={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function So({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=Ha({layout:Ba({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ha({layout:Ba({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Co({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=lo(a),l=mo({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),_=po(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=vo(),C=b===`horizontal`?`vertical`:`horizontal`;uo(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=Zi(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=ya(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(So({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})}Co.displayName=`Separator`;function wo(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function To(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Eo(e){let t=e.split(`/`).filter(e=>e!==``);t.pop();let n=[];for(let e of t)n.push(Oo(n[n.length-1]??``,e));return n}function Do(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function Oo(e,t){return e===``?t:`${e}/${t}`}function ko(e,t){return t===``?e:`${e.replace(/\/+$/,``)}/${t}`}function Ao(e,t){let n=e=>{let t=e.replaceAll(`\\`,`/`).replace(/\/+$/,``);return t===``?`/`:t},r=n(e),i=n(t),a=/^[A-Za-z]:($|\/)/.test(r),o=a?r.toLocaleLowerCase(`en-US`):r,s=a?i.toLocaleLowerCase(`en-US`):i;if(s===o)return``;let c=o===`/`?`/`:`${o}/`;return s.startsWith(c)?i.slice(c.length):null}function jo(e){let t=new Set(e);return e.filter(e=>{if(e===``)return!0;for(let n=To(e);;n=To(n)){if(t.has(n))return!1;if(n===``)return!0}})}var Mo=`application/x-puddle-paths`;function No(e){return JSON.stringify(e)}function Po(e){try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Fo(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=Oo(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 Io(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 Lo(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():null}function Ro(e,t){let n=Lo(e);return n!==null&&t.has(n)}function zo(e,t,n){return`${e}\0${n??``}\0${t}`}function Bo(e,t){let n=Vo(t);dt(n.source?zo(n.source.session,n.source.path,n.source.root):e,n.diagnostics??[]);let r=Ho(n);return M.error(n.message,{id:`err:${n.message}`,duration:2e4,...r?{description:(0,X.jsx)(Rr,{summary:(n.diagnostics?.length?`${n.diagnostics.length} source diagnostic${n.diagnostics.length===1?``:`s`} · `:``)+`Show compiler output`,children:(0,X.jsx)(`pre`,{className:`mt-2 max-h-52 overflow-auto whitespace-pre-wrap break-words font-mono text-2xs leading-snug text-fg-secondary`,children:r})})}:{}}),n}function Vo(e){let t=i.safeParse(e);if(t.success)return t.data;if(e instanceof ne){let t=f.safeParse(e.details);return t.success?{message:e.message,...t.data}:{message:e.message}}return{message:e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Compilation failed`}}function Ho(e){return e.output?.trim()?e.output.trim():(e.diagnostics??[]).map(e=>`${e.source.path}:${e.line}${e.column?`:${e.column}`:``}: ${e.message}`).join(`
|
|
3
|
-
`)}function Uo({target:e,sourceKey:t,leafId:n,onResult:r,onError:i,onRunningChange:a}){let[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(-1),l=(0,Z.useRef)(-1),u=(0,Z.useMemo)(()=>({source:{session:e.source.session,path:e.source.path,...e.source.root===void 0?{}:{root:e.source.root}},...e.provider===void 0?{}:{provider:e.provider},...e.profile_id===void 0?{}:{profile_id:e.profile_id},...e.project_id===void 0?{}:{project_id:e.project_id}}),[e.provider,e.profile_id,e.project_id,e.source.session,e.source.path,e.source.root]);(0,Z.useEffect)(()=>{let e=!1;return s(!1),a(t,!0),Lr({...u,mode:`eager`}).then(i=>{e||(a(t,i.state===`running`),s(!0),i.result&&i.result.revision>c.current&&(c.current=i.result.revision,r(t,n,i.result)))}).catch(n=>{e||(a(t,!1),s(!0),i(t,Vo(n)))}),()=>{e=!0,a(t,!1),Lr({...u,mode:`on_demand`}).catch(()=>void 0)}},[u,t,n,r,i,a]);let d=Pr(u,o).data;return(0,Z.useEffect)(()=>{d&&(a(t,d.state===`running`),d.result&&d.result.revision>c.current&&(c.current=d.result.revision,r(t,n,d.result)),d.state===`failed`&&d.error&&d.revision>l.current&&(l.current=d.revision,i(t,d.error)))},[d,t,n,r,i,a]),null}function Wo({request:e,onOpenChange:t}){let n=Mr(e),r=se();return(0,X.jsx)(Sr,{open:e!==null,onOpenChange:t,children:(0,X.jsxs)(yr,{className:`max-w-xl`,children:[(0,X.jsxs)(_r,{children:[(0,X.jsxs)(br,{children:[n.data?.display_name??`Compilation`,` settings`]}),(0,X.jsxs)(xr,{children:[e?wo(e.source.path):`This file`,` · overrides the language defaults for this file in this project.`]})]}),n.isLoading?(0,X.jsx)(`p`,{className:`py-4 text-sm text-fg-muted`,children:`Loading commands…`}):n.isError?(0,X.jsx)(`p`,{role:`alert`,className:`py-4 text-sm text-danger`,children:n.error instanceof Error?n.error.message:`Couldn’t load commands`}):n.data&&e?(0,X.jsx)(Fr,{settings:n.data,onCancel:()=>t(!1),onSave:async n=>{for(let t of n){let n=await jr({...e,...t});r.setQueryData([`compilation-settings`,e],n)}t(!1)}},JSON.stringify(e)):null]})})}function Go(e){if(e===null)return!1;if(wr(e)===`untitled`){let t=wt(e.path);return t===void 0?!1:(ct({name:e.path,content:t}),!0)}return Be(ft(e.session,e.path,e.root))}function Ko({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 j(`GET`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Ye(n)}`)}catch(e){if(e instanceof ne&&e.status===404)s=!1;else if(e instanceof ne&&e.status===413)s=!0;else throw e}if(s){u(`${a} already exists in ${r}.`);return}await j(`PUT`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Ye(n)}`,{content:e.content}),i!==void 0&&await it(i,e.name).catch(()=>void 0),mt(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)(Sr,{open:e!==null,onOpenChange:e=>!e&&a(),children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Save draft into the worktree`}),(0,X.jsx)(xr,{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)(_,{htmlFor:`untitled-path`,children:`Worktree-relative path`}),(0,X.jsx)(b,{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)(vr,{children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,onClick:a,children:`Cancel`}),(0,X.jsx)(G,{type:`submit`,disabled:d||!t,children:`Save`})]})]})]})})}function qo(e,t){return t??e.root??e.session?.worktree_path??null}function Jo(e,t){return{...e,unpin(){t(),e.unpin()}}}function Yo(e){return{id:o,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 Xo(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?Yo(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 Zo(e,t,n){let r=ko(e.root??t,e.path);if(n!==null){let e=Ao(n,r);if(e!==null)return{directory:n,path:e}}if(e.root===void 0)return{directory:t,path:e.path};let i=ko(e.root,To(e.path));return{directory:i,path:wo(e.path),browseRoot:i}}var Qo=null,$o=null;async function es(){let[e,t]=await Promise.all([k(()=>import(`./PaneEditorBody-Cxn0s84L.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42])),k(()=>import(`./ModelRefcount-CJK-g5rf.js`),__vite__mapDeps([43,1,2,34,6,7,3,4,5,8,12,13,35,36,37]))]);Qo=e.PaneEditorBody,$o=t.ModelRefcount}var ts=(0,Z.lazy)(()=>k(()=>import(`./PaneEditorBody-Cxn0s84L.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,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42])));function ns(e){return Qo?(0,X.jsx)(Qo,{...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)(ts,{...e})})}var rs=(0,Z.lazy)(()=>k(()=>import(`./ModelRefcount-CJK-g5rf.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([43,1,2,34,6,7,3,4,5,8,12,13,35,36,37])));function is({buffers:e}){return $o?(0,X.jsx)($o,{buffers:e}):(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(rs,{buffers:e})})}var as=(0,Z.lazy)(()=>k(()=>import(`./EditorTabClose-DNWGZZN8.js`).then(e=>({default:e.EditorDirtyDot})),__vite__mapDeps([44,1,2,3,18,19,45,46,17,33,32,34,6,7,4,5,8,12,13,35,36,37,38])));function os(e){return(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(as,{...e})})}var ss=(0,Z.lazy)(()=>k(()=>import(`./EditorTabClose-DNWGZZN8.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([44,1,2,3,18,19,45,46,17,33,32,34,6,7,4,5,8,12,13,35,36,37,38])));function cs(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)(ss,{...e})})}var ls=e(n(),1),us=(0,Z.createContext)(null);function ds({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 Sn(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)(us.Provider,{value:f,children:[(0,X.jsx)(`div`,{ref:i,className:`hidden`,"aria-hidden":!0}),u.map(e=>(0,ls.createPortal)((0,X.jsx)(E,{stream:e,paused:!o.has(`term:${e}`),onOpenFile:t=>n(e,t)}),d(e),e)),r]})}function fs(e){let t=(0,Z.useContext)(us),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}function ps({session:e,term:t,ready:n,insertTarget:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(null),c=o!==null;(0,Z.useEffect)(()=>()=>a.current?.abort(),[e,t,n]);let l=o?.stage===`uploading`?Math.floor(o.received/o.total*100):void 0,u=o?.stage===`uploading`?`${l}%`:o?.stage===`saving`?`Saving…`:o?.stage===`inserting`?`Inserting…`:`Preparing…`,d=async i=>{if(!n||a.current)return;let o=new AbortController;a.current=o;let c=r?.();s({stage:`preparing`});try{let{resized:n}=await ar(i,e,t,{signal:o.signal,onProgress:s,insert:c});n&&M(`Image resized for remote access`)}catch(e){o.signal.aborted||M.error(e instanceof Error?e.message:`Could not insert the image.`)}finally{a.current=null,s(null)}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:i,className:`hidden`,type:`file`,accept:ir,"aria-label":`Choose image`,disabled:!n||c,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&d(t)}}),(0,X.jsx)(G,{variant:`ghost`,"aria-label":c?`Cancel image upload`:`Insert image`,title:c?`Cancel image upload`:`Insert image`,"aria-busy":c,disabled:!n||o?.stage===`inserting`,onClick:()=>c?a.current?.abort():i.current?.click(),children:c?(0,X.jsxs)(X.Fragment,{children:[o.stage===`inserting`?(0,X.jsx)(pi,{className:`animate-spin`}):(0,X.jsx)(Pt,{}),(0,X.jsx)(`span`,{role:`progressbar`,"aria-label":`Image upload`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":l,"aria-valuetext":u,className:`text-xs`,children:u})]}):(0,X.jsx)(li,{})})]})}function ms({activate:e,...t}){let n=(0,Z.useRef)(null),r=(0,Z.useRef)(-1/0);return(0,X.jsx)(G,{...t,"data-terminal-key":``,onPointerDown:e=>{e.preventDefault(),e.pointerType!==`touch`&&(r.current=-1/0)},onTouchStart:e=>{let t=e.touches[0];n.current=t&&e.touches.length===1?{x:t.clientX,y:t.clientY,moved:!1}:null},onTouchMove:e=>{let t=e.touches[0];n.current&&(!t||e.touches.length!==1||Math.hypot(t.clientX-n.current.x,t.clientY-n.current.y)>8)&&(n.current.moved=!0)},onTouchCancel:()=>{n.current=null},onTouchEnd:i=>{let a=n.current;n.current=null,!(!a||a.moved||t.disabled)&&(i.preventDefault(),r.current=performance.now(),e())},onClick:t=>{t.detail!==0&&performance.now()-r.current<700||e()}})}function hs(e){return t=>{t.target.closest(`button:not([data-terminal-key])`)||(t.cancelable&&t.preventDefault(),e())}}function gs({session:e,term:t,connected:n,composing:r,toggleComposer:i,insertTarget:a}){let o=nr(e,t)&&n,s=or(e,t),[c,l]=(0,Z.useState)(``),u=n=>{lr(e,t),sr(e,t,n).catch(e=>l(e.message))};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`phone-keys`,role:`toolbar`,"aria-label":`Terminal keys`,onTouchEnd:hs(()=>lr(e,t)),children:[(0,X.jsx)(ps,{session:e,term:t,ready:o,insertTarget:a}),(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,activate:()=>u(`\x1B`),children:`Esc`}),[[`Control`,`⌃`,fr.ctrl],[`Option`,`⌥`,fr.alt],[`Shift`,`⇧`,fr.shift]].map(([n,r,i])=>(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,"aria-label":n,title:n,"aria-pressed":(s&i)!==0,activate:()=>{ur(e,t,i),lr(e,t)},children:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`text-base leading-none`,children:r})},i)),[{label:`Left`,icon:Br,data:`\x1B[D`},{label:`Down`,icon:rt,data:`\x1B[B`},{label:`Up`,icon:ut,data:`\x1B[A`},{label:`Right`,icon:Hr,data:`\x1B[C`}].map(({label:e,icon:t,data:n})=>(0,X.jsx)(ms,{variant:`ghost`,"aria-label":e,disabled:!o,activate:()=>u(n),children:(0,X.jsx)(t,{})},e)),(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,activate:()=>u(` `),children:`Tab`}),(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,activate:()=>u(`\r`),children:`Enter`}),(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,activate:()=>u(``),children:`Ctrl-C`}),(0,X.jsx)(G,{variant:`ghost`,"aria-label":`Compose prompt`,"aria-pressed":r,onClick:i,children:(0,X.jsx)(wi,{})})]}),c&&(0,X.jsx)(`p`,{role:`alert`,className:`px-2 text-xs text-danger`,children:c})]})}function _s({session:e,term:t,connected:n,compact:r=!1}){let i=nr(e,t)&&n,a=u(`puddle.phone.draft:${e}:${t}`),[o,s]=(0,Z.useState)(()=>{try{return sessionStorage.getItem(a)??``}catch{return``}}),c=(0,Z.useRef)(o),l=(0,Z.useRef)(null),d=(0,Z.useRef)(`terminal`);(0,Z.useEffect)(()=>{let e=e=>{e.target.classList?.contains(`xterm-helper-textarea`)&&(d.current=`terminal`)};return document.addEventListener(`focusin`,e),()=>document.removeEventListener(`focusin`,e)},[]);let[f,p]=(0,Z.useState)(!r||!!o),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),v=e=>{c.current=e,s(e);try{e?sessionStorage.setItem(a,e):sessionStorage.removeItem(a)}catch{}},y=e=>{let t=c.current,n=t.slice(0,l.current?.selectionStart??t.length),r=t.slice(l.current?.selectionEnd??t.length);/\S$/.test(n)&&(n+=` `),/^\s/.test(r)&&(e=e.trimEnd()),v(n+e+r);let i=n.length+e.length;requestAnimationFrame(()=>l.current?.setSelectionRange(i,i))},b=async(n,r=!1)=>{if(!(!i||m)){h(!0),_(``);try{await sr(e,t,n,r),r&&v(``)}catch(e){_(e instanceof Error?e.message:`Delivery is uncertain. Check the terminal before resending.`)}finally{h(!1)}}};return(0,X.jsxs)(`div`,{className:`phone-composer`,children:[(0,X.jsx)(gs,{session:e,term:t,connected:n,composing:f,toggleComposer:()=>p(!f),insertTarget:()=>f&&d.current===`prompt`?y:void 0}),f&&(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o&&b(o,!0)},children:[(0,X.jsx)(`textarea`,{ref:l,onFocus:()=>d.current=`prompt`,className:`rounded-md bg-surface p-2 text-base`,"aria-label":`Prompt`,rows:2,value:o,onChange:e=>v(e.target.value),placeholder:`Write a prompt…`,autoCapitalize:`sentences`,autoCorrect:`on`,spellCheck:!0}),(0,X.jsx)(G,{type:`submit`,disabled:!i||m||!o,children:m?`Sending…`:`Send`})]}),g&&(0,X.jsx)(`p`,{role:`alert`,children:g})]})}var vs=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends vs{};function ys(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function bs(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function xs(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Ss(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Cs(e,t){return xs(e,t,``)}function ws(e,t){return Ss(e,t,``)}function Ts(e,t){return t.slice(0,Es(e,t))}function Es(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Ds(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Os(e,t){if(t)return As(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function ks(e,t){if(t)return As(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function As(e,t){if(!t)return[ks(e),Os(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Ds(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var js=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Ms=RegExp(`[${js}]+|\\s+|[^${js}]`,`ug`);new class extends vs{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Ds(e,r)}else n=e.match(Ms)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Ns(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Ns(n,i,r,null,t.intlSegmenter),e}};function Ns(e,t,n,r,i){if(t&&n){let[a,o]=As(t.value,i),[s,c]=As(n.value,i);if(e){let r=ys(a,s);e.value=Ss(e.value,s,r),t.value=Cs(t.value,r),n.value=Cs(n.value,r)}if(r){let e=bs(o,c);r.value=xs(r.value,c,e),t.value=ws(t.value,e),n.value=ws(n.value,e)}}else if(n){if(e){let e=ks(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=ks(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=ks(r.value,i),[a,o]=As(t.value,i),s=ys(n,a);t.value=Cs(t.value,s);let c=bs(Cs(n,s),o);t.value=ws(t.value,c),r.value=xs(r.value,n,c),e.value=Ss(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=ks(r.value,i),n=Ts(Os(t.value,i),e);t.value=ws(t.value,n)}else if(e){let n=Ts(Os(e.value,i),ks(t.value,i));t.value=Cs(t.value,n)}}var Ps=new class extends vs{tokenize(e){let t=RegExp(`(\\r?\\n)|[${js}]+|[^\\S\\n\\r]+|[^${js}]`,`ug`);return e.match(t)||[]}};function Fs(e,t,n){return Ps.diff(e,t,n)}var Is=new class extends vs{constructor(){super(...arguments),this.tokenize=Rs}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-CqLkAxM1.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/auth-BxExwqPW.js","assets/client-settings-CwqpIric.js","assets/preload-helper-Czpn1I53.js","assets/index-BRywm-gU.js","assets/index-XBWIhnuP.css","assets/purify.es-D8QhFVkO.js","assets/katex.min-ZqdHjttS.js","assets/katex-Dz-67XSV.css","assets/editor.api2-4X9Vh9Zw.js","assets/editor-Br_kD0ds.css","assets/dist-7fft9rhQ.js","assets/protocol-support-gmAQBWF3.js","assets/media-refresh-store-DLtYZTP9.js","assets/es2015-CrC2hHeB.js","assets/x-DCpy1q13.js","assets/createLucideIcon-DyMAgLa3.js","assets/recipes-K5GH3Kht.js","assets/dist-DmyIHyF9.js","assets/dist-B67qxih2.js","assets/dist-BCwJL3w9.js","assets/select-YFIOZ3zx.js","assets/chevron-down--sjpQEHH.js","assets/FindWidget-BSK2PIfO.js","assets/whole-word-2m2pmAFT.js","assets/code-DRWf9a5s.js","assets/rotate-ccw-CNjR2LSi.js","assets/popover-C-BfSLgw.js","assets/preview-kind-CJ9RTgbs.js","assets/debounce-B9DrqirV.js","assets/drafts-B_tChlzR.js","assets/buffer-store-CYe-IdNO.js","assets/workers-Ck67TJT4.js","assets/monaco.contribution-C0TYpF88.js","assets/buffer-logic-BAkSBQT7.js","assets/editor-sync-W1bamxAP.js","assets/scroll-restoration-hg7BYUz2.js","assets/math-CSw6sgCC.js","assets/math-delimiters-BCnTi7Ii.js","assets/markdown-mermaid-CF9txXiK.js","assets/ModelRefcount-BasPzO4R.js","assets/EditorTabClose-BV-zQyHT.js","assets/button-Chvl9hcE.js","assets/dialog-Bnex_wlx.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{A as i,D as a,E as o,W as s,Y as c,_ as l,a as u,b as d,k as f,o as p,x as m,y as h}from"./auth-BxExwqPW.js";import{a as g,c as _,f as v,i as y,l as b,n as x,o as S,p as C,r as w,s as T,t as E}from"./LazyTerminal-gX1-vBQf.js";import{i as D,r as ee,t as O}from"./client-settings-CwqpIric.js";import{t as k}from"./preload-helper-Czpn1I53.js";import{l as te,u as A}from"./index-BRywm-gU.js";import{i as j,n as M,r as ne}from"./dist-7fft9rhQ.js";import{At as N,B as P,C as re,Ct as ie,Dt as F,E as ae,Et as I,I as oe,It as se,J as ce,M as le,Nt as ue,Ot as de,P as fe,R as pe,St as L,Y as me,Z as he,a as ge,bt as R,d as _e,f as ve,ft as ye,gt as be,i as xe,it as Se,k as Ce,l as we,p as Te,pt as z,r as Ee,rt as De,s as Oe,st as ke,t as Ae,vt as je,wt as Me,xt as Ne,yt as Pe,z as Fe}from"./protocol-support-gmAQBWF3.js";import{r as Ie}from"./copy-CjatFFf8.js";import{$ as Le,A as Re,B as ze,D as Be,F as Ve,G as He,I as Ue,J as We,L as Ge,N as Ke,O as qe,P as B,Q as Je,R as Ye,T as Xe,U as Ze,V as Qe,X as $e,Z as et,_ as tt,a as nt,at as rt,b as it,c as at,d as ot,et as st,g as ct,i as lt,it as ut,j as dt,k as ft,l as pt,m as mt,nt as ht,o as gt,p as _t,r as vt,rt as yt,s as bt,t as xt,tt as St,u as Ct,v as wt,y as Tt,z as Et}from"./media-refresh-store-DLtYZTP9.js";import{a as Dt,d as Ot,l as kt,n as At,r as jt,t as Mt,u as Nt}from"./project-abbrev-DX_a_ySv.js";import{n as V,t as Pt}from"./x-DCpy1q13.js";import{n as Ft,r as It}from"./dist-BCwJL3w9.js";import{A as Lt,B as Rt,C as zt,D as Bt,E as Vt,F as Ht,I as Ut,J as Wt,K as Gt,L as Kt,M as qt,N as Jt,O as Yt,P as Xt,Q as Zt,R as Qt,S as $t,T as en,V as tn,Y as nn,Z as rn,_ as an,a as on,b as sn,c as cn,et as ln,g as un,h as dn,i as fn,it as pn,j as mn,k as hn,l as gn,n as _n,nt as vn,o as yn,ot as H,rt as U,s as bn,u as xn,v as Sn,w as Cn,x as wn,y as Tn,z as W}from"./use-ui-state-C2LCTPRw.js";import{t as G}from"./button-Chvl9hcE.js";import{t as K}from"./createLucideIcon-DyMAgLa3.js";import{a as En,c as Dn,d as On,f as kn,h as An,i as jn,l as Mn,m as Nn,n as Pn,o as Fn,p as In,r as q,s as Ln,t as Rn,u as zn}from"./context-menu-DVUv5Z6a.js";import{c as Bn,i as Vn,l as Hn,o as Un,t as Wn,u as Gn}from"./switch-OD1b2aeq.js";import{n as Kn,r as qn,t as Jn}from"./whole-word-2m2pmAFT.js";import{a as Yn,i as Xn,n as Zn,r as Qn,t as $n}from"./select-YFIOZ3zx.js";import{t as J}from"./chevron-down--sjpQEHH.js";import{r as er}from"./dist-DmyIHyF9.js";import{b as tr,c as nr,d as rr,g as ir,h as ar,l as or,o as sr,p as cr,r as lr,s as ur,t as dr,u as fr,y as pr}from"./selection-actions-BZy4596m.js";import{n as mr,t as hr}from"./errors-DhRwiizF.js";import{t as gr}from"./ws-oU1ansI7.js";import{a as _r,i as vr,n as yr,o as br,r as xr,t as Sr}from"./dialog-Bnex_wlx.js";import{n as Cr,o as wr}from"./preview-kind-CJ9RTgbs.js";import{a as Tr,t as Er}from"./drafts-B_tChlzR.js";import{i as Dr}from"./buffer-logic-BAkSBQT7.js";import{i as Or,r as kr,t as Ar}from"./scroll-restoration-hg7BYUz2.js";import{a as jr,c as Mr,d as Nr,l as Pr,n as Fr,o as Ir,r as Lr,t as Rr,u as zr}from"./disclosure-7lu23NnB.js";var Br=K(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Vr=K(`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`}]]),Hr=K(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Ur=K(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Wr=K(`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`}]]),Gr=K(`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`}]]),Kr=K(`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`}]]),qr=K(`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=K(`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`}]]),Jr=K(`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`}]]),Yr=K(`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`}]]),Xr=K(`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`}]]),Zr=K(`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`}]]),Qr=K(`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`}]]),$r=K(`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`}]]),ei=K(`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`}]]),ti=K(`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`}]]),ni=K(`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`}]]),ri=K(`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`}]]),ii=K(`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`}]]),ai=K(`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`}]]),oi=K(`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`}]]),si=K(`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`}]]),ci=K(`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`}]]),li=K(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),ui=K(`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`}]]),di=K(`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`}]]),fi=K(`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`}]]),pi=K(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),mi=K(`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`}]]),hi=K(`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`}]]),gi=K(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),_i=K(`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`}]]),vi=K(`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`}]]),yi=K(`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`}]]),bi=K(`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`}]]),xi=K(`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`}]]),Si=K(`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`}]]),Ci=K(`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`}]]),wi=K(`text-cursor-input`,[[`path`,{d:`M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6`,key:`1528k5`}],[`path`,{d:`M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7`,key:`13ksps`}],[`path`,{d:`M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1`,key:`1n9rhb`}],[`path`,{d:`M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1`,key:`1mj8rg`}],[`path`,{d:`M9 6v12`,key:`velyjx`}]]),Ti=K(`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`}]]),Ei=K(`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`}]]),Di=K(`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`}]]),Oi=K(`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=r(),Z=e(t(),1);function ki(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Ai(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function ji(e){return e/100*window.innerHeight}function Mi(e){return e/100*window.innerWidth}function Ni(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 Pi({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Ni(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Ai(t,i);break;case`em`:r=ki(t,i);break;case`vh`:r=ji(i);break;case`vw`:r=Mi(i);break}return r}function Fi(e){return parseFloat(e.toFixed(3))}function Ii({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 Li(e){let{panels:t}=e,n=Ii({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=Fi(Pi({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Fi(Pi({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Fi(Pi({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Fi(Pi({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 Ri(e,t){return Array.from(t).sort(e===`horizontal`?zi:Bi)}function zi(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Bi(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Vi(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Hi(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 Ui({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}=Hi(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Q(i,`No rect found`),i}var Wi;function Gi(){return Wi===void 0&&(Wi=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),Wi}function Ki(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Ri(n,Array.from(t.children).filter(Vi).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,Ui({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=Gi()?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:Ii({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 qi=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)}}},Ji={cursorFlags:0,state:`inactive`},Yi=new qi;function Xi(){return Ji}function Zi(e){return Yi.addListener(`change`,e)}function Qi(e){let t=Ji,n={...Ji};n.cursorFlags=e,Ji=n,Yi.emit(`change`,{prev:t,next:n})}function $i(e){let t=Ji;Ji=e,Yi.emit(`change`,{prev:t,next:e})}var ea=e=>e,ta=()=>{},na=1,ra=2,ia=4,aa=8,oa=3,sa=12,ca;function la(){return ca===void 0&&(ca=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(ca=!0)),ca}function ua({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&&la()){let t=(e&na)!==0,n=(e&ra)!==0,r=(e&ia)!==0,i=(e&aa)!==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 la()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var da=new WeakMap;function fa(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=da.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=Xi();switch(r.state){case`active`:case`hover`:{let e=ua({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}da.set(e,{prevStyle:t,styleSheet:n})}var pa=new Map,ma=new qi;function ha(e){pa=new Map(pa),pa.delete(e)}function ga(e,t){for(let[t]of pa)if(t.id===e)return t}function _a(e,t){for(let[t,n]of pa)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function va(){return pa}function ya(e,t){return ma.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function ba(e,t,n){let r=pa.get(e);pa=new Map(pa),pa.set(e,t),ma.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function xa(e){let t=Xi(),n=!1;switch(t.state){case`active`:$i({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(fa(e),n=!0,t.hitRegions.forEach(e=>{let t=_a(e.group.id,!0);ba(e.group,t,{isUserInteraction:!0})}))}return n}function Sa(e){e.defaultPrevented||xa(e.currentTarget)}function Ca(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Hi(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 wa(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ta(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:ja(e),b:ja(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:Aa(ka(n.a)),b:Aa(ka(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 Ea=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Da(e){let t=getComputedStyle(Ma(e)??e).display;return t===`flex`||t===`inline-flex`}function Oa(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Da(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`||Ea.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function ka(e){let t=e.length;for(;t--;){let n=e[t];if(Q(n,`Missing node`),Oa(n))return n}return null}function Aa(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ja(e){let t=[];for(;e;)t.push(e),e=Ma(e);return t}function Ma(e){let{parentNode:t}=e;return wa(t)?t.host:t}function Na(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 Pa({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Vi(n)||n.contains(e)||e.contains(n))return!0;if(Ta(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Na(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Fa(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Ki(r),a=Ca(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Pa({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Ia(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 La(e,t,n=0){return Math.abs(Fi(e)-Fi(t))<=n}function Ra(e,t){return La(e,t)?0:e>t?1:-1}function za({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(Ra(r,c)<0)if(a){let e=(i+c)/2;r=Ra(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Fi(r),r}function Ba({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(La(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}`),La(n,i)){let t=o-n;Ra(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}`),La(n,o)){let t=n-i;Ra(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&&Ra(i,c)<0)if(e>0){let t=c-o,n=t/2;Ra(i+e,c)<0&&(e=Ra(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Ra(i-e,c)<0&&(e=Ra(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=za({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=za({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!La(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(Ia(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=za({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!La(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=za({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(La(i,s)||(t-=s-i,l[r]=s),La(t,0))break;e>0?r--:r++}}}if(!La(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 Va(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Ra(e[n],t[n])!==0)return!1;return!0}function Ha({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(!La(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=za({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!La(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=za({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,La(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Ua({groupId:e,panelId:t}){let n=()=>{let t=va();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&&La(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:Fi(100-e)}}return Ba({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=Ha({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});Va(c,u)||ba(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&&La(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Ii({group:t}),o=Fi(Pi({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function Wa(e){e.defaultPrevented||Fa(e,va()).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=Ua({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Ga(e){let t=va();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 Ka({groupId:e}){let t=()=>{let t=va();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=Ha({layout:e,panelConstraints:r});return n?o:(Va(o,c)||ba(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function qa(e,t){let n=Ga(e),r=_a(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=Ka({groupId:n.id}).getLayout(),c=Ha({layout:Ba({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Va(s,c)||ba(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function Ja(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Ga(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&qa(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&qa(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&qa(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&qa(t,-5);break;case`End`:e.preventDefault(),qa(t,100);break;case`Enter`:{e.preventDefault();let n=Ga(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=_a(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];qa(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Ga(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(),qa(t,-100);break}}function Ya(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=va(),n=Fa(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)}),$i({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function Xa({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=Ba({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Va(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?na:ra;break;case`vertical`:s|=d<0?ia:aa;break}}else ba(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&oa:c|=s&oa,t.movementY===0?c|=o&sa:c|=s&sa,Qi(c),fa(e)}function Za(e){let t=va(),n=Xi();switch(n.state){case`active`:Xa({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Qa(e){if(e.defaultPrevented)return;let t=Xi(),n=va();switch(t.state){case`active`:if(e.buttons===0){$i({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=_a(e.group.id,!0);ba(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)}Xa({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Fa(e,n);r.length===0?t.state!==`inactive`&&$i({cursorFlags:0,state:`inactive`}):$i({cursorFlags:0,hitRegions:r,state:`hover`}),fa(e.currentTarget);break}}}function $a(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Xi().state){case`hover`:$i({cursorFlags:0,state:`inactive`})}}function eo(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||xa(e.currentTarget)&&e.preventDefault()}function to(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Fi(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Fi((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function no(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Ii({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Fi(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function ro(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 io({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=Fi(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]=Fi((r[e]??0)/a*l);else{let e=Fi(l/c.length);for(let t of c)u[t]=e}return u}function ao(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 oo=new Map;function so(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=Ii({group:e});if(t===0)return;let n=_a(e.id);if(!n)return;let r=Li(e),i=n.defaultLayoutDeferred?to(r):n.layout,a=Ha({layout:io({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Va(n.layout,a)&&ro(n.derivedPanelConstraints,r)&&n.groupSize===t)return;ba(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else no(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=Ii({group:e}),s=Li(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(ao(e.panels,l)||(l=void 0));let u=Ha({layout:e.mutableState.layouts[c]??l??to(s),panelConstraints:s}),d=e.element.ownerDocument;oo.set(d,(oo.get(d)??0)+1);let f=new Map;return Ki(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),ba(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`,Ja)}),oo.get(d)===1&&(d.addEventListener(`contextmenu`,Sa,!0),d.addEventListener(`dblclick`,Wa,!0),d.addEventListener(`pointerdown`,Ya,!0),d.addEventListener(`pointerleave`,Za),d.addEventListener(`pointermove`,Qa),d.addEventListener(`pointerout`,$a),d.addEventListener(`pointerup`,eo,!0)),function(){t=!1,oo.set(d,Math.max(0,(oo.get(d)??0)-1)),ha(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Ja)}),oo.get(d)||(d.removeEventListener(`contextmenu`,Sa,!0),d.removeEventListener(`dblclick`,Wa,!0),d.removeEventListener(`pointerdown`,Ya,!0),d.removeEventListener(`pointerleave`,Za),d.removeEventListener(`pointermove`,Qa),d.removeEventListener(`pointerout`,$a),d.removeEventListener(`pointerup`,eo,!0)),a.disconnect()}}function co(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function lo(e){let t=(0,Z.useId)();return`${e??t}`}var uo=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function fo(e){let t=(0,Z.useRef)(e);return uo(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function po(...e){return fo(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function mo(e){let t=(0,Z.useRef)({...e});return uo(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var ho=(0,Z.createContext)(null);function go(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:ea});(0,Z.useImperativeHandle)(t,()=>n.current,[]),uo(()=>{Object.assign(n.current,Ka({groupId:e}))})}function _o({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=fo(e=>{Va(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=fo((e,t)=>{Va(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=lo(s),v=(0,Z.useRef)(null),[y,b]=co(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=po(v,a);go(_,o);let C=fo((e,t)=>{let r=Xi(),i=ga(e),a=_a(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=mo({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=Ri(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Ri(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=ga(_),i=_a(_);r&&i&&ba(r,{...i,derivedPanelConstraints:Li(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 uo(()=>{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=so(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=_a(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=ya(_,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=La(t.collapsedSize,i[t.panelId]),a=La(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Xi().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)(ho.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})})}_o.displayName=`Group`;function vo(){let e=(0,Z.useContext)(ho);return Q(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function yo(e,t){let{id:n}=vo(),r=(0,Z.useRef)({collapse:ta,expand:ta,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:ta});(0,Z.useImperativeHandle)(t,()=>r.current,[]),uo(()=>{Object.assign(r.current,Ua({groupId:n,panelId:e}))})}function bo({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=lo(c),_=mo({disabled:a}),v=(0,Z.useRef)(null),y=po(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=vo(),T=d!==null,E=fo((e,t,n)=>{d?.(e,c,n)});uo(()=>{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]),yo(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},ee=(0,Z.useSyncExternalStore)(e=>ya(x,e),D,D),O;return O=ee?JSON.parse(ee):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,X.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...xo,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...O},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})})}bo.displayName=`Panel`;var xo={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function So({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=Ha({layout:Ba({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ha({layout:Ba({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Co({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=lo(a),l=mo({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),_=po(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=vo(),C=b===`horizontal`?`vertical`:`horizontal`;uo(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=Zi(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=ya(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(So({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})}Co.displayName=`Separator`;function wo(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function To(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Eo(e){let t=e.split(`/`).filter(e=>e!==``);t.pop();let n=[];for(let e of t)n.push(Oo(n[n.length-1]??``,e));return n}function Do(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function Oo(e,t){return e===``?t:`${e}/${t}`}function ko(e,t){return t===``?e:`${e.replace(/\/+$/,``)}/${t}`}function Ao(e,t){let n=e=>{let t=e.replaceAll(`\\`,`/`).replace(/\/+$/,``);return t===``?`/`:t},r=n(e),i=n(t),a=/^[A-Za-z]:($|\/)/.test(r),o=a?r.toLocaleLowerCase(`en-US`):r,s=a?i.toLocaleLowerCase(`en-US`):i;if(s===o)return``;let c=o===`/`?`/`:`${o}/`;return s.startsWith(c)?i.slice(c.length):null}function jo(e){let t=new Set(e);return e.filter(e=>{if(e===``)return!0;for(let n=To(e);;n=To(n)){if(t.has(n))return!1;if(n===``)return!0}})}var Mo=`application/x-puddle-paths`;function No(e){return JSON.stringify(e)}function Po(e){try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Fo(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=Oo(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 Io(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 Lo(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():null}function Ro(e,t){let n=Lo(e);return n!==null&&t.has(n)}function zo(e,t,n){return`${e}\0${n??``}\0${t}`}function Bo(e,t){let n=Vo(t);dt(n.source?zo(n.source.session,n.source.path,n.source.root):e,n.diagnostics??[]);let r=Ho(n);return M.error(n.message,{id:`err:${n.message}`,duration:2e4,...r?{description:(0,X.jsx)(Rr,{summary:(n.diagnostics?.length?`${n.diagnostics.length} source diagnostic${n.diagnostics.length===1?``:`s`} · `:``)+`Show compiler output`,children:(0,X.jsx)(`pre`,{className:`mt-2 max-h-52 overflow-auto whitespace-pre-wrap break-words font-mono text-2xs leading-snug text-fg-secondary`,children:r})})}:{}}),n}function Vo(e){let t=i.safeParse(e);if(t.success)return t.data;if(e instanceof ne){let t=f.safeParse(e.details);return t.success?{message:e.message,...t.data}:{message:e.message}}return{message:e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Compilation failed`}}function Ho(e){return e.output?.trim()?e.output.trim():(e.diagnostics??[]).map(e=>`${e.source.path}:${e.line}${e.column?`:${e.column}`:``}: ${e.message}`).join(`
|
|
3
|
+
`)}function Uo({target:e,sourceKey:t,leafId:n,onResult:r,onError:i,onRunningChange:a}){let[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(-1),l=(0,Z.useRef)(-1),u=(0,Z.useMemo)(()=>({source:{session:e.source.session,path:e.source.path,...e.source.root===void 0?{}:{root:e.source.root}},...e.provider===void 0?{}:{provider:e.provider},...e.profile_id===void 0?{}:{profile_id:e.profile_id},...e.project_id===void 0?{}:{project_id:e.project_id}}),[e.provider,e.profile_id,e.project_id,e.source.session,e.source.path,e.source.root]);(0,Z.useEffect)(()=>{let e=!1;return s(!1),a(t,!0),Lr({...u,mode:`eager`}).then(i=>{e||(a(t,i.state===`running`),s(!0),i.result&&i.result.revision>c.current&&(c.current=i.result.revision,r(t,n,i.result)))}).catch(n=>{e||(a(t,!1),s(!0),i(t,Vo(n)))}),()=>{e=!0,a(t,!1),Lr({...u,mode:`on_demand`}).catch(()=>void 0)}},[u,t,n,r,i,a]);let d=Pr(u,o).data;return(0,Z.useEffect)(()=>{d&&(a(t,d.state===`running`),d.result&&d.result.revision>c.current&&(c.current=d.result.revision,r(t,n,d.result)),d.state===`failed`&&d.error&&d.revision>l.current&&(l.current=d.revision,i(t,d.error)))},[d,t,n,r,i,a]),null}function Wo({request:e,onOpenChange:t}){let n=Mr(e),r=se();return(0,X.jsx)(Sr,{open:e!==null,onOpenChange:t,children:(0,X.jsxs)(yr,{className:`max-w-xl`,children:[(0,X.jsxs)(_r,{children:[(0,X.jsxs)(br,{children:[n.data?.display_name??`Compilation`,` settings`]}),(0,X.jsxs)(xr,{children:[e?wo(e.source.path):`This file`,` · overrides the language defaults for this file in this project.`]})]}),n.isLoading?(0,X.jsx)(`p`,{className:`py-4 text-sm text-fg-muted`,children:`Loading commands…`}):n.isError?(0,X.jsx)(`p`,{role:`alert`,className:`py-4 text-sm text-danger`,children:n.error instanceof Error?n.error.message:`Couldn’t load commands`}):n.data&&e?(0,X.jsx)(Fr,{settings:n.data,onCancel:()=>t(!1),onSave:async n=>{for(let t of n){let n=await jr({...e,...t});r.setQueryData([`compilation-settings`,e],n)}t(!1)}},JSON.stringify(e)):null]})})}function Go(e){if(e===null)return!1;if(wr(e)===`untitled`){let t=wt(e.path);return t===void 0?!1:(ct({name:e.path,content:t}),!0)}return Be(ft(e.session,e.path,e.root))}function Ko({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 j(`GET`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Ye(n)}`)}catch(e){if(e instanceof ne&&e.status===404)s=!1;else if(e instanceof ne&&e.status===413)s=!0;else throw e}if(s){u(`${a} already exists in ${r}.`);return}await j(`PUT`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Ye(n)}`,{content:e.content}),i!==void 0&&await it(i,e.name).catch(()=>void 0),mt(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)(Sr,{open:e!==null,onOpenChange:e=>!e&&a(),children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Save draft into the worktree`}),(0,X.jsx)(xr,{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)(_,{htmlFor:`untitled-path`,children:`Worktree-relative path`}),(0,X.jsx)(b,{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)(vr,{children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,onClick:a,children:`Cancel`}),(0,X.jsx)(G,{type:`submit`,disabled:d||!t,children:`Save`})]})]})]})})}function qo(e,t){return t??e.root??e.session?.worktree_path??null}function Jo(e,t){return{...e,unpin(){t(),e.unpin()}}}function Yo(e){return{id:o,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 Xo(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?Yo(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 Zo(e,t,n){let r=ko(e.root??t,e.path);if(n!==null){let e=Ao(n,r);if(e!==null)return{directory:n,path:e}}if(e.root===void 0)return{directory:t,path:e.path};let i=ko(e.root,To(e.path));return{directory:i,path:wo(e.path),browseRoot:i}}var Qo=null,$o=null;async function es(){let[e,t]=await Promise.all([k(()=>import(`./PaneEditorBody-CqLkAxM1.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42])),k(()=>import(`./ModelRefcount-BasPzO4R.js`),__vite__mapDeps([43,1,2,34,6,7,3,4,5,8,12,13,35,36,37]))]);Qo=e.PaneEditorBody,$o=t.ModelRefcount}var ts=(0,Z.lazy)(()=>k(()=>import(`./PaneEditorBody-CqLkAxM1.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,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42])));function ns(e){return Qo?(0,X.jsx)(Qo,{...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)(ts,{...e})})}var rs=(0,Z.lazy)(()=>k(()=>import(`./ModelRefcount-BasPzO4R.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([43,1,2,34,6,7,3,4,5,8,12,13,35,36,37])));function is({buffers:e}){return $o?(0,X.jsx)($o,{buffers:e}):(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(rs,{buffers:e})})}var as=(0,Z.lazy)(()=>k(()=>import(`./EditorTabClose-BV-zQyHT.js`).then(e=>({default:e.EditorDirtyDot})),__vite__mapDeps([44,1,2,3,18,19,45,46,17,33,32,34,6,7,4,5,8,12,13,35,36,37,38])));function os(e){return(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(as,{...e})})}var ss=(0,Z.lazy)(()=>k(()=>import(`./EditorTabClose-BV-zQyHT.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([44,1,2,3,18,19,45,46,17,33,32,34,6,7,4,5,8,12,13,35,36,37,38])));function cs(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)(ss,{...e})})}var ls=e(n(),1),us=(0,Z.createContext)(null);function ds({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 Sn(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)(us.Provider,{value:f,children:[(0,X.jsx)(`div`,{ref:i,className:`hidden`,"aria-hidden":!0}),u.map(e=>(0,ls.createPortal)((0,X.jsx)(E,{stream:e,paused:!o.has(`term:${e}`),onOpenFile:t=>n(e,t)}),d(e),e)),r]})}function fs(e){let t=(0,Z.useContext)(us),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}function ps({session:e,term:t,ready:n,insertTarget:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(null),c=o!==null;(0,Z.useEffect)(()=>()=>a.current?.abort(),[e,t,n]);let l=o?.stage===`uploading`?Math.floor(o.received/o.total*100):void 0,u=o?.stage===`uploading`?`${l}%`:o?.stage===`saving`?`Saving…`:o?.stage===`inserting`?`Inserting…`:`Preparing…`,d=async i=>{if(!n||a.current)return;let o=new AbortController;a.current=o;let c=r?.();s({stage:`preparing`});try{let{resized:n}=await ar(i,e,t,{signal:o.signal,onProgress:s,insert:c});n&&M(`Image resized for remote access`)}catch(e){o.signal.aborted||M.error(e instanceof Error?e.message:`Could not insert the image.`)}finally{a.current=null,s(null)}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:i,className:`hidden`,type:`file`,accept:ir,"aria-label":`Choose image`,disabled:!n||c,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&d(t)}}),(0,X.jsx)(G,{variant:`ghost`,"aria-label":c?`Cancel image upload`:`Insert image`,title:c?`Cancel image upload`:`Insert image`,"aria-busy":c,disabled:!n||o?.stage===`inserting`,onClick:()=>c?a.current?.abort():i.current?.click(),children:c?(0,X.jsxs)(X.Fragment,{children:[o.stage===`inserting`?(0,X.jsx)(pi,{className:`animate-spin`}):(0,X.jsx)(Pt,{}),(0,X.jsx)(`span`,{role:`progressbar`,"aria-label":`Image upload`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":l,"aria-valuetext":u,className:`text-xs`,children:u})]}):(0,X.jsx)(li,{})})]})}function ms({activate:e,...t}){let n=(0,Z.useRef)(null),r=(0,Z.useRef)(-1/0);return(0,X.jsx)(G,{...t,"data-terminal-key":``,onPointerDown:e=>{e.preventDefault(),e.pointerType!==`touch`&&(r.current=-1/0)},onTouchStart:e=>{let t=e.touches[0];n.current=t&&e.touches.length===1?{x:t.clientX,y:t.clientY,moved:!1}:null},onTouchMove:e=>{let t=e.touches[0];n.current&&(!t||e.touches.length!==1||Math.hypot(t.clientX-n.current.x,t.clientY-n.current.y)>8)&&(n.current.moved=!0)},onTouchCancel:()=>{n.current=null},onTouchEnd:i=>{let a=n.current;n.current=null,!(!a||a.moved||t.disabled)&&(i.preventDefault(),r.current=performance.now(),e())},onClick:t=>{t.detail!==0&&performance.now()-r.current<700||e()}})}function hs(e){return t=>{t.target.closest(`button:not([data-terminal-key])`)||(t.cancelable&&t.preventDefault(),e())}}function gs({session:e,term:t,connected:n,composing:r,toggleComposer:i,insertTarget:a}){let o=nr(e,t)&&n,s=or(e,t),[c,l]=(0,Z.useState)(``),u=n=>{lr(e,t),sr(e,t,n).catch(e=>l(e.message))};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`phone-keys`,role:`toolbar`,"aria-label":`Terminal keys`,onTouchEnd:hs(()=>lr(e,t)),children:[(0,X.jsx)(ps,{session:e,term:t,ready:o,insertTarget:a}),(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,activate:()=>u(`\x1B`),children:`Esc`}),[[`Control`,`⌃`,fr.ctrl],[`Option`,`⌥`,fr.alt],[`Shift`,`⇧`,fr.shift]].map(([n,r,i])=>(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,"aria-label":n,title:n,"aria-pressed":(s&i)!==0,activate:()=>{ur(e,t,i),lr(e,t)},children:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`text-base leading-none`,children:r})},i)),[{label:`Left`,icon:Br,data:`\x1B[D`},{label:`Down`,icon:rt,data:`\x1B[B`},{label:`Up`,icon:ut,data:`\x1B[A`},{label:`Right`,icon:Hr,data:`\x1B[C`}].map(({label:e,icon:t,data:n})=>(0,X.jsx)(ms,{variant:`ghost`,"aria-label":e,disabled:!o,activate:()=>u(n),children:(0,X.jsx)(t,{})},e)),(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,activate:()=>u(` `),children:`Tab`}),(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,activate:()=>u(`\r`),children:`Enter`}),(0,X.jsx)(ms,{variant:`ghost`,disabled:!o,activate:()=>u(``),children:`Ctrl-C`}),(0,X.jsx)(G,{variant:`ghost`,"aria-label":`Compose prompt`,"aria-pressed":r,onClick:i,children:(0,X.jsx)(wi,{})})]}),c&&(0,X.jsx)(`p`,{role:`alert`,className:`px-2 text-xs text-danger`,children:c})]})}function _s({session:e,term:t,connected:n,compact:r=!1}){let i=nr(e,t)&&n,a=u(`puddle.phone.draft:${e}:${t}`),[o,s]=(0,Z.useState)(()=>{try{return sessionStorage.getItem(a)??``}catch{return``}}),c=(0,Z.useRef)(o),l=(0,Z.useRef)(null),d=(0,Z.useRef)(`terminal`);(0,Z.useEffect)(()=>{let e=e=>{e.target.classList?.contains(`xterm-helper-textarea`)&&(d.current=`terminal`)};return document.addEventListener(`focusin`,e),()=>document.removeEventListener(`focusin`,e)},[]);let[f,p]=(0,Z.useState)(!r||!!o),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),v=e=>{c.current=e,s(e);try{e?sessionStorage.setItem(a,e):sessionStorage.removeItem(a)}catch{}},y=e=>{let t=c.current,n=t.slice(0,l.current?.selectionStart??t.length),r=t.slice(l.current?.selectionEnd??t.length);/\S$/.test(n)&&(n+=` `),/^\s/.test(r)&&(e=e.trimEnd()),v(n+e+r);let i=n.length+e.length;requestAnimationFrame(()=>l.current?.setSelectionRange(i,i))},b=async(n,r=!1)=>{if(!(!i||m)){h(!0),_(``);try{await sr(e,t,n,r),r&&v(``)}catch(e){_(e instanceof Error?e.message:`Delivery is uncertain. Check the terminal before resending.`)}finally{h(!1)}}};return(0,X.jsxs)(`div`,{className:`phone-composer`,children:[(0,X.jsx)(gs,{session:e,term:t,connected:n,composing:f,toggleComposer:()=>p(!f),insertTarget:()=>f&&d.current===`prompt`?y:void 0}),f&&(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o&&b(o,!0)},children:[(0,X.jsx)(`textarea`,{ref:l,onFocus:()=>d.current=`prompt`,className:`rounded-md bg-surface p-2 text-base`,"aria-label":`Prompt`,rows:2,value:o,onChange:e=>v(e.target.value),placeholder:`Write a prompt…`,autoCapitalize:`sentences`,autoCorrect:`on`,spellCheck:!0}),(0,X.jsx)(G,{type:`submit`,disabled:!i||m||!o,children:m?`Sending…`:`Send`})]}),g&&(0,X.jsx)(`p`,{role:`alert`,children:g})]})}var vs=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends vs{};function ys(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function bs(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function xs(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Ss(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Cs(e,t){return xs(e,t,``)}function ws(e,t){return Ss(e,t,``)}function Ts(e,t){return t.slice(0,Es(e,t))}function Es(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Ds(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Os(e,t){if(t)return As(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function ks(e,t){if(t)return As(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function As(e,t){if(!t)return[ks(e),Os(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Ds(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var js=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Ms=RegExp(`[${js}]+|\\s+|[^${js}]`,`ug`);new class extends vs{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Ds(e,r)}else n=e.match(Ms)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Ns(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Ns(n,i,r,null,t.intlSegmenter),e}};function Ns(e,t,n,r,i){if(t&&n){let[a,o]=As(t.value,i),[s,c]=As(n.value,i);if(e){let r=ys(a,s);e.value=Ss(e.value,s,r),t.value=Cs(t.value,r),n.value=Cs(n.value,r)}if(r){let e=bs(o,c);r.value=xs(r.value,c,e),t.value=ws(t.value,e),n.value=ws(n.value,e)}}else if(n){if(e){let e=ks(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=ks(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=ks(r.value,i),[a,o]=As(t.value,i),s=ys(n,a);t.value=Cs(t.value,s);let c=bs(Cs(n,s),o);t.value=ws(t.value,c),r.value=xs(r.value,n,c),e.value=Ss(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=ks(r.value,i),n=Ts(Os(t.value,i),e);t.value=ws(t.value,n)}else if(e){let n=Ts(Os(e.value,i),ks(t.value,i));t.value=Cs(t.value,n)}}var Ps=new class extends vs{tokenize(e){let t=RegExp(`(\\r?\\n)|[${js}]+|[^\\S\\n\\r]+|[^${js}]`,`ug`);return e.match(t)||[]}};function Fs(e,t,n){return Ps.diff(e,t,n)}var Is=new class extends vs{constructor(){super(...arguments),this.tokenize=Rs}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
4
4
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
5
5
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
6
6
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
@@ -17,4 +17,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jk
|
|
|
17
17
|
To pick up a draggable item, press the space bar.
|
|
18
18
|
While dragging, use the arrow keys to move the item.
|
|
19
19
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
20
|
-
`},Sd={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 Cd(e){let{announcements:t=Sd,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=xd}=e,{announce:a,announcement:o}=_d(),s=rd(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),yd((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(hd,{id:r,value:i.draggable}),Z.createElement(gd,{id:s,announcement:o}));return n?(0,ls.createPortal)(u,n):u}var wd;(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`})(wd||={});function Td(){}function Ed(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Dd(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Od=Object.freeze({x:0,y:0});function kd(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Ad(e,t){let n=ud(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 jd(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Md(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Nd(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 Pd(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Fd(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 Id=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=Fd(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Md)};function Ld(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 Rd=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&&Ld(r,a)){let n=Nd(a).reduce((e,t)=>e+kd(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(jd)};function zd(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Bd(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Od}function Vd(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 Hd=Vd(1);function Ud(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 Wd(e,t,n){let r=Ud(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 Gd={ignoreTransform:!1};function Kd(e,t){t===void 0&&(t=Gd);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Wu(e).getComputedStyle(e);t&&(n=Wd(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 qd(e){return Kd(e,{ignoreTransform:!0})}function Jd(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Yd(e,t){return t===void 0&&(t=Wu(e).getComputedStyle(e)),t.position===`fixed`}function Xd(e,t){t===void 0&&(t=Wu(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 Zd(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Gu(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ku(i)||qu(i)||n.includes(i))return n;let a=Wu(e).getComputedStyle(i);return i!==e&&Xd(i,a)&&n.push(i),Yd(i,a)?n:r(i.parentNode)}return e?r(e):n}function Qd(e){let[t]=Zd(e,1);return t??null}function $d(e){return!Vu||!e?null:Hu(e)?e:Uu(e)?Gu(e)||e===Ju(e).scrollingElement?window:Ku(e)?e:null:null}function ef(e){return Hu(e)?e.scrollX:e.scrollLeft}function tf(e){return Hu(e)?e.scrollY:e.scrollTop}function nf(e){return{x:ef(e),y:tf(e)}}var rf;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(rf||={});function af(e){return!Vu||!e?!1:e===document.scrollingElement}function of(e){let t={x:0,y:0},n=af(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 sf={x:.2,y:.2};function cf(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=sf);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=of(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=rf.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=rf.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=rf.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=rf.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function lf(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 uf(e){return e.reduce((e,t)=>ad(e,nf(t)),Od)}function df(e){return e.reduce((e,t)=>e+ef(t),0)}function ff(e){return e.reduce((e,t)=>e+tf(t),0)}function pf(e,t){if(t===void 0&&(t=Kd),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Qd(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var mf=[[`x`,[`left`,`right`],df],[`y`,[`top`,`bottom`],ff]],hf=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=Zd(t),r=uf(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of mf)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})}},gf=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 _f(e){let{EventTarget:t}=Wu(e);return e instanceof t?e:Ju(e)}function vf(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 yf;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(yf||={});function bf(e){e.preventDefault()}function xf(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 Sf={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},Cf=(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}}},wf=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 gf(Ju(t)),this.windowListeners=new gf(Wu(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(yf.Resize,this.handleCancel),this.windowListeners.add(yf.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(yf.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&pf(n),t(Od)}handleKeyDown(e){if(cd(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Sf,coordinateGetter:a=Cf,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}:Od;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=od(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}=of(n),p=lf(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,ad(od(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()}};wf.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Sf,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 Tf(e){return!!(e&&`distance`in e)}function Ef(e){return!!(e&&`delay`in e)}var Df=class{constructor(e,t,n){n===void 0&&(n=_f(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=Ju(i),this.documentListeners=new gf(this.document),this.listeners=new gf(n),this.windowListeners=new gf(Wu(i)),this.initialCoordinates=ud(r)??Od,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(yf.Resize,this.handleCancel),this.windowListeners.add(yf.DragStart,bf),this.windowListeners.add(yf.VisibilityChange,this.handleCancel),this.windowListeners.add(yf.ContextMenu,bf),this.documentListeners.add(yf.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ef(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Tf(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(yf.Click,xf,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(yf.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=ud(e)??Od,s=od(n,o);if(!t&&a){if(Tf(a)){if(a.tolerance!=null&&vf(s,a.tolerance))return this.handleCancel();if(vf(s,a.distance))return this.handleStart()}if(Ef(a)&&vf(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()}},Of={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},kf=class extends Df{constructor(e){let{event:t}=e,n=Ju(t.target);super(e,Of,n)}};kf.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 Af={move:{name:`mousemove`},end:{name:`mouseup`}},jf;(function(e){e[e.RightClick=2]=`RightClick`})(jf||={});var Mf=class extends Df{constructor(e){super(e,Af,Ju(e.event.target))}};Mf.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===jf.RightClick?!1:(r?.({event:n}),!0)}}];var Nf={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Pf=class extends Df{constructor(e){super(e,Nf)}static setup(){return window.addEventListener(Nf.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Nf.move.name,e)};function e(){}}};Pf.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 Ff;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Ff||={});var If;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(If||={});function Lf(e){let{acceleration:t,activator:n=Ff.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=If.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=zf({delta:d,disabled:!a}),[m,h]=Zu(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case Ff.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Ff.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===If.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}=cf(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 Rf={x:{[rf.Backward]:!1,[rf.Forward]:!1},y:{[rf.Backward]:!1,[rf.Forward]:!1}};function zf(e){let{delta:t,disabled:n}=e,r=td(t);return $u(e=>{if(n||!r||!e)return Rf;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[rf.Backward]:e.x[rf.Backward]||i.x===-1,[rf.Forward]:e.x[rf.Forward]||i.x===1},y:{[rf.Backward]:e.y[rf.Backward]||i.y===-1,[rf.Forward]:e.y[rf.Forward]||i.y===1}}},[n,t,r])}function Bf(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return $u(e=>t==null?null:r??e??null,[r,t])}function Vf(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 Hf;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Hf||={});var Uf;(function(e){e.Optimized=`optimized`})(Uf||={});var Wf=new Map;function Gf(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=Qu(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=$u(t=>{if(d&&!n)return Wf;if(!t||t===Wf||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 hf(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 Hf.Always:return!1;case Hf.BeforeDragging:return n;default:return!n}}}function Kf(e,t){return $u(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function qf(e,t){return Kf(e,t)}function Jf(e){let{callback:t,disabled:n}=e,r=Xu(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 Yf(e){let{callback:t,disabled:n}=e,r=Xu(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 Xf(e){return new hf(Kd(e),e)}function Zf(e,t,n){t===void 0&&(t=Xf);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=Jf({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=Yf({callback:a});return Yu(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Qf(e){return Bd(e,Kf(e))}var $f=[];function ep(e){let t=(0,Z.useRef)(e),n=$u(n=>e?n&&n!==$f&&e&&t.current&&e.parentNode===t.current.parentNode?n:Zd(e):$f,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function tp(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=$d(e.target);t&&n(e=>e?(e.set(t,nf(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=$d(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,nf(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=>{$d(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>ad(e,t),Od):uf(e):Od,[e,t])}function np(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!==Od;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?od(e,n.current):Od}function rp(e){(0,Z.useEffect)(()=>{if(!Vu)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 ip(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 ap(e){return(0,Z.useMemo)(()=>e?Jd(e):null,[e])}var op=[];function sp(e,t){t===void 0&&(t=Kd);let[n]=e,r=ap(n?Wu(n):null),[i,a]=(0,Z.useState)(op);function o(){a(()=>e.length?e.map(e=>af(e)?r:new hf(t(e),e)):op)}let s=Yf({callback:o});return Yu(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function cp(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Ku(t)?t:e}function lp(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=Yf({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(Ku(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=ed((0,Z.useCallback)(e=>{let n=cp(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 up=[{sensor:kf,options:{}},{sensor:wf,options:{}}],dp={current:{}},fp={draggable:{measure:qd},droppable:{measure:qd,strategy:Hf.WhileDragging,frequency:Uf.Optimized},dragOverlay:{measure:Kd}},pp=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}},mp={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new pp,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Td},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:fp,measureDroppableContainers:Td,windowRect:null,measuringScheduled:!1},hp={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Td,draggableNodes:new Map,over:null,measureDroppableContainers:Td},gp=(0,Z.createContext)(hp),_p=(0,Z.createContext)(mp);function vp(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new pp}}}function yp(e,t){switch(t.type){case wd.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case wd.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 wd.DragEnd:case wd.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case wd.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new pp(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case wd.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 pp(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case wd.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new pp(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function bp(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(gp),a=td(r),o=td(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!cd(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=pd(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function xp(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Sp(e){return(0,Z.useMemo)(()=>({draggable:{...fp.draggable,...e?.draggable},droppable:{...fp.droppable,...e?.droppable},dragOverlay:{...fp.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Cp(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;Yu(()=>{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=Bd(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=Qd(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var wp=(0,Z.createContext)({...Od,scaleX:1,scaleY:1}),Tp;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Tp||={});var Ep=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=up,collisionDetection:o=Id,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(yp,void 0,vp),[f,p]=bd(),[m,h]=(0,Z.useState)(Tp.Uninitialized),g=m===Tp.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??dp,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,ee]=(0,Z.useState)(null),O=Qu(l,Object.values(l)),k=rd(`DndDescribedBy`,t),te=(0,Z.useMemo)(()=>b.getEnabled(),[b]),A=Sp(s),{droppableRects:j,measureDroppableContainers:M,measuringScheduled:ne}=Gf(te,{dragging:g,dependencies:[y.x,y.y],config:A.droppable}),N=Bf(v,_),P=(0,Z.useMemo)(()=>D?ud(D):null,[D]),re=ke(),ie=qf(N,A.draggable.measure);Cp({activeNode:_==null?null:v.get(_),config:re.layoutShiftCompensation,initialRect:ie,measure:A.draggable.measure});let F=Zf(N,A.draggable.measure,ie),ae=Zf(N?N.parentElement:null),I=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:N,collisionRect:null,collisions:null,droppableRects:j,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=b.getNodeFor(I.current.over?.id),se=lp({measure:A.dragOverlay.measure}),ce=se.nodeRef.current??N,le=g?se.rect??F:null,ue=!!(se.nodeRef.current&&se.rect),de=Qf(ue?null:F),fe=ap(ce?Wu(ce):null),pe=ep(g?oe??N:null),L=sp(pe),me=xp(c,{transform:{x:y.x-de.x,y:y.y-de.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:F,containerNodeRect:ae,draggingNodeRect:le,over:I.current.over,overlayNodeRect:se.rect,scrollableAncestors:pe,scrollableAncestorRects:L,windowRect:fe}),he=P?ad(P,y):null,ge=tp(pe),R=np(ge),_e=np(ge,[F]),ve=ad(me,R),ye=le?Hd(le,me):null,be=C&&ye?o({active:C,collisionRect:ye,droppableRects:j,droppableContainers:te,pointerCoordinates:he}):null,xe=Pd(be,`id`),[Se,Ce]=(0,Z.useState)(null),we=zd(ue?me:ad(me,_e),Se?.rect??null,F),Te=(0,Z.useRef)(null),z=(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:I,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=O.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=O.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=O.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ls.unstable_batchedUpdates)(()=>{r?.(i),h(Tp.Initializing),d({type:wd.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Te.current),ee(a)})},onMove(e){d({type:wd.DragMove,coordinates:e})},onEnd:s(wd.DragEnd),onCancel:s(wd.DragCancel)});Te.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=I.current,o=null;if(t&&i){let{cancelDrop:s}=O.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===wd.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=wd.DragCancel)}w.current=null,(0,ls.unstable_batchedUpdates)(()=>{d({type:e}),h(Tp.Uninitialized),Ce(null),E(null),ee(null),Te.current=null;let t=e===wd.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=O.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Ee=Vf(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,z(n,t))},[v,z]));rp(a),Yu(()=>{F&&m===Tp.Initializing&&h(Tp.Initialized)},[F,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=O.current,{active:t,activatorEvent:n,collisions:r,over:i}=I.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ve.x,y:ve.y},over:i};(0,ls.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ve.x,ve.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=I.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=O.current,o=r.get(xe),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,ls.unstable_batchedUpdates)(()=>{Ce(s),a?.(c),f({type:`onDragOver`,event:c})})},[xe]),Yu(()=>{I.current={activatorEvent:D,active:C,activeNode:N,collisionRect:ye,collisions:be,droppableRects:j,draggableNodes:v,draggingNode:ce,draggingNodeRect:le,droppableContainers:b,over:Se,scrollableAncestors:pe,scrollAdjustedTranslate:ve},S.current={initial:le,translated:ye}},[C,N,be,ye,v,ce,le,j,b,Se,pe,ve]),Lf({...re,delta:y,draggingRect:ye,pointerCoordinates:he,scrollableAncestors:pe,scrollableAncestorRects:L});let De=(0,Z.useMemo)(()=>({active:C,activeNode:N,activeNodeRect:F,activatorEvent:D,collisions:be,containerNodeRect:ae,dragOverlay:se,draggableNodes:v,droppableContainers:b,droppableRects:j,over:Se,measureDroppableContainers:M,scrollableAncestors:pe,scrollableAncestorRects:L,measuringConfiguration:A,measuringScheduled:ne,windowRect:fe}),[C,N,F,D,be,ae,se,v,b,j,Se,M,pe,L,A,ne,fe]),Oe=(0,Z.useMemo)(()=>({activatorEvent:D,activators:Ee,active:C,activeNodeRect:F,ariaDescribedById:{draggable:k},dispatch:d,draggableNodes:v,over:Se,measureDroppableContainers:M}),[D,Ee,C,F,d,k,v,Se,M]);return Z.createElement(vd.Provider,{value:p},Z.createElement(gp.Provider,{value:Oe},Z.createElement(_p.Provider,{value:De},Z.createElement(wp.Provider,{value:we},i)),Z.createElement(bp,{disabled:n?.restoreFocus===!1})),Z.createElement(Cd,{...n,hiddenTextDescribedById:k}));function ke(){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}}}),Dp=(0,Z.createContext)(null),Op=`button`,kp=`Draggable`;function Ap(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=rd(kp),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(gp),{role:p=Op,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?wp:Dp),[v,y]=ed(),[b,x]=ed(),S=ip(o,t),C=Qu(n);return Yu(()=>(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===Op?!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 jp(){return(0,Z.useContext)(_p)}var Mp=`Droppable`,Np={timeout:25};function Pp(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=rd(Mp),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(gp),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}={...Np,...i},_=Qu(h??r),v=Yf({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]=ed((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Qu(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:wd.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:wd.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:wd.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 Fp(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=td(n);return!n&&!r&&s&&i(s),Yu(()=>{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 Ip={x:0,y:0,scaleX:1,scaleY:1};function Lp(e){let{children:t}=e;return Z.createElement(gp.Provider,{value:hp},Z.createElement(wp.Provider,{value:Ip},t))}var Rp={position:`fixed`,touchAction:`none`},zp=e=>cd(e)?`transform 250ms ease`:void 0,Bp=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=zp}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Rp,width:s.width,height:s.height,top:s.top,left:s.left,transform:dd.Transform.toString(d),transformOrigin:i&&r?Ad(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),Vp={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:dd.Transform.toString(t)},{transform:dd.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 Hp(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Xu((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=cp(a);if(!c)return;let{transform:l}=Wu(a).getComputedStyle(a),u=Ud(l);if(!u)return;let d=typeof t==`function`?t:Up(t);return pf(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 Up(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Vp,...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 Wp=0;function Gp(e){return(0,Z.useMemo)(()=>{if(e!=null)return Wp++,Wp},[e])}var Kp=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}=jp(),S=(0,Z.useContext)(wp),C=Gp(d?.id),w=xp(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=Kf(f),E=Hp({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(Lp,null,Z.createElement(Fp,{animation:E},d&&C?Z.createElement(Bp,{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 qp({status:e,kind:t=`agent`,agentType:n,detectedAgentType:r,stale:i=!1,className:a,iconClassName:o=`size-3`,iconStrokeScale:s=1}){let c=t===`terminal`?r:n,l=`${t===`terminal`?c?`${c} in terminal`:`terminal`:c??`agent`} — status: ${e.replace(`_`,` `)}${i?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,X.jsx)(`span`,{className:V(`status-glyph`,a),"data-status":e,"data-kind":t,"data-stale":i||void 0,role:`img`,title:i?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":l,children:t===`terminal`&&!c?(0,X.jsx)(Mt,{className:o,strokeWidth:2*s}):(0,X.jsx)(Gt,{type:c??``,className:o,strokeScale:s})})}var Jp=[`starting`,`running`,`waiting_input`],Yp=[`exited`,`interrupted`],Xp={Item:nt,Separator:gt,Sub:bt,SubTrigger:pt,SubContent:at},Zp={Item:q,Separator:jn,Sub:En,SubTrigger:Ln,SubContent:Fn};function Qp(e,t){let n=I(`resume`),r=I(`kill`),i=Fe(),a=N(),o=Ne(),s=ke(),c=De(),l=P(),u=ce(),d=Nt(),f=Ce(),p=oe(f??void 0),m=be(f??void 0),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(e.title??``),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=(p.data??[]).filter(t=>t.agent_type===e.agent_type),D=!e.worktree_missing&&e.status!==`archived`&&E.some(t=>t.id!==e.account_id),ee=(p.data??[]).filter(t=>t.agent_type!==e.agent_type&&t.logged_in),O=m.data?.default_account_id,k=typeof O==`number`?O:null,te=(p.data??[]).filter(e=>e.logged_in),A=k===null?te:[...te.filter(e=>e.id===k),...te.filter(e=>e.id!==k)];return{menu:{session:e,resumable:Yp.includes(e.status)&&!e.conversation_missing,live:Jp.includes(e.status),archived:e.status===`archived`,canMigrate:D,sameAgent:E,handoffTargets:!e.worktree_missing&&e.status!==`archived`?ee:[],setHandoffTo:T,resume:()=>n.mutate(e.id,{onError:e=>{let t=hr(e);t?d(`/project/${t.projectId}/session/${t.sessionId}`):mr(e)}}),kill:()=>r.mutate(e.id,{onError:e=>mr(e)}),openClearEnv:()=>g(`clear-env`),openTerminal:()=>u.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void d(`/project/${e.project_id}/session/${e.id}`),onError:e=>mr(e)}),spawnAccounts:A,defaultAccountId:k,spawnAgent:t=>u.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void d(`/project/${e.project_id}/session/${e.id}`),onError:e=>mr(e)}),openRename:()=>{x(e.title??``),v(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>mr(e)}),unarchive:()=>a.mutate(e.id,{onError:e=>mr(e)}),setMigrateTo:C},dialogs:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sr,{open:h===`clear-env`,onOpenChange:e=>{e||g(null)},children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Clear captured environment?`}),(0,X.jsx)(xr,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,X.jsxs)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>g(null),children:`Cancel`}),(0,X.jsx)(G,{variant:`danger`,disabled:l.isPending,onClick:()=>l.mutate(e.id,{onSuccess:e=>{g(null),M.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{g(null),mr(e)}}),children:`Clear captured env`})]})]})}),(0,X.jsx)(Sr,{open:_,onOpenChange:v,children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Rename session`}),(0,X.jsx)(xr,{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:y.trim()},{onSuccess:()=>v(!1),onError:e=>mr(e)})},children:[(0,X.jsx)(b,{value:y,onChange:e=>x(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,X.jsxs)(vr,{children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,onClick:()=>v(!1),children:`Cancel`}),(0,X.jsx)(G,{type:`submit`,disabled:o.isPending,children:`Rename`})]})]})]})}),(0,X.jsx)(Sr,{open:S!==null,onOpenChange:e=>!e&&C(null),children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsxs)(br,{children:[`Move this session to `,S?.label,`?`]}),(0,X.jsx)(xr,{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)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>C(null),children:`Cancel`}),(0,X.jsx)(G,{disabled:s.isPending,onClick:()=>{S&&s.mutate({sessionId:e.id,accountId:S.id},{onSuccess:()=>{C(null),M.success(`Moved to ${S.label}`)},onError:e=>{C(null),mr(e)}})},children:`Move session`})]})]})}),(0,X.jsx)(Sr,{open:w!==null,onOpenChange:e=>!e&&T(null),children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsxs)(br,{children:[`Hand off to `,w?.agent_type,`?`]}),(0,X.jsxs)(xr,{children:[`A new session starts in this worktree and branch on`,` `,(0,X.jsx)(`span`,{className:`text-fg`,children:w?.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)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>T(null),children:`Cancel`}),(0,X.jsx)(G,{disabled:c.isPending,onClick:()=>{w&&c.mutate({sessionId:e.id,accountId:w.id},{onSuccess:e=>{T(null),M.success(`Handed off to ${w.agent_type}`),d(`/session/${e.id}`)},onError:e=>{T(null),mr(e)}})},children:`Hand off`})]})]})})]})}}function $p({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)(St,{}),` Resume`]}),t.live&&(0,X.jsxs)(n,{onSelect:t.kill,children:[(0,X.jsx)(st,{}),` Kill`]}),(0,X.jsxs)(n,{onSelect:t.openRename,children:[(0,X.jsx)(S,{}),` Rename`]}),!t.archived&&(0,X.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,X.jsx)(Wr,{}),` Clear captured env`]}),t.canMigrate&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Oi,{}),` 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)(Vr,{}),` 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)(Gt,{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)(Mt,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Gn,{}),` 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)(Gt,{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=te(`vscode`,s.worktree_path,A())},children:[(0,X.jsx)(Gr,{}),` Open in VS Code`]}),(0,X.jsxs)(n,{onSelect:()=>{window.location.href=te(`cursor`,s.worktree_path,A())},children:[(0,X.jsx)(Gr,{}),` 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)(Nn,{}),` Archive`]})]}),t.archived&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.unarchive,children:[(0,X.jsx)(An,{}),` Unarchive`]})]})]})}function em({batch:e}){return(0,X.jsxs)(q,{onSelect:()=>e.archiveAll(e.sessionIds),children:[(0,X.jsx)(Nn,{}),` Archive all`,(0,X.jsx)(`span`,{className:`ml-auto pl-3 tabular-nums text-fg-muted`,children:e.sessionIds.length})]})}function tm({menu:e}){return(0,X.jsxs)(vt,{children:[(0,X.jsx)(Ct,{asChild:!0,children:(0,X.jsxs)(G,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:e=>e.preventDefault(),children:[(0,X.jsx)(ht,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,X.jsx)(lt,{align:`end`,children:(0,X.jsx)($p,{kit:Xp,menu:e})})]})}function nm({session:e,onArchived:t,batch:n,children:r}){let{menu:i,dialogs:a}=Qp(e,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Rn,{children:[(0,X.jsx)(Dn,{asChild:!0,children:typeof r==`function`?r(i):r}),(0,X.jsx)(Pn,{children:n?(0,X.jsx)(em,{batch:n}):(0,X.jsx)($p,{kit:Zp,menu:i})})]}),a]})}function rm({menu:e,batch:t}){return(0,X.jsx)(Pn,{children:t?(0,X.jsx)(em,{batch:t}):(0,X.jsx)($p,{kit:Zp,menu:e})})}var im=`application/x-puddle-sessions`,am=s(c().uuid()).min(1);function om(e,t,n,r,i){if(i.toggle){let e=new Set(t);return e.has(r)?e.delete(r):e.add(r),{selection:e,anchor:r}}if(i.shift&&n!==null){let t=e.indexOf(n),i=e.indexOf(r);if(t!==-1&&i!==-1){let r=Math.min(t,i),a=Math.max(t,i);return{selection:new Set(e.slice(r,a+1)),anchor:n}}}return{selection:new Set([r]),anchor:r}}function sm(e,t){let n=new Set(t),r=new Set([...e].filter(e=>n.has(e)));return r.size===e.size&&[...r].every(t=>e.has(t))?e:r}function cm(e,t,n){if(!t.has(n)||t.size<2)return[n];let r=e.filter(e=>t.has(e));return r.length>0?r:[n]}function lm(e){return JSON.stringify(e)}function um(e){try{return[...new Set(am.parse(JSON.parse(e)))]}catch{return[]}}function dm(e){return e.includes(im)}function fm(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=pm(t.x/e.width),i=pm(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 pm(e){return e<0?0:e>1?1:e}var mm=(0,Z.createContext)(null);function hm(){return(0,Z.useContext)(mm)}var gm=(0,Z.createContext)(null);function _m(){return(0,Z.useContext)(gm)}var vm=`leaf:`,ym=`tabdrop:`,bm=`strip:`,xm=`archive:`,Sm=e=>{let t=Rd(e);for(let e of[ym,bm]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:Id(e)};function Cm({onDrop:e,onArchive:t,renderOverlay:n,children:r}){let i=Dd(Ed(kf,{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)(Ep,{sensors:i,collisionDetection:Sm,onDragStart:e=>c(e.active.data.current?.ref??null),onDragMove:e=>{let t=e.over,n=wm(e),r=t&&n?Em(String(t.id),t.rect,t.data.current,n):null;Tm(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)(mm.Provider,{value:a,children:(0,X.jsx)(gm.Provider,{value:s,children:r})}),(0,X.jsx)(Kp,{dropAnimation:null,children:s?n(s):null})]})}function wm(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 Tm(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function Em(e,t,n,r){if(e.startsWith(ym)){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(bm)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(vm)){let n=fm({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 Dm=`application/x-puddle-project`,Om=`group-hover:[transform:translateX(var(--tail))]`;function km(e,t){let n=document.createElement(`div`);n.textContent=`${t} sessions`,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 Am({projectId:e,name:t,colour:n,actions:r,editLabel:i}){let[a,o]=(0,Z.useState)(!1),s=z(),c=_e(me().data?.protocol);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Pn,{children:[(0,X.jsxs)(q,{onSelect:()=>r.onNewSessionIn(e),children:[(0,X.jsx)(Gn,{}),`New agent`]}),(0,X.jsxs)(q,{onSelect:()=>r.onNewTerminalIn(e),children:[(0,X.jsx)(Mt,{}),`New terminal`]}),(0,X.jsx)(jn,{}),(0,X.jsxs)(q,{onSelect:i.onSelect,children:[(0,X.jsx)(S,{}),i.label]}),c&&(0,X.jsxs)(q,{onSelect:()=>o(!0),children:[(0,X.jsx)(Hn,{}),`Change project colour`]})]}),(0,X.jsx)(Sr,{open:a,onOpenChange:o,children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Project colour`}),(0,X.jsx)(xr,{className:g(n),children:t})]}),(0,X.jsx)(y,{value:n,label:`Project colour`,disabled:s.isPending,onChange:t=>s.mutate({id:e,colour:t},{onSuccess:()=>o(!1),onError:e=>mr(e)})})]})})]})}function jm(e,t){let{isOver:n,setNodeRef:r}=Pp({id:`${xm}${e}`}),i=_m(),[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=>{!dm(e.dataTransfer.types)&&!ql(e.dataTransfer.types)||(e.preventDefault(),o(!0))},onDragLeave:()=>o(!1),onDrop:e=>{o(!1);let n=um(e.dataTransfer.getData(im));if(n.length>0){e.preventDefault(),t(n);return}let r=Kl(e.dataTransfer.getData(Wl));r?.type===`terminal`&&(e.preventDefault(),t([r.session]))}}}}function Mm({onArchiveDrop:e,onExpand:t}){let n=jm(`rail`,e);return(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{ref:n.setNodeRef,type:`button`,onClick:t,...n.props,className:V(`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)(Nn,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Archived sessions`})]})}),(0,X.jsx)(pn,{side:`left`,children:`Drop selected sessions here to archive them`})]})}function Nm({collapsed:e,children:t}){return(0,X.jsx)(`div`,{className:V(`grid transition-[grid-template-rows] duration-200`,e?`grid-rows-[0fr]`:`grid-rows-[1fr]`),children:t})}function Pm({icon:e,label:t,onClick:n,active:r=!1,tooltipSide:i=`bottom`}){return(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:V(`flex items-center rounded-md p-1.5 transition-colors`,r?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,X.jsx)(e,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(pn,{side:i,children:t})]})}function Fm({session:e,accountLabel:t}){return(0,X.jsxs)(`span`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:nn()(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:[e.detected_agent_type?(0,X.jsx)(Gt,{type:e.detected_agent_type,className:`size-3 shrink-0`}):(0,X.jsx)(Mt,{className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:e.detected_agent_type?`${e.detected_agent_type} · terminal`:`terminal`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Gt,{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 Im({session:e,accountLabel:t,activeSessionId:n,onPromote:r,onArchived:i,selectedIds:a,selection:o}){let{menu:s,dialogs:c}=Qp(e,i),l=nn(),u=o.ids.has(e.id),d=u&&a.length>1?{sessionIds:a,archiveAll:o.onArchive}:void 0;return(0,X.jsxs)(Rn,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(Dn,{asChild:!0,children:(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(Dt,{draggable:!1,"aria-current":e.id===n?`true`:void 0,onClick:t=>{let n=t.shiftKey||t.metaKey||t.ctrlKey;o.onSelect(e.id,{shift:t.shiftKey,toggle:t.metaKey||t.ctrlKey}),n&&t.preventDefault()},onDoubleClick:()=>r(e.id),onContextMenu:()=>{u||o.onSelectOnly(e.id)},to:`/project/${e.project_id}/session/${e.id}`,"aria-selected":u,className:V(`flex items-center rounded-md p-1 transition-colors hover:bg-elevated`,u?`bg-selection`:e.id===n&&`bg-elevated`),children:[(0,X.jsx)(qp,{status:e.status,kind:e.kind,agentType:e.agent_type,detectedAgentType:e.detected_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:l(e)})]})})}),(0,X.jsx)(pn,{side:`left`,children:(0,X.jsx)(Fm,{session:e,accountLabel:t})})]}),(0,X.jsx)(rm,{menu:s,batch:d}),c]})}function Lm({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,onExpand:a,onNewTerminal:o,onNewSession:s,onArchived:c,onArchiveDrop:l,selection:u,projectActions:d}){let[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[_,y]=(0,Z.useState)(null),b=z(),x=new Map(t.map(e=>[e.id,e.label])),S=(0,Z.useMemo)(()=>e.flatMap(e=>e.sessions.map(e=>e.id)),[e]),C=S.filter(e=>u.ids.has(e)),w=(t,n)=>{let i=On(e,t,n);i&&r(i)},T=(e,t)=>{y(null);let n=v(t);!n||n===e.abbrev||b.mutate({id:e.projectId,abbrev:n},{onError:e=>mr(e)})};return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 w-9 shrink-0 flex-col items-center overflow-hidden 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)(Pm,{icon:bi,label:`Show sessions`,onClick:a,tooltipSide:`left`}),(0,X.jsx)(Pm,{icon:Gn,label:`New agent`,onClick:s,tooltipSide:`left`}),(0,X.jsx)(Pm,{icon:Mt,label:`New terminal`,onClick:o,tooltipSide:`left`})]}),(0,X.jsx)(`div`,{className:`no-scrollbar flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto overscroll-contain 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`}),_===e.projectId?(0,X.jsx)(ln,{initial:e.abbrev,maxLength:5,className:`w-7 text-center text-[8px] uppercase leading-3 text-fg`,onCommit:t=>T(e,t),onCancel:()=>y(null)}):(0,X.jsxs)(Rn,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(Dn,{asChild:!0,children:(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Dt,{to:`/project/${e.projectId}`,...Mn(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Dm,e.projectId),h(e.projectId)},onDragEnd:()=>h(null),className:V(`w-7 truncate text-center text-[8px] uppercase leading-3 transition-colors`,g(e.colour)?V(g(e.colour),`hover:opacity-75`):`text-fg-muted hover:text-fg`,m===e.projectId&&`opacity-50`),children:e.abbrev})})}),(0,X.jsx)(pn,{side:`left`,children:e.name})]}),(0,X.jsx)(Am,{projectId:e.projectId,name:e.name,colour:e.colour,actions:d,editLabel:{label:`Change project abbreviation`,onSelect:()=>y(e.projectId)}})]}),(0,X.jsx)(Nm,{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=>{let n=cm(S,u.ids,e.id);t.dataTransfer.setData(Wl,Gl({type:`terminal`,session:e.id})),t.dataTransfer.setData(im,lm(n)),t.dataTransfer.effectAllowed=`copyMove`,n.length>1&&km(t,n.length),u.ids.has(e.id)||u.onSelectOnly(e.id),p({sourceId:e.id,sessionIds:n})},onDragEnd:()=>p(null),onDragOver:t=>{t.preventDefault(),f?.sessionIds.length===1&&f.sourceId!==e.id&&w(f.sourceId,e.id)},className:V(`transition-opacity`,f?.sessionIds.includes(e.id)&&`opacity-50`),children:(0,X.jsx)(Im,{session:e,accountLabel:e.account_id===null?void 0:x.get(e.account_id),activeSessionId:n,onPromote:i,onArchived:c,selectedIds:C,selection:u})},e.id))})})]},e.projectId))}),(0,X.jsx)(Mm,{onArchiveDrop:l,onExpand:a})]})}function Rm({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,selectedIds:a,selection:o,ellipsis:s,lastActive:c=!1}){let l=nn(),u=o?.ids.has(e.id)??!1,d=o&&u&&a&&a.length>1?{sessionIds:a,archiveAll:o.onArchive}:void 0,f=e.kind===`terminal`?`terminal`:e.agent_type??`agent`,p=c?e.last_activity_at===null?``:` · ${Xe(e.last_activity_at)}`:e.account_id!==null&&n.has(e.account_id)?` · ${n.get(e.account_id)}`:``;return(0,X.jsx)(nm,{session:e,onArchived:i,batch:d,children:n=>(0,X.jsxs)(Dt,{draggable:!1,onClick:t=>{if(!o)return;let n=t.shiftKey||t.metaKey||t.ctrlKey;o.onSelect(e.id,{shift:t.shiftKey,toggle:t.metaKey||t.ctrlKey}),n&&t.preventDefault()},onDoubleClick:r&&(()=>r(e.id)),onContextMenu:()=>{o&&!u&&o.onSelectOnly(e.id)},to:`/project/${e.project_id}/session/${e.id}`,"aria-selected":o?u:void 0,className:V(`group flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-elevated compact:gap-1.5 compact:py-1`,u?`bg-selection`:e.id===t&&`bg-elevated`),children:[(0,X.jsx)(qp,{status:e.status,kind:e.kind,agentType:e.agent_type,detectedAgentType:e.detected_agent_type,stale:e.stale_running}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(hc,{text:l(e),className:`font-sans text-xs text-fg`,hoverClass:Om}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:[(0,X.jsx)(ci,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(hc,{text:e.branch,hoverClass:Om})]}),(0,X.jsx)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:(0,X.jsx)(hc,{text:`${f}${p}`,hoverClass:Om})})]}),e.skip_permissions&&(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Ci,{className:`size-3.5 shrink-0 text-warning`})}),(0,X.jsx)(pn,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(si,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(pn,{children:`Worktree directory is gone — archive only`})]}),e.conversation_missing&&(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(hi,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(pn,{children:`Native conversation is missing — resume unavailable`})]}),e.native_sync===`fallback`&&e.status!==`archived`&&(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Ti,{className:`size-3.5 shrink-0 text-fg-muted`})}),(0,X.jsx)(pn,{children:`In-agent conversation switches are not synchronised`})]}),s&&(0,X.jsx)(`span`,{className:`hidden group-hover:inline-flex has-[[data-state=open]]:inline-flex pointer-coarse:inline-flex`,children:(0,X.jsx)(tm,{menu:n})})]})})}function zm({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onNewSession:o,onNewTerminal:s,onCollapse:c,onArchived:l,onArchiveDrop:u,selection:d,projectActions:f}){return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 py-1.5`,children:[(0,X.jsx)(Pm,{icon:yi,label:`Hide sessions`,onClick:c}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(Pm,{icon:Gn,label:`New agent`,onClick:o}),(0,X.jsx)(Pm,{icon:Mt,label:`New terminal`,onClick:s})]})]}),(0,X.jsx)(Bm,{groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:l,onArchiveDrop:u,selection:d,projectActions:f})]})}function Bm({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:o,onArchiveDrop:s,selection:c,projectActions:l}){let[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=jm(`list`,s),b=_m(),x=u!==null||b?.type===`terminal`,S=z(),C=ae(`palette.toggle`),w=new Map(t.map(e=>[e.id,e.label])),T=e.reduce((e,t)=>e+t.sessions.length,0),E=(0,Z.useMemo)(()=>e.flatMap(e=>e.sessions.map(e=>e.id)),[e]),D=E.filter(e=>c.ids.has(e)),{height:ee,handle:O}=uc(`sessions-archived`,200,{sized:`below`,min:96}),k=(0,Z.useMemo)(()=>{let t=new Set,n=e.map(e=>{let n=a.filter(t=>t.project_id===e.projectId);for(let e of n)t.add(e.id);return{...e,sessions:n}}),r=a.filter(e=>!t.has(e.id));return[...n.filter(e=>e.sessions.length>0),...r.length>0?[{projectId:``,name:``,abbrev:``,colour:null,repoId:-1,sessions:r}]:[]]},[e,a]),te=(t,n)=>{let i=On(e,t,n);i&&r(i)},A=(e,t)=>{h(null);let n=t.trim();!n||n===e.name||S.mutate({id:e.projectId,name:n},{onError:e=>mr(e)})};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain py-1.5`,children:[T===0&&a.length===0&&(0,X.jsxs)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`No sessions yet — press `,C,` 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)(ln,{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=>A(e,t),onCancel:()=>h(null)}):(0,X.jsxs)(Rn,{children:[(0,X.jsx)(Dn,{asChild:!0,children:(0,X.jsx)(Dt,{to:`/project/${e.projectId}`,...Mn(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Dm,e.projectId),p(e.projectId)},onDragEnd:()=>p(null),className:V(`block truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide transition-colors compact:pb-0.5 compact:pt-1.5`,g(e.colour)?V(g(e.colour),`hover:opacity-75`):`text-fg-gold hover:text-fg`,f===e.projectId&&`opacity-50`),children:e.name})}),(0,X.jsx)(Am,{projectId:e.projectId,name:e.name,colour:e.colour,actions:l,editLabel:{label:`Change project name`,onSelect:()=>h(e.projectId)}})]}),(0,X.jsx)(Nm,{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=>{let n=cm(E,c.ids,e.id);t.dataTransfer.setData(Wl,Gl({type:`terminal`,session:e.id})),t.dataTransfer.setData(im,lm(n)),t.dataTransfer.effectAllowed=`copyMove`,n.length>1&&km(t,n.length),c.ids.has(e.id)||c.onSelectOnly(e.id),d({sourceId:e.id,sessionIds:n})},onDragEnd:()=>d(null),onDragOver:t=>{t.preventDefault(),u?.sessionIds.length===1&&u.sourceId!==e.id&&te(u.sourceId,e.id)},className:V(`transition-opacity`,u?.sessionIds.includes(e.id)&&`opacity-50`),children:(0,X.jsx)(Rm,{session:e,activeSessionId:n,accountLabel:w,onPromote:i,onArchived:o,selectedIds:D,selection:c,ellipsis:!0})},e.id))})})]},e.projectId))]}),(a.length>0||x)&&(0,X.jsxs)(X.Fragment,{children:[_&&(0,X.jsx)(dc,{handle:O,label:`Resize the archived sessions`}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col pb-1.5`,style:_?{height:ee,maxHeight:`70%`}:void 0,children:[(0,X.jsxs)(`button`,{ref:y.setNodeRef,type:`button`,onClick:()=>v(e=>!e),...y.props,className:V(`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`,y.armed&&`bg-selection text-fg`),children:[(0,X.jsx)(er,{className:V(`size-3 transition-transform`,_&&`rotate-90`)}),(0,X.jsx)(Nn,{className:`size-3`}),(0,X.jsx)(`span`,{children:`Archived`}),(0,X.jsx)(`span`,{className:`ml-auto tabular-nums`,children:a.length})]}),_&&(0,X.jsx)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:k.map(e=>(0,X.jsxs)(`div`,{children:[e.name!==``&&(0,X.jsx)(`div`,{className:V(`truncate px-3 pb-0.5 pt-1.5 text-2xs font-medium uppercase tracking-wide`,g(e.colour)?V(g(e.colour),`opacity-70`):`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)(Rm,{session:e,activeSessionId:n,accountLabel:w,onArchived:o,ellipsis:!0,lastActive:!0})},e.id))})]},e.projectId))})]})]})]})}function Vm({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 Hm=[`running`,`waiting_input`];function Um({sessionId:e,status:t}){let n=Hm.includes(t),{data:r}=F(e,n),i=r?.vars??[];if(!n||i.length===0)return null;let a=async(e,t)=>{try{await navigator.clipboard.writeText(t),M.success(`${e} value copied`)}catch{M.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)(U,{children:[(0,X.jsx)(H,{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)(pn,{children:[e.bytes,` B ·`,` `,t===void 0?`value unavailable from this daemon`:`click to copy value`]})]},e.name)})})})]})}function Wm(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var Gm=[`running`,`waiting_input`];function Km({sessionId:e,status:t}){let n=Gm.includes(t),{data:r}=de(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)(qm,{sessionId:e,port:t},t.port))})})]})}function qm({sessionId:e,port:t}){let n=Se().data;return(0,X.jsxs)(vt,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Ct,{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)(pn,{children:[t.command,` · pid `,t.pid]})]}),(0,X.jsxs)(lt,{align:`start`,children:[pr()===null?(0,X.jsx)(nt,{asChild:!0,children:(0,X.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,X.jsx)(nt,{onSelect:()=>{Ie(`/forward/${e}/${t.port}`).catch(mr)},children:`Open via proxy`}),(0,X.jsx)(nt,{onSelect:()=>{n&&navigator.clipboard.writeText(Wm(t.port,n.username,n.hostname)).then(()=>M.success(`Copied`))},children:`Copy ssh -L`})]})]})}var Jm=[`interrupted`,`exited`];function Ym({session:e}){let t=I(`resume`),n=Nt();return Jm.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)(G,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>{let t=hr(e);t?n(`/project/${t.projectId}/session/${t.sessionId}`):mr(e)}}),children:[(0,X.jsx)(St,{}),`Resume`]})}):null}function Xm({tab:e,directory:t,onReveal:n,onCompilationSettings:r,onRename:i,editing:a,children:o}){let s=Se(),c=me().data?.protocol,l=Cl(),u=Ll(e.session,e.root,t),d=(0,Z.useMemo)(()=>({sid:e.session,root:e.root,directory:t,host:hl(s.data)}),[e.session,e.root,t,s.data]),f=e.root!==void 0&&!Ae(c),p=l!==null&&_l(l.source,d),m=l!==null&&gl(l.source,d),h=!f&&(p&&m||l!==null&&vl(l.source,d)&&ge(c)),[g,_]=(0,Z.useState)(!1),v=ko(t,e.path),y=()=>{!l||!h||u.paste(l,To(e.path)).then(e=>{l.mode===`cut`&&bl(l.id,e)})},b=t=>{navigator.clipboard.writeText(t?e.path:v),M.success(t?`Relative path copied`:`Path copied`)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Rn,{children:[(0,X.jsx)(Dn,{asChild:!0,children:o}),(0,X.jsx)(Pn,{onCloseAutoFocus:e=>{a&&e.preventDefault()},children:(0,X.jsx)(eu,{absolutePath:v,readOnly:f,canPaste:h,onCut:()=>yl([e.path],`cut`,d),onCopy:()=>yl([e.path],`copy`,d),onPaste:y,onCopyPath:()=>b(!1),onCopyRelativePath:()=>b(!0),onReveal:n,onCompilationSettings:r,onRename:i,onDelete:()=>_(!0),onDownload:()=>{Ue(e.session,e.path,e.root).catch(e=>M.error(e instanceof Error?e.message:`Download failed`))}})})]}),(0,X.jsx)(Sr,{open:g,onOpenChange:_,children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsxs)(br,{children:[`Delete “`,wo(e.path),`”?`]}),(0,X.jsxs)(xr,{children:[`This permanently removes it from `,t,`. There is no undo.`]})]}),(0,X.jsxs)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,X.jsx)(G,{variant:`danger`,onClick:()=>{_(!1),u.remove([e.path])},children:`Delete`})]})]})})]})}function Zm({session:e,onArchived:t}){let n=Fe();return(0,X.jsx)(`button`,{type:`button`,disabled:n.isPending,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:async r=>{r.stopPropagation();try{await n.mutateAsync(e),t(e)}catch(e){mr(e)}},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg disabled:cursor-wait disabled:opacity-50 group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":`Archive session`,title:`Archive session`,children:(0,X.jsx)(Nn,{className:`size-3`})})}var Qm=`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`,$m=`group-hover:[transform:translateX(var(--tail))]`;function eh({leaf:e,sessions:t,onActivate:n,onClose:r,onPromote:i,onArchived:a,onSetView:o,compilableExtensions:s,compilationProviders:c,compilationRunningKeys:l,onRunCompilation:u,onSetCompilationMode:d,onOpenCompilationSettings:f,onNewFile:p,onRevealFile:m,onRenameFile:h}){let g=new Map(t.map(e=>[e.id,e.branch])),_=new Map(t.map(e=>[e.id,e.worktree_path])),v=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),y=hm(),b=y?.leafId===e.id&&y.index!==void 0?y.index:null,{setNodeRef:x}=Pp({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),S=e=>{let t=Dr(e.path,e.session,v,g,e.root,_);return wr(e)===`diff`?`${t} (diff)`:wr(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,X.jsxs)(`div`,{ref:x,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&&p()},children:[e.tabs.map((p,g)=>(0,X.jsxs)(Z.Fragment,{children:[b===g&&(0,X.jsx)(th,{}),(0,X.jsx)(ch,{tab:p,leafId:e.id,index:g,active:W(p)===e.activeKey,preview:W(p)===e.previewKey,session:p.type===`terminal`?t.find(e=>e.id===p.session):void 0,fileSession:p.type===`editor`&&p.tab.root===void 0?t.find(e=>e.id===p.tab.session):void 0,fileDirectory:p.type===`editor`&&(wr(p.tab)===`file`||wr(p.tab)===`external`)?p.tab.root??t.find(e=>e.id===p.tab.session)?.worktree_path:void 0,label:p.type===`editor`?S(p.tab):``,onActivate:()=>n(p),onClose:()=>r(p),onPromote:()=>i(p),onArchived:a,onSetView:e=>o(p,e),compilable:Ro(p.type===`editor`?p.tab.path:``,s),provider:p.type===`editor`?c.find(e=>e.extensions.includes(Lo(p.tab.path)??``)):void 0,compilationRunning:p.type===`editor`&&l.has(zo(p.tab.session,p.tab.path,p.tab.root)),onRunCompilation:()=>{p.type===`editor`&&(n(p),requestAnimationFrame(()=>u(p.tab)))},onSetCompilationMode:e=>{p.type===`editor`&&(n(p),requestAnimationFrame(()=>d(p.tab,e)))},onOpenCompilationSettings:p.type===`editor`&&f?()=>f({session:p.tab.session,path:p.tab.path,...p.tab.root===void 0?{}:{root:p.tab.root}}):void 0,onRevealFile:()=>p.type===`editor`&&m(p.tab),onRenameFile:e=>p.type===`editor`?h(p.tab,e):Promise.resolve(!1)})]},W(p))),b===e.tabs.length&&(0,X.jsx)(th,{})]})}function th(){return(0,X.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function nh({active:e,children:t}){return(0,X.jsx)(`span`,{className:V(`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 rh={source:`preview`,preview:`linked`,linked:`locked`,locked:`source`},ih={source:Y,preview:tr,linked:di,locked:mi},ah={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 oh({view:e,notebook:t=!1,onSetView:n}){let r=ih[e];return(0,X.jsx)(`button`,{onClick:r=>{r.stopPropagation(),n(t?e===`source`?`preview`:`source`:rh[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":t?e===`source`?`Show notebook`:`Show JSON source`:ah[e],title:t?e===`source`?`Show notebook`:`Show JSON source`:ah[e],children:(0,X.jsx)(r,{className:`size-3`})})}function sh({mode:e,running:t,onRun:n,onSetMode:r,provider:i}){let a=e===`eager`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:t,onClick:e=>{e.stopPropagation(),n()},className:V(`hidden rounded-sm p-0.5 transition-colors hover:text-fg disabled:cursor-wait group-hover:inline-flex pointer-coarse:inline-flex`,a?`text-fg-muted`:`text-accent`),"aria-label":i?.action===`run`?`Run file`:`Compile on demand`,title:i?.action===`run`?`Run file`:`Compile on demand`,children:t&&!a?(0,X.jsx)(pi,{className:`size-3 animate-spin`}):(0,X.jsx)(St,{className:`size-3`})}),i?.eager&&(0,X.jsx)(`button`,{type:`button`,disabled:t,onClick:e=>{e.stopPropagation(),r(a?`on_demand`:`eager`)},className:V(`hidden rounded-sm p-0.5 transition-colors hover:text-fg disabled:cursor-wait group-hover:inline-flex pointer-coarse:inline-flex`,a?`text-accent`:`text-fg-muted`),"aria-label":a?`Disable eager compilation`:`Enable eager compilation`,title:a?`Eager compilation — switch to on demand`:`Compile eagerly on disk changes`,children:t&&a?(0,X.jsx)(pi,{className:`size-3 animate-spin`}):(0,X.jsx)(Un,{className:`size-3`})})]})}function ch({tab:e,leafId:t,index:n,active:r,preview:i,session:a,fileSession:o,fileDirectory:s,label:c,onActivate:l,onClose:u,onPromote:d,onArchived:f,onSetView:p,compilable:m,provider:h,compilationRunning:g,onRunCompilation:_,onSetCompilationMode:v,onOpenCompilationSettings:y,onRevealFile:b,onRenameFile:x}){let[S,C]=(0,Z.useState)(!1),w=nn(),T=W(e),{attributes:E,listeners:D,setNodeRef:ee,isDragging:O}=Ap({id:`drag:${t}:${T}`,data:{ref:e,fromLeafId:t}}),{setNodeRef:k}=Pp({id:`tabdrop:${t}:${T}`,data:{leafId:t,index:n}}),te=e=>{ee(e),k(e)},A=V(Qm,r?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`,i&&`italic`,O&&`opacity-40`),j=(0,X.jsx)(`div`,{ref:te,...S?{}:E,...S?{}:D,onClick:l,onDoubleClick:d,className:V(A,S&&`cursor-text select-text`),children:e.type===`terminal`?(0,X.jsxs)(X.Fragment,{children:[a&&(0,X.jsx)(qp,{status:a.status,kind:a.kind,agentType:a.agent_type,detectedAgentType:a.detected_agent_type,stale:a.stale_running}),(0,X.jsx)(`span`,{className:`truncate`,children:a?w(a):e.session.slice(0,8)}),(0,X.jsxs)(nh,{active:r,children:[a&&a.status!==`archived`&&(0,X.jsx)(Zm,{session:a.id,onArchived:f}),(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),u()},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)(Pt,{className:`size-3`})})]})]}):(0,X.jsxs)(X.Fragment,{children:[e.tab.view===`linked`&&(0,X.jsx)(di,{className:`size-3 shrink-0 text-fg-muted`}),e.tab.view===`locked`&&(0,X.jsx)(mi,{className:`size-3 shrink-0 text-fg-muted`}),S?(0,X.jsx)(lh,{initial:e.tab.path.split(`/`).pop()??e.tab.path,onCommit:x,onCancel:()=>C(!1),onCommitted:()=>C(!1)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(hc,{text:c,hoverClass:$m,containerClassName:`flex-[0_1_auto]`,className:(wr(e.tab)===`file`||wr(e.tab)===`external`)&&(Cr(e.tab.path)!==null||m)?`-mr-20 pr-20`:`-mr-11 pr-11`}),(0,X.jsx)(os,{session:e.tab.session,path:e.tab.path,kind:wr(e.tab),root:e.tab.root}),(0,X.jsxs)(nh,{active:r,children:[(wr(e.tab)===`file`||wr(e.tab)===`external`)&&Cr(e.tab.path)!==null&&(0,X.jsx)(oh,{notebook:Cr(e.tab.path)===`notebook`,view:e.tab.view??`source`,onSetView:p}),(wr(e.tab)===`file`||wr(e.tab)===`external`)&&m&&!e.tab.generated_by&&(0,X.jsx)(sh,{provider:h,mode:e.tab.compile_mode??`on_demand`,running:g,onRun:_,onSetMode:v}),(0,X.jsx)(cs,{session:e.tab.session,path:e.tab.path,kind:wr(e.tab),root:e.tab.root,label:c,onClose:u})]})]})]})}),M=(0,X.jsx)(pn,{side:`bottom`,children:(0,X.jsx)(Ou,{name:e.type===`terminal`?a?w(a):e.session:c,session:e.type===`terminal`?a:o})});return e.type===`terminal`&&a?(0,X.jsxs)(U,{children:[(0,X.jsx)(nm,{session:a,onArchived:()=>f(e.session),children:(0,X.jsx)(H,{asChild:!0,children:j})}),M]}):e.type===`editor`&&s!==void 0&&(wr(e.tab)===`file`||wr(e.tab)===`external`)?(0,X.jsxs)(U,{open:!S&&void 0,children:[(0,X.jsx)(Xm,{tab:e.tab,directory:s,onReveal:b,onCompilationSettings:m?y:void 0,onRename:()=>C(!0),editing:S,children:(0,X.jsx)(H,{asChild:!0,children:j})}),M]}):(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:j}),M]})}function lh({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 uh(e,t,n){return{focus:e===`press`,driveScroll:t&&n!==`linked`}}function dh({leaf:e,sessions:t,reveal:n,onActivateTab:r,onCloseTab:i,onPromoteTab:a,onArchived:o,onFocusLeaf:s,onScrollDrive:c,onDropTab:l,onSetTabView:u,compilableExtensions:d,compilationProviders:f,compilationRunningKeys:p,onRunCompilation:m,onSetCompilationMode:h,onOpenCompilationSettings:g,onRevealPreviewSource:_,onRevealCompiledSource:v,onNewUntitled:y,onRevealFile:b,onRenameFile:x,focused:S,scrollDriver:C,scrollChannel:w}){let T=e.tabs.find(t=>W(t)===e.activeKey)??null,E=T?.type===`terminal`?W(T):null,D=T?.type===`terminal`?t.find(e=>e.id===T.session)??null:null,ee=fs(E),{setNodeRef:O}=Pp({id:`leaf:${e.id}`}),k=hm(),te=_m(),A=ae(`palette.toggle`),j=T?.type===`editor`?T.tab:null,M=j?.view??`source`,ne=j!==null&&(wr(j)===`file`||wr(j)===`external`)&&Cr(j.path)!==null,N=C&&ne&&M!==`linked`,P=!N&&(M===`locked`||ne&&M===`source`),re=t=>{let n=uh(t,ne,M);n.focus&&s(e.id),n.driveScroll&&c(e.id)},ie=(0,Z.useRef)(null),F=(0,Z.useRef)(()=>void 0);F.current=()=>{T&&r(e.id,T)},(0,Z.useEffect)(()=>{let e=ie.current;if(!e)return;let t=()=>F.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[I,oe]=(0,Z.useState)(null),se=(0,Z.useRef)(l);return se.current=l,(0,Z.useEffect)(()=>{let t=ie.current;if(!t)return;let n=e=>e.dataTransfer!==null&&ql(e.dataTransfer.types),r=e=>{let n=t.getBoundingClientRect();return fm({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`),oe(r(e)))},a=e=>{t.contains(e.relatedTarget)||oe(null)},o=t=>{if(!n(t))return;t.preventDefault(),t.stopPropagation(),oe(null);let i=Kl(t.dataTransfer?.getData(`application/x-puddle-tab`)??``);i&&se.current(e.id,i,r(t))},s=()=>oe(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:()=>re(`press`),onWheelCapture:()=>re(`scroll`),children:[e.tabs.length>0&&(0,X.jsx)(eh,{leaf:e,sessions:t,onActivate:t=>r(e.id,t),onClose:t=>i(e.id,t),onPromote:a,onArchived:o,onSetView:(t,n)=>u(e.id,t,n),compilableExtensions:d,compilationProviders:f,compilationRunningKeys:p,onRunCompilation:t=>m(e.id,t),onSetCompilationMode:h,onOpenCompilationSettings:g,onNewFile:()=>y(e),onRevealFile:b,onRenameFile:x}),(0,X.jsxs)(`div`,{ref:e=>{ie.current=e,O(e)},className:`relative min-h-0 flex-1`,children:[T?.type===`editor`&&(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(kr.Provider,{value:JSON.stringify([w,e.id,W(T)]),children:(0,X.jsx)(ns,{tab:T.tab,onRunCompilation:d.has(Lo(T.tab.path)??``)?()=>m(e.id,T.tab):void 0,compilationRunning:p.has(zo(T.tab.session,T.tab.path,T.tab.root)),reveal:n,focused:S,scrollDriver:N,scrollReceiver:P,scrollChannel:w,onRevealSource:j?.view===`linked`||j?.view===`locked`?t=>_(e.id,j,t):void 0,onRevealCompiledSource:t=>v(e.id,t)})})}),(0,X.jsx)(`div`,{ref:ee,className:V(`absolute inset-0 py-1 pl-4 pr-2`,!E&&`hidden`)}),te&&(0,X.jsx)(`div`,{className:`absolute inset-0 z-10 cursor-grabbing`,"aria-hidden":`true`}),k?.leafId===e.id&&k.index===void 0&&(0,X.jsx)(ph,{zone:k.zone}),I!==null&&(0,X.jsx)(ph,{zone:I}),D&&(0,X.jsx)(Ym,{session:D}),!T&&(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,X.jsx)(Vm,{className:`size-24 text-fg-muted/40`}),(0,X.jsx)(`button`,{type:`button`,onClick:Zt,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:A})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1 empty:hidden`,children:[D&&(0,X.jsx)(Um,{sessionId:D.id,status:D.status}),D&&(0,X.jsx)(Km,{sessionId:D.id,status:D.status})]})]})}var fh={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 ph({zone:e}){return(0,X.jsx)(`div`,{className:V(`pointer-events-none absolute z-20 bg-accent/20`,fh[e])})}var mh=`bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`;function hh({tree:e,...t}){let n=(0,Z.useMemo)(()=>{let t=new Set,n=[];for(let r of en(e)){if(r.type!==`editor`||![`file`,`diff`,`external`].includes(wr(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)(is,{buffers:n}),(0,X.jsx)(gh,{node:e,...t})]})}function gh({node:e,...t}){if(e.kind===`leaf`)return(0,X.jsx)(dh,{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,compilableExtensions:t.compilableExtensions,compilationProviders:t.compilationProviders,compilationRunningKeys:t.compilationRunningKeys,onRunCompilation:t.onRunCompilation,onSetCompilationMode:t.onSetCompilationMode,onOpenCompilationSettings:t.onOpenCompilationSettings,onRevealPreviewSource:t.onRevealPreviewSource,onRevealCompiledSource:t.onRevealCompiledSource,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)(_o,{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)(Co,{className:n===`horizontal`?`w-px ${mh}`:`h-px ${mh}`}),(0,X.jsx)(bo,{id:e.id,minSize:64,children:(0,X.jsx)(gh,{node:e,...t})})]},e.id))},e.id)}function _h(e,t){return e.session===t.session&&e.path===t.path&&(e.root??``)===(t.root??``)&&wr(e)===wr(t)}function vh(e,t=`profile`){let n=e.snapshot,r=(0,Z.useRef)(null),i=(0,Z.useRef)(null),a=(0,Z.useRef)(t),o=(0,Z.useRef)(!1);a.current!==t&&(a.current=t,r.current=null,i.current=null,o.current=!1),!n.layout_tree&&!r.current&&(r.current=sn(n));let s=n.layout_tree??r.current??hn([]),c=(0,Z.useMemo)(()=>$t(s),[s]),l=(0,Z.useCallback)(t=>e.update({layout_tree:t}),[e]),u=(0,Z.useRef)(l);u.current=l,(0,Z.useEffect)(()=>{o.current||e.loaded&&!n.layout_tree&&r.current&&(o.current=!0,en(r.current).length>0&&u.current(r.current))},[e.loaded,n.layout_tree]),(0,Z.useEffect)(()=>{e.loaded&&c!==s&&n.layout_tree&&u.current(c)},[e.loaded,c,s,n.layout_tree]);let[d,f]=(0,Z.useState)(null),p=(d?Cn(c,d):null)??Sn(c)[0]??hn([]),m=p.tabs.find(e=>W(e)===p.activeKey)??null,h=m?.type===`editor`?m.tab:null,g=(e,t)=>{let n=Yt(t);n&&(i.current={leafId:e,target:n})};return(0,Z.useMemo)(()=>({tree:c,focusedLeaf:p,activeEditorTab:h,focusLeaf:e=>f(e),activate:(e,t)=>{f(e),g(e,t);let n=W(t),r=Cn(c,e)?.activeKey===n,i=Ht(r?c:Vt(c,e,n),t);r&&i===c||l(i)},close:(e,t)=>{let n=wn(c,e,W(t)),r=Cn(n,e),i=r?.tabs.find(e=>W(e)===r.activeKey);i&&g(e,i),l(i?Ht(n,i):n)},openEditor:(e,t)=>{let n=p.id;f(n);let r={type:`editor`,tab:e};g(n,r);let i=t?.preview?Lt(c,n,r):an(c,n,r);l(Ht(i,r))},openEditorInLeaf:(e,t,n)=>{let r={type:`editor`,tab:t},i=W(r),a=n?.activate??!0,o=n?.dedupeAcrossTree?Bt(c,i):null;if(o){let e=Rt(c,o.id,r);return a&&(f(o.id),e=Vt(e,o.id,i)),o.previewKey===i&&(e=mn(e,i)),e!==c&&l(e),o.id}let s=Cn(c,e)?.id??p.id;return a?(f(s),g(s,r),l(Ht(an(c,s,r),r))):l(un(c,s,r)),s},setCompileMode:(e,t)=>{let n=Ut(c,e,t);n!==c&&l(n)},ensureTerminal:(e,t)=>{let n=`term:${e}`,r=Bt(c,n);if(r){f(r.id);let e=r.activeKey!==n,i=!t?.preview&&r.previewKey===n;if(e||i){let t=c;e&&(t=Vt(t,r.id,n)),i&&(t=mn(t,n)),l(t)}}else{let n=p.id;f(n);let r={type:`terminal`,session:e};l(t?.preview?Lt(c,n,r):an(c,n,r))}},promote:e=>l(mn(c,W(e))),setView:(e,t,n)=>{g(e,t);let r=Kt(c,e,W(t),n),i=Cn(r,e),a=i?.tabs.find(e=>W(e)===i.activeKey);l(a?Ht(r,a):r)},revealSource:(e,t)=>{let n=i.current,r=n&&_h(n.target,t)?n:null,a=r&&Qt(c,t,r.leafId)?r.leafId:void 0,o=Qt(c,t,a);if(o){f(o.leafId);let e=Kt(c,o.leafId,W(o.ref),`source`);return e=Vt(e,o.leafId,W(o.ref)),i.current={leafId:o.leafId,target:t},e!==c&&l(e),o.leafId}let s=(r?Cn(c,r.leafId):null)?.id??Cn(c,e)?.id??p.id,u={type:`editor`,tab:{session:t.session,path:t.path,...t.kind===void 0?{}:{kind:t.kind},...t.root===void 0?{}:{root:t.root},view:`source`}};return f(s),i.current={leafId:s,target:t},l(an(c,s,u)),s},renameFile:(e,t)=>{let n=Jt(c,e,t);n!==c&&l(n)},removeTerminal:e=>{let t=Bt(c,`term:${e}`);t&&l(wn(c,t.id,`term:${e}`))},pruneSessions:e=>l(qt(c,Tn(e))),resize:(e,t)=>l(Xt(c,e,t)),drop:e=>{f(e.toLeafId),g(e.toLeafId,e.ref),l(Ht(zt(c,e),e.ref))}}),[c,p,h,l])}function yh(e,t,n){return n>0?`● ${n} waiting — ${e} (${t})`:`${e} — ${t}`}function bh(){return(0,X.jsx)(ot,{children:(0,X.jsx)(xh,{})})}function xh(){let e=Ot(),t=Nt(),n=ce(),r=e.id??``,i=/^[0-9a-f]{10}$/.test(r),a=e.sid??null,s=kt(),c=s.state?.notificationSession===a?s.key:null,l=je(i?r:void 0),u=l.data?.project.id===r?l.data:void 0,d=oe(l.data?.project.profile_id).data??[],f=nn(),p=ae(`editor.save`),m=me().data?.protocol,h=se(),g=Ir(xe(m)),_=Ee(m),v=zr(),[y,b]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(()=>new Set),te=(0,Z.useMemo)(()=>{let e=new Set(T);return S&&e.add(S),e},[T,S]),A=(0,Z.useMemo)(()=>g.data?.providers.filter(e=>e.available)??[],[g.data]),j=(0,Z.useMemo)(()=>new Set(A.flatMap(e=>e.extensions.map(e=>e.toLowerCase()))),[A]),ne=_n(),N=pe(),P=(0,Z.useMemo)(()=>u?.sessions??N.data?.filter(e=>e.project_id===r)??[],[u,N.data,r]),ie=N.data??P,F=D(),I=F.projectBasedLayout,ue=F.showAllProjectSessions,de=I&&ne.snapshot.layout_mode===`project`,L=bn(ne,r,de),he=(0,Z.useRef)(ne);he.current=ne;let ge=(0,Z.useRef)(N.data);ge.current=N.data;let R=l.data?.project.profile_id,_e=Pe(R),ve=be(R),Ce=ye(R??``),z=u?.project??_e.data?.find(e=>e.id===r),De=(0,Z.useMemo)(()=>kn((_e.data??(z?[z]:[])).filter(e=>!e.archived),ve.data?.projectOrder??[]),[_e.data,z,ve.data]),ke=(0,Z.useMemo)(()=>{let e=e=>e.status!==`archived`,t=N.data??P;return De.map(n=>({projectId:n.id,name:n.name,abbrev:C(n),colour:n.colour,repoId:n.repo_id,sessions:kn(t.filter(t=>t.project_id===n.id&&e(t)&&(ue||n.id===r)),L.snapshot.session_order)}))},[ue,P,r,L.snapshot.session_order,De,N.data]),Ae=(0,Z.useMemo)(()=>ke.flatMap(e=>e.sessions.map(e=>e.id)),[ke]),[Ne,Ie]=(0,Z.useState)(()=>new Set),Le=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{Ie(e=>sm(e,Ae)),Le.current!==null&&!Ae.includes(Le.current)&&(Le.current=null)},[Ae]);let ze=(0,Z.useCallback)((e,t)=>{Ie(n=>{let r=om(Ae,n,Le.current,e,t);return Le.current=r.anchor,r.selection})},[Ae]),Be=(0,Z.useCallback)(e=>{Le.current=e,Ie(new Set([e]))},[]),Ve=(0,Z.useCallback)((e,t)=>{let n=De.map(e=>e.id),r=In(n,e,t);r.some((e,t)=>e!==n[t])&&Ce.mutate({projectOrder:r})},[De,Ce]),He=(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(de||!ue)return t(P.filter(n));let r=N.data??P;return De.flatMap(e=>t(r.filter(t=>t.project_id===e.id&&n(t))))},[ue,de,P,N.data,De]),Ue=(0,Z.useRef)(De);Ue.current=De;let We=(0,Z.useRef)(_e.data);We.current=_e.data,(0,Z.useEffect)(()=>{let e=he.current;if(!e.loaded)return;let t=e.current(),n=t.layout_mode??`profile`;if(I&&n!==`project`){if(!N.data||!_e.data)return;let n=new Map(N.data.map(e=>[e.id,e.project_id])),i=cn(t,_e.data.map(e=>e.id),n,r);e.update({...i,project_layouts:on(i.project_layouts??{},t.project_layouts)})}else!I&&n===`project`&&e.update(gn(t,[r,...Ue.current.map(e=>e.id)]))},[I,ne.loaded,N.data,_e.data,r]);let Ke=de?`project:${r}`:`profile`,B=vh(L,Ke),[Je,Ye]=(0,Z.useState)(null),Xe=(0,Z.useCallback)(e=>Ye({scopeKey:Ke,leafId:e}),[Ke]),Ze=(Je?.scopeKey===Ke?Cn(B.tree,Je.leafId):null)?.id??B.focusedLeaf.id;(0,Z.useEffect)(()=>{Xe(B.focusedLeaf.id)},[Xe,B.focusedLeaf.id,B.focusedLeaf.activeKey]);let Qe=(0,Z.useCallback)(e=>{B.focusLeaf(e),Xe(e)},[B,Xe]),$e=ne.snapshot.project_layouts,et=(0,Z.useMemo)(()=>de?yn($e,r):[],[de,$e,r]),nt=(0,Z.useRef)(B);nt.current=B;let rt=(0,Z.useCallback)(e=>{let t=Lo(e.path);return t===null?void 0:A.find(e=>e.extensions.includes(t))},[A]),at=(0,Z.useCallback)(e=>rt(e)?.id,[rt]),ot=(0,Z.useCallback)(e=>R===void 0?null:{profile_id:R,project_id:ie.find(t=>t.id===e)?.project_id??r},[R,r,ie]),st=(0,Z.useCallback)(e=>{let t=at(e),n=ot(e.session);return{source:{session:e.session,path:e.path,...e.root===void 0?{}:{root:e.root}},...t===void 0?{}:{provider:t},...n??{}}},[ot,at]),ct=(0,Z.useCallback)(e=>{if(!_||R===void 0)return;let t=Lo(e.path),n=t===null?void 0:A.find(e=>e.extensions.includes(t)),r=ot(e.session);!n||!r||b({source:e,provider:n.id,...r})},[A,_,ot,R]),lt=(0,Z.useCallback)((e,t,n)=>{let r=t.artifacts.find(e=>e.role===`preview`);r&&(xt(r.file.session,r.file.path,r.file.root),h.invalidateQueries({queryKey:r.file.root===void 0?[`wt-file`,r.file.session,r.file.path]:[`wt-file`,r.file.session,r.file.path,r.file.root],exact:!0}),nt.current.openEditorInLeaf(e,{session:r.file.session,path:r.file.path,...r.file.root===void 0?{kind:`file`}:{kind:`external`,root:r.file.root},generated_by:t.provider,...Cr(r.file.path)?{view:`preview`}:{}},{dedupeAcrossTree:!0,activate:n}))},[h]),ut=(0,Z.useCallback)(async(e,t)=>{if(S!==null)return;let n=st(t),r=rt(t);if(!r)return;let i=zo(t.session,t.path,t.root);w(i);try{if(!await qe(n.source,new Set(r.input_extensions))){M.error(`Run cancelled because an input could not be saved`);return}(t.compile_mode??`on_demand`)===`eager`&&(nt.current.setCompileMode(t,`on_demand`),await Lr({...n,mode:`on_demand`}));let i=await v.mutateAsync(n);Re(zo(i.source.session,i.source.path,i.source.root)),lt(e,i,!0),M.success(`${r.action===`run`?`Ran`:`Compiled`} ${wo(i.source.path)}`)}catch(e){Bo(i,e)}finally{w(null)}},[S,rt,st,lt,v]),dt=(0,Z.useCallback)(async(e,t)=>{let n=e.compile_mode??`on_demand`;if(n===t)return;let r=rt(e);if(!r||t===`eager`&&!r.eager)return;let i=st(e);if(t===`eager`&&!await qe(i.source,new Set(r.input_extensions))){M.error(`Eager compilation was not enabled because an input could not be saved`);return}nt.current.setCompileMode(e,t),t===`on_demand`&&Lr({...i,mode:t}).catch(t=>{nt.current.setCompileMode(e,n),mr(t)})},[rt,st]),ft=(0,Z.useMemo)(()=>{let e=new Map;for(let t of Sn(B.tree))for(let n of t.tabs){if(n.type!==`editor`||n.tab.compile_mode!==`eager`||!at(n.tab)||!rt(n.tab)?.eager)continue;let r=zo(n.tab.session,n.tab.path,n.tab.root);e.has(r)||e.set(r,{leafId:t.id,target:st(n.tab)})}return[...e.entries()].map(([e,t])=>({key:e,...t}))},[B.tree,st,at,rt]),pt=(0,Z.useCallback)((e,t,n)=>{Re(zo(n.source.session,n.source.path,n.source.root)),lt(t,n,!1)},[lt]),ht=(0,Z.useCallback)((e,t)=>Bo(e,t),[]),gt=(0,Z.useCallback)((e,t)=>{E(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),vt=(0,Z.useRef)(L);vt.current=L;let yt=(0,Z.useCallback)(e=>vt.current.update({session_order:zn(e,vt.current.snapshot.session_order)}),[]),bt=ac(oc),[St,Ct]=(0,Z.useState)(null),[wt,Et]=(0,Z.useState)([]),Dt=(0,Z.useRef)(bt);Dt.current=bt;let[At,jt]=(0,Z.useState)(!1),[Mt,V]=(0,Z.useState)(!1),[Pt,Ft]=(0,Z.useState)(null),It=Pt===r,[Lt,Rt]=(0,Z.useState)(!1),[zt,Bt]=(0,Z.useState)(`agent`),[Vt,Ht]=(0,Z.useState)(void 0),[Ut,Gt]=(0,Z.useState)(null),Kt=(0,Z.useCallback)((e=`agent`,t)=>{Ht(void 0),Gt(t??null),Bt(e),Rt(!0)},[]),Jt=(0,Z.useCallback)((e,t)=>{let n=De.find(e=>e.id===t);Kt(e,n?{projectId:n.id,repoId:n.repo_id}:void 0)},[De,Kt]),Yt=(0,Z.useRef)(null),Xt=(0,Z.useRef)(null),{setHandler:Zt}=Wt();(0,Z.useEffect)(()=>{!i||!we(m)||fe(r).catch(()=>void 0)},[m,r,i]),(0,Z.useEffect)(()=>gr.onSessionSwitched(e=>{e.source_session===a&&(Xt.current={session:e.target_session,pin:!1},e.target_project===r&&nt.current.ensureTerminal(e.target_session,{preview:!0}),t(`/project/${e.target_project}/session/${e.target_session}`))}),[a,t,r]);let[Qt,$t]=(0,Z.useState)(null),an=(0,Z.useCallback)((e,t)=>{let n=nt.current.openEditorInLeaf(e,{session:t.session,path:t.path,...t.root===void 0?{kind:`file`}:{kind:`external`,root:t.root}},{dedupeAcrossTree:!0});Xe(n),$t({session:t.session,path:t.path,...t.root===void 0?{}:{root:t.root},line:t.line,column:t.column,nonce:Date.now()})},[Xe]),sn=(0,Z.useCallback)((e,t,n)=>{Xe(B.focusedLeaf.id),B.openEditor(e,{preview:n?.preview}),Dt.current&&jt(!1),t&&[`file`,`external`].includes(e.kind??`file`)&&$t({session:e.session,path:e.path,...e.root===void 0?{}:{root:e.root},line:t.line,column:t.column,nonce:Date.now()})},[B,Xe]),ln=(0,Z.useCallback)((e,t,n,r)=>sn({...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&&Cr(t)===`notebook`?{view:`preview`}:{}},n,r),[sn]);_t(ln);let un=(0,Z.useCallback)((e,t,n)=>{let r=B.revealSource(e,t);Xe(r),$t({session:t.session,path:t.path,...t.root===void 0?{}:{root:t.root},line:n.line,column:n.column,nonce:Date.now()})},[B,Xe]),[pn,mn]=(0,Z.useState)(null),hn=(0,Z.useRef)(null),vn=(0,Z.useCallback)(e=>{hn.current=e},[]),H=(0,Z.useCallback)((e,t,n)=>ln(e,t,void 0,{preview:n?.preview??!0}),[ln]),U=(0,Z.useCallback)((e,r)=>{let i=P.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=>mr(e)})},[P,n,t]),wn=(0,Z.useCallback)(e=>B.promote(e),[B]),K=(0,Z.useCallback)((e,t,n,r)=>sn({kind:`external`,session:e,path:t,root:n},void 0,{preview:r?.preview??!0}),[sn]),En=Te(m),Dn=(0,Z.useCallback)(e=>{if(R!==void 0){if(!En){M.error(`Untitled drafts need a newer daemon — refresh the connection to update it`);return}Tt(R).then(({name:e})=>sn({kind:`untitled`,session:o,path:e})).catch(e=>M.error(e instanceof Error?e.message:`Could not create a draft`))}},[sn,R,En]),[On,An]=(0,Z.useState)(null);(0,Z.useEffect)(()=>(tt(An),()=>tt(null)),[]);let[jn,Mn]=(0,Z.useState)(null),Nn=()=>{let e=jn;if(Mn(null),!e||e.ref.type!==`editor`)return;let t=e.ref.tab.path;R!==void 0&&it(R,t).catch(()=>void 0),mt(t),B.close(e.leafId,e.ref)},Pn=(e,t,n,r)=>{An(null);let i={type:`editor`,tab:{kind:`untitled`,session:o,path:e}},a=W(i);for(let e of Sn(nt.current.tree))e.tabs.some(e=>W(e)===a)&&nt.current.close(e.id,i);h.invalidateQueries({queryKey:[`wt-tree`,t]}),setTimeout(()=>{nt.current.openEditor(r===void 0?{kind:`file`,session:t,path:n}:{kind:`external`,session:t,path:n,root:r})},0)};(0,Z.useEffect)(()=>(Zt(e=>{Ht(e?.accountId),Bt(e?.kind??`agent`),Rt(!0)}),()=>Zt(null)),[Zt]);let[Fn,q]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!L.loaded)return;let e=en(nt.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?x():void 0,e.some(e=>e.type===`editor`)?es():void 0]).finally(()=>q(!0))},[L.loaded,Ke]),(0,Z.useEffect)(()=>{if(It||!L.loaded||!u)return;Ft(r);let e=L.snapshot.active_session,n=P.find(t=>t.id===e);!a&&n&&n.status!==`archived`&&t(`/project/${r}/session/${n.id}`,{replace:!0})},[It,L,u,P,a,t,r]);let Ln=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(Ln.current||!L.loaded||!N.data)return;Ln.current=!0;let e=new Set(N.data.filter(e=>e.status!==`archived`).map(e=>e.id));nt.current.pruneSessions(e);let t=he.current,n=t.current().project_layouts;if(Object.keys(n).length>0){let r=Tn(e);t.update({project_layouts:Object.fromEntries(Object.entries(n).map(([t,n])=>[t,{...n,layout_tree:n.layout_tree?qt(n.layout_tree,r):null,active_session:n.active_session!==null&&e.has(n.active_session)?n.active_session:null}]))})}let r=vt.current.snapshot.session_order,i=r.filter(t=>e.has(t));i.length!==r.length&&vt.current.update({session_order:i})},[L.loaded,N.data]),(0,Z.useEffect)(()=>{if(!It)return;if(Dt.current){a&&(Ct(a),Et(e=>e.includes(a)?e:[...e,a])),V(!1);return}if(V(!1),!a){Yt.current=null;return}if(a===Yt.current&&!c)return;Yt.current=null;let e=Xt.current;Xt.current=null,nt.current.ensureTerminal(a,{preview:e?.session!==a||!e.pin});let t=vt.current;t.snapshot.active_session!==a&&t.update({active_session:a})},[It,a,c]);let Rn=Se();(0,Z.useEffect)(()=>{let e=le(Rn.data)??`Puddle`,t=P.filter(e=>e.status===`waiting_input`).length,n=z?.name??`Puddle`;return document.title=yh(n,e,t),()=>{document.title=e}},[P,z?.name,Rn.data]);let Bn=(0,Z.useCallback)(e=>{let n=a===e;n&&(Yt.current=e),B.removeTerminal(e),n&&(L.update({active_session:null}),t(`/project/${r}`))},[B,L,a,t,r]),Vn=Fe(),Hn=(0,Z.useCallback)(async e=>{let t=[...new Set(e)],n=await Promise.allSettled(t.map(e=>Vn.mutateAsync(e))),r=t.filter((e,t)=>n[t]?.status===`fulfilled`);for(let e of r)Bn(e);r.length>0&&(Ie(e=>{let t=new Set(e);for(let e of r)t.delete(e);return t}),Le.current!==null&&r.includes(Le.current)&&(Le.current=null));let i=n.filter(e=>e.status===`rejected`),a=i[0];i.length===1&&a?mr(a.reason):i.length>1&&M.error(`Couldn’t archive ${i.length} of ${t.length} sessions`)},[Vn,Bn]),Un={ids:Ne,onSelect:ze,onSelectOnly:Be,onArchive:e=>void Hn(e)},Wn=(0,Z.useCallback)((e,n)=>{if(Xe(e),B.activate(e,n),n.type===`terminal`&&n.session!==a){let e=ie.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[B,t,ie,a,Xe]),Gn=(0,Z.useCallback)((e,n)=>{if(n.type===`editor`&&wr(n.tab)===`untitled`){Mn({leafId:e,ref:n});return}let i=Cn(B.tree,e)?.tabs.findIndex(e=>W(e)===W(n))??-1;rc(Ke,{leafId:e,index:Math.max(0,i),ref:n}),B.close(e,n),n.type===`terminal`&&n.session===a&&(Yt.current=n.session,L.update({active_session:null}),t(`/project/${r}`))},[B,a,L,t,r,Ke]),Kn=(0,Z.useCallback)(()=>{let e=ge.current,n=e?new Set(e.filter(e=>e.status!==`archived`).map(e=>e.id)):null,r=ic(Ke,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=Cn(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=ie.find(e=>e.id===i.session)?.project_id;e&&t(`/project/${e}/session/${i.session}`)}},[B,Ke,a,ie,t]),qn=(0,Z.useCallback)((e,n,i)=>{let o=n.type===`terminal`?ie.find(e=>e.id===n.session)?.project_id:void 0;if(de&&o!==void 0&&o!==r&&n.type===`terminal`){Xt.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,ie,t,de,r]),Jn=B.focusedLeaf.tabs.find(e=>W(e)===B.focusedLeaf.activeKey)??null,Yn=Jn===null?null:Jn.type===`terminal`?Jn.session:Jn.tab.session,Xn=Yn===`00000000-0000-0000-0000-000000000000`?null:Yn,Zn=Me().data?.find(e=>e.id===z?.repo_id),Qn=(0,Z.useMemo)(()=>Oe(m)&&Zn&&z?{path:Zn.path,projectId:z.id,name:z.name,defaultBranch:Zn.default_base_branch}:null,[m,Zn,z]),$n=Xo(ie,Xn??a,L,Qn),J=$n.session,er=$n.root,tr=(0,Z.useCallback)(e=>{let t=ie.find(t=>t.id===e.session);if(e.root===void 0&&!t)return;let n=hn.current??er??J?.worktree_path??null,r=Zo(e,t?.worktree_path??e.root??``,n);if(Dt.current&&jt(!0),L.update({sidebar_mode:`files`,...Dt.current?{}:{sidebar_collapsed:!1}}),r.browseRoot!==void 0){let n=t?.id??J?.id??e.session;mn({session:n,root:r.browseRoot,nonce:Date.now()})}else n!==r.directory&&$n.pin(e.session);Qs({path:r.path,directory:r.directory})},[$n,ie,er,J?.worktree_path,L]),nr=(0,Z.useCallback)(async(e,t)=>{let n=t.trim();if(n===``||n===wo(e.path))return!0;let r=Oo(To(e.path),n);try{let{rekeyBuffer:t}=await k(async()=>{let{rekeyBuffer:e}=await import(`./buffer-store-BAQjeFXg.js`).then(e=>e.n);return{rekeyBuffer:e}},__vite__mapDeps([34,1,2,6,7,3,4,5,8,12,13,35,36,37])),n=await Ge(e.session,e.path,r,e.root),i=t(e.session,e.path,n.path,e.root);return nt.current.renameFile(e,n.path),h.invalidateQueries({queryKey:[`wt-tree`,e.session]}),h.invalidateQueries({queryKey:[`wt-git-status`,e.session]}),setTimeout(()=>{(i?.dirty?Tr(e.session,n.path,i.content,i.baseMtimeMs,e.root):Promise.resolve()).then(()=>Er(e.session,e.path,e.root))},0),!0}catch(e){return mr(e),!1}},[h]),ir=(0,Z.useCallback)((e,t)=>{if(t.kind===`dir`){Dt.current&&jt(!0),L.update({sidebar_mode:`files`,...Dt.current?{}:{sidebar_collapsed:!1}}),mn({session:e,root:t.path,nonce:Date.now()});return}let n=rr(t,er);n!==null&&mn({session:e,root:n,nonce:Date.now()}),ln(e,t.path,t.line===void 0?void 0:{line:t.line,column:t.column},t.root===void 0?void 0:{root:t.root})},[ln,L,er]),ar=J?.id??null,or=(0,Z.useCallback)(async e=>{if(ar===null)throw Error(`No worktree is available for this project.`);let t=await cr(ar,e,{root:er}),n=t.kind===`file`&&t.root===void 0&&er!==void 0?{...t,root:er}:t;if(n.kind===`dir`&&n.relativePath!==void 0){Dt.current&&jt(!0),L.update({sidebar_mode:`files`,...Dt.current?{}:{sidebar_collapsed:!1}}),Qs({path:n.relativePath,root:er,expandTarget:!0});return}ir(ar,n)},[ar,er,ir]);(0,Z.useEffect)(()=>rn(or),[or]);let sr=Pu(L.snapshot.sidebar_mode),lr=L.snapshot.sidebar_collapsed,ur=L.snapshot.sessions_collapsed,dr=(0,Z.useCallback)(e=>{let t=B.focusedLeaf,n=t.tabs.find(e=>W(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){M.error(`Focus a terminal or agent to insert`);return}gr.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[B]);(0,Z.useEffect)(()=>(tn(dr),()=>tn(null)),[dr]);let fr=(0,Z.useCallback)(e=>{let t=he.current,n=ge.current,i=We.current;if(!t.loaded||!n||!i)return!1;let{patch:a,projectBased:o}=fn(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),O().projectBasedLayout!==o&&ee({projectBasedLayout:o}),!0},[r]),pr=de?`project`:`profile`,hr=L.snapshot.layout_tree,Dr=L.snapshot.layout_ref,Or=ne.snapshot.project_layouts;(0,Z.useEffect)(()=>{ne.loaded&&xn({scope:pr,projectId:r,layoutRef:Dr,signature:dn(hr),slices:Object.fromEntries(Object.entries(Or).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:dn(t.layout_tree)}])),capture:()=>{let e=vt.current.current();return{layout_tree:e.layout_tree,active_session:e.active_session}},apply:fr})},[ne.loaded,pr,r,hr,Dr,Or,fr]),(0,Z.useEffect)(()=>()=>xn(null),[]);let kr=(0,Z.useRef)({}),Ar=e=>{let t=B.focusedLeaf;if(t.tabs.length<2)return;let n=t.tabs.findIndex(e=>W(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&&Wn(t.id,i)},jr=e=>{bt?(L.update({sidebar_mode:e}),jt(!0)):L.update({sidebar_mode:e,sidebar_collapsed:!1})};kr.current={"tab.close":()=>{let e=B.focusedLeaf,t=e.tabs.find(t=>W(t)===e.activeKey);t&&Gn(e.id,t)},"tab.reopen":Kn,"tab.newUntitled":()=>Dn(B.focusedLeaf),"tab.next":()=>Ar(1),"tab.prev":()=>Ar(-1),"editor.save":()=>{Go(B.activeEditorTab)},"sidebar.left":()=>bt?jt(e=>!e):L.update({sidebar_collapsed:!L.snapshot.sidebar_collapsed}),"sidebar.right":()=>bt?V(e=>!e):L.update({sessions_collapsed:!L.snapshot.sessions_collapsed}),"nav.files":()=>jr(`files`),"nav.search":()=>jr(`search`),"nav.changes":()=>jr(`changes`),"nav.worktrees":()=>jr(`worktrees`),"session.newAgent":()=>Kt(`agent`),"session.newTerminal":()=>Kt(`terminal`)},(0,Z.useEffect)(()=>{let e=Object.keys(kr.current).map(e=>re(e,()=>kr.current[e]?.()));return()=>e.forEach(e=>e())},[]);let Mr=B.activeEditorTab,Nr=Mr?.kind===`diff`&&J&&Mr.session===J.id?Mr.path:null,Pr=Mr&&(Mr.kind??`file`)===`file`&&J&&Mr.session===J.id?Mr.path:null,Fr=Mr?.kind===`external`&&Mr.root!==void 0?{path:Mr.path,root:Mr.root}:null,Rr=e=>({preview:e?.preview??!0}),Br=(e,t)=>{if(J){let n=t?.root??er,r=n===void 0?{}:{root:n};sn({kind:`diff`,session:J.id,path:e,...r,...t?.gitArea===void 0?{}:{git_area:t.gitArea}},void 0,Rr(t))}},Vr=(e,t,n)=>{if(J){let r=n?.root??er,i=r===void 0?{}:{root:r};sn({kind:`commit`,session:J.id,path:e,sha:t,...i},void 0,Rr(n))}},Hr=(e,t,n)=>{if(!J)return;let r=t===void 0?void 0:{line:t,column:1};if(er!==void 0){sn({kind:`external`,session:J.id,path:e,root:er},r,Rr(n));return}ln(J.id,e,r,Rr(n))},Ur=(0,Z.useCallback)(e=>L.update({layout:{...L.snapshot.layout,...e}}),[L]),Wr=sc(L.snapshot.layout,[...lr?[]:[`nav`],`main`,...ur?[]:[`sessions`]]);if(!i)return null;if(!L.loaded||!z||!Fn)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`});let Gr=e=>(0,X.jsx)(Iu,{mode:sr,onModeChange:e=>L.update({sidebar_mode:e}),onCollapse:e,projectId:r,repoId:z.repo_id,sessions:P,target:$n,browseRequest:pn,onFiletreeRootChange:vn,compilableExtensions:j,onOpenCompilationSettings:_?ct:void 0,onOpenFile:H,onOpenExternalFile:K,onOpenTerminalIn:U,activeFilePath:Pr,activeExternalTab:Fr,activeDiffPath:Nr,onOpenDiff:Br,onOpenCommitFile:Vr,onOpenSearchFile:Hr}),Kr={onNewSessionIn:e=>Jt(`agent`,e),onNewTerminalIn:e=>Jt(`terminal`,e),onMoveProject:Ve},qr=e=>(0,X.jsx)(zm,{groups:ke,accounts:d,activeSessionId:a,onReorder:yt,onPromote:e=>B.ensureTerminal(e),archived:He,onNewSession:()=>Kt(`agent`),onNewTerminal:()=>Kt(`terminal`),onCollapse:e,onArchived:Bn,onArchiveDrop:e=>void Hn(e),selection:Un,projectActions:Kr}),Y=P.find(e=>e.id===St)?.id??P.find(e=>e.id===a)?.id??null,Jr=bt?(0,X.jsx)(Ys,{sessions:P,selected:Y,select:e=>{Ct(e),Et(t=>t.includes(e)?t:[...t,e])}}):(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[ft.map(({key:e,leafId:t,target:n})=>(0,X.jsx)(Uo,{sourceKey:e,leafId:t,target:n,onResult:pt,onError:ht,onRunningChange:gt},e)),(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(hh,{tree:B.tree,sessions:ie,reveal:Qt,onActivateTab:Wn,onCloseTab:Gn,onPromoteTab:wn,onArchived:Bn,onFocusLeaf:Qe,onScrollDrive:Xe,onResize:B.resize,onDropTab:qn,onSetTabView:B.setView,compilableExtensions:j,compilationProviders:A,compilationRunningKeys:te,onRunCompilation:(e,t)=>void ut(e,t),onSetCompilationMode:dt,onOpenCompilationSettings:_?ct:void 0,onRevealPreviewSource:un,onRevealCompiledSource:an,onNewUntitled:Dn,onRevealFile:tr,onRenameFile:nr,focusedLeafId:B.focusedLeaf.id,scrollDriverLeafId:Ze,scrollChannel:`${R??``}:${Ke}`})})]});return(0,X.jsx)(ds,{tree:B.tree,parked:[...et,...wt,...Y?[Y]:[]],onOpenFile:ir,children:(0,X.jsx)(Cm,{onDrop:B.drop,onArchive:e=>void Hn([e]),renderOverlay:e=>{let t=e.type===`terminal`?ie.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?f(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,X.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden`,children:[bt?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fu,{mode:sr,onExpand:()=>jt(!0),onSelect:e=>{L.update({sidebar_mode:e}),jt(!0)}}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:Jr}),(0,X.jsx)(Lm,{groups:ke,accounts:d,activeSessionId:a,onReorder:yt,onPromote:e=>B.ensureTerminal(e),onExpand:()=>V(!0),onNewTerminal:()=>Kt(`terminal`),onNewSession:()=>Kt(`agent`),onArchived:Bn,onArchiveDrop:e=>void Hn(e),selection:Un,projectActions:Kr}),At&&(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:()=>jt(!1)}),(0,X.jsx)(`div`,{className:`absolute inset-y-0 left-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:Gr(()=>jt(!1))})]}),Mt&&(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:()=>V(!1)}),(0,X.jsx)(`div`,{className:`absolute inset-y-0 right-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:qr(()=>V(!1))})]})]}):(0,X.jsxs)(X.Fragment,{children:[lr&&(0,X.jsx)(Fu,{mode:sr,onExpand:()=>L.update({sidebar_collapsed:!1}),onSelect:e=>L.update({sidebar_collapsed:!1,sidebar_mode:e})}),(0,X.jsxs)(_o,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:Wr,onLayoutChanged:Ur,children:[!lr&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(bo,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,children:Gr(()=>L.update({sidebar_collapsed:!0}))}),(0,X.jsx)(Co,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`})]}),(0,X.jsx)(bo,{id:`main`,children:Jr}),!ur&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Co,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`}),(0,X.jsx)(bo,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,children:qr(()=>L.update({sessions_collapsed:!0}))})]})]}),ur&&(0,X.jsx)(Lm,{groups:ke,accounts:d,activeSessionId:a,onReorder:yt,onPromote:e=>B.ensureTerminal(e),onExpand:()=>L.update({sessions_collapsed:!1}),onNewTerminal:()=>Kt(`terminal`),onNewSession:()=>Kt(`agent`),onArchived:Bn,onArchiveDrop:e=>void Hn(e),selection:Un,projectActions:Kr})]}),(0,X.jsx)(zu,{projectId:Ut?.projectId??r,repoId:Ut?.repoId??z.repo_id,open:Lt,kind:zt,seedAccountId:Vt,onOpenChange:Rt,onCreated:e=>void t(`/project/${e.project_id}/session/${e.id}`)}),(0,X.jsx)(Ko,{request:On,targetSession:J,targetRoot:er,targetLabel:J===null?``:er===void 0?J.branch:er,profileId:R,onClose:()=>An(null),onSaved:Pn}),(0,X.jsx)(Wo,{request:y,onOpenChange:e=>!e&&b(null)}),(0,X.jsx)(Sr,{open:jn!==null,onOpenChange:e=>!e&&Mn(null),children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Discard this draft?`}),(0,X.jsxs)(xr,{children:[`Closing an untitled tab deletes its draft — `,p,` saves it into the worktree instead.`]})]}),(0,X.jsxs)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>Mn(null),children:`Keep editing`}),(0,X.jsx)(G,{variant:`danger`,onClick:Nn,children:`Discard`})]})]})})]})})})}export{bh as Workspace};
|
|
20
|
+
`},Sd={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 Cd(e){let{announcements:t=Sd,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=xd}=e,{announce:a,announcement:o}=_d(),s=rd(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),yd((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(hd,{id:r,value:i.draggable}),Z.createElement(gd,{id:s,announcement:o}));return n?(0,ls.createPortal)(u,n):u}var wd;(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`})(wd||={});function Td(){}function Ed(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Dd(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Od=Object.freeze({x:0,y:0});function kd(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Ad(e,t){let n=ud(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 jd(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Md(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Nd(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 Pd(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Fd(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 Id=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=Fd(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Md)};function Ld(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 Rd=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&&Ld(r,a)){let n=Nd(a).reduce((e,t)=>e+kd(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(jd)};function zd(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Bd(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Od}function Vd(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 Hd=Vd(1);function Ud(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 Wd(e,t,n){let r=Ud(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 Gd={ignoreTransform:!1};function Kd(e,t){t===void 0&&(t=Gd);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Wu(e).getComputedStyle(e);t&&(n=Wd(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 qd(e){return Kd(e,{ignoreTransform:!0})}function Jd(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Yd(e,t){return t===void 0&&(t=Wu(e).getComputedStyle(e)),t.position===`fixed`}function Xd(e,t){t===void 0&&(t=Wu(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 Zd(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Gu(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ku(i)||qu(i)||n.includes(i))return n;let a=Wu(e).getComputedStyle(i);return i!==e&&Xd(i,a)&&n.push(i),Yd(i,a)?n:r(i.parentNode)}return e?r(e):n}function Qd(e){let[t]=Zd(e,1);return t??null}function $d(e){return!Vu||!e?null:Hu(e)?e:Uu(e)?Gu(e)||e===Ju(e).scrollingElement?window:Ku(e)?e:null:null}function ef(e){return Hu(e)?e.scrollX:e.scrollLeft}function tf(e){return Hu(e)?e.scrollY:e.scrollTop}function nf(e){return{x:ef(e),y:tf(e)}}var rf;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(rf||={});function af(e){return!Vu||!e?!1:e===document.scrollingElement}function of(e){let t={x:0,y:0},n=af(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 sf={x:.2,y:.2};function cf(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=sf);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=of(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=rf.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=rf.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=rf.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=rf.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function lf(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 uf(e){return e.reduce((e,t)=>ad(e,nf(t)),Od)}function df(e){return e.reduce((e,t)=>e+ef(t),0)}function ff(e){return e.reduce((e,t)=>e+tf(t),0)}function pf(e,t){if(t===void 0&&(t=Kd),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Qd(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var mf=[[`x`,[`left`,`right`],df],[`y`,[`top`,`bottom`],ff]],hf=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=Zd(t),r=uf(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of mf)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})}},gf=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 _f(e){let{EventTarget:t}=Wu(e);return e instanceof t?e:Ju(e)}function vf(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 yf;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(yf||={});function bf(e){e.preventDefault()}function xf(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 Sf={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},Cf=(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}}},wf=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 gf(Ju(t)),this.windowListeners=new gf(Wu(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(yf.Resize,this.handleCancel),this.windowListeners.add(yf.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(yf.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&pf(n),t(Od)}handleKeyDown(e){if(cd(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Sf,coordinateGetter:a=Cf,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}:Od;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=od(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}=of(n),p=lf(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,ad(od(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()}};wf.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Sf,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 Tf(e){return!!(e&&`distance`in e)}function Ef(e){return!!(e&&`delay`in e)}var Df=class{constructor(e,t,n){n===void 0&&(n=_f(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=Ju(i),this.documentListeners=new gf(this.document),this.listeners=new gf(n),this.windowListeners=new gf(Wu(i)),this.initialCoordinates=ud(r)??Od,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(yf.Resize,this.handleCancel),this.windowListeners.add(yf.DragStart,bf),this.windowListeners.add(yf.VisibilityChange,this.handleCancel),this.windowListeners.add(yf.ContextMenu,bf),this.documentListeners.add(yf.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ef(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Tf(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(yf.Click,xf,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(yf.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=ud(e)??Od,s=od(n,o);if(!t&&a){if(Tf(a)){if(a.tolerance!=null&&vf(s,a.tolerance))return this.handleCancel();if(vf(s,a.distance))return this.handleStart()}if(Ef(a)&&vf(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()}},Of={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},kf=class extends Df{constructor(e){let{event:t}=e,n=Ju(t.target);super(e,Of,n)}};kf.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 Af={move:{name:`mousemove`},end:{name:`mouseup`}},jf;(function(e){e[e.RightClick=2]=`RightClick`})(jf||={});var Mf=class extends Df{constructor(e){super(e,Af,Ju(e.event.target))}};Mf.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===jf.RightClick?!1:(r?.({event:n}),!0)}}];var Nf={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Pf=class extends Df{constructor(e){super(e,Nf)}static setup(){return window.addEventListener(Nf.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Nf.move.name,e)};function e(){}}};Pf.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 Ff;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Ff||={});var If;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(If||={});function Lf(e){let{acceleration:t,activator:n=Ff.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=If.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=zf({delta:d,disabled:!a}),[m,h]=Zu(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case Ff.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Ff.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===If.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}=cf(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 Rf={x:{[rf.Backward]:!1,[rf.Forward]:!1},y:{[rf.Backward]:!1,[rf.Forward]:!1}};function zf(e){let{delta:t,disabled:n}=e,r=td(t);return $u(e=>{if(n||!r||!e)return Rf;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[rf.Backward]:e.x[rf.Backward]||i.x===-1,[rf.Forward]:e.x[rf.Forward]||i.x===1},y:{[rf.Backward]:e.y[rf.Backward]||i.y===-1,[rf.Forward]:e.y[rf.Forward]||i.y===1}}},[n,t,r])}function Bf(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return $u(e=>t==null?null:r??e??null,[r,t])}function Vf(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 Hf;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Hf||={});var Uf;(function(e){e.Optimized=`optimized`})(Uf||={});var Wf=new Map;function Gf(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=Qu(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=$u(t=>{if(d&&!n)return Wf;if(!t||t===Wf||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 hf(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 Hf.Always:return!1;case Hf.BeforeDragging:return n;default:return!n}}}function Kf(e,t){return $u(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function qf(e,t){return Kf(e,t)}function Jf(e){let{callback:t,disabled:n}=e,r=Xu(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 Yf(e){let{callback:t,disabled:n}=e,r=Xu(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 Xf(e){return new hf(Kd(e),e)}function Zf(e,t,n){t===void 0&&(t=Xf);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=Jf({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=Yf({callback:a});return Yu(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Qf(e){return Bd(e,Kf(e))}var $f=[];function ep(e){let t=(0,Z.useRef)(e),n=$u(n=>e?n&&n!==$f&&e&&t.current&&e.parentNode===t.current.parentNode?n:Zd(e):$f,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function tp(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=$d(e.target);t&&n(e=>e?(e.set(t,nf(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=$d(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,nf(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=>{$d(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>ad(e,t),Od):uf(e):Od,[e,t])}function np(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!==Od;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?od(e,n.current):Od}function rp(e){(0,Z.useEffect)(()=>{if(!Vu)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 ip(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 ap(e){return(0,Z.useMemo)(()=>e?Jd(e):null,[e])}var op=[];function sp(e,t){t===void 0&&(t=Kd);let[n]=e,r=ap(n?Wu(n):null),[i,a]=(0,Z.useState)(op);function o(){a(()=>e.length?e.map(e=>af(e)?r:new hf(t(e),e)):op)}let s=Yf({callback:o});return Yu(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function cp(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Ku(t)?t:e}function lp(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=Yf({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(Ku(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=ed((0,Z.useCallback)(e=>{let n=cp(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 up=[{sensor:kf,options:{}},{sensor:wf,options:{}}],dp={current:{}},fp={draggable:{measure:qd},droppable:{measure:qd,strategy:Hf.WhileDragging,frequency:Uf.Optimized},dragOverlay:{measure:Kd}},pp=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}},mp={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new pp,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Td},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:fp,measureDroppableContainers:Td,windowRect:null,measuringScheduled:!1},hp={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Td,draggableNodes:new Map,over:null,measureDroppableContainers:Td},gp=(0,Z.createContext)(hp),_p=(0,Z.createContext)(mp);function vp(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new pp}}}function yp(e,t){switch(t.type){case wd.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case wd.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 wd.DragEnd:case wd.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case wd.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new pp(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case wd.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 pp(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case wd.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new pp(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function bp(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(gp),a=td(r),o=td(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!cd(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=pd(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function xp(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Sp(e){return(0,Z.useMemo)(()=>({draggable:{...fp.draggable,...e?.draggable},droppable:{...fp.droppable,...e?.droppable},dragOverlay:{...fp.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Cp(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;Yu(()=>{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=Bd(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=Qd(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var wp=(0,Z.createContext)({...Od,scaleX:1,scaleY:1}),Tp;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Tp||={});var Ep=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=up,collisionDetection:o=Id,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(yp,void 0,vp),[f,p]=bd(),[m,h]=(0,Z.useState)(Tp.Uninitialized),g=m===Tp.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??dp,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,ee]=(0,Z.useState)(null),O=Qu(l,Object.values(l)),k=rd(`DndDescribedBy`,t),te=(0,Z.useMemo)(()=>b.getEnabled(),[b]),A=Sp(s),{droppableRects:j,measureDroppableContainers:M,measuringScheduled:ne}=Gf(te,{dragging:g,dependencies:[y.x,y.y],config:A.droppable}),N=Bf(v,_),P=(0,Z.useMemo)(()=>D?ud(D):null,[D]),re=ke(),ie=qf(N,A.draggable.measure);Cp({activeNode:_==null?null:v.get(_),config:re.layoutShiftCompensation,initialRect:ie,measure:A.draggable.measure});let F=Zf(N,A.draggable.measure,ie),ae=Zf(N?N.parentElement:null),I=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:N,collisionRect:null,collisions:null,droppableRects:j,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=b.getNodeFor(I.current.over?.id),se=lp({measure:A.dragOverlay.measure}),ce=se.nodeRef.current??N,le=g?se.rect??F:null,ue=!!(se.nodeRef.current&&se.rect),de=Qf(ue?null:F),fe=ap(ce?Wu(ce):null),pe=ep(g?oe??N:null),L=sp(pe),me=xp(c,{transform:{x:y.x-de.x,y:y.y-de.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:F,containerNodeRect:ae,draggingNodeRect:le,over:I.current.over,overlayNodeRect:se.rect,scrollableAncestors:pe,scrollableAncestorRects:L,windowRect:fe}),he=P?ad(P,y):null,ge=tp(pe),R=np(ge),_e=np(ge,[F]),ve=ad(me,R),ye=le?Hd(le,me):null,be=C&&ye?o({active:C,collisionRect:ye,droppableRects:j,droppableContainers:te,pointerCoordinates:he}):null,xe=Pd(be,`id`),[Se,Ce]=(0,Z.useState)(null),we=zd(ue?me:ad(me,_e),Se?.rect??null,F),Te=(0,Z.useRef)(null),z=(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:I,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=O.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=O.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=O.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ls.unstable_batchedUpdates)(()=>{r?.(i),h(Tp.Initializing),d({type:wd.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Te.current),ee(a)})},onMove(e){d({type:wd.DragMove,coordinates:e})},onEnd:s(wd.DragEnd),onCancel:s(wd.DragCancel)});Te.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=I.current,o=null;if(t&&i){let{cancelDrop:s}=O.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===wd.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=wd.DragCancel)}w.current=null,(0,ls.unstable_batchedUpdates)(()=>{d({type:e}),h(Tp.Uninitialized),Ce(null),E(null),ee(null),Te.current=null;let t=e===wd.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=O.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Ee=Vf(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,z(n,t))},[v,z]));rp(a),Yu(()=>{F&&m===Tp.Initializing&&h(Tp.Initialized)},[F,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=O.current,{active:t,activatorEvent:n,collisions:r,over:i}=I.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ve.x,y:ve.y},over:i};(0,ls.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ve.x,ve.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=I.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=O.current,o=r.get(xe),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,ls.unstable_batchedUpdates)(()=>{Ce(s),a?.(c),f({type:`onDragOver`,event:c})})},[xe]),Yu(()=>{I.current={activatorEvent:D,active:C,activeNode:N,collisionRect:ye,collisions:be,droppableRects:j,draggableNodes:v,draggingNode:ce,draggingNodeRect:le,droppableContainers:b,over:Se,scrollableAncestors:pe,scrollAdjustedTranslate:ve},S.current={initial:le,translated:ye}},[C,N,be,ye,v,ce,le,j,b,Se,pe,ve]),Lf({...re,delta:y,draggingRect:ye,pointerCoordinates:he,scrollableAncestors:pe,scrollableAncestorRects:L});let De=(0,Z.useMemo)(()=>({active:C,activeNode:N,activeNodeRect:F,activatorEvent:D,collisions:be,containerNodeRect:ae,dragOverlay:se,draggableNodes:v,droppableContainers:b,droppableRects:j,over:Se,measureDroppableContainers:M,scrollableAncestors:pe,scrollableAncestorRects:L,measuringConfiguration:A,measuringScheduled:ne,windowRect:fe}),[C,N,F,D,be,ae,se,v,b,j,Se,M,pe,L,A,ne,fe]),Oe=(0,Z.useMemo)(()=>({activatorEvent:D,activators:Ee,active:C,activeNodeRect:F,ariaDescribedById:{draggable:k},dispatch:d,draggableNodes:v,over:Se,measureDroppableContainers:M}),[D,Ee,C,F,d,k,v,Se,M]);return Z.createElement(vd.Provider,{value:p},Z.createElement(gp.Provider,{value:Oe},Z.createElement(_p.Provider,{value:De},Z.createElement(wp.Provider,{value:we},i)),Z.createElement(bp,{disabled:n?.restoreFocus===!1})),Z.createElement(Cd,{...n,hiddenTextDescribedById:k}));function ke(){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}}}),Dp=(0,Z.createContext)(null),Op=`button`,kp=`Draggable`;function Ap(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=rd(kp),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(gp),{role:p=Op,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?wp:Dp),[v,y]=ed(),[b,x]=ed(),S=ip(o,t),C=Qu(n);return Yu(()=>(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===Op?!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 jp(){return(0,Z.useContext)(_p)}var Mp=`Droppable`,Np={timeout:25};function Pp(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=rd(Mp),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(gp),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}={...Np,...i},_=Qu(h??r),v=Yf({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]=ed((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Qu(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:wd.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:wd.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:wd.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 Fp(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=td(n);return!n&&!r&&s&&i(s),Yu(()=>{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 Ip={x:0,y:0,scaleX:1,scaleY:1};function Lp(e){let{children:t}=e;return Z.createElement(gp.Provider,{value:hp},Z.createElement(wp.Provider,{value:Ip},t))}var Rp={position:`fixed`,touchAction:`none`},zp=e=>cd(e)?`transform 250ms ease`:void 0,Bp=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=zp}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Rp,width:s.width,height:s.height,top:s.top,left:s.left,transform:dd.Transform.toString(d),transformOrigin:i&&r?Ad(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),Vp={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:dd.Transform.toString(t)},{transform:dd.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 Hp(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Xu((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=cp(a);if(!c)return;let{transform:l}=Wu(a).getComputedStyle(a),u=Ud(l);if(!u)return;let d=typeof t==`function`?t:Up(t);return pf(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 Up(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Vp,...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 Wp=0;function Gp(e){return(0,Z.useMemo)(()=>{if(e!=null)return Wp++,Wp},[e])}var Kp=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}=jp(),S=(0,Z.useContext)(wp),C=Gp(d?.id),w=xp(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=Kf(f),E=Hp({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(Lp,null,Z.createElement(Fp,{animation:E},d&&C?Z.createElement(Bp,{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 qp({status:e,kind:t=`agent`,agentType:n,detectedAgentType:r,stale:i=!1,className:a,iconClassName:o=`size-3`,iconStrokeScale:s=1}){let c=t===`terminal`?r:n,l=`${t===`terminal`?c?`${c} in terminal`:`terminal`:c??`agent`} — status: ${e.replace(`_`,` `)}${i?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,X.jsx)(`span`,{className:V(`status-glyph`,a),"data-status":e,"data-kind":t,"data-stale":i||void 0,role:`img`,title:i?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":l,children:t===`terminal`&&!c?(0,X.jsx)(Mt,{className:o,strokeWidth:2*s}):(0,X.jsx)(Gt,{type:c??``,className:o,strokeScale:s})})}var Jp=[`starting`,`running`,`waiting_input`],Yp=[`exited`,`interrupted`],Xp={Item:nt,Separator:gt,Sub:bt,SubTrigger:pt,SubContent:at},Zp={Item:q,Separator:jn,Sub:En,SubTrigger:Ln,SubContent:Fn};function Qp(e,t){let n=I(`resume`),r=I(`kill`),i=Fe(),a=N(),o=Ne(),s=ke(),c=De(),l=P(),u=ce(),d=Nt(),f=Ce(),p=oe(f??void 0),m=be(f??void 0),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(e.title??``),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=(p.data??[]).filter(t=>t.agent_type===e.agent_type),D=!e.worktree_missing&&e.status!==`archived`&&E.some(t=>t.id!==e.account_id),ee=(p.data??[]).filter(t=>t.agent_type!==e.agent_type&&t.logged_in),O=m.data?.default_account_id,k=typeof O==`number`?O:null,te=(p.data??[]).filter(e=>e.logged_in),A=k===null?te:[...te.filter(e=>e.id===k),...te.filter(e=>e.id!==k)];return{menu:{session:e,resumable:Yp.includes(e.status)&&!e.conversation_missing,live:Jp.includes(e.status),archived:e.status===`archived`,canMigrate:D,sameAgent:E,handoffTargets:!e.worktree_missing&&e.status!==`archived`?ee:[],setHandoffTo:T,resume:()=>n.mutate(e.id,{onError:e=>{let t=hr(e);t?d(`/project/${t.projectId}/session/${t.sessionId}`):mr(e)}}),kill:()=>r.mutate(e.id,{onError:e=>mr(e)}),openClearEnv:()=>g(`clear-env`),openTerminal:()=>u.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void d(`/project/${e.project_id}/session/${e.id}`),onError:e=>mr(e)}),spawnAccounts:A,defaultAccountId:k,spawnAgent:t=>u.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void d(`/project/${e.project_id}/session/${e.id}`),onError:e=>mr(e)}),openRename:()=>{x(e.title??``),v(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>mr(e)}),unarchive:()=>a.mutate(e.id,{onError:e=>mr(e)}),setMigrateTo:C},dialogs:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Sr,{open:h===`clear-env`,onOpenChange:e=>{e||g(null)},children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Clear captured environment?`}),(0,X.jsx)(xr,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,X.jsxs)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>g(null),children:`Cancel`}),(0,X.jsx)(G,{variant:`danger`,disabled:l.isPending,onClick:()=>l.mutate(e.id,{onSuccess:e=>{g(null),M.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{g(null),mr(e)}}),children:`Clear captured env`})]})]})}),(0,X.jsx)(Sr,{open:_,onOpenChange:v,children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Rename session`}),(0,X.jsx)(xr,{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:y.trim()},{onSuccess:()=>v(!1),onError:e=>mr(e)})},children:[(0,X.jsx)(b,{value:y,onChange:e=>x(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,X.jsxs)(vr,{children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,onClick:()=>v(!1),children:`Cancel`}),(0,X.jsx)(G,{type:`submit`,disabled:o.isPending,children:`Rename`})]})]})]})}),(0,X.jsx)(Sr,{open:S!==null,onOpenChange:e=>!e&&C(null),children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsxs)(br,{children:[`Move this session to `,S?.label,`?`]}),(0,X.jsx)(xr,{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)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>C(null),children:`Cancel`}),(0,X.jsx)(G,{disabled:s.isPending,onClick:()=>{S&&s.mutate({sessionId:e.id,accountId:S.id},{onSuccess:()=>{C(null),M.success(`Moved to ${S.label}`)},onError:e=>{C(null),mr(e)}})},children:`Move session`})]})]})}),(0,X.jsx)(Sr,{open:w!==null,onOpenChange:e=>!e&&T(null),children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsxs)(br,{children:[`Hand off to `,w?.agent_type,`?`]}),(0,X.jsxs)(xr,{children:[`A new session starts in this worktree and branch on`,` `,(0,X.jsx)(`span`,{className:`text-fg`,children:w?.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)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>T(null),children:`Cancel`}),(0,X.jsx)(G,{disabled:c.isPending,onClick:()=>{w&&c.mutate({sessionId:e.id,accountId:w.id},{onSuccess:e=>{T(null),M.success(`Handed off to ${w.agent_type}`),d(`/session/${e.id}`)},onError:e=>{T(null),mr(e)}})},children:`Hand off`})]})]})})]})}}function $p({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)(St,{}),` Resume`]}),t.live&&(0,X.jsxs)(n,{onSelect:t.kill,children:[(0,X.jsx)(st,{}),` Kill`]}),(0,X.jsxs)(n,{onSelect:t.openRename,children:[(0,X.jsx)(S,{}),` Rename`]}),!t.archived&&(0,X.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,X.jsx)(Wr,{}),` Clear captured env`]}),t.canMigrate&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Oi,{}),` 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)(Vr,{}),` 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)(Gt,{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)(Mt,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Gn,{}),` 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)(Gt,{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=te(`vscode`,s.worktree_path,A())},children:[(0,X.jsx)(Gr,{}),` Open in VS Code`]}),(0,X.jsxs)(n,{onSelect:()=>{window.location.href=te(`cursor`,s.worktree_path,A())},children:[(0,X.jsx)(Gr,{}),` 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)(Nn,{}),` Archive`]})]}),t.archived&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.unarchive,children:[(0,X.jsx)(An,{}),` Unarchive`]})]})]})}function em({batch:e}){return(0,X.jsxs)(q,{onSelect:()=>e.archiveAll(e.sessionIds),children:[(0,X.jsx)(Nn,{}),` Archive all`,(0,X.jsx)(`span`,{className:`ml-auto pl-3 tabular-nums text-fg-muted`,children:e.sessionIds.length})]})}function tm({menu:e}){return(0,X.jsxs)(vt,{children:[(0,X.jsx)(Ct,{asChild:!0,children:(0,X.jsxs)(G,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:e=>e.preventDefault(),children:[(0,X.jsx)(ht,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,X.jsx)(lt,{align:`end`,children:(0,X.jsx)($p,{kit:Xp,menu:e})})]})}function nm({session:e,onArchived:t,batch:n,children:r}){let{menu:i,dialogs:a}=Qp(e,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Rn,{children:[(0,X.jsx)(Dn,{asChild:!0,children:typeof r==`function`?r(i):r}),(0,X.jsx)(Pn,{children:n?(0,X.jsx)(em,{batch:n}):(0,X.jsx)($p,{kit:Zp,menu:i})})]}),a]})}function rm({menu:e,batch:t}){return(0,X.jsx)(Pn,{children:t?(0,X.jsx)(em,{batch:t}):(0,X.jsx)($p,{kit:Zp,menu:e})})}var im=`application/x-puddle-sessions`,am=s(c().uuid()).min(1);function om(e,t,n,r,i){if(i.toggle){let e=new Set(t);return e.has(r)?e.delete(r):e.add(r),{selection:e,anchor:r}}if(i.shift&&n!==null){let t=e.indexOf(n),i=e.indexOf(r);if(t!==-1&&i!==-1){let r=Math.min(t,i),a=Math.max(t,i);return{selection:new Set(e.slice(r,a+1)),anchor:n}}}return{selection:new Set([r]),anchor:r}}function sm(e,t){let n=new Set(t),r=new Set([...e].filter(e=>n.has(e)));return r.size===e.size&&[...r].every(t=>e.has(t))?e:r}function cm(e,t,n){if(!t.has(n)||t.size<2)return[n];let r=e.filter(e=>t.has(e));return r.length>0?r:[n]}function lm(e){return JSON.stringify(e)}function um(e){try{return[...new Set(am.parse(JSON.parse(e)))]}catch{return[]}}function dm(e){return e.includes(im)}function fm(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=pm(t.x/e.width),i=pm(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 pm(e){return e<0?0:e>1?1:e}var mm=(0,Z.createContext)(null);function hm(){return(0,Z.useContext)(mm)}var gm=(0,Z.createContext)(null);function _m(){return(0,Z.useContext)(gm)}var vm=`leaf:`,ym=`tabdrop:`,bm=`strip:`,xm=`archive:`,Sm=e=>{let t=Rd(e);for(let e of[ym,bm]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:Id(e)};function Cm({onDrop:e,onArchive:t,renderOverlay:n,children:r}){let i=Dd(Ed(kf,{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)(Ep,{sensors:i,collisionDetection:Sm,onDragStart:e=>c(e.active.data.current?.ref??null),onDragMove:e=>{let t=e.over,n=wm(e),r=t&&n?Em(String(t.id),t.rect,t.data.current,n):null;Tm(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)(mm.Provider,{value:a,children:(0,X.jsx)(gm.Provider,{value:s,children:r})}),(0,X.jsx)(Kp,{dropAnimation:null,children:s?n(s):null})]})}function wm(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 Tm(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function Em(e,t,n,r){if(e.startsWith(ym)){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(bm)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(vm)){let n=fm({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 Dm=`application/x-puddle-project`,Om=`group-hover:[transform:translateX(var(--tail))]`;function km(e,t){let n=document.createElement(`div`);n.textContent=`${t} sessions`,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 Am({projectId:e,name:t,colour:n,actions:r,editLabel:i}){let[a,o]=(0,Z.useState)(!1),s=z(),c=_e(me().data?.protocol);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Pn,{children:[(0,X.jsxs)(q,{onSelect:()=>r.onNewSessionIn(e),children:[(0,X.jsx)(Gn,{}),`New agent`]}),(0,X.jsxs)(q,{onSelect:()=>r.onNewTerminalIn(e),children:[(0,X.jsx)(Mt,{}),`New terminal`]}),(0,X.jsx)(jn,{}),(0,X.jsxs)(q,{onSelect:i.onSelect,children:[(0,X.jsx)(S,{}),i.label]}),c&&(0,X.jsxs)(q,{onSelect:()=>o(!0),children:[(0,X.jsx)(Hn,{}),`Change project colour`]})]}),(0,X.jsx)(Sr,{open:a,onOpenChange:o,children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Project colour`}),(0,X.jsx)(xr,{className:g(n),children:t})]}),(0,X.jsx)(y,{value:n,label:`Project colour`,disabled:s.isPending,onChange:t=>s.mutate({id:e,colour:t},{onSuccess:()=>o(!1),onError:e=>mr(e)})})]})})]})}function jm(e,t){let{isOver:n,setNodeRef:r}=Pp({id:`${xm}${e}`}),i=_m(),[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=>{!dm(e.dataTransfer.types)&&!ql(e.dataTransfer.types)||(e.preventDefault(),o(!0))},onDragLeave:()=>o(!1),onDrop:e=>{o(!1);let n=um(e.dataTransfer.getData(im));if(n.length>0){e.preventDefault(),t(n);return}let r=Kl(e.dataTransfer.getData(Wl));r?.type===`terminal`&&(e.preventDefault(),t([r.session]))}}}}function Mm({onArchiveDrop:e,onExpand:t}){let n=jm(`rail`,e);return(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{ref:n.setNodeRef,type:`button`,onClick:t,...n.props,className:V(`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)(Nn,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Archived sessions`})]})}),(0,X.jsx)(pn,{side:`left`,children:`Drop selected sessions here to archive them`})]})}function Nm({collapsed:e,children:t}){return(0,X.jsx)(`div`,{className:V(`grid transition-[grid-template-rows] duration-200`,e?`grid-rows-[0fr]`:`grid-rows-[1fr]`),children:t})}function Pm({icon:e,label:t,onClick:n,active:r=!1,tooltipSide:i=`bottom`}){return(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:V(`flex items-center rounded-md p-1.5 transition-colors`,r?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,X.jsx)(e,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(pn,{side:i,children:t})]})}function Fm({session:e,accountLabel:t}){return(0,X.jsxs)(`span`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:nn()(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:[e.detected_agent_type?(0,X.jsx)(Gt,{type:e.detected_agent_type,className:`size-3 shrink-0`}):(0,X.jsx)(Mt,{className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:e.detected_agent_type?`${e.detected_agent_type} · terminal`:`terminal`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Gt,{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 Im({session:e,accountLabel:t,activeSessionId:n,onPromote:r,onArchived:i,selectedIds:a,selection:o}){let{menu:s,dialogs:c}=Qp(e,i),l=nn(),u=o.ids.has(e.id),d=u&&a.length>1?{sessionIds:a,archiveAll:o.onArchive}:void 0;return(0,X.jsxs)(Rn,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(Dn,{asChild:!0,children:(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(Dt,{draggable:!1,"aria-current":e.id===n?`true`:void 0,onClick:t=>{let n=t.shiftKey||t.metaKey||t.ctrlKey;o.onSelect(e.id,{shift:t.shiftKey,toggle:t.metaKey||t.ctrlKey}),n&&t.preventDefault()},onDoubleClick:()=>r(e.id),onContextMenu:()=>{u||o.onSelectOnly(e.id)},to:`/project/${e.project_id}/session/${e.id}`,"aria-selected":u,className:V(`flex items-center rounded-md p-1 transition-colors hover:bg-elevated`,u?`bg-selection`:e.id===n&&`bg-elevated`),children:[(0,X.jsx)(qp,{status:e.status,kind:e.kind,agentType:e.agent_type,detectedAgentType:e.detected_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:l(e)})]})})}),(0,X.jsx)(pn,{side:`left`,children:(0,X.jsx)(Fm,{session:e,accountLabel:t})})]}),(0,X.jsx)(rm,{menu:s,batch:d}),c]})}function Lm({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,onExpand:a,onNewTerminal:o,onNewSession:s,onArchived:c,onArchiveDrop:l,selection:u,projectActions:d}){let[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[_,y]=(0,Z.useState)(null),b=z(),x=new Map(t.map(e=>[e.id,e.label])),S=(0,Z.useMemo)(()=>e.flatMap(e=>e.sessions.map(e=>e.id)),[e]),C=S.filter(e=>u.ids.has(e)),w=(t,n)=>{let i=On(e,t,n);i&&r(i)},T=(e,t)=>{y(null);let n=v(t);!n||n===e.abbrev||b.mutate({id:e.projectId,abbrev:n},{onError:e=>mr(e)})};return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 w-9 shrink-0 flex-col items-center overflow-hidden 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)(Pm,{icon:bi,label:`Show sessions`,onClick:a,tooltipSide:`left`}),(0,X.jsx)(Pm,{icon:Gn,label:`New agent`,onClick:s,tooltipSide:`left`}),(0,X.jsx)(Pm,{icon:Mt,label:`New terminal`,onClick:o,tooltipSide:`left`})]}),(0,X.jsx)(`div`,{className:`no-scrollbar flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto overscroll-contain 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`}),_===e.projectId?(0,X.jsx)(ln,{initial:e.abbrev,maxLength:5,className:`w-7 text-center text-[8px] uppercase leading-3 text-fg`,onCommit:t=>T(e,t),onCancel:()=>y(null)}):(0,X.jsxs)(Rn,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(Dn,{asChild:!0,children:(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Dt,{to:`/project/${e.projectId}`,...Mn(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Dm,e.projectId),h(e.projectId)},onDragEnd:()=>h(null),className:V(`w-7 truncate text-center text-[8px] uppercase leading-3 transition-colors`,g(e.colour)?V(g(e.colour),`hover:opacity-75`):`text-fg-muted hover:text-fg`,m===e.projectId&&`opacity-50`),children:e.abbrev})})}),(0,X.jsx)(pn,{side:`left`,children:e.name})]}),(0,X.jsx)(Am,{projectId:e.projectId,name:e.name,colour:e.colour,actions:d,editLabel:{label:`Change project abbreviation`,onSelect:()=>y(e.projectId)}})]}),(0,X.jsx)(Nm,{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=>{let n=cm(S,u.ids,e.id);t.dataTransfer.setData(Wl,Gl({type:`terminal`,session:e.id})),t.dataTransfer.setData(im,lm(n)),t.dataTransfer.effectAllowed=`copyMove`,n.length>1&&km(t,n.length),u.ids.has(e.id)||u.onSelectOnly(e.id),p({sourceId:e.id,sessionIds:n})},onDragEnd:()=>p(null),onDragOver:t=>{t.preventDefault(),f?.sessionIds.length===1&&f.sourceId!==e.id&&w(f.sourceId,e.id)},className:V(`transition-opacity`,f?.sessionIds.includes(e.id)&&`opacity-50`),children:(0,X.jsx)(Im,{session:e,accountLabel:e.account_id===null?void 0:x.get(e.account_id),activeSessionId:n,onPromote:i,onArchived:c,selectedIds:C,selection:u})},e.id))})})]},e.projectId))}),(0,X.jsx)(Mm,{onArchiveDrop:l,onExpand:a})]})}function Rm({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,selectedIds:a,selection:o,ellipsis:s,lastActive:c=!1}){let l=nn(),u=o?.ids.has(e.id)??!1,d=o&&u&&a&&a.length>1?{sessionIds:a,archiveAll:o.onArchive}:void 0,f=e.kind===`terminal`?`terminal`:e.agent_type??`agent`,p=c?e.last_activity_at===null?``:` · ${Xe(e.last_activity_at)}`:e.account_id!==null&&n.has(e.account_id)?` · ${n.get(e.account_id)}`:``;return(0,X.jsx)(nm,{session:e,onArchived:i,batch:d,children:n=>(0,X.jsxs)(Dt,{draggable:!1,onClick:t=>{if(!o)return;let n=t.shiftKey||t.metaKey||t.ctrlKey;o.onSelect(e.id,{shift:t.shiftKey,toggle:t.metaKey||t.ctrlKey}),n&&t.preventDefault()},onDoubleClick:r&&(()=>r(e.id)),onContextMenu:()=>{o&&!u&&o.onSelectOnly(e.id)},to:`/project/${e.project_id}/session/${e.id}`,"aria-selected":o?u:void 0,className:V(`group flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-elevated compact:gap-1.5 compact:py-1`,u?`bg-selection`:e.id===t&&`bg-elevated`),children:[(0,X.jsx)(qp,{status:e.status,kind:e.kind,agentType:e.agent_type,detectedAgentType:e.detected_agent_type,stale:e.stale_running}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(hc,{text:l(e),className:`font-sans text-xs text-fg`,hoverClass:Om}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:[(0,X.jsx)(ci,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(hc,{text:e.branch,hoverClass:Om})]}),(0,X.jsx)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:(0,X.jsx)(hc,{text:`${f}${p}`,hoverClass:Om})})]}),e.skip_permissions&&(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Ci,{className:`size-3.5 shrink-0 text-warning`})}),(0,X.jsx)(pn,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(si,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(pn,{children:`Worktree directory is gone — archive only`})]}),e.conversation_missing&&(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(hi,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(pn,{children:`Native conversation is missing — resume unavailable`})]}),e.native_sync===`fallback`&&e.status!==`archived`&&(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Ti,{className:`size-3.5 shrink-0 text-fg-muted`})}),(0,X.jsx)(pn,{children:`In-agent conversation switches are not synchronised`})]}),s&&(0,X.jsx)(`span`,{className:`hidden group-hover:inline-flex has-[[data-state=open]]:inline-flex pointer-coarse:inline-flex`,children:(0,X.jsx)(tm,{menu:n})})]})})}function zm({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onNewSession:o,onNewTerminal:s,onCollapse:c,onArchived:l,onArchiveDrop:u,selection:d,projectActions:f}){return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 py-1.5`,children:[(0,X.jsx)(Pm,{icon:yi,label:`Hide sessions`,onClick:c}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(Pm,{icon:Gn,label:`New agent`,onClick:o}),(0,X.jsx)(Pm,{icon:Mt,label:`New terminal`,onClick:s})]})]}),(0,X.jsx)(Bm,{groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:l,onArchiveDrop:u,selection:d,projectActions:f})]})}function Bm({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:o,onArchiveDrop:s,selection:c,projectActions:l}){let[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=jm(`list`,s),b=_m(),x=u!==null||b?.type===`terminal`,S=z(),C=ae(`palette.toggle`),w=new Map(t.map(e=>[e.id,e.label])),T=e.reduce((e,t)=>e+t.sessions.length,0),E=(0,Z.useMemo)(()=>e.flatMap(e=>e.sessions.map(e=>e.id)),[e]),D=E.filter(e=>c.ids.has(e)),{height:ee,handle:O}=uc(`sessions-archived`,200,{sized:`below`,min:96}),k=(0,Z.useMemo)(()=>{let t=new Set,n=e.map(e=>{let n=a.filter(t=>t.project_id===e.projectId);for(let e of n)t.add(e.id);return{...e,sessions:n}}),r=a.filter(e=>!t.has(e.id));return[...n.filter(e=>e.sessions.length>0),...r.length>0?[{projectId:``,name:``,abbrev:``,colour:null,repoId:-1,sessions:r}]:[]]},[e,a]),te=(t,n)=>{let i=On(e,t,n);i&&r(i)},A=(e,t)=>{h(null);let n=t.trim();!n||n===e.name||S.mutate({id:e.projectId,name:n},{onError:e=>mr(e)})};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain py-1.5`,children:[T===0&&a.length===0&&(0,X.jsxs)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`No sessions yet — press `,C,` 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)(ln,{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=>A(e,t),onCancel:()=>h(null)}):(0,X.jsxs)(Rn,{children:[(0,X.jsx)(Dn,{asChild:!0,children:(0,X.jsx)(Dt,{to:`/project/${e.projectId}`,...Mn(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Dm,e.projectId),p(e.projectId)},onDragEnd:()=>p(null),className:V(`block truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide transition-colors compact:pb-0.5 compact:pt-1.5`,g(e.colour)?V(g(e.colour),`hover:opacity-75`):`text-fg-gold hover:text-fg`,f===e.projectId&&`opacity-50`),children:e.name})}),(0,X.jsx)(Am,{projectId:e.projectId,name:e.name,colour:e.colour,actions:l,editLabel:{label:`Change project name`,onSelect:()=>h(e.projectId)}})]}),(0,X.jsx)(Nm,{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=>{let n=cm(E,c.ids,e.id);t.dataTransfer.setData(Wl,Gl({type:`terminal`,session:e.id})),t.dataTransfer.setData(im,lm(n)),t.dataTransfer.effectAllowed=`copyMove`,n.length>1&&km(t,n.length),c.ids.has(e.id)||c.onSelectOnly(e.id),d({sourceId:e.id,sessionIds:n})},onDragEnd:()=>d(null),onDragOver:t=>{t.preventDefault(),u?.sessionIds.length===1&&u.sourceId!==e.id&&te(u.sourceId,e.id)},className:V(`transition-opacity`,u?.sessionIds.includes(e.id)&&`opacity-50`),children:(0,X.jsx)(Rm,{session:e,activeSessionId:n,accountLabel:w,onPromote:i,onArchived:o,selectedIds:D,selection:c,ellipsis:!0})},e.id))})})]},e.projectId))]}),(a.length>0||x)&&(0,X.jsxs)(X.Fragment,{children:[_&&(0,X.jsx)(dc,{handle:O,label:`Resize the archived sessions`}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col pb-1.5`,style:_?{height:ee,maxHeight:`70%`}:void 0,children:[(0,X.jsxs)(`button`,{ref:y.setNodeRef,type:`button`,onClick:()=>v(e=>!e),...y.props,className:V(`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`,y.armed&&`bg-selection text-fg`),children:[(0,X.jsx)(er,{className:V(`size-3 transition-transform`,_&&`rotate-90`)}),(0,X.jsx)(Nn,{className:`size-3`}),(0,X.jsx)(`span`,{children:`Archived`}),(0,X.jsx)(`span`,{className:`ml-auto tabular-nums`,children:a.length})]}),_&&(0,X.jsx)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:k.map(e=>(0,X.jsxs)(`div`,{children:[e.name!==``&&(0,X.jsx)(`div`,{className:V(`truncate px-3 pb-0.5 pt-1.5 text-2xs font-medium uppercase tracking-wide`,g(e.colour)?V(g(e.colour),`opacity-70`):`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)(Rm,{session:e,activeSessionId:n,accountLabel:w,onArchived:o,ellipsis:!0,lastActive:!0})},e.id))})]},e.projectId))})]})]})]})}function Vm({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 Hm=[`running`,`waiting_input`];function Um({sessionId:e,status:t}){let n=Hm.includes(t),{data:r}=F(e,n),i=r?.vars??[];if(!n||i.length===0)return null;let a=async(e,t)=>{try{await navigator.clipboard.writeText(t),M.success(`${e} value copied`)}catch{M.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)(U,{children:[(0,X.jsx)(H,{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)(pn,{children:[e.bytes,` B ·`,` `,t===void 0?`value unavailable from this daemon`:`click to copy value`]})]},e.name)})})})]})}function Wm(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var Gm=[`running`,`waiting_input`];function Km({sessionId:e,status:t}){let n=Gm.includes(t),{data:r}=de(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)(qm,{sessionId:e,port:t},t.port))})})]})}function qm({sessionId:e,port:t}){let n=Se().data;return(0,X.jsxs)(vt,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(Ct,{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)(pn,{children:[t.command,` · pid `,t.pid]})]}),(0,X.jsxs)(lt,{align:`start`,children:[pr()===null?(0,X.jsx)(nt,{asChild:!0,children:(0,X.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,X.jsx)(nt,{onSelect:()=>{Ie(`/forward/${e}/${t.port}`).catch(mr)},children:`Open via proxy`}),(0,X.jsx)(nt,{onSelect:()=>{n&&navigator.clipboard.writeText(Wm(t.port,n.username,n.hostname)).then(()=>M.success(`Copied`))},children:`Copy ssh -L`})]})]})}var Jm=[`interrupted`,`exited`];function Ym({session:e}){let t=I(`resume`),n=Nt();return Jm.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)(G,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>{let t=hr(e);t?n(`/project/${t.projectId}/session/${t.sessionId}`):mr(e)}}),children:[(0,X.jsx)(St,{}),`Resume`]})}):null}function Xm({tab:e,directory:t,onReveal:n,onCompilationSettings:r,onRename:i,editing:a,children:o}){let s=Se(),c=me().data?.protocol,l=Cl(),u=Ll(e.session,e.root,t),d=(0,Z.useMemo)(()=>({sid:e.session,root:e.root,directory:t,host:hl(s.data)}),[e.session,e.root,t,s.data]),f=e.root!==void 0&&!Ae(c),p=l!==null&&_l(l.source,d),m=l!==null&&gl(l.source,d),h=!f&&(p&&m||l!==null&&vl(l.source,d)&&ge(c)),[g,_]=(0,Z.useState)(!1),v=ko(t,e.path),y=()=>{!l||!h||u.paste(l,To(e.path)).then(e=>{l.mode===`cut`&&bl(l.id,e)})},b=t=>{navigator.clipboard.writeText(t?e.path:v),M.success(t?`Relative path copied`:`Path copied`)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Rn,{children:[(0,X.jsx)(Dn,{asChild:!0,children:o}),(0,X.jsx)(Pn,{onCloseAutoFocus:e=>{a&&e.preventDefault()},children:(0,X.jsx)(eu,{absolutePath:v,readOnly:f,canPaste:h,onCut:()=>yl([e.path],`cut`,d),onCopy:()=>yl([e.path],`copy`,d),onPaste:y,onCopyPath:()=>b(!1),onCopyRelativePath:()=>b(!0),onReveal:n,onCompilationSettings:r,onRename:i,onDelete:()=>_(!0),onDownload:()=>{Ue(e.session,e.path,e.root).catch(e=>M.error(e instanceof Error?e.message:`Download failed`))}})})]}),(0,X.jsx)(Sr,{open:g,onOpenChange:_,children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsxs)(br,{children:[`Delete “`,wo(e.path),`”?`]}),(0,X.jsxs)(xr,{children:[`This permanently removes it from `,t,`. There is no undo.`]})]}),(0,X.jsxs)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,X.jsx)(G,{variant:`danger`,onClick:()=>{_(!1),u.remove([e.path])},children:`Delete`})]})]})})]})}function Zm({session:e,onArchived:t}){let n=Fe();return(0,X.jsx)(`button`,{type:`button`,disabled:n.isPending,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:async r=>{r.stopPropagation();try{await n.mutateAsync(e),t(e)}catch(e){mr(e)}},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg disabled:cursor-wait disabled:opacity-50 group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":`Archive session`,title:`Archive session`,children:(0,X.jsx)(Nn,{className:`size-3`})})}var Qm=`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`,$m=`group-hover:[transform:translateX(var(--tail))]`;function eh({leaf:e,sessions:t,onActivate:n,onClose:r,onPromote:i,onArchived:a,onSetView:o,compilableExtensions:s,compilationProviders:c,compilationRunningKeys:l,onRunCompilation:u,onSetCompilationMode:d,onOpenCompilationSettings:f,onNewFile:p,onRevealFile:m,onRenameFile:h}){let g=new Map(t.map(e=>[e.id,e.branch])),_=new Map(t.map(e=>[e.id,e.worktree_path])),v=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),y=hm(),b=y?.leafId===e.id&&y.index!==void 0?y.index:null,{setNodeRef:x}=Pp({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),S=e=>{let t=Dr(e.path,e.session,v,g,e.root,_);return wr(e)===`diff`?`${t} (diff)`:wr(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,X.jsxs)(`div`,{ref:x,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&&p()},children:[e.tabs.map((p,g)=>(0,X.jsxs)(Z.Fragment,{children:[b===g&&(0,X.jsx)(th,{}),(0,X.jsx)(ch,{tab:p,leafId:e.id,index:g,active:W(p)===e.activeKey,preview:W(p)===e.previewKey,session:p.type===`terminal`?t.find(e=>e.id===p.session):void 0,fileSession:p.type===`editor`&&p.tab.root===void 0?t.find(e=>e.id===p.tab.session):void 0,fileDirectory:p.type===`editor`&&(wr(p.tab)===`file`||wr(p.tab)===`external`)?p.tab.root??t.find(e=>e.id===p.tab.session)?.worktree_path:void 0,label:p.type===`editor`?S(p.tab):``,onActivate:()=>n(p),onClose:()=>r(p),onPromote:()=>i(p),onArchived:a,onSetView:e=>o(p,e),compilable:Ro(p.type===`editor`?p.tab.path:``,s),provider:p.type===`editor`?c.find(e=>e.extensions.includes(Lo(p.tab.path)??``)):void 0,compilationRunning:p.type===`editor`&&l.has(zo(p.tab.session,p.tab.path,p.tab.root)),onRunCompilation:()=>{p.type===`editor`&&(n(p),requestAnimationFrame(()=>u(p.tab)))},onSetCompilationMode:e=>{p.type===`editor`&&(n(p),requestAnimationFrame(()=>d(p.tab,e)))},onOpenCompilationSettings:p.type===`editor`&&f?()=>f({session:p.tab.session,path:p.tab.path,...p.tab.root===void 0?{}:{root:p.tab.root}}):void 0,onRevealFile:()=>p.type===`editor`&&m(p.tab),onRenameFile:e=>p.type===`editor`?h(p.tab,e):Promise.resolve(!1)})]},W(p))),b===e.tabs.length&&(0,X.jsx)(th,{})]})}function th(){return(0,X.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function nh({active:e,children:t}){return(0,X.jsx)(`span`,{className:V(`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 rh={source:`preview`,preview:`linked`,linked:`locked`,locked:`source`},ih={source:Y,preview:tr,linked:di,locked:mi},ah={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 oh({view:e,notebook:t=!1,onSetView:n}){let r=ih[e];return(0,X.jsx)(`button`,{onClick:r=>{r.stopPropagation(),n(t?e===`source`?`preview`:`source`:rh[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":t?e===`source`?`Show notebook`:`Show JSON source`:ah[e],title:t?e===`source`?`Show notebook`:`Show JSON source`:ah[e],children:(0,X.jsx)(r,{className:`size-3`})})}function sh({mode:e,running:t,onRun:n,onSetMode:r,provider:i}){let a=e===`eager`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:t,onClick:e=>{e.stopPropagation(),n()},className:V(`hidden rounded-sm p-0.5 transition-colors hover:text-fg disabled:cursor-wait group-hover:inline-flex pointer-coarse:inline-flex`,a?`text-fg-muted`:`text-accent`),"aria-label":i?.terminal?`Run in terminal`:i?.action===`run`?`Run file`:`Compile on demand`,title:i?.terminal?`Run in terminal`:i?.action===`run`?`Run file`:`Compile on demand`,children:t&&!a?(0,X.jsx)(pi,{className:`size-3 animate-spin`}):(0,X.jsx)(St,{className:`size-3`})}),i?.eager&&(0,X.jsx)(`button`,{type:`button`,disabled:t,onClick:e=>{e.stopPropagation(),r(a?`on_demand`:`eager`)},className:V(`hidden rounded-sm p-0.5 transition-colors hover:text-fg disabled:cursor-wait group-hover:inline-flex pointer-coarse:inline-flex`,a?`text-accent`:`text-fg-muted`),"aria-label":a?`Disable eager compilation`:`Enable eager compilation`,title:a?`Eager compilation — switch to on demand`:`Compile eagerly on disk changes`,children:t&&a?(0,X.jsx)(pi,{className:`size-3 animate-spin`}):(0,X.jsx)(Un,{className:`size-3`})})]})}function ch({tab:e,leafId:t,index:n,active:r,preview:i,session:a,fileSession:o,fileDirectory:s,label:c,onActivate:l,onClose:u,onPromote:d,onArchived:f,onSetView:p,compilable:m,provider:h,compilationRunning:g,onRunCompilation:_,onSetCompilationMode:v,onOpenCompilationSettings:y,onRevealFile:b,onRenameFile:x}){let[S,C]=(0,Z.useState)(!1),w=nn(),T=W(e),{attributes:E,listeners:D,setNodeRef:ee,isDragging:O}=Ap({id:`drag:${t}:${T}`,data:{ref:e,fromLeafId:t}}),{setNodeRef:k}=Pp({id:`tabdrop:${t}:${T}`,data:{leafId:t,index:n}}),te=e=>{ee(e),k(e)},A=V(Qm,r?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`,i&&`italic`,O&&`opacity-40`),j=(0,X.jsx)(`div`,{ref:te,...S?{}:E,...S?{}:D,onClick:l,onDoubleClick:d,className:V(A,S&&`cursor-text select-text`),children:e.type===`terminal`?(0,X.jsxs)(X.Fragment,{children:[a&&(0,X.jsx)(qp,{status:a.status,kind:a.kind,agentType:a.agent_type,detectedAgentType:a.detected_agent_type,stale:a.stale_running}),(0,X.jsx)(`span`,{className:`truncate`,children:a?w(a):e.session.slice(0,8)}),(0,X.jsxs)(nh,{active:r,children:[a&&a.status!==`archived`&&(0,X.jsx)(Zm,{session:a.id,onArchived:f}),(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),u()},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)(Pt,{className:`size-3`})})]})]}):(0,X.jsxs)(X.Fragment,{children:[e.tab.view===`linked`&&(0,X.jsx)(di,{className:`size-3 shrink-0 text-fg-muted`}),e.tab.view===`locked`&&(0,X.jsx)(mi,{className:`size-3 shrink-0 text-fg-muted`}),S?(0,X.jsx)(lh,{initial:e.tab.path.split(`/`).pop()??e.tab.path,onCommit:x,onCancel:()=>C(!1),onCommitted:()=>C(!1)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(hc,{text:c,hoverClass:$m,containerClassName:`flex-[0_1_auto]`,className:(wr(e.tab)===`file`||wr(e.tab)===`external`)&&(Cr(e.tab.path)!==null||m)?`-mr-20 pr-20`:`-mr-11 pr-11`}),(0,X.jsx)(os,{session:e.tab.session,path:e.tab.path,kind:wr(e.tab),root:e.tab.root}),(0,X.jsxs)(nh,{active:r,children:[(wr(e.tab)===`file`||wr(e.tab)===`external`)&&Cr(e.tab.path)!==null&&(0,X.jsx)(oh,{notebook:Cr(e.tab.path)===`notebook`,view:e.tab.view??`source`,onSetView:p}),(wr(e.tab)===`file`||wr(e.tab)===`external`)&&m&&!e.tab.generated_by&&(0,X.jsx)(sh,{provider:h,mode:e.tab.compile_mode??`on_demand`,running:g,onRun:_,onSetMode:v}),(0,X.jsx)(cs,{session:e.tab.session,path:e.tab.path,kind:wr(e.tab),root:e.tab.root,label:c,onClose:u})]})]})]})}),M=(0,X.jsx)(pn,{side:`bottom`,children:(0,X.jsx)(Ou,{name:e.type===`terminal`?a?w(a):e.session:c,session:e.type===`terminal`?a:o})});return e.type===`terminal`&&a?(0,X.jsxs)(U,{children:[(0,X.jsx)(nm,{session:a,onArchived:()=>f(e.session),children:(0,X.jsx)(H,{asChild:!0,children:j})}),M]}):e.type===`editor`&&s!==void 0&&(wr(e.tab)===`file`||wr(e.tab)===`external`)?(0,X.jsxs)(U,{open:!S&&void 0,children:[(0,X.jsx)(Xm,{tab:e.tab,directory:s,onReveal:b,onCompilationSettings:m?y:void 0,onRename:()=>C(!0),editing:S,children:(0,X.jsx)(H,{asChild:!0,children:j})}),M]}):(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{asChild:!0,children:j}),M]})}function lh({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 uh(e,t,n){return{focus:e===`press`,driveScroll:t&&n!==`linked`}}function dh({leaf:e,sessions:t,reveal:n,onActivateTab:r,onCloseTab:i,onPromoteTab:a,onArchived:o,onFocusLeaf:s,onScrollDrive:c,onDropTab:l,onSetTabView:u,compilableExtensions:d,compilationProviders:f,compilationRunningKeys:p,onRunCompilation:m,onSetCompilationMode:h,onOpenCompilationSettings:g,onRevealPreviewSource:_,onRevealCompiledSource:v,onNewUntitled:y,onRevealFile:b,onRenameFile:x,focused:S,scrollDriver:C,scrollChannel:w}){let T=e.tabs.find(t=>W(t)===e.activeKey)??null,E=T?.type===`terminal`?W(T):null,D=T?.type===`terminal`?t.find(e=>e.id===T.session)??null:null,ee=fs(E),{setNodeRef:O}=Pp({id:`leaf:${e.id}`}),k=hm(),te=_m(),A=ae(`palette.toggle`),j=T?.type===`editor`?T.tab:null,M=j?.view??`source`,ne=j!==null&&(wr(j)===`file`||wr(j)===`external`)&&Cr(j.path)!==null,N=C&&ne&&M!==`linked`,P=!N&&(M===`locked`||ne&&M===`source`),re=t=>{let n=uh(t,ne,M);n.focus&&s(e.id),n.driveScroll&&c(e.id)},ie=(0,Z.useRef)(null),F=(0,Z.useRef)(()=>void 0);F.current=()=>{T&&r(e.id,T)},(0,Z.useEffect)(()=>{let e=ie.current;if(!e)return;let t=()=>F.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[I,oe]=(0,Z.useState)(null),se=(0,Z.useRef)(l);return se.current=l,(0,Z.useEffect)(()=>{let t=ie.current;if(!t)return;let n=e=>e.dataTransfer!==null&&ql(e.dataTransfer.types),r=e=>{let n=t.getBoundingClientRect();return fm({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`),oe(r(e)))},a=e=>{t.contains(e.relatedTarget)||oe(null)},o=t=>{if(!n(t))return;t.preventDefault(),t.stopPropagation(),oe(null);let i=Kl(t.dataTransfer?.getData(`application/x-puddle-tab`)??``);i&&se.current(e.id,i,r(t))},s=()=>oe(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:()=>re(`press`),onWheelCapture:()=>re(`scroll`),children:[e.tabs.length>0&&(0,X.jsx)(eh,{leaf:e,sessions:t,onActivate:t=>r(e.id,t),onClose:t=>i(e.id,t),onPromote:a,onArchived:o,onSetView:(t,n)=>u(e.id,t,n),compilableExtensions:d,compilationProviders:f,compilationRunningKeys:p,onRunCompilation:t=>m(e.id,t),onSetCompilationMode:h,onOpenCompilationSettings:g,onNewFile:()=>y(e),onRevealFile:b,onRenameFile:x}),(0,X.jsxs)(`div`,{ref:e=>{ie.current=e,O(e)},className:`relative min-h-0 flex-1`,children:[T?.type===`editor`&&(0,X.jsx)(`div`,{className:`absolute inset-0`,children:(0,X.jsx)(kr.Provider,{value:JSON.stringify([w,e.id,W(T)]),children:(0,X.jsx)(ns,{tab:T.tab,onRunCompilation:d.has(Lo(T.tab.path)??``)?()=>m(e.id,T.tab):void 0,compilationRunning:p.has(zo(T.tab.session,T.tab.path,T.tab.root)),reveal:n,focused:S,scrollDriver:N,scrollReceiver:P,scrollChannel:w,onRevealSource:j?.view===`linked`||j?.view===`locked`?t=>_(e.id,j,t):void 0,onRevealCompiledSource:t=>v(e.id,t)})})}),(0,X.jsx)(`div`,{ref:ee,className:V(`absolute inset-0 py-1 pl-4 pr-2`,!E&&`hidden`)}),te&&(0,X.jsx)(`div`,{className:`absolute inset-0 z-10 cursor-grabbing`,"aria-hidden":`true`}),k?.leafId===e.id&&k.index===void 0&&(0,X.jsx)(ph,{zone:k.zone}),I!==null&&(0,X.jsx)(ph,{zone:I}),D&&(0,X.jsx)(Ym,{session:D}),!T&&(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,X.jsx)(Vm,{className:`size-24 text-fg-muted/40`}),(0,X.jsx)(`button`,{type:`button`,onClick:Zt,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:A})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1 empty:hidden`,children:[D&&(0,X.jsx)(Um,{sessionId:D.id,status:D.status}),D&&(0,X.jsx)(Km,{sessionId:D.id,status:D.status})]})]})}var fh={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 ph({zone:e}){return(0,X.jsx)(`div`,{className:V(`pointer-events-none absolute z-20 bg-accent/20`,fh[e])})}var mh=`bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`;function hh({tree:e,...t}){let n=(0,Z.useMemo)(()=>{let t=new Set,n=[];for(let r of en(e)){if(r.type!==`editor`||![`file`,`diff`,`external`].includes(wr(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)(is,{buffers:n}),(0,X.jsx)(gh,{node:e,...t})]})}function gh({node:e,...t}){if(e.kind===`leaf`)return(0,X.jsx)(dh,{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,compilableExtensions:t.compilableExtensions,compilationProviders:t.compilationProviders,compilationRunningKeys:t.compilationRunningKeys,onRunCompilation:t.onRunCompilation,onSetCompilationMode:t.onSetCompilationMode,onOpenCompilationSettings:t.onOpenCompilationSettings,onRevealPreviewSource:t.onRevealPreviewSource,onRevealCompiledSource:t.onRevealCompiledSource,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)(_o,{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)(Co,{className:n===`horizontal`?`w-px ${mh}`:`h-px ${mh}`}),(0,X.jsx)(bo,{id:e.id,minSize:64,children:(0,X.jsx)(gh,{node:e,...t})})]},e.id))},e.id)}function _h(e,t){return e.session===t.session&&e.path===t.path&&(e.root??``)===(t.root??``)&&wr(e)===wr(t)}function vh(e,t=`profile`){let n=e.snapshot,r=(0,Z.useRef)(null),i=(0,Z.useRef)(null),a=(0,Z.useRef)(t),o=(0,Z.useRef)(!1);a.current!==t&&(a.current=t,r.current=null,i.current=null,o.current=!1),!n.layout_tree&&!r.current&&(r.current=sn(n));let s=n.layout_tree??r.current??hn([]),c=(0,Z.useMemo)(()=>$t(s),[s]),l=(0,Z.useCallback)(t=>e.update({layout_tree:t}),[e]),u=(0,Z.useRef)(l);u.current=l,(0,Z.useEffect)(()=>{o.current||e.loaded&&!n.layout_tree&&r.current&&(o.current=!0,en(r.current).length>0&&u.current(r.current))},[e.loaded,n.layout_tree]),(0,Z.useEffect)(()=>{e.loaded&&c!==s&&n.layout_tree&&u.current(c)},[e.loaded,c,s,n.layout_tree]);let[d,f]=(0,Z.useState)(null),p=(d?Cn(c,d):null)??Sn(c)[0]??hn([]),m=p.tabs.find(e=>W(e)===p.activeKey)??null,h=m?.type===`editor`?m.tab:null,g=(e,t)=>{let n=Yt(t);n&&(i.current={leafId:e,target:n})};return(0,Z.useMemo)(()=>({tree:c,focusedLeaf:p,activeEditorTab:h,focusLeaf:e=>f(e),activate:(e,t)=>{f(e),g(e,t);let n=W(t),r=Cn(c,e)?.activeKey===n,i=Ht(r?c:Vt(c,e,n),t);r&&i===c||l(i)},close:(e,t)=>{let n=wn(c,e,W(t)),r=Cn(n,e),i=r?.tabs.find(e=>W(e)===r.activeKey);i&&g(e,i),l(i?Ht(n,i):n)},openEditor:(e,t)=>{let n=p.id;f(n);let r={type:`editor`,tab:e};g(n,r);let i=t?.preview?Lt(c,n,r):an(c,n,r);l(Ht(i,r))},openEditorInLeaf:(e,t,n)=>{let r={type:`editor`,tab:t},i=W(r),a=n?.activate??!0,o=n?.dedupeAcrossTree?Bt(c,i):null;if(o){let e=Rt(c,o.id,r);return a&&(f(o.id),e=Vt(e,o.id,i)),o.previewKey===i&&(e=mn(e,i)),e!==c&&l(e),o.id}let s=Cn(c,e)?.id??p.id;return a?(f(s),g(s,r),l(Ht(an(c,s,r),r))):l(un(c,s,r)),s},setCompileMode:(e,t)=>{let n=Ut(c,e,t);n!==c&&l(n)},ensureTerminal:(e,t)=>{let n=`term:${e}`,r=Bt(c,n);if(r){f(r.id);let e=r.activeKey!==n,i=!t?.preview&&r.previewKey===n;if(e||i){let t=c;e&&(t=Vt(t,r.id,n)),i&&(t=mn(t,n)),l(t)}}else{let n=p.id;f(n);let r={type:`terminal`,session:e};l(t?.preview?Lt(c,n,r):an(c,n,r))}},promote:e=>l(mn(c,W(e))),setView:(e,t,n)=>{g(e,t);let r=Kt(c,e,W(t),n),i=Cn(r,e),a=i?.tabs.find(e=>W(e)===i.activeKey);l(a?Ht(r,a):r)},revealSource:(e,t)=>{let n=i.current,r=n&&_h(n.target,t)?n:null,a=r&&Qt(c,t,r.leafId)?r.leafId:void 0,o=Qt(c,t,a);if(o){f(o.leafId);let e=Kt(c,o.leafId,W(o.ref),`source`);return e=Vt(e,o.leafId,W(o.ref)),i.current={leafId:o.leafId,target:t},e!==c&&l(e),o.leafId}let s=(r?Cn(c,r.leafId):null)?.id??Cn(c,e)?.id??p.id,u={type:`editor`,tab:{session:t.session,path:t.path,...t.kind===void 0?{}:{kind:t.kind},...t.root===void 0?{}:{root:t.root},view:`source`}};return f(s),i.current={leafId:s,target:t},l(an(c,s,u)),s},renameFile:(e,t)=>{let n=Jt(c,e,t);n!==c&&l(n)},removeTerminal:e=>{let t=Bt(c,`term:${e}`);t&&l(wn(c,t.id,`term:${e}`))},pruneSessions:e=>l(qt(c,Tn(e))),resize:(e,t)=>l(Xt(c,e,t)),drop:e=>{f(e.toLeafId),g(e.toLeafId,e.ref),l(Ht(zt(c,e),e.ref))}}),[c,p,h,l])}function yh(e,t,n){return n>0?`● ${n} waiting — ${e} (${t})`:`${e} — ${t}`}function bh(){return(0,X.jsx)(ot,{children:(0,X.jsx)(xh,{})})}function xh(){let e=Ot(),t=Nt(),n=ce(),r=e.id??``,i=/^[0-9a-f]{10}$/.test(r),a=e.sid??null,s=kt(),c=s.state?.notificationSession===a?s.key:null,l=je(i?r:void 0),u=l.data?.project.id===r?l.data:void 0,d=oe(l.data?.project.profile_id).data??[],f=nn(),p=ae(`editor.save`),m=me().data?.protocol,h=se(),g=Ir(xe(m)),_=Ee(m),v=zr(),[y,b]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(()=>new Set),te=(0,Z.useMemo)(()=>{let e=new Set(T);return S&&e.add(S),e},[T,S]),A=(0,Z.useMemo)(()=>g.data?.providers.filter(e=>e.available)??[],[g.data]),j=(0,Z.useMemo)(()=>new Set(A.flatMap(e=>e.extensions.map(e=>e.toLowerCase()))),[A]),ne=_n(),N=pe(),P=(0,Z.useMemo)(()=>u?.sessions??N.data?.filter(e=>e.project_id===r)??[],[u,N.data,r]),ie=N.data??P,F=D(),I=F.projectBasedLayout,ue=F.showAllProjectSessions,de=I&&ne.snapshot.layout_mode===`project`,L=bn(ne,r,de),he=(0,Z.useRef)(ne);he.current=ne;let ge=(0,Z.useRef)(N.data);ge.current=N.data;let R=l.data?.project.profile_id,_e=Pe(R),ve=be(R),Ce=ye(R??``),z=u?.project??_e.data?.find(e=>e.id===r),De=(0,Z.useMemo)(()=>kn((_e.data??(z?[z]:[])).filter(e=>!e.archived),ve.data?.projectOrder??[]),[_e.data,z,ve.data]),ke=(0,Z.useMemo)(()=>{let e=e=>e.status!==`archived`,t=N.data??P;return De.map(n=>({projectId:n.id,name:n.name,abbrev:C(n),colour:n.colour,repoId:n.repo_id,sessions:kn(t.filter(t=>t.project_id===n.id&&e(t)&&(ue||n.id===r)),L.snapshot.session_order)}))},[ue,P,r,L.snapshot.session_order,De,N.data]),Ae=(0,Z.useMemo)(()=>ke.flatMap(e=>e.sessions.map(e=>e.id)),[ke]),[Ne,Ie]=(0,Z.useState)(()=>new Set),Le=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{Ie(e=>sm(e,Ae)),Le.current!==null&&!Ae.includes(Le.current)&&(Le.current=null)},[Ae]);let ze=(0,Z.useCallback)((e,t)=>{Ie(n=>{let r=om(Ae,n,Le.current,e,t);return Le.current=r.anchor,r.selection})},[Ae]),Be=(0,Z.useCallback)(e=>{Le.current=e,Ie(new Set([e]))},[]),Ve=(0,Z.useCallback)((e,t)=>{let n=De.map(e=>e.id),r=In(n,e,t);r.some((e,t)=>e!==n[t])&&Ce.mutate({projectOrder:r})},[De,Ce]),He=(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(de||!ue)return t(P.filter(n));let r=N.data??P;return De.flatMap(e=>t(r.filter(t=>t.project_id===e.id&&n(t))))},[ue,de,P,N.data,De]),Ue=(0,Z.useRef)(De);Ue.current=De;let We=(0,Z.useRef)(_e.data);We.current=_e.data,(0,Z.useEffect)(()=>{let e=he.current;if(!e.loaded)return;let t=e.current(),n=t.layout_mode??`profile`;if(I&&n!==`project`){if(!N.data||!_e.data)return;let n=new Map(N.data.map(e=>[e.id,e.project_id])),i=cn(t,_e.data.map(e=>e.id),n,r);e.update({...i,project_layouts:on(i.project_layouts??{},t.project_layouts)})}else!I&&n===`project`&&e.update(gn(t,[r,...Ue.current.map(e=>e.id)]))},[I,ne.loaded,N.data,_e.data,r]);let Ke=de?`project:${r}`:`profile`,B=vh(L,Ke),[Je,Ye]=(0,Z.useState)(null),Xe=(0,Z.useCallback)(e=>Ye({scopeKey:Ke,leafId:e}),[Ke]),Ze=(Je?.scopeKey===Ke?Cn(B.tree,Je.leafId):null)?.id??B.focusedLeaf.id;(0,Z.useEffect)(()=>{Xe(B.focusedLeaf.id)},[Xe,B.focusedLeaf.id,B.focusedLeaf.activeKey]);let Qe=(0,Z.useCallback)(e=>{B.focusLeaf(e),Xe(e)},[B,Xe]),$e=ne.snapshot.project_layouts,et=(0,Z.useMemo)(()=>de?yn($e,r):[],[de,$e,r]),nt=(0,Z.useRef)(B);nt.current=B;let rt=(0,Z.useCallback)(e=>{let t=Lo(e.path);return t===null?void 0:A.find(e=>e.extensions.includes(t))},[A]),at=(0,Z.useCallback)(e=>rt(e)?.id,[rt]),ot=(0,Z.useCallback)(e=>R===void 0?null:{profile_id:R,project_id:ie.find(t=>t.id===e)?.project_id??r},[R,r,ie]),st=(0,Z.useCallback)(e=>{let t=at(e),n=ot(e.session);return{source:{session:e.session,path:e.path,...e.root===void 0?{}:{root:e.root}},...t===void 0?{}:{provider:t},...n??{}}},[ot,at]),ct=(0,Z.useCallback)(e=>{if(!_||R===void 0)return;let t=Lo(e.path),n=t===null?void 0:A.find(e=>e.extensions.includes(t)),r=ot(e.session);!n||!r||b({source:e,provider:n.id,...r})},[A,_,ot,R]),lt=(0,Z.useCallback)((e,t,n)=>{let r=t.artifacts.find(e=>e.role===`preview`);r&&(xt(r.file.session,r.file.path,r.file.root),h.invalidateQueries({queryKey:r.file.root===void 0?[`wt-file`,r.file.session,r.file.path]:[`wt-file`,r.file.session,r.file.path,r.file.root],exact:!0}),nt.current.openEditorInLeaf(e,{session:r.file.session,path:r.file.path,...r.file.root===void 0?{kind:`file`}:{kind:`external`,root:r.file.root},generated_by:t.provider,...Cr(r.file.path)?{view:`preview`}:{}},{dedupeAcrossTree:!0,activate:n}))},[h]),ut=(0,Z.useCallback)(async(e,n)=>{if(S!==null)return;let r=st(n),i=rt(n);if(!i)return;let a=zo(n.session,n.path,n.root);w(a);try{if(!await qe(r.source,new Set(i.input_extensions))){M.error(`Run cancelled because an input could not be saved`);return}(n.compile_mode??`on_demand`)===`eager`&&(nt.current.setCompileMode(n,`on_demand`),await Lr({...r,mode:`on_demand`}));let a=await v.mutateAsync(r);if(Re(zo(a.source.session,a.source.path,a.source.root)),a.terminal){await h.invalidateQueries({queryKey:[`sessions`]}),h.invalidateQueries({queryKey:[`project`,a.terminal.project_id]}),nt.current.ensureTerminal(a.terminal.id),t(`/project/${a.terminal.project_id}/session/${a.terminal.id}`);return}lt(e,a,!0),M.success(`${i.action===`run`?`Ran`:`Compiled`} ${wo(a.source.path)}`)}catch(e){Bo(a,e)}finally{w(null)}},[S,rt,st,lt,v,h,t]),dt=(0,Z.useCallback)(async(e,t)=>{let n=e.compile_mode??`on_demand`;if(n===t)return;let r=rt(e);if(!r||t===`eager`&&!r.eager)return;let i=st(e);if(t===`eager`&&!await qe(i.source,new Set(r.input_extensions))){M.error(`Eager compilation was not enabled because an input could not be saved`);return}nt.current.setCompileMode(e,t),t===`on_demand`&&Lr({...i,mode:t}).catch(t=>{nt.current.setCompileMode(e,n),mr(t)})},[rt,st]),ft=(0,Z.useMemo)(()=>{let e=new Map;for(let t of Sn(B.tree))for(let n of t.tabs){if(n.type!==`editor`||n.tab.compile_mode!==`eager`||!at(n.tab)||!rt(n.tab)?.eager)continue;let r=zo(n.tab.session,n.tab.path,n.tab.root);e.has(r)||e.set(r,{leafId:t.id,target:st(n.tab)})}return[...e.entries()].map(([e,t])=>({key:e,...t}))},[B.tree,st,at,rt]),pt=(0,Z.useCallback)((e,t,n)=>{Re(zo(n.source.session,n.source.path,n.source.root)),lt(t,n,!1)},[lt]),ht=(0,Z.useCallback)((e,t)=>Bo(e,t),[]),gt=(0,Z.useCallback)((e,t)=>{E(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),vt=(0,Z.useRef)(L);vt.current=L;let yt=(0,Z.useCallback)(e=>vt.current.update({session_order:zn(e,vt.current.snapshot.session_order)}),[]),bt=ac(oc),[St,Ct]=(0,Z.useState)(null),[wt,Et]=(0,Z.useState)([]),Dt=(0,Z.useRef)(bt);Dt.current=bt;let[At,jt]=(0,Z.useState)(!1),[Mt,V]=(0,Z.useState)(!1),[Pt,Ft]=(0,Z.useState)(null),It=Pt===r,[Lt,Rt]=(0,Z.useState)(!1),[zt,Bt]=(0,Z.useState)(`agent`),[Vt,Ht]=(0,Z.useState)(void 0),[Ut,Gt]=(0,Z.useState)(null),Kt=(0,Z.useCallback)((e=`agent`,t)=>{Ht(void 0),Gt(t??null),Bt(e),Rt(!0)},[]),Jt=(0,Z.useCallback)((e,t)=>{let n=De.find(e=>e.id===t);Kt(e,n?{projectId:n.id,repoId:n.repo_id}:void 0)},[De,Kt]),Yt=(0,Z.useRef)(null),Xt=(0,Z.useRef)(null),{setHandler:Zt}=Wt();(0,Z.useEffect)(()=>{!i||!we(m)||fe(r).catch(()=>void 0)},[m,r,i]),(0,Z.useEffect)(()=>gr.onSessionSwitched(e=>{e.source_session===a&&(Xt.current={session:e.target_session,pin:!1},e.target_project===r&&nt.current.ensureTerminal(e.target_session,{preview:!0}),t(`/project/${e.target_project}/session/${e.target_session}`))}),[a,t,r]);let[Qt,$t]=(0,Z.useState)(null),an=(0,Z.useCallback)((e,t)=>{let n=nt.current.openEditorInLeaf(e,{session:t.session,path:t.path,...t.root===void 0?{kind:`file`}:{kind:`external`,root:t.root}},{dedupeAcrossTree:!0});Xe(n),$t({session:t.session,path:t.path,...t.root===void 0?{}:{root:t.root},line:t.line,column:t.column,nonce:Date.now()})},[Xe]),sn=(0,Z.useCallback)((e,t,n)=>{Xe(B.focusedLeaf.id),B.openEditor(e,{preview:n?.preview}),Dt.current&&jt(!1),t&&[`file`,`external`].includes(e.kind??`file`)&&$t({session:e.session,path:e.path,...e.root===void 0?{}:{root:e.root},line:t.line,column:t.column,nonce:Date.now()})},[B,Xe]),ln=(0,Z.useCallback)((e,t,n,r)=>sn({...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&&Cr(t)===`notebook`?{view:`preview`}:{}},n,r),[sn]);_t(ln);let un=(0,Z.useCallback)((e,t,n)=>{let r=B.revealSource(e,t);Xe(r),$t({session:t.session,path:t.path,...t.root===void 0?{}:{root:t.root},line:n.line,column:n.column,nonce:Date.now()})},[B,Xe]),[pn,mn]=(0,Z.useState)(null),hn=(0,Z.useRef)(null),vn=(0,Z.useCallback)(e=>{hn.current=e},[]),H=(0,Z.useCallback)((e,t,n)=>ln(e,t,void 0,{preview:n?.preview??!0}),[ln]),U=(0,Z.useCallback)((e,r)=>{let i=P.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=>mr(e)})},[P,n,t]),wn=(0,Z.useCallback)(e=>B.promote(e),[B]),K=(0,Z.useCallback)((e,t,n,r)=>sn({kind:`external`,session:e,path:t,root:n},void 0,{preview:r?.preview??!0}),[sn]),En=Te(m),Dn=(0,Z.useCallback)(e=>{if(R!==void 0){if(!En){M.error(`Untitled drafts need a newer daemon — refresh the connection to update it`);return}Tt(R).then(({name:e})=>sn({kind:`untitled`,session:o,path:e})).catch(e=>M.error(e instanceof Error?e.message:`Could not create a draft`))}},[sn,R,En]),[On,An]=(0,Z.useState)(null);(0,Z.useEffect)(()=>(tt(An),()=>tt(null)),[]);let[jn,Mn]=(0,Z.useState)(null),Nn=()=>{let e=jn;if(Mn(null),!e||e.ref.type!==`editor`)return;let t=e.ref.tab.path;R!==void 0&&it(R,t).catch(()=>void 0),mt(t),B.close(e.leafId,e.ref)},Pn=(e,t,n,r)=>{An(null);let i={type:`editor`,tab:{kind:`untitled`,session:o,path:e}},a=W(i);for(let e of Sn(nt.current.tree))e.tabs.some(e=>W(e)===a)&&nt.current.close(e.id,i);h.invalidateQueries({queryKey:[`wt-tree`,t]}),setTimeout(()=>{nt.current.openEditor(r===void 0?{kind:`file`,session:t,path:n}:{kind:`external`,session:t,path:n,root:r})},0)};(0,Z.useEffect)(()=>(Zt(e=>{Ht(e?.accountId),Bt(e?.kind??`agent`),Rt(!0)}),()=>Zt(null)),[Zt]);let[Fn,q]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!L.loaded)return;let e=en(nt.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?x():void 0,e.some(e=>e.type===`editor`)?es():void 0]).finally(()=>q(!0))},[L.loaded,Ke]),(0,Z.useEffect)(()=>{if(It||!L.loaded||!u)return;Ft(r);let e=L.snapshot.active_session,n=P.find(t=>t.id===e);!a&&n&&n.status!==`archived`&&t(`/project/${r}/session/${n.id}`,{replace:!0})},[It,L,u,P,a,t,r]);let Ln=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(Ln.current||!L.loaded||!N.data)return;Ln.current=!0;let e=new Set(N.data.filter(e=>e.status!==`archived`).map(e=>e.id));nt.current.pruneSessions(e);let t=he.current,n=t.current().project_layouts;if(Object.keys(n).length>0){let r=Tn(e);t.update({project_layouts:Object.fromEntries(Object.entries(n).map(([t,n])=>[t,{...n,layout_tree:n.layout_tree?qt(n.layout_tree,r):null,active_session:n.active_session!==null&&e.has(n.active_session)?n.active_session:null}]))})}let r=vt.current.snapshot.session_order,i=r.filter(t=>e.has(t));i.length!==r.length&&vt.current.update({session_order:i})},[L.loaded,N.data]),(0,Z.useEffect)(()=>{if(!It)return;if(Dt.current){a&&(Ct(a),Et(e=>e.includes(a)?e:[...e,a])),V(!1);return}if(V(!1),!a){Yt.current=null;return}if(a===Yt.current&&!c)return;Yt.current=null;let e=Xt.current;Xt.current=null,nt.current.ensureTerminal(a,{preview:e?.session!==a||!e.pin});let t=vt.current;t.snapshot.active_session!==a&&t.update({active_session:a})},[It,a,c]);let Rn=Se();(0,Z.useEffect)(()=>{let e=le(Rn.data)??`Puddle`,t=P.filter(e=>e.status===`waiting_input`).length,n=z?.name??`Puddle`;return document.title=yh(n,e,t),()=>{document.title=e}},[P,z?.name,Rn.data]);let Bn=(0,Z.useCallback)(e=>{let n=a===e;n&&(Yt.current=e),B.removeTerminal(e),n&&(L.update({active_session:null}),t(`/project/${r}`))},[B,L,a,t,r]),Vn=Fe(),Hn=(0,Z.useCallback)(async e=>{let t=[...new Set(e)],n=await Promise.allSettled(t.map(e=>Vn.mutateAsync(e))),r=t.filter((e,t)=>n[t]?.status===`fulfilled`);for(let e of r)Bn(e);r.length>0&&(Ie(e=>{let t=new Set(e);for(let e of r)t.delete(e);return t}),Le.current!==null&&r.includes(Le.current)&&(Le.current=null));let i=n.filter(e=>e.status===`rejected`),a=i[0];i.length===1&&a?mr(a.reason):i.length>1&&M.error(`Couldn’t archive ${i.length} of ${t.length} sessions`)},[Vn,Bn]),Un={ids:Ne,onSelect:ze,onSelectOnly:Be,onArchive:e=>void Hn(e)},Wn=(0,Z.useCallback)((e,n)=>{if(Xe(e),B.activate(e,n),n.type===`terminal`&&n.session!==a){let e=ie.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[B,t,ie,a,Xe]),Gn=(0,Z.useCallback)((e,n)=>{if(n.type===`editor`&&wr(n.tab)===`untitled`){Mn({leafId:e,ref:n});return}let i=Cn(B.tree,e)?.tabs.findIndex(e=>W(e)===W(n))??-1;rc(Ke,{leafId:e,index:Math.max(0,i),ref:n}),B.close(e,n),n.type===`terminal`&&n.session===a&&(Yt.current=n.session,L.update({active_session:null}),t(`/project/${r}`))},[B,a,L,t,r,Ke]),Kn=(0,Z.useCallback)(()=>{let e=ge.current,n=e?new Set(e.filter(e=>e.status!==`archived`).map(e=>e.id)):null,r=ic(Ke,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=Cn(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=ie.find(e=>e.id===i.session)?.project_id;e&&t(`/project/${e}/session/${i.session}`)}},[B,Ke,a,ie,t]),qn=(0,Z.useCallback)((e,n,i)=>{let o=n.type===`terminal`?ie.find(e=>e.id===n.session)?.project_id:void 0;if(de&&o!==void 0&&o!==r&&n.type===`terminal`){Xt.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,ie,t,de,r]),Jn=B.focusedLeaf.tabs.find(e=>W(e)===B.focusedLeaf.activeKey)??null,Yn=Jn===null?null:Jn.type===`terminal`?Jn.session:Jn.tab.session,Xn=Yn===`00000000-0000-0000-0000-000000000000`?null:Yn,Zn=Me().data?.find(e=>e.id===z?.repo_id),Qn=(0,Z.useMemo)(()=>Oe(m)&&Zn&&z?{path:Zn.path,projectId:z.id,name:z.name,defaultBranch:Zn.default_base_branch}:null,[m,Zn,z]),$n=Xo(ie,Xn??a,L,Qn),J=$n.session,er=$n.root,tr=(0,Z.useCallback)(e=>{let t=ie.find(t=>t.id===e.session);if(e.root===void 0&&!t)return;let n=hn.current??er??J?.worktree_path??null,r=Zo(e,t?.worktree_path??e.root??``,n);if(Dt.current&&jt(!0),L.update({sidebar_mode:`files`,...Dt.current?{}:{sidebar_collapsed:!1}}),r.browseRoot!==void 0){let n=t?.id??J?.id??e.session;mn({session:n,root:r.browseRoot,nonce:Date.now()})}else n!==r.directory&&$n.pin(e.session);Qs({path:r.path,directory:r.directory})},[$n,ie,er,J?.worktree_path,L]),nr=(0,Z.useCallback)(async(e,t)=>{let n=t.trim();if(n===``||n===wo(e.path))return!0;let r=Oo(To(e.path),n);try{let{rekeyBuffer:t}=await k(async()=>{let{rekeyBuffer:e}=await import(`./buffer-store-CYe-IdNO.js`).then(e=>e.n);return{rekeyBuffer:e}},__vite__mapDeps([34,1,2,6,7,3,4,5,8,12,13,35,36,37])),n=await Ge(e.session,e.path,r,e.root),i=t(e.session,e.path,n.path,e.root);return nt.current.renameFile(e,n.path),h.invalidateQueries({queryKey:[`wt-tree`,e.session]}),h.invalidateQueries({queryKey:[`wt-git-status`,e.session]}),setTimeout(()=>{(i?.dirty?Tr(e.session,n.path,i.content,i.baseMtimeMs,e.root):Promise.resolve()).then(()=>Er(e.session,e.path,e.root))},0),!0}catch(e){return mr(e),!1}},[h]),ir=(0,Z.useCallback)((e,t)=>{if(t.kind===`dir`){Dt.current&&jt(!0),L.update({sidebar_mode:`files`,...Dt.current?{}:{sidebar_collapsed:!1}}),mn({session:e,root:t.path,nonce:Date.now()});return}let n=rr(t,er);n!==null&&mn({session:e,root:n,nonce:Date.now()}),ln(e,t.path,t.line===void 0?void 0:{line:t.line,column:t.column},t.root===void 0?void 0:{root:t.root})},[ln,L,er]),ar=J?.id??null,or=(0,Z.useCallback)(async e=>{if(ar===null)throw Error(`No worktree is available for this project.`);let t=await cr(ar,e,{root:er}),n=t.kind===`file`&&t.root===void 0&&er!==void 0?{...t,root:er}:t;if(n.kind===`dir`&&n.relativePath!==void 0){Dt.current&&jt(!0),L.update({sidebar_mode:`files`,...Dt.current?{}:{sidebar_collapsed:!1}}),Qs({path:n.relativePath,root:er,expandTarget:!0});return}ir(ar,n)},[ar,er,ir]);(0,Z.useEffect)(()=>rn(or),[or]);let sr=Pu(L.snapshot.sidebar_mode),lr=L.snapshot.sidebar_collapsed,ur=L.snapshot.sessions_collapsed,dr=(0,Z.useCallback)(e=>{let t=B.focusedLeaf,n=t.tabs.find(e=>W(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){M.error(`Focus a terminal or agent to insert`);return}gr.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[B]);(0,Z.useEffect)(()=>(tn(dr),()=>tn(null)),[dr]);let fr=(0,Z.useCallback)(e=>{let t=he.current,n=ge.current,i=We.current;if(!t.loaded||!n||!i)return!1;let{patch:a,projectBased:o}=fn(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),O().projectBasedLayout!==o&&ee({projectBasedLayout:o}),!0},[r]),pr=de?`project`:`profile`,hr=L.snapshot.layout_tree,Dr=L.snapshot.layout_ref,Or=ne.snapshot.project_layouts;(0,Z.useEffect)(()=>{ne.loaded&&xn({scope:pr,projectId:r,layoutRef:Dr,signature:dn(hr),slices:Object.fromEntries(Object.entries(Or).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:dn(t.layout_tree)}])),capture:()=>{let e=vt.current.current();return{layout_tree:e.layout_tree,active_session:e.active_session}},apply:fr})},[ne.loaded,pr,r,hr,Dr,Or,fr]),(0,Z.useEffect)(()=>()=>xn(null),[]);let kr=(0,Z.useRef)({}),Ar=e=>{let t=B.focusedLeaf;if(t.tabs.length<2)return;let n=t.tabs.findIndex(e=>W(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&&Wn(t.id,i)},jr=e=>{bt?(L.update({sidebar_mode:e}),jt(!0)):L.update({sidebar_mode:e,sidebar_collapsed:!1})};kr.current={"tab.close":()=>{let e=B.focusedLeaf,t=e.tabs.find(t=>W(t)===e.activeKey);t&&Gn(e.id,t)},"tab.reopen":Kn,"tab.newUntitled":()=>Dn(B.focusedLeaf),"tab.next":()=>Ar(1),"tab.prev":()=>Ar(-1),"editor.save":()=>{Go(B.activeEditorTab)},"sidebar.left":()=>bt?jt(e=>!e):L.update({sidebar_collapsed:!L.snapshot.sidebar_collapsed}),"sidebar.right":()=>bt?V(e=>!e):L.update({sessions_collapsed:!L.snapshot.sessions_collapsed}),"nav.files":()=>jr(`files`),"nav.search":()=>jr(`search`),"nav.changes":()=>jr(`changes`),"nav.worktrees":()=>jr(`worktrees`),"session.newAgent":()=>Kt(`agent`),"session.newTerminal":()=>Kt(`terminal`)},(0,Z.useEffect)(()=>{let e=Object.keys(kr.current).map(e=>re(e,()=>kr.current[e]?.()));return()=>e.forEach(e=>e())},[]);let Mr=B.activeEditorTab,Nr=Mr?.kind===`diff`&&J&&Mr.session===J.id?Mr.path:null,Pr=Mr&&(Mr.kind??`file`)===`file`&&J&&Mr.session===J.id?Mr.path:null,Fr=Mr?.kind===`external`&&Mr.root!==void 0?{path:Mr.path,root:Mr.root}:null,Rr=e=>({preview:e?.preview??!0}),Br=(e,t)=>{if(J){let n=t?.root??er,r=n===void 0?{}:{root:n};sn({kind:`diff`,session:J.id,path:e,...r,...t?.gitArea===void 0?{}:{git_area:t.gitArea}},void 0,Rr(t))}},Vr=(e,t,n)=>{if(J){let r=n?.root??er,i=r===void 0?{}:{root:r};sn({kind:`commit`,session:J.id,path:e,sha:t,...i},void 0,Rr(n))}},Hr=(e,t,n)=>{if(!J)return;let r=t===void 0?void 0:{line:t,column:1};if(er!==void 0){sn({kind:`external`,session:J.id,path:e,root:er},r,Rr(n));return}ln(J.id,e,r,Rr(n))},Ur=(0,Z.useCallback)(e=>L.update({layout:{...L.snapshot.layout,...e}}),[L]),Wr=sc(L.snapshot.layout,[...lr?[]:[`nav`],`main`,...ur?[]:[`sessions`]]);if(!i)return null;if(!L.loaded||!z||!Fn)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`});let Gr=e=>(0,X.jsx)(Iu,{mode:sr,onModeChange:e=>L.update({sidebar_mode:e}),onCollapse:e,projectId:r,repoId:z.repo_id,sessions:P,target:$n,browseRequest:pn,onFiletreeRootChange:vn,compilableExtensions:j,onOpenCompilationSettings:_?ct:void 0,onOpenFile:H,onOpenExternalFile:K,onOpenTerminalIn:U,activeFilePath:Pr,activeExternalTab:Fr,activeDiffPath:Nr,onOpenDiff:Br,onOpenCommitFile:Vr,onOpenSearchFile:Hr}),Kr={onNewSessionIn:e=>Jt(`agent`,e),onNewTerminalIn:e=>Jt(`terminal`,e),onMoveProject:Ve},qr=e=>(0,X.jsx)(zm,{groups:ke,accounts:d,activeSessionId:a,onReorder:yt,onPromote:e=>B.ensureTerminal(e),archived:He,onNewSession:()=>Kt(`agent`),onNewTerminal:()=>Kt(`terminal`),onCollapse:e,onArchived:Bn,onArchiveDrop:e=>void Hn(e),selection:Un,projectActions:Kr}),Y=P.find(e=>e.id===St)?.id??P.find(e=>e.id===a)?.id??null,Jr=bt?(0,X.jsx)(Ys,{sessions:P,selected:Y,select:e=>{Ct(e),Et(t=>t.includes(e)?t:[...t,e])}}):(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[ft.map(({key:e,leafId:t,target:n})=>(0,X.jsx)(Uo,{sourceKey:e,leafId:t,target:n,onResult:pt,onError:ht,onRunningChange:gt},e)),(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(hh,{tree:B.tree,sessions:ie,reveal:Qt,onActivateTab:Wn,onCloseTab:Gn,onPromoteTab:wn,onArchived:Bn,onFocusLeaf:Qe,onScrollDrive:Xe,onResize:B.resize,onDropTab:qn,onSetTabView:B.setView,compilableExtensions:j,compilationProviders:A,compilationRunningKeys:te,onRunCompilation:(e,t)=>void ut(e,t),onSetCompilationMode:dt,onOpenCompilationSettings:_?ct:void 0,onRevealPreviewSource:un,onRevealCompiledSource:an,onNewUntitled:Dn,onRevealFile:tr,onRenameFile:nr,focusedLeafId:B.focusedLeaf.id,scrollDriverLeafId:Ze,scrollChannel:`${R??``}:${Ke}`})})]});return(0,X.jsx)(ds,{tree:B.tree,parked:[...et,...wt,...Y?[Y]:[]],onOpenFile:ir,children:(0,X.jsx)(Cm,{onDrop:B.drop,onArchive:e=>void Hn([e]),renderOverlay:e=>{let t=e.type===`terminal`?ie.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?f(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,X.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden`,children:[bt?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fu,{mode:sr,onExpand:()=>jt(!0),onSelect:e=>{L.update({sidebar_mode:e}),jt(!0)}}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:Jr}),(0,X.jsx)(Lm,{groups:ke,accounts:d,activeSessionId:a,onReorder:yt,onPromote:e=>B.ensureTerminal(e),onExpand:()=>V(!0),onNewTerminal:()=>Kt(`terminal`),onNewSession:()=>Kt(`agent`),onArchived:Bn,onArchiveDrop:e=>void Hn(e),selection:Un,projectActions:Kr}),At&&(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:()=>jt(!1)}),(0,X.jsx)(`div`,{className:`absolute inset-y-0 left-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:Gr(()=>jt(!1))})]}),Mt&&(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:()=>V(!1)}),(0,X.jsx)(`div`,{className:`absolute inset-y-0 right-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:qr(()=>V(!1))})]})]}):(0,X.jsxs)(X.Fragment,{children:[lr&&(0,X.jsx)(Fu,{mode:sr,onExpand:()=>L.update({sidebar_collapsed:!1}),onSelect:e=>L.update({sidebar_collapsed:!1,sidebar_mode:e})}),(0,X.jsxs)(_o,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:Wr,onLayoutChanged:Ur,children:[!lr&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(bo,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,children:Gr(()=>L.update({sidebar_collapsed:!0}))}),(0,X.jsx)(Co,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`})]}),(0,X.jsx)(bo,{id:`main`,children:Jr}),!ur&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Co,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`}),(0,X.jsx)(bo,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,children:qr(()=>L.update({sessions_collapsed:!0}))})]})]}),ur&&(0,X.jsx)(Lm,{groups:ke,accounts:d,activeSessionId:a,onReorder:yt,onPromote:e=>B.ensureTerminal(e),onExpand:()=>L.update({sessions_collapsed:!1}),onNewTerminal:()=>Kt(`terminal`),onNewSession:()=>Kt(`agent`),onArchived:Bn,onArchiveDrop:e=>void Hn(e),selection:Un,projectActions:Kr})]}),(0,X.jsx)(zu,{projectId:Ut?.projectId??r,repoId:Ut?.repoId??z.repo_id,open:Lt,kind:zt,seedAccountId:Vt,onOpenChange:Rt,onCreated:e=>void t(`/project/${e.project_id}/session/${e.id}`)}),(0,X.jsx)(Ko,{request:On,targetSession:J,targetRoot:er,targetLabel:J===null?``:er===void 0?J.branch:er,profileId:R,onClose:()=>An(null),onSaved:Pn}),(0,X.jsx)(Wo,{request:y,onOpenChange:e=>!e&&b(null)}),(0,X.jsx)(Sr,{open:jn!==null,onOpenChange:e=>!e&&Mn(null),children:(0,X.jsxs)(yr,{children:[(0,X.jsxs)(_r,{children:[(0,X.jsx)(br,{children:`Discard this draft?`}),(0,X.jsxs)(xr,{children:[`Closing an untitled tab deletes its draft — `,p,` saves it into the worktree instead.`]})]}),(0,X.jsxs)(vr,{children:[(0,X.jsx)(G,{variant:`ghost`,onClick:()=>Mn(null),children:`Keep editing`}),(0,X.jsx)(G,{variant:`danger`,onClick:Nn,children:`Discard`})]})]})})]})})})}export{bh as Workspace};
|