vibelet 1.2.230 → 1.2.231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/inventory-scan-worker.cjs +1 -1
  3. package/dist/runtime-version.cjs +1 -1
  4. package/dist/vibelet.mjs +123 -98
  5. package/dist/web/assets/App-BbkHX6Hv.css +1 -0
  6. package/dist/web/assets/App-TtlYNy7O.js +20 -0
  7. package/dist/web/assets/{BrowserControlPanel-BTBKDi0n.js → BrowserControlPanel-DzDyeCam.js} +1 -1
  8. package/dist/web/assets/{ChipGroup-ImS6VTKx.js → ChipGroup-Do4YgaVh.js} +1 -1
  9. package/dist/web/assets/FilesControlPanel-Dy08iN_7.js +1 -0
  10. package/dist/web/assets/{GlobalPendingDialog-BCLMQc_r.js → GlobalPendingDialog-BokEX_Go.js} +1 -1
  11. package/dist/web/assets/{ImageViewer-BvBKQ6wE.js → ImageViewer-BAycGfGo.js} +1 -1
  12. package/dist/web/assets/{LanguageSettingsPanel-DTDvB4l2.js → LanguageSettingsPanel-db264JO3.js} +1 -1
  13. package/dist/web/assets/NewSessionDialog-BTZlw3Gl.js +1 -0
  14. package/dist/web/assets/{NotificationSettingsPanel-BS01O3sC.js → NotificationSettingsPanel-BYr3-NRw.js} +1 -1
  15. package/dist/web/assets/{TerminalControlPanel-B7S_ebVy.js → TerminalControlPanel-16KT-TCS.js} +1 -1
  16. package/dist/web/assets/{ThemeSettingsPanel-DVaJ6nGu.js → ThemeSettingsPanel-D3-WUp4t.js} +1 -1
  17. package/dist/web/assets/{arrow-right-ORILUMdJ.js → arrow-right-mMC7Zi8G.js} +1 -1
  18. package/dist/web/assets/{collectMessageImages-lfAaZW_Y.js → collectMessageImages-F_MsAk3D.js} +2 -2
  19. package/dist/web/assets/{file-editor-FileCodeEditor-ZAqN9Q2f.js → file-editor-FileCodeEditor-CInvSSQe.js} +3 -3
  20. package/dist/web/assets/{file-editor-MarkdownLivePreview-DXTFwUnj.js → file-editor-MarkdownLivePreview-CRJo_RMu.js} +1 -1
  21. package/dist/web/assets/{file-editor-index-Dj3dV82Z.js → file-editor-index-Cbe_0mr3.js} +1 -1
  22. package/dist/web/assets/{file-editor-index-C4S-qKVH.js → file-editor-index-DXLgqR7Z.js} +1 -1
  23. package/dist/web/assets/{file-editor-index-DKQvp2Qx.js → file-editor-index-Gu3GlV9m.js} +1 -1
  24. package/dist/web/assets/{file-editor-index-Dc2gxJQY.js → file-editor-index-R2lTkg6K.js} +1 -1
  25. package/dist/web/assets/{file-editor-index-Byun61j6.js → file-editor-index-VN_2L1I4.js} +1 -1
  26. package/dist/web/assets/{file-editor-index-BC0Bqs8t.js → file-editor-index-awBV_67q.js} +1 -1
  27. package/dist/web/assets/{file-editor-index-Bo2dEHVF.js → file-editor-index-hdpS6VVW.js} +1 -1
  28. package/dist/web/assets/{file-editor-index-BBHGMD89.js → file-editor-index-ixbyM_m4.js} +1 -1
  29. package/dist/web/assets/{folder-plus-DHw5YJHP.js → folder-plus-DbDHVXck.js} +1 -1
  30. package/dist/web/assets/{highlighted-body-TPN3WLV5-DDb5MlJt.js → highlighted-body-TPN3WLV5-F1GioA6X.js} +1 -1
  31. package/dist/web/assets/{index-ConcKf33.js → index-DJLpIsPI.js} +9 -9
  32. package/dist/web/assets/{index-Be6TVbvo.css → index-XET9GutV.css} +1 -1
  33. package/dist/web/assets/{mermaid-O7DHMXV3-D-5FgaAx.js → mermaid-O7DHMXV3-H7_sz6Xo.js} +3 -3
  34. package/dist/web/index.html +2 -2
  35. package/package.json +1 -1
  36. package/dist/web/assets/App-94_jdzMk.css +0 -1
  37. package/dist/web/assets/App-CapuoJH2.js +0 -18
  38. package/dist/web/assets/DiffDrawer-sMBIj4bW.js +0 -2
  39. package/dist/web/assets/FilesControlPanel-4hHS85Mr.js +0 -1
  40. package/dist/web/assets/NewSessionDialog-LttGZHY7.js +0 -1
@@ -0,0 +1,20 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-O7DHMXV3-H7_sz6Xo.js","assets/index-DJLpIsPI.js","assets/index-XET9GutV.css","assets/collectMessageImages-F_MsAk3D.js","assets/mermaid-O7DHMXV3-tkqeC_Xz.css","assets/ImageViewer-BAycGfGo.js","assets/arrow-right-mMC7Zi8G.js","assets/ImageViewer-L8SQkFy1.css","assets/BrowserControlPanel-DzDyeCam.js","assets/TerminalControlPanel-16KT-TCS.js","assets/FilesControlPanel-Dy08iN_7.js","assets/folder-plus-DbDHVXck.js","assets/FilesControlPanel-DsKJrFYk.css","assets/LanguageSettingsPanel-db264JO3.js","assets/ChipGroup-Do4YgaVh.js","assets/ThemeSettingsPanel-D3-WUp4t.js","assets/NotificationSettingsPanel-BYr3-NRw.js","assets/file-editor-FileCodeEditor-CInvSSQe.js","assets/FileCodeEditor-yqSvo7VZ.css","assets/NewSessionDialog-BTZlw3Gl.js","assets/NewSessionDialog-cuN6a01X.css","assets/GlobalPendingDialog-BokEX_Go.js"])))=>i.map(i=>d[i]);
2
+ import{c as F,m as Ge,e as Je,l as Xe,j as r,r as c,i as it,k as se,S as ba,n as va,t as Et,o as Rs,_ as gt,u as rs,D as is,E as xa,p as xs,q as pn,v as As,w as Tn,x as wa,y as Sa,z as ka,A as ja,s as In,B as Ca,C as Ia,F as Na,G as Ea,H as Ra}from"./index-DJLpIsPI.js";const Aa=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ri=F("activity",Aa);const Ta=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],Ma=F("archive-restore",Ta);const Pa=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],as=F("archive",Pa);const Da=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],_a=F("arrow-down",Da);const La=[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]],Qs=F("arrow-left-to-line",La);const $a=[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]],Fa=F("arrow-right-to-line",$a);const Oa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],qa=F("arrow-up",Oa);const Wa=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Lt=F("check",Wa);const Ha=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Zs=F("chevron-down",Ha);const Ba=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ii=F("chevron-right",Ba);const za=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ai=F("chevron-up",za);const Ka=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],oi=F("circle-alert",Ka);const Ga=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],Ua=F("clipboard",Ga);const Va=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Qa=F("clock-3",Va);const Za=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Ya=F("code-xml",Za);const Ja=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],yn=F("copy",Ja);const Xa=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]],eo=F("corner-up-right",Xa);const to=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ws=F("cpu",to);const no=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],so=F("ellipsis",no);const ro=[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]],io=F("file-pen-line",ro);const ao=[["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"}]],Ys=F("file-text",ao);const oo=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Xn=F("folder-open",oo);const co=[["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"}]],lo=F("folder",co);const uo=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],ho=F("funnel",uo);const fo=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],_t=F("gauge",fo);const mo=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],os=F("git-compare",mo);const po=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],go=F("git-merge",po);const yo=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ci=F("globe",yo);const bo=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],vo=F("hash",bo);const xo=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]],wo=F("image-off",xo);const So=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],li=F("info",So);const ko=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],jo=F("key-round",ko);const Co=[["path",{d:"M10 5h11",key:"1hkqpe"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 19h11",key:"14g2nv"}],["path",{d:"m3 10 3-3-3-3",key:"i7pm08"}],["path",{d:"m3 20 3-3-3-3",key:"20gx1n"}]],Io=F("list-collapse",Co);const No=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],cs=F("loader-circle",No);const Eo=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Ro=F("maximize-2",Eo);const Ao=[["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"}]],di=F("message-circle",Ao);const To=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],ui=F("mic",To);const Mo=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Po=F("minimize-2",Mo);const Do=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],_o=F("panel-left",Do);const Lo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],$o=F("panel-right",Lo);const Fo=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Oo=F("paperclip",Fo);const qo=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Wo=F("pencil",qo);const Ho=[["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"}]],qn=F("pin",Ho);const Bo=[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],hi=F("plug-zap",Bo);const zo=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Wn=F("plus",zo);const Ko=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Dn=F("refresh-cw",Ko);const Go=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],fi=F("rotate-ccw",Go);const Uo=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Vo=F("save",Uo);const Qo=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_n=F("search",Qo);const Zo=[["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"}]],Yo=F("send",Zo);const Jo=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Xo=F("settings-2",Jo);const ec=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],tc=F("settings",ec);const nc=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Js=F("shield-check",nc);const sc=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],mi=F("sliders-horizontal",sc);const rc=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],ic=F("sparkles",rc);const ac=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],ls=F("square-terminal",ac);const oc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],pi=F("square",oc);const cc=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],gi=F("tag",cc);const lc=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Xs=F("terminal",lc);const dc=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],yi=F("trash-2",dc);const uc=[["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"}]],hc=F("upload",uc);const fc=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],mc=F("wrench",fc);const pc=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Me=F("x",pc);const gc=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],fn=F("zap",gc),Ts="vibelet.shortcuts.changed",Ms="vibelet.workspace.command",sn=[{id:"leftSidebar",zh:"显示 / 隐藏左侧栏",en:"Toggle left sidebar",default:"mod+alt+["},{id:"rightSidebar",zh:"显示 / 隐藏右侧栏",en:"Toggle right sidebar",default:"mod+alt+]"},{id:"searchSessions",zh:"搜索会话",en:"Search sessions",default:"mod+shift+f"},{id:"files",zh:"打开文件树",en:"Open files",default:"mod+alt+e"},{id:"terminal",zh:"打开终端",en:"Open terminal",default:"mod+j"},{id:"browser",zh:"打开浏览器",en:"Open browser",default:"mod+alt+b"},{id:"newTab",zh:"新建终端 / 浏览器标签",en:"New terminal / browser tab",default:"mod+t"},{id:"previousTab",zh:"上一个标签",en:"Previous tab",default:"mod+shift+["},{id:"nextTab",zh:"下一个标签",en:"Next tab",default:"mod+shift+]"},{id:"closeTab",zh:"关闭当前标签",en:"Close current tab",default:"mod+alt+w"},{id:"moveTab",zh:"在中间区域与右侧栏间移动标签",en:"Move tab between workspace and sidebar",default:"mod+shift+m"},{id:"diff",zh:"查看 Git 变更",en:"View Git changes",default:"mod+alt+g"}];function bi(){return/Mac|iPhone|iPad/.test(navigator.platform)}const yc={BracketLeft:"[",BracketRight:"]",Comma:",",Period:".",Slash:"/",Backslash:"\\",Minus:"-",Equal:"=",Space:"space"};function vi(e,t=bi()){const n=yc[e.code]||(/^Key[A-Z]$/.test(e.code)?e.code.slice(3).toLowerCase():/^Digit\d$/.test(e.code)?e.code.slice(5):e.key.toLowerCase());return["meta","control","alt","shift","dead"].includes(n)||!(e.metaKey||e.ctrlKey||e.altKey)?null:[t?e.metaKey&&"mod":e.ctrlKey&&"mod",t?e.ctrlKey&&"ctrl":e.metaKey&&"meta",e.altKey&&"alt",e.shiftKey&&"shift",n].filter(Boolean).join("+")}function xi(e,t=bi()){const n=t?{mod:"⌘",ctrl:"⌃",meta:"⌘",alt:"⌥",shift:"⇧",space:"Space"}:{mod:"Ctrl",ctrl:"Ctrl",meta:"Win",alt:"Alt",shift:"Shift",space:"Space"};return e.split("+").map(s=>n[s]||s.toUpperCase()).join(t?"":"+")}function bc(e,t={}){return t[e]??sn.find(n=>n.id===e).default}function vc(e,t,n){return t?["mod+n","mod+,","mod+q","mod+w","mod+c","mod+v","mod+x","mod+a","mod+z","mod+shift+z","mod+s","mod+f","mod+r","mod+h","mod+m","mod+-","mod+=","mod+shift+="].includes(t)?"reserved":sn.find(s=>s.id!==e&&bc(s.id,n)===t)?.id??null:null}const wi="vibelet.web.shortcuts";function es(){try{const e=JSON.parse(Ge().getItem(wi)||"{}");return Object.fromEntries(sn.filter(t=>typeof e?.[t.id]=="string").map(t=>[t.id,e[t.id]]))}catch{return{}}}function er(e,t=es()){return t[e]??sn.find(n=>n.id===e).default}function xc(e){Ge().setItem(wi,JSON.stringify(e)),window.dispatchEvent(new Event(Ts))}function Hn(e,t){const n=er(t);return n?`${e} (${xi(n)})`:e}const wc="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-3%20-3%2041%2041'%20shape-rendering='crispEdges'%3e%3cpath%20fill='%23ffffff'%20d='M-3%20-3h41v41H-3z'/%3e%3cpath%20stroke='%23000000'%20d='M1%201.5h7m2%200h2m2%200h1m2%200h1m1%200h2m1%200h1m1%200h1m2%200h7M1%202.5h1m5%200h1m2%200h1m3%200h5m3%200h1m2%200h1m1%200h1m5%200h1M1%203.5h1m1%200h3m1%200h1m1%200h1m1%200h1m2%200h1m1%200h2m1%200h6m2%200h1m1%200h3m1%200h1M1%204.5h1m1%200h3m1%200h1m1%200h3m3%200h4m1%200h4m1%200h1m1%200h1m1%200h3m1%200h1M1%205.5h1m1%200h3m1%200h1m1%200h1m2%200h3m1%200h1m1%200h3m1%200h2m3%200h1m1%200h3m1%200h1M1%206.5h1m5%200h1m1%200h2m2%200h6m3%200h2m3%200h1m5%200h1M1%207.5h7m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h7M9%208.5h1m1%200h1m4%200h1m3%200h4M1%209.5h1m1%200h5m2%200h1m1%200h7m1%200h1m2%200h1m1%200h1m1%200h5M3%2010.5h2m1%200h1m2%200h2m1%200h1m3%200h2m1%200h4m1%200h1m2%200h2m1%200h2M1%2011.5h2m1%200h1m2%200h5m4%200h1m4%200h1m1%200h1m1%200h2m2%200h1m1%200h2M1%2012.5h3m1%200h1m2%200h3m2%200h1m1%200h1m3%200h2m1%200h3m1%200h1m2%200h5M2%2013.5h1m1%200h1m2%200h3m1%200h3m2%200h1m2%200h1m3%200h2m1%200h1m1%200h1m1%200h1m1%200h1M2%2014.5h3m1%200h1m3%200h2m3%200h3m1%200h3m2%200h2m6%200h2M1%2015.5h2m1%200h1m1%200h2m4%200h3m3%200h1m2%200h2m2%200h3m1%200h4M1%2016.5h1m1%200h3m2%200h1m2%200h2m1%200h1m2%200h1m1%200h1m1%200h8m1%200h2M3%2017.5h7m1%200h2m1%200h2m1%200h2m4%200h4m1%200h2m1%200h1m1%200h1M2%2018.5h2m4%200h1m1%200h2m1%200h1m2%200h13m1%200h4M1%2019.5h1m2%200h5m1%200h1m1%200h7m7%200h1m1%200h2m1%200h1M1%2020.5h3m5%200h1m1%200h2m1%200h1m2%200h8m2%200h5m1%200h1M1%2021.5h1m1%200h6m1%200h1m1%200h1m1%200h1m2%200h1m2%200h1m1%200h2m1%200h2m1%200h3M1%2022.5h1m1%200h2m1%200h1m1%200h2m1%200h6m1%200h2m1%200h2m1%200h1m2%200h1m2%200h1m2%200h1M1%2023.5h1m2%200h2m1%200h5m2%200h4m1%200h1m1%200h1m3%200h2m2%200h1m2%200h1M1%2024.5h1m2%200h1m5%200h1m1%200h5m3%200h4m1%200h3m1%200h3m1%200h1M1%2025.5h1m3%200h3m4%200h3m1%200h1m1%200h1m4%200h7m1%200h2M9%2026.5h1m1%200h2m1%200h2m3%200h2m1%200h1m1%200h2m3%200h1m1%200h1m1%200h1M1%2027.5h7m2%200h1m1%200h2m1%200h3m1%200h1m1%200h1m2%200h2m1%200h1m1%200h1m1%200h2M1%2028.5h1m5%200h1m1%200h9m3%200h5m3%200h3m1%200h1M1%2029.5h1m1%200h3m1%200h1m1%200h2m2%200h2m1%200h1m2%200h1m1%200h1m3%200h6M1%2030.5h1m1%200h3m1%200h1m1%200h4m1%200h5m2%200h1m1%200h2m1%200h1m2%200h2m1%200h2M1%2031.5h1m1%200h3m1%200h1m1%200h2m1%200h2m7%200h2m1%200h5m1%200h2M1%2032.5h1m5%200h1m2%200h2m2%200h2m1%200h1m1%200h4m1%200h1m2%200h1m1%200h3M1%2033.5h7m1%200h5m4%200h1m2%200h1m1%200h3m1%200h2m3%200h1'/%3e%3c/svg%3e",Sc="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2041%2041'%20shape-rendering='crispEdges'%3e%3cpath%20fill='%23ffffff'%20d='M0%200h41v41H0z'/%3e%3cpath%20stroke='%23000000'%20d='M4%204.5h7m3%200h5m3%200h1m2%200h2m3%200h7M4%205.5h1m5%200h1m1%200h1m2%200h1m4%200h2m2%200h2m2%200h1m1%200h1m5%200h1M4%206.5h1m1%200h3m1%200h1m1%200h1m1%200h1m1%200h1m2%200h1m3%200h3m1%200h1m2%200h1m1%200h3m1%200h1M4%207.5h1m1%200h3m1%200h1m1%200h2m1%200h1m2%200h2m1%200h1m1%200h3m1%200h2m1%200h1m1%200h3m1%200h1M4%208.5h1m1%200h3m1%200h1m3%200h1m6%200h3m1%200h1m1%200h1m2%200h1m1%200h3m1%200h1M4%209.5h1m5%200h1m4%200h1m1%200h1m6%200h1m5%200h1m5%200h1M4%2010.5h7m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h7M12%2011.5h1m3%200h1m3%200h1m2%200h2m1%200h1m1%200h1M4%2012.5h1m5%200h1m1%200h1m1%200h1m1%200h4m1%200h2m3%200h5m2%200h3M6%2013.5h4m4%200h2m1%200h3m1%200h3m3%200h2m3%200h4M4%2014.5h1m2%200h5m1%200h2m2%200h3m2%200h1m1%200h3m2%200h2m1%200h1m1%200h2M5%2015.5h1m1%200h2m2%200h2m2%200h3m1%200h2m2%200h1m2%200h10M5%2016.5h1m4%200h1m1%200h3m2%200h1m1%200h2m2%200h2m2%200h2m1%200h2m4%200h1M6%2017.5h3m2%200h5m3%200h1m1%200h4m2%200h1m1%200h3m1%200h4M7%2018.5h2m1%200h1m3%200h3m1%200h4m3%200h1m2%200h3m3%200h2M5%2019.5h1m1%200h2m3%200h2m5%200h1m3%200h1m2%200h2m1%200h1m1%200h1m2%200h1m1%200h1M4%2020.5h1m4%200h2m3%200h1m1%200h3m1%200h2m1%200h1m2%200h1m2%200h1m1%200h2m3%200h1M6%2021.5h4m1%200h1m2%200h1m1%200h1m1%200h3m1%200h3m1%200h2m2%200h1m2%200h2m1%200h1M5%2022.5h2m3%200h3m2%200h3m1%200h1m1%200h1m1%200h2m1%200h3m1%200h2m1%200h2m1%200h1M5%2023.5h1m1%200h1m3%200h5m2%200h3m1%200h3m1%200h1m1%200h1m3%200h3M6%2024.5h3m1%200h1m1%200h4m2%200h1m1%200h1m1%200h2m2%200h1m2%200h1m1%200h3m1%200h2M4%2025.5h1m7%200h1m3%200h1m3%200h1m2%200h1m2%200h2m3%200h3M4%2026.5h1m2%200h1m2%200h2m1%200h5m1%200h1m2%200h1m1%200h2m7%200h3M4%2027.5h1m3%200h1m4%200h2m5%200h1m8%200h1m1%200h1m1%200h4M4%2028.5h3m1%200h1m1%200h3m5%200h3m3%200h1m3%200h5m3%200h1M12%2029.5h1m1%200h2m3%200h1m3%200h1m1%200h1m1%200h2m3%200h1m1%200h1m1%200h1M4%2030.5h7m7%200h2m2%200h1m1%200h1m1%200h3m1%200h1m1%200h1m1%200h2M4%2031.5h1m5%200h1m2%200h3m4%200h1m1%200h1m4%200h2m3%200h5M4%2032.5h1m1%200h3m1%200h1m2%200h1m3%200h3m1%200h2m3%200h1m1%200h6m1%200h1M4%2033.5h1m1%200h3m1%200h1m2%200h2m4%200h1m2%200h4m2%200h2m1%200h2m1%200h3M4%2034.5h1m1%200h3m1%200h1m4%200h3m2%200h6m1%200h2m2%200h3m1%200h2M4%2035.5h1m5%200h1m2%200h2m1%200h2m1%200h1m2%200h1m1%200h1m4%200h1m1%200h4M4%2036.5h7m1%200h6m2%200h2m4%200h1m1%200h2m1%200h1m3%200h1'/%3e%3c/svg%3e";function Mn(){const e=Je(Xe().language);return e==="en"?{close:"Close",title:"Continue on your phone",free:"Mac and Web are free",description:"Step away from your desk. Check progress, respond to approvals and continue your sessions on your phone.",download:"Scan to install",ios:"Get the iPhone app",android:"Get the Android app",pairing:"Keep your computer running. On Mac, open Settings → Current device, enable phone access and generate a pairing code. Open Vibelet on your phone and scan it. For a CLI daemon, use the pairing code shown by npx vibelet.",pro:"Explore the mobile app first. Upgrade to Vibelet Pro on your phone when you need its advanced features. Existing mobile purchases can be restored there."}:e==="zh-TW"?{close:"關閉",title:"在手機上繼續",free:"Mac 與 Web 免費使用",description:"離開電腦,也能查看任務進度、處理審批,繼續同一段對話。",download:"掃碼安裝",ios:"取得 iPhone 版",android:"取得 Android 版",pairing:"保持電腦運行。在 Mac「設定 → 當前裝置」開啟手機存取並產生配對碼,再用手機 Vibelet 掃碼。使用 CLI 時,掃描 npx vibelet 顯示的配對碼。",pro:"先體驗手機端,需要進階功能時再於手機升級 Vibelet Pro。已有手機端購買可在手機恢復。"}:{close:"关闭",title:"在手机上继续",free:"Mac 与 Web 免费使用",description:"离开电脑,也能查看任务进度、处理审批,继续同一段对话。",download:"扫码安装",ios:"获取 iPhone 版",android:"获取 Android 版",pairing:"保持电脑运行。在 Mac「设置 → 当前设备」开启手机访问并生成配对码,再用手机 Vibelet 扫码。使用 CLI 时,扫描 npx vibelet 显示的配对码。",pro:"先体验手机端,需要高级功能时再在手机升级 Vibelet Pro。已有手机端购买可在手机恢复。"}}function Si(){const e=Mn();return r.jsxs("section",{className:"mobile-companion-panel control-section",children:[r.jsx("p",{className:"mobile-companion-free",children:e.free}),r.jsx("h2",{children:e.title}),r.jsx("p",{children:e.description}),r.jsx("div",{className:"mobile-companion-downloads",children:[{label:e.ios,qr:Sc,url:"https://apps.apple.com/app/id6761245790"},{label:e.android,qr:wc,url:"https://www.feishu.cn/file/RUnbb7INMocEFjxj5AWcC7WEn6d"}].map(t=>r.jsxs("div",{children:[r.jsx("img",{src:t.qr,alt:`${t.label} · ${e.download}`,width:"140",height:"140"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:t.label})]},t.url))}),r.jsx("p",{children:e.pairing}),r.jsx("p",{className:"mobile-companion-hint",children:e.pro})]})}function kc({onClose:e}){const t=c.useRef(null);c.useEffect(()=>{const s=document.activeElement,i=document.getElementById("vibelet-workspace"),a=i?.inert;return i&&(i.inert=!0),t.current?.focus(),()=>{i&&(i.inert=!!a),s?.focus()}},[]);const n=Mn().title;return it.createPortal(r.jsx("div",{className:"mobile-companion-backdrop",onClick:s=>{s.target===s.currentTarget&&e()},children:r.jsxs("section",{ref:t,className:"mobile-companion-dialog",role:"dialog","aria-modal":"true","aria-label":n,tabIndex:-1,onKeyDown:s=>{if(s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),e()),s.key!=="Tab")return;const i=Array.from(s.currentTarget.querySelectorAll("button,a[href]")),a=i[0],o=i.at(-1);s.shiftKey&&(document.activeElement===a||document.activeElement===t.current)?(s.preventDefault(),o?.focus()):!s.shiftKey&&document.activeElement===o&&(s.preventDefault(),a?.focus())},children:[r.jsx("button",{type:"button",className:"icon-button mobile-companion-close","aria-label":Mn().close,title:Mn().close,onClick:e,children:r.jsx(Me,{"aria-hidden":"true"})}),r.jsx(Si,{})]})}),document.body)}function jc({activeSession:e,busy:t,controlsOpen:n,t:s,onOpenControls:i,onRefreshSessions:a,onRestoreSnapshot:o,onToggleArchived:l,onTogglePinned:u,onViewChanges:h}){const[d,m]=c.useState(!1),[g,p]=c.useState(!1),S=c.useRef(null);c.useEffect(()=>{if(!g)return;const v=j=>{j.target instanceof Node&&!S.current?.contains(j.target)&&p(!1)},k=j=>{j.key==="Escape"&&p(!1)};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",k),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k)}},[g]);const w=v=>{p(!1),v()},b=se(),y=r.jsxs("div",{className:"header-actions",children:[d&&r.jsx(kc,{onClose:()=>m(!1)}),e?null:r.jsx("button",{"aria-label":s.refreshSessions,className:"icon-button",onClick:a,title:s.refreshSessions,type:"button",children:r.jsx(Dn,{"aria-hidden":"true"})}),r.jsx("button",{"aria-expanded":n,"aria-label":n?s.collapseControlsSidebar:s.workspaceTools,title:Hn(n?s.collapseControlsSidebar:s.workspaceTools,"rightSidebar"),className:"header-tool-button",onClick:i,type:"button",children:r.jsx($o,{"aria-hidden":"true"})}),e||b.openSettings?r.jsxs("div",{className:"header-more-wrap",ref:S,children:[r.jsx("button",{"aria-expanded":g,"aria-haspopup":"menu","aria-label":s.moreActions,className:"icon-button",onClick:()=>p(v=>!v),title:s.moreActions,type:"button",children:r.jsx(so,{"aria-hidden":"true"})}),g?r.jsxs("div",{className:"header-action-menu",role:"menu",children:[e&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>w(()=>h(e.sessionId)),role:"menuitem",type:"button",children:[r.jsx(os,{"aria-hidden":"true"}),r.jsx("span",{children:s.viewChanges})]}),r.jsxs("button",{disabled:t,onClick:()=>w(u),role:"menuitem",type:"button",children:[r.jsx(qn,{"aria-hidden":"true"}),r.jsx("span",{children:e.pinned?s.unpin:s.pin})]}),r.jsxs("button",{disabled:t,onClick:()=>w(l),role:"menuitem",type:"button",children:[r.jsx(as,{"aria-hidden":"true"}),r.jsx("span",{children:e.archived?s.unarchive:s.archive})]}),r.jsxs("button",{onClick:()=>w(o),role:"menuitem",type:"button",children:[r.jsx(fi,{"aria-hidden":"true"}),r.jsx("span",{children:s.restoreSnapshot})]})]}),r.jsxs("button",{role:"menuitem",type:"button",onClick:()=>w(()=>m(!0)),children:[r.jsx(ba,{"aria-hidden":"true"}),r.jsx("span",{children:Mn().title})]}),b.openSettings&&r.jsxs("button",{role:"menuitem",type:"button",onClick:()=>w(b.openSettings),children:[r.jsx(tc,{"aria-hidden":"true"}),r.jsx("span",{children:s.settings})]}),r.jsxs("button",{onClick:()=>w(a),role:"menuitem",type:"button",children:[r.jsx(Dn,{"aria-hidden":"true"}),r.jsx("span",{children:s.refreshSessions})]})]}):null]}):null]}),f=b.toolbarTarget?.("right");return f?it.createPortal(y,f):y}const Cc=/^[A-Za-z][A-Za-z0-9_-]*$/,Ic=[{name:"clear",commandName:"clear",title:"Clear session",description:"Clear this session in place.",source:"Vibelet",agents:["claude","codex"],argsHint:""},{name:"new",commandName:"new",title:"New session",description:"Start a fresh session with the same assistant and directory.",source:"Vibelet",agents:["claude","codex"],argsHint:""},{name:"exit",commandName:"exit",title:"Archive session",description:"Archive this session and return to the session list.",source:"Vibelet",agents:["claude","codex"],argsHint:""},{name:"quit",commandName:"exit",title:"Archive session",description:"Alias for /exit.",source:"Vibelet",agents:["claude","codex"],argsHint:""},{name:"q",commandName:"exit",title:"Archive session",description:"Alias for /exit.",source:"Vibelet",agents:["claude","codex"],argsHint:""},{name:"compact",commandName:"compact",title:"Compact context",description:"Ask the assistant runtime to compact the current session.",source:"Native",agents:["claude","codex"],argsHint:""},{name:"goal",commandName:"goal",title:"Goal",description:"View, set, pause, resume, or clear the current goal.",source:"Native",agents:["claude","codex"],argsHint:"[objective|status|pause|resume|clear]"}];function ki(e){return Ic.filter(t=>!e||t.agents.includes(e))}function tr(e){return e.trim().toLowerCase()}function Vn(e){if(!e.startsWith("/")||e.startsWith("//"))return null;const t=/^\/([A-Za-z0-9_-]*)$/.exec(e);if(!t)return null;const n=t[1]??"";return n&&!Cc.test(n)?null:{start:0,end:e.length,keyword:tr(n)}}function Nc(e,t,n=8){const s=tr(t);return(s?e.filter(a=>a.name.includes(s)||a.title.toLowerCase().includes(s)).sort((a,o)=>Sr(a,s)-Sr(o,s)):[...e]).slice(0,n)}function Sr(e,t){return e.name===t?0:e.name.startsWith(t)?1:e.name.includes(t)?2:3}function Ec(e,t,n){return`${e.slice(0,t.start)}${ji(n,"")}${e.slice(t.end)}`}function Rc(e,t,n){return t?Ec(e,t,n):`${ji(n,e)}${e}`}function ji(e,t){const n=t.length>0,s=n&&!/^\s/.test(t),i=!!(e.argsHint&&!n);return`/${e.name}${i||s?" ":""}`}function kr(e,t){const n=e.trim();if(!n.startsWith("/")||n.startsWith("//"))return null;const s=/^\/([A-Za-z][A-Za-z0-9_-]*)(?:\s+([\s\S]*))?$/.exec(n);if(!s)return null;const i=tr(s[1]??""),a=ki(t).find(l=>l.name===i);if(!a)return null;const o=s[2]?.trim()??"";switch(a.commandName){case"clear":return{raw:n,command:{name:"clear"}};case"new":return{raw:n,command:{name:"new"}};case"exit":return{raw:n,command:{name:"exit"}};case"compact":return{raw:n,command:{name:"compact"}};case"goal":{const l=o.toLowerCase();return!o||l==="status"||l==="show"||l==="usage"||l==="help"?{raw:n,command:{name:"goal",operation:"status"}}:l==="clear"||l==="reset"?{raw:n,command:{name:"goal",operation:"clear"}}:l==="pause"||l==="paused"?{raw:n,command:{name:"goal",operation:"pause"}}:l==="resume"||l==="active"?{raw:n,command:{name:"goal",operation:"resume"}}:{raw:n,command:{name:"goal",operation:"set",objective:o}}}}}function Ac(e){return e.startsWith("//")?e.slice(1):e}function Tc(e){return e.name==="compact"?"/compact":e.name!=="goal"?null:e.operation==="clear"?"/goal clear":e.operation==="pause"?"/goal pause":e.operation==="resume"?"/goal resume":e.operation==="set"&&e.objective?.trim()?`/goal ${e.objective.trim()}`:"/goal"}function Mc(e){const t=typeof e?.objective=="string"?e.objective.trim():"";return t?`Goal${typeof e?.status=="string"&&e.status?` (${e.status})`:""}: ${t}`:"Goal: none."}function jr(e){return e==="subscriptionRequired"?"Error: Agent commands require an active Pro subscription.":`Error: ${e||"Command failed."}`}function Pc(e,t){return!t||!Vn(e)?e:t.draftBeforeInsertion}function Ci(e){return/^[a-zA-Z0-9._/~-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Dc(e){const t=e.approvalMode??e.observedApprovalMode,n=e.agent==="claude"?["claude","--resume",e.sessionId]:["codex","resume",e.sessionId];return t==="autoApprove"?n.push(e.agent==="claude"?"--dangerously-skip-permissions":"--dangerously-bypass-approvals-and-sandbox"):e.agent==="claude"&&t==="acceptEdits"&&n.push("--permission-mode","acceptEdits"),n.map(Ci).join(" ")}function Ii(e){return`cd ${Ci(e.cwd||".")} && ${Dc(e)}`}const Ni="vibelet.web.notificationSettings",zt={enabled:!1,approvals:!0,questions:!0,replies:!0,hiddenOnly:!0};function Ps(e=Ge()){try{const t=e.getItem(Ni);if(!t)return{...zt};const n=JSON.parse(t);return nn(n)?{enabled:typeof n.enabled=="boolean"?n.enabled:zt.enabled,approvals:typeof n.approvals=="boolean"?n.approvals:zt.approvals,questions:typeof n.questions=="boolean"?n.questions:zt.questions,replies:typeof n.replies=="boolean"?n.replies:zt.replies,hiddenOnly:typeof n.hiddenOnly=="boolean"?n.hiddenOnly:zt.hiddenOnly}:{...zt}}catch{return{...zt}}}function _c(e,t=Ge()){t.setItem(Ni,JSON.stringify(e))}function Pn(e=typeof Notification>"u"?void 0:Notification){return se().notifications?se().notifications.permission():e?.permission??"unsupported"}function Lc(e,t,n=typeof document>"u"?"visible":document.visibilityState){return!(!e.enabled||t!=="granted"||e.hiddenOnly&&n==="visible")}function $c(e,t,n={}){const s=n.notificationFactory??(typeof Notification>"u"?void 0:Notification);if(!s&&!se().notifications)return!1;const i=n.settings??{enabled:!0,hiddenOnly:!1},a=n.permission??Pn(),o=n.visibilityState??(typeof document>"u"?"visible":document.visibilityState);if(!Lc(i,a,o))return!1;if(se().notifications)return se().notifications.show(e,t,n.onClick),!0;const l=new s(e,{body:t,tag:n.tag});return n.onClick&&(l.onclick=n.onClick),!0}function Ds(e,t){return e.role===t.role&&(e.type??"message")===(t.type??"message")&&e.content===t.content&&JSON.stringify(e.images??[])===JSON.stringify(t.images??[])&&e.toolName===t.toolName&&JSON.stringify(e.toolInput)===JSON.stringify(t.toolInput)}function Fc(e,t){if(e.historyKey&&t.historyKey)return e.historyKey===t.historyKey;const n=e.timestamp?Date.parse(e.timestamp):NaN;return Number.isFinite(n)&&n>0&&n===Date.parse(t.timestamp??"")&&Ds(e,t)}function Oc(e){for(let t=e.length-1;t>=0;t-=1)if(e[t]?.role==="user")return t;return-1}function Ei(e,t){const n=e.slice(),s=new Map,i=[];n.forEach((o,l)=>{o.historyKey&&!s.has(o.historyKey)&&s.set(o.historyKey,l),(!o.historyKey||o.historyKey.startsWith("client:"))&&i.push(l)});const a=new Set;for(const o of t){const l=o.historyKey?s.get(o.historyKey)??-1:-1;if(l>=0){o.delivery==="accepted"&&(n[l]={...n[l],...o,localDelivery:"delivered"});continue}const h=(o.historyKey?i:n.map((d,m)=>m)).find(d=>{const m=n[d];if(a.has(d))return!1;if(Fc(m,o))return!0;if(m.historyKey&&!m.historyKey.startsWith("client:"))return!1;if(m.liveReply&&(d===n.length-1||n.slice(d+1).every(g=>g.localClientMessageId&&g.historyKey?.startsWith("client:")))&&o.role==="assistant"&&o.type!=="info")return m.content.length>0&&o.content.startsWith(m.content);if(m.localClientMessageId&&o.historyKey&&!o.historyKey.startsWith("client:")&&Ds(m,o)){const g=Date.parse(m.timestamp??""),p=Date.parse(o.timestamp??"");if(Number.isFinite(g)&&Number.isFinite(p))return p>=g-1e3}return!!(o.historyKey&&!o.historyKey.startsWith("client:")&&m.historyKey?.startsWith("client:")&&m.role==="user"&&d===Oc(n)&&n.slice(d+1).every(g=>g.role!=="assistant"||g.type==="info"||g.liveReply)&&Ds(m,o))})??-1;if(h<0)o.historyKey&&s.set(o.historyKey,n.length),(!o.historyKey||o.historyKey.startsWith("client:"))&&i.push(n.length),n.push({...o});else{a.add(h);const d=n[h].historyKey;d&&d!==o.historyKey&&s.delete(d),n[h]={...n[h],...o},n[h].historyKey&&s.set(n[h].historyKey,h),n[h].localClientMessageId&&o.historyKey&&!o.historyKey.startsWith("client:")&&(n[h].localDelivery="delivered"),delete n[h].liveReply}}return n}function nr(e){const t=e.at(-1);return t?.role==="assistant"&&t.type!=="info"?[...e.slice(0,-1),{...t,liveReply:!0}]:e.slice()}const qc=".",Wc="@vibelet/needs-attention",Hc="@vibelet/running",Bc="@vibelet/pinned";function zc(e,t={}){const n=new Map,s=[],i=[],a=[];for(const l of e){const u=l.archived!==!0;if(!!(t.showNeedsAttentionGroup&&u&&(t.needsAttentionSessionIds?.has(l.sessionId)||l.runtime.needsAttention||l.interruptReason||l.stallWarning))?s.push(l):t.showRunningGroup&&u&&t.respondingSessionIds?.has(l.sessionId)&&i.push(l),t.separatePinnedGroup&&u&&l.pinned){a.push(l);continue}const d=l.cwd||qc;n.set(d,[...n.get(d)??[],l])}const o=[];if(s.length>0&&o.push({folder:Wc,kind:"attention",sessions:s}),i.length>0){const l=new Map(t.runningSessionOrder?.map((u,h)=>[u,h]));o.push({folder:Hc,kind:"running",sessions:l.size?[...i].sort((u,h)=>(l.get(u.sessionId)??Number.MAX_SAFE_INTEGER)-(l.get(h.sessionId)??Number.MAX_SAFE_INTEGER)):i})}return a.length>0&&o.push({folder:Bc,kind:"pinned",sessions:[...a].sort((l,u)=>Date.parse(u.lastActivityAt)-Date.parse(l.lastActivityAt))}),[...o,...Array.from(n.entries()).map(([l,u])=>({folder:l,kind:"folder",sessions:u}))]}function ds(e,t=Date.now(),n=va){if(!e)return n.timeUnknown;const s=Date.parse(e);if(!Number.isFinite(s))return n.timeUnknown;const i=t-s,a=60*1e3,o=60*a,l=24*o;return i<a?n.timeNow:i<o?n.timeMinutesAgo(Math.floor(i/a)):i<l?n.timeHoursAgo(Math.floor(i/o)):n.timeDaysAgo(Math.floor(i/l))}function Ri(e,t){return e.type==="info"?t.messageInfoRole:{user:t.messageUserRole,assistant:t.messageAssistantRole,tool:t.messageToolRole}[e.role]}function Ai(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e;return typeof t.lastActivityAt=="string"&&typeof t.sessionId=="string"?{lastActivityAt:t.lastActivityAt,sessionId:t.sessionId}:void 0}const dt=".",sr="normal",Cr=80,Kc=1600,Gc="pending_local_";function nn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Uc(e){if(!Number.isFinite(e))return"unknown";const t=e??0;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function rr(e,t){const n=e[e.length-1];return n?.role==="assistant"&&n.type!=="info"?[...e.slice(0,-1),{...n,content:`${n.content}${t}`}]:[...e,{role:"assistant",content:t,timestamp:new Date().toISOString()}]}function Ti(e){const t=e;return{sessions:Array.isArray(t.sessions)?t.sessions:[],nextCursor:Ai(t.nextCursor),inventoryVersion:t.inventoryVersion,inventoryBackfillInFlight:t.inventoryBackfillInFlight,folderCounts:t.folderCounts}}function Vc(e){const t=e;return typeof t.sessionId=="string"?t.sessionId:null}function Qc(e){const t=e;return typeof t.path=="string"?t.path:null}function Ht(e){return e.split("/").filter(Boolean).at(-1)??e}function Zc(e){return Object.entries(e).length===0?"No structured input.":JSON.stringify(e,null,2)}function ir(e){return Object.fromEntries(e.questions.map(t=>[t.id,t.options[0]?[t.options[0].label]:[]]))}function Qn(e){return e.trim()||void 0}function Mi(e){if(e==="7d")return Date.now()-7*864e5;if(e==="30d")return Date.now()-30*864e5;if(e==="90d")return Date.now()-90*864e5}function _s(e,t){const n=new Map;for(const s of e)n.set(s.sessionId,s);for(const s of t)n.set(s.sessionId,{...n.get(s.sessionId),...s,interruptReason:s.interruptReason,stallWarning:s.stallWarning});return Array.from(n.values()).sort((s,i)=>{const a=s.pinned?s.pinnedAt??0:0,o=i.pinned?i.pinnedAt??0:0;return a!==o?o-a:Date.parse(i.lastActivityAt)-Date.parse(s.lastActivityAt)})}let Ss=0;function Yc(e=Date.now()){return Ss=(Ss+1)%1e4,`${Gc}${e}_${Ss}`}function Jc(e){const t=e.now??new Date().toISOString();return{sessionId:e.sessionId,agent:e.agent,cwd:e.cwd||dt,...e.model?{model:e.model}:{},...e.effort?{effort:e.effort}:{},fastMode:e.fastMode??!1,...e.title?{title:e.title}:{},createdAt:t,lastActivityAt:t,sources:["daemon"],runtime:{state:"daemonActive",confidence:"high",resumeMode:"reuseDriver"},managed:!0,approvalMode:e.approvalMode}}function Xc(e,t,n=new Date().toISOString()){return{...e,sessionId:t,lastActivityAt:n}}function ks(e,t,n){if(!t||!n||t===n||!Object.hasOwn(e,t))return e;const{[t]:s,...i}=e;return{...i,[n]:s}}function Ir(e,t,n){if(!t||!n||t===n||!e.has(t))return e;const s=new Set(e);return s.delete(t),s.add(n),s}function el(e,t){const n=e.replace(/\\/g,"/").replace(/\/+$/,"");return!n||n==="."?t:`${n}/${t}`}function cm(e){const t=e.replace(/\\/g,"/").replace(/\/+$/,"");if(!t||t==="/"||t==="~"||t===".")return null;const n=t.lastIndexOf("/");return n<0?".":n===0?"/":t.slice(0,n)}function tl(e,t){return t.startsWith("text/")||t.includes("json")||t.includes("xml")||t.includes("javascript")?!0:/\.(md|txt|json|ya?ml|toml|csv|log|ts|tsx|js|jsx|css|html|xml|py|rb|go|rs|java|kt|swift|sh|zsh|bash)$/i.test(e)}function nl(e,t){return t.startsWith("image/")||/\.(png|jpe?g|gif|webp|heic|heif|svg)$/i.test(e)}function Zn(e,t,n=window.location.origin){const s=new URL("/file",n);return s.searchParams.set("path",e),t&&s.searchParams.set("cwd",t),s.toString()}function Gn(e,t){return e.get(t)||void 0}function sl(e,t){return`${e.replace(/[<>:"/\\|?*\u0000-\u001F]/g," ").replace(/\s+/g," ").trim().slice(0,80)||t.slice(0,12)||"session"}.txt`}function rl(e,t){const n=[`# ${Et(e)}`,"",`- Agent: ${e.agent}`,`- Session: \`${e.sessionId}\``,`- Working directory: \`${e.cwd}\``,`- Created: ${e.createdAt}`,`- Exported: ${new Date().toISOString()}`,""];for(const s of t){if(s.role!=="user"&&s.role!=="assistant")continue;const i=s.content.trim(),a=(s.images??[]).map(o=>`- Attachment: \`${o}\``);!i&&a.length===0||(n.push(`## ${s.role==="user"?"User":"Assistant"}`,""),i&&n.push(i,""),a.length&&n.push(...a,""))}return n.join(`
3
+ `).trimEnd()}function il(e,t){const n=URL.createObjectURL(new Blob([t],{type:"text/plain;charset=utf-8"})),s=document.createElement("a");s.href=n,s.download=e,s.click(),URL.revokeObjectURL(n)}function al(e,t={}){const n=new Set,s={},i={},a={};for(const p of e.sessions)(p.runtime.isResponding||p.runtime.state==="daemonActive")&&n.add(p.sessionId);for(const p of e.pendingApprovals??[])s[p.sessionId]={type:"approval.request",...p};for(const p of e.pendingQuestions??[])i[p.sessionId]={type:"question.request",...p};let o=null,l,u,h,d,m,g;if(e.activeSession){const p=e.activeSession,S=e.sessions.find(b=>b.sessionId===p.sessionId);o=p.sessionId,l=p.agent,u=S?.cwd||t.currentCwd||dt,h=p.approvalMode??S?.approvalMode??sr,d=p.approvalMode??null;const w=p.messages??[];if(m=p.partialReplyText?nr(rr(w,p.partialReplyText)):w,(p.isResponding||p.externallyResponding)&&n.add(p.sessionId),p.pendingApproval&&(s[p.sessionId]={type:"approval.request",sessionId:p.sessionId,...p.pendingApproval}),p.pendingQuestion){const b={type:"question.request",sessionId:p.sessionId,...p.pendingQuestion};i[p.sessionId]=b,g=ir(b)}p.pendingQueue?.length&&(a[p.sessionId]=p.pendingQueue)}else{const p=t.currentActiveSessionId??null;if(p){const S=e.sessionAliases?.[p];S?o=S:e.sessions.some(w=>w.sessionId===p)&&(o=p)}o=o??e.sessions[0]?.sessionId??null}return{page:{sessions:e.sessions,nextCursor:Ai(e.nextCursor),inventoryVersion:e.inventoryVersion,inventoryBackfillInFlight:e.inventoryBackfillInFlight},activeSessionId:o,activeAgent:l,activeCwd:u,activeApprovalMode:h,activeApprovalOverride:d,messages:m,respondingSessionIds:Array.from(n),pendingApprovals:s,pendingQuestions:i,pendingQueues:a,questionAnswers:g}}function Nr(e,t){if(e==="subscriptionRequired"){const n=typeof window>"u"?"en":Je(Xe().language);return n==="en"?"Computer features are free. Update Vibelet on the paired computer and reconnect.":n==="zh-TW"?"電腦端功能免費。請更新配對電腦上的 Vibelet,再重新連線。":"电脑端功能免费。请更新配对电脑上的 Vibelet,再重新连接。"}return e==="skillNotFound"?"Skill not found on the paired computer.":e==="skillResolveFailed"?"Could not load the skill on the paired computer.":e}const ol=/^[A-Za-z_][A-Za-z0-9._:-]*$/,cl=/(?:^|\s)\$([A-Za-z_][A-Za-z0-9._:-]*|)$/;function Ln(e){return e.trim().toLowerCase()}function Er(e){const t=e.trim(),n=/^\$([A-Za-z_][A-Za-z0-9._:-]*)(?:\s+([\s\S]*))?$/.exec(t);return n?{name:Ln(n[1]??""),...n[2]?.trim()?{args:n[2].trim()}:{}}:null}function Yn(e){const t=cl.exec(e);if(!t||t.index+t[0].length!==e.length)return null;const n=t[1]??"";if(n&&!ol.test(n))return null;const s=t[0].lastIndexOf("$");return{start:t.index+s,end:e.length,keyword:Ln(n)}}function ll(e,t,n){return`${e.slice(0,t.start)}$${Ln(n)} ${e.slice(t.end)}`}function dl(e,t){if(!t)return e;const n=Yn(e);if(!n||n.start!==t.triggerStart)return e;const s=n.start>t.draftBeforeInsertion.length?" ":"";return e.slice(0,n.start)!==`${t.draftBeforeInsertion}${s}`?e:t.draftBeforeInsertion}function ul(e,t,n=8){const s=Ln(t);return(s?e.filter(a=>Ln(a.name).includes(s)):e).slice(0,n)}function An({icon:e,label:t,menuLabel:n,options:s,value:i,onSelect:a,align:o="left",disabled:l,selected:u,wide:h}){const[d,m]=c.useState(!1),g=c.useRef(null),p=c.useRef(null),S=s.some(w=>w.icon);return c.useEffect(()=>{if(!d)return;const w=g.current?.querySelectorAll('[role="menuitemradio"]:not(:disabled)');([...w??[]].find(f=>f.getAttribute("aria-checked")==="true")??w?.[0])?.focus();const y=f=>{f.target instanceof Node&&!g.current?.contains(f.target)&&m(!1)};return document.addEventListener("pointerdown",y),()=>document.removeEventListener("pointerdown",y)},[d]),r.jsxs("div",{className:"composer-menu",ref:g,onBlur:w=>{const b=w.relatedTarget;(!b||!w.currentTarget.contains(b))&&m(!1)},onKeyDown:w=>{if(w.key==="Escape"&&d&&(w.stopPropagation(),w.preventDefault(),m(!1),p.current?.focus()),!["ArrowDown","ArrowUp","Home","End"].includes(w.key))return;if(w.preventDefault(),!d){m(!0);return}const b=[...w.currentTarget.querySelectorAll('[role="menuitemradio"]:not(:disabled)')];if(!b.length)return;const y=b.indexOf(document.activeElement),f=w.key==="Home"?0:w.key==="End"?b.length-1:(y+(w.key==="ArrowDown"?1:-1)+b.length)%b.length;b[f]?.focus()},children:[r.jsxs("button",{ref:p,"aria-expanded":d,"aria-haspopup":"menu",className:`composer-option-button ${d||u?"selected":""}`,disabled:l,onClick:()=>m(w=>!w),title:n,type:"button",children:[r.jsx(e,{"aria-hidden":"true"}),r.jsx("span",{children:t}),d?r.jsx(ai,{"aria-hidden":"true"}):r.jsx(Zs,{"aria-hidden":"true"})]}),d?r.jsx("div",{"aria-label":n,className:`composer-option-popover ${S?"":"without-icons"} ${h?"wide":""} ${o==="right"?"align-right":""}`,role:"menu",children:s.map(w=>{const b=w.icon,y=w.value===i;return r.jsxs("button",{"aria-checked":y,className:y?"selected":"",disabled:w.disabled,onClick:()=>{a(w.value),m(!1),p.current?.focus()},role:"menuitemradio",title:w.description??w.label,type:"button",children:[S&&r.jsx("span",{className:"composer-menu-icon",children:b?r.jsx(b,{"aria-hidden":"true"}):null}),r.jsxs("span",{className:"composer-menu-copy",children:[r.jsx("strong",{children:w.label}),w.description?r.jsx("small",{children:w.description}):null]}),r.jsx("span",{className:"composer-menu-indicator","aria-hidden":"true",children:y?r.jsx(Lt,{className:"composer-menu-check"}):null})]},w.value)})}):null]})}function Pi(e,t,n){const s=c.useRef(null);return c.useEffect(()=>{n&&document.getElementById(`${e}-${t}`)?.scrollIntoView({block:"nearest"})},[e,t,n]),s}function hl({visible:e,listId:t,selectedIndex:n,onHighlight:s,skills:i,onClose:a,onSelect:o,t:l}){const u=Pi(t,n,e);return e?r.jsxs("div",{className:"skill-suggestion-popover",children:[r.jsxs("header",{children:[r.jsx("strong",{children:l.skills}),r.jsx("button",{type:"button",className:"icon-button",onClick:a,title:l.closeSkills,children:r.jsx(Me,{"aria-hidden":"true"})})]}),i.length?r.jsx("div",{className:"skill-suggestion-list",id:t,role:"listbox",ref:u,children:i.map((h,d)=>r.jsxs("button",{id:`${t}-${d}`,role:"option","aria-selected":n===d,onMouseEnter:()=>s(d),onClick:()=>o(h),title:h.description??h.name,type:"button",children:[r.jsxs("span",{children:[r.jsxs("strong",{children:["$",h.name]}),h.description?r.jsx("small",{children:h.description}):null]}),r.jsx("em",{children:h.source})]},`${h.source}:${h.name}`))}):r.jsx("p",{children:l.noSkillsFound})]}):null}function fl({visible:e,listId:t,selectedIndex:n,onHighlight:s,commands:i,onClose:a,onSelect:o,t:l}){const u=Pi(t,n,e);return e?r.jsxs("div",{className:"skill-suggestion-popover command-suggestion-popover",children:[r.jsxs("header",{children:[r.jsx("strong",{children:l.commands}),r.jsx("button",{type:"button",className:"icon-button",onClick:a,title:l.closeCommands,children:r.jsx(Me,{"aria-hidden":"true"})})]}),i.length?r.jsx("div",{className:"skill-suggestion-list",id:t,role:"listbox",ref:u,children:i.map((h,d)=>r.jsxs("button",{id:`${t}-${d}`,role:"option","aria-selected":n===d,onMouseEnter:()=>s(d),onClick:()=>o(h),title:h.description,type:"button",children:[r.jsxs("span",{children:[r.jsxs("strong",{children:["/",h.name]}),r.jsx("small",{children:h.argsHint?`${h.title} ${h.argsHint}`:h.title})]}),r.jsx("em",{children:h.source})]},h.name))}):r.jsx("p",{children:l.noCommandsFound})]}):null}function ml({queue:e,controls:t,busy:n,t:s,onCancel:i}){const[a,o]=c.useState(new Set),[l,u]=c.useState(!1),h=c.useId(),d=c.useRef(null),m=c.useRef(0),g=c.useRef(!1),[p,S]=c.useState(null),w=c.useRef(null),b=()=>{w.current=null,S(null)},y=x=>{if(w.current===x)return;const C=x.getBoundingClientRect(),I=Math.min(280,window.innerWidth-16);w.current=x,S({label:x.dataset.queueLabel||"",help:x.dataset.queueHelp||"",left:Math.max(8,Math.min(C.left,window.innerWidth-I-8)),top:C.top<76?C.bottom+7:C.top-7,below:C.top<76})},f=x=>{const C=x.target instanceof Element?x.target.closest("button[data-queue-help]"):null;C?y(C):w.current&&b()},v=e.filter(x=>x.clientMessageId),k=v.filter(x=>a.has(x.clientMessageId)),j=n||t.busy,E=k.length?k:v;return c.useLayoutEffect(()=>{e.length>m.current&&(g.current=!0,l&&u(!1)),m.current=e.length,!l&&g.current&&d.current&&(d.current.scrollTop=d.current.scrollHeight,g.current=!1)},[l,e.length]),e.length?r.jsxs("section",{className:"composer-queue-banner","aria-label":s.queuedTurns(e.length),onPointerMove:f,onPointerLeave:b,onFocusCapture:x=>{x.target instanceof HTMLButtonElement&&x.target.dataset.queueHelp&&y(x.target)},onBlurCapture:b,onScrollCapture:b,onClickCapture:b,children:[r.jsxs("header",{className:"composer-queue-heading",children:[r.jsx("strong",{"aria-live":"polite",children:s.queuedTurns(e.length)}),r.jsxs("div",{className:"composer-queue-heading-actions",children:[!l&&r.jsx("button",{type:"button","data-queue-label":v.length>0&&k.length===v.length?s.queueClearSelection:s.queueSelectAll,"data-queue-help":s.queueSelectionHelp,disabled:j||!v.length,onClick:()=>o(v.length>0&&k.length===v.length?new Set:new Set(v.map(x=>x.clientMessageId))),children:v.length>0&&k.length===v.length?s.queueClearSelection:s.queueSelectAll}),r.jsx("button",{type:"button",className:"composer-queue-collapse","aria-controls":h,"aria-expanded":!l,"aria-label":l?s.queueExpand:s.queueCollapse,"data-queue-label":l?s.queueExpand:s.queueCollapse,"data-queue-help":l?s.queueExpandHelp:s.queueCollapseHelp,onClick:()=>u(x=>!x),children:l?r.jsx(Zs,{"aria-hidden":"true"}):r.jsx(ai,{"aria-hidden":"true"})})]})]}),r.jsxs("div",{className:"composer-queue-details",id:h,hidden:l,children:[r.jsx("div",{className:"composer-queue-list",ref:d,children:e.map((x,C)=>r.jsxs("div",{className:"composer-queue-item","data-selected":!!x.clientMessageId&&a.has(x.clientMessageId)||void 0,children:[r.jsx("button",{type:"button",className:"queue-select-button","aria-label":s.selectQueuedTurn(C+1),"aria-pressed":!!x.clientMessageId&&a.has(x.clientMessageId),disabled:j||!x.clientMessageId,"data-queue-label":s.selectQueuedTurn(C+1),"data-queue-help":x.content?`${s.queueSelectionHelp}
4
+ ${x.content}`:s.queueSelectionHelp,onClick:()=>o(I=>{const N=new Set(I),L=x.clientMessageId;return N.has(L)?N.delete(L):N.add(L),N}),children:r.jsx("span",{children:x.content||s.queuedTurnFallback})}),r.jsxs("div",{className:"queue-row-actions",children:[r.jsx("button",{type:"button","data-queue-label":s.queueGuide,"data-queue-help":s.queueGuideHelp,"aria-label":s.guideQueuedTurn(C+1),disabled:j||!x.clientMessageId||!t.canGuide,onClick:()=>{t.onAction([x],"guide")},children:r.jsx(eo,{"aria-hidden":"true"})}),r.jsx("button",{type:"button","data-queue-label":s.queueSendNow,"data-queue-help":s.queueSendNowHelp,"aria-label":s.sendQueuedTurnNow(C+1),disabled:j||!x.clientMessageId||!t.canSendNow,onClick:()=>{t.onAction([x],"sendNow")},children:r.jsx(Yo,{"aria-hidden":"true"})}),r.jsx("button",{type:"button",className:"queue-withdraw-button","data-queue-label":s.withdraw,"data-queue-help":s.queueWithdrawHelp,"aria-label":s.withdrawQueuedTurn(C+1),disabled:j||!x.clientMessageId,onClick:()=>i(x),children:r.jsx(Me,{"aria-hidden":"true"})})]})]},x.clientMessageId||`${x.enqueuedAt}:${C}`))}),r.jsxs("footer",{className:"queue-batch-actions",children:[k.length>0&&r.jsx("span",{children:s.queueSelectedCount(k.length)}),r.jsxs("button",{type:"button","data-queue-label":k.length?s.queueCollectSelected:s.queueCollectAll,"data-queue-help":s.queueCollectHelp,disabled:j||E.length<2,onClick:()=>{t.onCollect(E)},children:[r.jsx(Io,{"aria-hidden":"true"}),k.length?s.queueCollectSelected:s.queueCollectAll]}),r.jsx("button",{type:"button","data-queue-label":k.length?s.queueGuideSelected:s.queueGuideAll,"data-queue-help":s.queueGuideHelp,disabled:j||!E.length||!t.canGuide,onClick:()=>{t.onAction(E,"guide")},children:k.length?s.queueGuideSelected:s.queueGuideAll}),r.jsx("button",{type:"button","data-queue-label":k.length?s.queueSendSelected:s.queueSendAll,"data-queue-help":s.queueSendNowHelp,disabled:j||!E.length||!t.canSendNow,onClick:()=>{t.onAction(E,"sendNow")},children:k.length?s.queueSendSelected:s.queueSendAll})]})]}),p&&it.createPortal(r.jsxs("div",{className:"composer-queue-tooltip",role:"tooltip",style:{left:p.left,top:p.top,transform:p.below?void 0:"translateY(-100%)"},children:[r.jsx("strong",{children:p.label}),r.jsx("span",{children:p.help})]}),document.body)]}):null}function pl({connected:e,busy:t,sending:n,responding:s,hasDraft:i,shortcut:a,onStop:o,t:l}){const u=n?"sending":s?"replying":"ready",h=s&&!n&&!i,d=n?l.sendingMessage:h?l.stopGenerating:l.send,m=n?l.sendingMessage:s?l.replyingMessage:l.send,g=n?cs:h?pi:qa;return r.jsxs("button",{type:h?"button":"submit",className:"send-button","data-state":u,"data-action":h?"stop":"send",disabled:!e||t||n||!h&&!i,"aria-label":d,"aria-description":m,title:h?`${m} · ${l.stopGenerating}`:n?m:`${s?`${m} · `:""}${l.send} · ${a==="enter"?l.sendShortcutEnter:l.sendShortcutModEnter}`,onClick:h?o:void 0,children:[s&&!n&&r.jsx("span",{className:"composer-send-progress","aria-hidden":"true"}),r.jsx(g,{className:n?"composer-send-spinner":h?"composer-send-stop":void 0,"aria-hidden":"true"}),r.jsx("span",{className:"composer-send-status",role:"status","aria-live":"polite",children:m})]})}function gl({context:e,count:t,onSelect:n,onClose:s}){const i=c.useId(),[a,o]=c.useState({context:"",index:0}),l=a.context===e?Math.min(a.index,Math.max(0,t-1)):0,u=d=>o({context:e,index:d});return{listId:i,selectedIndex:l,selectIndex:u,handleKeyDown:d=>!e||d.nativeEvent.isComposing||d.nativeEvent.keyCode===229||d.metaKey||d.ctrlKey||d.altKey||d.shiftKey?!1:d.key==="Escape"?(d.preventDefault(),d.stopPropagation(),s(),!0):t?d.key==="ArrowDown"||d.key==="ArrowUp"?(d.preventDefault(),d.stopPropagation(),u((l+(d.key==="ArrowDown"?1:-1)+t)%t),!0):d.key==="Enter"||d.key==="Tab"?(d.preventDefault(),d.stopPropagation(),n(l),!0):!1:!1}}async function yl(e){const t=new AudioContext;try{const n=await t.decodeAudioData(await e.arrayBuffer());if(n.duration>61||n.duration<=0)throw new Error("Invalid recording duration");const s=new Uint8Array(44+n.length*2),i=new DataView(s.buffer),a=(l,u)=>[...u].forEach((h,d)=>i.setUint8(l+d,h.charCodeAt(0)));a(0,"RIFF"),i.setUint32(4,s.length-8,!0),a(8,"WAVEfmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,n.sampleRate,!0),i.setUint32(28,n.sampleRate*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),a(36,"data"),i.setUint32(40,s.length-44,!0);const o=Array.from({length:n.numberOfChannels},(l,u)=>n.getChannelData(u));for(let l=0;l<n.length;l++){const u=Math.max(-1,Math.min(1,o.reduce((h,d)=>h+d[l],0)/o.length));i.setInt16(44+l*2,u*(u<0?32768:32767),!0)}return s}finally{await t.close()}}function bl({onTranscript:e}){const t=se(),[n,s]=c.useState("idle"),[i,a]=c.useState("");c.useEffect(()=>{if(!i||n!=="idle")return;const y=setTimeout(()=>a(""),5e3);return()=>clearTimeout(y)},[i,n]);const[o,l]=c.useState(0),u=c.useRef(!1);c.useEffect(()=>{if(n!=="recording")return;const y=Date.now();l(0);const f=setInterval(()=>l(Math.floor((Date.now()-y)/1e3)),1e3);return()=>clearInterval(f)},[n]);const[h,d]=c.useState(!1);c.useEffect(()=>{let y=!0;const f=()=>{t.speechSettings?.status().then(v=>{y&&d(v.configured)}).catch(()=>{y&&d(!1)})};return f(),window.addEventListener("vibelet.speech.changed",f),()=>{y=!1,window.removeEventListener("vibelet.speech.changed",f)}},[]);const m=c.useRef(null),g=c.useRef(!0),p=c.useRef(e);p.current=e;const S=Je(Xe().language),w=S!=="en";if(c.useEffect(()=>(g.current=!0,()=>{g.current=!1,m.current?.stream.getTracks().forEach(y=>y.stop()),m.current?.state==="recording"&&m.current.stop()}),[]),!h||!t.transcribeAudio||Ge().getItem("vibelet.web.voice.enabled")!=="true")return null;const b=async()=>{if(!u.current){u.current=!0,a(""),s("starting");try{const y=await navigator.mediaDevices.getUserMedia({audio:!0});if(!g.current){y.getTracks().forEach(E=>E.stop());return}let f;try{f=new MediaRecorder(y,{mimeType:"audio/webm"})}catch(E){throw y.getTracks().forEach(x=>x.stop()),E}m.current=f;const v=[];let k=0;f.ondataavailable=E=>{v.push(E.data),k+=E.data.size,k>9*1024*1024&&f.state==="recording"&&f.stop()};const j=setTimeout(()=>{f.state==="recording"&&f.stop()},6e4);f.onstop=async()=>{if(clearTimeout(j),y.getTracks().forEach(E=>E.stop()),m.current=null,!!g.current){s("transcribing");try{const E=new Blob(v,{type:"audio/webm"}),x=await t.speechSettings?.status(),C=x?.engine==="system"||x?.engine==="volcengine"?await yl(E):new Uint8Array(await E.arrayBuffer()),I=await t.transcribeAudio(C,S==="zh-TW"?"zh-TW":w?"zh":"en");if(g.current)if(I.trim()){a("");let N=I;const L=await t.polishSettings?.status().catch(()=>{});if(!g.current)return;if(L?.settings.enabled&&t.polishTranscript){s("polishing");try{const P=await t.polishTranscript(I);N=P.text,g.current&&P.status==="fallback"&&a(w?"润色暂不可用,已保留原始识别文字。":"Polishing unavailable; the original transcript was kept.")}catch{g.current&&a(w?"润色暂不可用,已保留原始识别文字。":"Polishing unavailable; the original transcript was kept.")}}g.current&&p.current(N)}else a(w?"没有识别到语音,请靠近麦克风重试。":"No speech detected. Try speaking closer to the microphone.")}catch{g.current&&a(w?"语音识别失败,请检查麦克风权限、语音设置和网络。":"Speech failed. Check microphone access, speech settings and connection.")}finally{u.current=!1,g.current&&s("idle")}}};try{f.start(1e3)}catch(E){throw clearTimeout(j),y.getTracks().forEach(x=>x.stop()),m.current=null,E}s("recording")}catch{u.current=!1,g.current&&(s("idle"),a(w?"无法开启麦克风,请检查系统权限。":"Microphone unavailable. Check system permissions."))}}};return r.jsxs("span",{className:"voice-input-control","data-voice-state":n,children:[r.jsx("button",{className:"icon-button",type:"button",disabled:n!=="idle"&&n!=="recording","aria-label":w?n==="recording"?"停止录音":"语音输入":n==="recording"?"Stop recording":"Voice input",title:n==="recording"?w?"停止录音":"Stop recording":w?"语音输入(最长 60 秒)":"Voice input (up to 60 seconds)",onClick:()=>{n==="recording"?m.current?.state==="recording"&&m.current.stop():b()},children:n==="recording"?r.jsx(pi,{"aria-hidden":"true"}):n==="idle"?r.jsx(ui,{"aria-hidden":"true"}):r.jsx(cs,{className:"voice-input-spinner","aria-hidden":"true"})}),n!=="idle"&&r.jsxs("span",{className:"voice-input-progress",children:[n==="recording"&&r.jsxs("span",{className:"voice-input-wave","aria-hidden":"true",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),r.jsx("span",{role:"status","aria-live":"polite",children:n==="recording"?w?"录音中":"Recording":n==="polishing"?w?"润色中":"Polishing":n==="transcribing"?w?"识别中":"Transcribing":w?"开启麦克风":"Opening microphone"}),n==="recording"&&r.jsxs("span",{className:"voice-input-time","aria-hidden":"true",children:["00:",String(o).padStart(2,"0")]})]}),n==="idle"&&i&&r.jsx("span",{className:"voice-input-error",role:"alert",children:i})]})}function vl(e){return[{value:"normal",label:e.approvalNormal,description:e.approvalNormalDescription,icon:Js},{value:"plan",label:e.approvalPlan,description:e.approvalPlanDescription,icon:mi},{value:"acceptEdits",label:e.approvalEdits,description:e.approvalEditsDescription,icon:io},{value:"autoApprove",label:e.approvalAuto,description:e.approvalAutoDescription,icon:fn}]}function xl(e){return[{value:"",label:e.effort,description:e.useDaemonDefault,icon:_t},{value:"minimal",label:e.effortMinimal,icon:_t},{value:"low",label:e.effortLow,icon:_t},{value:"medium",label:e.effortMedium,icon:_t},{value:"high",label:e.effortHigh,icon:_t},{value:"xhigh",label:e.effortXHigh,icon:_t},{value:"max",label:e.effortMax,icon:_t},{value:"ultra",label:e.effortUltra,icon:_t}]}function wl({activeQueue:e,queueControls:t,agent:n,attachments:s,approvalMode:i,activeModelOptions:a,busy:o,sending:l,responding:u,onStop:h,draft:d,effort:m,fastMode:g,model:p,phase:S,quickReplies:w,sendShortcut:b,skills:y,uploadBusy:f,t:v,onApprovalModeChange:k,onCancelQueuedTurn:j,onDraftChange:E,onEffortChange:x,onFastModeChange:C,onModelChange:I,onRefreshSkills:N,onRemoveAttachment:L,onSubmit:P,onUploadFiles:R}){const _=c.useRef(null),V=c.useRef(null),[Z,ue]=c.useState(!1),[ye,D]=c.useState(!1),[Q,G]=c.useState(!1),[re,ae]=c.useState(!1),[T,$]=c.useState(""),[B,Y]=c.useState(""),W=c.useRef(null),J=c.useRef(null),z=S==="connected",ne=c.useMemo(()=>ki(n),[n]),X=c.useMemo(()=>Vn(d),[d]),qe=X?`${X.start}:${X.end}:${X.keyword}`:"",me=!!(re||X&&B!==qe),Ue=c.useMemo(()=>Nc(ne,X?.keyword??"",8),[ne,X?.keyword]),Se=c.useMemo(()=>Yn(d),[d]),Ie=Se?`${Se.start}:${Se.end}:${Se.keyword}`:"",Ne=!!(!me&&(Q||Se&&T!==Ie)),ke=c.useMemo(()=>ul(y,Se?.keyword??"",8),[Se?.keyword,y]),be=c.useMemo(()=>vl(v),[v]),Ee=c.useMemo(()=>xl(v),[v]),We=a.find(A=>A.value===p)?.label??(p||v.defaultOption),Qe=be.find(A=>A.value===i)?.label??i,Ze=Ee.find(A=>A.value===m)?.label??m,he=a.map(A=>({value:A.value,label:A.label,description:A.desc,icon:ws}));he.some(A=>A.value==="")||he.unshift({value:"",label:v.defaultOption,description:v.useDaemonDefaultModel,icon:ws}),c.useEffect(()=>{Se||(W.current=null,$(""),G(!1))},[Se]),c.useEffect(()=>{X||(J.current=null,Y(""),ae(!1))},[X]);const je=async(A,Ae)=>{await R(A),Ae.value=""},et=async A=>{A.preventDefault(),ue(!1),z&&await R(A.dataTransfer.files)},Pe=async A=>{!z||!A.clipboardData.files.length||await R(A.clipboardData.files)},oe=()=>{const A=dl(d,W.current);W.current=null,A!==d&&E(A),Ie&&$(Ie),G(!1),V.current?.focus()},Ce=()=>{const A=Pc(d,J.current);J.current=null,A!==d&&E(A),qe&&Y(qe),ae(!1),V.current?.focus()},tt=()=>{if(me){Ce();return}Y(""),!Vn(d)&&d.length===0&&(J.current={draftBeforeInsertion:d},E("/")),ae(!0),V.current?.focus()},xe=A=>{const Ae=Vn(d),pe=Rc(d,Ae,A);E(pe),J.current=null,ae(!1),Y(""),V.current?.focus()},De=()=>{if(Ne){oe();return}if(N(),$(""),!Yn(d)){const A=d.length===0||/\s$/.test(d)?"":" ";W.current={draftBeforeInsertion:d,triggerStart:d.length+A.length},E(`${d}${A}$`)}G(!0),V.current?.focus()},Re=A=>{const Ae=Yn(d),pe=Ae?ll(d,Ae,A.name):d.trim().length?`${d}${/\s$/.test(d)?"":" "}$${A.name} `:`$${A.name} `;E(pe),W.current=null,G(!1),$(""),V.current?.focus()},ce=gl({context:me?`command:${qe}:${Ue.map(A=>A.name).join(",")}`:Ne?`skill:${Ie}:${ke.map(A=>`${A.source}:${A.name}`).join(",")}`:"",count:me?Ue.length:Ne?ke.length:0,onSelect:A=>me?xe(Ue[A]):Re(ke[A]),onClose:me?Ce:oe}),te=A=>{ce.handleKeyDown(A)||A.key!=="Enter"||A.nativeEvent.isComposing||A.nativeEvent.keyCode===229||!(b==="enter"?!A.shiftKey:A.metaKey||A.ctrlKey)||(A.preventDefault(),P())};return r.jsxs("form",{className:`composer ${Z?"dragging":""}`,onDragEnter:A=>{A.preventDefault(),ue(!0)},onDragLeave:()=>ue(!1),onDragOver:A=>A.preventDefault(),onDrop:A=>{et(A)},onSubmit:A=>{P(A)},children:[r.jsx(ml,{queue:e,controls:t,busy:o,t:v,onCancel:j}),ye&&w.length?r.jsx("div",{className:"quick-reply-row",children:w.slice(0,6).map(A=>r.jsx("button",{onClick:()=>E(d?`${d}
5
+ ${A}`:A),type:"button",children:A},A))}):null,r.jsx(hl,{visible:Ne,skills:ke,listId:ce.listId,selectedIndex:ce.selectedIndex,onHighlight:ce.selectIndex,onClose:oe,onSelect:Re,t:v}),r.jsx(fl,{visible:me,commands:Ue,listId:ce.listId,selectedIndex:ce.selectedIndex,onHighlight:ce.selectIndex,onClose:Ce,onSelect:xe,t:v}),r.jsx("textarea",{ref:V,"aria-controls":me||Ne?ce.listId:void 0,"aria-activedescendant":me&&Ue.length||Ne&&ke.length?`${ce.listId}-${ce.selectedIndex}`:void 0,"aria-autocomplete":"list",value:d,onChange:A=>E(A.target.value),onPaste:A=>{Pe(A)},onKeyDown:te,placeholder:v.messagePlaceholder,rows:3,disabled:!z}),r.jsxs("div",{className:"composer-toolbar",children:[r.jsxs("div",{className:"composer-leading-controls",children:[r.jsx(bl,{onTranscript:A=>E(d?`${d} ${A}`:A)}),r.jsx("button",{type:"button",className:"icon-button",onClick:()=>_.current?.click(),title:v.uploadFiles,"aria-label":v.uploadFiles,disabled:!z||f,children:r.jsx(Wn,{"aria-hidden":"true"})}),w.length?r.jsx("button",{className:`icon-button ${ye?"selected":""}`,type:"button",title:ye?v.hideQuickReplies:v.showQuickReplies,"aria-label":ye?v.hideQuickReplies:v.showQuickReplies,onClick:()=>D(A=>!A),children:r.jsx(ic,{"aria-hidden":"true"})}):null,r.jsx("button",{className:`icon-button ${Ne?"selected":""}`,type:"button",title:v.skills,"aria-label":v.skills,onClick:De,disabled:!z||f,children:r.jsx(fn,{"aria-hidden":"true"})}),r.jsx("button",{className:`icon-button ${me?"selected":""}`,type:"button",title:v.commands,"aria-label":v.commands,onClick:tt,disabled:!z||f,children:r.jsx(ls,{"aria-hidden":"true"})})]}),r.jsx("input",{ref:_,type:"file",multiple:!0,hidden:!0,onChange:A=>{je(A.currentTarget.files,A.currentTarget)}}),r.jsxs("div",{className:"composer-control-strip",children:[r.jsx(An,{icon:i==="autoApprove"?fn:Js,label:Qe,menuLabel:v.approvalMode,options:be,value:i,onSelect:k,wide:!0}),r.jsx(An,{icon:ws,label:We,menuLabel:v.model,options:he,value:p,onSelect:I,align:"right",wide:!0}),r.jsx(An,{icon:_t,label:Ze||v.effort,menuLabel:v.effort,options:Ee,value:m,onSelect:x,align:"right"}),r.jsx(An,{icon:fn,label:g?v.fast:v.normal,menuLabel:v.fastMode,options:[{value:"off",label:v.normal,description:v.standardExecution,icon:_t},{value:"on",label:v.fast,description:v.preferFasterResponses,icon:fn}],value:g?"on":"off",onSelect:A=>C(A==="on"),align:"right",selected:g,wide:!0})]}),r.jsx(pl,{connected:z,busy:o,sending:l,responding:u,hasDraft:!!d.trim(),shortcut:b,onStop:h,t:v})]}),s.length||f?r.jsx("div",{className:"attachment-row",children:s.length?r.jsx("div",{className:"attachment-list",children:s.map(A=>r.jsxs("span",{children:[r.jsx(Oo,{"aria-hidden":"true"}),A.name||Ht(A.path),r.jsx("small",{children:Uc(A.size)}),r.jsx("button",{type:"button",onClick:()=>L(A.path),title:v.removeAttachment,children:r.jsx(Me,{"aria-hidden":"true"})})]},A.path))}):r.jsxs("span",{className:"attachment-empty",children:[r.jsx("span",{className:"loading-spinner small","aria-hidden":"true"}),v.uploading]})}):null]})}async function ar(e){const t=se().writeClipboardText;if(t)return t(e);try{if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}}catch{}const n=document.activeElement,s=window.getSelection(),i=s?Array.from({length:s.rangeCount},(l,u)=>s.getRangeAt(u).cloneRange()):[],a=n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement?[n.selectionStart,n.selectionEnd,n.selectionDirection]:void 0,o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style.position="fixed",o.style.opacity="0",document.body.append(o);try{if(o.focus({preventScroll:!0}),o.select(),!document.execCommand("copy"))throw new Error("Clipboard copy was rejected")}finally{if(o.remove(),n instanceof HTMLElement&&n.focus({preventScroll:!0}),a&&(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&a[0]!==null&&a[1]!==null&&n.setSelectionRange(a[0],a[1],a[2]??void 0),s){s.removeAllRanges();for(const l of i)s.addRange(l)}}}function or(e,t){const[n,s]=c.useState(null),i=c.useRef(null);return c.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),{copyText:c.useCallback(async o=>{try{await ar(o),s({message:e,tone:"success"})}catch{s({message:t,tone:"error"})}i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>s(null),2400)},[t,e]),feedback:n}}function cr({feedback:e}){if(!e)return null;const t=e.tone==="success"?Lt:Me;return r.jsxs("div",{className:`copy-feedback ${e.tone}`,role:"status",children:[r.jsx(t,{"aria-hidden":"true"}),e.message]})}function Sl({message:e,retryLabel:t,onRetry:n,onDismiss:s,closeLabel:i}){return r.jsxs("div",{className:"notice error chat-error-notice",role:"alert",children:[s?r.jsx("button",{type:"button",className:"chat-notice-dismiss","aria-label":i,title:i,onClick:s,children:r.jsx(Me,{"aria-hidden":"true"})}):r.jsx(oi,{"aria-hidden":"true"}),r.jsx("span",{children:e}),r.jsxs("button",{className:"chat-notice-retry",onClick:n,type:"button",children:[r.jsx(Dn,{"aria-hidden":"true"}),t]})]})}function kl({label:e}){return r.jsxs("div",{className:"history-loading-state","aria-busy":"true","aria-label":e,role:"status",children:[r.jsx("span",{className:"loading-spinner","aria-hidden":"true"}),r.jsxs("div",{className:"history-loading-copy",children:[r.jsx("strong",{children:e}),r.jsx("span",{"aria-hidden":"true"}),r.jsx("span",{"aria-hidden":"true"}),r.jsx("span",{"aria-hidden":"true"})]})]})}function Di({failedSend:e,onRetry:t,onDismiss:n,t:s}){const i={network:s.sendFailedNetwork,timeout:s.sendFailedTimeout,permission:s.sendFailedPermission,subscription:s.sendFailedSubscription,"missing-resource":s.sendFailedMissingResource,unknown:s.sendFailedUnknown}[e.kind];return r.jsxs("div",{className:"failed-send-notice",role:"alert",children:[r.jsx(oi,{"aria-hidden":"true"}),r.jsxs("span",{children:[r.jsx("strong",{children:s.sendFailed}),i]}),r.jsxs("button",{disabled:e.retrying,onClick:t,type:"button",children:[r.jsx(Dn,{"aria-hidden":"true",className:e.retrying?"spin":void 0}),e.retrying?s.retrying:s.retrySend]}),n&&r.jsx("button",{className:"chat-notice-dismiss",onClick:n,type:"button","aria-label":s.close,title:s.close,children:r.jsx(Me,{"aria-hidden":"true"})})]})}function jl({label:e,onClick:t}){return r.jsx("button",{className:"scroll-latest-button",type:"button","aria-label":e,title:e,onClick:t,children:r.jsx(_a,{"aria-hidden":"true"})})}function Cl({activeSession:e,busy:t,errorText:n,failedSend:s,failedSendVisibleInConversation:i,onClearInterrupt:a,onDismissError:o,onDismissFailedSend:l,onRetry:u,onRetryFailedSend:h,t:d}){return r.jsxs("div",{className:"chat-notices","aria-live":"polite",children:[n?r.jsx(Sl,{message:n,retryLabel:d.retry,onRetry:u,closeLabel:d.close,onDismiss:o}):null,s&&!i?r.jsx(Di,{failedSend:s,onRetry:h,onDismiss:l,t:d}):null,e?.interruptReason?r.jsxs("div",{className:"notice warning",children:[r.jsx(fn,{"aria-hidden":"true"}),r.jsx("span",{children:e.interruptReason.humanText||e.interruptReason.kind}),r.jsx("button",{className:"icon-text-button",disabled:t,onClick:a,type:"button",children:d.clear})]}):null,e?.stallWarning?r.jsxs("div",{className:"notice warning",children:[r.jsx(Qa,{"aria-hidden":"true"}),r.jsx("span",{children:e.stallWarning.humanText||d.agentMayBeStalled}),r.jsx("button",{className:"chat-notice-dismiss",type:"button","aria-label":d.close,title:d.close,onClick:a,children:r.jsx(Me,{"aria-hidden":"true"})})]}):null]})}function _i({title:e,draft:t,label:n,disabled:s,onDraftChange:i,onCommit:a}){const[o,l]=c.useState(!1),u=c.useRef(null),h=c.useRef(null),d=c.useRef(!1),m=c.useRef(!1);c.useLayoutEffect(()=>{o?(u.current?.focus(),u.current?.select()):d.current&&(d.current=!1,h.current?.focus()),o||(m.current=!1)},[o]);const g=()=>{d.current=!0,l(!1)};return o?r.jsx("input",{ref:u,className:"inline-session-title-input","aria-label":n,value:t,onChange:p=>i(p.target.value),onBlur:()=>{m.current||(t.trim()&&t.trim()!==e&&a(),l(!1))},onKeyDown:p=>{p.nativeEvent.isComposing||p.keyCode===229||(p.key==="Enter"?(p.preventDefault(),m.current=!0,t.trim()&&t.trim()!==e&&a(),g()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),m.current=!0,g()))}}):r.jsx("button",{ref:h,type:"button",className:"inline-session-title-button",title:e,"aria-label":`${n}: ${e}`,disabled:s,onClick:()=>{i(e),l(!0)},children:e})}const Li=c.createContext(null);function Il({matchCount:e,query:t,onChange:n,onNext:s,onClose:i,t:a}){return r.jsxs("div",{className:"message-search-bar",id:"conversation-message-search",children:[r.jsx(_n,{"aria-hidden":"true"}),r.jsx("input",{autoFocus:!0,"aria-label":a.searchThisSession,value:t,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&s(),o.key==="Escape"&&(o.preventDefault(),i())},placeholder:a.searchThisSession}),r.jsx("span",{children:t.trim()?a.messageSearchMatches(e):a.allMessages}),r.jsx("button",{"aria-label":a.clearMessageSearch,title:a.clearMessageSearch,className:"icon-button mini-button",onClick:i,type:"button",children:r.jsx(Me,{"aria-hidden":"true"})})]})}function Nl({activeSession:e,agent:t,cwd:n,t:s,onOpenDetails:i,onScrollToStart:a,renameTitle:o,busy:l,onRename:u,onRenameTitleChange:h,onViewChanges:d,search:m}){const[g,p]=c.useState(!1),S=c.useRef(null),w=c.useRef(!1);c.useEffect(()=>{m.query&&p(!0)},[m.query]),c.useLayoutEffect(()=>{g||!w.current||(w.current=!1,S.current?.focus())},[g]);const b=()=>{w.current=!0,m.onChange(""),p(!1)},y=e?Et(e):s.newSession,f=e?.cwd??(n.trim().length>0&&n!=="."?n:""),v=e?.agent??t,k=c.useContext(Li),j=se().toolbarTarget?.("conversation")??k,E=r.jsxs("div",{className:"chat-header-title-row",onClick:x=>{x.target instanceof Element&&x.target.closest('button,a,input,textarea,[contenteditable="true"],.message-search-bar')||a()},children:[r.jsxs("div",{className:"chat-title-block",children:[r.jsxs("span",{className:"chat-title-line",children:[r.jsx("button",{className:`agent-status-pill chat-session-details-button ${v}`,type:"button",onClick:i,"aria-label":s.details,title:s.details,disabled:!e,children:v==="codex"?"Codex":"Claude"}),r.jsx("h1",{children:e?r.jsx(_i,{title:y,draft:o,label:s.rename,disabled:l,onDraftChange:h,onCommit:u},e.sessionId):y})]}),f?r.jsx("p",{title:f,children:f}):null,e?.branch||e?.diffStat?r.jsxs("div",{className:"header-metadata",children:[e.branch?r.jsx("span",{children:e.branch}):null,e.runtime.state?r.jsx("span",{children:s.runtimeState(e.runtime.state)}):null,e.terminal?.mode?r.jsx("span",{children:e.terminal.mode}):null]}):null]}),r.jsx("button",{"aria-label":s.scrollToConversationStart,className:"chat-scroll-start-target",onClick:a,title:s.scrollToConversationStart,type:"button"}),e&&!g?r.jsxs("button",{className:"chat-changes-button",type:"button","aria-label":s.viewChanges,title:s.viewChanges,onClick:()=>d(e.sessionId),children:[r.jsx(os,{"aria-hidden":"true"}),e.diffStat&&(e.diffStat.additions>0||e.diffStat.deletions>0)?r.jsxs("span",{className:"chat-changes-summary","aria-hidden":"true",children:[r.jsxs("span",{className:"diff-add",children:["+",e.diffStat.additions]}),r.jsxs("span",{className:"diff-del",children:["−",e.diffStat.deletions]})]}):null]}):null,g?r.jsx(Il,{...m,t:s,onClose:b}):r.jsx("button",{ref:S,className:"icon-button chat-search-toggle",type:"button","aria-label":s.searchThisSession,title:s.searchThisSession,"aria-expanded":!1,"aria-controls":"conversation-message-search",onClick:()=>p(!0),children:r.jsx(_n,{"aria-hidden":"true"})})]});return r.jsx("header",{className:`chat-header chat-search-header ${j?"chat-header-in-titlebar":""}`,children:j?it.createPortal(E,j):E})}const El=/\u001B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,Rl=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u00AD\u061C\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFEFF]/g,Al=new Set(["","{}","[]","null","undefined",'""']);function Un(e){return e.replace(/\s+/g," ").trim()}function Te(e,t){return typeof e[t]=="string"?e[t]:""}function Rr(e,t){return typeof e[t]=="number"?e[t]:void 0}function Nn(e,t){return e.length<=t?e:`${e.slice(0,t)}...`}function js(e){const t=[],n=Te(e,"file_path")||Te(e,"filePath");n&&t.push({label:"Path",value:n,isFilePath:!0});const s=Rr(e,"offset"),i=Rr(e,"limit");if(s!==void 0||i!==void 0){const a=[];s!==void 0&&a.push(`line ${s+1}`),i!==void 0&&a.push(`to ${s!==void 0?s+i:i}`),t.push({label:"Range",value:a.join(" ")})}return t}function Tl(e){return typeof e!="string"?"":e.replace(/\r\n?/g,`
6
+ `).replace(El,"").replace(Rl,"").trim()}function lr(e){const t=Tl(e);return Al.has(t)?"":t}function Ml(e){return lr(e).length>0}function dr(e){const t=lr(e);if(!t)return"";try{const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const s=typeof n.query=="string"?Un(n.query):"";if(s)return s;const i=typeof n.command=="string"?Un(n.command):"";if(i)return i;const a=typeof n.description=="string"?Un(n.description):"";if(a)return a}}catch{}return Un(t)}function Pl(e,t){if(!t)return[];switch((e??"").toLowerCase()){case"read":return js(t);case"write":{const s=js(t),i=Te(t,"content");return i&&s.push({label:"Content",isDiff:!0,value:"",diffNew:Nn(i,500)}),s}case"edit":{const s=js(t),i=Te(t,"old_string")||Te(t,"oldString"),a=Te(t,"new_string")||Te(t,"newString");return(i||a)&&s.push({label:"Change",isDiff:!0,value:"",diffOld:Nn(i,300),diffNew:Nn(a,300)}),s}case"bash":{const s=Te(t,"command");return s?[{label:"Command",value:s,isCode:!0}]:[]}case"websearch":{const s=Te(t,"query");return s?[{label:"Query",value:s}]:[]}case"webfetch":{const s=[],i=Te(t,"url");i&&s.push({label:"URL",value:i});const a=Te(t,"prompt");return a&&s.push({label:"Prompt",value:Nn(a,200)}),s}case"glob":{const s=Te(t,"pattern");return s?[{label:"Pattern",value:s}]:[]}case"grep":{const s=[],i=Te(t,"pattern");i&&s.push({label:"Pattern",value:i,isCode:!0});const a=Te(t,"path");return a&&s.push({label:"In",value:a,isFilePath:!0}),s}default:{const s=[],i=Te(t,"command");if(i)return[{label:"Command",value:i,isCode:!0}];const a=Te(t,"file_path")||Te(t,"filePath");a&&s.push({label:"Path",value:a,isFilePath:!0});const o=Te(t,"description");o&&s.push({label:"Description",value:Nn(o,200)});const l=Te(t,"query");l&&s.push({label:"Query",value:l});const u=Te(t,"url");return u&&s.push({label:"URL",value:u}),s}}}function Ar(e){return e.role==="tool"?!0:e.type!=="info"?!1:!/^Error:/i.test(e.content.trim())}function $i(e){const t=[];for(const s of e){const i=s.toolName?.trim();i&&!t.includes(i)&&t.push(i)}return t.length?t.join(", "):e.map(s=>dr(s.content)).find(Boolean)??""}function Fi(e,t){return`${e.historyKey??e.timestamp??e.toolName??e.content.slice(0,24)??"message"}:${t}`}function Dl(e){const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];if(!Ar(s)){t.push({type:"message",index:n,message:s});continue}const i=[];let a=n;for(;a<e.length&&Ar(e[a]);)i.push({index:a,message:e[a]}),a+=1;t.push({type:"toolGroup",entries:i,id:`tool-group:${i.map(({index:o,message:l})=>Fi(l,o)).join("|")}`}),n=a-1}return t}function _l(e,t){return e.type==="message"?e.index===t:e.entries.some(n=>n.index===t)}function Ll(e,t){const n=t.trim().toLowerCase();return n?e.map((s,i)=>({index:i,message:s})).filter(({message:s})=>s.content.toLowerCase().includes(n)):[]}function $l(e){const t=e.at(-1);return t?`${e.length}:${t.historyKey??""}:${t.timestamp??""}:${t.content.length}`:"0"}function Fl(e,t,n,s,i,a,o,l=0){const u=()=>{const h=t.current||s.current;n.current=null,s.current=!1,t.current=!1,i.current=performance.now();const d=e.current;a.current=d?.scrollTop??0,h&&d?.scrollTo({top:d.scrollTop,behavior:"auto"})};return{toStart:()=>{const h=e.current;h&&(n.current=null,s.current=!1,t.current=!1,i.current=performance.now(),a.current=0,h.scrollTo({top:h.scrollTop,behavior:"auto"}),l>0&&o?.(),requestAnimationFrame(()=>requestAnimationFrame(()=>e.current?.scrollTo({top:0,behavior:l>0?"auto":"smooth"}))))},onWheel:h=>{if(!h.deltaY)return;const d=e.current;(h.deltaY<0||d&&d.scrollHeight-d.scrollTop-d.clientHeight>2)&&u()},onPointerDown:h=>{const d=h.currentTarget.getBoundingClientRect();(h.button===1||h.clientX>=d.right-16)&&u()},onTouchStart:u,onKeyDown:h=>{h.target instanceof Element&&h.target.closest('input,textarea,[contenteditable="true"]')||["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(h.key)&&u()}}}function Ol(e,t,n){const s=i=>i?.some(a=>a.localClientMessageId===n||a.historyKey===`client:${n}`);return s(e[t])?t:Object.entries(e).find(([,i])=>s(i))?.[0]??t}function ql(e,t,n,s){const i=e.findIndex(o=>o.localClientMessageId===t||o.historyKey===`client:${t}`),a=e.slice();if(i<0)s&&a.push({role:"user",...s,timestamp:new Date().toISOString(),historyKey:`client:${t}`,localClientMessageId:t,localDelivery:n});else{const o=e[i],l=o.delivery==="accepted"||o.historyKey&&!o.historyKey.startsWith("client:");a[i]={...o,localClientMessageId:t,localDelivery:l&&n==="failed"?"delivered":n}}return a}function Wl(e,t){const n=e.delivery==="accepted"?"delivered":e.localDelivery;if(e.role!=="user"||!n)return null;const s=t.browser==="浏览器"?{sending:"发送中",delivered:"已送达",failed:"未确认送达",hint:"配对电脑已接收,可能仍在等待处理。"}:t.browser==="瀏覽器"?{sending:"傳送中",delivered:"已送達",failed:"未確認送達",hint:"配對電腦已接收,可能仍在等待處理。"}:{sending:"Sending",delivered:"Delivered",failed:"Delivery unconfirmed",hint:"Received by the paired computer; processing may still be pending."};return{state:n,label:s[n],title:n==="delivered"?s.hint:s[n]}}const Hl={en:{rewind:"Rewind to here",confirmRewind:"Continue in a new branch before this message? The original conversation will be archived and preserved. The selected message will become a draft; no message will be sent.",incompleteHistory:"This conversation has older history that is not loaded. Rewinding is unavailable to avoid selecting the wrong turn.",unavailable:"This message is no longer available.",rewindFailed:"Unable to rewind this conversation.",invalidResponse:"Invalid rewind response.",mediaError:"This format cannot be played here. Download the file to open it.",remoteSettings:"Sessions and remote devices",htmlPreview:"HTML preview",pdfPreview:"PDF preview",audioPreview:"Audio preview",videoPreview:"Video preview"},zh:{rewind:"回退到这里",confirmRewind:"从这条消息之前建立新分支继续?原会话会归档保留,所选消息会填入草稿,不会自动发送。",incompleteHistory:"此会话还有未加载的历史,暂时不能回退,以免选错消息位置。",unavailable:"这条消息已不可用。",rewindFailed:"无法回退此会话。",invalidResponse:"回退响应无效。",mediaError:"此格式无法在这里播放,请下载后打开。",remoteSettings:"会话与远程设备",htmlPreview:"HTML 预览",pdfPreview:"PDF 预览",audioPreview:"音频预览",videoPreview:"视频预览"},"zh-TW":{rewind:"回退到這裡",confirmRewind:"從這則訊息之前建立新分支繼續?原對話會封存保留,所選訊息會填入草稿,不會自動傳送。",incompleteHistory:"此對話還有未載入的歷史,暫時不能回退,以免選錯訊息位置。",unavailable:"這則訊息已無法使用。",rewindFailed:"無法回退此對話。",invalidResponse:"回退回應無效。",mediaError:"此格式無法在這裡播放,請下載後開啟。",remoteSettings:"對話與遠端裝置",htmlPreview:"HTML 預覽",pdfPreview:"PDF 預覽",audioPreview:"音訊預覽",videoPreview:"影片預覽"}};function $n(){return Hl[Je(Xe().language)]}const Ls="vibelet:image-gallery";function Bl(e){window.dispatchEvent(new CustomEvent(Ls,{detail:e}))}const zl="(?:png|jpg|jpeg|gif|webp|svg|heic|heif)",Kl="(?:~/|/|\\.{1,2}/|[A-Za-z0-9._-]+/)",Gl="[^\\n`<>\"')\\]},。!?;:、]*?",Ul="(?::\\d+(?::\\d+)?|#[^\\s`<>\"')\\]},。!?;:、]+)?",Vl=`${Kl}${Gl}\\.${zl}${Ul}`,Tr=new RegExp(`(${Vl})`,"gi"),Ql=[".png",".jpg",".jpeg",".gif",".webp",".svg",".heic",".heif"],$s="\\s`<>\"')\\]},。!?;:、",Mr="`<>\"')\\]},。!?;:、\\n\\r\\t",Zl=new RegExp(`(^|[\\s([{>])((?:~\\/|\\/|\\.{1,2}\\/)[^${$s}]+|[A-Za-z0-9._-]+(?:\\/[A-Za-z0-9._-]+)+(?:\\.[A-Za-z0-9._-]+)?\\/?)`,"g"),Yl=new RegExp(`(^|[\\s([{>])((?=[^${Mr}]*\\/)[^${Mr}]+?\\.[A-Za-z0-9._-]+(?::\\d+(?::\\d+)?|#[^${$s}]+)?)(?=$|[${$s}])`,"g");function Fs(e){let t=e;for(;/[.,!?;:,。!?;:、]+$/.test(t);)t=t.slice(0,-1);return t}function Os(e,t){return!e||/^[a-z]+:\/\//i.test(e)||e.startsWith("streamdown:")?!1:e==="~"||e.startsWith("~/")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("\\\\")||e.includes("/")||e.includes("\\")?!0:!!t?.allowBareFilename&&/^[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+$/.test(e)}function us(e){let t=Fs(e.trim());if(!t)return"";const n=t.indexOf("#");if(n>0){const i=t.slice(0,n);Os(i,{allowBareFilename:!0})&&(t=i)}const s=t.match(/^(.*?)(:\d+(?::\d+)?)$/);if(s){const i=s[1]??"";Os(i,{allowBareFilename:!0})&&(t=i)}return Fs(t)}function Jl(e,t){return e.start<t.end&&t.start<e.end}function qs(e){if(e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../"))return!0;const t=e.indexOf("/");if(t<=0)return!1;const n=e.slice(0,t).trim();return/^\d+\s+\S/.test(n)?!0:/\s/.test(n)?!1:/[^\p{ASCII}]/u.test(n)}function Xl(e){if(qs(e.rawCandidate))return e;const t=e.rawCandidate.indexOf("/");if(t<=0)return e;const n=e.rawCandidate.slice(0,t);for(let s=n.indexOf(" ");s>=0;s=n.indexOf(" ",s+1)){const i=s+1,a=e.rawCandidate.slice(i);if(qs(a))return{start:e.start+i,end:e.end,rawCandidate:a}}return e}function ed(e){const t=[];for(const n of e.matchAll(Zl)){const s=n[1]??"",i=n[2]??"",o=(n.index??0)+s.length;t.push({start:o,end:o+i.length,rawCandidate:i})}for(const n of e.matchAll(Yl)){const s=n[1]??"",i=n[2]??"",o=(n.index??0)+s.length,l=Xl({start:o,end:o+i.length,rawCandidate:i}),u=t.filter(h=>Jl(h,l));if(u.length===0){t.push(l);continue}if(qs(l.rawCandidate)){for(const h of u){const d=t.indexOf(h);d>=0&&t.splice(d,1)}t.push(l)}}return t.sort((n,s)=>n.start-s.start||n.end-s.end)}function ur(e,t){const n=us(e);return Os(n,t)}function hr(e){const t=us(e).toLowerCase();return ur(t,{allowBareFilename:!0})&&Ql.some(n=>t.endsWith(n))}function td(e){if(!e)return[];const t=[];let n=0;for(const s of ed(e)){s.start>n&&t.push({type:"text",value:e.slice(n,s.start)});const i=Fs(s.rawCandidate),a=us(i),o=s.rawCandidate.slice(i.length);ur(i)&&!hr(i)?(t.push({type:"path",value:i,target:a||i}),o&&t.push({type:"text",value:o})):t.push({type:"text",value:s.rawCandidate}),n=s.end}return n<e.length&&t.push({type:"text",value:e.slice(n)}),t.length>0?t:[{type:"text",value:e}]}const nd=/^[a-z][a-z0-9+.-]*:/i,sd=/^[a-z]:[\\/]/i,Oi=/\.(?:md|markdown)$/i,qi="https://vibelet.local",Wi="/__vibelet_markdown__",rd=`${qi}${Wi}`;function id(e){try{return decodeURIComponent(e)}catch{return e}}function Hi(e){const t=e?.trim()??"";if(!t||t.startsWith("#")||t.startsWith("//"))return null;const n=ad(t);if(n)return n;if(nd.test(t)&&!sd.test(t))return null;const s=t.split(/[?#]/,1)[0]??"";return Oi.test(s)?id(s):null}function lm(e){const t=e.split(`
7
+ `);let n=null;return t.map(s=>{const i=s.match(/^ {0,3}(`{3,}|~{3,})/);if(i){const a=i[1][0];return n===a?n=null:n||(n=a),s}return n?s:od(s)}).join(`
8
+ `)}function ad(e){let t;try{t=new URL(e)}catch{return null}if(t.origin!==qi||t.pathname!==Wi)return null;const n=t.searchParams.get("path");return!n||!Oi.test(n)?null:n}function od(e){let t="",n=0;for(;n<e.length;){if(e[n]==="`"){const s=cd(e,n);t+=e.slice(n,s),n=s;continue}if(e[n]==="["&&e[n-1]!=="!"){const s=ld(e,n);if(s){t+=s.text,n=s.end;continue}}t+=e[n],n+=1}return t}function cd(e,t){let n=0;for(;e[t+n]==="`";)n+=1;const s="`".repeat(n),i=e.indexOf(s,t+n);return i<0?e.length:i+n}function ld(e,t){const n=dd(e,t);if(n<0||e[n+1]!=="(")return null;const s=n+2,i=ud(e,s);if(i<0)return null;const a=e.slice(s,i),o=hd(a);return o?{text:`${e.slice(t,s)}${o})`,end:i+1}:null}function dd(e,t){let n=!1;for(let s=t+1;s<e.length;s+=1){const i=e[s];if(n){n=!1;continue}if(i==="\\"){n=!0;continue}if(i==="]")return s}return-1}function ud(e,t){let n=!1;for(let s=t;s<e.length;s+=1){const i=e[s];if(n){n=!1;continue}if(i==="\\"){n=!0;continue}if(i===")")return s}return-1}function hd(e){const t=e.match(/^\s*/)?.[0]??"",n=e.match(/\s*$/)?.[0]??"",s=e.slice(t.length,e.length-n.length);if(s.startsWith("<")){const o=s.indexOf(">");if(o<0)return null;const l=s.slice(1,o),u=Pr(l);return u?`${t}<${u}>${s.slice(o+1)}${n}`:null}const i=s.match(/^(\S+)([\s\S]*)$/);if(!i)return null;const a=Pr(i[1]);return a?`${t}${a}${i[2]}${n}`:null}function Pr(e){const t=Hi(e);return t?`${rd}?path=${encodeURIComponent(t)}`:null}const Bi="https://vibelet.local/__vibelet_file__";function Fn(e){if(!e)return null;const t=Hi(e);if(t)return t;let n=e.trim();if(n.startsWith(Bi))try{const s=new URL(n);if(s.origin!=="https://vibelet.local"||s.pathname!=="/__vibelet_file__")return null;n=s.searchParams.get("path")??""}catch{return null}else if(/^file:\/\//i.test(n))try{const s=new URL(n);if(s.hostname&&s.hostname!=="localhost")return null;n=s.pathname}catch{return null}else if(/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/i.test(n)&&!/^[a-z]:[\\/]/i.test(n))return null;try{n=decodeURIComponent(n.split("?")[0])}catch{}return n=us(n),ur(n,{allowBareFilename:!0})?n:null}const Ws=e=>`${Bi}?path=${encodeURIComponent(e)}`;function zi(e){return e.value??e.children?.map(zi).join("")??""}function fd(e){const t=[],n=new RegExp(`(?:file://(?:localhost)?(?=/))?${Tr.source}`,Tr.flags);let s=0;const i=a=>{for(const o of td(a))t.push(o.type==="path"?{type:"link",url:Ws(o.target??o.value),children:[{type:"text",value:o.value}]}:{type:"text",value:o.value})};for(const a of e.matchAll(n)){const o=Fn(a[0]);!o||!hr(o)||(i(e.slice(s,a.index)),t.push({type:"image",url:Ws(o),alt:o.split(/[\\/]/).at(-1)}),s=a.index+a[0].length)}return i(e.slice(s)),t}function dm(){return e=>{const t=n=>{if(n.type==="link"||n.type==="image"){const s=Fn(n.url);s&&(n.url=Ws(s),hr(s)&&(n.alt=n.alt||zi(n)||s.split(/[\\/]/).at(-1),n.type="image",delete n.children));return}!n.children||["code","inlineCode","html"].includes(n.type)||(n.children=n.children.flatMap(s=>s.type==="text"?fd(s.value??""):(t(s),[s])))};t(e)}}const Ki="pair",rn="vibelet.web.pairing",Dr="vibelet.web.deviceId";class On extends Error{constructor(t,n){super(n),this.code=t,this.name="PairingCreateError"}}function fr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function md(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return decodeURIComponent(Array.from(atob(n),s=>`%${s.charCodeAt(0).toString(16).padStart(2,"0")}`).join(""))}function pd(e){const[t,n,s,i,a,o]=e;return!n||!Number.isFinite(s)||s<=0?null:{kind:t==="relay"?"relay":"direct",host:n,port:Math.floor(s),source:i,stability:a,...o===!0?{secure:!0}:{}}}function gd(e){if(!fr(e))return null;const{kind:t,host:n,port:s,source:i,stability:a,secure:o}=e;return t!=="direct"&&t!=="relay"||typeof n!="string"||!n.trim()||typeof s!="number"||!Number.isFinite(s)||s<=0||typeof i!="string"||typeof a!="string"?null:{kind:t,host:n.trim(),port:Math.floor(s),source:i,stability:a,...o===!0?{secure:!0}:{}}}function yd(e){const t=e.trim().split(".");if(t.length!==4)return!1;const n=t.map(a=>/^\d+$/.test(a)?Number(a):Number.NaN);if(n.some(a=>!Number.isInteger(a)||a<0||a>255))return!1;const[s,i]=n;return s===10||s===172&&i>=16&&i<=31||s===192&&i===168}function Gi(e){const t=e.trim().replace(/^\[(.*)\]$/,"$1").replace(/\.$/,"").toLowerCase();if(t==="localhost"||t.endsWith(".localhost")||t==="::1"||t==="0:0:0:0:0:0:0:1")return!0;const n=t.split(".");if(n.length!==4||n.some(i=>!/^\d+$/.test(i)))return!1;const s=n.map(Number);return s.every(i=>i>=0&&i<=255)&&s[0]===127}function bd(e){const t=e.trim();return t.includes(":")&&!t.startsWith("[")?`[${t}]`:t}function vd(e,t){return t.protocol==="https:"&&e.secure!==!0?null:`${e.secure===!0?"wss":"ws"}://${bd(e.host)}:${e.port}`}function _r(e){return yd(e.host)?0:e.source==="local_network"?1:e.source==="configured_host"?2:3}function xd(e,t){const n=t?.port??e.port,s=t?.canonicalHost??e.canonicalHost;if(!s||typeof n!="number"||!Number.isFinite(n))return[];const i=Math.floor(n);return[{kind:"direct",host:s,port:i,source:"fallback",stability:"stable"},...[...t?.fallbackHosts??[],...e.fallbackHosts??[]].map(a=>({kind:"direct",host:a,port:i,source:"fallback",stability:"stable"}))]}function wd(e,t,n=window.location,s=!0){if(s&&Gi(n.hostname))return;const i=[...t?.connections??[],...e.connections??[],...xd(e,t)].map(gd).filter(a=>!!a).filter(a=>a.kind==="direct").sort((a,o)=>_r(a)-_r(o));for(const a of i){const o=vd(a,n);if(o)return o}}function Sd(e){if(!e.d||!e.c)return null;const t=Array.isArray(e.o)?e.o.map(pd).filter(n=>!!n):void 0;return{daemonId:e.d,pairNonce:e.c,...e.n?{displayName:e.n}:{},...e.h?{canonicalHost:e.h}:{},...Number.isFinite(e.p)?{port:e.p}:{},...Array.isArray(e.f)?{fallbackHosts:e.f.filter(n=>typeof n=="string")}:{},...t?.length?{connections:t}:{},...e.e?{expiresAt:e.e}:{}}}function kd(e){return!e.daemonId||!e.pairNonce?null:{daemonId:e.daemonId,displayName:e.displayName,canonicalHost:e.canonicalHost,fallbackHosts:e.fallbackHosts,port:e.port,connections:e.connections,pairNonce:e.pairNonce,expiresAt:e.expiresAt}}function jd(e=window.location.hash){const t=e.startsWith("#")?e.slice(1):e,n=new URLSearchParams(t).get(Ki);if(!n)return null;try{const s=JSON.parse(md(n));if(!fr(s))return null;if(s.t==="vp")return Sd(s);if(s.type==="vibelet-pair")return kd(s)}catch{return null}return null}function Cd(){if(!window.location.hash.includes(`${Ki}=`))return;const e=`${window.location.pathname}${window.location.search}`;window.history.replaceState(null,"",e)}function Id(e=Ge()){const t=e.getItem(Dr);if(t)return t;const n=typeof crypto.randomUUID=="function"?crypto.randomUUID():`web_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;return e.setItem(Dr,n),n}function Lr(e){const t=e.getItem(rn);if(!t)return null;try{const n=JSON.parse(t);return!n.daemonId||!n.deviceId||!n.pairToken?null:{daemonId:n.daemonId,displayName:n.displayName,deviceId:n.deviceId,pairToken:n.pairToken,pairedAt:n.pairedAt??new Date().toISOString(),webSocketUrl:typeof n.webSocketUrl=="string"?n.webSocketUrl:void 0}}catch{return null}}function mr(e){if(typeof window>"u")return null;try{return e===Ge()?window.sessionStorage:null}catch{return null}}function pr(e=Ge(),t=mr(e)){const n=Lr(e);if(n)return n;const s=t?Lr(t):null;return s?(e.setItem(rn,JSON.stringify(s)),t?.removeItem(rn),s):null}function $r(e,t=Ge(),n=mr(t)){t.setItem(rn,JSON.stringify(e)),n?.removeItem(rn)}function Ui(e=Ge(),t=mr(e)){e.removeItem(rn),t?.removeItem(rn)}function Nd(e,t=Date.now()){if(!e.expiresAt)return!1;const n=new Date(e.expiresAt).getTime();return Number.isFinite(n)&&n<t}async function Ed(e){const t=await e.text().catch(()=>"");try{const n=JSON.parse(t);if(fr(n)&&n.error==="pair_window_expired")return new On("pair_window_expired","Pairing link expired.")}catch{}return new On("pairing_failed",t||"Pairing failed.")}async function Rd(e,t=Id()){if(Nd(e))throw new On("pair_window_expired","Pairing link expired.");const n=await fetch("/pair/create",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({daemonId:e.daemonId,pairNonce:e.pairNonce,deviceId:t,deviceName:"Vibelet Web"})});if(!n.ok)throw await Ed(n);const s=await n.json();return{daemonId:s.daemonId,displayName:s.displayName||e.displayName,deviceId:s.deviceId,pairToken:s.pairToken,pairedAt:new Date().toISOString(),webSocketUrl:wd(e,s,window.location,!0)}}async function Ad(e,t){try{return await Rd(e,t?.deviceId)}catch(n){if(n instanceof On&&n.code==="pair_window_expired"&&t?.daemonId===e.daemonId)return t;throw n}}const Fr=20*1024*1024;class Td{constructor(t=128,n=64*1024*1024,s=3e4){this.maxEntries=t,this.maxBytes=n,this.ttl=s}scope="";bytes=0;entries=new Map;get(t,n,s){this.scope!==t&&(this.entries.clear(),this.bytes=0,this.scope=t);for(const[o,l]of this.entries)l.expires<=Date.now()&&this.remove(o,l);const i=this.entries.get(n);if(i)return this.entries.delete(n),this.entries.set(n,i),i.promise;const a={promise:Promise.resolve(new Blob),bytes:0,expires:1/0};return a.promise=Promise.resolve().then(s).then(o=>(this.entries.get(n)===a&&(a.bytes=o.size,a.expires=Date.now()+this.ttl,this.bytes+=o.size,this.trim()),o),o=>{throw this.remove(n,a),o}),this.entries.set(n,a),this.trim(),a.promise}remove(t,n){this.entries.get(t)===n&&(this.entries.delete(t),this.bytes-=n.bytes)}trim(){for(;this.entries.size>this.maxEntries||this.bytes>this.maxBytes;){const t=this.entries.entries().next().value;if(!t)return;this.remove(...t)}}}const Md=new Td;function Pd(e,t){return Md.get(t,e,async()=>{const n=await fetch(e,{headers:{authorization:`Bearer ${t}`}});if(!n.ok||Number(n.headers.get("content-length"))>Fr)throw new Error("Image unavailable");const s=await n.blob();if(!s.type.startsWith("image/")||s.size>Fr)throw new Error("Unsupported image");return s})}function Dd(e,t,n=1600){const s=Fn(e),i=pr(),[a,o]=c.useState(null),[l,u]=c.useState(null);return c.useEffect(()=>{if(!s)return;const m=new AbortController;let g;return o(null),u(null),(async()=>{try{if(!i)throw new Error("No pairing");const S=new URL(Zn(s,t));n!==null&&S.searchParams.set("w",String(n));const w=await Pd(S.toString(),i.pairToken);if(m.signal.aborted)return;g=URL.createObjectURL(w),o({src:e,url:g})}catch{m.signal.aborted||u(e)}})(),()=>{m.abort(),g&&URL.revokeObjectURL(g)}},[e,s,t,n,i?.pairToken,i?.webSocketUrl]),{url:s?a?.src===e?a.url:void 0:e,error:l===e,fail:()=>u(e)}}function _d({src:e,alt:t,cwd:n,onOpen:s,gallery:i}){const a=Fn(e),{url:o,error:l,fail:u}=Dd(e,n),h=Rs[Je(Xe().language)],d=t||Ht(a??e);return r.jsx("button",{className:"message-image-preview",type:"button",title:a??e,"aria-label":`${h.preview}: ${d}`,onClick:async m=>{m.preventDefault(),m.stopPropagation();const g=await i?.()??[{src:e,alt:d,cwd:n}],p=g.findIndex(S=>S.src===e||a&&Fn(S.src)===a);Bl({images:p<0?[{src:e,alt:d,cwd:n}]:g,index:Math.max(0,p),onOpen:s})},children:l?r.jsxs("span",{className:"message-image-placeholder",children:[r.jsx(wo,{"aria-hidden":"true"}),d," · ",h.fileOpenFailed]}):o?r.jsx("img",{src:o,alt:d,loading:"lazy",onError:u}):r.jsxs("span",{className:"message-image-placeholder",children:[r.jsx(cs,{className:"session-running-icon","aria-hidden":"true"}),d]})})}function Ld({message:e,t}){return r.jsx("pre",{className:"message-markdown-source",role:"region","aria-label":t.markdownSource,children:e.content})}function $d({field:e}){return e.isDiff?r.jsxs("div",{className:"tool-field diff",children:[r.jsx("span",{children:e.label}),e.diffOld?r.jsxs("pre",{className:"tool-diff old",children:[r.jsx("b",{children:"-"}),e.diffOld]}):null,e.diffNew?r.jsxs("pre",{className:"tool-diff new",children:[r.jsx("b",{children:"+"}),e.diffNew]}):null]}):r.jsxs("div",{className:`tool-field ${e.isCode?"code":""} ${e.isFilePath?"path":""}`,children:[r.jsx("span",{children:e.label}),r.jsx("pre",{children:e.value})]})}function Fd({message:e,onCopy:t,t:n}){const s=Pl(e.toolName,e.toolInput),i=dr(e.content),a=lr(e.content),o=Ml(e.content)&&!s.length,l=e.toolName??n.tool;return r.jsxs("section",{className:"tool-detail-card",children:[r.jsxs("header",{children:[r.jsx("span",{className:"tool-detail-icon",children:r.jsx(Xs,{"aria-hidden":"true"})}),r.jsxs("div",{children:[r.jsx("strong",{children:l}),i?r.jsx("small",{title:i,children:i}):null]}),r.jsx("button",{className:"icon-button",onClick:()=>t(e.content),type:"button",title:n.copyOutput,children:r.jsx(yn,{"aria-hidden":"true"})})]}),s.length?r.jsx("div",{className:"tool-fields",children:s.map((u,h)=>r.jsx($d,{field:u},`${u.label}:${h}`))}):null,o?r.jsx("pre",{className:"json-box compact",children:a}):null]})}function Vi({messages:e,showHeader:t=!0,onClose:n,onCopy:s,t:i}){if(!e.length)return null;const o=e.filter(d=>d.role==="tool").length||e.length,l=i.toolCallCount(o),u=$i(e),h=e.map(d=>d.content).join(`
9
+
10
+ `);return r.jsxs("section",{className:"tool-inline-panel","aria-label":i.toolDetails,children:[t?r.jsxs("header",{className:"inline-detail-header",children:[r.jsxs("div",{className:"inline-detail-title",children:[r.jsx("strong",{children:l}),r.jsx("span",{title:u,children:u||i.toolDetail})]}),r.jsxs("div",{className:"row-actions",children:[r.jsx("button",{className:"icon-button",onClick:()=>s(h),type:"button",title:i.copyOutput,children:r.jsx(yn,{"aria-hidden":"true"})}),r.jsx("button",{className:"icon-button",onClick:n,type:"button",title:i.closeToolDetails,children:r.jsx(Me,{"aria-hidden":"true"})})]})]}):null,r.jsx("div",{className:"tool-detail-list",children:e.map((d,m)=>r.jsx(Fd,{message:d,onCopy:s,t:i},`${d.historyKey??d.timestamp??d.toolName??"tool"}:${m}`))})]})}const Od=c.lazy(async()=>gt(()=>import("./mermaid-O7DHMXV3-H7_sz6Xo.js").then(e=>e.b),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.MessageMarkdown})));function Qi({label:e}){return r.jsxs("span",{className:"message-replying-indicator","aria-label":e,role:"status",children:[r.jsxs("span",{"aria-hidden":"true",className:"message-replying-dots",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),r.jsx("span",{children:e})]})}function qd({activeMatch:e,baseCwd:t,message:n,onCopy:s,onRewind:i,onCloseTool:a,onOpenRemoteFile:o,onToggleSource:l,onToggleTool:u,sourceOpen:h,toolOpen:d,replying:m,t:g}){const p=Wl(n,g),S=n.role==="tool"?dr(n.content):"";return r.jsxs("article",{className:`message ${n.role} ${n.type==="info"?"info":""} ${e?"match":""}`,children:[r.jsxs("div",{className:"message-meta",children:[r.jsx("span",{children:Ri(n,g)}),r.jsxs("div",{className:"message-meta-side",children:[p&&r.jsx("span",{className:"message-delivery","data-state":p.state,role:"status",title:p.title,children:p.label}),r.jsx("time",{children:ds(n.timestamp,Date.now(),g)})]})]}),h?r.jsx(Ld,{message:n,t:g}):n.role==="tool"?r.jsxs("button",{className:"tool-inline-summary","aria-expanded":d,onClick:u,type:"button",children:[r.jsxs("span",{children:[r.jsx(mc,{"aria-hidden":"true"}),n.toolName??g.tool]}),S?r.jsx("small",{children:S}):null]}):n.role==="assistant"||n.role==="user"?r.jsx(c.Suspense,{fallback:r.jsx("pre",{children:n.content}),children:r.jsx(Od,{baseCwd:t,content:n.images?.length?n.content.replace(/(?:^|\n)\[Attached image: [^\n]+\](?=\n|$)/g,"").trim():n.content,onOpenRemoteFile:o,additionalImages:n.images})}):r.jsx("pre",{children:n.content}),n.images?.length?r.jsx("div",{className:"message-image-attachments",children:n.images.map(w=>r.jsx(_d,{src:w,cwd:t,onOpen:o,gallery:async()=>[...(await gt(async()=>{const{collectMessageImages:b}=await import("./collectMessageImages-F_MsAk3D.js").then(y=>y.q);return{collectMessageImages:b}},[])).collectMessageImages(n.content,t),...(n.images??[]).map(b=>({src:b,cwd:t}))]},w))}):null,n.role==="tool"&&d?r.jsx(Vi,{messages:[n],onClose:a,onCopy:s,t:g}):null,m&&r.jsx(Qi,{label:g.replyingMessage}),r.jsxs("div",{className:"message-actions","aria-label":g.messageActions,role:"group",children:[i&&n.role==="user"&&n.type!=="info"&&r.jsx("button",{type:"button",onClick:i,title:$n().rewind,"aria-label":$n().rewind,children:r.jsx(fi,{"aria-hidden":"true"})}),r.jsx("button",{"aria-label":g.copyMessage,onClick:()=>s(n.content),title:g.copyMessage,type:"button",children:r.jsx(yn,{"aria-hidden":"true"})}),r.jsx("button",{"aria-label":g.viewMarkdownSource,"aria-expanded":h,onClick:l,title:h?g.hideMarkdownSource:g.viewMarkdownSource,type:"button",children:r.jsx(Ya,{"aria-hidden":"true"})})]})]})}function Wd({activeMatch:e,expanded:t,messages:n,onToggle:s}){const i=n.filter(l=>l.role==="tool").length||n.length,a=$i(n),o=i===1?"1 tool call":`${i} tool calls`;return r.jsx("button",{className:`tool-group-bubble ${e?"match":""} ${t?"expanded":""}`,type:"button",onClick:s,"aria-expanded":t,"aria-label":a?`${o}: ${a}`:o,children:r.jsxs("span",{className:"tool-group-header",children:[r.jsxs("span",{className:"tool-group-title",children:[r.jsx(ii,{className:"tool-group-chevron","aria-hidden":"true"}),r.jsx("strong",{children:o})]}),a?r.jsx("span",{className:"tool-group-summary",children:a}):null]})})}function Hd(e,t,n){const s=c.useRef(n);s.current=n;const i=c.useRef(!1),[a,o]=c.useState(0);c.useLayoutEffect(()=>{i.current=!1;const l=d=>{d.type==="focusin"&&d.target instanceof Element&&d.target.contains(e.current)||(i.current=d.target instanceof Element&&!!e.current?.contains(d.target)&&!d.target.closest("input,textarea,select")&&!d.target.isContentEditable)},h=[["pointerdown",l],["focusin",l],["keydown",d=>{!i.current||d.isComposing||(d.metaKey||d.ctrlKey)&&!d.altKey&&!d.shiftKey&&d.key.toLowerCase()==="a"&&(d.preventDefault(),s.current(),o(m=>m+1))}]];return h.forEach(([d,m])=>document.addEventListener(d,m,!0)),()=>h.forEach(([d,m])=>document.removeEventListener(d,m,!0))},[e,t]),c.useLayoutEffect(()=>{if(!i.current)return;const l=e.current?.querySelectorAll(".message-frame"),u=l?.[l.length-1];u&&window.getSelection()?.setBaseAndExtent(l[0],0,u,u.childNodes.length)},[a,e,t])}const Jn=160,Bd=120,En=-1;function Xt(e){return Math.max(0,e-Jn)}function zd(e,t){const n=t.length,[s,i]=c.useState(()=>({sessionId:e,start:Xt(n),total:n})),a=s.sessionId!==e?Xt(n):s.start===En?En:n>s.total&&s.start+Jn>=s.total?Xt(n):Math.min(s.start,Xt(n));c.useLayoutEffect(()=>{s.sessionId===e&&s.start===a&&s.total===n||i({sessionId:e,start:a,total:n})},[e,a,s,n]);const o=c.useCallback(()=>{i(p=>({sessionId:e,start:Math.max(0,(p.sessionId===e?p.start:Xt(n))-Bd),total:n}))},[e,n]),l=c.useCallback(p=>{const S=t.findIndex(b=>_l(b,p));if(a===En||S<0||S>=a&&S<a+Jn)return!1;const w=Math.min(Xt(n),Math.max(0,S-40));return i({sessionId:e,start:w,total:n}),!0},[t,e,a,n]),u=c.useCallback(()=>{i({sessionId:e,start:Xt(n),total:n})},[e,n]),h=c.useCallback(()=>{i({sessionId:e,start:0,total:n})},[e,n]),d=()=>i({sessionId:e,start:En,total:n}),m=Math.max(0,a),g=a===En?n:Math.min(n,a+Jn);return{ensureMessageVisible:l,hiddenItemCount:m,hiddenLaterItemCount:Math.max(0,n-g),revealEarlier:o,revealLatest:u,revealStart:h,revealAll:d,visibleItems:t.slice(m,g)}}const Or=()=>null,Kd=()=>()=>{};function Gd(e,t,n,s){const i=c.useSyncExternalStore(e.submission?.subscribe??Kd,e.submission?.getSnapshot??Or,Or),a=c.useRef(!1),o=async l=>{if(!a.current){a.current=!0;try{await l()}finally{a.current=!1}}};return{sending:!!i&&i.sessionId===s,submit:l=>{if(l?.preventDefault(),!!n)return o(()=>e())},retry:()=>o(t)}}function Ud({activeSession:e,activeUsage:t,messages:n,renameTitle:s,busy:i,t:a,onBrowseFiles:o,onClose:l,onExport:u,onJumpToMessage:h,onRename:d,onRenameTitleChange:m,onToggleArchived:g,onTogglePinned:p,onViewChanges:S}){const[w,b]=c.useState(""),{copyText:y,feedback:f}=or(a.commandCopied,a.copyResumeFailed),v=c.useRef(null),k=rs(l,v),j=c.useMemo(()=>Ii(e),[e]),E=c.useMemo(()=>{const x=w.trim().toLowerCase();return x?n.map((C,I)=>({message:C,index:I})).filter(({message:C})=>C.role!=="user"&&C.role!=="assistant"?!1:C.content.toLowerCase().includes(x)).slice(0,20):[]},[n,w]);return r.jsxs("div",{"aria-labelledby":"session-detail-title","aria-modal":"true",className:"session-detail-drawer",ref:k,role:"dialog",tabIndex:-1,children:[r.jsx("div",{className:"drawer-backdrop",onClick:l,"aria-hidden":"true"}),r.jsxs("aside",{className:"session-detail-panel",children:[r.jsxs("header",{className:"drawer-header",children:[r.jsxs("div",{children:[r.jsx("span",{className:"eyebrow",children:e.agent}),r.jsx("strong",{id:"session-detail-title",title:Et(e),children:r.jsx(_i,{title:Et(e),draft:s,label:a.rename,disabled:i,onDraftChange:m,onCommit:d},e.sessionId)})]}),r.jsx("button",{"aria-label":a.closeSessionDetails,title:a.closeSessionDetails,className:"icon-button",onClick:l,ref:v,type:"button",children:r.jsx(Me,{"aria-hidden":"true"})})]}),r.jsxs("div",{className:"detail-info-grid",children:[r.jsxs("div",{children:[r.jsx(Xn,{"aria-hidden":"true"}),r.jsx("span",{children:a.workingDirectory}),r.jsx("strong",{title:e.cwd,children:e.cwd})]}),r.jsxs("div",{children:[r.jsx(di,{"aria-hidden":"true"}),r.jsx("span",{children:a.messages}),r.jsx("strong",{children:n.filter(x=>x.role==="user"||x.role==="assistant").length})]}),r.jsxs("div",{children:[r.jsx(vo,{"aria-hidden":"true"}),r.jsx("span",{children:a.session}),r.jsx("strong",{title:e.sessionId,children:e.sessionId})]}),r.jsxs("div",{children:[r.jsx(Xs,{"aria-hidden":"true"}),r.jsx("span",{children:a.runtime}),r.jsx("strong",{children:a.runtimeState(e.runtime.state)})]})]}),e.branch||e.diffStat?r.jsxs("button",{className:"detail-command-card detail-changes-card",type:"button",onClick:S,children:[r.jsx(os,{"aria-hidden":"true"}),r.jsx("span",{className:"detail-change-label",children:e.branch??a.changes}),r.jsx("span",{className:"detail-change-stats",role:"group","aria-label":a.changes,children:e.diffStat?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"diff-add",children:["+",e.diffStat.additions]}),r.jsxs("span",{className:"diff-del",children:["-",e.diffStat.deletions]})]}):null})]}):null,r.jsxs("label",{className:"detail-search",children:[r.jsx(_n,{"aria-hidden":"true"}),r.jsx("input",{value:w,onChange:x=>b(x.target.value),placeholder:a.searchMessages}),w.trim()?r.jsx("small",{children:a.searchResultCount(E.length)}):null]}),w.trim()&&E.length?r.jsx("div",{className:"detail-search-results",children:E.map(({message:x,index:C})=>r.jsxs("button",{type:"button",onClick:()=>{h(C,w),l()},children:[r.jsx("span",{children:Ri(x,a)}),r.jsx("strong",{children:x.content})]},`${x.historyKey??x.timestamp??C}:${C}`))}):null,w.trim()?null:r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:"detail-command-card",type:"button",onClick:o,children:[r.jsx(Xn,{"aria-hidden":"true"}),r.jsx("span",{children:a.browseFiles})]}),r.jsxs("button",{className:"detail-command-card",type:"button",onClick:()=>{y(j)},children:[r.jsx(Ua,{"aria-hidden":"true"}),r.jsx("span",{title:j,children:j})]}),r.jsx(cr,{feedback:f}),r.jsxs("div",{className:"detail-action-grid",children:[r.jsxs("button",{className:"icon-text-button",disabled:i,type:"button",onClick:p,children:[r.jsx(qn,{"aria-hidden":"true"}),e.pinned?a.unpin:a.pin]}),r.jsxs("button",{className:"icon-text-button",disabled:i,type:"button",onClick:g,children:[r.jsx(as,{"aria-hidden":"true"}),e.archived?a.unarchive:a.archive]}),r.jsxs("button",{className:"icon-text-button",type:"button",onClick:u,children:[r.jsx(is,{"aria-hidden":"true"}),a.exportSession]})]}),t?r.jsxs("p",{className:"detail-usage",children:[a.usage,": ",t.limits?.fiveHour?.usedPercent??"-","% 5h ·"," ",t.limits?.weekly?.usedPercent??"-","% weekly"]}):null,r.jsxs("p",{className:"detail-usage",children:[a.created," ",ds(e.createdAt,Date.now(),a)]})]})]})]})}function Vd({activeSession:e,activeSessionId:t,activeModelOptions:n,activeQueue:s,queueControls:i,activeUsage:a,agent:o,approvalMode:l,attachments:u,busy:h,cwd:d,draft:m,effort:g,errorText:p,failedSend:S,onDismissFailedSend:w,fastMode:b,historyLoading:y,messages:f,messagesSessionId:v,model:k,phase:j,quickReplies:E,renameTitle:x,respondingSessionIds:C,sendShortcut:I,skills:N,uploadBusy:L,detailsOpen:P,t:R,onApprovalModeChange:_,onBrowseFiles:V,onCancelQueuedTurn:Z,onClearInterrupt:ue,onDraftChange:ye,onDetailsOpenChange:D,onEffortChange:Q,onExportActiveSession:G,onRewindMessage:re,onFastModeChange:ae,onRetryFailedSend:T,onModelChange:$,onOpenRemoteFile:B,onInterrupt:Y,onRetry:W,onDismissError:J,onRefreshSkills:z,onRenameSession:ne,onRenameTitleChange:X,onRemoveAttachment:qe,onSubmit:me,onToggleArchived:Ue,onTogglePinned:Se,onUploadFiles:Ie,onViewChanges:Ne}){const ke=Gd(me,T,j==="connected"&&!h&&!!m.trim(),t),[be,Ee]=c.useState(""),[Ve,We]=c.useState(0),[Qe,Ze]=c.useState(null),[he,je]=c.useState(null),[et,Pe]=c.useState(!1),oe=c.useRef(null),Ce=c.useRef([]),tt=c.useRef(null),xe=c.useRef(null),De=c.useRef(!1),Re=c.useRef(!1),ce=c.useRef(!0),te=c.useRef(0),A=c.useRef(0),Ae=c.useMemo(()=>Dl(f),[f]),pe=!!(t&&C.has(t)),nt=pe&&v===t&&!y,ut=nt&&f.at(-1)?.role==="assistant"&&f.at(-1)?.type!=="info"?f.length-1:-1,{ensureMessageVisible:at,hiddenItemCount:ge,hiddenLaterItemCount:le,revealAll:ee,revealEarlier:we,revealLatest:Ye,revealStart:st,visibleItems:yt}=zd(t,Ae),Bt=c.useMemo(()=>!!(S&&yt.some(O=>O.type==="message"&&O.message.historyKey===S.historyKey)),[S,yt]),bt=c.useRef(null),{copyText:Rt,feedback:$t}=or(R.messageCopied,R.copyFailed),He=c.useMemo(()=>Ll(f,be),[be,f]),St=O=>{ce.current=!1,te.current=0;const U=at(O),de=()=>Ce.current[O]?.scrollIntoView({behavior:"smooth",block:"center"});U?requestAnimationFrame(()=>requestAnimationFrame(de)):de()},At=()=>{if(!He.length)return;const O=Ve%He.length,U=He[O]?.index;typeof U=="number"&&St(U),We(de=>(de+1)%He.length)},ot=c.useCallback(()=>{const O=oe.current;O&&(ce.current=!0,te.current=0,O.scrollTop=O.scrollHeight,Pe(!1))},[]),ct=c.useCallback(O=>{ce.current=!0,te.current=0,Re.current=!0,De.current=!1,bt.current=null;const U=oe.current,de=U?U.scrollHeight-U.scrollTop-U.clientHeight:0,_e=O??(le===0&&U&&de<=U.clientHeight?"smooth":"auto"),ft=()=>{const Le=oe.current;!Le||!Re.current||(Le.scrollTo({top:Le.scrollHeight,behavior:_e}),Pe(!1),requestAnimationFrame(()=>{Re.current=!1}))};le>0?(Ye(),requestAnimationFrame(()=>requestAnimationFrame(ft))):ft()},[le,Ye]),lt=()=>{const O=oe.current;if(!O)return;const U=O.querySelector(".message-frame");bt.current={element:U,top:U?U.getBoundingClientRect().top-O.getBoundingClientRect().top:O.scrollTop,height:O.scrollHeight}},kt=()=>{const O=oe.current;if(!O)return;O.scrollTop<160&&ge>0&&!De.current&&!Re.current&&(De.current=!0,lt(),we());const U=O.scrollTop>A.current;A.current=O.scrollTop;const de=O.scrollHeight-O.scrollTop-O.clientHeight;te.current>0&&!Re.current&&!De.current&&(ce.current=U&&de<=2&&le===0),Pe(de>180||le>0)};c.useLayoutEffect(()=>{le>0&&Pe(!0)},[le]);const Tt=Fl(oe,ce,xe,Re,te,A,st,ge),Mt=$l(f);c.useLayoutEffect(()=>{const O=bt.current,U=oe.current;if(O&&U){if(O.element?.isConnected){const Le=O.element.getBoundingClientRect().top-U.getBoundingClientRect().top;U.scrollTop+=Le-O.top}else U.scrollTop+=U.scrollHeight-O.height;bt.current=null,De.current=!1;return}if(tt.current!==t&&(tt.current=t,xe.current=t,Ze(null),je(null)),!oe.current)return;const _e=v===t;if(t!==null&&xe.current===t&&_e&&(!y||f.length>0)){ot();let Le=0,mt=-1,ve=0;const jt=performance.now(),Be=()=>{if(xe.current!==t)return;ot();const $e=oe.current?.scrollHeight??0;ve=$e===mt?ve+1:0,mt=$e;const vt=performance.now()-jt>=1400;if(!y&&ve>=4||!y&&vt){xe.current=null;return}vt||(Le=requestAnimationFrame(Be))};return Le=requestAnimationFrame(Be),Pe(!1),()=>cancelAnimationFrame(Le)}ce.current&&le===0&&ot()},[t,ge,le,y,Mt,f.length,v,j,nt,ot]),c.useLayoutEffect(()=>{const O=oe.current;if(!O)return;const U=new ResizeObserver(()=>{ce.current&&le===0&&ot()});U.observe(O);for(const de of O.children)U.observe(de);return()=>U.disconnect()},[t,Mt,ge,le,nt,ot]);const ht=He.length&&be.trim()?He[(Ve+He.length-1)%He.length]?.index:void 0;return Hd(oe,t,()=>{lt(),ee()}),r.jsxs("section",{className:"chat-pane","aria-label":R.chat,children:[r.jsx(Nl,{activeSession:e,agent:o,cwd:d,t:R,onOpenDetails:()=>e&&D(!0),onScrollToStart:Tt.toStart,renameTitle:x,busy:h,onRename:ne,onRenameTitleChange:X,onViewChanges:Ne,search:{query:be,matchCount:He.length,onChange:O=>{Ee(O),We(0)},onNext:At}}),r.jsx(Cl,{activeSession:e,busy:h,errorText:p,failedSend:S,failedSendVisibleInConversation:Bt,onClearInterrupt:ue,onDismissError:J,onDismissFailedSend:w,onRetry:W,onRetryFailedSend:()=>{ke.retry()},t:R}),r.jsxs("div",{className:"message-scroll","aria-busy":y,"data-history-loading":y?"true":"false","data-rendered-items":yt.length,"data-hidden-items":ge,"data-hidden-later-items":le,"data-total-messages":f.length,ref:oe,onScroll:kt,...Tt,children:[y&&f.length===0?r.jsx(kl,{label:R.loadingHistory}):null,!y&&f.length===0&&!nt?r.jsxs("div",{className:"empty-state compact",children:[r.jsx(Js,{"aria-hidden":"true"}),r.jsx("h2",{children:e?R.noVisibleMessages:R.startDaemonSession}),r.jsx("p",{children:R.emptyChatHint})]}):null,ge>0?r.jsx("div",{className:"conversation-window-gate",children:r.jsx("button",{type:"button",onClick:()=>{De.current=!0,lt(),we()},children:R.showEarlierMessages(ge)})}):null,yt.map(O=>{if(O.type==="toolGroup"){const ve=O.entries.map($e=>$e.message),jt=O.entries.some($e=>ht===$e.index),Be=he===O.id;return r.jsx("div",{className:"message-frame tool info",ref:$e=>{for(const vt of O.entries)Ce.current[vt.index]=$e},children:r.jsxs("div",{className:"inline-message-stack",children:[r.jsx(Wd,{activeMatch:jt,expanded:Be,messages:ve,onToggle:()=>je($e=>$e===O.id?null:O.id)}),Be?r.jsx(Vi,{messages:ve,showHeader:!1,onClose:()=>je(null),onCopy:Rt,t:R}):null]})},O.id)}const{index:U,message:de}=O,_e=Fi(de,U),ft=Qe===_e,Le=he===_e,mt=S?.historyKey===de.historyKey?S:null;return r.jsxs("div",{className:`message-frame ${de.role} ${de.type==="info"?"info":""}`,ref:ve=>{Ce.current[U]=ve},children:[r.jsx(qd,{activeMatch:ht===U,baseCwd:e?.cwd,message:de,replying:le===0&&U===ut,onCopy:Rt,onRewind:h||C.has(t??"")?void 0:()=>re(de),onCloseTool:()=>je(null),onOpenRemoteFile:B,onToggleSource:()=>Ze(ve=>ve===_e?null:_e),onToggleTool:()=>je(ve=>ve===_e?null:_e),sourceOpen:ft,toolOpen:Le,t:R}),mt?r.jsx(Di,{failedSend:mt,onRetry:()=>{ke.retry()},onDismiss:w,t:R}):null]},_e)}),nt&&le===0&&ut<0?r.jsx("div",{className:"message-frame assistant","data-replying-placeholder":"true",children:r.jsx("div",{className:"message assistant replying-placeholder",children:r.jsx(Qi,{label:R.replyingMessage})})}):null,le>0?r.jsx("div",{className:"conversation-window-gate",children:r.jsx("button",{type:"button",onClick:()=>ct("auto"),children:R.showLatestMessages(le)})}):null,r.jsx("div",{"aria-hidden":"true",className:"message-latest-anchor"})]}),et?r.jsx(jl,{label:R.newMessages,onClick:()=>ct()}):null,r.jsx(cr,{feedback:$t}),r.jsx(wl,{activeModelOptions:n,activeQueue:s,queueControls:{...i,onAction:(O,U)=>(ct("auto"),i.onAction(O,U))},agent:o,approvalMode:l,attachments:u,busy:h,sending:ke.sending,responding:pe,onStop:Y,draft:m,effort:g,fastMode:b,model:k,phase:j,quickReplies:E,sendShortcut:I,skills:N,uploadBusy:L,onApprovalModeChange:_,onCancelQueuedTurn:Z,onDraftChange:ye,onEffortChange:Q,onFastModeChange:ae,onModelChange:$,onRemoveAttachment:qe,onRefreshSkills:z,onSubmit:O=>(ct("auto"),ke.submit(O)),onUploadFiles:Ie,t:R},t),P&&e?r.jsx(Ud,{activeSession:e,activeUsage:a,busy:h,messages:f,renameTitle:x,t:R,onBrowseFiles:()=>{D(!1),V()},onClose:()=>D(!1),onExport:G,onJumpToMessage:(O,U)=>{Ee(U),We(0),St(O)},onRename:ne,onRenameTitleChange:X,onToggleArchived:Ue,onTogglePinned:Se,onViewChanges:()=>{D(!1),Ne(e.sessionId)}}):null]})}const Qd="https://service.lifeos.vip/feedback",Zi=8e3,Zd=6e4,qr=4,Yd=20*1024*1024,Yi=["accountActivationCode","account-activation-code","activationCode","activation-code","apiKey","api_key","api-key","x-api-key","accessKey","access-key","accessKeyId","access-key-id","password","secret","secretAccessKey","secret-access-key","token","access-token","refresh-token","security-token","cookie","set-cookie","authorization","proxy-authorization","x-amz-credential","x-amz-security-token","x-amz-signature"],Ji=["authorization","proxy-authorization"],Xi=["cookie","set-cookie"],Jd=[...Ji,...Xi],hs=(e,t)=>t.length-e.length,ea=[...Yi].sort(hs).join("|"),Xd=Yi.filter(e=>!Jd.includes(e)).sort(hs).join("|"),eu=[...Ji].sort(hs).join("|"),tu=[...Xi].sort(hs).join("|"),nu=new RegExp(`(?:${ea}|credential|private[-_ ]?key|session[-_ ]?id|e-?mail|phone|mobile|address)`,"i"),su=new RegExp(`(["']?(?:${eu})["']?\\s*[:=]\\s*)("[^"\\r\\n]*"|'[^'\\r\\n]*'|(?:Basic|Bearer)\\s+[^\\s,;}]+|AWS4-HMAC-SHA256[^\\r\\n]*(?=\\r?$)|[^\\s,;}]+)`,"gim"),ru=new RegExp(`(["']?(?:${tu})["']?\\s*[:=]\\s*)("[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\r\\n]+)`,"gi"),iu=new RegExp(`(["']?(?:${Xd})["']?\\s*[:=]\\s*)("[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s,;}&]+)`,"gi"),au=new RegExp(`([?&](?:${ea})=)[^&\\s]+`,"gi");function ou(e,t="[REDACTED]"){const n=(s,i,a)=>{const o=a[0]==='"'||a[0]==="'"?a[0]:"";if(!o)return`${i}${t}`;const l=a.slice(1,-1).trim(),u=/^(Basic|Bearer)\b/i.exec(l)?.[1];return`${i}${o}${u?`${u} `:""}${t}${o}`};return e.replace(/-----BEGIN(?: [A-Z0-9]+)? PRIVATE KEY-----[\s\S]*?-----END(?: [A-Z0-9]+)? PRIVATE KEY-----/gi,t).replace(su,n).replace(ru,n).replace(iu,n).replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,`Bearer ${t}`).replace(/\bBasic\s+[A-Za-z0-9+/=_-]+/gi,`Basic ${t}`).replace(/\bsk(?:-proj)?-[A-Za-z0-9_-]{8,}/g,t).replace(/\bgh[pousr]_[A-Za-z0-9]{16,}\b/gi,t).replace(/\bgithub_pat_[A-Za-z0-9_]{16,}\b/gi,t).replace(/\bglpat-[A-Za-z0-9_-]{16,}\b/gi,t).replace(/\bxox[baprs]-[A-Za-z0-9-]{16,}\b/gi,t).replace(/\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{12,}\b/gi,t).replace(/\bAIza[0-9A-Za-z_-]{20,}\b/g,t).replace(/\bAKIA[0-9A-Z]{16}\b/g,t).replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,t).replace(/(https?:\/\/)[^/\s:@]+:[^@\s/]+@/gi,`$1${t}@`).replace(au,`$1${t}`)}function cu(e){return e.replace(/(^|[\s("'=])(?:file:\/\/)?\/(?:Users|home|Volumes|private|var|tmp|storage\/emulated\/\d+|data\/user\/\d+|sdcard)[^\r\n"'<>]*?\.[A-Za-z0-9]{1,12}\b/gim,"$1[LOCAL_PATH]").replace(/(^|[\s("'=])(?:file:\/\/)?\/(?:Users|home|Volumes|private|var|tmp|storage\/emulated\/\d+|data\/user\/\d+|sdcard)(?:\/[^\s"'<>]*)?/gim,"$1[LOCAL_PATH]").replace(/\b[A-Z]:\\(?:Users\\)?[^\r\n"'<>]*?\.[A-Za-z0-9]{1,12}\b/gi,"[LOCAL_PATH]").replace(/\b[A-Z]:\\(?:Users\\)?[^\s"'<>]+/gi,"[LOCAL_PATH]").replace(/\\\\[^\s\\"'<>]+\\[^\r\n"'<>]+/g,"[LOCAL_PATH]").replace(/\bcontent:\/\/[^\s"'<>]+/gi,"[LOCAL_PATH]").replace(/\b(?:[\w.-]+\/)+(?:[\w.-]+\.(?:md|txt|json|ya?ml|pdf|docx?|xlsx?|csv|log|db|sqlite|png|jpe?g|webp|gif))\b/gi,"[RELATIVE_PATH]")}function gn(e){return cu(ou(e)).replace(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,"[EMAIL]").replace(new RegExp("(?<![\\w])(?:\\+?\\d[\\d\\s().-]{7,}\\d)(?![\\w])","g"),"[PHONE]")}function lu(e,t={}){if(!e)return{};const n=Math.max(0,t.characterBudget??6e4),s=Math.max(0,t.maxArrayEntries??50),i=Math.max(0,t.maxDepth??8),a=Math.max(0,t.maxObjectEntries??80),o=Math.max(0,t.maxStringLength??4e3),l={remaining:n},u=new WeakSet,h=(d,m)=>{if(l.remaining<=0)return"[TRUNCATED]";if(d===null||typeof d=="boolean"||typeof d=="number")return d;if(typeof d=="bigint")return d.toString();if(typeof d=="string"){const S=gn(d).slice(0,Math.min(o,l.remaining));return l.remaining-=S.length,S}if(m>=i)return"[MAX_DEPTH]";if(typeof d!="object")return gn(String(d)).slice(0,Math.min(200,l.remaining));if(u.has(d))return"[Circular]";if(u.add(d),Array.isArray(d))return d.slice(0,s).map(p=>h(p,m+1));const g={};for(const[p,S]of Object.entries(d).slice(0,a)){if(l.remaining<=0)break;const w=gn(p).slice(0,Math.min(120,l.remaining));l.remaining-=w.length,g[w]=nu.test(p)?"[REDACTED]":h(S,m+1)}return g};return h(e,0)}function du(e,t=Zd){const n=gn(e);return n.length<=t?n:`[truncated ${n.length-t} chars]
11
+ ${n.slice(-t)}`}function uu(e){return gn(e.trim()).slice(0,Zi)}function hu(e){try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}async function fu(e){const t=await fetch(e.url,{method:e.method,headers:e.headers,body:e.body,signal:e.signal});return{status:t.status,statusText:t.statusText,body:await t.text()}}async function mu(e,t={}){const n=new AbortController,s=Number.isFinite(t.timeoutMs)&&(t.timeoutMs??0)>0?t.timeoutMs:15e3;let i;try{const a=(t.transport??fu)({url:t.endpoint??Qd,method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:n.signal}),o=new Promise((h,d)=>{i=setTimeout(()=>{n.abort(),d(new Error("Feedback request timed out"))},s)}),l=await Promise.race([a,o]),u=hu(l.body);if(l.status<200||l.status>=300||u.code!==0)throw new Error(u.message||l.statusText||"Feedback request failed");if(typeof u.data?.id!="string"||!u.data.id||typeof u.data.createdAt!="string")throw new Error("Feedback response is invalid");return{id:u.data.id,createdAt:u.data.createdAt,issueFingerprint:typeof u.data?.issueFingerprint=="string"?u.data.issueFingerprint:void 0,issueOccurrence:typeof u.data?.issueOccurrence=="number"?u.data.issueOccurrence:void 0}}finally{i&&clearTimeout(i)}}const pu=["action","app","automatic","browser","buildNumber","contextSchemaVersion","correlationId","debugEnabled","deviceFingerprint","diagnosticSchemaVersion","entry","errorCode","errorMessage","module","pagePath","pageTitle","pageUrl","pluginId","privacy","providerPreset","reportKind","resultKind","runtime","screen","storageType","updateChannel","userAgent"],gu=new Set(pu);function yu(e){const t={contextSchemaVersion:1};if(e)for(const[n,s]of Object.entries(e))gu.has(n)&&s!==void 0&&(t[n]=s);return lu(t)}const bu={title:"Feedback",subtitle:"Report a problem or suggest an improvement.",bug:"Problem",feature:"Suggestion",description:"Description",descriptionPlaceholder:"What happened, or what would you like to improve?",email:"Email (optional)",emailPlaceholder:"For a reply from the team",includeDiagnostics:"Include privacy-safe diagnostics",privacyNotice:"Only include diagnostics when needed. Recognized credentials, personal identifiers, and local paths are removed before sending.",submit:"Send feedback",sending:"Sending…",success:"Thank you. Your feedback has been sent.",error:"Could not send feedback. Please try again.",close:"Close"},vu={title:"意见反馈",subtitle:"报告问题,或告诉我们希望改进的地方。",bug:"问题",feature:"建议",description:"详细说明",descriptionPlaceholder:"发生了什么,或者你希望我们怎样改进?",email:"邮箱(选填)",emailPlaceholder:"便于我们回复你",includeDiagnostics:"附带经过隐私处理的诊断信息",privacyNotice:"仅在需要时附带诊断信息;发送前会移除已识别的凭据、个人标识和本地路径。",submit:"发送反馈",sending:"正在发送…",success:"感谢反馈,已经发送成功。",error:"发送失败,请稍后重试。",close:"关闭"},xu={title:"意見回饋",subtitle:"回報問題,或告訴我們希望改善的地方。",bug:"問題",feature:"建議",description:"詳細說明",descriptionPlaceholder:"發生了什麼,或你希望我們如何改善?",email:"電子郵件(選填)",emailPlaceholder:"方便我們回覆你",includeDiagnostics:"附上經過隱私處理的診斷資訊",privacyNotice:"僅在需要時附上診斷資訊;傳送前會移除已識別的憑證、個人識別資訊和本機路徑。",submit:"傳送回饋",sending:"正在傳送…",success:"感謝回饋,已成功傳送。",error:"傳送失敗,請稍後再試。",close:"關閉"};function ta(e){const t=e?.trim().toLowerCase().replace(/_/g,"-")??"";return/^zh(?:-(?:tw|hk|mo|hant))(?:-|$)/u.test(t)?xu:t.startsWith("zh")?vu:bu}const wu=new Set(["image/jpeg","image/png","image/webp","image/gif"]);function Su(e){if(!e||e.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/u.test(e))return;const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return e.length/4*3-t}function ku(e){if(!e?.length)return;if(e.length>qr)throw new Error(`Feedback supports at most ${qr} images`);const t=e.map(s=>{if(!wu.has(s.mimeType))throw new Error("Feedback image type is not supported");const i=Su(s.base64);if(!Number.isSafeInteger(s.size)||s.size<=0||i!==s.size)throw new Error("Feedback image size does not match its data");return{name:gn(s.name.trim()||"image").slice(0,255),mimeType:s.mimeType,size:s.size,base64:s.base64}});if(t.reduce((s,i)=>s+i.size,0)>Yd)throw new Error("Feedback images are too large");return t}function ju(e){const t=uu(e.description);if(!t)throw new Error("Feedback description is required");const n=e.includeLogs===!1||!e.logs?"":du(e.logs),s=e.email?.trim().slice(0,320);return{product:e.product,source:e.source,type:e.type,description:t,email:s||void 0,appVersion:e.appVersion?.trim().slice(0,64)||"unknown",locale:e.locale?.trim().slice(0,64)||"unknown",platform:e.platform?.trim().slice(0,128)||"unknown",logsIncluded:!!n,logs:n||void 0,metadata:yu(e.metadata),images:ku(e.images)}}function Cu({language:e,entry:t="web-settings"}){const n=Je(e),s=c.useMemo(()=>ta(n),[n]),[i,a]=c.useState("bug"),[o,l]=c.useState(""),[u,h]=c.useState(""),[d,m]=c.useState("idle"),g=async()=>{if(!(!o.trim()||d==="sending")){m("sending");try{await mu(ju({product:"vibelet",source:se().kind==="desktop"?"desktop":"web",type:i,description:o,email:u,appVersion:se().appVersion||"web",locale:n,platform:navigator.platform||"web",metadata:{app:se().kind==="desktop"?"vibelet-desktop":"vibelet-web",entry:t,screen:t==="connection-guide"?"connection-guide":"settings/language",module:"feedback",action:"manual-submit",userAgent:navigator.userAgent}})),l(""),m("success")}catch{m("error")}}};return r.jsxs("section",{className:"control-section compact-section",children:[r.jsx("h2",{children:s.title}),r.jsx("p",{className:"empty-copy",children:s.subtitle}),r.jsxs("div",{className:"feedback-type-grid",children:[r.jsx("button",{className:i==="bug"?"primary-button":"",type:"button","aria-pressed":i==="bug",onClick:()=>a("bug"),children:s.bug}),r.jsx("button",{className:i==="feature"?"primary-button":"",type:"button","aria-pressed":i==="feature",onClick:()=>a("feature"),children:s.feature})]}),r.jsxs("label",{className:"field",children:[r.jsx("span",{children:s.description}),r.jsx("textarea",{rows:5,maxLength:Zi,value:o,placeholder:s.descriptionPlaceholder,onChange:p=>l(p.target.value)})]}),r.jsxs("label",{className:"field",children:[r.jsx("span",{children:s.email}),r.jsx("input",{type:"email",maxLength:320,value:u,placeholder:s.emailPlaceholder,onChange:p=>h(p.target.value)})]}),r.jsx("button",{className:"primary-button",type:"button",disabled:!o.trim()||d==="sending",onClick:()=>{g()},children:d==="sending"?s.sending:s.submit}),d==="success"?r.jsx("p",{className:"empty-copy success-copy",children:s.success}):null,d==="error"?r.jsx("p",{className:"empty-copy error-copy",children:s.error}):null]})}const Wr="vibelet --access=quick";function Iu({errorText:e,t}){const[n,s]=c.useState("idle"),[i,a]=c.useState(!1),o=Xe().language,l=ta(o),u=async()=>{try{await ar(Wr),s("success")}catch{s("error")}window.setTimeout(()=>s("idle"),1800)};return r.jsx("main",{className:"connection-guide",id:"vibelet-main-content",tabIndex:-1,children:r.jsxs("section",{className:"connection-guide-content","aria-labelledby":"connection-guide-title",children:[r.jsx("span",{className:"connection-guide-mark","aria-hidden":"true",children:r.jsx(ls,{})}),r.jsx("span",{className:"connection-guide-eyebrow",children:"Vibelet Web"}),r.jsx("h1",{id:"connection-guide-title",children:t.openDaemonWebLink}),r.jsx("p",{children:t.openDaemonWebLinkHint}),r.jsxs("div",{className:"connection-command",children:[r.jsx("code",{children:Wr}),r.jsxs("button",{className:"primary-button",onClick:()=>{u()},type:"button",children:[n==="success"?r.jsx(Lt,{"aria-hidden":"true"}):r.jsx(yn,{"aria-hidden":"true"}),r.jsx("span",{children:n==="success"?t.commandCopied:n==="error"?t.copyFailed:t.copyStartCommand})]})]}),r.jsx("p",{className:"connection-guide-footnote",children:t.connectionGuideFootnote}),e?r.jsx("p",{className:"connection-guide-error",children:e}):null,r.jsxs("button",{className:"connection-feedback-toggle",type:"button","aria-expanded":i,onClick:()=>a(h=>!h),children:[r.jsx(di,{"aria-hidden":"true"}),l.title]}),i?r.jsx("div",{className:"connection-feedback-panel",children:r.jsx(Cu,{language:o,entry:"connection-guide"})}):null]})})}const Nu=c.lazy(()=>gt(()=>import("./ImageViewer-BAycGfGo.js"),__vite__mapDeps([5,1,2,6,7])));function Eu(){const[e,t]=c.useState(null);return c.useEffect(()=>{const n=s=>t(s.detail);return window.addEventListener(Ls,n),()=>window.removeEventListener(Ls,n)},[]),e?r.jsx(c.Suspense,{fallback:null,children:r.jsx(Nu,{request:e,onClose:()=>t(null)},e.images[e.index].src)}):null}function Ru(){const e=c.useRef(null),t=c.useRef({browser:0,terminal:0}),[n,s]=c.useState(0),[i,a]=c.useState([]),[o,l]=c.useState(null),[u,h]=c.useState({}),[d,m]=c.useState({}),g=c.useCallback((f,v,k,j,E,x)=>{const C=crypto.randomUUID(),I=f==="diff"?"center":"right";return f!=="diff"&&(v=`${v} ${++t.current[f]}`),a(N=>[...N,{id:C,kind:f,title:v,cwd:k,session:j,scope:E,path:x,location:I}]),I==="center"?l(C):h(N=>({...N,[f]:C})),C},[]),p=c.useCallback((f,v)=>{const k=i.find(j=>j.id===f);k&&(a(j=>j.map(E=>E.id===f?{...E,location:v}:E)),v==="center"?(l(f),h(j=>({...j,[k.kind]:i.find(E=>E.id!==f&&E.kind===k.kind&&E.location==="right")?.id}))):(h(j=>({...j,[k.kind]:f})),e.current?.(k.kind),o===f&&l(null)))},[i,o]),S=c.useCallback(f=>{const v=i.find(k=>k.id===f);a(k=>k.filter(j=>j.id!==f)),o===f&&l(null),v&&u[v.kind]===f&&h(k=>({...k,[v.kind]:i.find(j=>j.id!==f&&j.kind===v.kind&&j.location==="right")?.id}))},[i,o,u]),w=c.useCallback((f,v)=>a(k=>k.map(j=>j.id===f&&j.title!==v?{...j,title:v}:j)),[]),b=c.useCallback((f,v)=>m(k=>{if(k[f]===v||!k[f]&&!v)return k;const j={...k};return v?j[f]=v:delete j[f],j}),[]),y=c.useCallback(()=>{a([]),l(null),h({}),s(f=>f+1)},[]);return c.useMemo(()=>({openRight:e,epoch:n,items:i,center:o,right:u,hosts:d,add:g,move:p,close:S,rename:w,register:b,reset:y,setCenter:l,setRight:h}),[n,i,o,u,d,g,p,S,w,b,y])}const gr=c.createContext(null);function Au({children:e}){const t=Ru();return r.jsx(gr.Provider,{value:t,children:e})}function ln(){const e=c.useContext(gr);if(!e)throw new Error("Dock workspace provider missing");return e}function na(){return c.useContext(gr)}const ts="application/x-vibelet-workspace-tab",Tu={browser:ci,terminal:ls,diff:os};function fs(e){return e.browser==="浏览器"?{center:"移到中间区域",right:"移到右侧栏",create:"新建标签页",drop:"拖到这里以移动标签页"}:e.browser==="瀏覽器"?{center:"移到中間區域",right:"移到右側欄",create:"新增標籤頁",drop:"拖到這裡以移動標籤頁"}:{center:"Move to workspace",right:"Move to sidebar",create:"New tab",drop:"Drop here to move tab"}}function Hs({location:e,kind:t,t:n,cwd:s}){const i=ln(),a=fs(n),o=c.useRef(null),l=i.items.filter(u=>u.location===e&&(!t||u.kind===t));return c.useEffect(()=>{e==="right"&&t&&!i.items.some(u=>u.kind===t)&&i.add(t,n[t==="browser"?"browser":"terminal"],s)},[e,t,i.epoch]),c.useEffect(()=>{if(e!=="right"||!o.current)return;const u=o.current.querySelector('.dock-tab[data-active="true"]');u&&(o.current.scrollLeft=Math.max(0,u.offsetLeft-o.current.offsetLeft))},[e,t,i.right,l.map(u=>u.title).join("|")]),e==="right"&&t&&l.length===1?null:r.jsxs("div",{className:"dock-tabs",role:e==="right"?"tablist":"group","aria-label":t?n[t==="browser"?"browser":"terminal"]:void 0,children:[e==="right"&&t&&i.right[t]&&r.jsx("button",{type:"button",className:"dock-move dock-move-first","aria-label":a.center,title:a.center,onClick:()=>i.move(i.right[t],"center"),children:r.jsx(Qs,{})}),r.jsx("div",{className:"dock-tab-items",ref:o,children:l.map(u=>{const h=e==="center"?i.center===u.id:i.right[u.kind]===u.id,d=Tu[u.kind];return r.jsxs("div",{className:"document-tab dock-tab","data-active":h,"data-dock-id":u.id,draggable:!0,onDragStart:m=>{m.dataTransfer.setData(ts,u.id),m.dataTransfer.effectAllowed="move"},children:[r.jsxs("button",{type:"button",role:"tab","aria-selected":h,title:u.title,onClick:()=>e==="center"?i.setCenter(u.id):i.setRight(m=>({...m,[u.kind]:u.id})),children:[r.jsx(d,{}),r.jsx("span",{children:u.title})]}),h&&e==="center"&&r.jsx("button",{type:"button",className:"dock-move","aria-label":a.right,title:a.right,onClick:()=>i.move(u.id,"right"),children:r.jsx(Fa,{})}),r.jsx("button",{type:"button",className:"document-tab-close","aria-label":`${n.close} ${u.title}`,title:n.close,onClick:()=>i.close(u.id),children:r.jsx(Me,{})})]},u.id)})}),e==="right"&&t&&r.jsx("button",{type:"button",className:"dock-new","aria-label":a.create,title:Hn(a.create,"newTab"),onClick:()=>i.add(t,n[t==="browser"?"browser":"terminal"],s),children:r.jsx(Wn,{})})]})}function Mu({item:e,t}){const n=ln(),s=fs(t);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":s.center,title:s.center,draggable:!0,onDragStart:i=>{i.dataTransfer.setData(ts,e.id),i.dataTransfer.effectAllowed="move"},onClick:()=>n.move(e.id,"center"),children:r.jsx(Qs,{})}),r.jsx("button",{type:"button","aria-label":s.create,title:Hn(s.create,"newTab"),onClick:()=>n.add(e.kind,t[e.kind==="browser"?"browser":"terminal"],e.cwd),children:r.jsx(Wn,{})})]})}function ns({location:e,kind:t}){const n=ln(),s=e==="center"?"center":`right-${t}`,i=c.useCallback(a=>n.register(s,a),[n.register,s]);return r.jsx("div",{ref:i,className:"dock-slot","data-dock-location":e,"data-dock-kind":t})}function yr(e,t){const n=na();return n?{onDragOver:s=>{s.dataTransfer.types.includes(ts)&&(s.preventDefault(),s.dataTransfer.dropEffect="move",s.currentTarget.classList.add("dock-drop-target"))},onDragLeave:s=>{s.currentTarget.contains(s.relatedTarget)||s.currentTarget.classList.remove("dock-drop-target")},onDrop:s=>{s.currentTarget.classList.remove("dock-drop-target");const i=s.dataTransfer.getData(ts),a=n.items.find(o=>o.id===i);a&&(s.preventDefault(),s.stopPropagation(),document.body.classList.remove("dock-dragging"),n.move(i,e),t?.(a.kind))}}:{}}const Pu=c.lazy(()=>gt(()=>import("./BrowserControlPanel-DzDyeCam.js"),__vite__mapDeps([8,1,2,6]))),Du=c.lazy(()=>gt(()=>import("./TerminalControlPanel-16KT-TCS.js"),__vite__mapDeps([9,1,2]))),_u=c.lazy(()=>gt(()=>Promise.resolve().then(()=>Hu),void 0).then(e=>({default:e.DiffDrawer})));function Lu({item:e,...t}){const n=ln(),s=yr(e.location),[i]=c.useState(()=>document.createElement("div")),a=e.location==="right",l=a&&n.items.filter(g=>g.location==="right"&&g.kind===e.kind).length===1?r.jsx(Mu,{item:e,t:t.t}):void 0,u=a?e.kind==="diff"?n.right.diff===e.id:t.rightVisible&&t.controlTab===e.kind&&n.right[e.kind]===e.id:n.center===e.id,h=n.hosts[a?`right-${e.kind}`:"center"]??n.hosts.parking,d=n.hosts.parking;c.useLayoutEffect(()=>{d&&i.parentElement!==d&&d.appendChild(i)},[i,d]),c.useLayoutEffect(()=>{i.className="dock-surface",i.dataset.dockId=e.id,i.dataset.location=e.location,i.dataset.kind=e.kind,i.hidden=!u;const g=a&&e.kind==="diff",p=()=>{const w=h?.getBoundingClientRect();Object.assign(i.style,g?{left:"0px",top:"0px",width:"100vw",height:"100vh"}:{left:`${w?.left??0}px`,top:`${w?.top??0}px`,width:`${w?.width??0}px`,height:`${w?.height??0}px`})};p();const S=new ResizeObserver(p);return h&&S.observe(h),window.addEventListener("resize",p),window.addEventListener("scroll",p,!0),()=>{S.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0)}},[i,h,u,e.id,e.location,e.kind,a]),c.useLayoutEffect(()=>()=>i.remove(),[i]);const m=()=>n.move(e.id,a?"center":"right");return it.createPortal(r.jsx("div",{className:"dock-surface-content",...s,children:r.jsx(c.Suspense,{fallback:r.jsx("p",{className:"control-panel-loading",children:t.t.loading}),children:e.kind==="browser"?r.jsx(Pu,{t:t.t,dockActions:l,onTitleChange:g=>n.rename(e.id,g)}):e.kind==="terminal"?r.jsx(Du,{client:t.client,cwd:e.cwd??"",deviceName:t.deviceName,visible:u,t:t.t,dockActions:l}):e.session&&t.client?r.jsx(_u,{client:t.client,sessionId:e.session.sessionId,cwd:e.session.cwd,sessionTitle:e.title,t:t.t,onClose:()=>n.close(e.id),onDock:m,dockLabel:fs(t.t).center,presentation:a?"drawer":"workspace",initialScope:e.scope,initialPath:e.path}):null})}),i)}function $u(e){const t=ln();t.openRight.current=s=>{(s==="browser"||s==="terminal")&&e.onOpenRight?.(s)};const n=c.useCallback(s=>t.register("parking",s),[t.register]);return c.useEffect(()=>{t.reset()},[e.daemonId]),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"dock-parking",ref:n}),r.jsx("div",{className:"dock-overlay-slot",children:r.jsx(ns,{location:"right",kind:"diff"})}),t.items.map(s=>r.jsx(Lu,{item:s,...e},s.id))]})}function Fu(e){let t=0,n=0;return e.split(`
12
+ `).map(s=>{const i=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(s);return i?(t=Number(i[1]),n=Number(i[2]),{text:s,kind:"hunk",oldLine:"",newLine:"",sign:""}):s.startsWith("diff ")||s.startsWith("index ")||s.startsWith("---")||s.startsWith("+++")||!t&&!n?{text:s,kind:"header",oldLine:"",newLine:"",sign:""}:s.startsWith("+")?{text:s.slice(1),kind:"add",oldLine:"",newLine:String(n++),sign:"+"}:s.startsWith("-")?{text:s.slice(1),kind:"del",oldLine:String(t++),newLine:"",sign:"−"}:s.startsWith(" ")?{text:s.slice(1),kind:"ctx",oldLine:String(t++),newLine:String(n++),sign:""}:{text:s,kind:"header",oldLine:"",newLine:"",sign:""}})}function Ou({patch:e,truncated:t,truncatedLabel:n,loadingLabel:s}){const i=c.useMemo(()=>Fu(e),[e]),[a,o]=c.useState(400),l=c.useRef(null);return c.useEffect(()=>{o(400)},[e]),c.useEffect(()=>{const u=l.current;if(!u)return;const h=new IntersectionObserver(d=>{d.some(m=>m.isIntersecting)&&o(m=>m+400)},{root:u.closest(".diff-patch"),rootMargin:"200px"});return h.observe(u),()=>h.disconnect()},[a,i.length]),r.jsxs("div",{className:"diff-patch-view",children:[i.slice(0,a).map((u,h)=>r.jsxs("div",{className:`diff-line ${u.kind}`,children:[r.jsx("span",{className:"diff-line-number","aria-hidden":"true",children:u.oldLine}),r.jsx("span",{className:"diff-line-number","aria-hidden":"true",children:u.newLine}),r.jsx("span",{className:"diff-line-sign","aria-hidden":"true",children:u.sign}),r.jsx("span",{className:"diff-line-text",children:u.text||" "})]},h)),a<i.length&&r.jsx("div",{ref:l,className:"diff-more",role:"status",children:s}),t&&r.jsx("p",{className:"diff-empty",children:n})]})}function qu(e){const t=c.useRef(void 0);return c.useEffect(()=>()=>t.current?.(),[]),{"data-dock-draggable":!!e,onPointerDown:n=>{if(!e||n.button!==0||n.target.closest("button"))return;t.current?.();const s=n.currentTarget,i={x:n.clientX,y:n.clientY},a=document.querySelector(".workspace-documents");if(!a)return;let o=!1;const l=(m,g)=>{const p=a.getBoundingClientRect();return m>=p.left&&m<=p.right&&g>=p.top&&g<=p.bottom},u=m=>{Math.hypot(m.clientX-i.x,m.clientY-i.y)<6&&!o||(o=!0,document.body.classList.add("dock-dragging"),a.classList.toggle("dock-drop-target",l(m.clientX,m.clientY)))},h=()=>{document.body.classList.remove("dock-dragging"),a.classList.remove("dock-drop-target"),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",h),s.hasPointerCapture(n.pointerId)&&s.releasePointerCapture(n.pointerId),t.current=void 0},d=m=>{const g=o&&l(m.clientX,m.clientY);h(),g&&e()};t.current=h,s.setPointerCapture(n.pointerId),window.addEventListener("pointermove",u),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",h),n.preventDefault()}}}const Hr=new WeakMap,sa=5e3;function br(e,t,n){let s=Hr.get(e);s||Hr.set(e,s=new Map);const i=JSON.stringify([t.sessionId,t.cwd,n]);let a=s.get(i);return a||(s.size>=12&&s.delete(s.keys().next().value),s.set(i,a={updated:0,patches:new Map})),a}function Br(e,t,n){return br(e,t,n)}function ra(e,t,n){const s=br(e,t,n);return s.pending?s.pending:s.data&&Date.now()-s.updated<sa?Promise.resolve(s.data):(s.pending=e.request({action:"session.gitDiff.list",id:e.makeId("gitDiffList"),...t,scope:n}).then(i=>(s.data=i,s.updated=Date.now(),s.patches.clear(),i)).finally(()=>{s.pending=void 0}),s.pending)}function ia(e,t,n,s){const i=br(e,t,n),a=i.patches.get(s);if(a?.pending)return a.pending;if(a?.data&&Date.now()-i.updated<sa)return Promise.resolve(a.data);i.patches.size>=12&&i.patches.delete(i.patches.keys().next().value);const o={};return i.patches.set(s,o),o.pending=e.request({action:"session.gitDiff.file",id:e.makeId("gitDiffFile"),...t,scope:n,path:s}).then(l=>(o.data=l,l)).finally(()=>{o.pending=void 0}),o.pending}async function Wu(e,t){const n=await ra(e,t,"unstaged");n.files[0]&&await ia(e,t,"unstaged",n.files[0].path)}const Cs={loading:!1,files:null,error:null};function aa({client:e,sessionId:t,cwd:n,sessionTitle:s,t:i,onClose:a,onDock:o,dockLabel:l,presentation:u="drawer",initialScope:h="unstaged",initialPath:d}){const m=c.useId(),g=c.useRef(null),[p,S]=c.useState(!1),w=c.useRef(void 0),b=c.useCallback(()=>{if(w.current===void 0){if(u==="workspace"||window.matchMedia("(prefers-reduced-motion: reduce)").matches){a();return}S(!0),w.current=window.setTimeout(a,180)}},[a,u]);c.useEffect(()=>()=>window.clearTimeout(w.current),[]);const y=rs(b,g,u==="drawer"),f=Br(e,{sessionId:t,cwd:n},h),[v,k]=c.useState(h),[j,E]=c.useState({unstaged:Cs,staged:Cs,[h]:{...Cs,files:f.data?.files??null}}),[x,C]=c.useState(d??f.data?.files[0]?.path??null),[I,N]=c.useState(f.patches.get(d??f.data?.files[0]?.path??"")?.data??null),[L,P]=c.useState(!1),[R,_]=c.useState(null),V=qu(u==="drawer"&&o?()=>o({scope:v,path:x}):void 0),Z=j[v],ue=c.useCallback(async D=>{E(Q=>({...Q,[D]:{loading:!0,files:Q[D].files,error:null}}));try{const Q=await ra(e,{sessionId:t,cwd:n},D);E(G=>({...G,[D]:{loading:!1,files:Q.files,error:null}}))}catch(Q){E(G=>({...G,[D]:{loading:!1,files:null,error:Q instanceof Error?Q.message:String(Q)}}))}},[e,t,n]);c.useEffect(()=>{ue(v)},[v,ue]),c.useEffect(()=>{const D=Z.files;if(D){if(!D.length){C(null);return}C(Q=>D.some(G=>G.path===Q)?Q:D[0].path)}},[Z.files]),c.useEffect(()=>{if(!x){N(null),_(null);return}let D=!1;const Q=Br(e,{sessionId:t,cwd:n},v).patches.get(x)?.data;return N(G=>Q??(G?.path===x?G:null)),P(!Q&&I?.path!==x),_(null),ia(e,{sessionId:t,cwd:n},v,x).then(G=>{D||(N(G),P(!1))}).catch(G=>{D||(_(G instanceof Error?G.message:String(G)),P(!1))}),()=>{D=!0}},[e,t,n,v,x,Z.files]);const ye=c.useMemo(()=>{const D=Q=>Q?Q.reduce((G,re)=>({adds:G.adds+re.additions,dels:G.dels+re.deletions,count:G.count+1}),{adds:0,dels:0,count:0}):{adds:0,dels:0,count:0};return{unstaged:D(j.unstaged.files),staged:D(j.staged.files)}},[j]);return r.jsxs("div",{"aria-labelledby":m,"aria-modal":u==="drawer"?!0:void 0,className:`diff-drawer ${u==="workspace"?"diff-workspace":""} ${p?"closing":""}`,ref:y,role:u==="drawer"?"dialog":"region",tabIndex:-1,children:[u==="drawer"&&r.jsx("div",{className:"diff-drawer-backdrop",onClick:b,"aria-hidden":"true"}),r.jsxs("div",{className:"diff-drawer-panel",children:[r.jsxs("header",{className:"diff-drawer-header",...V,children:[o&&u==="drawer"&&r.jsx("button",{type:"button",className:"icon-button","aria-label":l,title:l,onClick:()=>o({scope:v,path:x}),children:r.jsx(Qs,{})}),r.jsxs("div",{children:[r.jsx("strong",{id:m,children:i.changes}),r.jsx("span",{children:s})]}),r.jsx("button",{"aria-label":i.closeChanges,className:"icon-button",onClick:b,ref:g,type:"button",title:i.closeChanges,children:r.jsx(Me,{"aria-hidden":"true"})})]}),r.jsx("div",{className:"diff-tabs",role:"tablist",children:["unstaged","staged"].map(D=>{const Q=ye[D],G=v===D;return r.jsxs("button",{type:"button",role:"tab","aria-selected":G,className:`diff-tab ${G?"active":""}`,onClick:()=>{D!==v&&(C(null),N(null),_(null),k(D))},children:[r.jsx("span",{className:"diff-tab-label",children:D==="unstaged"?i.workingChanges:i.stagedChanges}),Q.count>0?r.jsxs("span",{className:"diff-tab-meta",children:[r.jsxs("span",{className:"diff-add",children:["+",Q.adds]}),r.jsxs("span",{className:"diff-del",children:["-",Q.dels]})]}):null]},D)})}),r.jsxs("div",{className:"diff-body",children:[r.jsxs("aside",{className:"diff-files","aria-label":i.changedFiles,children:[Z.loading&&!Z.files?r.jsx("p",{className:"diff-empty",children:i.loading}):null,Z.error?r.jsx("p",{className:"diff-empty diff-error",children:Z.error}):null,Z.files&&Z.files.length===0?r.jsx("p",{className:"diff-empty",children:i.noChanges}):null,Z.files?.map(D=>r.jsxs("button",{type:"button",className:`diff-file diff-file-${D.status} ${x===D.path?"active":""}`,onClick:()=>C(D.path),children:[r.jsx("span",{className:`diff-status diff-status-${D.status}`,children:D.status}),r.jsx("span",{className:"diff-file-path",title:D.path,children:D.path}),r.jsxs("span",{className:"diff-file-stats",children:[D.binary?r.jsx("span",{className:"diff-binary",children:"bin"}):null,!D.binary&&D.additions>0?r.jsxs("span",{className:"diff-add",children:["+",D.additions]}):null,!D.binary&&D.deletions>0?r.jsxs("span",{className:"diff-del",children:["-",D.deletions]}):null]})]},D.path))]}),r.jsx("section",{className:"diff-patch","aria-label":i.fileDiff,children:x?L?r.jsx("p",{className:"diff-empty",children:i.loadingPatch}):R?r.jsx("p",{className:"diff-empty diff-error",children:R}):I?.binary?r.jsx("p",{className:"diff-empty",children:i.binaryDiffUnavailable}):I?r.jsx(Ou,{patch:I.patch,truncated:I.truncated,truncatedLabel:i.patchTruncated,loadingLabel:i.loadingPatch},`${v}:${x}`):null:r.jsxs("div",{className:"diff-empty",children:[r.jsx(Ys,{"aria-hidden":"true"}),r.jsx("p",{children:i.selectFileForDiff})]})})]})]})]})}const Hu=Object.freeze(Object.defineProperty({__proto__:null,DiffDrawer:aa},Symbol.toStringTag,{value:"Module"})),Bu=c.lazy(async()=>gt(()=>import("./FilesControlPanel-Dy08iN_7.js"),__vite__mapDeps([10,1,2,11,12])).then(e=>({default:e.FilesControlPanel}))),zu=c.lazy(async()=>gt(()=>import("./LanguageSettingsPanel-db264JO3.js"),__vite__mapDeps([13,1,2,14])).then(e=>({default:e.LanguageSettingsPanel}))),Ku=c.lazy(async()=>gt(()=>import("./ThemeSettingsPanel-D3-WUp4t.js"),__vite__mapDeps([15,1,2,14])).then(e=>({default:e.ThemeSettingsPanel}))),Gu=c.lazy(async()=>gt(()=>import("./NotificationSettingsPanel-BYr3-NRw.js"),__vite__mapDeps([16,1,2])).then(e=>({default:e.NotificationSettingsPanel})));function zr({t:e}){return r.jsxs("div",{className:"control-panel-loading","aria-live":"polite","aria-busy":"true",children:[r.jsx("span",{className:"loading-spinner","aria-hidden":"true"}),r.jsx("span",{children:e.loadingControls})]})}function Uu({client:e,id:t,activeSession:n,sessions:s,t:i,close:a}){const o=na(),l=n?.sessionId,u=n?.cwd,h=n?.runtime.isResponding;c.useEffect(()=>{if(!e||!l)return;const m=window.setTimeout(()=>{document.visibilityState!=="hidden"&&Wu(e,{sessionId:l,cwd:u}).catch(()=>{})},350);return()=>window.clearTimeout(m)},[e,l,u,h]);const d=s.find(m=>m.sessionId===t);return!d||!e?null:r.jsx(aa,{client:e,sessionId:d.sessionId,cwd:d.cwd,sessionTitle:Et(d),t:i,onClose:a,dockLabel:fs(i).center,onDock:o?({scope:m,path:g})=>{o.add("diff",Et(d),d.cwd,d,m,g),a()}:void 0},d.sessionId)}const Vu="/web/assets/logo-SQcOtj-8.png";function Qu(e,t,n){const s=e.find(i=>i.daemonId===t&&n(i.daemonId))??e.find(i=>n(i.daemonId));return e.filter(i=>!n(i.daemonId)||i===s)}function Zu({activeDaemonId:e,busy:t,fallbackName:n,phase:s,statusText:i,t:a,targets:o,onConnect:l,onRename:u,onEditConnection:h}){const[d,m]=c.useState(!1),[g,p]=c.useState(null),[S,w]=c.useState(""),b=c.useRef(null),y=c.useRef(null),f=se().isLocalDaemon??(()=>!1),v=Qu(o,e,f),j=o.find(C=>C.daemonId===e)?.label||n||e?.slice(0,10)||"Vibelet Web";c.useEffect(()=>{d||p(null),g&&y.current?.select()},[d,g]),c.useEffect(()=>{if(!d)return;const C=N=>{N.target instanceof Node&&!b.current?.contains(N.target)&&m(!1)},I=N=>{N.key==="Escape"&&m(!1)};return document.addEventListener("pointerdown",C),document.addEventListener("keydown",I),()=>{document.removeEventListener("pointerdown",C),document.removeEventListener("keydown",I)}},[d]);const E=C=>{p(C.daemonId),w(C.label)},x=()=>{!g||!S.trim()||(u(g,S),p(null))};return r.jsxs("div",{className:"device-switcher",ref:b,children:[r.jsxs("button",{"aria-expanded":d,"aria-haspopup":"menu",className:"device-switcher-trigger",onClick:()=>m(C=>!C),title:j,type:"button",children:[r.jsx("strong",{children:j}),r.jsx(Zs,{"aria-hidden":"true"})]}),r.jsxs("span",{className:`brand-connection ${s}`,children:[r.jsx("i",{"aria-hidden":"true"}),s==="connected"?a.connected:i]}),d?r.jsxs("div",{"aria-label":a.savedDevices,className:"device-switcher-menu",role:"menu",children:[v.map(C=>{const I=C.daemonId===e;return r.jsx("div",{className:"device-switcher-row",children:g===C.daemonId?r.jsxs("form",{className:"device-rename-form",onSubmit:N=>{N.preventDefault(),x()},children:[r.jsx("input",{ref:y,"aria-label":a.rename,autoFocus:!0,onChange:N=>w(N.target.value),onKeyDown:N=>{N.key==="Escape"&&(N.stopPropagation(),p(null))},value:S}),r.jsx("button",{"aria-label":a.rename,title:a.rename,disabled:!S.trim(),type:"submit",children:r.jsx(Lt,{"aria-hidden":"true"})}),r.jsx("button",{"aria-label":a.cancel,title:a.cancel,type:"button",onClick:()=>p(null),children:r.jsx(Me,{"aria-hidden":"true"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:"device-connect-button",disabled:t||I,onClick:()=>{l(C),m(!1)},role:"menuitem",type:"button",children:[I?r.jsx(Lt,{"aria-hidden":"true"}):r.jsx(hi,{"aria-hidden":"true"}),r.jsxs("span",{children:[r.jsx("strong",{children:C.label}),r.jsx("small",{children:f(C.daemonId)?`${a.currentDevice}${I?` · ${a.active}`:""}`:I?a.active:C.displayName||C.daemonId})]})]}),r.jsx("button",{"aria-label":`${a.rename} ${C.label}`,title:`${a.rename} ${C.label}`,className:"device-rename-button",onClick:()=>E(C),type:"button",children:r.jsx(Wo,{"aria-hidden":"true"})}),h&&se().canEditConnection?.(C.daemonId)&&r.jsx("button",{"aria-label":`${a.editConnection} ${C.label}`,title:`${a.editConnection} ${C.label}`,className:"device-rename-button",onClick:()=>{h(C),m(!1)},type:"button",children:r.jsx(Xo,{"aria-hidden":"true"})})]})},C.daemonId)}),o.length===0?r.jsx("p",{className:"empty-copy",children:a.noSavedDevices}):null]}):null]})}function Bs({label:e,value:t,options:n,onChange:s}){const i=c.useId();return r.jsxs("div",{className:"filter-section",children:[r.jsx("span",{className:"filter-section-label",id:i,children:e}),r.jsx("div",{className:"filter-choice-list",role:"radiogroup","aria-labelledby":i,children:n.map(a=>r.jsxs("label",{className:"filter-menu-row",children:[r.jsx("input",{type:"radio",name:i,value:a.value,checked:t===a.value,onChange:()=>s(a.value)}),r.jsx("span",{children:a.label}),r.jsx(Lt,{className:"filter-menu-check","aria-hidden":"true","data-checked":t===a.value})]},a.value))})]})}function Yu({folder:e,initialValue:t,t:n,onClose:s,onSave:i}){const[a,o]=c.useState(t),l=c.useRef(null),u=rs(s,l),h=d=>{d.preventDefault(),i(a)};return it.createPortal(r.jsxs("div",{"aria-labelledby":"folder-tag-dialog-title","aria-modal":"true",className:"folder-tag-dialog-layer",ref:u,role:"dialog",tabIndex:-1,children:[r.jsx("div",{"aria-hidden":"true",className:"folder-tag-dialog-backdrop",onClick:s}),r.jsxs("form",{className:"folder-tag-dialog",onSubmit:h,children:[r.jsxs("header",{children:[r.jsx("span",{className:"folder-tag-dialog-icon","aria-hidden":"true",children:r.jsx(gi,{})}),r.jsxs("div",{children:[r.jsx("strong",{id:"folder-tag-dialog-title",children:n.editDirectoryTags}),r.jsx("span",{title:e,children:e})]}),r.jsx("button",{"aria-label":n.cancel,title:n.cancel,className:"mini-button",onClick:s,type:"button",children:r.jsx(Me,{"aria-hidden":"true"})})]}),r.jsxs("label",{className:"folder-tag-dialog-field",children:[r.jsx("span",{children:n.directoryTags}),r.jsx("textarea",{"aria-describedby":"folder-tag-dialog-help",placeholder:n.directoryTagsPlaceholder,ref:l,rows:3,value:a,onChange:d=>o(d.target.value)})]}),r.jsx("p",{id:"folder-tag-dialog-help",children:n.directoryTagsDescription}),r.jsxs("footer",{children:[r.jsx("button",{className:"icon-text-button",onClick:s,type:"button",children:n.cancel}),r.jsx("button",{className:"primary-button",type:"submit",children:n.saveDirectoryTags})]})]})]}),document.body)}function Ju({connectionIndicators:e,search:t,busy:n,connected:s,filtersOpen:i,filtersActive:a,t:o,onSearchChange:l,onSearchCommit:u,onToggleFilters:h,onCreate:d}){const[m,g]=c.useState(!!t),p=c.useRef(null);return c.useEffect(()=>{const S=()=>{g(!0),requestAnimationFrame(()=>p.current?.focus())};return window.addEventListener("vibelet.session-search",S),()=>window.removeEventListener("vibelet.session-search",S)},[]),r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"rail-list-heading",children:[r.jsx("span",{children:o.sessions}),r.jsx("div",{className:"rail-heading-indicators",children:e}),r.jsxs("div",{className:"rail-heading-actions",children:[r.jsx("button",{"aria-label":o.searchSessions,"aria-expanded":m,className:"rail-create-button",title:Hn(o.searchSessions,"searchSessions"),type:"button",onClick:()=>{g(!0),requestAnimationFrame(()=>p.current?.focus())},children:r.jsx(_n,{"aria-hidden":"true"})}),r.jsx("button",{"aria-label":o.newSession,className:"rail-create-button",disabled:n||!s,onClick:d,title:o.newSession,type:"button",children:r.jsx(Wn,{"aria-hidden":"true"})}),r.jsx("button",{"aria-expanded":i,"aria-label":o.sessionFilters,className:`filter-toggle ${i||a?"selected":""}`,onClick:h,title:o.sessionFilters,type:"button",children:r.jsx(ho,{"aria-hidden":"true"})})]})]}),(m||t)&&r.jsxs("div",{className:"search-box",children:[r.jsx(_n,{"aria-hidden":"true"}),r.jsx("input",{ref:p,"aria-label":o.searchSessions,value:t,onBlur:u,onChange:S=>l(S.target.value),placeholder:o.searchSessions,onKeyDown:S=>{S.key==="Enter"&&u(),S.key==="Escape"&&(l(""),u(),g(!1))}}),r.jsx("button",{className:"filter-toggle","aria-label":o.cancel,title:o.cancel,type:"button",onClick:()=>{l(""),g(!1),p.current?.blur()},children:r.jsx(Me,{"aria-hidden":"true"})})]})]})}function Xu({menu:e,pending:t,t:n,onOpen:s,onDetails:i,onCopyResumeCommand:a,onResumeInTerminal:o,terminalBusy:l,onTogglePinned:u,onToggleArchived:h,onDelete:d}){return r.jsxs("div",{className:"session-context-menu",role:"menu",style:{left:e.x,top:e.y},onPointerDown:m=>m.stopPropagation(),children:[r.jsxs("button",{type:"button",role:"menuitem",onClick:s,children:[r.jsx(xa,{"aria-hidden":"true"}),n.open]}),r.jsxs("button",{type:"button",role:"menuitem",disabled:t,onClick:i,children:[r.jsx(li,{"aria-hidden":"true"}),n.details]}),r.jsxs("button",{type:"button",role:"menuitem",disabled:t,onClick:a,children:[r.jsx(yn,{"aria-hidden":"true"}),n.copyResumeCommand]}),o&&r.jsxs("button",{type:"button",role:"menuitem",disabled:t||l,title:l?n.resumeTerminalBusy:n.resumeInTerminal,onClick:o,children:[r.jsx(Xs,{"aria-hidden":"true"}),n.resumeInTerminal]}),r.jsx("span",{className:"context-menu-separator"}),r.jsxs("button",{type:"button",role:"menuitem",disabled:t,onClick:u,children:[r.jsx(qn,{"aria-hidden":"true"}),e.session.pinned?n.unpin:n.pin]}),r.jsxs("button",{type:"button",role:"menuitem",disabled:t,onClick:h,children:[r.jsx(as,{"aria-hidden":"true"}),e.session.archived?n.unarchive:n.archive]}),r.jsxs("button",{className:"danger",type:"button",role:"menuitem",onClick:d,children:[r.jsx(yi,{"aria-hidden":"true"}),n.delete]})]})}function Kr({session:e,active:t,selected:n=!1,responding:s,pending:i=!1,tagLabels:a,showFolder:o=!0,t:l,onSelect:u,onContextMenu:h,onToggleArchived:d,onTogglePinned:m}){const g=Et(e),p=ds(e.lastActivityAt,Date.now(),l),S=e.cwd?.split(/[\\/]/).filter(Boolean).at(-1)||e.cwd||".",w=e.branchUrl||(e.branch&&e.pullRequest?.url.match(/^https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/\d+$/)?e.pullRequest.url.replace(/\/pull\/\d+$/,`/tree/${encodeURIComponent(e.branch)}`):void 0),b=!!(e.branch||e.pullRequest),[y,f]=c.useState(!1),v=c.useRef(null),k=c.useRef(null),j=c.useRef({x:0,y:0}),E=c.useRef(null),x=()=>{const N=k.current;if(!N)return;const{x:L,y:P}=j.current,R=N.getBoundingClientRect(),V=P+18+R.height<=window.innerHeight-8?P+18:P-R.height-12;N.style.left=`${Math.max(8,Math.min(L+14,window.innerWidth-R.width-8))}px`,N.style.top=`${Math.max(8,Math.min(V,window.innerHeight-R.height-8))}px`,N.style.visibility="visible"};c.useLayoutEffect(()=>{y&&x()},[y,g]);const C=()=>{v.current!==null&&window.clearTimeout(v.current),v.current=null,E.current!==null&&window.cancelAnimationFrame(E.current),E.current=null,f(!1)};c.useEffect(()=>()=>{v.current!==null&&window.clearTimeout(v.current),E.current!==null&&window.cancelAnimationFrame(E.current)},[e.sessionId]),c.useEffect(()=>{if(!y)return;const N=()=>f(!1);return document.addEventListener("scroll",N,!0),()=>document.removeEventListener("scroll",N,!0)},[y]);const I=N=>{v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{v.current=null,N.isConnected&&N.matches(":hover")&&f(!0)},2e3)};return r.jsxs("div",{className:"session-item","data-active":t||void 0,"data-multi-selected":n||void 0,"data-statuses":+!!e.pinned+ +!!e.archived,onMouseEnter:N=>{j.current={x:N.clientX,y:N.clientY},I(N.currentTarget)},onMouseMove:N=>{j.current={x:N.clientX,y:N.clientY},y&&E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null,x()}))},onMouseLeave:C,onFocusCapture:N=>{if(N.target instanceof HTMLElement&&N.target.matches(":focus-visible")){v.current!==null&&window.clearTimeout(v.current),v.current=null;const L=N.currentTarget.getBoundingClientRect();j.current={x:L.left+L.width/2,y:L.bottom},f(!0)}},onBlurCapture:N=>{(!(N.relatedTarget instanceof Node)||!N.currentTarget.contains(N.relatedTarget))&&C()},children:[r.jsxs("button",{className:`session-row ${t?"active":""} ${e.archived?"archived":""} ${s?"responding":""}`,"data-session-id":e.sessionId,"aria-current":t?"true":void 0,"aria-pressed":n,onContextMenu:h,onClick:u,onMouseDown:N=>{N.shiftKey&&N.preventDefault()},type:"button",children:[r.jsxs("span",{className:"session-row-head",children:[r.jsx("strong",{children:g}),r.jsx("span",{className:"session-row-metadata",children:r.jsx("span",{className:"session-row-time",title:p,children:p})}),s?r.jsx("span",{className:"session-running-indicator",role:"img","aria-label":l.agentResponding,title:l.agentResponding}):r.jsx("span",{className:"session-running-placeholder","aria-hidden":"true"})]}),a?.length?r.jsx("span",{className:"directory-tag-row",title:l.directoryTags,children:a.map(N=>r.jsx("em",{children:N},N))}):null,r.jsxs("span",{className:"session-row-footer","data-has-git":b||void 0,children:[!b&&o?r.jsx("span",{className:"session-row-folder",title:e.cwd,children:S}):null,e.pinned?r.jsx("span",{children:l.pinned}):null,e.archived?r.jsx("span",{children:l.archived}):null,r.jsx("span",{className:"session-row-agent",children:e.agent==="codex"?"Codex":"Claude"})]})]}),r.jsxs("div",{className:"session-quick-actions",children:[r.jsx("button",{"aria-label":e.archived?l.unarchive:l.archive,className:e.archived?"is-archived":void 0,disabled:i,onClick:d,title:e.archived?l.unarchive:l.archive,type:"button",children:r.jsx(as,{"aria-hidden":"true"})}),r.jsx("button",{"aria-label":e.pinned?l.unpin:l.pin,className:e.pinned?"is-pinned":void 0,disabled:i,onClick:m,title:e.pinned?l.unpin:l.pin,type:"button",children:r.jsx(qn,{"aria-hidden":"true"})})]}),b&&r.jsxs("div",{className:"session-git-links",children:[o&&r.jsx("span",{className:"session-git-folder",title:e.cwd,children:S}),e.branch&&(w?r.jsx("a",{className:"session-branch-link",href:w,target:"_blank",rel:"noopener noreferrer",title:e.branch,children:e.branch}):r.jsx("span",{className:"session-branch-link",title:e.branch,children:e.branch})),e.pullRequest&&r.jsxs("a",{className:"session-pr-link",href:e.pullRequest.url,target:"_blank",rel:"noopener noreferrer",title:e.pullRequest.title,children:["PR #",e.pullRequest.number]})]}),y&&it.createPortal(r.jsx("div",{"aria-hidden":"true",className:"session-title-tooltip",ref:k,style:{left:0,top:0,visibility:"hidden"},children:g}),document.body)]})}function eh({activeSessionId:e,busy:t,collapsedFolders:n,folderCounts:s,getFolderTags:i,groupFolders:a,groupedSessions:o,phase:l,pendingSessionIds:u,respondingSessionIds:h,t:d,visibleSessions:m,onEditFolderTags:g,onOpenCreateMenu:p,onOpenSessionMenu:S,onSelectSession:w,onToggleSessionArchived:b,onToggleSessionPinned:y,onToggleFolder:f}){const v=c.useId(),[k,j]=c.useState(()=>new Set),E=c.useRef(null),x=c.useMemo(()=>{const I=a?o.flatMap(N=>n[N.folder]?[]:N.sessions):m;return[...new Set(I.map(N=>N.sessionId))]},[n,a,o,m]);c.useEffect(()=>{const I=new Set(x);j(N=>[...N].every(L=>I.has(L))?N:new Set([...N].filter(L=>I.has(L)))),E.current&&!I.has(E.current)&&(E.current=null)},[x]),c.useEffect(()=>{k.size===0&&(E.current=e)},[e,k]);const C=(I,N)=>{if(N.shiftKey){const L=E.current??e??I,P=x.indexOf(L),R=x.indexOf(I),_=x.slice(Math.min(P<0?R:P,R),Math.max(P,R)+1);j(V=>{const Z=N.metaKey||N.ctrlKey?new Set(V):new Set;for(const ue of _)Z.add(ue);return Z}),E.current=L;return}if(E.current=I,N.metaKey||N.ctrlKey){j(L=>{const P=L.size?new Set(L):new Set(e?[e]:[]);return P.has(I)?P.delete(I):P.add(I),P});return}j(new Set),w(I)};return a?r.jsxs(r.Fragment,{children:[o.map(I=>{const N=!!n[I.folder],L=`${v}-${encodeURIComponent(I.folder)}`,P=I.kind==="folder"?s[I.folder]??I.sessions.length:I.sessions.length,R=I.kind==="attention"?d.needsAttentionSessionsGroup:I.kind==="running"?d.runningSessionsGroup:I.kind==="pinned"?d.pinnedSessionsGroup:I.folder;return r.jsxs("div",{className:`folder-group ${I.kind!=="folder"?"virtual-session-group":""}`,"data-group-kind":I.kind,children:[r.jsxs("div",{className:"folder-heading",children:[r.jsxs("div",{className:"folder-header",children:[r.jsxs("button",{"aria-expanded":!N,"aria-controls":L,title:R,onClick:()=>f(I.folder),type:"button",children:[r.jsx(ii,{className:"folder-disclosure","aria-hidden":"true"}),I.kind==="attention"?r.jsx(li,{"aria-hidden":"true"}):I.kind==="running"?r.jsx(ri,{"aria-hidden":"true"}):I.kind==="pinned"?r.jsx(qn,{"aria-hidden":"true"}):N?r.jsx(lo,{"aria-hidden":"true"}):r.jsx(Xn,{"aria-hidden":"true"}),r.jsx("span",{children:I.kind==="folder"?I.folder.split(/[\\/]/).filter(Boolean).at(-1)||I.folder:R})]}),I.kind==="folder"?r.jsxs(r.Fragment,{children:[r.jsx("button",{"aria-label":i(I.folder).length?d.editDirectoryTags:d.addDirectoryTags,className:"mini-button folder-hover-action",onClick:()=>g(I.folder),title:i(I.folder).length?d.editDirectoryTags:d.addDirectoryTags,type:"button",children:r.jsx(gi,{"aria-hidden":"true"})}),r.jsx("button",{"aria-label":d.newSession,className:"mini-button folder-hover-action",disabled:t||l!=="connected",onClick:_=>p(_,I.folder),title:d.newSession,type:"button",children:r.jsx(Wn,{"aria-hidden":"true"})})]}):null,r.jsx("small",{className:"folder-session-count",title:`${P} ${d.sessions}`,children:P})]}),I.kind==="folder"&&i(I.folder).length?r.jsx("div",{className:"folder-tag-row",children:i(I.folder).map(_=>r.jsx("span",{children:_},_))}):null]}),r.jsx("div",{className:"folder-session-list",id:L,hidden:N,children:N?null:I.sessions.map(_=>r.jsx(Kr,{active:_.sessionId===e,selected:k.has(_.sessionId),responding:h.has(_.sessionId),pending:u?.has(_.sessionId),session:_,showFolder:I.kind!=="folder",tagLabels:i(_.cwd),t:d,onContextMenu:V=>S(V,_),onSelect:V=>C(_.sessionId,V),onToggleArchived:()=>b(_),onTogglePinned:()=>y(_)},_.sessionId))})]},I.folder)}),m.length===0?r.jsx("p",{className:"empty-copy",children:d.noSessionsMatch}):null]}):r.jsxs(r.Fragment,{children:[m.map(I=>r.jsx(Kr,{active:I.sessionId===e,selected:k.has(I.sessionId),responding:h.has(I.sessionId),pending:u?.has(I.sessionId),session:I,tagLabels:i(I.cwd),t:d,onContextMenu:N=>S(N,I),onSelect:N=>C(I.sessionId,N),onToggleArchived:()=>b(I),onTogglePinned:()=>y(I)},I.sessionId)),m.length===0?r.jsx("p",{className:"empty-copy",children:d.noSessionsMatch}):null]})}function th({agentFilter:e,t,onAgentFilterChange:n}){return r.jsx(Bs,{label:t.agentFilterLabel,value:e,options:[{value:"all",label:t.agentFilterAll},{value:"claude",label:t.agentFilterClaude},{value:"codex",label:t.agentFilterCodex}],onChange:n})}function nh({groupFolders:e,hideArchived:t,separatePinnedGroup:n,showNeedsAttentionGroup:s,showRunningGroup:i,t:a,onToggleGroupFolders:o,onToggleHideArchived:l,onToggleNeedsAttentionGroup:u,onToggleRunningGroup:h,onToggleSeparatePinnedGroup:d}){const m=[[a.showNeedsAttentionGroup,s,u],[a.showRunningGroup,i,h],[a.separatePinnedGroup,n,d]];return r.jsxs("div",{className:"filter-section",children:[r.jsx("span",{className:"filter-section-label",children:a.filterViewOptions}),r.jsxs("div",{className:"filter-view-list",children:[r.jsxs("button",{"aria-pressed":e,className:"filter-menu-row",onClick:o,type:"button",children:[r.jsx("span",{children:a.groupByFolder}),r.jsx(Lt,{className:"filter-menu-check","aria-hidden":"true","data-checked":e})]}),m.map(([g,p,S])=>r.jsxs("button",{"aria-pressed":e&&p,className:"filter-menu-row nested-filter-option",disabled:!e,onClick:S,type:"button",children:[r.jsx("span",{children:g}),r.jsx(Lt,{className:"filter-menu-check","aria-hidden":"true","data-checked":e&&p})]},g)),r.jsxs("button",{"aria-pressed":t,className:"filter-menu-row",onClick:l,type:"button",children:[r.jsx("span",{children:a.hideArchived}),r.jsx(Lt,{className:"filter-menu-check","aria-hidden":"true","data-checked":t})]})]})]})}function sh(e,t,n=!1){const s=c.useMemo(()=>e,[e?.lastActivityAt,e?.sessionId]),i=c.useRef(null),a=c.useRef(null),o=c.useRef(t),[l,u]=c.useState(null),h=!!(e?.lastActivityAt&&e.sessionId),d=h?`${e?.lastActivityAt}:${e?.sessionId}`:null;return c.useEffect(()=>{o.current=t},[t]),c.useEffect(()=>{const m=i.current;if(!m||!s||!d){a.current=null,u(null);return}const g=m.closest(".session-list");if(!(g instanceof HTMLElement))return;let p=!0,S;u(null);const w=()=>{a.current!==d&&(a.current=d,u(d),o.current(s).catch(()=>{p&&(S=window.setTimeout(()=>{p&&(a.current=null,n?w():(b?.unobserve(m),b?.observe(m)))},1500))}).finally(()=>{p&&u(y=>y===d?null:y)}))},b=n?null:new IntersectionObserver(y=>{y.some(f=>f.isIntersecting)&&w()},{root:g,rootMargin:"0px 0px 240px 0px",threshold:.01});return n?w():b?.observe(m),()=>{p=!1,a.current=null,S!==void 0&&window.clearTimeout(S),b?.disconnect()}},[d,s,n]),{canLoadMore:h,loading:h&&l===d,sentinelRef:i}}function rh(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function ih({connectionIndicators:e,activeSessionId:t,busy:n,collapsedFolders:s,allFoldersCollapsed:i,currentCwd:a,activeDaemonId:o,displayName:l,savedTargets:u,directoryTags:h,folderCounts:d,groupFolders:m,sessionSort:g,onSessionSortChange:p,groupedSessions:S,hideArchived:w,separatePinnedGroup:b,showNeedsAttentionGroup:y,showRunningGroup:f,inventoryVersion:v,nextCursor:k,phase:j,pendingSessionIds:E,respondingSessionIds:x,search:C,sessionAgentFilter:I,sessionsCount:N,sinceFilter:L,statusText:P,t:R,visibleSessions:_,onLoadMore:V,onCopyResumeCommand:Z,onResumeInTerminal:ue,onConnectTarget:ye,onRequestNewSession:D,onDeleteSession:Q,onEditFolderTags:G,onOpenSessionDetails:re,onResetFilters:ae,onRenameTarget:T,onEditConnection:$,onSearchChange:B,onSearchCommit:Y,onSelectSession:W,onToggleSessionArchived:J,onToggleSessionPinned:z,onSessionAgentFilterChange:ne,onSinceFilterChange:X,onToggleFolder:qe,onToggleAllFolders:me,onToggleGroupFolders:Ue,onToggleHideArchived:Se,onToggleNeedsAttentionGroup:Ie,onToggleRunningGroup:Ne,onToggleSeparatePinnedGroup:ke}){const[be,Ee]=c.useState(!1),[Ve,We]=c.useState(null);c.useEffect(()=>{if(!Ve)return;const ee=window.setTimeout(()=>We(null),2400);return()=>window.clearTimeout(ee)},[Ve]);const[Qe,Ze]=c.useState(null),[he,je]=c.useState(null),et=c.useRef(null),Pe=c.useRef(null),[oe,Ce]=c.useState(null),tt=g!=="updated"||I!=="all"||L!=="30d"||!m||m&&(y||f||b)||w,xe=sh(k,V,g!=="updated"||!w),De=he?!!E?.has(he.session.sessionId):!1,Re=ee=>h[rh(ee)??"/"]??[],ce=j==="connected"?`${_.length}/${N} sessions · v${v??"-"}`:R.sameOriginAccess,te=`${P} · ${ce}`,A=se().toolbarTarget?.("left");c.useLayoutEffect(()=>{if(!be)return;const ee=()=>{const we=et.current?.getBoundingClientRect();if(!we)return;const Ye=Math.min(820,window.innerWidth-24);Ce({top:we.bottom+8,left:Math.max(12,Math.min(we.left,window.innerWidth-Ye-12))})};return ee(),window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[be]),c.useEffect(()=>{if(!be&&!he)return;const ee=Ye=>{const st=Ye.target;st instanceof Node&&(et.current?.contains(st)||Pe.current?.contains(st))||(Ee(!1),je(null))},we=Ye=>{Ye.key==="Escape"&&(Ee(!1),je(null))};return document.addEventListener("pointerdown",ee),document.addEventListener("keydown",we),()=>{document.removeEventListener("pointerdown",ee),document.removeEventListener("keydown",we)}},[he,be]);const Ae=(ee,we)=>{je(null),Ee(!1),D(we)},pe=(ee,we)=>{ee.preventDefault(),je({session:we,x:Math.min(ee.clientX,window.innerWidth-224-10),y:Math.min(ee.clientY,window.innerHeight-306-10)})},nt=()=>je(null),ut=ee=>{Ee(!1),je(null),Ze({folder:ee,value:Re(ee).join(", ")})},at=ee=>{Qe&&(G(Qe.folder,ee),Ze(null))},ge=ee=>{if(!he)return;const{session:we}=he;nt(),ee(we)},le=r.jsxs("div",{className:"brand-block",title:te,children:[r.jsx("div",{className:"brand-mark","aria-hidden":"true",children:r.jsx("img",{alt:"",className:"brand-logo",height:"40",src:Vu,width:"40"})}),r.jsx(Zu,{activeDaemonId:o,busy:n,fallbackName:l,phase:j,statusText:P,t:R,targets:u,onConnect:ye,onRename:T,onEditConnection:$}),m&&S.length>0&&r.jsx("button",{"aria-label":i?R.expandAllSessions:R.collapseAllSessions,"aria-pressed":i,className:"session-folders-toggle",onClick:me,title:i?R.expandAllSessions:R.collapseAllSessions,type:"button",children:i?r.jsx(Ro,{"aria-hidden":"true"}):r.jsx(Po,{"aria-hidden":"true"})})]});return r.jsxs("aside",{className:"session-rail","aria-label":R.sessions,children:[A?it.createPortal(le,A):le,r.jsxs("div",{className:"search-filter-wrap",ref:et,children:[r.jsx(Ju,{connectionIndicators:e,search:C,busy:n,connected:j==="connected",filtersOpen:be,filtersActive:tt,t:R,onSearchChange:B,onSearchCommit:Y,onToggleFilters:()=>Ee(ee=>!ee),onCreate:Ae}),be&&oe?it.createPortal(r.jsxs("div",{className:"filter-popover session-filter-popover",role:"dialog","aria-label":R.sessionFilters,ref:Pe,style:{top:oe.top,left:oe.left},children:[r.jsx(Bs,{label:R.sessionSortLabel,value:g,options:[{value:"updated",label:R.sessionSortUpdated},{value:"created",label:R.sessionSortCreated},{value:"title",label:R.sessionSortTitle},{value:"folder",label:R.sessionSortFolder}],onChange:p}),r.jsx(th,{agentFilter:I,t:R,onAgentFilterChange:ne}),r.jsx(Bs,{label:R.searchTimeRangeLabel,value:L,options:[{value:"all",label:R.searchTimeRangeAllTime},{value:"7d",label:R.searchTimeRangeLast7Days},{value:"30d",label:R.searchTimeRangeLast30Days},{value:"90d",label:R.searchTimeRangeLast90Days}],onChange:X}),r.jsx(nh,{groupFolders:m,hideArchived:w,separatePinnedGroup:b,showNeedsAttentionGroup:y,showRunningGroup:f,t:R,onToggleGroupFolders:Ue,onToggleHideArchived:Se,onToggleNeedsAttentionGroup:Ie,onToggleRunningGroup:Ne,onToggleSeparatePinnedGroup:ke}),tt?r.jsx("button",{className:"filter-reset-button",onClick:ae,type:"button",children:R.resetFilters}):null]}),document.body):null]}),r.jsxs("div",{className:"session-list",children:[r.jsx(eh,{activeSessionId:t,busy:n,collapsedFolders:s,folderCounts:d,getFolderTags:Re,groupFolders:m,groupedSessions:S,phase:j,pendingSessionIds:E,respondingSessionIds:x,t:R,visibleSessions:_,onEditFolderTags:ut,onOpenCreateMenu:Ae,onOpenSessionMenu:pe,onSelectSession:W,onToggleSessionArchived:J,onToggleSessionPinned:z,onToggleFolder:qe},o??"unconnected"),xe.canLoadMore?r.jsx("div",{"aria-live":"polite",className:`session-load-sentinel ${xe.loading?"loading":""}`,ref:xe.sentinelRef,role:"status",children:xe.loading?r.jsxs(r.Fragment,{children:[r.jsx(cs,{className:"spin","aria-hidden":"true"}),r.jsx("span",{children:R.loadingMore})]}):null}):null]}),Qe?r.jsx(Yu,{folder:Qe.folder,initialValue:Qe.value,t:R,onClose:()=>Ze(null),onSave:at}):null,he?r.jsx(Xu,{menu:he,pending:De,t:R,onOpen:()=>ge(ee=>W(ee.sessionId)),onDetails:()=>ge(re),onCopyResumeCommand:()=>ge(ee=>{Promise.resolve(Z(ee)).then(()=>We({message:R.commandCopied,tone:"success"})).catch(()=>We({message:R.copyResumeFailed,tone:"error"}))}),onResumeInTerminal:ue&&o&&se().resumeInTerminal&&se().isLocalDaemon?.(o)?()=>ge(ue):void 0,terminalBusy:x.has(he.session.sessionId),onTogglePinned:()=>ge(z),onToggleArchived:()=>ge(J),onDelete:()=>ge(Q)}):null,r.jsx(cr,{feedback:Ve})]})}function ah({collapsed:e,children:t,onExpand:n,onResize:s,t:i}){const a=se().toolbarTarget?.("left"),o=r.jsx("button",{"aria-label":e?i.expandSessionSidebar:i.collapseSessionSidebar,className:"sidebar-titlebar-toggle",onClick:n,title:Hn(e?i.expandSessionSidebar:i.collapseSessionSidebar,"leftSidebar"),type:"button",children:r.jsx(_o,{"aria-hidden":"true"})});return r.jsxs(r.Fragment,{children:[a?it.createPortal(o,a):o,r.jsx("div",{className:"session-sidebar-motion",inert:e,"aria-hidden":e,children:t}),r.jsx("button",{"aria-label":i.resizeSessionSidebar,"aria-hidden":e,className:"resize-handle",disabled:e,onPointerDown:s,title:i.resizeSessionSidebar,type:"button",children:r.jsx("span",{})})]})}const vr={version:"",latestVersion:"",loading:!1,error:null};function Gr(e){const t=e.match(/^\d+/);return t?Number(t[0]):0}function oh(e,t){const n=e.split(/[+-]/,1)[0].split(".").map(Gr),s=t.split(/[+-]/,1)[0].split(".").map(Gr),i=Math.max(n.length,s.length);for(let a=0;a<i;a+=1){const o=n[a]??0,l=s[a]??0;if(o<l)return-1;if(o>l)return 1}return 0}function oa(e,t){return oh(e,t)<0}function ch(e){const t=e.toLowerCase();if(t.includes("alpha"))return"alpha";if(t.includes("beta"))return"beta";if(e.trim())return"latest"}function lh(e,t,n){const s=e?.webSocketUrl?e.webSocketUrl:t.origin;try{const i=new URL(s);return i.protocol==="ws:"&&(i.protocol="http:"),i.protocol==="wss:"&&(i.protocol="https:"),i.pathname="/health",i.search="",i.hash="",i.toString()}catch{return new URL("/health",t.origin).toString()}}function dh(e){if(!e||typeof e!="object")return{version:"",latestVersion:""};const t=e;return{version:typeof t.version=="string"?t.version.trim():"",latestVersion:typeof t.latestVersion=="string"?t.latestVersion.trim():""}}function uh({busy:e,connected:t,dismissed:n,feedback:s,synced:i,t:a,onPull:o,onPushMerge:l,onPushReplace:u,onSkip:h}){const d=!t||e!==null;return r.jsxs("section",{className:"control-section compact-section archive-sync-panel",children:[r.jsx("h2",{children:a.archiveSyncTitle}),r.jsx("p",{className:"empty-copy",children:i?a.archiveSyncSynced:n?a.archiveSyncSkippedState:a.archiveSyncBody}),r.jsxs("div",{className:"action-grid archive-sync-actions",children:[r.jsxs("button",{className:"icon-text-button",disabled:d,onClick:l,type:"button",children:[r.jsx(go,{"aria-hidden":"true"}),e==="pushMerge"?a.archiveSyncSyncing:a.archiveSyncPushMerge]}),r.jsxs("button",{className:"icon-text-button",disabled:d,onClick:o,type:"button",children:[r.jsx(is,{"aria-hidden":"true"}),e==="pull"?a.archiveSyncSyncing:a.archiveSyncPull]}),r.jsxs("button",{className:"icon-text-button",disabled:d,onClick:u,type:"button",children:[r.jsx(hc,{"aria-hidden":"true"}),e==="pushReplace"?a.archiveSyncSyncing:a.archiveSyncPushReplace]}),r.jsxs("button",{className:"icon-text-button",disabled:d,onClick:h,type:"button",children:[r.jsx(Ma,{"aria-hidden":"true"}),a.archiveSyncSkip]})]}),s?r.jsx("p",{className:`empty-copy ${s.tone==="error"?"error-copy":"success-copy"}`,children:s.message}):null]})}function hh({pairing:e,phase:t,t:n,onForgetPairing:s}){const i=t==="connected"?"connected":e?t:n.notPaired;return r.jsxs("section",{className:"control-section compact-section",children:[r.jsx("h2",{children:n.currentDevice}),r.jsxs("dl",{children:[r.jsxs("div",{children:[r.jsx("dt",{children:n.daemon}),r.jsx("dd",{children:e?.displayName??e?.daemonId??n.notPaired})]}),r.jsxs("div",{children:[r.jsx("dt",{children:n.status}),r.jsx("dd",{children:i})]})]}),r.jsx("div",{className:"action-grid",children:r.jsxs("button",{className:"danger-button",disabled:!e,onClick:s,type:"button",children:[r.jsx(jo,{"aria-hidden":"true"}),n.forget]})})]})}function fh({connected:e,metadata:t,showUpdate:n,updateBusy:s,restartBusy:i,t:a,updateStatus:o,onUpdate:l,onRestart:u}){const h=t.version&&t.latestVersion&&n?`${t.version} -> ${t.latestVersion}`:t.version||a.unknown;return r.jsxs("section",{className:"control-section compact-section",children:[r.jsx("h2",{children:a.desktopConnector}),r.jsx("dl",{children:r.jsxs("div",{children:[r.jsx("dt",{children:a.version}),r.jsx("dd",{children:t.loading?a.checking:h})]})}),r.jsxs("div",{className:"action-grid",children:[n?r.jsxs("button",{className:"primary-button",disabled:!e||s||i,onClick:l,type:"button",children:[r.jsx(is,{"aria-hidden":"true"}),s?a.updating:a.update]}):null,r.jsxs("button",{className:"danger-button",disabled:!e||i,onClick:u,type:"button",children:[r.jsx(Dn,{"aria-hidden":"true"}),i?a.restarting:a.restart]})]}),t.error?r.jsx("p",{className:"empty-copy",children:t.error}):null,o?r.jsx("p",{className:"empty-copy",children:o}):null]})}function mh({activeDaemonId:e,busy:t,t:n,targets:s,onConnect:i,onForget:a}){return r.jsxs("section",{className:"control-section compact-section",children:[r.jsx("h2",{children:n.savedDevices}),r.jsxs("div",{className:"stack-list",children:[s.map(o=>r.jsxs("div",{className:"data-row target-row",children:[r.jsxs("div",{children:[r.jsxs("strong",{children:[o.label,o.daemonId===e?` · ${n.active}`:""]}),r.jsxs("span",{children:[o.displayName??o.daemonId," ·"," ",o.lastConnectedAt?ds(o.lastConnectedAt,Date.now(),n):n.notConnectedRecently]})]}),r.jsxs("div",{className:"row-actions",children:[r.jsx("button",{"aria-label":`Connect to ${o.label}`,title:`Connect to ${o.label}`,className:"icon-button",disabled:t,onClick:()=>i(o),type:"button",children:r.jsx(hi,{"aria-hidden":"true"})}),r.jsx("button",{"aria-label":`Forget ${o.label}`,title:`Forget ${o.label}`,className:"icon-button danger-icon",disabled:t,onClick:()=>a(o.daemonId),type:"button",children:r.jsx(yi,{"aria-hidden":"true"})})]})]},o.daemonId)),s.length===0?r.jsx("p",{className:"empty-copy",children:n.noSavedDevices}):null]})]})}function Ur({workspace:e,portalOnly:t=!1}){const[n,s]=c.useState(()=>se().settingsTarget?.()??null);c.useEffect(()=>{const l=()=>s(se().settingsTarget?.()??null);return window.addEventListener("vibelet.settings.target.changed",l),l(),()=>window.removeEventListener("vibelet.settings.target.changed",l)},[]);const i=e,a=r.jsxs(r.Fragment,{children:[!t&&r.jsxs(r.Fragment,{children:[r.jsx(hh,{pairing:i.pairing,phase:i.phase,t:i.t,onForgetPairing:i.clearPairing}),r.jsx(mh,{activeDaemonId:i.pairing?.daemonId,busy:i.busy,t:i.t,targets:i.savedTargets,onConnect:i.connectSavedTarget,onForget:i.forgetSavedTarget})]}),r.jsx(uh,{busy:i.archiveSyncBusy,connected:i.phase==="connected",dismissed:i.archiveSyncDismissed,feedback:i.archiveSyncStatus,synced:i.archiveSynced,t:i.t,onPull:()=>{i.runArchiveSync("pull")},onPushMerge:()=>{i.runArchiveSync("pushMerge")},onPushReplace:()=>{i.runArchiveSync("pushReplace")},onSkip:i.skipArchiveSync}),r.jsx(fh,{connected:i.phase==="connected",metadata:i.daemonMetadata,restartBusy:i.admin.loading&&i.admin.action==="restart",showUpdate:!!(i.daemonMetadata.version&&i.daemonMetadata.latestVersion&&oa(i.daemonMetadata.version,i.daemonMetadata.latestVersion)),t:i.t,updateBusy:i.admin.loading&&i.admin.action==="update",updateStatus:i.admin.statusText,onRestart:()=>{i.runAdminAction("restart")},onUpdate:()=>{i.runAdminAction("update")}})]}),o=r.jsx("div",{className:"remote-workspace-settings",children:a});return t?n?it.createPortal(o,n):null:o}function ph(){const e=se().polishSettings,t=Je(Xe().language)!=="en",[n,s]=c.useState(),[i,a]=c.useState({...xs}),[o,l]=c.useState(""),[u,h]=c.useState(!1),[d,m]=c.useState(""),[g,p]=c.useState(!1);if(c.useEffect(()=>{let w=!0;return e?.status().then(b=>{w&&(s(b),a(b.settings))}).catch(()=>{w&&(p(!0),m(t?"无法读取润色设置。":"Could not load polishing settings."))}),()=>{w=!1}},[e]),!e)return null;const S=async w=>{h(!0),m(""),p(!1);try{const b=await e.save(i,w);s(b),a(b.settings),l(""),m(t?"已保存":"Saved"),window.dispatchEvent(new Event("vibelet.speech.changed"))}catch{p(!0),m(t?"保存失败,请检查 HTTPS API 地址、模型和提示词。":"Save failed. Check the HTTPS API URL, model and prompts.")}finally{h(!1)}};return r.jsxs("section",{className:"control-section compact-section speech-polish-settings",children:[r.jsx("h2",{children:t?"语音润色":"Voice polishing"}),r.jsxs("label",{className:"speech-enabled",children:[r.jsx("input",{type:"checkbox",role:"switch","aria-checked":i.enabled,className:"settings-switch",checked:i.enabled,disabled:!n||u,onChange:async w=>{const b={...i,enabled:w.target.checked};a(b),h(!0),m(""),p(!1);try{const y=await e.save({...n.settings,enabled:b.enabled});s(y),a(b),window.dispatchEvent(new Event("vibelet.speech.changed"))}catch{a(i),p(!0),m(t?"无法保存开关设置":"Could not save setting")}finally{h(!1)}}}),t?"启用语音润色":"Enable voice polishing"]}),i.enabled&&r.jsxs("fieldset",{disabled:!n||u,className:"speech-polish-fields",children:[r.jsx("p",{className:"empty-copy",children:t?"识别后轻度整理口误、重复和标点,保留原意。转写文字会发送到你配置的模型;失败时保留原始文字,仅填入草稿。":"Lightly correct slips, repetition and punctuation while preserving meaning. Transcripts are sent to your configured model. Failures keep the original text; nothing is sent from your draft."}),r.jsxs("label",{className:"field",children:[r.jsx("span",{children:t?"API 地址":"API URL"}),r.jsx("input",{type:"url",value:i.baseUrl,onChange:w=>a({...i,baseUrl:w.target.value}),autoComplete:"off"})]}),r.jsxs("label",{className:"field",children:[r.jsx("span",{children:t?"模型":"Model"}),r.jsx("input",{value:i.model,onChange:w=>a({...i,model:w.target.value}),autoComplete:"off"})]}),r.jsxs("label",{className:"field",children:[r.jsx("span",{children:t?"润色 API Key":"Polishing API Key"}),r.jsx("input",{type:"password",autoComplete:"off",value:o,onChange:w=>l(w.target.value),placeholder:n?.configured?t?"已保存 · 留空保留":"Saved · leave blank to keep":"API Key"})]}),r.jsx("p",{className:"empty-copy",children:n?.persistence==="encrypted"?t?"密钥加密保存在这台 Mac。支持 OpenAI 兼容接口。":"Key encrypted on this Mac. Supports OpenAI-compatible APIs.":t?"密钥仅保留在当前页面,刷新后需重新填写。Web API 需允许跨域访问。":"Key kept only in this page; enter it again after reload. The API must allow cross-origin requests."}),i.enabled&&!n?.configured&&!o.trim()&&r.jsx("p",{className:"empty-copy",children:t?"请填写 API Key 并保存,润色才能生效。":"Enter and save an API key to use polishing."}),r.jsxs("details",{className:"speech-polish-advanced",children:[r.jsx("summary",{children:t?"自定义提示词":"Custom prompts"}),r.jsxs("label",{className:"field",children:[r.jsx("span",{children:t?"中文提示词":"Chinese prompt"}),r.jsx("textarea",{rows:5,value:i.promptZh,onChange:w=>a({...i,promptZh:w.target.value})})]}),r.jsxs("label",{className:"field",children:[r.jsx("span",{children:t?"英文提示词":"English prompt"}),r.jsx("textarea",{rows:5,value:i.promptEn,onChange:w=>a({...i,promptEn:w.target.value})})]}),r.jsx("button",{type:"button",className:"icon-text-button",onClick:()=>a({...i,promptZh:xs.promptZh,promptEn:xs.promptEn}),children:t?"恢复默认提示词":"Reset prompts"})]}),r.jsxs("div",{className:"attention-actions",children:[r.jsx("button",{type:"button",className:"icon-text-button",onClick:()=>{S(o.trim()||void 0)},children:t?"保存润色设置":"Save polishing settings"}),n?.configured&&r.jsx("button",{type:"button",className:"icon-text-button",onClick:()=>{S("")},children:t?"移除润色密钥":"Remove polishing key"})]})]}),d&&r.jsx("p",{role:g?"alert":"status",className:g?"error-copy":"empty-copy",children:d})]})}const gh={en:{title:"Voice input",disclosure:"Recording adds text to your draft without sending it. Audio is uploaded to Deepgram Nova-3 and billed to your Deepgram account.",saved:"Saved; your key is never displayed",session:"The key is kept only in this page’s memory. Enter it again after reloading or closing the page.",secure:"The key is encrypted on this Mac.",save:"Save API key",remove:"Remove API key",enabled:"Enable voice input",unsupported:"Recording requires a secure connection and a browser that supports WebM audio recording."},zh:{title:"语音输入",disclosure:"录音后将文字填入草稿,不会自动发送。音频会上传到 Deepgram Nova-3,并按你的 Deepgram 账户计费。",saved:"已保存,密钥不会回显",session:"密钥只保留在当前页面内存中,刷新或关闭页面后需要重新填写。",secure:"密钥会在此 Mac 上加密保存。",save:"保存密钥",remove:"移除密钥",enabled:"启用语音输入",unsupported:"录音需要安全连接,以及支持 WebM 音频录制的浏览器。"},"zh-TW":{title:"語音輸入",disclosure:"錄音後將文字填入草稿,不會自動傳送。音訊會上傳到 Deepgram Nova-3,並按你的 Deepgram 帳戶計費。",saved:"已儲存,金鑰不會回顯",session:"金鑰只保留在目前頁面記憶體中,重新整理或關閉頁面後需要重新填寫。",secure:"金鑰會在此 Mac 上加密儲存。",save:"儲存金鑰",remove:"移除金鑰",enabled:"啟用語音輸入",unsupported:"錄音需要安全連線,以及支援 WebM 音訊錄製的瀏覽器。"}};function yh(){const e=se().speechSettings,t=gh[Je(Xe().language)],[n,s]=c.useState(),[i,a]=c.useState(""),[o,l]=c.useState(!1),[u,h]=c.useState(""),[d,m]=c.useState(Ge().getItem("vibelet.web.voice.enabled")==="true"),g=!!(globalThis.isSecureContext&&typeof globalThis.navigator?.mediaDevices?.getUserMedia=="function"&&globalThis.MediaRecorder?.isTypeSupported("audio/webm"));c.useEffect(()=>{let y=!0;return e?.status().then(f=>{y&&s(f)}).catch(()=>{y&&h("Unable to load speech settings.")}),()=>{y=!1}},[e]);const p=y=>{m(y),Ge().setItem("vibelet.web.voice.enabled",String(y)),window.dispatchEvent(new Event("vibelet.speech.changed"))},S=async y=>{if(!(!e||o)){l(!0),h("");try{s(await e.saveKey(y)),a(""),y||p(!1),window.dispatchEvent(new Event("vibelet.speech.changed"))}catch(f){h(f instanceof Error?f.message:String(f))}finally{l(!1)}}};if(!e)return null;const w=n?.engine==="volcengine",b=[...n?.systemAvailable?[{value:"system",label:"macOS · Apple"}]:[],{value:"deepgram",label:"Deepgram · Nova-3"},{value:"volcengine",label:Je(Xe().language)==="en"?"Volcengine · ASR Flash":"火山引擎 · 录音识别"}];return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"control-section compact-section speech-input-settings",children:[r.jsx("h2",{children:t.title}),r.jsxs("label",{className:"speech-enabled",children:[r.jsx("input",{type:"checkbox",role:"switch","aria-checked":d,className:"settings-switch",checked:d,disabled:!g,onChange:y=>p(y.target.checked)}),t.enabled]}),d&&r.jsxs(r.Fragment,{children:[e.setEngine&&r.jsxs("div",{className:"field speech-engine-field",children:[r.jsx("span",{children:Je(Xe().language)==="en"?"Recognition engine":"识别引擎"}),r.jsx(An,{icon:ui,menuLabel:"Speech engine",label:b.find(y=>y.value===n?.engine)?.label??"Deepgram · Nova-3",options:b,value:n?.engine??"deepgram",disabled:o,onSelect:async y=>{l(!0),h(""),a("");try{s(await e.setEngine(y)),window.dispatchEvent(new Event("vibelet.speech.changed"))}catch(f){h(f instanceof Error?f.message:String(f))}finally{l(!1)}}})]}),r.jsx("p",{className:"empty-copy",children:n?.engine==="system"?Je(Xe().language)==="en"?"No API key needed. macOS 26+ uses on-device recognition and may download a language model on first use. Earlier versions may send audio to Apple. Text is added to your draft without sending.":"无需 API Key。macOS 26 及以上在本机识别,首次可能下载语言模型;较旧系统可能将音频发送给 Apple。文字只填入草稿,不会自动发送。":w?Je(Xe().language)==="en"?"Audio is sent to Volcengine ASR Flash (volc.bigasr.auc_turbo), billed to your account. Enable this voice resource and use its API Key. Text only enters your draft.":"音频会上传至火山引擎录音识别极速版(volc.bigasr.auc_turbo),按你的账户计费。请开通此语音资源并填写语音 API Key,文字只追加到草稿。":t.disclosure}),n?.engine!=="system"&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"empty-copy",children:n?.persistence==="encrypted"?t.secure:t.session}),r.jsxs("label",{className:"field",children:[r.jsx("span",{children:w?"火山引擎 API Key":"Deepgram API Key"}),r.jsx("input",{type:"password",autoComplete:"off",value:i,onChange:y=>a(y.target.value),placeholder:n?.configured?t.saved:"API Key"})]}),r.jsxs("div",{className:"attention-actions",children:[r.jsx("button",{type:"button",className:"icon-text-button",disabled:o||!i.trim(),onClick:()=>{S(i)},children:t.save}),n?.configured&&r.jsx("button",{type:"button",className:"icon-text-button",disabled:o,onClick:()=>{S("")},children:t.remove})]})]})]}),!g&&r.jsx("p",{className:"empty-copy",children:t.unsupported}),u&&r.jsx("p",{role:"alert",className:"error-copy",children:u})]}),d&&r.jsx(ph,{})]})}function Vr(e){const t=e?.fiveHour??e?.weekly,n=Number(t?.usedPercent);return Number.isFinite(n)?{availablePercent:Math.round(Math.max(0,Math.min(100,100-n))),resetsAt:t?.resetsAt??""}:null}function bh(e,t=Date.now()){const n=new Date(e);if(!Number.isFinite(n.getTime())||n.getTime()<=t)return null;const s=i=>String(i).padStart(2,"0");return`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())} ${s(n.getHours())}:${s(n.getMinutes())}`}function vh(e){const t=[],n=Vr(e.codex),s=Vr(e.claude);return n!==null&&t.push({agent:"codex",label:"Codex",...n}),s!==null&&t.push({agent:"claude",label:"Claude",...s}),t}function xh(e){return e?"success":"warning"}function wh(e,t){return!e||t===null?"warning":t<150?"success":t<500?"warning":"danger"}function Sh({connected:e,latencyMs:t,limits:n,t:s}){const i=vh({codex:n.codex?.limits,claude:n.claude?.limits}),[a,o]=c.useState(0);c.useEffect(()=>{if(o(0),i.length<2)return;const m=setInterval(()=>o(g=>(g+1)%i.length),4e3);return()=>clearInterval(m)},[i.length]);const l=i[a%i.length],u=l?bh(l.resetsAt):null,h=l?`${l.label} ${l.availablePercent}%`:s.quotaUnavailable,d=e?t===null?s.latencyMeasuring:`${t} ms`:s.latencyDisconnected;return r.jsxs("div",{className:"connection-indicators",children:[r.jsxs("span",{role:"img",className:"connection-quota",title:`${s.remainingQuota}: ${h} · ${u?s.quotaResetsAt.replace("{time}",u):s.quotaResetUnavailable}${e?"":` · ${s.latencyDisconnected}`}`,"aria-label":`${s.remainingQuota}: ${h}${e?"":` · ${s.latencyDisconnected}`}`,children:[r.jsx("span",{className:"connection-quota-dot",style:{background:`var(--${xh(e)})`}}),r.jsx("span",{className:"connection-quota-text",children:h})]}),r.jsxs("span",{role:"img",className:"connection-latency",style:{color:`var(--${wh(e,t)})`},"aria-label":`${s.connectionLatency}: ${d}`,children:[r.jsx(ri,{size:11,"aria-hidden":"true"}),r.jsx("span",{className:"connection-latency-text",children:d})]})]})}function kh({workspace:e}){const{phase:t,clientRef:n,pairing:s,t:i}=e,[a,o]=c.useState(null),[l,u]=c.useState({});return c.useEffect(()=>{u({})},[s?.daemonId]),c.useEffect(()=>{const h=n.current;if(o(null),t!=="connected"||!h)return;let d=!0;const m=h.onLatency(o),g=()=>{for(const S of["codex","claude"])h.request({action:"usage.limits.fetch",id:h.makeId("header-usage"),agent:S},{timeoutMs:15e3}).then(w=>{d&&n.current===h&&u(b=>({...b,[S]:w}))}).catch(()=>{})};g();const p=setInterval(g,6e4);return()=>{d=!1,m(),clearInterval(p)}},[t,n,s?.daemonId]),r.jsx(Sh,{connected:t==="connected",latencyMs:a,limits:l,t:i})}function jh({value:e,t,showSession:n=!0,onChange:s}){const i=[...n?[{tab:"session",label:t.session,Icon:mi}]:[],{tab:"files",label:t.files,Icon:Xn},{tab:"terminal",label:t.terminal,Icon:ls},{tab:"browser",label:t.browser,Icon:ci}];return r.jsx("div",{className:"control-tabs",children:i.map(({tab:a,label:o,Icon:l})=>r.jsxs("button",{"aria-label":o,"aria-pressed":e===a,className:e===a?"selected":"",onClick:()=>s(a),title:o,type:"button",children:[r.jsx(l,{"aria-hidden":"true"}),r.jsx("span",{children:o})]},a))})}function Ch(){const[e,t]=c.useState(null);return c.useEffect(()=>{let n=null,s=null;const i=()=>{n&&s!==null&&n.setAttribute("title",s),n=null,s=null,t(null)},a=m=>{if(!(m instanceof Element))return null;const g=m.closest("button, a");return!g?.closest(".control-pane, .control-tabs, .header-actions, .right-resize-handle")||g.textContent?.trim()?null:g},o=m=>{if(m===n||(i(),!m))return;const g=m.getAttribute("title")||m.getAttribute("aria-label");if(!g)return;n=m,s=m.getAttribute("title"),s!==null&&m.removeAttribute("title");const p=m.getBoundingClientRect(),S=p.bottom+42>window.innerHeight,w=p.right>window.innerWidth-140?"end":p.left<140?"start":"center";t({label:g,left:w==="end"?p.right:w==="start"?p.left:p.left+p.width/2,top:S?p.top-7:p.bottom+7,above:S,align:w})},l=m=>o(a(m.target)),u=m=>{n&&m.relatedTarget instanceof Node&&n.contains(m.relatedTarget)||a(m.target)===n&&i()},h=m=>o(a(m.target)),d=m=>{a(m.target)===n&&i()};return document.addEventListener("pointerover",l),document.addEventListener("pointerout",u),document.addEventListener("focusin",h),document.addEventListener("focusout",d),()=>{document.removeEventListener("pointerover",l),document.removeEventListener("pointerout",u),document.removeEventListener("focusin",h),document.removeEventListener("focusout",d),i()}},[]),e?it.createPortal(r.jsx("div",{className:"right-sidebar-icon-hint",role:"tooltip",style:{left:e.left,top:e.top,transform:`translate(${e.align==="end"?"-100%":e.align==="start"?"0":"-50%"}, ${e.above?"-100%":"0"})`},children:e.label}),document.body):null}function Ih({chinese:e}){const[t,n]=c.useState(es),[s,i]=c.useState(null),[a,o]=c.useState(""),l=u=>{xc(u),n(u),o("")};return r.jsxs("section",{className:"control-section compact-section workspace-shortcut-settings",children:[r.jsx("h2",{children:e?"应用内快捷键":"In-app shortcuts"}),r.jsx("p",{className:"empty-copy",children:e?"点击组合键后直接按键录制。Esc 取消,退格键清除。新建标签会沿用当前终端或浏览器;其他页面默认新建浏览器标签。":"Click a shortcut to record it. Escape cancels; Backspace clears. New tab follows the current terminal or browser; elsewhere it opens a browser tab."}),sn.map(u=>r.jsxs("div",{className:"workspace-shortcut-row",children:[r.jsx("span",{children:e?u.zh:u.en}),r.jsx("button",{type:"button","data-shortcut-recording":s===u.id?"true":void 0,"aria-label":`${e?"设置快捷键:":"Set shortcut: "}${e?u.zh:u.en}`,onClick:()=>{i(u.id),o("")},onBlur:()=>i(null),onKeyDown:h=>{if(s!==u.id)return;if(h.preventDefault(),h.stopPropagation(),h.key==="Escape"){i(null),o("");return}if(h.key==="Backspace"||h.key==="Delete"){l({...t,[u.id]:""}),i(null);return}const d=vi(h.nativeEvent);if(!d)return;const m=vc(u.id,d,t);if(m){const g=sn.find(p=>p.id===m);o(m==="reserved"?e?"此组合键用于系统菜单或编辑操作,请换一个组合。":"Reserved for a system menu or editing action. Choose another combination.":`${e?"已用于:":"Already assigned to: "}${e?g?.zh:g?.en}`);return}l({...t,[u.id]:d}),i(null)},children:s===u.id?e?"按下快捷键…":"Press shortcut…":xi(er(u.id,t))||(e?"未设置":"Not set")})]},u.id)),a&&r.jsx("p",{role:"alert",children:a}),r.jsx("div",{className:"attention-actions",children:r.jsx("button",{type:"button",onClick:()=>{l({}),i(null)},children:e?"恢复默认快捷键":"Restore defaults"})}),r.jsx("p",{className:"empty-copy",children:e?"⌘N 新建会话,⌘, 打开设置;⌘W 保留为关闭窗口。关闭标签默认使用 ⌘⌥W。":"⌘N creates a session; ⌘, opens settings; ⌘W closes the window. Close tab defaults to ⌘⌥W."})]})}function Nh({children:e,t,onClose:n}){const s=c.useRef(null);return c.useEffect(()=>{const i=document.getElementById("vibelet-workspace");return i&&(i.inert=!0),s.current?.focus(),()=>{i&&(i.inert=!1)}},[]),it.createPortal(r.jsxs("section",{className:"browser-settings-page","aria-label":t.settings,onKeyDown:i=>{if(i.key==="Escape"&&!i.defaultPrevented&&(i.preventDefault(),n()),i.key!=="Tab")return;const a=[...i.currentTarget.querySelectorAll("button:not(:disabled),input:not(:disabled),a[href]")].filter(u=>u.getBoundingClientRect().width>0),o=a[0],l=a.at(-1);i.shiftKey&&document.activeElement===o&&(i.preventDefault(),l?.focus()),!i.shiftKey&&document.activeElement===l&&(i.preventDefault(),o?.focus())},children:[r.jsxs("button",{ref:s,type:"button",className:"icon-text-button",onClick:n,children:["← ",t.chat]}),r.jsx("h1",{children:t.settings}),r.jsxs("div",{className:"browser-settings-body",children:[r.jsx(Si,{}),e,r.jsx(Ih,{chinese:t.browser!=="Browser"})]})]}),document.body)}function Eh({children:e,collapsed:t,t:n,value:s,showSession:i,onChange:a,onResize:o}){const l=yr("right",d=>{(d==="terminal"||d==="browser")&&a(d)}),u=se().toolbarTarget?.("controls"),h=r.jsx(jh,{value:s,t:n,showSession:i,onChange:a});return s==="admin"&&se().kind==="browser"?r.jsx(Nh,{t:n,onClose:()=>a("files"),children:e}):r.jsxs(r.Fragment,{children:[r.jsx(Ch,{}),u&&!t?it.createPortal(h,u):null,r.jsx("button",{"aria-label":n.resizeControlsSidebar,"aria-hidden":t,className:"resize-handle right-resize-handle",disabled:t,onPointerDown:o,title:n.resizeControlsSidebar,type:"button",children:r.jsx("span",{})}),r.jsx("div",{className:"workspace-control-sidebar-motion",inert:t,"aria-hidden":t,children:r.jsxs("aside",{"aria-label":n.controls,className:"control-pane",...l,children:[!u&&r.jsx("div",{className:"control-pane-toolbar",children:h}),e]})})]})}function Rh({path:e,label:t,zh:n}){const{copyText:s,feedback:i}=or(n?"已复制路径":"Path copied",n?"复制失败,请重试":"Copy failed. Please try again."),a=i?.message??t;return r.jsx("button",{type:"button",title:a,"aria-label":a,onClick:()=>{s(e)},children:i?i.tone==="success"?r.jsx(Lt,{}):r.jsx(Me,{}):r.jsx(yn,{})})}function um(e){return/\.(md|mdx|markdown|mdown)$/i.test(e)}function ss(e,t,n){const s=t.split(";")[0].trim().toLowerCase();return s.startsWith("image/")?"image":s==="text/html"||/\.html?$/i.test(e)?"html":s==="application/pdf"||/\.pdf$/i.test(e)?"pdf":s.startsWith("audio/")||/\.(mp3|wav|m4a|ogg|flac)$/i.test(e)?"audio":s.startsWith("video/")||/\.(mp4|webm|mov)$/i.test(e)?"video":n?"text":"unsupported"}function Ah(e){return`<!doctype html><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data: blob: https:; media-src data: blob:; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src 'none'; base-uri 'none'; form-action 'none'">${e}`}function Th({file:e}){const[t,n]=c.useState(!1),s=rs(()=>n(!1),void 0,t),i=$n(),a=Je(Xe().language),o=a==="en"?"Close":a==="zh-TW"?"關閉":"关闭",l=se().pdfPreviewUrl?.(e.path,e.cwd)??e.objectUrl;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:"icon-text-button",type:"button",onClick:()=>n(!0),children:[r.jsx(Ys,{"aria-hidden":"true"}),i.pdfPreview]}),t&&it.createPortal(r.jsx("div",{className:"remote-document-layer",onPointerDown:u=>{u.target===u.currentTarget&&n(!1)},children:r.jsxs("div",{ref:s,className:"remote-document-dialog","aria-label":i.pdfPreview,role:"dialog","aria-modal":"true",tabIndex:-1,children:[r.jsxs("header",{children:[r.jsx("span",{children:e.path.split("/").pop()}),r.jsx("button",{className:"icon-button",type:"button","aria-label":o,title:o,onClick:()=>n(!1),children:r.jsx(Me,{"aria-hidden":"true"})})]}),r.jsx("iframe",{title:i.pdfPreview,src:`${l}#toolbar=1&navpanes=0&view=Fit`})]})}),document.body)]})}function ca({file:e}){const[t,n]=c.useState(!1),s=$n(),i=ss(e.path,e.contentType,e.kind==="text");if(t)return r.jsx("p",{className:"empty-copy",role:"status",children:s.mediaError});if(i==="html"){const a=e.dirty?void 0:se().htmlPreviewUrl?.(e.path,e.cwd);return r.jsx("iframe",{className:"remote-document-preview",sandbox:"allow-scripts",title:s.htmlPreview,src:a,srcDoc:a?void 0:Ah(e.text)})}return e.objectUrl?i==="image"?r.jsx("div",{className:"remote-image-viewer",children:r.jsx("img",{className:"remote-image",src:e.objectUrl,alt:e.path,onError:()=>n(!0)})}):i==="audio"?r.jsx("audio",{"aria-label":s.audioPreview,controls:!0,preload:"metadata",src:e.objectUrl,onError:()=>n(!0)}):i==="video"?r.jsx("video",{"aria-label":s.videoPreview,controls:!0,playsInline:!0,preload:"metadata",src:e.objectUrl,onError:()=>n(!0)}):i==="pdf"?r.jsx(Th,{file:e}):r.jsx("p",{className:"empty-copy",children:s.mediaError}):null}const Mh=c.lazy(()=>gt(()=>import("./file-editor-FileCodeEditor-CInvSSQe.js").then(e=>e.Q),__vite__mapDeps([17,1,2,18])).then(e=>({default:e.FileCodeEditor})));function Ph({file:e,onOpenRemoteFile:t,onTextChange:n}){const[s,i]=c.useState("preview"),a=ss(e.path,e.contentType,!0)==="html",o=Je(Xe().language)!=="en";return r.jsxs(r.Fragment,{children:[a&&r.jsxs("div",{className:"segmented editor-mode-tabs",children:[r.jsx("button",{type:"button",className:s==="edit"?"selected":"",onClick:()=>i("edit"),children:o?"编辑":"Edit"}),r.jsx("button",{type:"button",className:s==="preview"?"selected":"",onClick:()=>i("preview"),children:o?"预览":"Preview"})]}),a&&s==="preview"?r.jsx(ca,{file:e}):r.jsx(c.Suspense,{fallback:r.jsx("pre",{className:"remote-editor",children:e.text}),children:r.jsx(Mh,{path:e.path,cwd:e.cwd,text:e.text,onChange:n,onOpenFile:t})})]})}const zs="vibelet:file-operation-before",Ks="vibelet:file-operation-done";function mn(e,t=""){const n=e.replace(/\\/g,"/"),s=/^(\/|[a-z]:\/|~)/i.test(n)?n:`${t.replace(/\\/g,"/")}/${n}`,i=[];for(const a of s.split("/"))!a||a==="."||(a===".."?i.pop():i.push(a));return`${s.startsWith("/")?"/":""}${i.join("/")}`}function Is(e,t,n){const s=mn(e,n),i=mn(t,n);return s===i||s.startsWith(`${i}/`)}async function hm(e,t){const n=new CustomEvent(zs,{cancelable:!0,detail:{...e,daemonId:t.daemonId,cwd:e.sourceCwd??e.cwd}});if(!window.dispatchEvent(n))throw new Error("unsaved_changes");const s=await fetch("/file-operation",{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t.pairToken}`},body:JSON.stringify(e)}),i=await s.text();let a;try{a=JSON.parse(i)}catch{throw new Error(s.status===404||/^Vibelet Daemon v/.test(i)?"daemon_update_required":"operation_failed")}if(s.status===404&&a.error!=="ENOENT")throw new Error("daemon_update_required");if(!s.ok)throw new Error(a.error??"operation_failed");return pr()?.daemonId===t.daemonId&&window.dispatchEvent(new CustomEvent(Ks,{detail:{...a,daemonId:t.daemonId,cwd:e.sourceCwd??e.cwd,source:e.path}})),a}function Dh(e){const t=c.useRef(e);t.current=e,c.useEffect(()=>{const n=i=>{const{detail:a}=i,o=t.current;if(o.daemonId!==a.daemonId||a.action==="copy"||a.action==="restore")return;[...Object.values(o.files),o.remoteFile].filter(Boolean).some(u=>u.dirty&&Is(u.path,a.path,a.cwd))&&i.preventDefault()},s=i=>{const{detail:a}=i,o=t.current;if(o.daemonId!==a.daemonId||a.action==="copy"||a.action==="restore")return;const l=a.source??a.path,u=m=>{if(!Is(m.path,l,a.cwd))return m;if(a.action==="delete")return null;const g=`${a.target}${mn(m.path,a.cwd).slice(mn(l,a.cwd).length)}`;return{...m,path:g}};o.setFiles(m=>Object.fromEntries(Object.values(m).flatMap(g=>{const p=u(g);return p?[[p.path,p]]:[]}))),o.active&&o.files[o.active]&&o.setActive(u(o.files[o.active])?.path??null),o.setRemoteFile(m=>m&&u(m));const h=new URL(window.location.href),d=h.searchParams.get("file");d&&Is(d,l,a.cwd)&&(a.action==="delete"?h.searchParams.delete("file"):h.searchParams.set("file",`${a.target}${mn(d,a.cwd).slice(mn(l,a.cwd).length)}`),window.history.replaceState(null,"",h.href))};return window.addEventListener(zs,n),window.addEventListener(Ks,s),()=>{window.removeEventListener(zs,n),window.removeEventListener(Ks,s)}},[])}function _h({workspace:e,children:t}){const n=ln(),s=yr("center"),[i,a]=c.useState({}),[o,l]=c.useState(null),[u,h]=c.useState(null),d=c.useRef({files:i,remoteFile:e.remoteFile,daemonId:e.pairing?.daemonId});d.current={files:i,remoteFile:e.remoteFile,daemonId:e.pairing?.daemonId};const m=c.useRef(null),g=c.useRef(e.activeSessionId),p=Je(Xe().language)!=="en";c.useEffect(()=>{d.current.files={},a({}),l(null),m.current=null},[e.pairing?.daemonId]),c.useEffect(()=>{if(!e.remoteFile){m.current=null;return}const k=e.remoteFile,j=d.current.files[k.path];if(j?.dirty&&!k.dirty&&j.cwd===k.cwd&&j.text!==k.text){e.setRemoteFile(j),l(j.path),n.setCenter(null);return}a(E=>({...E,[k.path]:k})),m.current!==k.path&&(l(k.path),n.setCenter(null)),m.current=k.path},[e.remoteFile]),c.useEffect(()=>{const k=g.current;g.current=e.activeSessionId,!(!k||k===e.activeSessionId)&&(l(null),m.current=null)},[e.activeSessionId]);const S=k=>{n.setCenter(null),e.setRemoteFile(i[k]),l(k)},w=async k=>{const j=i[k],E=e.pairing?.daemonId;if(!j)return;const x=pn();j.dirty&&!await As({title:x.discard,message:k,confirmLabel:x.discardAction,danger:!0})||d.current.daemonId!==E||d.current.files[k]?.text!==j.text||(a(C=>{const I={...C};return delete I[k],I}),k===o&&(l(null),m.current=null,e.setRemoteFile(null)))};Dh({daemonId:e.pairing?.daemonId,files:i,active:o,remoteFile:e.remoteFile,setFiles:a,setActive:l,setRemoteFile:e.setRemoteFile}),c.useEffect(()=>{const k=j=>{const E=j.detail;if(E==="closeTab"){n.center?n.close(n.center):o&&w(o);return}const x=[null,...Object.keys(i),...n.items.filter(N=>N.location==="center").map(N=>N.id)],C=x.indexOf(n.center||o),I=x[(Math.max(C,0)+(E==="nextTab"?1:x.length-1))%x.length];I?i[I]?S(I):n.setCenter(I):(l(null),n.setCenter(null))};return window.addEventListener(Ms,k),()=>window.removeEventListener(Ms,k)},[i,o,n]);const b=o?i[o]:null,y=async()=>{const k=e.remoteFile;!k||!await As({message:e.t.confirmOverwrite(Ht(k.path)),danger:!0})||d.current.remoteFile===k&&await e.saveRemoteFile({force:!0})},f=se().toolbarTarget?.("conversation"),v=b&&!n.center&&r.jsxs("header",{className:"document-file-header",role:"toolbar","aria-label":p?"文件操作":"File actions",children:[r.jsx("button",{type:"button",title:e.t.download,"aria-label":e.t.download,onClick:()=>{e.downloadRemoteFile()},children:r.jsx(is,{})}),r.jsx(Rh,{path:b.path,label:e.t.copyPath,zh:p},b.path),b.kind==="text"&&r.jsx("button",{type:"button",title:e.t.saveFile,"aria-label":e.t.saveFile,disabled:!b.dirty||e.busy,onClick:()=>{e.saveRemoteFile()},children:r.jsx(Vo,{})})]});return r.jsx(Li.Provider,{value:u,children:r.jsxs("div",{className:"workspace-documents",...s,children:[!f&&r.jsx("div",{className:"chat-header document-conversation-header",ref:h}),(Object.keys(i).length>0||n.items.some(k=>k.location==="center"))&&r.jsxs("div",{className:"document-tabs",children:[r.jsxs("div",{className:"document-tab-items",role:"tablist","aria-label":p?"工作区标签页":"Workspace tabs",children:[r.jsx("button",{role:"tab","aria-selected":!o&&!n.center,onClick:()=>{l(null),n.setCenter(null),m.current=null},type:"button",children:e.t.chat}),Object.values(i).map(k=>r.jsxs("div",{className:"document-tab","data-active":!n.center&&o===k.path,children:[r.jsxs("button",{type:"button",role:"tab","aria-selected":!n.center&&o===k.path,title:k.path,onClick:()=>S(k.path),children:[r.jsx(Ys,{}),r.jsxs("span",{className:"document-tab-label",children:[Ht(k.path),k.dirty?" ·":""]})]}),r.jsx("button",{type:"button",className:"document-tab-close",title:e.t.close,"aria-label":`${e.t.close} ${Ht(k.path)}`,onClick:()=>w(k.path),children:r.jsx(Me,{})})]},k.path)),r.jsx(Hs,{location:"center",t:e.t})]}),v]}),r.jsx("div",{hidden:!!o||!!n.center,className:"document-chat",children:t}),r.jsx("div",{hidden:!n.center,className:"dock-center-content",children:r.jsx(ns,{location:"center"})}),b&&!n.center&&r.jsxs("section",{className:"document-file",role:"tabpanel","aria-label":Ht(b.path),children:[b.kind==="text"?r.jsx(Ph,{file:b,onOpenRemoteFile:(k,j)=>{e.openRemoteFile(k,j,{updateRoute:!0})},onTextChange:k=>e.setRemoteFile(j=>j&&{...j,text:k,dirty:!0})},b.path):r.jsx(ca,{file:b},b.path),e.remoteFileConflict&&r.jsxs("div",{role:"alert",className:"inline-notice warning",children:[r.jsx("span",{children:e.t.remoteFileConflict(b.path)}),r.jsx("button",{type:"button",onClick:()=>{y()},children:e.t.forceSave})]})]})]})})}function Lh(e){const t=ln(),[n,s]=c.useState(es),i=c.useRef({workspace:e,dock:t,shortcuts:n});i.current={workspace:e,dock:t,shortcuts:n},c.useEffect(()=>{const a=()=>s(es()),o=l=>{if(l.defaultPrevented||l.isComposing||l.repeat||document.querySelector('[data-shortcut-recording="true"], [role="dialog"], .desktop-workspace-container[hidden], .browser-settings-page'))return;const u=vi(l);if(!u)return;const{workspace:h,dock:d,shortcuts:m}=i.current,g=sn.find(y=>er(y.id,m)===u)?.id;if(!g)return;l.preventDefault(),l.stopPropagation();const p=h.controlTab==="terminal"?"terminal":"browser",S=d.items.find(y=>y.id===d.center),w=l.target instanceof Element&&!!l.target.closest('.workspace-control-sidebar-motion, .dock-surface[data-location="right"]'),b=!w&&S?S:d.items.find(y=>y.id===d.right[p]);switch(g){case"leftSidebar":h.setLeftSidebarCollapsed(y=>!y);break;case"rightSidebar":h.setRightSidebarCollapsed(y=>!y);break;case"files":case"terminal":case"browser":h.setControlTabAndOpen(g);break;case"searchSessions":h.setLeftSidebarCollapsed(!1),window.dispatchEvent(new Event("vibelet.session-search"));break;case"newTab":{const y=S?.kind==="terminal"||S?.kind==="browser"?S.kind:p;d.add(y,h.t[y],h.cwd),h.setControlTabAndOpen(y);break}case"moveTab":b&&d.move(b.id,b.location==="center"?"right":"center");break;case"diff":h.activeSession&&h.setDiffSessionId(h.activeSession.sessionId);break;case"closeTab":case"nextTab":case"previousTab":if(w)if(g==="closeTab")b&&d.close(b.id);else{const y=d.items.filter(f=>f.location==="right"&&f.kind===p);y.length&&d.setRight(f=>({...f,[p]:y[(Math.max(0,y.findIndex(v=>v.id===b?.id))+(g==="nextTab"?1:y.length-1))%y.length].id}))}else window.dispatchEvent(new CustomEvent(Ms,{detail:g}));break}};return window.addEventListener(Ts,a),window.addEventListener("keydown",o),()=>{window.removeEventListener(Ts,a),window.removeEventListener("keydown",o)}},[])}const la="vibelet.web.savedTargets",da=12;function $h(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Fh(e){if(!$h(e)||typeof e.daemonId!="string"||typeof e.deviceId!="string"||typeof e.pairToken!="string"||typeof e.pairedAt!="string")return null;const t=typeof e.displayName=="string"?e.displayName:void 0,n=typeof e.label=="string"&&e.label.trim()?e.label.trim():t||e.daemonId.slice(0,10);return{daemonId:e.daemonId,deviceId:e.deviceId,pairToken:e.pairToken,pairedAt:e.pairedAt,displayName:t,webSocketUrl:typeof e.webSocketUrl=="string"?e.webSocketUrl:void 0,label:n,lastConnectedAt:typeof e.lastConnectedAt=="string"?e.lastConnectedAt:void 0}}function ua(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const s of e){const i=Fh(s);if(!(!i||t.has(i.daemonId))&&(t.add(i.daemonId),n.push(i),n.length>=da))break}return n}function Oh(e=Ge()){const t=e.getItem(la);if(!t)return[];try{return ua(JSON.parse(t))}catch{return[]}}function ha(e,t=Ge()){t.setItem(la,JSON.stringify(ua(e)))}function qh(e,t,n=new Date().toISOString()){const s=e.find(a=>a.daemonId===t.daemonId);return[{...t,label:s?.label||t.displayName||t.daemonId.slice(0,10),lastConnectedAt:n},...e.filter(a=>a.daemonId!==t.daemonId)].slice(0,da)}function Wh(e,t,n){const s=n.trim();return s?e.map(i=>i.daemonId===t?{...i,label:s}:i):e}function Hh(e,t){return e.filter(n=>n.daemonId!==t)}function Bh(e){return e.filter(t=>t.archived===!0).map(t=>t.sessionId)}function zh(e,t,n){return e.ok?{tone:"success",message:t.replace("{n}",String(e.archivedSessionIds.length))}:e.error==="timeout"?{tone:"error",message:n.timeout}:e.error==="not_connected"?{tone:"error",message:n.disconnected}:{tone:"error",message:n.generic.replace("{error}",e.error)}}async function Kh(e,t,n){if(!e?.isConnected)return{ok:!1,error:"not_connected"};try{const s=await e.request({action:"sessions.archiveSync",id:e.makeId("archive_sync"),mode:t,...t==="pull"?{}:{archivedSessionIds:n??[]}});return{ok:!0,archivedSessionIds:Array.isArray(s.archivedSessionIds)?s.archivedSessionIds.filter(i=>typeof i=="string"&&i.length>0):[]}}catch(s){return{ok:!1,error:s instanceof Error?s.message:String(s)}}}function Gh(e){const t=c.useCallback((f,v)=>{e.updateSessionListPreferences(k=>({...k,archiveSyncedDaemonIds:v==="synced"?{...k.archiveSyncedDaemonIds,[f]:!0}:k.archiveSyncedDaemonIds,archiveSyncCardDismissedDaemonIds:{...k.archiveSyncCardDismissedDaemonIds,[f]:!0}}))},[e]),n=c.useCallback((f,v)=>{const k=f==="pull"?e.t.archiveSyncSuccessPull:f==="pushMerge"?e.t.archiveSyncSuccessMerge:e.t.archiveSyncSuccessPush;if(e.setArchiveSyncStatus(zh(v,k,{timeout:e.t.archiveSyncFailedTimeout,disconnected:e.t.archiveSyncFailedDisconnected,generic:e.t.archiveSyncFailedGeneric})),!v.ok)return;const j=new Set(v.archivedSessionIds);e.setSessions(E=>E.map(x=>({...x,archived:j.has(x.sessionId)}))),e.pairingRef.current?.daemonId&&t(e.pairingRef.current.daemonId,"synced"),e.requestSessions({force:!0})},[t,e]),s=c.useCallback(async f=>{if(e.archiveSyncBusy)return;e.setArchiveSyncBusy(f),e.setArchiveSyncStatus(null);const v=await Kh(e.clientRef.current,f,Bh(e.displaySessions));n(f,v),e.setArchiveSyncBusy(null)},[n,e]),i=c.useCallback(()=>{e.pairing?.daemonId&&(t(e.pairing.daemonId,"dismissed"),e.setArchiveSyncStatus({tone:"success",message:e.t.archiveSyncSkipped}))},[t,e]),a=c.useCallback(async f=>{const v=e.clientRef.current;if(v?.isConnected&&!(f==="update"&&!await Tn(pn().update))&&!(f==="restart"&&!await Tn(pn().restart))&&!(e.clientRef.current!==v||!v.isConnected)){e.setAdmin(k=>({...k,loading:!0,action:f,statusText:""})),e.setErrorText(null);try{if(f==="update"){const k=ch(e.daemonMetadata.version),j=await v.request({action:"daemon.update",id:v.makeId("daemon_update"),...k?{channel:k}:{}});e.setAdmin(E=>({...E,loading:!1,action:null,statusText:j.alreadyRunning?"Connector update already running":"Connector update started"}));return}await v.request({action:"daemon.restart",id:v.makeId("daemon_restart")}),e.setAdmin(k=>({...k,loading:!1,action:null,statusText:"Connector restart requested"})),e.refreshDaemonMetadata()}catch(k){e.setAdmin(j=>({...j,loading:!1,action:null})),e.setErrorText(k instanceof Error?k.message:String(k))}}},[e]),o=c.useCallback(async()=>{if(!e.activeSession)return;const f=rl(e.activeSession,e.messages);il(sl(Et(e.activeSession),e.activeSession.sessionId),f),await navigator.clipboard?.writeText(f).catch(()=>{})},[e.activeSession,e.messages]),l=c.useCallback(async()=>{if(!("Notification"in window)){e.setNotificationPermission("unsupported"),e.setErrorText("Browser notifications are not supported.");return}const f=await Notification.requestPermission();e.notificationPermissionRef.current=f,e.setNotificationPermission(f),f==="granted"&&e.updateNotificationSettings({enabled:!0}),e.setStatusText(f==="granted"?"Browser notifications enabled":"Browser notifications not enabled")},[e]),u=c.useCallback(async()=>{const f=e.pairingRef.current;!await Tn(pn().forget)||e.pairingRef.current!==f||(e.intentionalDisconnectRef.current=!0,e.connectionAttemptIdRef.current+=1,Ui(),e.clientRef.current?.disconnect(),e.historyCacheRef.current={},e.historyCacheDaemonIdRef.current=null,e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([]),e.setPairing(null),e.setDaemonMetadata(vr),e.setPhase("missing-pair"),e.setStatusText(e.t.missingPair))},[e]),h=c.useCallback(f=>{if(f&&e.notificationPermission==="default"){l();return}e.updateNotificationSettings({enabled:f})},[e,l]),d=c.useCallback(f=>{e.connectWithPairingRef.current(f,!0)},[e]),m=c.useCallback(f=>e.saveTargets(Hh(e.savedTargets,f)),[e]),g=c.useCallback(f=>{e.setActiveSessionId(f.sessionId),e.setRenameTitle(f.customTitle??f.title??""),e.setDetailsOpen(!0)},[e]),p=c.useCallback((f,v)=>{const k=wa(v);e.updateSessionListPreferences(j=>({...j,directoryTags:Sa(j.directoryTags,f,k)}))},[e]),S=c.useCallback(f=>{e.setControlTab("files"),e.listDirectory(f,{updateRoute:!0})},[e]),w=c.useCallback(async f=>{try{await ar(Ii(f)),e.setStatusText(e.t.commandCopied)}catch{throw e.setErrorText(e.t.copyResumeFailed),new Error(e.t.copyResumeFailed)}},[e]),b=c.useRef(!1),y=c.useCallback(async f=>{if(b.current)return;const v=se(),k=e.pairingRef.current?.daemonId;if(!(!k||!v.resumeInTerminal||!v.isLocalDaemon?.(k))){b.current=!0;try{const j=e.clientRef.current;if(!j)throw new Error("Not connected");await j.request({action:"session.release",id:j.makeId("release"),sessionId:f.sessionId,agent:f.agent}),await v.resumeInTerminal({...f,daemonId:k,approvalMode:f.approvalMode??f.observedApprovalMode})}catch(j){e.setErrorText(String(j).includes("session_busy")?e.t.resumeTerminalBusy:e.t.resumeTerminalFailed)}finally{b.current=!1}}},[e]);return{runArchiveSync:s,skipArchiveSync:i,runAdminAction:a,exportActiveSession:o,clearPairing:u,setNotificationsEnabled:h,connectSavedTarget:d,forgetSavedTarget:m,openSessionDetails:g,editFolderTags:p,browseFolder:S,copyResumeCommand:w,resumeInTerminal:y}}class Uh{timer=null;sentAt=null;listeners=new Set;value=null;subscribe(t){return this.listeners.add(t),t(this.value),()=>{this.listeners.delete(t)}}start(t,n){this.stop();const s=()=>{if(this.sentAt!==null){this.stop(),n();return}this.sentAt=performance.now(),t()};s(),this.timer=setInterval(s,3e4)}acknowledge(){if(this.sentAt===null)return;const t=Math.max(0,Math.round(performance.now()-this.sentAt));this.sentAt=null,this.publish(t)}stop(){this.timer!==null&&clearInterval(this.timer),this.timer=null,this.sentAt=null,this.publish(null)}publish(t){this.value=t,this.listeners.forEach(n=>n(t))}}function Qr(e){return`${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Vh(e,t=window.location,n=!0){const i=`${t.protocol==="https:"?"wss:":"ws:"}//${t.host}`;return n&&Gi(t.hostname)?i:e?.webSocketUrl?e.webSocketUrl:i}class Qh{heartbeat=new Uh;onLatency=t=>this.heartbeat.subscribe(t);capabilities={};socket=null;pending=new Map;messageListeners=new Set;closeListeners=new Set;async connect(t){this.disconnect();const n=new WebSocket(Vh(t));this.socket=n;let s;const i=new Promise((o,l)=>{s=l,n.onopen=()=>o(),n.onerror=()=>l(new Error("WebSocket connection failed."))});if(n.onmessage=o=>{this.socket===n&&this.handleSocketMessage(o.data)},n.onclose=()=>{s(new Error("WebSocket disconnected.")),this.socket===n&&(this.heartbeat.stop(),this.socket=null,this.rejectPending(new Error("WebSocket disconnected.")),this.closeListeners.forEach(o=>o()))},await i,this.socket!==n)throw new Error("WebSocket disconnected.");const a=await this.request({action:"auth.hello",id:Qr("auth"),pairToken:t.pairToken,daemonId:t.daemonId,deviceId:t.deviceId,locale:navigator.language});if(this.socket!==n)throw new Error("WebSocket disconnected.");return this.capabilities=a.capabilities??{},this.heartbeat.start(()=>n.send(JSON.stringify({action:"ping"})),()=>n.close()),a}request(t,n={}){return!this.socket||this.socket.readyState!==WebSocket.OPEN?Promise.reject(new Error("WebSocket is not connected.")):new Promise((s,i)=>{const a={action:t.action,resolve:s,reject:i};n.timeoutMs&&n.timeoutMs>0&&(a.timeoutId=setTimeout(()=>{this.pending.delete(t.id),i(new Error(n.timeoutMessage||"Request timed out."))},n.timeoutMs)),this.pending.set(t.id,a),this.socket?.send(JSON.stringify(t))})}send(t){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(t))}onMessage(t){return this.messageListeners.add(t),()=>this.messageListeners.delete(t)}onClose(t){return this.closeListeners.add(t),()=>this.closeListeners.delete(t)}get supportsSessionSteer(){return this.isConnected&&this.capabilities.sessionSteer===!0}get supportsQueueSendNow(){return this.isConnected&&this.capabilities.queueSendNow===!0}disconnect(){this.heartbeat.stop(),this.capabilities={},this.rejectPending(new Error("WebSocket disconnected."));const t=this.socket;this.socket=null,t?.close(1e3,"client disconnect")}get isConnected(){return this.socket?.readyState===WebSocket.OPEN}makeId(t){return Qr(t)}handleSocketMessage(t){if(typeof t!="string")return;let n;try{n=JSON.parse(t)}catch{return}if(n.type==="pong"){this.heartbeat.acknowledge();return}if(n.type==="error"&&!n.sessionId){const s=/unsupported action "([^"]+)"/.exec(n.message)?.[1];if(s){let i=!1;for(const[a,o]of this.pending)o.action===s&&(this.pending.delete(a),o.timeoutId&&clearTimeout(o.timeoutId),o.reject(new Error(n.message)),i=!0);if(i)return}}if(n.type==="response"){const s=this.pending.get(n.id);if(s){this.pending.delete(n.id),s.timeoutId&&clearTimeout(s.timeoutId),n.ok?s.resolve(n.data):s.reject(new Error(n.error||"Request failed."));return}}this.messageListeners.forEach(s=>s(n))}rejectPending(t){for(const n of this.pending.values())n.timeoutId&&clearTimeout(n.timeoutId),n.reject(t);this.pending.clear()}}const fa="vibelet.web.sessionListCache",ma=120;function Zh(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Yh(e){if(!Zh(e)||typeof e.daemonId!="string"||!e.daemonId)return null;const t=Ti(e.page);return{daemonId:e.daemonId,page:{...t,sessions:t.sessions.slice(0,ma)},cachedAt:typeof e.cachedAt=="string"?e.cachedAt:new Date(0).toISOString()}}function Jh(e,t=Ge()){if(!e)return null;try{const n=t.getItem(fa);if(!n)return null;const s=Yh(JSON.parse(n));return s?.daemonId===e?s.page:null}catch{return null}}function Xh(e,t,n=Ge(),s=new Date().toISOString()){if(!e)return;const i={daemonId:e,page:{...t,sessions:t.sessions.slice(0,ma)},cachedAt:s};n.setItem(fa,JSON.stringify(i))}function ef(e){return e instanceof Error&&e.message==="auth_failed"}function tf(e,t){return e instanceof On&&e.code==="pair_window_expired"?t.pairingLinkExpired:e instanceof Error?e.message:String(e)}function nf(e){const t=c.useRef(null),n=c.useRef(e);n.current=e;const s=c.useCallback(a=>{const o=n.current,l=a??o.pairingRef.current;!l||o.intentionalDisconnectRef.current||(o.reconnectTimerRef.current&&window.clearTimeout(o.reconnectTimerRef.current),o.reconnectTimerRef.current=window.setTimeout(()=>{o.reconnectTimerRef.current=null,o.connectWithPairingRef.current(l,!0)},Kc))},[]),i=c.useCallback(async(a,o=!1)=>{const l=n.current;l.reconnectTimerRef.current&&(window.clearTimeout(l.reconnectTimerRef.current),l.reconnectTimerRef.current=null),l.intentionalDisconnectRef.current=!1,l.setPhase("connecting"),l.setStatusText(o?l.t.reconnectingToDaemon:l.t.connectingToDaemon),l.setErrorText(null);const u=new Qh,h=l.connectionAttemptIdRef.current+1;l.connectionAttemptIdRef.current=h;const d=l.clientRef.current;l.clientRef.current=u,d?.disconnect();const m=()=>l.connectionAttemptIdRef.current===h&&l.clientRef.current===u;u.onMessage(g=>{m()&&n.current.handleServerMessage(g)}),u.onClose(()=>{l.clientRef.current===u&&(l.clientRef.current=null,!l.intentionalDisconnectRef.current&&(l.setPhase("connecting"),l.setStatusText(l.t.reconnectingToDaemon),l.setErrorText(l.t.webSocketClosedRetrying),s(l.pairingRef.current??a)))});try{let g=a,p;try{p=await u.connect(a)}catch(y){if(!m()||!a.webSocketUrl)throw y;g={...a,webSocketUrl:void 0},l.setStatusText(l.t.reconnectingToDaemon),p=await u.connect(g)}if(!m())return;const S={...g,displayName:p.displayName??g.displayName};l.historyCacheDaemonIdRef.current&&l.historyCacheDaemonIdRef.current!==S.daemonId&&(l.historyCacheRef.current={},l.messagesSessionIdRef.current=null,l.lastHistorySessionIdRef.current=null,l.setMessages([])),l.historyCacheDaemonIdRef.current=S.daemonId,l.setPairing(S),l.pairingRef.current=S,$r(S);const w=Jh(S.daemonId);if(w&&l.setSessionsFromPage(w,!1),l.setSavedTargets(y=>{const f=qh(y,S);return ha(f),f}),l.setPhase("connected"),l.setStatusText(l.t.connectedTo(p.displayName??a.displayName??"Vibelet Daemon")),l.refreshDaemonMetadata(S),await l.requestReconnectSnapshot(),!m())return;const b=n.current;await b.fetchAgentResources(b.agent,b.cwd),l.reportLog("web.connected",{reconnecting:o})}catch(g){if(!m())return;ef(g)&&Ui(),l.setPhase("error"),l.setStatusText(l.t.connectionFailed),l.setErrorText(g instanceof Error?g.message:String(g)),s(a)}},[s]);c.useEffect(()=>{const a=n.current;a.connectWithPairingRef.current=i},[i]),c.useEffect(()=>{const a=n.current;let o=!1;async function l(){const u=jd(),d=pr()??a.rememberedTarget;if(!u&&!d){a.setPhase("missing-pair"),a.setStatusText(a.t.missingPair);return}try{a.setPhase("pairing"),u&&t.current?.pairNonce!==u.pairNonce&&(t.current={pairNonce:u.pairNonce,promise:Ad(u,d)});const m=u?await t.current?.promise:d;if(!m||o)return;u&&($r(m),t.current=null,Cd()),await a.connectWithPairingRef.current(m)}catch(m){if(o)return;u&&(t.current=null),a.setPhase("error"),a.setStatusText(a.t.pairingFailed),a.setErrorText(tf(m,a.t))}}return l(),()=>{o=!0,a.intentionalDisconnectRef.current=!0,a.connectionAttemptIdRef.current+=1,a.reconnectTimerRef.current&&window.clearTimeout(a.reconnectTimerRef.current),a.clientRef.current?.disconnect()}},[e.t]),c.useEffect(()=>{const a=n.current;if(a.phase!=="connected")return;const o=window.setTimeout(()=>{a.requestSessions({force:!0}).catch(l=>a.setErrorText(l instanceof Error?l.message:String(l)))},260);return()=>window.clearTimeout(o)},[e.phase,e.requestSessions,e.search,e.sinceFilter]),c.useEffect(()=>{const a=n.current;a.phase==="connected"&&a.fetchAgentResources(a.agent,a.cwd)},[e.agent,e.cwd,e.fetchAgentResources,e.phase])}const pa="vibelet.web.composerDrafts",Gs={draftsBySessionId:{},newSessionDraft:""};function Zr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ga(e){return Zr(e)?{draftsBySessionId:Zr(e.draftsBySessionId)?Object.fromEntries(Object.entries(e.draftsBySessionId).filter(n=>typeof n[1]=="string")):{},newSessionDraft:typeof e.newSessionDraft=="string"?e.newSessionDraft:""}:Gs}function sf(e=Ge()){const t=e.getItem(pa);if(!t)return Gs;try{return ga(JSON.parse(t))}catch{return Gs}}function an(e,t=Ge()){t.setItem(pa,JSON.stringify(ga(e)))}function on(e,t,n){if(!t)return{...e,newSessionDraft:n};const s={...e.draftsBySessionId};return n.trim()?s[t]=n:delete s[t],{...e,draftsBySessionId:s}}function cn(e,t){return t?e.draftsBySessionId[t]??"":e.newSessionDraft}function rf(e,t,n){if(!t||!n||t===n)return e;const s=e.draftsBySessionId[t];if(s===void 0)return e;const i={...e.draftsBySessionId};return delete i[t],s.trim()&&(i[n]=s),{...e,draftsBySessionId:i}}function af(e){const[t,n]=c.useState(!1),s=c.useRef(!1),i=e.clientRef.current,a=e.activeSessionId,o=!a||!!(e.pendingApprovals[a]||e.pendingQuestions[a]),l=!o&&i?.supportsSessionSteer===!0&&!!a&&e.respondingSessions.has(a)&&e.activeSession?.runtime.state!=="externalRunning",u=!o&&i?.supportsQueueSendNow===!0;return{busy:t,canGuide:l,canSendNow:u,onAction:async(m,g)=>{if(!a||!i?.isConnected||s.current||!(g==="guide"?l:u))return;const p=new Set(m.map(y=>y.clientMessageId).filter(Boolean)),S=e.activeQueue.filter(y=>y.clientMessageId&&p.has(y.clientMessageId));if(!S.length)return;s.current=!0,n(!0),e.setErrorText(null);const w=new Set;for(const y of S)e.setCachedMessageDelivery(a,y.clientMessageId,"sending",y);const b=y=>{w.add(y.clientMessageId),e.setCachedMessageDelivery(a,y.clientMessageId,"delivered")};try{if(g==="sendNow")await i.request({action:"session.queue.sendNow",id:i.makeId("queue_now"),sessionId:a,clientMessageIds:S.map(y=>y.clientMessageId)},{timeoutMs:15e3}),S.forEach(b);else for(const y of S)await i.request({action:"session.steer",id:i.makeId("queue_guide"),sessionId:a,clientMessageId:y.clientMessageId,message:y.content,images:y.images},{timeoutMs:15e3}),b(y),e.setPendingQueues(f=>({...f,[a]:(f[a]??[]).filter(v=>v.clientMessageId!==y.clientMessageId)}))}catch(y){let f=!1;for(const v of S)w.has(v.clientMessageId)||(f=e.setCachedMessageDelivery(a,v.clientMessageId,"failed")!=="delivered"||f);f&&e.setErrorText(y instanceof Error?y.message:String(y))}finally{s.current=!1,n(!1)}},onCollect:async m=>{if(!a||!i?.isConnected||s.current)return;const g=new Set(m.map(S=>S.clientMessageId).filter(S=>!!S)),p=e.activeQueue.filter(S=>S.clientMessageId&&g.has(S.clientMessageId));if(!(p.length<2)){s.current=!0,n(!0),e.setErrorText(null);try{const w=(await i.request({action:"session.queue.collect",id:i.makeId("queue_collect"),sessionId:a,clientMessageIds:p.map(f=>f.clientMessageId)},{timeoutMs:15e3})).entries;if(!Array.isArray(w))throw new Error("Invalid queue collection response");const b=w.map(f=>f.content).filter(f=>f.trim()).join(`
13
+
14
+ `),y=f=>[f,b].filter(v=>v.trim()).join(`
15
+
16
+ `);if(e.setComposerDrafts(f=>{const v=on(f,a,y(cn(f,a)));return e.composerDraftsRef.current=v,an(v),v}),e.activeSessionIdRef.current===a){e.setDraft(y);const f=[...new Set(w.flatMap(v=>v.images??[]))];e.setAttachments(v=>{const k=new Set(v.map(j=>j.path));return[...v,...f.filter(j=>!k.has(j)).map(j=>({path:j,name:Ht(j),type:"image/*",size:0}))]})}e.setPendingQueues(f=>({...f,[a]:(f[a]??[]).filter(v=>!v.clientMessageId||!g.has(v.clientMessageId))}))}catch(S){e.setErrorText(S instanceof Error?S.message:String(S))}finally{s.current=!1,n(!1)}}}}}function ms(e,t){return!!t&&Object.hasOwn(e,t)}function of(e,t){const n=e.map(s=>({...s}));return t?nr(rr(n,t)):n}function cf(e,t,n){return t?{...e,[t]:ff(e[t]??[],n)}:e}function ya(e,t,n){return!t||n.length===0?e:{...e,[t]:Ei(e[t]??[],n)}}function lf(e,t,n){return n.historyKey&&e[t]?.some(s=>s.historyKey===n.historyKey)?e:ya(e,t,[n])}function df(e,t,n){return!t||!n?e:{...e,[t]:nr(rr(e[t]??[],n))}}function uf(e,t,n){if(!t||!n||t===n||!ms(e,t))return e;const s={...e};return s[n]=e[t],delete s[t],s}function hf(e,t){if(!ms(e,t))return e;const n={...e};return delete n[t],n}function ff(e,t){const n=Ei(e,t),s=new Map;for(const o of n)o.historyKey&&o.localClientMessageId&&!s.has(o.historyKey)&&s.set(o.historyKey,o);const i=t.map(o=>{const l=o.historyKey&&s.get(o.historyKey);return l?{...o,localClientMessageId:l.localClientMessageId,localDelivery:l.localDelivery}:{...o}}),a=new Set(i.map(o=>o.localClientMessageId));return[...i,...n.filter(o=>o.localClientMessageId&&o.historyKey?.startsWith("client:")&&!a.has(o.localClientMessageId))]}function en(e,t,n){const s=new Set(e);return n?s.add(t):s.delete(t),s}function mf(e){const t=s=>{e.setSessions(i=>{const a=i.findIndex(l=>l.sessionId===s&&l.stallWarning);if(a<0)return i;const o=[...i];return o[a]={...i[a],stallWarning:void 0},o})},n=c.useCallback((s,i,a,o,l)=>{const u=e.notificationSettingsRef.current;if(!u[o]||e.notifiedEventsRef.current.has(s))return;$c(i,a,{onClick:()=>{window.focus(),l&&e.setActiveSessionId(l)},permission:e.notificationPermissionRef.current,settings:u,tag:s,visibilityState:document.visibilityState})&&e.notifiedEventsRef.current.add(s)},[e]);return c.useCallback(s=>{switch(s.type){case"response":{nn(s.data)&&typeof s.data.oldSessionId=="string"&&typeof s.data.sessionId=="string"&&e.remapLocalSessionState(s.data.oldSessionId,s.data.sessionId);break}case"sessions.changed":e.requestSessions({force:!0,preserveLoaded:!0}).catch(i=>e.setErrorText(i instanceof Error?i.message:String(i)));break;case"session.history":e.setSessions(i=>{const a=i.findIndex(l=>l.sessionId===s.sessionId&&l.stallWarning!==s.stallWarning);if(a<0)return i;const o=[...i];return o[a]={...i[a],stallWarning:s.stallWarning},o}),e.setPendingQueues(i=>({...i,[s.sessionId]:s.pendingQueue??[]})),e.clearHistoryLoading(s.sessionId),e.mergeCachedHistoryPage(s.sessionId,of(s.messages,s.partialReplyText),s.historyPage),s.sessionId===e.activeSessionIdRef.current&&(e.setPendingApprovals(i=>{const a={...i};return s.pendingApproval?a[s.sessionId]={type:"approval.request",sessionId:s.sessionId,...s.pendingApproval}:delete a[s.sessionId],a}),e.setPendingQuestions(i=>{const a={...i};if(s.pendingQuestion){const o={type:"question.request",sessionId:s.sessionId,...s.pendingQuestion};a[s.sessionId]=o,e.setQuestionAnswers(ir(o))}else delete a[s.sessionId];return a})),e.setRespondingSessions(i=>{const a=en(i,s.sessionId,!!(s.isResponding||s.externallyResponding));return e.respondingSessionsRef.current=a,a});break;case"session.history.append":e.appendCachedHistory(s.sessionId,s.messages);break;case"text.delta":t(s.sessionId),e.appendCachedDelta(s.sessionId,s.content),e.respondingSessionsRef.current=en(e.respondingSessionsRef.current,s.sessionId,!0),e.setRespondingSessions(i=>en(i,s.sessionId,!0));break;case"tool.call":t(s.sessionId),e.appendCachedHistory(s.sessionId,[{role:"tool",type:"info",toolName:s.toolName,toolInput:s.input,content:`${e.t.toolCallLabel}: ${s.toolName}
17
+
18
+ ${Zc(s.input)}`,timestamp:new Date().toISOString()}]);break;case"tool.result":t(s.sessionId),e.appendCachedHistory(s.sessionId,[{role:"tool",type:"info",content:s.output,timestamp:new Date().toISOString()}]);break;case"approval.request":e.setPendingApprovals(i=>({...i,[s.sessionId]:s})),n(`approval:${s.sessionId}:${s.requestId}`,e.t.notificationApprovalTitle,s.description||s.toolName,"approvals",s.sessionId);break;case"question.request":e.setPendingQuestions(i=>({...i,[s.sessionId]:s})),n(`question:${s.sessionId}:${s.requestId}`,e.t.notificationQuestionTitle,e.t.notificationQuestionCount(s.questions.length),"questions",s.sessionId);break;case"question.cleared":e.setPendingQuestions(i=>{const a={...i};return a[s.sessionId]?.requestId===s.requestId&&delete a[s.sessionId],a});break;case"session.queue":e.setLivePendingQueue(s.sessionId,s.pending);break;case"session.stall_warning":e.setSessions(i=>i.map(a=>a.sessionId===s.sessionId?{...a,stallWarning:s.warning}:a));break;case"session.interrupted_notice":e.setSessions(i=>i.map(a=>a.sessionId===s.sessionId?{...a,interruptReason:s.reason,stallWarning:void 0}:a));break;case"session.done":if(t(s.sessionId),e.respondingSessionsRef.current.has(s.sessionId)){const i=(e.turnNotificationCountsRef.current[s.sessionId]??0)+1;e.turnNotificationCountsRef.current[s.sessionId]=i,n(`done:${s.sessionId}:${i}`,e.t.notificationReplyTitle,e.t.notificationReplyBody,"replies",s.sessionId)}e.respondingSessionsRef.current=en(e.respondingSessionsRef.current,s.sessionId,!1),e.setRespondingSessions(i=>en(i,s.sessionId,!1)),e.setPendingApprovals(i=>{const a={...i};return delete a[s.sessionId],a}),e.setPendingQuestions(i=>{const a={...i};return delete a[s.sessionId],a}),s.usage&&e.setSessions(i=>i.map(a=>a.sessionId===s.sessionId?{...a,lastUsage:s.usage}:a)),e.requestSessions({force:!0,preserveLoaded:!0}).catch(i=>e.setErrorText(i instanceof Error?i.message:String(i)));break;case"session.interrupted":e.respondingSessionsRef.current=en(e.respondingSessionsRef.current,s.sessionId,!1),e.setRespondingSessions(i=>en(i,s.sessionId,!1)),e.requestSessions({force:!0,preserveLoaded:!0}).catch(i=>e.setErrorText(i instanceof Error?i.message:String(i)));break;case"session.renamed":e.setSessions(i=>i.map(a=>a.sessionId===s.sessionId?{...a,customTitle:s.title}:a));break;case"error":e.setErrorText(s.message);break}},[e,n])}function pf(e,t,n,s=!1){if(!s)return{...e,[t]:[n]};const i=e[t]??[],a=i.includes(n)?i.filter(o=>o!==n):[...i,n];return{...e,[t]:a}}function gf(e){const t=c.useCallback(async b=>{const y=e.clientRef.current,f=e.activeApproval;if(!(!y?.isConnected||!f)){e.setBusy(!0),e.setErrorText(null);try{await y.request({action:"session.approve",id:y.makeId("approve"),sessionId:f.sessionId,requestId:f.requestId,approved:b}),e.setPendingApprovals(v=>{const k={...v};return k[f.sessionId]?.requestId===f.requestId&&delete k[f.sessionId],k})}catch(v){const k=v instanceof Error?v.message:String(v);/session not found|session .* inactive/i.test(k)&&e.setPendingApprovals(j=>{if(j[f.sessionId]?.requestId!==f.requestId)return j;const E={...j};return delete E[f.sessionId],E}),e.setErrorText(k)}finally{e.setBusy(!1)}}},[e]),n=c.useCallback(async()=>{const b=e.clientRef.current;if(!(!b?.isConnected||!e.activeQuestion)){e.setBusy(!0),e.setErrorText(null);try{await b.request({action:"session.respondQuestion",id:b.makeId("question"),sessionId:e.activeQuestion.sessionId,requestId:e.activeQuestion.requestId,answers:e.questionAnswers}),e.setPendingQuestions(y=>{const f={...y};return f[e.activeQuestion.sessionId]?.requestId===e.activeQuestion.requestId&&delete f[e.activeQuestion.sessionId],f})}catch(y){e.setErrorText(y instanceof Error?y.message:String(y))}finally{e.setBusy(!1)}}},[e]),s=c.useCallback(async()=>{const b=e.clientRef.current;if(!(!b?.isConnected||!e.activeQuestion)){e.setBusy(!0),e.setErrorText(null);try{await b.request({action:"session.cancelQuestion",id:b.makeId("cancel_question"),sessionId:e.activeQuestion.sessionId,requestId:e.activeQuestion.requestId}),e.setPendingQuestions(y=>{const f={...y};return f[e.activeQuestion.sessionId]?.requestId===e.activeQuestion.requestId&&delete f[e.activeQuestion.sessionId],f})}catch(y){e.setErrorText(y instanceof Error?y.message:String(y))}finally{e.setBusy(!1)}}},[e]),i=c.useCallback((b,y,f)=>{e.setQuestionAnswers(v=>pf(v,b,y,!!f))},[e]),a=c.useCallback(async b=>{const y=e.clientRef.current,f=e.activeSession,v=f?.sessionId??(b==="session.interrupt"?e.activeSessionIdRef.current:null);if(!y?.isConnected||!v||b!=="session.interrupt"&&!f||b==="session.delete"&&!await Tn(pn().deleteSession(Et(f)))||e.clientRef.current!==y||!y.isConnected)return!1;e.setBusy(!0),e.setErrorText(null);try{return b==="session.resume"?await y.request({action:b,id:y.makeId("resume"),sessionId:v,agent:f.agent}):await y.request({action:b,id:y.makeId(b.split(".").at(-1)??"session"),sessionId:v}),b==="session.delete"&&(e.removeCachedHistory(f.sessionId),e.setActiveSessionId(null),e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([])),b!=="session.interrupt"&&await e.requestSessions({force:!0,preserveLoaded:!0}),!0}catch(k){return e.setErrorText(k instanceof Error?k.message:String(k)),!1}finally{e.setBusy(!1)}},[e]),o=c.useCallback(async b=>{const y=e.clientRef.current;if(!e.activeSession){e.setApprovalMode(b);return}if(y?.isConnected){e.setErrorText(null);try{await y.request({action:"session.setApprovalMode",id:y.makeId("approval_mode"),sessionId:e.activeSession.sessionId,approvalMode:b}),e.activeSessionIdRef.current===e.activeSession.sessionId&&e.setApprovalMode(b),e.setSessions(f=>f.map(v=>v.sessionId===e.activeSession.sessionId?{...v,approvalMode:b}:v))}catch(f){e.setErrorText(f instanceof Error?f.message:String(f))}}},[e]),l=c.useCallback(async b=>{const y=e.clientRef.current;if(!y?.isConnected||!e.activeSessionId||!b.clientMessageId)return;const f=e.activeSessionId;let v=-1;e.setPendingQueues(j=>{const E=j[f]??[];return v=E.findIndex(x=>x.clientMessageId===b.clientMessageId),{...j,[f]:E.filter(x=>x.clientMessageId!==b.clientMessageId)}}),e.setBusy(!0),e.setErrorText(null);try{await y.request({action:"session.queue.cancel",id:y.makeId("queue_cancel"),sessionId:f,clientMessageId:b.clientMessageId})}catch(j){e.setPendingQueues(E=>{const x=E[f]??[];if(x.some(I=>I.clientMessageId===b.clientMessageId))return E;const C=Math.min(Math.max(v,0),x.length);return{...E,[f]:[...x.slice(0,C),b,...x.slice(C)]}}),e.setErrorText(j instanceof Error?j.message:String(j));return}finally{e.setBusy(!1)}const k=j=>[j,b.content].filter(Boolean).join(`
19
+
20
+ `);if(e.setComposerDrafts(j=>{const E=on(j,f,k(cn(j,f)));return e.composerDraftsRef.current=E,an(E),E}),e.activeSessionIdRef.current===f&&(e.setDraft(k),b.images?.length)){const j=[...new Set(b.images)];e.setAttachments(E=>{const x=new Set(E.map(C=>C.path));return[...E,...j.filter(C=>!x.has(C)).map(C=>({path:C,name:Ht(C),type:"image/*",size:0}))]})}},[e]),u=c.useCallback(async(b,y)=>{if(e.pendingSessions[b.sessionId])return;const f=e.clientRef.current;if(f?.isConnected){e.setBusy(!0),e.setErrorText(null);try{const v=y?Date.now():void 0;await f.request({action:"session.setPinned",id:f.makeId("pin"),sessionId:b.sessionId,pinned:y,...v?{pinnedAt:v}:{}}),e.setSessions(k=>k.map(j=>j.sessionId===b.sessionId?{...j,pinned:y,pinnedAt:v}:j)),await e.requestSessions({force:!0,preserveLoaded:!0})}catch(v){e.setErrorText(v instanceof Error?v.message:String(v))}finally{e.setBusy(!1)}}},[e]),h=c.useCallback(async(b,y)=>{if(e.pendingSessions[b.sessionId])return;const f=e.clientRef.current;if(f?.isConnected){e.setBusy(!0),e.setErrorText(null);try{await f.request({action:"session.setArchived",id:f.makeId("archive"),sessionId:b.sessionId,archived:y}),e.setSessions(v=>v.map(k=>k.sessionId===b.sessionId?{...k,archived:y}:k)),await e.requestSessions({force:!0,preserveLoaded:!0})}catch(v){e.setErrorText(v instanceof Error?v.message:String(v))}finally{e.setBusy(!1)}}},[e]),d=c.useCallback(async b=>{if(e.pendingSessions[b.sessionId]){e.removeCachedHistory(b.sessionId),e.setPendingSessions(f=>{const v={...f};return delete v[b.sessionId],v}),e.setComposerDrafts(f=>{const v=on(f,b.sessionId,"");return e.composerDraftsRef.current=v,an(v),v}),e.activeSessionIdRef.current===b.sessionId&&(e.setActiveSessionId(null),e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([]),e.setDraft(cn(e.composerDraftsRef.current,null)),e.setDetailsOpen(!1));return}const y=e.clientRef.current;if(!(!y?.isConnected||!await Tn(pn().deleteSession(Et(b))))&&!(e.clientRef.current!==y||!y.isConnected)){e.setBusy(!0),e.setErrorText(null);try{await y.request({action:"session.delete",id:y.makeId("delete"),sessionId:b.sessionId}),e.removeCachedHistory(b.sessionId),e.setOptimisticSessions(f=>{if(!f[b.sessionId])return f;const v={...f};return delete v[b.sessionId],v}),e.activeSessionIdRef.current===b.sessionId&&(e.setActiveSessionId(null),e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([]),e.setDetailsOpen(!1)),await e.requestSessions({force:!0,preserveLoaded:!0})}catch(f){e.setErrorText(f instanceof Error?f.message:String(f))}finally{e.setBusy(!1)}}},[e]),m=c.useCallback(async()=>{e.activeSession&&await u(e.activeSession,!e.activeSession.pinned)},[e.activeSession,u]),g=c.useCallback(async()=>{e.activeSession&&await h(e.activeSession,!e.activeSession.archived)},[e.activeSession,h]),p=c.useCallback(()=>{const b=e.activeSessionId;b&&a("session.interrupt").then(y=>{y&&(e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current),e.respondingSessionsRef.current.delete(b),e.setRespondingSessions(f=>{const v=new Set(f);return v.delete(b),v}))})},[e,a]),S=c.useCallback(()=>{e.setErrorText(null),e.phase==="connected"?e.requestSessions({force:!0,preserveLoaded:!0}):window.location.reload()},[e]),w=c.useCallback(async()=>{const b=e.renameTitle.trim();if(e.activeSession&&e.pendingSessions[e.activeSession.sessionId]){e.setPendingSessions(f=>{const v=f[e.activeSession.sessionId];return v?{...f,[e.activeSession.sessionId]:{...v,title:b||v.title,customTitle:b||void 0}}:f});return}const y=e.clientRef.current;if(!(!y?.isConnected||!e.activeSession)){e.setBusy(!0),e.setErrorText(null);try{await y.request({action:"session.rename",id:y.makeId("rename"),sessionId:e.activeSession.sessionId,title:b||void 0}),e.setSessions(f=>f.map(v=>v.sessionId===e.activeSession.sessionId?{...v,customTitle:b||void 0}:v))}catch(f){e.setErrorText(f instanceof Error?f.message:String(f))}finally{e.setBusy(!1)}}},[e]);return{respondApproval:t,respondQuestion:n,cancelQuestion:s,setQuestionChoice:i,requestActiveAction:a,interruptActiveSession:p,retrySessions:S,updateApprovalMode:o,cancelQueuedTurn:l,setSessionPinned:u,setSessionArchived:h,deleteSession:d,updatePinned:m,updateArchived:g,renameSession:w}}async function Us(e){return{[e]:"desktop-free"}}function yf(){let e=null,t=null;const n=new Set,s=()=>n.forEach(i=>i());return{getSnapshot:()=>e,subscribe:i=>(n.add(i),()=>{n.delete(i)}),start(i){const a={sessionId:i};return t=a,e=a,s(),{remap(o){t===a&&(e={sessionId:o},s())},finish(){t===a&&(t=null,e=null,s())}}}}}function Yr(e){const t=e.toLowerCase();return/subscription|required|upgrade|billing/u.test(t)?"subscription":/skillnotfound|not found|missing/u.test(t)?"missing-resource":/permission|forbidden|unauthorized|denied/u.test(t)?"permission":/timeout|timed out/u.test(t)?"timeout":/websocket|network|disconnect|connection|offline|closed/u.test(t)?"network":"unknown"}const Jr=15e3,Xr="Session send timed out.";function Rn(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function bf(e){const[t]=c.useState(yf),[n,s]=c.useState(null),[i,a]=c.useState(null),o=c.useCallback(m=>{e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current),e.respondingSessionsRef.current.delete(m),e.setRespondingSessions(g=>{const p=new Set(g);return p.delete(m),p})},[e]),l=c.useCallback((m,g,p)=>{const S=Rn(m)??Rn(e.cwd)??dt,w=g??e.agent,b=Yc(),y=Jc({sessionId:b,agent:w,cwd:S,approvalMode:p?.approvalMode??e.approvalMode,model:Qn(p?.model??e.model),effort:e.effort||void 0,fastMode:e.fastMode,title:w==="codex"?e.t.newCodexSession:e.t.newClaudeSession}),f=p?.draft??(e.activeSessionIdRef.current?"":cn(e.composerDraftsRef.current,null));return e.setPendingSessions(v=>({...v,[b]:y})),e.setComposerDrafts(v=>{let k=on(v,b,f);return e.activeSessionIdRef.current||(k=on(k,null,"")),e.composerDraftsRef.current=k,an(k),k}),e.setCwd(S),e.setAgent(w),e.activeSessionIdRef.current=b,e.setActiveSessionId(b),e.lastHistorySessionIdRef.current=b,e.messagesSessionIdRef.current=b,e.clearHistoryLoading(),e.setMessages([]),e.setDraft(f),p?.draft?.trim()&&a(b),e.setErrorText(null),e.reportLog("web.session.pending_create",{sessionId:b,agent:w,cwd:S}),b},[e]),u=c.useCallback(async(m,g,p)=>{const S=e.clientRef.current;if(!S?.isConnected)return e.setErrorText(e.t.webSocketNotConnected),null;const w=p?e.pendingSessions[p]:void 0,b=Rn(m)??Rn(w?.cwd)??Rn(e.cwd)??dt,y=g??w?.agent??e.agent,f=w?.approvalMode??e.approvalMode,v=w?w.model:Qn(e.model),k=w?.effort??(e.effort||void 0),j=w?.fastMode??e.fastMode;e.setErrorText(null);try{const E=await S.request({action:"session.create",id:S.makeId("create"),agent:y,cwd:b,approvalMode:f,continueSession:e.continueSession,model:v,effort:k,fastMode:j,...p?{clientSessionId:p}:{}}),x=Vc(E);if(!x)throw new Error(e.t.sessionIdMissing);const C=nn(E)&&typeof E.oldSessionId=="string"?E.oldSessionId:p;return e.setCwd(b),e.setAgent(y),e.activeSessionIdRef.current=x,e.setActiveSessionId(x),e.lastHistorySessionIdRef.current=x,e.messagesSessionIdRef.current=x,e.clearHistoryLoading(),p&&w?(e.setPendingSessions(I=>{const N={...I};return delete N[p],C&&C!==p&&delete N[C],N}),e.setOptimisticSessions(I=>({...I,[x]:Xc(w,x)})),C&&C!==x&&e.remapLocalSessionState(C,x),p!==x&&e.remapLocalSessionState(p,x)):await e.requestSessions({force:!0}),e.reportLog("web.session.create",{sessionId:x,clientSessionId:p,agent:y,cwd:b}),x}catch(E){return e.setErrorText(E instanceof Error?E.message:String(E)),null}},[e]),h=c.useCallback(async m=>{m?.preventDefault();const g=e.draft.trim();if(!g||e.busy)return;const p=e.clientRef.current;if(!p?.isConnected){e.setErrorText(e.t.webSocketNotConnected);return}const S=t.start(e.activeSessionId);try{const w=Er(g)?"agentSkills":e.attachments.length===0&&kr(g,e.activeSession?.agent??e.agent)?"agentCommands":void 0;let b;if(w){e.setBusy(!0);try{b=await Us(w)}catch(R){e.setErrorText(R instanceof Error?R.message:String(R));return}finally{e.setBusy(!1)}}e.setBusy(!0),e.setErrorText(null),e.updateDraft("");const y=e.attachments;e.setAttachments([]);let f=e.activeSessionId,v=e.activeSession?.agent??e.agent;const k=f?e.pendingSessions[f]:void 0,j=k?k.model:Qn(e.model);if(f&&e.pendingSessions[f]){const R=await u(e.pendingSessions[f].cwd,e.pendingSessions[f].agent,f);if(!R){e.setBusy(!1),e.updateDraft(g),e.setAttachments(y);return}f=R,v=e.pendingSessions[e.activeSessionId??""]?.agent??v}else f||(f=await u());if(!f){e.setBusy(!1),e.updateDraft(g),e.setAttachments(y);return}S.remap(f);const E=y.length===0?kr(g,v):null;if(E){const R=Tc(E.command),_=R?p.makeId("cmd_msg"):void 0;R&&(e.messagesSessionIdRef.current=f,e.appendCachedHistory(f,[{role:"user",content:R,timestamp:new Date().toISOString()}]),e.renderCachedHistory(f));try{const V=await p.request({action:"session.command",id:p.makeId("command"),sessionId:f,agent:v,command:E.command,..._?{clientMessageId:_}:{},featureEntitlements:b});await e.handleSessionCommandResponse(f,E.command,V)}catch(V){const Z=V instanceof Error?V.message:String(V);e.appendInfoMessage(f,jr(Z)),e.setErrorText(jr(Z))}finally{e.setBusy(!1)}return}const x=Ac(g),C=y.map(R=>R.path),I=p.makeId("msg"),N=`client:${I}`;e.messagesSessionIdRef.current=f,e.setCachedMessageDelivery(f,I,"sending",{content:x,...C.length?{images:C}:{}}),e.renderCachedHistory(f),e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current).add(f),e.setRespondingSessions(R=>new Set(R).add(f));const L=Er(x)??void 0,P=L?b:void 0;try{const R=await p.request({action:"session.send",id:p.makeId("send"),sessionId:f,agent:v,message:x,clientMessageId:I,images:C.length?C:void 0,model:j,effort:e.effort||void 0,fastMode:e.fastMode,skillInvocation:L,featureEntitlements:P},{timeoutMs:Jr,timeoutMessage:Xr});nn(R)&&typeof R.oldSessionId=="string"&&typeof R.sessionId=="string"&&(S.remap(R.sessionId),e.remapLocalSessionState(R.oldSessionId,R.sessionId)),e.setCachedMessageDelivery(nn(R)&&typeof R.sessionId=="string"?R.sessionId:f,I,"delivered"),e.reportLog("web.telemetry.send_accepted",{attachmentCount:C.length}),s(_=>_?.historyKey===N?null:_)}catch(R){f=e.resolveCachedMessageSession(f,I);const _=R instanceof Error?R.message:String(R),V=Yr(Nr(_,!!L));if(e.setCachedMessageDelivery(f,I,"failed")==="delivered")return;e.setErrorText(null),s({sessionId:f,agent:v,message:x,clientMessageId:I,historyKey:N,kind:V,retrying:!1,...C.length?{images:C}:{},model:j,effort:e.effort||void 0,fastMode:e.fastMode,skillInvocation:L,featureEntitlements:P}),e.reportLog("web.telemetry.send_failed",{attachmentCount:C.length,failureKind:V},"warn"),o(f)}finally{e.setBusy(!1)}}finally{S.finish()}},[o,u,e,t]),d=c.useCallback(async()=>{if(!n||n.retrying||e.busy)return;const m=e.clientRef.current;if(!m?.isConnected){s(S=>S?{...S,kind:"network"}:null);return}let g=e.resolveCachedMessageSession(n.sessionId,n.clientMessageId);const p=t.start(g);s(S=>S?{...S,retrying:!0}:null),e.ensureCachedHistoryEntry(g,{role:"user",content:n.message,historyKey:n.historyKey,...n.images?.length?{images:n.images}:{}}),e.setCachedMessageDelivery(g,n.clientMessageId,"sending"),e.setBusy(!0),e.setErrorText(null),e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current).add(g),e.setRespondingSessions(S=>new Set(S).add(g));try{const S=await m.request({action:"session.send",id:m.makeId("retry_send"),sessionId:g,agent:n.agent,message:n.message,clientMessageId:n.clientMessageId,images:n.images,model:n.model,effort:n.effort,fastMode:n.fastMode,skillInvocation:n.skillInvocation??void 0,featureEntitlements:n.skillInvocation?await Us("agentSkills"):void 0},{timeoutMs:Jr,timeoutMessage:Xr});nn(S)&&typeof S.oldSessionId=="string"&&typeof S.sessionId=="string"&&(p.remap(S.sessionId),e.remapLocalSessionState(S.oldSessionId,S.sessionId)),e.setCachedMessageDelivery(nn(S)&&typeof S.sessionId=="string"?S.sessionId:g,n.clientMessageId,"delivered"),e.reportLog("web.telemetry.retry_accepted",{attachmentCount:n.images?.length??0}),s(null)}catch(S){g=e.resolveCachedMessageSession(g,n.clientMessageId);const w=S instanceof Error?S.message:String(S),b=Yr(Nr(w,!!n.skillInvocation));if(e.setCachedMessageDelivery(g,n.clientMessageId,"failed")==="delivered"){s(null);return}s(y=>y?{...y,sessionId:g,kind:b,retrying:!1}:null),e.reportLog("web.telemetry.retry_failed",{attachmentCount:n.images?.length??0,failureKind:b},"warn"),o(g)}finally{e.setBusy(!1),p.finish()}},[o,n,e,t]);return c.useEffect(()=>{if(!(!i||e.busy)){if(e.activeSessionId!==i||!e.pendingSessions[i]){a(null);return}a(null),h()}},[i,e.activeSessionId,e.busy,e.pendingSessions,h]),{failedSend:n,dismissFailedSend:()=>s(null),retryFailedSend:d,stagePendingSession:l,sendDraft:Object.assign(h,{submission:t})}}function vf({daemonId:e,session:t,setModel:n,setPendingSessions:s}){const i=t?.sessionId,a=t?.model??"";return c.useEffect(()=>{i&&n(a)},[e,i,a,n]),c.useCallback(o=>{n(o),i&&s(l=>{const u=l[i];return u?{...l,[i]:{...u,model:Qn(o)}}:l})},[i,n,s])}function xf(e,t){const n=e.indexOf(t);if(n>=0)return n;const s=t.historyKey;if(s)return e.findIndex(o=>o.historyKey===s);const i=t.rewindPoint;if(i)return e.findIndex(o=>JSON.stringify(o.rewindPoint)===JSON.stringify(i));const a=e.flatMap((o,l)=>o.role===t.role&&o.type===t.type&&o.content===t.content&&o.timestamp===t.timestamp&&JSON.stringify(o.images)===JSON.stringify(t.images)?[l]:[]);return a.length===1?a[0]:-1}function wf(e){const t=c.useRef(!1);return async n=>{const s=e.activeSession,i=e.clientRef.current;if(!s||!i?.isConnected||t.current||e.busy)return;const a=$n(),o=e.historyCacheRef.current[s.sessionId]??[],l=xf(o,n);if(l<0||n.role!=="user"||n.type==="info"){e.setErrorText(a.unavailable);return}if((e.historyPageStartRef.current[s.sessionId]??0)>0){e.setErrorText(a.incompleteHistory);return}t.current=!0;let u=!1;try{u=await As({message:a.confirmRewind})}finally{t.current=!1}if(!(!u||e.clientRef.current!==i||!i.isConnected||e.activeSessionIdRef.current!==s.sessionId)){t.current=!0,e.setBusy(!0),e.setErrorText(null);try{const h=await i.request({action:"session.rewind",id:i.makeId("rewind"),sessionId:s.sessionId,agent:s.agent,targetUserMessageIndex:o.slice(0,l+1).filter(m=>m.role==="user"&&m.type!=="info").length-1,featureEntitlements:await Us("sessionRewind")},{timeoutMs:15e4,timeoutMessage:a.rewindFailed});if(!h||typeof h.sessionId!="string"||!h.sessionId||h.sessionId===s.sessionId||h.sourceSessionId!==s.sessionId||h.archivedSource!==!0||!Array.isArray(h.messages)||h.messages.some(m=>!m||typeof m.content!="string"||!["user","assistant","tool"].includes(m.role)))throw new Error(a.invalidResponse);const d={...s,sessionId:h.sessionId,archived:!1};e.setOptimisticSessions(m=>{const g={...m};return delete g[s.sessionId],g[h.sessionId]=d,g}),e.setSessions(m=>[...m.filter(g=>g.sessionId!==h.sessionId).map(g=>g.sessionId===s.sessionId?{...g,archived:!0,pinned:!1}:g),d]),e.replaceCachedHistory(h.sessionId,h.messages),e.lastHistorySessionIdRef.current=h.sessionId,e.activeSessionIdRef.current=h.sessionId,e.setActiveSessionId(h.sessionId),e.renderCachedHistory(h.sessionId),e.updateDraft(n.content),e.setAttachments((n.images??[]).map(m=>({path:m,name:m.split("/").pop()??m,type:"application/octet-stream",size:0}))),await e.requestSessions({force:!0}).catch(()=>{})}catch(h){e.setErrorText(h instanceof Error?h.message:a.rewindFailed)}finally{t.current=!1,e.setBusy(!1)}}}}function Sf(e,t,n,s,i){if(t===n)return e;const a=!t&&i?i:s||dt;return a===e.path?e:{path:a,entries:[],loading:!1,loaded:!1}}function Ns(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function tn(e=window.location.search){const t=new URLSearchParams(e),n=Ns(t.get("folder")),s=Ns(t.get("file")),i=Ns(t.get("cwd"));return{...n?{folder:n}:{},...s?{file:s}:{},...i?{cwd:i}:{}}}function kf(e,t,n=[]){const s=new URLSearchParams(e);for(const a of n)s.delete(a);for(const[a,o]of Object.entries(t))o?s.set(a,o):s.delete(a);const i=s.toString();return i?`?${i}`:""}function ei(e,t={}){const n=t.history??window.history,s=t.location??window.location,i=[];e.folder&&i.push("file","cwd"),e.file&&i.push("folder");const a=kf(s.search,e,i),o=`${s.pathname}${a}${s.hash}`;if(t.replace){n.replaceState(null,"",o);return}n.pushState(null,"",o)}function hn(e,t){c.useEffect(()=>{e.current=t},[e,t])}function jf({activeSessionIdRef:e,composerDraftsRef:t,setComposerDrafts:n,setDraft:s}){const i=c.useCallback(o=>{s(o),n(l=>{const u=on(l,e.current,o);return t.current=u,an(u),u})},[e,t,n,s]),a=c.useCallback(o=>{n(l=>{const u=on(l,null,o);return t.current=u,an(u),u}),e.current||s(o)},[e,t,n,s]);return{updateDraft:i,updateNewSessionDraft:a}}function Cf(e,t,n){return!e||e.path!==t.path||e.cwd!==t.cwd?e:{...e,dirty:e.text!==t.text,etag:typeof n.etag=="string"?n.etag:e.etag,lastModified:typeof n.lastModified=="string"?n.lastModified:e.lastModified,size:typeof n.size=="number"?n.size:e.size}}function If(e){const{clientRef:t,pairing:n,cwd:s,phase:i,controlTab:a,setControlTab:o,setBusy:l,setErrorText:u,t:h}=e,d=c.useRef(!1),[m,g]=c.useState([]),[p,S]=c.useState(!1),w=c.useRef(new Set),[b,y]=c.useState({path:tn().folder||tn().cwd||dt,entries:[],loading:!1,loaded:!1}),[f,v]=c.useState(""),[k,j]=c.useState(null),[E,x]=c.useState(()=>new Set),C=T=>JSON.stringify([T.cwd,T.path,T.etag]),I=!!k&&E.has(C(k)),N=c.useRef(null),L=c.useRef(null),P=c.useRef(0),R=c.useRef(b.path);c.useEffect(()=>{R.current!==b.path&&(P.current++,R.current=b.path)},[b.path]),c.useEffect(()=>(P.current++,y({path:tn().folder||tn().cwd||s||dt,entries:[],loading:!1,loaded:!1}),g([]),S(!1),j(null),x(new Set),()=>{P.current++;for(const T of w.current)T.abort();w.current.clear(),L.current?.abort(),N.current&&(N.current.abort(),N.current=null,l(!1))}),[n?.pairToken]),c.useEffect(()=>{b.path!==dt||tn().folder||(P.current++,y(T=>({...T,entries:[],loaded:!1,loading:!1})))},[s]);const _=c.useRef(new Set);c.useEffect(()=>{k?.objectUrl&&_.current.add(k.objectUrl)},[k?.objectUrl]),c.useEffect(()=>()=>{for(const T of _.current)URL.revokeObjectURL(T);_.current.clear()},[n?.pairToken]);const V=c.useCallback(async T=>{if(!T?.length||!n)return;const $=new AbortController;w.current.add($),S(!0),u(null);try{for(const B of Array.from(T)){const Y=await fetch(`/upload?name=${encodeURIComponent(B.name)}`,{method:"POST",signal:$.signal,headers:{authorization:`Bearer ${n.pairToken}`,"content-type":B.type||"application/octet-stream"},body:B});if($.signal.aborted)return;if(!Y.ok)throw new Error(await Y.text().catch(()=>h.uploadFailed)||h.uploadFailed);const W=Qc(await Y.json());if($.signal.aborted)return;if(!W)throw new Error(h.uploadPathMissing);const J={path:W,name:B.name,type:B.type||"application/octet-stream",size:B.size};g(z=>[...z,J])}}catch(B){$.signal.aborted||u(B instanceof Error?B.message:String(B))}finally{w.current.delete($)&&S(w.current.size>0)}},[n,u,h.uploadFailed,h.uploadPathMissing]),Z=c.useCallback(async(T,$,B)=>{if(!n)return;L.current?.abort();const Y=new AbortController;L.current=Y,u(null);try{const W=/^(?:https?:\/\/|data:image\/|blob:)/i.test(T),J=await fetch(W?T:Zn(T,$),{headers:W?{}:{authorization:`Bearer ${n.pairToken}`},signal:Y.signal});if(!J.ok)throw new Error(await J.text().catch(()=>h.fileOpenFailed)||h.fileOpenFailed);const z=J.headers.get("content-type")??"application/octet-stream";if(W&&!z.startsWith("image/"))throw new Error(h.fileOpenFailed);const ne=ss(T,z,!1);if(ne==="html"||ne==="unsupported"&&tl(T,z)){const X=await J.text();if(Y.signal.aborted)return;j({path:T,cwd:$,kind:"text",contentType:z,text:X,etag:Gn(J.headers,"etag"),lastModified:Gn(J.headers,"last-modified"),size:Number(J.headers.get("content-length"))||void 0,dirty:!1})}else{const X=await J.blob();if(Y.signal.aborted)return;const qe=ss(T,z,!1)==="pdf"?new Blob([X],{type:"application/pdf"}):X;j({path:T,cwd:$,kind:nl(T,z)?"image":"binary",contentType:z,text:"",objectUrl:URL.createObjectURL(qe),etag:Gn(J.headers,"etag"),lastModified:Gn(J.headers,"last-modified"),size:X.size,dirty:!1})}o("files"),B?.updateRoute&&ei({file:T,...$?{cwd:$}:{}},{replace:B.replaceRoute})}catch(W){if(Y.signal.aborted)return;u(W instanceof Error?W.message:String(W))}},[n,o,u]),ue=c.useCallback(async T=>{if(!n||!k||k.kind!=="text"||N.current)return;const $=new AbortController;N.current=$,l(!0),u(null);try{const B=await fetch(Zn(k.path,k.cwd),{method:"PUT",signal:$.signal,headers:{authorization:`Bearer ${n.pairToken}`,"content-type":"text/markdown; charset=utf-8",...k.etag&&!T?.force?{"if-match":k.etag}:{}},body:k.text});if($.signal.aborted)return;if(!B.ok)throw B.status===409?(x(W=>new Set(W).add(C(k))),new Error(h.remoteFileConflict(k.path))):new Error(await B.text().catch(()=>h.fileSaveFailed)||h.fileSaveFailed);const Y=await B.json().catch(()=>({}));if($.signal.aborted)return;x(W=>{const J=new Set(W);return J.delete(C(k)),J}),j(W=>Cf(W,k,Y))}catch(B){$.signal.aborted||u(B instanceof Error?B.message:String(B))}finally{N.current===$&&(N.current=null,l(!1))}},[n,k,l,u]),ye=c.useCallback(async()=>{if(!(!n||!k))try{const T=/^(?:https?:\/\/|data:image\/|blob:)/i.test(k.path),$=await fetch(T?k.path:Zn(k.path,k.cwd),{headers:T?{}:{authorization:`Bearer ${n.pairToken}`}});if(!$.ok)throw new Error(h.downloadFailed);const B=URL.createObjectURL(await $.blob()),Y=document.createElement("a");Y.href=B,Y.download=Ht(k.path),Y.click(),URL.revokeObjectURL(B)}catch(T){u(T instanceof Error?T.message:String(T))}},[n,k,u]),D=c.useCallback(async(T=b.path,$)=>{const B=t.current;if(!B?.isConnected)return;R.current=T;const Y=++P.current;y(W=>({...W,path:T,entries:T===W.path?W.entries:[],loading:!0,loaded:!1,error:void 0}));try{const W=await B.request({action:"dirs.list",id:B.makeId("dirs"),path:T,cwd:s||void 0});if(Y!==P.current)return;y({path:T,entries:W.entries??[],loading:!1,loaded:!0}),$?.updateRoute&&ei({folder:T},{replace:$.replaceRoute})}catch(W){if(Y!==P.current)return;y(J=>({...J,loading:!1,loaded:!0,error:W instanceof Error?W.message:String(W)}))}},[t,s,b.path]),Q=c.useCallback(async T=>{const $=t.current;if(!$?.isConnected)throw new Error(h.webSocketNotConnected);return(await $.request({action:"dirs.list",id:$.makeId("dirs"),path:T,cwd:s||void 0},{timeoutMs:1e4,timeoutMessage:h.directoryListTimedOut})).entries??[]},[t,s]),G=c.useCallback(async T=>(await Q(T)).filter($=>$.isDirectory),[Q]);c.useEffect(()=>{!d.current||a!=="files"||i!=="connected"||b.loading||b.loaded||D(b.path||s||dt)},[a,s,b.loaded,b.loading,b.path,D,i]),c.useEffect(()=>{if(i!=="connected"||d.current)return;const T=tn();if(!T.folder&&!T.file){d.current=!0;return}if(d.current=!0,o("files"),T.folder){D(T.folder,{updateRoute:!1});return}T.file&&(T.cwd&&y($=>({...$,path:T.cwd,loaded:!1})),Z(T.file,T.cwd,{updateRoute:!1}))},[D,Z,i,o]);const re=c.useCallback(async()=>{const T=t.current;if(!(!T?.isConnected||f.trim().length===0)){l(!0),u(null);try{await T.request({action:"dirs.create",id:T.makeId("mkdir"),path:el(b.path,f),cwd:s||void 0}),v(""),await D(b.path)}catch($){u($ instanceof Error?$.message:String($))}finally{l(!1)}}},[t,s,b.path,D,f,l,u]),ae=c.useCallback(async T=>{const $=t.current;if(!$?.isConnected)throw new Error(h.webSocketNotConnected);await $.request({action:"dirs.create",id:$.makeId("mkdir"),path:T,cwd:s||void 0},{timeoutMs:1e4,timeoutMessage:h.directoryCreationTimedOut})},[t,s]);return{attachments:m,setAttachments:g,uploadBusy:p,directory:b,setDirectory:y,newDirName:f,setNewDirName:v,remoteFile:k,setRemoteFile:j,remoteFileConflict:I,uploadFiles:V,openRemoteFile:Z,saveRemoteFile:ue,downloadRemoteFile:ye,listDirectory:D,listSessionDirectories:G,listFileTreeDirectory:Q,createDirectory:re,createSessionDirectory:ae}}function Nf({clientRef:e,setSessions:t}){const n=c.useRef(new Map);return c.useEffect(()=>()=>n.current.clear(),[]),c.useCallback(async s=>{const i=e.current;if(!i?.isConnected)return;const a=[...new Set(s.map(l=>l.cwd).filter(Boolean))];if(a.length===0)return;const o={};for(const l of a)n.current.set(l,o);try{const l=await i.request({action:"sessions.gitMetadata",id:i.makeId("git"),cwds:a});if(e.current!==i||!i.isConnected)return;t(u=>u.map(h=>e.current===i&&i.isConnected&&n.current.get(h.cwd)===o?{...h,pullRequest:l.pullRequests?.[h.cwd],branchUrl:l.branchUrls?.[h.cwd],branch:l.branches[h.cwd]??h.branch,diffStat:l.diffStats[h.cwd]??h.diffStat}:h))}catch{}},[])}const Vs=15e3,ti=500,Es=1e3;function Ef(e){const t=c.useRef({}),n=c.useRef(null),s=c.useRef({}),i=c.useRef(null),[a,o]=c.useState(!1),[l,u]=c.useState([]),h=c.useCallback(x=>x&&n.current&&n.current!==x?!1:(n.current=null,o(!1),!0),[]),d=c.useCallback(x=>ms(t.current,x)?(i.current=x,u(t.current[x]??[]),!0):!1,[]),m=c.useCallback((x,C,I)=>{t.current=cf(t.current,x,C);const N=t.current[x]??[];return I?.renderActive!==!1&&x===e.activeSessionIdRef.current&&(i.current=x,u(N)),N},[e.activeSessionIdRef]),g=c.useCallback((x,C,I)=>{if(!I)return s.current[x]=void 0,m(x,C);const N=s.current[x],L=t.current[x]??[],P=I.start+C.length;if(N===void 0||P<N||I.start>N+L.length)return s.current[x]=I.start,m(x,C);s.current[x]=Math.min(N,I.start);const R=L.slice(0,Math.max(0,I.start-N)),_=L.slice(Math.max(0,P-N),Math.max(0,I.total-N));return m(x,[...R,...C,..._])},[m]),p=c.useCallback((x,C)=>{s.current[x]=0;const I=m(x,C,{renderActive:!1});i.current=x,u(I)},[m]),S=c.useCallback((x,C)=>{t.current=ya(t.current,x,C),x===e.activeSessionIdRef.current&&(i.current=x,u(t.current[x]??[]))},[e.activeSessionIdRef]),w=c.useCallback((x,C)=>{t.current=lf(t.current,x,C),x===e.activeSessionIdRef.current&&(i.current=x,u(t.current[x]??[]))},[e.activeSessionIdRef]),b=c.useCallback((x,C)=>Ol(t.current,x,C),[]),y=c.useCallback((x,C,I,N)=>{x=b(x,C);const L=ql(t.current[x]??[],C,I,N);return t.current={...t.current,[x]:L},(x===e.activeSessionIdRef.current||x===i.current)&&(i.current=x,u(t.current[x]??[])),L.find(P=>P.localClientMessageId===C)?.localDelivery},[e.activeSessionIdRef]),f=c.useCallback((x,C)=>{t.current=df(t.current,x,C),x===e.activeSessionIdRef.current&&(i.current=x,u(t.current[x]??[]))},[e.activeSessionIdRef]),v=c.useCallback((x,C)=>{S(x,[{role:"assistant",type:"info",content:C,timestamp:new Date().toISOString()}])},[S]),k=c.useCallback(x=>{t.current=hf(t.current,x),delete s.current[x]},[]),j=c.useCallback((x,C)=>{t.current=uf(t.current,x,C),s.current[C]=s.current[x],delete s.current[x]},[]),E=c.useCallback(async x=>{const C=e.clientRef.current;if(!C?.isConnected)return;const I=d(x.sessionId);I?h(x.sessionId):(n.current=x.sessionId,delete s.current[x.sessionId],o(!0),e.setErrorText(null));try{const N=s.current[x.sessionId]??0,L=t.current[x.sessionId]?.length??0;if(I&&(N===0||L>=Es)){const _=(await C.request({action:"reconnect.snapshot",id:C.makeId("snapshot"),activeSessionId:x.sessionId,activeAgent:x.agent,skipActiveSessionHistory:!0,skipGitMetadata:!0})).snapshot.activeSession;_?.sessionId===x.sessionId&&e.setPendingQueues(V=>({...V,[x.sessionId]:_.pendingQueue??[]}));return}await C.request({action:"session.history",id:C.makeId("history"),sessionId:x.sessionId,agent:x.agent,limit:ti},{timeoutMessage:e.historyTimeoutMessage,timeoutMs:Vs});let P=s.current[x.sessionId];for(;typeof P=="number"&&P>0&&(t.current[x.sessionId]?.length??0)<Es;){const R=t.current[x.sessionId]?.length??0;await C.request({action:"session.history",id:C.makeId("history_older"),sessionId:x.sessionId,agent:x.agent,before:P,limit:Math.min(ti,Es-R)},{timeoutMessage:e.historyTimeoutMessage,timeoutMs:Vs});const _=s.current[x.sessionId];if(typeof _!="number"||_>=P)break;P=_}}catch(N){e.activeSessionIdRef.current===x.sessionId&&e.setErrorText(N instanceof Error?N.message:String(N))}finally{h(x.sessionId)}},[h,e.activeSessionIdRef,e.clientRef,e.historyTimeoutMessage,e.setErrorText,e.setPendingQueues,d]);return{resolveCachedMessageSession:b,setCachedMessageDelivery:y,appendCachedDelta:f,appendCachedHistory:S,appendInfoMessage:v,clearHistoryLoading:h,ensureCachedHistoryEntry:w,historyCacheRef:t,historyLoading:a,historyPageStartRef:s,hydrateVisibleHistory:p,messages:l,messagesSessionIdRef:i,mergeCachedHistoryPage:g,remapCachedHistory:j,removeCachedHistory:k,renderCachedHistory:d,replaceCachedHistory:m,requestHistory:E,setMessages:u}}function Rf(e){const{clientRef:t,activeSessionIdRef:n,search:s,sinceFilter:i,hideArchived:a,sessionAgentFilter:o}=e,l=c.useMemo(()=>({}),[s,i,a,o,n.current]),u=c.useRef({scope:l,options:e,request:0});return u.current.scope=l,u.current.options=e,c.useEffect(()=>()=>{u.current.request++},[]),c.useCallback(async()=>{const h=t.current;if(!h?.isConnected)return;const d=++u.current.request,m=()=>t.current===h&&h.isConnected&&u.current.request===d;for(;m();){const g=u.current,p=g.scope,S=g.options,w=n.current,b=()=>u.current.scope===p&&n.current===w;try{const y=await h.request({action:"reconnect.snapshot",id:h.makeId("snapshot"),activeSessionId:w??void 0,activeAgent:S.activeAgent,agent:S.sessionAgentFilter==="all"?void 0:S.sessionAgentFilter,search:S.search.trim()||void 0,sinceMs:Mi(S.sinceFilter),hideArchived:S.hideArchived,skipGitMetadata:!0});if(!m())return;if(!b())continue;u.current.options.apply(y.snapshot);return}catch(y){if(!m())return;if(b())throw y}}},[t,n])}function Af(e){const{clientRef:t,search:n,sinceFilter:s,hideArchived:i,sessionAgentFilter:a,viewKey:o}=e,l=c.useMemo(()=>({refresh:0}),[n,s,i,a,o]),u=c.useRef({options:e,scope:l});u.current={options:e,scope:l};const h=c.useRef(l);c.useLayoutEffect(()=>{h.current!==l&&(h.current=l,e.setNextCursor(void 0))},[e.setNextCursor,l]);const d=c.useRef(!0);return c.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),c.useCallback(async m=>{const g=t.current;if(!d.current||!g?.isConnected||u.current.scope!==l)return;const p=m?.append?l.refresh:++l.refresh,S=()=>d.current&&t.current===g&&g.isConnected&&u.current.scope===l&&(m?.append||p===l.refresh);try{const w=await g.request({action:"sessions.list",id:g.makeId(m?.append?"sessions_more":"sessions"),limit:m?.preserveLoaded?Math.max(Cr,u.current.options.loadedCount):Cr,cursor:m?.cursor,agent:a==="all"?void 0:a,search:n.trim()||void 0,sinceMs:Mi(s),hideArchived:i,skipGitMetadata:!0,force:m?.force});if(!S())return;const b=Ti(w),y=u.current.options;y.setSessionsFromPage(b,m?.append),y.setActiveSessionId(f=>f??b.sessions[0]?.sessionId??null),y.hydrateGitMetadata(b.sessions),y.prefetchActiveHistories(b.sessions)}catch(w){if(S())throw w}},[t,l,n,s,i,a])}function Tf(e){const t=async n=>{(n==="needsAttention"?e.setShowNeedsAttentionGroup:n==="running"?e.setShowRunningGroup:e.setSeparatePinnedGroup)(i=>!i)};return{showNeedsAttentionGroup:e.showNeedsAttentionGroup,showRunningGroup:e.showRunningGroup,separatePinnedGroup:e.separatePinnedGroup,toggleSessionViewGroup:t}}function Mf(e,t){const n=t.trim().toLowerCase();return n?[Et(e),e.cwd,e.agent,e.branch??"",...e.titleAliases??[]].some(s=>s.toLowerCase().includes(n)):!0}function Pf(e,t){return e.filter(n=>t.hideArchived&&n.archived||t.agentFilter!=="all"&&n.agent!==t.agentFilter?!1:Mf(n,t.search))}function Df(e){const t=c.useRef([]),n=c.useMemo(()=>_s(_s(e.sessions,Object.values(e.optimisticSessions)),Object.values(e.pendingSessions)),[e.optimisticSessions,e.pendingSessions,e.sessions]),s=c.useMemo(()=>new Set(Object.keys(e.pendingSessions)),[e.pendingSessions]),i=c.useMemo(()=>n.find(p=>p.sessionId===e.activeSessionId)??null,[e.activeSessionId,n]),a=Object.values(e.pendingApprovals)[0]??null,o=Object.values(e.pendingQuestions)[0]??null,l=c.useMemo(()=>ka(Pf(n,{search:e.search,hideArchived:e.hideArchived,agentFilter:e.sessionAgentFilter}),e.sessionSort??"updated"),[n,e.hideArchived,e.search,e.sessionAgentFilter,e.sessionSort]),u=c.useMemo(()=>new Set([...Object.keys(e.pendingApprovals),...Object.keys(e.pendingQuestions)]),[e.pendingApprovals,e.pendingQuestions]),h=l.filter(p=>e.respondingSessionIds.has(p.sessionId)).map(p=>p.sessionId),d=new Set(h),m=t.current.filter(p=>d.has(p));for(const p of h)m.includes(p)||m.push(p);t.current=m;const g=c.useMemo(()=>ja(zc(l,{needsAttentionSessionIds:u,respondingSessionIds:e.respondingSessionIds,runningSessionOrder:m,separatePinnedGroup:e.separatePinnedGroup,showNeedsAttentionGroup:e.showNeedsAttentionGroup,showRunningGroup:e.showRunningGroup}),e.sessionSort??"updated"),[u,e.respondingSessionIds,e.separatePinnedGroup,e.showNeedsAttentionGroup,e.showRunningGroup,e.sessionSort,l,m]);return{activeApproval:a,activeQuestion:o,activeSession:i,displaySessions:n,groupedSessions:g,pendingSessionIds:s,visibleSessions:l}}const _f=new Set(["attachmentCount","domNodes","durationMs","errorKind","failureKind","longTaskCount","maxLongTaskMs","online","phase","visibilityState"]);function Lf(e){const t={};for(const[n,s]of Object.entries(e))_f.has(n)&&(typeof s=="string"?t[n]=s.slice(0,48):typeof s=="number"&&Number.isFinite(s)?t[n]=Math.round(s):typeof s=="boolean"&&(t[n]=s));return t}function ni(e){return e instanceof TypeError?"TypeError":e instanceof RangeError?"RangeError":e instanceof SyntaxError?"SyntaxError":e instanceof Error?"Error":typeof e=="string"?"string":typeof e}function $f(e){c.useEffect(()=>{const t=performance.now(),n=(h,d,m="info")=>e(h,Lf(d),m),s=h=>{n("web.telemetry.runtime_error",{errorKind:ni(h.error)},"error")},i=h=>{n("web.telemetry.unhandled_rejection",{errorKind:ni(h.reason)},"error")},a=window.setTimeout(()=>{n("web.telemetry.workspace_ready",{durationMs:performance.now()-t,domNodes:document.getElementsByTagName("*").length,online:navigator.onLine,visibilityState:document.visibilityState})},1500);let o=0,l=0,u=null;return typeof PerformanceObserver<"u"&&PerformanceObserver.supportedEntryTypes.includes("longtask")&&(u=new PerformanceObserver(h=>{for(const d of h.getEntries())o+=1,l=Math.max(l,d.duration)}),u.observe({entryTypes:["longtask"]})),window.addEventListener("error",s),window.addEventListener("unhandledrejection",i),()=>{window.clearTimeout(a),window.removeEventListener("error",s),window.removeEventListener("unhandledrejection",i),u?.disconnect(),o>0&&n("web.telemetry.long_tasks",{longTaskCount:o,maxLongTaskMs:l},"warn")}},[e])}const Ff=6;function Of(e,t){return t.has(e.sessionId)||e.runtime?.isResponding===!0||e.runtime?.state==="daemonActive"||e.runtime?.state==="externalRunning"}function qf(e,t,n,s,i=Ff){if(i<=0)return[];const a=[];for(const o of e){if(a.length>=i)break;!o.sessionId||!Of(o,n)||ms(t,o.sessionId)||s.has(o.sessionId)||a.push(o)}return a}function Wf(e,t,n=!1){const s=new Set(t.map(i=>i.sessionId));return _s(n?e:e.filter(i=>s.has(i.sessionId)),t)}function Hf(e,t,n){return e.replace(/tailcat/gi,t).replace(/(?:https?:\/\/|wss?:\/\/)?\b127\.0\.0\.1\b(?::\d+)?/gi,n)}class Bf{cleared=new Map;live(t,n,s){const i=new Set(s.map(o=>o.clientMessageId)),a=this.cleared.get(n)??new Set;for(const o of t[n]??[])o.clientMessageId&&!i.has(o.clientMessageId)&&a.add(o.clientMessageId);for(const o of i)o&&a.delete(o);return this.cleared.set(n,a),{...t,[n]:s}}snapshot(t){return Object.fromEntries(Object.entries(t).map(([n,s])=>[n,s.filter(i=>!i.clientMessageId||!this.cleared.get(n)?.has(i.clientMessageId))]))}remap(t,n){const s=this.cleared.get(t);s&&(this.cleared.set(n,new Set([...this.cleared.get(n)??[],...s])),this.cleared.delete(t))}}function zf(){const e=c.useRef(new Bf),[t,n]=c.useState({}),s=c.useCallback(o=>{n(l=>e.current.snapshot(typeof o=="function"?o(l):o))},[]),i=c.useCallback((o,l)=>{n(u=>e.current.live(u,o,l))},[]),a=c.useCallback((o,l)=>{e.current.remap(o,l)},[]);return{pendingQueues:t,setPendingQueues:s,setLivePendingQueue:i,remapPendingQueue:a}}function Kf(e,t,n=1/0){return Math.min(Math.max(Math.round(e),t),n)}function Gf(e,t){const n=e.leftCollapsed?0:e.leftPaneWidth,s=e.rightCollapsed?0:e.rightPaneWidth,i=n+s,a=i>t?Math.max(0,t)/i:1;return{leftPaneWidth:e.leftCollapsed?e.leftPaneWidth:Math.floor(n*a),rightPaneWidth:e.rightCollapsed?e.rightPaneWidth:Math.floor(s*a)}}function Uf(e){return{workspaceClassName:["workspace",e.leftCollapsed&&"left-sidebar-collapsed"].filter(Boolean).join(" "),wideMainClassName:["wide-main",e.rightCollapsed&&"right-sidebar-collapsed"].filter(Boolean).join(" "),style:{"--left-pane-width":`${e.leftPaneWidth}px`,"--right-pane-width":`${e.rightPaneWidth}px`}}}const si=96,Vf=64,Qf=252,Zf=234;function Yf(e,t){const[n,s]=c.useState(288),[i,a]=c.useState(297),[o,l]=c.useState(()=>window.innerWidth);c.useEffect(()=>{const d=()=>l(window.innerWidth);return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[]);const u=Gf({leftCollapsed:e,rightCollapsed:t,leftPaneWidth:n,rightPaneWidth:i},o-si-Vf),h=c.useCallback(d=>m=>{m.preventDefault();const g=m.clientX,p=d==="left"?u.leftPaneWidth:u.rightPaneWidth,S=m.currentTarget.closest(".workspace")?.querySelector(".chat-pane"),w=p+Math.max(0,(S?.getBoundingClientRect().width??0)-si),b=f=>{const v=(f.clientX-g)*(d==="left"?1:-1),k=Kf(p+v,d==="left"?Qf:Zf,w);d==="left"?s(k):a(k)},y=()=>{document.body.classList.remove("pane-resizing"),window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),window.removeEventListener("blur",y)};document.body.classList.add("pane-resizing"),window.addEventListener("pointermove",b),window.addEventListener("pointerup",y,{once:!0}),window.addEventListener("pointercancel",y,{once:!0}),window.addEventListener("blur",y,{once:!0})},[u.leftPaneWidth,u.rightPaneWidth]);return{...u,beginPaneResize:h}}function Jf(e,t){const[n,s]=c.useState(e);c.useEffect(()=>{const z=()=>{const ne=Xe();s(X=>({...X,theme:ne.theme,language:ne.language,composer:ne.composer}))};return window.addEventListener("vibelet.preferences.changed",z),()=>window.removeEventListener("vibelet.preferences.changed",z)},[]);const[i,a]=c.useState(e.sessionList.sortOrder),[o,l]=c.useState(""),[u,h]=c.useState(e.sessionList.searchHistory),[d,m]=c.useState(e.sessionList.sinceFilter),[g,p]=c.useState(e.sessionList.hideArchived),[S,w]=c.useState(e.sessionList.groupFolders),[b,y]=c.useState(e.sessionList.showNeedsAttentionGroup),[f,v]=c.useState(e.sessionList.showRunningGroup),[k,j]=c.useState(e.sessionList.separatePinnedGroup),[E,x]=c.useState(e.sessionList.collapsedFolders),[C,I]=c.useState(e.sessionList.agentFilter),[N,L]=c.useState(t),[P,R]=c.useState(e.layout.leftSidebarCollapsed),[_,V]=c.useState(e.layout.rightSidebarCollapsed),{leftPaneWidth:Z,rightPaneWidth:ue,beginPaneResize:ye}=Yf(P,_),D=n.sessionList.directoryTags,Q=n.sessionList.archiveSyncedDaemonIds,G=n.sessionList.archiveSyncCardDismissedDaemonIds,re=n.composer,ae=Uf({leftCollapsed:P,rightCollapsed:_,leftPaneWidth:Z,rightPaneWidth:ue});c.useEffect(()=>{s(z=>{const ne={...z,sessionList:{...z.sessionList,searchHistory:u,sortOrder:i,sinceFilter:d,hideArchived:g,groupFolders:S,showNeedsAttentionGroup:b,showRunningGroup:f,separatePinnedGroup:k,collapsedFolders:E,agentFilter:C},layout:{...z.layout,leftSidebarCollapsed:P,rightSidebarCollapsed:_}};return In(ne),ne})},[E,S,g,P,_,u,k,C,b,f,d,i]);const T=c.useCallback(()=>{h(z=>Ca(z,o))},[o]),$=c.useCallback(z=>{L(z),ha(z)},[]),B=c.useCallback(z=>{s(ne=>{const X={...ne,language:z};return In(X),X})},[]),Y=c.useCallback(z=>{s(ne=>{const X={...ne,theme:z};return In(X),X})},[]),W=c.useCallback(z=>{s(ne=>{const X={...ne,sessionList:z(ne.sessionList)};return In(X),X})},[]),J=c.useCallback(z=>{s(ne=>{const X={...ne,composer:z(ne.composer)};return In(X),X})},[]);return{webPreferences:n,sessionSort:i,setSessionSort:a,search:o,setSearch:l,sinceFilter:d,setSinceFilter:m,hideArchived:g,setHideArchived:p,groupFolders:S,setGroupFolders:w,showNeedsAttentionGroup:b,setShowNeedsAttentionGroup:y,showRunningGroup:f,setShowRunningGroup:v,separatePinnedGroup:k,setSeparatePinnedGroup:j,collapsedFolders:E,setCollapsedFolders:x,sessionAgentFilter:C,setSessionAgentFilter:I,directoryTags:D,archiveSyncedDaemonIds:Q,archiveSyncCardDismissedDaemonIds:G,composerPreferences:re,savedTargets:N,setSavedTargets:L,leftSidebarCollapsed:P,setLeftSidebarCollapsed:R,rightSidebarCollapsed:_,setRightSidebarCollapsed:V,workspaceClassName:ae.workspaceClassName,wideMainClassName:ae.wideMainClassName,workspaceStyle:ae.style,beginPaneResize:ye,commitSearch:T,saveTargets:$,setLanguagePreference:B,setThemePreference:Y,updateSessionListPreferences:W,updateComposerPreferences:J}}function Xf(e){c.useEffect(()=>{const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>Ia(e,document.documentElement,t.matches);if(n(),e==="system")return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[e])}function em(){const e=c.useRef(null),t=c.useRef(async()=>{}),n=c.useRef(null),s=c.useRef(Pn()),i=c.useRef(Ps()),a=c.useRef(Xe()),o=c.useRef(sf()),l=c.useRef(Oh()),u=c.useRef(s.current),h=c.useRef(i.current),d=c.useRef(o.current),m=c.useRef(null),g=c.useRef(null),p=c.useRef(new Set),S=c.useRef(null),w=c.useRef(new Set),b=c.useRef(null),y=c.useRef(0),f=c.useRef(new Set),v=c.useRef({}),k=c.useRef(!1),[j,E]=c.useState("connecting"),[x,C]=c.useState(()=>Rs[Je(a.current.language)].preparingVibeletWeb),[I,N]=c.useState(null),[L,P]=c.useState(null),[R,_]=c.useState([]),[V,Z]=c.useState({}),[ue,ye]=c.useState({}),[D,Q]=c.useState(),[G,re]=c.useState({}),[ae,T]=c.useState(),[$,B]=c.useState(null),[Y,W]=c.useState(null),[J,z]=c.useState(()=>new Set),[ne,X]=c.useState({}),[qe,me]=c.useState({}),[Ue,Se]=c.useState({}),{pendingQueues:Ie,setPendingQueues:Ne,setLivePendingQueue:ke,remapPendingQueue:be}=zf(),[Ee,Ve]=c.useState("claude"),[We,Qe]=c.useState(dt),[Ze,he]=c.useState(sr),[je]=c.useState(!1),[et,Pe]=c.useState(""),[oe,Ce]=c.useState(""),[tt,xe]=c.useState(!1),[De,Re]=c.useState(""),[ce,te]=c.useState(o.current),[A,Ae]=c.useState(()=>cn(o.current,null)),{webPreferences:pe,sessionSort:nt,setSessionSort:ut,setRightSidebarCollapsed:at,search:ge,setSearch:le,sinceFilter:ee,setSinceFilter:we,hideArchived:Ye,setHideArchived:st,groupFolders:yt,setGroupFolders:Bt,showNeedsAttentionGroup:bt,setShowNeedsAttentionGroup:Rt,showRunningGroup:$t,setShowRunningGroup:He,separatePinnedGroup:St,setSeparatePinnedGroup:At,collapsedFolders:ot,setCollapsedFolders:ct,sessionAgentFilter:lt,setSessionAgentFilter:kt,directoryTags:Tt,archiveSyncedDaemonIds:Mt,archiveSyncCardDismissedDaemonIds:ht,composerPreferences:O,savedTargets:U,setSavedTargets:de,leftSidebarCollapsed:_e,setLeftSidebarCollapsed:ft,rightSidebarCollapsed:Le,workspaceClassName:mt,wideMainClassName:ve,workspaceStyle:jt,beginPaneResize:Be,commitSearch:$e,saveTargets:vt,setLanguagePreference:Ft,setThemePreference:Kt,updateSessionListPreferences:Pt,updateComposerPreferences:Dt}=Jf(a.current,l.current),Ct=Je(pe.language),It=Rs[Ct],[Gt,Ut]=c.useState(!1),[Vt,Ot]=c.useState("session"),[qt,Qt]=c.useState(!1);Xf(pe.theme);const Zt=c.useCallback(jn=>{Ot(jn),at(!1)},[at]),[H,q]=c.useState({}),[K,fe]=c.useState({}),[Fe,xt]=c.useState([]),[Wt,bn]=c.useState({statusText:"",loading:!1,action:null}),[vn,xn]=c.useState(vr),[wn,Sn]=c.useState(i.current),[dn,un]=c.useState(s.current),[kn,Bn]=c.useState(null),[zn,Kn]=c.useState(null);return{clientRef:e,connectWithPairingRef:t,activeSessionIdRef:n,initialNotificationPermissionRef:s,initialNotificationSettingsRef:i,initialPreferencesRef:a,initialComposerDraftsRef:o,initialSavedTargetsRef:l,notificationPermissionRef:u,notificationSettingsRef:h,composerDraftsRef:d,lastHistorySessionIdRef:m,historyCacheDaemonIdRef:g,historyPrefetchingSessionIdsRef:p,pairingRef:S,notifiedEventsRef:w,reconnectTimerRef:b,connectionAttemptIdRef:y,respondingSessionsRef:f,turnNotificationCountsRef:v,intentionalDisconnectRef:k,phase:j,setPhase:E,statusText:x,setStatusText:C,errorText:I?Hf(I,It.remoteDirectConnection,It.localConnection):null,setErrorText:N,pairing:L,setPairing:P,sessions:R,setSessions:_,pendingSessions:V,setPendingSessions:Z,optimisticSessions:ue,setOptimisticSessions:ye,nextCursor:D,setNextCursor:Q,folderCounts:G,setFolderCounts:re,inventoryVersion:ae,setInventoryVersion:T,activeSessionId:$,setActiveSessionId:B,diffSessionId:Y,setDiffSessionId:W,respondingSessions:J,setRespondingSessions:z,pendingApprovals:ne,setPendingApprovals:X,pendingQuestions:qe,setPendingQuestions:me,questionAnswers:Ue,setQuestionAnswers:Se,pendingQueues:Ie,setPendingQueues:Ne,setLivePendingQueue:ke,remapPendingQueue:be,agent:Ee,setAgent:Ve,cwd:We,setCwd:Qe,approvalMode:Ze,setApprovalMode:he,continueSession:je,model:et,setModel:Pe,effort:oe,setEffort:Ce,fastMode:tt,setFastMode:xe,renameTitle:De,setRenameTitle:Re,composerDrafts:ce,setComposerDrafts:te,draft:A,setDraft:Ae,webPreferences:pe,sessionSort:nt,setSessionSort:ut,search:ge,setSearch:le,sinceFilter:ee,setSinceFilter:we,hideArchived:Ye,setHideArchived:st,groupFolders:yt,setGroupFolders:Bt,showNeedsAttentionGroup:bt,setShowNeedsAttentionGroup:Rt,showRunningGroup:$t,setShowRunningGroup:He,separatePinnedGroup:St,setSeparatePinnedGroup:At,collapsedFolders:ot,setCollapsedFolders:ct,sessionAgentFilter:lt,setSessionAgentFilter:kt,directoryTags:Tt,archiveSyncedDaemonIds:Mt,archiveSyncCardDismissedDaemonIds:ht,composerPreferences:O,savedTargets:U,setSavedTargets:de,leftSidebarCollapsed:_e,setLeftSidebarCollapsed:ft,rightSidebarCollapsed:Le,setRightSidebarCollapsed:at,workspaceClassName:mt,wideMainClassName:ve,workspaceStyle:jt,beginPaneResize:Be,commitSearch:$e,saveTargets:vt,setLanguagePreference:Ft,setThemePreference:Kt,updateSessionListPreferences:Pt,updateComposerPreferences:Dt,language:Ct,t:It,busy:Gt,setBusy:Ut,controlTab:Vt,setControlTab:Ot,detailsOpen:qt,setDetailsOpen:Qt,setControlTabAndOpen:Zt,modelOptions:H,setModelOptions:q,usageLimits:K,setUsageLimits:fe,skills:Fe,setSkills:xt,admin:Wt,setAdmin:bn,daemonMetadata:vn,setDaemonMetadata:xn,notificationSettings:wn,setNotificationSettings:Sn,notificationPermission:dn,setNotificationPermission:un,archiveSyncBusy:kn,setArchiveSyncBusy:Bn,archiveSyncStatus:zn,setArchiveSyncStatus:Kn}}function tm(){const e=em(),t=Tf(e),{clientRef:n,activeSessionIdRef:s,notificationPermissionRef:i,notificationSettingsRef:a,composerDraftsRef:o,lastHistorySessionIdRef:l,historyPrefetchingSessionIdsRef:u,pairingRef:h,reconnectTimerRef:d,respondingSessionsRef:m,phase:g,setStatusText:p,setErrorText:S,pairing:w,setSessions:b,setOptimisticSessions:y,setNextCursor:f,setFolderCounts:v,setInventoryVersion:k,activeSessionId:j,setActiveSessionId:E,respondingSessions:x,setRespondingSessions:C,pendingApprovals:I,setPendingApprovals:N,pendingQuestions:L,setPendingQuestions:P,setQuestionAnswers:R,pendingQueues:_,setPendingQueues:V,agent:Z,setAgent:ue,cwd:ye,setCwd:D,setApprovalMode:Q,composerDrafts:G,setComposerDrafts:re,search:ae,sinceFilter:T,hideArchived:$,sessionAgentFilter:B,setRightSidebarCollapsed:Y,t:W,controlTab:J,setControlTab:z,setControlTabAndOpen:ne,modelOptions:X,setModelOptions:qe,usageLimits:me,setUsageLimits:Ue,setSkills:Se,setDaemonMetadata:Ie,notificationSettings:Ne,setNotificationSettings:ke,notificationPermission:be,setNotificationPermission:Ee,sessions:Ve,pendingSessions:We,optimisticSessions:Qe,setDraft:Ze,setBusy:he}=e,{remoteFile:je,attachments:et,setAttachments:Pe,uploadBusy:oe,directory:Ce,setDirectory:tt,newDirName:xe,setNewDirName:De,setRemoteFile:Re,remoteFileConflict:ce,uploadFiles:te,openRemoteFile:A,saveRemoteFile:Ae,downloadRemoteFile:pe,listDirectory:nt,listSessionDirectories:ut,listFileTreeDirectory:at,createDirectory:ge,createSessionDirectory:le}=If({clientRef:n,pairing:w,cwd:ye,phase:g,controlTab:J,setControlTab:ne,setBusy:he,setErrorText:S,t:W}),ee=Object.keys(I).length+Object.keys(L).length,we=j?_[j]??[]:[],Ye=X[Z]??[],st=me[Z],{activeSession:yt,activeApproval:Bt,activeQuestion:bt,displaySessions:Rt,groupedSessions:$t,pendingSessionIds:He,visibleSessions:St}=Df({activeSessionId:j,hideArchived:$,optimisticSessions:Qe,pendingApprovals:I,pendingQuestions:L,pendingSessions:We,respondingSessionIds:x,search:ae,separatePinnedGroup:t.separatePinnedGroup,sessionAgentFilter:B,sessionSort:e.sessionSort,sessions:Ve,showNeedsAttentionGroup:t.showNeedsAttentionGroup,showRunningGroup:t.showRunningGroup}),{historyCacheRef:At,historyPageStartRef:ot,hydrateVisibleHistory:ct,messagesSessionIdRef:lt,remapCachedHistory:kt,appendCachedDelta:Tt,appendCachedHistory:Mt,appendInfoMessage:ht,clearHistoryLoading:O,ensureCachedHistoryEntry:U,setCachedMessageDelivery:de,resolveCachedMessageSession:_e,historyLoading:ft,messages:Le,mergeCachedHistoryPage:mt,removeCachedHistory:ve,renderCachedHistory:jt,replaceCachedHistory:Be,requestHistory:$e,setMessages:vt}=Ef({activeSessionIdRef:s,clientRef:n,historyTimeoutMessage:W.historyRequestTimedOut,setPendingQueues:V,setErrorText:S});hn(s,j),hn(h,w),hn(m,x),hn(a,Ne),hn(i,be),hn(o,G);const{updateNewSessionDraft:Ft,updateDraft:Kt}=jf({activeSessionIdRef:s,composerDraftsRef:o,setComposerDrafts:re,setDraft:Ze});c.useEffect(()=>{Na();const H=Ea();H&&(Ft(H),z("session"),Ra())},[Ft]),c.useEffect(()=>{const H=()=>{ke(Ps()),Ee(Pn())};return window.addEventListener("vibelet.notifications.changed",H),()=>window.removeEventListener("vibelet.notifications.changed",H)},[]),c.useEffect(()=>{J==="admin"&&Ee(Pn())},[J]),c.useEffect(()=>()=>{d.current&&window.clearTimeout(d.current)},[]);const Pt=c.useCallback((H,q=!1)=>{b(K=>Wf(K,H.sessions,q)),y(K=>{const fe=new Set(H.sessions.map(xt=>xt.sessionId)),Fe=Object.fromEntries(Object.entries(K).filter(([xt])=>!fe.has(xt)));return Object.keys(Fe).length===Object.keys(K).length?K:Fe}),f(H.nextCursor),k(H.inventoryVersion),H.folderCounts&&v(H.folderCounts),q||Xh(h.current?.daemonId,H),p(H.inventoryBackfillInFlight?W.connectedIndexing:W.connected)},[W.connected,W.connectedIndexing]),Dt=Nf({clientRef:n,setSessions:b}),Ct=c.useCallback((H,q=m.current)=>{const K=n.current;if(!K?.isConnected||H.length===0)return;const fe=qf(H,At.current,q,u.current);for(const Fe of fe)u.current.add(Fe.sessionId),K.request({action:"session.history",id:K.makeId("history_prefetch"),sessionId:Fe.sessionId,agent:Fe.agent},{timeoutMessage:W.historyPrefetchTimedOut,timeoutMs:Vs}).catch(()=>{}).finally(()=>{u.current.delete(Fe.sessionId)})},[W.historyPrefetchTimedOut]),It=c.useCallback(H=>{const q=al(H,{currentActiveSessionId:s.current,currentCwd:ye});Pt(q.page,!1),f(q.page.nextCursor),k(q.page.inventoryVersion),q.messages&&q.activeSessionId&&ct(q.activeSessionId,q.messages),E(q.activeSessionId),q.activeAgent&&ue(q.activeAgent),q.activeCwd&&D(q.activeCwd),q.activeApprovalMode&&Q(q.activeApprovalMode),q.questionAnswers&&R(q.questionAnswers),m.current=new Set(q.respondingSessionIds),C(m.current),N(q.pendingApprovals),P(q.pendingQuestions),V(q.pendingQueues),Dt(H.sessions),Ct(H.sessions,new Set(q.respondingSessionIds))},[ye,Dt,ct,Ct,Pt]),Gt=Rf({clientRef:n,activeSessionIdRef:s,activeAgent:yt?.agent??Z,sessionAgentFilter:B,search:ae,sinceFilter:T,hideArchived:$,apply:It}),Ut=Af({clientRef:n,search:ae,sinceFilter:T,hideArchived:$,sessionAgentFilter:B,viewKey:[e.sessionSort,e.groupFolders,t.showNeedsAttentionGroup,t.showRunningGroup,t.separatePinnedGroup].join(":"),loadedCount:Ve.length,setNextCursor:f,setSessionsFromPage:Pt,setActiveSessionId:E,hydrateGitMetadata:Dt,prefetchActiveHistories:Ct}),Vt=c.useCallback(async(H,q)=>{const K=n.current;if(K?.isConnected)try{const[fe,Fe,xt]=await Promise.all([K.request({action:"models.list",id:K.makeId("models"),agent:H}),K.request({action:"usage.limits.fetch",id:K.makeId("usage"),agent:H}),K.request({action:"skills.list",id:K.makeId("skills"),cwd:q||void 0})]);qe(Wt=>({...Wt,[H]:fe.options??[]})),Ue(Wt=>({...Wt,[H]:Fe})),Se(Array.isArray(xt.skills)?xt.skills:[])}catch(fe){S(fe instanceof Error?fe.message:String(fe))}},[]),Ot=c.useCallback((H,q,K="info")=>{const fe=n.current;fe?.isConnected&&fe.request({action:"log.report",id:fe.makeId("log"),entries:[{level:K,event:H,data:q,ts:new Date().toISOString()}]}).catch(()=>{})},[]);$f(Ot);const qt=c.useCallback(async(H=h.current)=>{if(!H){Ie(vr);return}Ie(q=>({...q,loading:!0,error:null}));try{const q=await fetch(lh(H,window.location,{sameOrigin:!1}),{cache:"no-store"});if(!q.ok)throw new Error(`HTTP ${q.status}`);const K=dh(await q.json().catch(()=>null));Ie({...K,loading:!1,error:null})}catch{Ie(q=>({...q,loading:!1,error:W.connectorVersionFailed}))}},[W.connectorVersionFailed]);c.useEffect(()=>{const H=()=>{ke(Ps()),Ee(Pn())};return window.addEventListener("vibelet.notifications.changed",H),()=>window.removeEventListener("vibelet.notifications.changed",H)},[]),c.useEffect(()=>{J==="admin"&&g==="connected"&&qt()},[J,g,qt]);const Qt=c.useCallback(H=>{ke(q=>{const K={...q,...H};return a.current=K,_c(K),K})},[]),Zt=c.useCallback((H,q)=>{!H||!q||H===q||(E(K=>K===H?q:K),l.current===H&&(l.current=q),lt.current===H&&(lt.current=q),kt(H,q),m.current=Ir(m.current,H,q),C(K=>Ir(K,H,q)),N(K=>ks(K,H,q)),P(K=>ks(K,H,q)),e.remapPendingQueue(H,q),V(K=>ks(K,H,q)),y(K=>{const fe=K[H];if(!fe)return K;const Fe={...K};return delete Fe[H],Fe[q]={...fe,sessionId:q},Fe}),re(K=>{const fe=rf(K,H,q);return fe!==K&&(o.current=fe,an(fe)),fe}))},[]);return{...e,...t,attachments:et,setAttachments:Pe,uploadBusy:oe,directory:Ce,setDirectory:tt,newDirName:xe,setNewDirName:De,remoteFile:je,setRemoteFile:Re,remoteFileConflict:ce,uploadFiles:te,openRemoteFile:A,saveRemoteFile:Ae,downloadRemoteFile:pe,listDirectory:nt,listSessionDirectories:ut,listFileTreeDirectory:at,createDirectory:ge,createSessionDirectory:le,pendingActionsCount:ee,activeQueue:we,activeModelOptions:Ye,activeUsage:st,activeApproval:Bt,activeQuestion:bt,activeSession:yt,displaySessions:Rt,groupedSessions:$t,pendingSessionIds:He,visibleSessions:St,appendCachedDelta:Tt,appendCachedHistory:Mt,appendInfoMessage:ht,clearHistoryLoading:O,ensureCachedHistoryEntry:U,setCachedMessageDelivery:de,resolveCachedMessageSession:_e,historyCacheRef:At,historyLoading:ft,historyPageStartRef:ot,hydrateVisibleHistory:ct,messages:Le,messagesSessionIdRef:lt,mergeCachedHistoryPage:mt,remapCachedHistory:kt,removeCachedHistory:ve,renderCachedHistory:jt,replaceCachedHistory:Be,requestHistory:$e,setMessages:vt,updateDraft:Kt,updateNewSessionDraft:Ft,setSessionsFromPage:Pt,hydrateGitMetadata:Dt,prefetchActiveHistories:Ct,applyReconnectSnapshot:It,requestReconnectSnapshot:Gt,requestSessions:Ut,fetchAgentResources:Vt,reportLog:Ot,refreshDaemonMetadata:qt,updateNotificationSettings:Qt,remapLocalSessionState:Zt}}function nm(){const e=tm(),t=c.useRef(void 0),n=wf(e),{initialSavedTargetsRef:s,composerDraftsRef:i,lastHistorySessionIdRef:a,respondingSessionsRef:o,phase:l,setErrorText:u,pairing:h,setSessions:d,pendingSessions:m,activeSessionId:g,setActiveSessionId:p,setRespondingSessions:S,setPendingApprovals:w,setPendingQuestions:b,setPendingQueues:y,setLivePendingQueue:f,agent:v,setAgent:k,cwd:j,setCwd:E,setApprovalMode:x,setModel:C,setEffort:I,setFastMode:N,setRenameTitle:L,setDraft:P,archiveSyncedDaemonIds:R,archiveSyncCardDismissedDaemonIds:_,setControlTabAndOpen:V,daemonMetadata:Z,notificationPermission:ue,setDirectory:ye,displaySessions:D,appendInfoMessage:Q,clearHistoryLoading:G,messagesSessionIdRef:re,renderCachedHistory:ae,replaceCachedHistory:T,requestHistory:$,setMessages:B,requestSessions:Y,remapLocalSessionState:W,attachments:J,setAttachments:z,listDirectory:ne,activeApproval:X,activeQuestion:qe,activeSession:me,appendCachedDelta:Ue,appendCachedHistory:Se,ensureCachedHistoryEntry:Ie,setCachedMessageDelivery:Ne,resolveCachedMessageSession:ke,historyCacheRef:be,messages:Ee,mergeCachedHistoryPage:Ve,removeCachedHistory:We,updateDraft:Qe,setSessionsFromPage:Ze,requestReconnectSnapshot:he,fetchAgentResources:je,reportLog:et,refreshDaemonMetadata:Pe,updateNotificationSettings:oe,clientRef:Ce,connectWithPairingRef:tt,activeSessionIdRef:xe,notificationPermissionRef:De,notificationSettingsRef:Re,historyCacheDaemonIdRef:ce,pairingRef:te,notifiedEventsRef:A,reconnectTimerRef:Ae,connectionAttemptIdRef:pe,turnNotificationCountsRef:nt,intentionalDisconnectRef:ut,setPhase:at,setStatusText:ge,setPairing:le,setPendingSessions:ee,setOptimisticSessions:we,questionAnswers:Ye,setQuestionAnswers:st,approvalMode:yt,continueSession:Bt,model:bt,effort:Rt,fastMode:$t,renameTitle:He,setComposerDrafts:St,draft:At,search:ot,sinceFilter:ct,savedTargets:lt,setSavedTargets:kt,saveTargets:Tt,updateSessionListPreferences:Mt,t:ht,busy:O,setBusy:U,setDetailsOpen:de,setAdmin:_e,setDaemonMetadata:ft,setNotificationPermission:Le,archiveSyncBusy:mt,setArchiveSyncBusy:ve,setArchiveSyncStatus:jt}=e,Be=c.useCallback(async(ie,Nt,pt)=>{const Oe=typeof pt.sessionId=="string"?pt.sessionId:ie,rt=typeof pt.oldSessionId=="string"?pt.oldSessionId:ie;rt&&Oe&&rt!==Oe&&W(rt,Oe),Nt.name==="clear"?(T(Oe,[]),y(wt=>{const M={...wt};return delete M[Oe],delete M[rt],M}),w(wt=>{const M={...wt};return delete M[Oe],delete M[rt],M}),b(wt=>{const M={...wt};return delete M[Oe],delete M[rt],M}),p(Oe)):Nt.name==="new"?(p(Oe),re.current=Oe,ae(Oe)):Nt.name==="exit"?(d(wt=>wt.map(M=>M.sessionId===Oe?{...M,archived:!0}:M)),p(null),re.current=null,a.current=null,B([])):Nt.name==="goal"&&"goal"in pt&&Q(Oe,Mc(pt.goal)),pt.turnStarted&&!pt.queued&&(o.current=new Set(o.current).add(Oe),S(wt=>new Set(wt).add(Oe))),await Y({force:!0})},[Q,W,ae,T,Y]),$e=mf({notificationSettingsRef:Re,notifiedEventsRef:A,notificationPermissionRef:De,activeSessionIdRef:xe,respondingSessionsRef:o,turnNotificationCountsRef:nt,t:ht,setActiveSessionId:p,setErrorText:u,setPendingQueues:y,setLivePendingQueue:f,setPendingApprovals:w,setPendingQuestions:b,setQuestionAnswers:st,setRespondingSessions:S,setSessions:d,remapLocalSessionState:W,requestSessions:Y,clearHistoryLoading:G,replaceCachedHistory:T,mergeCachedHistoryPage:Ve,appendCachedHistory:Se,appendCachedDelta:Ue});nf({clientRef:Ce,connectWithPairingRef:tt,pairingRef:te,reconnectTimerRef:Ae,connectionAttemptIdRef:pe,intentionalDisconnectRef:ut,historyCacheRef:be,historyCacheDaemonIdRef:ce,messagesSessionIdRef:re,lastHistorySessionIdRef:a,rememberedTarget:s.current[0]??null,agent:v,cwd:j,phase:l,search:ot,sinceFilter:ct,t:ht,handleServerMessage:$e,setPhase:at,setStatusText:ge,setErrorText:u,setMessages:B,setPairing:le,setSavedTargets:kt,setSessionsFromPage:Ze,refreshDaemonMetadata:Pe,requestReconnectSnapshot:he,fetchAgentResources:je,reportLog:et,requestSessions:Y}),c.useEffect(()=>{const ie=D.find(rt=>rt.sessionId===g);if(!ie){a.current=null,re.current=null,G(),B([]),P(cn(i.current,null));return}k(ie.agent),E(ie.cwd||dt),I(ie.effort??""),N(ie.fastMode??!1),x(ie.approvalMode??sr),L(ie.customTitle??ie.title??""),P(cn(i.current,ie.sessionId));const Nt=t.current,pt=`${h?.daemonId}:${ie.sessionId}`;t.current=pt;const Oe=tn();if(ye(rt=>Sf(rt,Nt,pt,ie.cwd||dt,Oe.folder||Oe.cwd)),m[ie.sessionId]){a.current=ie.sessionId,G(),re.current!==ie.sessionId&&(re.current=ie.sessionId,B([]));return}if(ae(ie.sessionId)){const rt=a.current!==ie.sessionId;a.current=ie.sessionId,G(ie.sessionId),rt&&$(ie);return}a.current!==ie.sessionId&&(a.current=ie.sessionId,re.current!==ie.sessionId&&(re.current=ie.sessionId,B([])),$(ie))},[g,G,D,m,ae,$]);const vt=vf({daemonId:h?.daemonId,session:me,setModel:C,setPendingSessions:ee}),{stagePendingSession:Ft,failedSend:Kt,dismissFailedSend:Pt,retryFailedSend:Dt,sendDraft:Ct}=bf({clientRef:Ce,activeSessionIdRef:xe,composerDraftsRef:i,lastHistorySessionIdRef:a,messagesSessionIdRef:re,respondingSessionsRef:o,agent:v,cwd:j,approvalMode:yt,continueSession:Bt,model:bt,effort:Rt,fastMode:$t,activeSessionId:g,activeSession:me,pendingSessions:m,draft:At,busy:O,attachments:J,t:ht,setPendingSessions:ee,setOptimisticSessions:we,setComposerDrafts:St,setCwd:E,setAgent:k,setActiveSessionId:p,setMessages:B,setDraft:P,setErrorText:u,setBusy:U,setAttachments:z,setRespondingSessions:S,clearHistoryLoading:G,reportLog:et,remapLocalSessionState:W,requestSessions:Y,updateDraft:Qe,appendCachedHistory:Se,ensureCachedHistoryEntry:Ie,setCachedMessageDelivery:Ne,resolveCachedMessageSession:ke,renderCachedHistory:ae,handleSessionCommandResponse:Be,appendInfoMessage:Q}),{respondApproval:It,respondQuestion:Gt,cancelQuestion:Ut,setQuestionChoice:Vt,requestActiveAction:Ot,interruptActiveSession:qt,retrySessions:Qt,updateApprovalMode:Zt,cancelQueuedTurn:H,setSessionPinned:q,setSessionArchived:K,deleteSession:fe,updatePinned:Fe,updateArchived:xt,renameSession:Wt}=gf({clientRef:Ce,activeSessionIdRef:xe,composerDraftsRef:i,lastHistorySessionIdRef:a,messagesSessionIdRef:re,respondingSessionsRef:o,activeApproval:X,activeQuestion:qe,activeSession:me,activeSessionId:g,questionAnswers:Ye,pendingSessions:m,phase:l,renameTitle:He,setBusy:U,setErrorText:u,setPendingApprovals:w,setPendingQuestions:b,setQuestionAnswers:st,setPendingQueues:y,setActiveSessionId:p,setMessages:B,setApprovalMode:x,setSessions:d,setPendingSessions:ee,setComposerDrafts:St,setDraft:P,setAttachments:z,setDetailsOpen:de,setRespondingSessions:S,setOptimisticSessions:we,removeCachedHistory:We,requestSessions:Y}),{runArchiveSync:bn,skipArchiveSync:vn,runAdminAction:xn,exportActiveSession:wn,clearPairing:Sn,setNotificationsEnabled:dn,connectSavedTarget:un,forgetSavedTarget:kn,openSessionDetails:Bn,editFolderTags:zn,browseFolder:Kn,copyResumeCommand:jn,resumeInTerminal:xr}=Gh({clientRef:Ce,pairingRef:te,connectWithPairingRef:tt,notificationPermissionRef:De,intentionalDisconnectRef:ut,connectionAttemptIdRef:pe,historyCacheRef:be,historyCacheDaemonIdRef:ce,messagesSessionIdRef:re,lastHistorySessionIdRef:a,displaySessions:D,pairing:h,t:ht,archiveSyncBusy:mt,daemonMetadata:Z,activeSession:me,messages:Ee,notificationPermission:ue,savedTargets:lt,setArchiveSyncBusy:ve,setArchiveSyncStatus:jt,setSessions:d,setAdmin:_e,setErrorText:u,setNotificationPermission:Le,setStatusText:ge,setMessages:B,setPairing:le,setDaemonMetadata:ft,setPhase:at,setActiveSessionId:p,setRenameTitle:L,setDetailsOpen:de,setControlTab:V,updateSessionListPreferences:Mt,requestSessions:Y,refreshDaemonMetadata:Pe,updateNotificationSettings:oe,saveTargets:Tt,listDirectory:ne}),ps=c.useCallback(async ie=>{const Nt=Ce.current;return Nt?.isConnected?(await Nt.request({action:"models.list",id:Nt.makeId("models"),agent:ie})).options??[]:[]},[]),gs=ue==="denied"||ue==="unsupported",wr=!!(Z.version&&Z.latestVersion&&oa(Z.version,Z.latestVersion)),Yt=h?.daemonId,ys=!!(Yt&&R[Yt]),bs=!!(Yt&&_[Yt]),vs=af(e);return{...e,setModel:vt,queueControls:vs,listSessionModels:ps,rewindMessage:n,handleSessionCommandResponse:Be,handleServerMessage:$e,failedSend:Kt,dismissFailedSend:Pt,retryFailedSend:Dt,stagePendingSession:Ft,sendDraft:Ct,respondApproval:It,respondQuestion:Gt,cancelQuestion:Ut,setQuestionChoice:Vt,requestActiveAction:Ot,interruptActiveSession:qt,retrySessions:Qt,updateApprovalMode:Zt,cancelQueuedTurn:H,setSessionPinned:q,setSessionArchived:K,deleteSession:fe,updatePinned:Fe,updateArchived:xt,renameSession:Wt,runArchiveSync:bn,skipArchiveSync:vn,runAdminAction:xn,exportActiveSession:wn,clearPairing:Sn,setNotificationsEnabled:dn,connectSavedTarget:un,forgetSavedTarget:kn,openSessionDetails:Bn,editFolderTags:zn,browseFolder:Kn,copyResumeCommand:jn,resumeInTerminal:xr,notificationsBlocked:gs,hasDaemonUpdate:wr,activeDaemonId:Yt,archiveSynced:ys,archiveSyncDismissed:bs}}const sm=c.lazy(()=>gt(()=>import("./NewSessionDialog-BTZlw3Gl.js"),__vite__mapDeps([19,1,2,11,20]))),rm=c.lazy(()=>gt(()=>import("./GlobalPendingDialog-BokEX_Go.js"),__vite__mapDeps([21,1,2])));function im(){return r.jsx(Au,{children:r.jsx(am,{})})}function am(){const[e,t]=c.useState(!0),[n,s]=c.useState(!1),[i,a]=c.useState(!1),o=nm();Lh(o);const[l,u]=c.useState(null);c.useEffect(()=>{const M=()=>u(Ke=>Ke??{cwd:o.cwd}),ze=se().subscribeCommand?.(Ke=>{Ke==="new-session"&&M()}),Jt=Ke=>{se().kind==="browser"&&(Ke.metaKey||Ke.ctrlKey)&&!Ke.altKey&&!Ke.shiftKey&&Ke.key.toLowerCase()==="n"&&(Ke.preventDefault(),M())};return window.addEventListener("keydown",Jt),()=>{ze?.(),window.removeEventListener("keydown",Jt)}},[o.cwd]),c.useEffect(()=>{o.controlTab==="browser"&&t(!0)},[o.controlTab]),c.useEffect(()=>{o.controlTab==="terminal"&&s(!0)},[o.controlTab]),c.useEffect(()=>{(o.controlTab==="session"||se().kind==="desktop"&&o.controlTab==="admin")&&o.setControlTab("files");const M=()=>o.setControlTabAndOpen("admin");return window.addEventListener("vibelet.browser.settings",M),()=>window.removeEventListener("vibelet.browser.settings",M)},[o.controlTab,o.setControlTab,o.setControlTabAndOpen]),c.useEffect(()=>{o.activeQuestion&&o.setQuestionAnswers(ir(o.activeQuestion))},[o.activeQuestion,o.setQuestionAnswers]);const{clientRef:h,phase:d,statusText:m,errorText:g,pairing:p,sessions:S,nextCursor:w,folderCounts:b,inventoryVersion:y,activeSessionId:f,setActiveSessionId:v,diffSessionId:k,setDiffSessionId:j,respondingSessions:E,questionAnswers:x,agent:C,cwd:I,approvalMode:N,model:L,setModel:P,effort:R,setEffort:_,fastMode:V,setFastMode:Z,renameTitle:ue,setRenameTitle:ye,draft:D,webPreferences:Q,sessionSort:G,setSessionSort:re,search:ae,setSearch:T,sinceFilter:$,setSinceFilter:B,hideArchived:Y,setHideArchived:W,groupFolders:J,setGroupFolders:z,showNeedsAttentionGroup:ne,setShowNeedsAttentionGroup:X,showRunningGroup:qe,setShowRunningGroup:me,separatePinnedGroup:Ue,setSeparatePinnedGroup:Se,collapsedFolders:Ie,setCollapsedFolders:Ne,sessionAgentFilter:ke,setSessionAgentFilter:be,directoryTags:Ee,composerPreferences:Ve,savedTargets:We,leftSidebarCollapsed:Qe,setLeftSidebarCollapsed:Ze,rightSidebarCollapsed:he,setRightSidebarCollapsed:je,workspaceClassName:et,wideMainClassName:Pe,workspaceStyle:oe,beginPaneResize:Ce,commitSearch:tt,saveTargets:xe,setLanguagePreference:De,setThemePreference:Re,updateComposerPreferences:ce,t:te,busy:A,rewindMessage:Ae,controlTab:pe,setControlTab:nt,detailsOpen:ut,setDetailsOpen:at,setControlTabAndOpen:ge,skills:le,admin:ee,daemonMetadata:we,notificationSettings:Ye,notificationPermission:st,archiveSyncBusy:yt,archiveSyncStatus:Bt,attachments:bt,setAttachments:Rt,uploadBusy:$t,directory:He,newDirName:St,setNewDirName:At,remoteFile:ot,uploadFiles:ct,openRemoteFile:lt,listDirectory:kt,listSessionDirectories:Tt,listFileTreeDirectory:Mt,createDirectory:ht,createSessionDirectory:O,pendingActionsCount:U,activeQueue:de,activeModelOptions:_e,activeUsage:ft,activeApproval:Le,activeQuestion:mt,activeSession:ve,displaySessions:jt,groupedSessions:Be,pendingSessionIds:$e,visibleSessions:vt,historyLoading:Ft,messages:Kt,messagesSessionIdRef:Pt,updateDraft:Dt,requestReconnectSnapshot:Ct,requestSessions:It,fetchAgentResources:Gt,failedSend:Ut,dismissFailedSend:Vt,retryFailedSend:Ot,stagePendingSession:qt,listSessionModels:Qt,sendDraft:Zt,respondApproval:H,respondQuestion:q,cancelQuestion:K,setQuestionChoice:fe,requestActiveAction:Fe,interruptActiveSession:xt,retrySessions:Wt,updateApprovalMode:bn,cancelQueuedTurn:vn,setSessionPinned:xn,setSessionArchived:wn,deleteSession:Sn,updatePinned:dn,updateArchived:un,renameSession:kn,runArchiveSync:Bn,skipArchiveSync:zn,runAdminAction:Kn,exportActiveSession:jn,clearPairing:xr,setNotificationsEnabled:ps,connectSavedTarget:gs,forgetSavedTarget:wr,openSessionDetails:Yt,editFolderTags:ys,copyResumeCommand:bs,resumeInTerminal:vs,notificationsBlocked:ie,hasDaemonUpdate:Nt,archiveSynced:pt,archiveSyncDismissed:Oe}=o,rt=c.useMemo(()=>i?Object.fromEntries(Be.map(M=>[M.folder,Ie[M.folder]!==!1])):Ie,[i,Ie,Be]),wt=Be.length>0&&Be.every(M=>rt[M.folder]);return d==="missing-pair"?r.jsxs(r.Fragment,{children:[r.jsx("a",{className:"skip-link",href:"#vibelet-main-content",children:te.skipToConversation}),r.jsx(Iu,{errorText:g,t:te})]}):r.jsxs("main",{className:et,id:"vibelet-workspace",style:oe,children:[l&&r.jsx(c.Suspense,{fallback:null,children:r.jsx(sm,{cwd:l.cwd,agent:C,device:p?.daemonId??"disconnected",connected:d==="connected",approvalMode:N,model:L,t:te,onClose:()=>u(null),onCreate:qt,onListModels:Qt,onListDirectories:Tt,onCreateDirectory:O})}),r.jsx("a",{className:"skip-link",href:"#vibelet-main-content",children:te.skipToConversation}),r.jsx(ah,{collapsed:Qe,onExpand:()=>Ze(M=>!M),onResize:Ce("left"),t:te,children:r.jsx(ih,{connectionIndicators:r.jsx(kh,{workspace:o}),activeDaemonId:p?.daemonId,activeSessionId:f,busy:A,collapsedFolders:rt,allFoldersCollapsed:wt,currentCwd:I,directoryTags:Ee,displayName:p?.displayName,savedTargets:We,folderCounts:b,groupFolders:J,sessionSort:G,onSessionSortChange:re,groupedSessions:Be,hideArchived:Y,separatePinnedGroup:Ue,showNeedsAttentionGroup:ne,showRunningGroup:qe,inventoryVersion:y,nextCursor:w,phase:d,respondingSessionIds:E,search:ae,sessionAgentFilter:ke,sessionsCount:jt.length,sinceFilter:$,statusText:m,t:te,visibleSessions:vt,onLoadMore:M=>It({append:!0,cursor:M}),onCopyResumeCommand:bs,onResumeInTerminal:vs,onConnectTarget:gs,pendingSessionIds:$e,onRequestNewSession:M=>u({cwd:M??I}),onDeleteSession:M=>{Sn(M)},onEditFolderTags:ys,onOpenSessionDetails:Yt,onResetFilters:()=>{re("updated"),be("all"),B("30d"),W(!1),z(!0),X(!1),me(!1),Se(!1)},onRenameTarget:(M,ze)=>xe(Wh(We,M,ze)),onEditConnection:se().settingsTarget?M=>window.dispatchEvent(new CustomEvent("vibelet.desktop.edit-connection",{detail:M.pairToken})):void 0,onSearchChange:T,onSearchCommit:tt,onSelectSession:v,onToggleSessionArchived:M=>{wn(M,!M.archived)},onToggleSessionPinned:M=>{xn(M,!M.pinned)},onSessionAgentFilterChange:be,onSinceFilterChange:B,onToggleFolder:M=>Ne(ze=>({...ze,[M]:i?ze[M]===!1:!ze[M]})),onToggleAllFolders:()=>{a(!wt),Ne({})},onToggleGroupFolders:()=>z(M=>!M),onToggleHideArchived:()=>W(M=>!M),onToggleNeedsAttentionGroup:()=>{o.toggleSessionViewGroup("needsAttention")},onToggleRunningGroup:()=>{o.toggleSessionViewGroup("running")},onToggleSeparatePinnedGroup:()=>{o.toggleSessionViewGroup("pinned")},onToggleCollapse:()=>Ze(!0)})}),r.jsxs("section",{className:Pe,"aria-label":te.vibeletWorkspace,id:"vibelet-main-content",tabIndex:-1,children:[r.jsx(_h,{workspace:o,children:r.jsx(Vd,{activeSession:ve,activeSessionId:f,activeModelOptions:_e,activeQueue:de,activeUsage:ft,agent:C,approvalMode:N,attachments:bt,busy:A,cwd:I,draft:D,effort:R,errorText:g,failedSend:Ut,onDismissFailedSend:Vt,fastMode:V,historyLoading:Ft,messages:Kt,messagesSessionId:Pt.current,model:L,phase:d,quickReplies:Ve.quickReplies,renameTitle:ue,respondingSessionIds:E,sendShortcut:Ve.sendShortcut,skills:le,uploadBusy:$t,detailsOpen:ut,t:te,onApprovalModeChange:M=>{bn(M)},onBrowseFiles:()=>{const M=ve?.cwd||I||dt;ge("files"),kt(M,{updateRoute:!0})},queueControls:o.queueControls,onCancelQueuedTurn:M=>{vn(M)},onClearInterrupt:()=>{Fe("session.clearInterrupt")},onDraftChange:Dt,onDetailsOpenChange:at,onEffortChange:_,onExportActiveSession:()=>{jn()},onRewindMessage:M=>{Ae(M)},onFastModeChange:Z,onRetryFailedSend:Ot,onModelChange:P,onOpenRemoteFile:(M,ze)=>{lt(M,ze,{updateRoute:!0})},onInterrupt:xt,onDismissError:()=>o.setErrorText(null),onRetry:Wt,onRenameSession:()=>{kn()},onRenameTitleChange:ye,onRemoveAttachment:M=>Rt(ze=>ze.filter(Jt=>Jt.path!==M)),onRefreshSkills:()=>{Gt(ve?.agent??C,I)},onSubmit:Zt,onToggleArchived:()=>{un()},onTogglePinned:()=>{dn()},onUploadFiles:ct,onViewChanges:j})}),r.jsxs(Eh,{collapsed:he,t:te,value:pe,showSession:!1,onChange:nt,onResize:Ce("right"),children:[pe==="files"?r.jsx(c.Suspense,{fallback:r.jsx(zr,{t:te}),children:r.jsx(Bu,{busy:A,cwd:I,directory:He,onLoadChildren:Mt,newDirName:St,remoteFile:ot,t:te,onCreateDirectory:()=>{ht()},onListDirectory:M=>{kt(M,{updateRoute:!0})},onNewDirNameChange:At,onOpenRemoteFile:(M,ze)=>{lt(M,ze,{updateRoute:!0})}},`${p?.daemonId}:${I}`)}):null,n?r.jsxs("div",{hidden:pe!=="terminal",className:"terminal-tab-content",children:[r.jsx(Hs,{location:"right",kind:"terminal",t:te,cwd:I===dt?He.path:I}),r.jsx(ns,{location:"right",kind:"terminal"})]}):null,e?r.jsxs("div",{hidden:pe!=="browser",className:"browser-tab-content",children:[r.jsx(Hs,{location:"right",kind:"browser",t:te}),r.jsx(ns,{location:"right",kind:"browser"})]}):null,pe==="admin"?r.jsxs(c.Suspense,{fallback:r.jsx(zr,{t:te}),children:[r.jsx(zu,{language:Q.language,t:te,onLanguageChange:De}),!se().settingsTarget&&r.jsx(yh,{}),r.jsx(Ku,{t:te,theme:Q.theme,onThemeChange:Re}),r.jsx(Gu,{notificationsBlocked:ie,permission:st,settings:Ye,t:te,onToggleEnabled:ps}),!se().settingsTarget&&r.jsx(Ur,{workspace:o})]}):null]})]}),se().settingsTarget&&r.jsx(Ur,{workspace:o,portalOnly:!0}),r.jsx("div",{className:"workspace-header-actions",children:r.jsx(jc,{activeSession:ve,busy:A,controlsOpen:!he,t:te,onOpenControls:()=>{he&&U===0&&pe==="session"&&nt("files"),je(M=>!M)},onRefreshSessions:()=>{It({force:!0})},onRestoreSnapshot:()=>{Ct()},onToggleArchived:()=>{un()},onTogglePinned:()=>{dn()},onViewChanges:j})}),U>0&&r.jsx(c.Suspense,{fallback:null,children:r.jsx(rm,{activeApproval:Le,activeQuestion:mt,pendingCount:U,requestKey:JSON.stringify([...Object.values(o.pendingApprovals),...Object.values(o.pendingQuestions)].map(M=>JSON.stringify([M.sessionId,M.requestId])).sort()),sessions:S,busy:A,errorText:g,questionAnswers:x,t:te,onCancelQuestion:()=>{K()},onQuestionChoice:fe,onRespondApproval:M=>{H(M)},onRespondQuestion:()=>{q()},onDismissRequest:(M,ze,Jt)=>{M==="approval"?o.setPendingApprovals(Ke=>{if(Ke[ze]?.requestId!==Jt)return Ke;const Cn={...Ke};return delete Cn[ze],Cn}):o.setPendingQuestions(Ke=>{if(Ke[ze]?.requestId!==Jt)return Ke;const Cn={...Ke};return delete Cn[ze],Cn})},onClearRequests:()=>{o.setPendingApprovals({}),o.setPendingQuestions({})}})}),r.jsx(Eu,{}),r.jsx($u,{onOpenRight:ge,client:d==="connected"?h.current:null,daemonId:p?.daemonId,deviceName:p?.displayName??"",controlTab:pe,rightVisible:!he,t:te}),r.jsx(Uu,{activeSession:ve,client:h.current,close:()=>j(null),id:k,sessions:S,t:te})]})}const fm=Object.freeze(Object.defineProperty({__proto__:null,App:im},Symbol.toStringTag,{value:"Module"}));export{qa as A,Lt as C,Cu as F,ci as G,wo as I,jo as K,cs as L,_d as M,Wo as P,Dn as R,Js as S,yi as T,Me as X,yn as a,Xn as b,An as c,Zc as d,ws as e,Ht as f,hm as g,Zs as h,ii as i,el as j,lo as k,pr as l,Ys as m,mn as n,um as o,cm as p,lm as q,Fn as r,dm as s,Wn as t,Dd as u,ls as v,ar as w,fm as x};