@vibelet/cli 1.2.182 → 1.2.184

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 (39) hide show
  1. package/README.md +4 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/inventory-scan-worker.cjs +1 -1
  4. package/dist/runtime-version.cjs +1 -1
  5. package/dist/tailcat/vibelet-tailcat-darwin-amd64 +0 -0
  6. package/dist/tailcat/vibelet-tailcat-darwin-arm64 +0 -0
  7. package/dist/tailcat/vibelet-tailcat-linux-amd64 +0 -0
  8. package/dist/tailcat/vibelet-tailcat-linux-arm64 +0 -0
  9. package/dist/tailcat/vibelet-tailcat-win32-amd64.exe +0 -0
  10. package/dist/tailcat/vibelet-tailcat-win32-arm64.exe +0 -0
  11. package/dist/vibelet.mjs +242 -125
  12. package/dist/web/assets/App-1V1UoQkP.js +12 -0
  13. package/dist/web/assets/{ArchiveSyncPanel-CQW9sGn8.js → ArchiveSyncPanel-HfbSbAJT.js} +1 -1
  14. package/dist/web/assets/{ConnectionSettingsPanel-CvgjycC_.js → ConnectionSettingsPanel-Y8Um-67e.js} +1 -1
  15. package/dist/web/assets/{DaemonSettingsPanel-8WGOLUs-.js → DaemonSettingsPanel--znFJEC6.js} +1 -1
  16. package/dist/web/assets/{DiffDrawer-8wyT-3Bj.js → DiffDrawer-BI-wtkQ_.js} +1 -1
  17. package/dist/web/assets/FilesControlPanel-B5M5ueO9.js +2 -0
  18. package/dist/web/assets/LanguageSettingsPanel-BLwzc7Dm.js +1 -0
  19. package/dist/web/assets/{NotificationSettingsPanel--Ov_1saA.js → NotificationSettingsPanel-IgZdwrhi.js} +1 -1
  20. package/dist/web/assets/SavedTargetsPanel-DggmoRgT.js +1 -0
  21. package/dist/web/assets/ThemeSettingsPanel-vB2Ox3sA.js +1 -0
  22. package/dist/web/assets/{file-text-B-0kY5qg.js → file-text-NAVq0aqX.js} +1 -1
  23. package/dist/web/assets/highlighted-body-TPN3WLV5-ClieluW-.js +1 -0
  24. package/dist/web/assets/{index-DRV2XMZs.js → index-CXts92Zv.js} +10 -10
  25. package/dist/web/assets/index-D8mZeSsk.css +1 -0
  26. package/dist/web/assets/{mermaid-O7DHMXV3-DaZ-aNWp.css → mermaid-O7DHMXV3-BPtfCfol.css} +1 -1
  27. package/dist/web/assets/{mermaid-O7DHMXV3-COP4-7nw.js → mermaid-O7DHMXV3-D0ujIgIK.js} +49 -49
  28. package/dist/web/assets/splash-logo-SQcOtj-8.png +0 -0
  29. package/dist/web/icon.svg +1 -1
  30. package/dist/web/index.html +3 -3
  31. package/dist/web/logo.svg +13 -0
  32. package/dist/web/manifest.webmanifest +1 -1
  33. package/package.json +2 -1
  34. package/dist/web/assets/App-20rnW-dS.js +0 -11
  35. package/dist/web/assets/FilesControlPanel-CM73JghJ.js +0 -2
  36. package/dist/web/assets/LanguageSettingsPanel-3P8xvsNr.js +0 -1
  37. package/dist/web/assets/SavedTargetsPanel-B4UDMnAq.js +0 -1
  38. package/dist/web/assets/highlighted-body-TPN3WLV5-BgMEhjMq.js +0 -1
  39. package/dist/web/assets/index-nF-4Ar2D.css +0 -1
@@ -0,0 +1,12 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-O7DHMXV3-D0ujIgIK.js","assets/index-CXts92Zv.js","assets/index-D8mZeSsk.css","assets/mermaid-O7DHMXV3-BPtfCfol.css","assets/FilesControlPanel-B5M5ueO9.js","assets/file-text-NAVq0aqX.js","assets/ArchiveSyncPanel-HfbSbAJT.js","assets/ConnectionSettingsPanel-Y8Um-67e.js","assets/DaemonSettingsPanel--znFJEC6.js","assets/LanguageSettingsPanel-BLwzc7Dm.js","assets/ThemeSettingsPanel-vB2Ox3sA.js","assets/NotificationSettingsPanel-IgZdwrhi.js","assets/SavedTargetsPanel-DggmoRgT.js","assets/DiffDrawer-BI-wtkQ_.js"])))=>i.map(i=>d[i]);
2
+ import{c as F,r as o,j as s,E as rr,_ as Ye,D as ma,a as Hn,l as ir,b as pa,p as ga,s as ya,d as Ot,e as ba,f as xa,W as As,g as Sa,h as va,i as wa}from"./index-CXts92Zv.js";const ka=[["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"}]],Zn=F("archive",ka);const ja=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ca=F("arrow-down",ja);const Na=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ia=F("arrow-up",Na);const Aa=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Ra=F("bot",Aa);const Ta=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],nt=F("check",Ta);const Ea=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ma=F("chevron-right",Ea);const _a=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Da=F("chevron-up",_a);const Pa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Fa=F("circle-dot",Pa);const $a=[["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"}]],La=F("clipboard",$a);const Oa=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ar=F("clock-3",Oa);const Ba=[["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"}]],qa=F("code-xml",Ba);const Ha=[["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"}]],It=F("copy",Ha);const za=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],Rs=F("corner-down-left",za);const Wa=[["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"}]],Pn=F("cpu",Wa);const Ua=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],or=F("ellipsis",Ua);const Ka=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Va=F("eye",Ka);const Ga=[["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"}]],Nt=F("folder-open",Ga);const Qa=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Za=F("folder-plus",Qa);const Ya=[["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"}]],cr=F("folder",Ya);const Ja=[["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"}]],Xa=F("funnel",Ja);const eo=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ze=F("gauge",eo);const to=[["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"}]],lr=F("git-compare",to);const no=[["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"}]],so=F("hash",no);const ro=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],dr=F("info",ro);const io=[["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"}]],ao=F("key-round",io);const oo=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],co=F("keyboard",oo);const lo=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],hn=F("loader-circle",lo);const uo=[["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"}]],ur=F("message-circle",uo);const fo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],fr=F("panel-left",fo);const ho=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],hr=F("panel-right",ho);const mo=[["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"}]],Yn=F("paperclip",mo);const po=[["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"}]],xn=F("pin",po);const go=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Jn=F("plus",go);const yo=[["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"}]],Gt=F("refresh-cw",yo);const bo=[["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"}]],xo=F("rotate-ccw",bo);const So=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Xn=F("search",So);const vo=[["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"}]],wo=F("settings",vo);const ko=[["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"}]],Sn=F("shield-check",ko);const jo=[["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"}]],mr=F("sliders-horizontal",jo);const Co=[["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"}]],No=F("sparkles",Co);const Io=[["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"}]],es=F("square-terminal",Io);const Ao=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ro=F("square",Ao);const To=[["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"}]],pr=F("tag",To);const Eo=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ts=F("terminal",Eo);const Mo=[["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"}]],_o=F("trash-2",Mo);const Do=[["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"}]],Po=F("wrench",Do);const Fo=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],we=F("x",Fo);const $o=[["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"}]],zt=F("zap",$o),Lo=".",Oo="@vibelet/needs-attention",Bo="@vibelet/running",qo="@vibelet/pinned";function Ho(e,t={}){const n=new Map,r=[],i=[],a=[];for(const c of e){const f=c.archived!==!0;if(!!(t.showNeedsAttentionGroup&&f&&(t.needsAttentionSessionIds?.has(c.sessionId)||c.runtime.needsAttention||c.interruptReason||c.stallWarning))?r.push(c):t.showRunningGroup&&f&&t.respondingSessionIds?.has(c.sessionId)&&i.push(c),t.separatePinnedGroup&&f&&c.pinned){a.push(c);continue}const m=c.cwd||Lo;n.set(m,[...n.get(m)??[],c])}const l=[];return r.length>0&&l.push({folder:Oo,kind:"attention",sessions:r}),i.length>0&&l.push({folder:Bo,kind:"running",sessions:i}),a.length>0&&l.push({folder:qo,kind:"pinned",sessions:[...a].sort((c,f)=>Date.parse(f.lastActivityAt)-Date.parse(c.lastActivityAt))}),[...l,...Array.from(n.entries()).map(([c,f])=>({folder:c,kind:"folder",sessions:f}))]}function gr(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 qe=".",zn="normal",zo=80,Wo=1600,yr="vibelet.web.notificationSettings",Uo="pending_local_",lt={enabled:!1,approvals:!0,questions:!0,replies:!0,hiddenOnly:!0};function Wt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ns(e,t=Date.now()){if(!e)return"unknown";const n=Date.parse(e);if(!Number.isFinite(n))return e;const r=t-n,i=60*1e3,a=60*i,l=24*a;return r<i?"now":r<a?`${Math.floor(r/i)}m ago`:r<l?`${Math.floor(r/a)}h ago`:`${Math.floor(r/l)}d ago`}function Ko(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 ze(e){return e.customTitle||e.title||e.sessionId.slice(0,10)}function ss(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 br(e){const t=e;return{sessions:Array.isArray(t.sessions)?t.sessions:[],nextCursor:gr(t.nextCursor),inventoryVersion:t.inventoryVersion,inventoryBackfillInFlight:t.inventoryBackfillInFlight,folderCounts:t.folderCounts}}function Vo(e){const t=e;return typeof t.sessionId=="string"?t.sessionId:null}function Go(e){const t=e;return typeof t.path=="string"?t.path:null}function vn(e){return e.split("/").filter(Boolean).at(-1)??e}function xr(e){return Object.entries(e).length===0?"No structured input.":JSON.stringify(e,null,2)}function Wn(e){return Object.fromEntries(e.questions.map(t=>[t.id,t.options[0]?[t.options[0].label]:[]]))}function dn(e){return e.trim()||void 0}function Ts(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 yn(e,t){const n=new Map;for(const r of e)n.set(r.sessionId,r);for(const r of t)n.set(r.sessionId,{...n.get(r.sessionId),...r});return Array.from(n.values()).sort((r,i)=>{const a=r.pinned?r.pinnedAt??0:0,l=i.pinned?i.pinnedAt??0:0;return a!==l?l-a:Date.parse(i.lastActivityAt)-Date.parse(r.lastActivityAt)})}let Fn=0;function Qo(e=Date.now()){return Fn=(Fn+1)%1e4,`${Uo}${e}_${Fn}`}function Zo(e){const t=e.now??new Date().toISOString();return{sessionId:e.sessionId,agent:e.agent,cwd:e.cwd||qe,...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 Yo(e,t,n=new Date().toISOString()){return{...e,sessionId:t,lastActivityAt:n}}function $n(e,t,n){if(!t||!n||t===n||!Object.hasOwn(e,t))return e;const{[t]:r,...i}=e;return{...i,[n]:r}}function Es(e,t,n){if(!t||!n||t===n||!e.has(t))return e;const r=new Set(e);return r.delete(t),r.add(n),r}function Un(e,t){const n=e.replace(/\\/g,"/").replace(/\/+$/,"");return!n||n==="."?t:`${n}/${t}`}function Ms(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 Jo(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 Xo(e,t){return t.startsWith("image/")||/\.(png|jpe?g|gif|webp|heic|heif|svg)$/i.test(e)}function Ln(e,t,n=window.location.origin){const r=new URL("/file",n);return r.searchParams.set("path",e),t&&r.searchParams.set("cwd",t),r.toString()}function un(e,t){return e.get(t)||void 0}function ec(e,t){return`${e.replace(/[<>:"/\\|?*\u0000-\u001F]/g," ").replace(/\s+/g," ").trim().slice(0,80)||t.slice(0,12)||"session"}.txt`}function tc(e,t){const n=[`# ${ze(e)}`,"",`- Agent: ${e.agent}`,`- Session: \`${e.sessionId}\``,`- Working directory: \`${e.cwd}\``,`- Created: ${e.createdAt}`,`- Exported: ${new Date().toISOString()}`,""];for(const r of t){if(r.role!=="user"&&r.role!=="assistant")continue;const i=r.content.trim(),a=(r.images??[]).map(l=>`- Attachment: \`${l}\``);!i&&a.length===0||(n.push(`## ${r.role==="user"?"User":"Assistant"}`,""),i&&n.push(i,""),a.length&&n.push(...a,""))}return n.join(`
3
+ `).trimEnd()}function Sr(e){const t=[`cd ${nc(e.cwd||qe)} &&`],n=e.approvalMode??e.observedApprovalMode;return e.agent==="claude"?(t.push("claude","--resume",e.sessionId),n==="autoApprove"?t.push("--dangerously-skip-permissions"):n==="acceptEdits"&&t.push("--permission-mode","acceptEdits"),t.join(" ")):(t.push("codex","resume",e.sessionId),n==="autoApprove"&&t.push("--dangerously-bypass-approvals-and-sandbox"),t.join(" "))}function nc(e){return/^[a-zA-Z0-9._/~-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function sc(e,t){const n=URL.createObjectURL(new Blob([t],{type:"text/plain;charset=utf-8"})),r=document.createElement("a");r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}function rc(e=window.localStorage){try{const t=e.getItem(yr);if(!t)return{...lt};const n=JSON.parse(t);return Wt(n)?{enabled:typeof n.enabled=="boolean"?n.enabled:lt.enabled,approvals:typeof n.approvals=="boolean"?n.approvals:lt.approvals,questions:typeof n.questions=="boolean"?n.questions:lt.questions,replies:typeof n.replies=="boolean"?n.replies:lt.replies,hiddenOnly:typeof n.hiddenOnly=="boolean"?n.hiddenOnly:lt.hiddenOnly}:{...lt}}catch{return{...lt}}}function ic(e,t=window.localStorage){t.setItem(yr,JSON.stringify(e))}function Kn(e=typeof Notification>"u"?void 0:Notification){return e?.permission??"unsupported"}function ac(e,t,n=typeof document>"u"?"visible":document.visibilityState){return!(!e.enabled||t!=="granted"||e.hiddenOnly&&n==="visible")}function oc(e,t,n={}){const r=n.notificationFactory??(typeof Notification>"u"?void 0:Notification);if(!r)return!1;const i=n.settings??{enabled:!0,hiddenOnly:!1},a=n.permission??Kn(),l=n.visibilityState??(typeof document>"u"?"visible":document.visibilityState);if(!ac(i,a,l))return!1;const c=new r(e,{body:t,tag:n.tag});return n.onClick&&(c.onclick=n.onClick),!0}function cc(e,t={}){const n=new Set,r={},i={},a={};for(const x of e.sessions)(x.runtime.isResponding||x.runtime.state==="daemonActive")&&n.add(x.sessionId);for(const x of e.pendingApprovals??[])r[x.sessionId]={type:"approval.request",...x};for(const x of e.pendingQuestions??[])i[x.sessionId]={type:"question.request",...x};let l=null,c,f,d,m,S,g;if(e.activeSession){const x=e.activeSession,C=e.sessions.find(u=>u.sessionId===x.sessionId);l=x.sessionId,c=x.agent,f=C?.cwd||t.currentCwd||qe,d=x.approvalMode??C?.approvalMode??zn,m=x.approvalMode??null;const b=x.messages??[];if(S=x.partialReplyText?ss(b,x.partialReplyText):b,(x.isResponding||x.externallyResponding)&&n.add(x.sessionId),x.pendingApproval&&(r[x.sessionId]={type:"approval.request",sessionId:x.sessionId,...x.pendingApproval}),x.pendingQuestion){const u={type:"question.request",sessionId:x.sessionId,...x.pendingQuestion};i[x.sessionId]=u,g=Wn(u)}x.pendingQueue?.length&&(a[x.sessionId]=x.pendingQueue)}else{const x=t.currentActiveSessionId??null;if(x){const C=e.sessionAliases?.[x];C?l=C:e.sessions.some(b=>b.sessionId===x)&&(l=x)}l=l??e.sessions[0]?.sessionId??null}return{page:{sessions:e.sessions,nextCursor:gr(e.nextCursor),inventoryVersion:e.inventoryVersion,inventoryBackfillInFlight:e.inventoryBackfillInFlight},activeSessionId:l,activeAgent:c,activeCwd:f,activeApprovalMode:d,activeApprovalOverride:m,messages:S,respondingSessionIds:Array.from(n),pendingApprovals:r,pendingQuestions:i,pendingQueues:a,questionAnswers:g}}function Ut(e,t=n=>window.confirm(n)){return t(`${e}
4
+
5
+ This action cannot be undone from Vibelet Web.`)}function _s(e,t){return e==="subscriptionRequired"?t?"Agent skills require an active Pro subscription.":"Terminal takeover requires an active Pro subscription.":e==="skillNotFound"?"Skill not found on the paired computer.":e==="skillResolveFailed"?"Could not load the skill on the paired computer.":e}function lc({activeSession:e,busy:t,controlsOpen:n,pendingActionsCount:r,t:i,onOpenControls:a,onRefreshSessions:l,onRestoreSnapshot:c,onToggleArchived:f,onTogglePinned:d,onViewChanges:m}){const[S,g]=o.useState(!1),x=o.useRef(null);o.useEffect(()=>{if(!S)return;const b=w=>{w.target instanceof Node&&!x.current?.contains(w.target)&&g(!1)},u=w=>{w.key==="Escape"&&g(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",u),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",u)}},[S]);const C=b=>{g(!1),b()};return s.jsxs("div",{className:"header-actions",children:[e?null:s.jsx("button",{"aria-label":i.refreshSessions,className:"icon-button",onClick:l,title:i.refreshSessions,type:"button",children:s.jsx(Gt,{"aria-hidden":"true"})}),s.jsxs("button",{"aria-expanded":n,"aria-label":r>0?`${i.workspaceTools}, ${r} ${i.pendingActions}`:i.workspaceTools,className:`header-tool-button ${n?"selected":""}`,onClick:a,type:"button",children:[s.jsx(hr,{"aria-hidden":"true"}),s.jsx("span",{children:i.workspaceTools}),r>0?s.jsx("strong",{"aria-hidden":"true",children:r}):null]}),e?s.jsxs("div",{className:"header-more-wrap",ref:x,children:[s.jsx("button",{"aria-expanded":S,"aria-haspopup":"menu","aria-label":i.moreActions,className:"icon-button",onClick:()=>g(b=>!b),title:i.moreActions,type:"button",children:s.jsx(or,{"aria-hidden":"true"})}),S?s.jsxs("div",{className:"header-action-menu",role:"menu",children:[s.jsxs("button",{onClick:()=>C(()=>m(e.sessionId)),role:"menuitem",type:"button",children:[s.jsx(lr,{"aria-hidden":"true"}),s.jsx("span",{children:i.viewChanges})]}),s.jsxs("button",{disabled:t,onClick:()=>C(d),role:"menuitem",type:"button",children:[s.jsx(xn,{"aria-hidden":"true"}),s.jsx("span",{children:e.pinned?i.unpin:i.pin})]}),s.jsxs("button",{disabled:t,onClick:()=>C(f),role:"menuitem",type:"button",children:[s.jsx(Zn,{"aria-hidden":"true"}),s.jsx("span",{children:e.archived?i.unarchive:i.archive})]}),s.jsxs("button",{onClick:()=>C(c),role:"menuitem",type:"button",children:[s.jsx(xo,{"aria-hidden":"true"}),s.jsx("span",{children:i.restoreSnapshot})]}),s.jsxs("button",{onClick:()=>C(l),role:"menuitem",type:"button",children:[s.jsx(Gt,{"aria-hidden":"true"}),s.jsx("span",{children:i.refreshSessions})]})]}):null]}):null]})}const dc=/^[A-Za-z][A-Za-z0-9_-]*$/,uc=[{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 vr(e){return uc.filter(t=>!e||t.agents.includes(e))}function rs(e){return e.trim().toLowerCase()}function mn(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&&!dc.test(n)?null:{start:0,end:e.length,keyword:rs(n)}}function fc(e,t,n=8){const r=rs(t);return(r?e.filter(a=>a.name.includes(r)||a.title.toLowerCase().includes(r)).sort((a,l)=>Ds(a,r)-Ds(l,r)):[...e]).slice(0,n)}function Ds(e,t){return e.name===t?0:e.name.startsWith(t)?1:e.name.includes(t)?2:3}function hc(e,t,n){return`${e.slice(0,t.start)}${wr(n,"")}${e.slice(t.end)}`}function mc(e,t,n){return t?hc(e,t,n):`${wr(n,e)}${e}`}function wr(e,t){const n=t.length>0,r=n&&!/^\s/.test(t),i=!!(e.argsHint&&!n);return`/${e.name}${i||r?" ":""}`}function pc(e,t){const n=e.trim();if(!n.startsWith("/")||n.startsWith("//"))return null;const r=/^\/([A-Za-z][A-Za-z0-9_-]*)(?:\s+([\s\S]*))?$/.exec(n);if(!r)return null;const i=rs(r[1]??""),a=vr(t).find(c=>c.name===i);if(!a)return null;const l=r[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 c=l.toLowerCase();return!l||c==="status"||c==="show"||c==="usage"||c==="help"?{raw:n,command:{name:"goal",operation:"status"}}:c==="clear"||c==="reset"?{raw:n,command:{name:"goal",operation:"clear"}}:c==="pause"||c==="paused"?{raw:n,command:{name:"goal",operation:"pause"}}:c==="resume"||c==="active"?{raw:n,command:{name:"goal",operation:"resume"}}:{raw:n,command:{name:"goal",operation:"set",objective:l}}}}}function gc(e){return e.startsWith("//")?e.slice(1):e}function yc(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 bc(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 Ps(e){return e==="subscriptionRequired"?"Error: Agent commands require an active Pro subscription.":`Error: ${e||"Command failed."}`}function xc(e,t){return!t||!mn(e)?e:t.draftBeforeInsertion}const Sc=/^[A-Za-z_][A-Za-z0-9._:-]*$/,vc=/(?:^|\s)\$([A-Za-z_][A-Za-z0-9._:-]*|)$/;function Qt(e){return e.trim().toLowerCase()}function wc(e){const t=e.trim(),n=/^\$([A-Za-z_][A-Za-z0-9._:-]*)(?:\s+([\s\S]*))?$/.exec(t);return n?{name:Qt(n[1]??""),...n[2]?.trim()?{args:n[2].trim()}:{}}:null}function pn(e){const t=vc.exec(e);if(!t||t.index+t[0].length!==e.length)return null;const n=t[1]??"";if(n&&!Sc.test(n))return null;const r=t[0].lastIndexOf("$");return{start:t.index+r,end:e.length,keyword:Qt(n)}}function kc(e,t,n){return`${e.slice(0,t.start)}$${Qt(n)} ${e.slice(t.end)}`}function jc(e,t){if(!t)return e;const n=pn(e);if(!n||n.start!==t.triggerStart)return e;const r=n.start>t.draftBeforeInsertion.length?" ":"";return e.slice(0,n.start)!==`${t.draftBeforeInsertion}${r}`?e:t.draftBeforeInsertion}function Cc(e,t,n=8){const r=Qt(t);return(r?e.filter(a=>Qt(a.name).includes(r)):e).slice(0,n)}function Bt({icon:e,label:t,menuLabel:n,options:r,value:i,onSelect:a,align:l="left",disabled:c,selected:f,wide:d}){const[m,S]=o.useState(!1);return s.jsxs("div",{className:"composer-menu",onBlur:g=>{const x=g.relatedTarget;(!x||!g.currentTarget.contains(x))&&S(!1)},onKeyDown:g=>{g.key==="Escape"&&S(!1)},children:[s.jsxs("button",{"aria-expanded":m,"aria-haspopup":"menu",className:`composer-option-button ${m||f?"selected":""}`,disabled:c,onClick:()=>S(g=>!g),title:n,type:"button",children:[s.jsx(e,{"aria-hidden":"true"}),s.jsx("span",{children:t}),s.jsx(Da,{"aria-hidden":"true"})]}),m?s.jsx("div",{"aria-label":n,className:`composer-option-popover ${d?"wide":""} ${l==="right"?"align-right":""}`,role:"menu",children:r.map(g=>{const x=g.icon,C=g.value===i;return s.jsxs("button",{"aria-checked":C,className:C?"selected":"",disabled:g.disabled,onClick:()=>{a(g.value),S(!1)},role:"menuitemradio",title:g.description??g.label,type:"button",children:[s.jsx("span",{className:"composer-menu-icon",children:x?s.jsx(x,{"aria-hidden":"true"}):C?s.jsx(nt,{"aria-hidden":"true"}):null}),s.jsxs("span",{children:[s.jsx("strong",{children:g.label}),g.description?s.jsx("small",{children:g.description}):null]}),C?s.jsx(nt,{className:"composer-menu-check","aria-hidden":"true"}):null]},g.value)})}):null]})}function Nc({visible:e,skills:t,onClose:n,onSelect:r,t:i}){return e?s.jsxs("div",{className:"skill-suggestion-popover",children:[s.jsxs("header",{children:[s.jsx("strong",{children:i.skills}),s.jsx("button",{type:"button",className:"icon-button",onClick:n,title:i.closeSkills,children:s.jsx(we,{"aria-hidden":"true"})})]}),t.length?s.jsx("div",{className:"skill-suggestion-list",children:t.map(a=>s.jsxs("button",{onClick:()=>r(a),title:a.description??a.name,type:"button",children:[s.jsxs("span",{children:[s.jsxs("strong",{children:["$",a.name]}),a.description?s.jsx("small",{children:a.description}):null]}),s.jsx("em",{children:a.source})]},`${a.source}:${a.name}`))}):s.jsx("p",{children:i.noSkillsFound})]}):null}function Ic({visible:e,commands:t,onClose:n,onSelect:r,t:i}){return e?s.jsxs("div",{className:"skill-suggestion-popover command-suggestion-popover",children:[s.jsxs("header",{children:[s.jsx("strong",{children:i.commands}),s.jsx("button",{type:"button",className:"icon-button",onClick:n,title:i.closeCommands,children:s.jsx(we,{"aria-hidden":"true"})})]}),t.length?s.jsx("div",{className:"skill-suggestion-list",children:t.map(a=>s.jsxs("button",{onClick:()=>r(a),title:a.description,type:"button",children:[s.jsxs("span",{children:[s.jsxs("strong",{children:["/",a.name]}),s.jsx("small",{children:a.argsHint?`${a.title} ${a.argsHint}`:a.title})]}),s.jsx("em",{children:a.source})]},a.name))}):s.jsx("p",{children:i.noCommandsFound})]}):null}function Ac(e){return[{value:"normal",label:e.approvalNormal,description:e.approvalNormalDescription,icon:Sn},{value:"plan",label:e.approvalPlan,description:e.approvalPlanDescription,icon:mr},{value:"acceptEdits",label:e.approvalEdits,description:e.approvalEditsDescription,icon:nt},{value:"autoApprove",label:e.approvalAuto,description:e.approvalAutoDescription,icon:zt}]}function Rc(e){return[{value:"",label:e.effort,description:e.useDaemonDefault,icon:Ze},{value:"minimal",label:e.effortMinimal,icon:Ze},{value:"low",label:e.effortLow,icon:Ze},{value:"medium",label:e.effortMedium,icon:Ze},{value:"high",label:e.effortHigh,icon:Ze},{value:"xhigh",label:e.effortXHigh,icon:Ze},{value:"max",label:e.effortMax,icon:Ze},{value:"ultra",label:e.effortUltra,icon:Ze}]}function Tc({activeQueue:e,agent:t,attachments:n,approvalMode:r,activeModelOptions:i,busy:a,draft:l,effort:c,fastMode:f,model:d,phase:m,quickReplies:S,sendShortcut:g,skills:x,uploadBusy:C,t:b,onApprovalModeChange:u,onCancelQueuedTurn:w,onDraftChange:h,onEffortChange:v,onFastModeChange:M,onModelChange:y,onRefreshSkills:A,onRemoveAttachment:k,onSendShortcutChange:U,onSubmit:fe,onUploadFiles:Z}){const he=o.useRef(null),se=o.useRef(null),[$,re]=o.useState(!1),[ge,je]=o.useState(!1),[_,E]=o.useState(!1),[B,P]=o.useState(!1),[ie,ye]=o.useState(""),[We,Ae]=o.useState(""),J=o.useRef(null),X=o.useRef(null),ke=m==="connected",Me=o.useMemo(()=>vr(t),[t]),ae=o.useMemo(()=>mn(l),[l]),z=ae?`${ae.start}:${ae.end}:${ae.keyword}`:"",V=!!(B||ae&&We!==z),G=o.useMemo(()=>fc(Me,ae?.keyword??"",8),[Me,ae?.keyword]),oe=o.useMemo(()=>pn(l),[l]),le=oe?`${oe.start}:${oe.end}:${oe.keyword}`:"",be=!!(!V&&(_||oe&&ie!==le)),xe=o.useMemo(()=>Cc(x,oe?.keyword??"",8),[oe?.keyword,x]),Re=o.useMemo(()=>Ac(b),[b]),K=o.useMemo(()=>Rc(b),[b]),_e=i.find(I=>I.value===d)?.label??(d||b.defaultOption),T=Re.find(I=>I.value===r)?.label??r,Q=K.find(I=>I.value===c)?.label??c,Ue=g==="enter"?b.sendShortcutEnter:b.sendShortcutModEnter,De=o.useMemo(()=>[{value:"enter",label:b.sendShortcutEnter,description:b.sendShortcutEnterDescription,icon:Rs},{value:"modEnter",label:b.sendShortcutModEnter,description:b.sendShortcutModEnterDescription,icon:co}],[b]),Pe=i.map(I=>({value:I.value,label:I.label,description:I.desc,icon:Pn}));Pe.some(I=>I.value==="")||Pe.unshift({value:"",label:b.defaultOption,description:b.useDaemonDefaultModel,icon:Pn}),o.useEffect(()=>{oe||(J.current=null,ye(""),E(!1))},[oe]),o.useEffect(()=>{ae||(X.current=null,Ae(""),P(!1))},[ae]);const Ce=async(I,te)=>{await Z(I),te.value=""},Ke=async I=>{I.preventDefault(),re(!1),ke&&await Z(I.dataTransfer.files)},Fe=async I=>{!ke||!I.clipboardData.files.length||await Z(I.clipboardData.files)},Je=()=>{const I=jc(l,J.current);J.current=null,I!==l&&h(I),le&&ye(le),E(!1),se.current?.focus()},Te=()=>{const I=xc(l,X.current);X.current=null,I!==l&&h(I),z&&Ae(z),P(!1),se.current?.focus()},st=()=>{if(V){Te();return}Ae(""),!mn(l)&&l.length===0&&(X.current={draftBeforeInsertion:l},h("/")),P(!0),se.current?.focus()},Xe=I=>{const te=mn(l),$e=mc(l,te,I);h($e),X.current=null,P(!1),Ae(""),se.current?.focus()},Se=()=>{if(be){Je();return}if(A(),ye(""),!pn(l)){const I=l.length===0||/\s$/.test(l)?"":" ";J.current={draftBeforeInsertion:l,triggerStart:l.length+I.length},h(`${l}${I}$`)}E(!0),se.current?.focus()},et=I=>{const te=pn(l),$e=te?kc(l,te,I.name):l.trim().length?`${l}${/\s$/.test(l)?"":" "}$${I.name} `:`$${I.name} `;h($e),J.current=null,E(!1),ye(""),se.current?.focus()},pe=I=>{I.key!=="Enter"||I.nativeEvent.isComposing||!(g==="enter"?!I.shiftKey:I.metaKey||I.ctrlKey)||(I.preventDefault(),fe())};return s.jsxs("form",{className:`composer ${$?"dragging":""}`,onDragEnter:I=>{I.preventDefault(),re(!0)},onDragLeave:()=>re(!1),onDragOver:I=>I.preventDefault(),onDrop:I=>{Ke(I)},onSubmit:I=>{fe(I)},children:[e.length?s.jsxs("div",{className:"composer-queue-banner",children:[s.jsx(ar,{"aria-hidden":"true"}),s.jsxs("div",{children:[s.jsxs("strong",{children:[e.length," queued"]}),s.jsx("span",{children:e[0]?.content??"A turn is waiting for this session."})]}),s.jsxs("button",{className:"icon-text-button",disabled:a||!e[0],onClick:()=>e[0]&&w(e[0]),type:"button",children:[s.jsx(we,{"aria-hidden":"true"}),"Withdraw"]})]}):null,ge&&S.length?s.jsx("div",{className:"quick-reply-row",children:S.slice(0,6).map(I=>s.jsx("button",{onClick:()=>h(l?`${l}
6
+ ${I}`:I),type:"button",children:I},I))}):null,s.jsx(Nc,{visible:be,skills:xe,onClose:Je,onSelect:et,t:b}),s.jsx(Ic,{visible:V,commands:G,onClose:Te,onSelect:Xe,t:b}),s.jsx("textarea",{ref:se,value:l,onChange:I=>h(I.target.value),onPaste:I=>{Fe(I)},onKeyDown:pe,placeholder:b.messagePlaceholder,rows:3,disabled:!ke}),s.jsxs("div",{className:"composer-toolbar",children:[s.jsxs("div",{className:"composer-leading-controls",children:[s.jsx("button",{type:"button",className:"icon-button",onClick:()=>he.current?.click(),title:b.uploadFiles,disabled:!ke||C,children:s.jsx(Jn,{"aria-hidden":"true"})}),S.length?s.jsx("button",{className:`icon-button ${ge?"selected":""}`,type:"button",title:ge?b.hideQuickReplies:b.showQuickReplies,onClick:()=>je(I=>!I),children:s.jsx(No,{"aria-hidden":"true"})}):null,s.jsx("button",{className:`icon-button ${be?"selected":""}`,type:"button",title:b.skills,onClick:Se,disabled:!ke||C,children:s.jsx(zt,{"aria-hidden":"true"})}),s.jsx("button",{className:`icon-button ${V?"selected":""}`,type:"button",title:b.commands,onClick:st,disabled:!ke||C,children:s.jsx(es,{"aria-hidden":"true"})})]}),s.jsx("input",{ref:he,type:"file",multiple:!0,hidden:!0,onChange:I=>{Ce(I.currentTarget.files,I.currentTarget)}}),s.jsxs("div",{className:"composer-control-strip",children:[s.jsx(Bt,{icon:Sn,label:T,menuLabel:b.approvalMode,options:Re,value:r,onSelect:u,wide:!0}),s.jsx(Bt,{icon:Pn,label:_e,menuLabel:b.model,options:Pe,value:d,onSelect:y,align:"right",wide:!0}),s.jsx(Bt,{icon:Ze,label:Q||b.effort,menuLabel:b.effort,options:K,value:c,onSelect:v,align:"right"}),s.jsx(Bt,{icon:zt,label:f?b.fast:b.normal,menuLabel:b.fastMode,options:[{value:"off",label:b.normal,description:b.standardExecution,icon:Ze},{value:"on",label:b.fast,description:b.preferFasterResponses,icon:zt}],value:f?"on":"off",onSelect:I=>M(I==="on"),align:"right",selected:f,wide:!0}),s.jsx(Bt,{icon:Rs,label:Ue,menuLabel:b.sendShortcut,options:De,value:g,onSelect:U,align:"right",wide:!0})]}),s.jsx("button",{type:"submit",className:"send-button",disabled:!ke||a||!l.trim(),"aria-label":b.send,title:b.send,children:s.jsx(Ia,{"aria-hidden":"true"})})]}),n.length||C?s.jsx("div",{className:"attachment-row",children:n.length?s.jsx("div",{className:"attachment-list",children:n.map(I=>s.jsxs("span",{children:[s.jsx(Yn,{"aria-hidden":"true"}),I.name||vn(I.path),s.jsx("small",{children:Ko(I.size)}),s.jsx("button",{type:"button",onClick:()=>k(I.path),title:b.removeAttachment,children:s.jsx(we,{"aria-hidden":"true"})})]},I.path))}):s.jsxs("span",{className:"attachment-empty",children:[s.jsx("span",{className:"loading-spinner small","aria-hidden":"true"}),b.uploading]})}):null]})}const Ec=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Fs(e){return Array.from(e.querySelectorAll(Ec)).filter(t=>!t.hidden&&t.getAttribute("aria-hidden")!=="true")}function wn(e,t,n=!0){const r=o.useRef(null),i=o.useRef(e);return i.current=e,o.useLayoutEffect(()=>{if(!n)return;const a=r.current;if(!a)return;const l=document.activeElement instanceof HTMLElement?document.activeElement:null;(t?.current??Fs(a)[0]??a).focus();const f=d=>{if(d.key==="Escape"){d.preventDefault(),i.current();return}if(d.key!=="Tab")return;const m=Fs(a);if(!m.length){d.preventDefault(),a.focus();return}const S=m[0],g=m.at(-1);d.shiftKey&&(document.activeElement===S||!a.contains(document.activeElement))?(d.preventDefault(),g.focus()):!d.shiftKey&&document.activeElement===g&&(d.preventDefault(),S.focus())};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),requestAnimationFrame(()=>l?.focus())}},[n,t]),r}function Mc({cwd:e,paths:t,t:n,onClose:r,onOpenRemoteFile:i}){const a=o.useRef(null),l=wn(r,a,t.length>0);return t.length?s.jsxs("div",{"aria-labelledby":"attachment-preview-title","aria-modal":"true",className:"side-drawer",ref:l,role:"dialog",tabIndex:-1,children:[s.jsx("button",{className:"side-drawer-backdrop",onClick:r,type:"button","aria-label":n.closeAttachmentPreview}),s.jsxs("aside",{className:"side-drawer-panel",children:[s.jsxs("header",{className:"side-drawer-header",children:[s.jsxs("div",{children:[s.jsx("strong",{id:"attachment-preview-title",children:n.attachments}),s.jsx("span",{children:n.fileCount(t.length)})]}),s.jsx("button",{"aria-label":n.closeAttachmentPreview,className:"icon-button",onClick:r,ref:a,type:"button",children:s.jsx(we,{"aria-hidden":"true"})})]}),s.jsx("div",{className:"stack-list",children:t.map(c=>s.jsxs("button",{className:"data-row attachment-preview-row",onClick:()=>i(c,e),type:"button",children:[s.jsx(Yn,{"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:vn(c)}),s.jsx("small",{children:c})]}),s.jsx(rr,{"aria-hidden":"true"})]},c))})]})]}):null}async function _c(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();const n=document.execCommand("copy");if(t.remove(),!n)throw new Error("Clipboard copy was rejected")}function Dc(e,t){const[n,r]=o.useState(null),i=o.useRef(null);return o.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),{copyText:o.useCallback(async l=>{try{await _c(l),r({message:e,tone:"success"})}catch{r({message:t,tone:"error"})}i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>r(null),2400)},[t,e]),feedback:n}}function Pc({feedback:e}){if(!e)return null;const t=e.tone==="success"?nt:we;return s.jsxs("div",{className:`copy-feedback ${e.tone}`,role:"status",children:[s.jsx(t,{"aria-hidden":"true"}),e.message]})}function Fc({message:e,retryLabel:t,onRetry:n}){return s.jsxs("div",{className:"notice error",children:[s.jsx(we,{"aria-hidden":"true"}),s.jsx("span",{children:e}),s.jsxs("button",{className:"icon-text-button",onClick:n,type:"button",children:[s.jsx(Gt,{"aria-hidden":"true"}),t]})]})}function $c({label:e}){return s.jsxs("div",{className:"history-loading-state","aria-busy":"true","aria-label":e,role:"status",children:[s.jsx("span",{className:"loading-spinner","aria-hidden":"true"}),s.jsxs("div",{className:"history-loading-copy",children:[s.jsx("strong",{children:e}),s.jsx("span",{"aria-hidden":"true"}),s.jsx("span",{"aria-hidden":"true"}),s.jsx("span",{"aria-hidden":"true"})]})]})}function $s({failedSend:e,onRetry:t,t:n}){const r={network:n.sendFailedNetwork,timeout:n.sendFailedTimeout,permission:n.sendFailedPermission,subscription:n.sendFailedSubscription,"missing-resource":n.sendFailedMissingResource,unknown:n.sendFailedUnknown}[e.kind];return s.jsxs("div",{className:"failed-send-notice",role:"alert",children:[s.jsx(we,{"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:n.sendFailed}),r]}),s.jsxs("button",{disabled:e.retrying,onClick:t,type:"button",children:[s.jsx(Gt,{"aria-hidden":"true",className:e.retrying?"spin":void 0}),e.retrying?n.retrying:n.retrySend]})]})}function Lc({busy:e,label:t,stopLabel:n,onStop:r}){return s.jsxs("div",{className:"typing-line",role:"status",children:[s.jsx("span",{className:"typing-indicator","aria-hidden":"true"}),s.jsx("span",{children:t}),s.jsxs("button",{className:"stop-generating-button",disabled:e,onClick:r,type:"button",children:[s.jsx(Ro,{"aria-hidden":"true"}),n]})]})}function Oc({label:e,onClick:t}){return s.jsxs("button",{className:"scroll-latest-button",type:"button","aria-label":e,title:e,onClick:t,children:[s.jsx(Ca,{"aria-hidden":"true"}),s.jsx("span",{children:e})]})}const Bc=/\u001B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,qc=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u00AD\u061C\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFEFF]/g,Hc=new Set(["","{}","[]","null","undefined",'""']);function fn(e){return e.replace(/\s+/g," ").trim()}function ce(e,t){return typeof e[t]=="string"?e[t]:""}function Ls(e,t){return typeof e[t]=="number"?e[t]:void 0}function qt(e,t){return e.length<=t?e:`${e.slice(0,t)}...`}function On(e){const t=[],n=ce(e,"file_path")||ce(e,"filePath");n&&t.push({label:"Path",value:n,isFilePath:!0});const r=Ls(e,"offset"),i=Ls(e,"limit");if(r!==void 0||i!==void 0){const a=[];r!==void 0&&a.push(`line ${r+1}`),i!==void 0&&a.push(`to ${r!==void 0?r+i:i}`),t.push({label:"Range",value:a.join(" ")})}return t}function zc(e){return typeof e!="string"?"":e.replace(/\r\n?/g,`
7
+ `).replace(Bc,"").replace(qc,"").trim()}function is(e){const t=zc(e);return Hc.has(t)?"":t}function Wc(e){return is(e).length>0}function as(e){const t=is(e);if(!t)return"";try{const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=typeof n.query=="string"?fn(n.query):"";if(r)return r;const i=typeof n.command=="string"?fn(n.command):"";if(i)return i;const a=typeof n.description=="string"?fn(n.description):"";if(a)return a}}catch{}return fn(t)}function Uc(e,t){if(!t)return[];switch((e??"").toLowerCase()){case"read":return On(t);case"write":{const r=On(t),i=ce(t,"content");return i&&r.push({label:"Content",isDiff:!0,value:"",diffNew:qt(i,500)}),r}case"edit":{const r=On(t),i=ce(t,"old_string")||ce(t,"oldString"),a=ce(t,"new_string")||ce(t,"newString");return(i||a)&&r.push({label:"Change",isDiff:!0,value:"",diffOld:qt(i,300),diffNew:qt(a,300)}),r}case"bash":{const r=ce(t,"command");return r?[{label:"Command",value:r,isCode:!0}]:[]}case"websearch":{const r=ce(t,"query");return r?[{label:"Query",value:r}]:[]}case"webfetch":{const r=[],i=ce(t,"url");i&&r.push({label:"URL",value:i});const a=ce(t,"prompt");return a&&r.push({label:"Prompt",value:qt(a,200)}),r}case"glob":{const r=ce(t,"pattern");return r?[{label:"Pattern",value:r}]:[]}case"grep":{const r=[],i=ce(t,"pattern");i&&r.push({label:"Pattern",value:i,isCode:!0});const a=ce(t,"path");return a&&r.push({label:"In",value:a,isFilePath:!0}),r}default:{const r=[],i=ce(t,"command");if(i)return[{label:"Command",value:i,isCode:!0}];const a=ce(t,"file_path")||ce(t,"filePath");a&&r.push({label:"Path",value:a,isFilePath:!0});const l=ce(t,"description");l&&r.push({label:"Description",value:qt(l,200)});const c=ce(t,"query");c&&r.push({label:"Query",value:c});const f=ce(t,"url");return f&&r.push({label:"URL",value:f}),r}}}function Os(e){return e.role==="tool"?!0:e.type!=="info"?!1:!/^Error:/i.test(e.content.trim())}function kr(e){const t=[];for(const r of e){const i=r.toolName?.trim();i&&!t.includes(i)&&t.push(i)}return t.length?t.join(", "):e.map(r=>as(r.content)).find(Boolean)??""}function jr(e,t){return`${e.historyKey??e.timestamp??e.toolName??e.content.slice(0,24)??"message"}:${t}`}function Kc(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e[n];if(!Os(r)){t.push({type:"message",index:n,message:r});continue}const i=[];let a=n;for(;a<e.length&&Os(e[a]);)i.push({index:a,message:e[a]}),a+=1;t.push({type:"toolGroup",entries:i,id:`tool-group:${i.map(({index:l,message:c})=>jr(c,l)).join("|")}`}),n=a-1}return t}function Vc(e,t){return e.type==="message"?e.index===t:e.entries.some(n=>n.index===t)}function Gc({message:e,onClose:t,onCopy:n,t:r}){if(!e)return null;const i=e.content;return s.jsxs("section",{className:"message-source-inline","aria-label":r.markdownSource,children:[s.jsxs("header",{className:"inline-detail-header",children:[s.jsxs("div",{className:"inline-detail-title",children:[s.jsx("strong",{children:r.markdownSource}),s.jsx("span",{children:e.type==="info"?"info":e.role})]}),s.jsxs("div",{className:"row-actions",children:[s.jsx("button",{className:"icon-button",onClick:()=>n(i),type:"button",title:r.copyMarkdownSource,children:s.jsx(It,{"aria-hidden":"true"})}),s.jsx("button",{className:"icon-button",onClick:t,type:"button",title:r.closeSource,children:s.jsx(we,{"aria-hidden":"true"})})]})]}),s.jsx("pre",{className:"json-box markdown-source-box",children:i})]})}function Qc({field:e}){return e.isDiff?s.jsxs("div",{className:"tool-field diff",children:[s.jsx("span",{children:e.label}),e.diffOld?s.jsxs("pre",{className:"tool-diff old",children:[s.jsx("b",{children:"-"}),e.diffOld]}):null,e.diffNew?s.jsxs("pre",{className:"tool-diff new",children:[s.jsx("b",{children:"+"}),e.diffNew]}):null]}):s.jsxs("div",{className:`tool-field ${e.isCode?"code":""} ${e.isFilePath?"path":""}`,children:[s.jsx("span",{children:e.label}),s.jsx("pre",{children:e.value})]})}function Zc({message:e,onCopy:t,t:n}){const r=Uc(e.toolName,e.toolInput),i=as(e.content),a=is(e.content),l=Wc(e.content)&&!r.length,c=e.toolName??n.tool;return s.jsxs("section",{className:"tool-detail-card",children:[s.jsxs("header",{children:[s.jsx("span",{className:"tool-detail-icon",children:s.jsx(ts,{"aria-hidden":"true"})}),s.jsxs("div",{children:[s.jsx("strong",{children:c}),i?s.jsx("small",{title:i,children:i}):null]}),s.jsx("button",{className:"icon-button",onClick:()=>t(e.content),type:"button",title:n.copyOutput,children:s.jsx(It,{"aria-hidden":"true"})})]}),r.length?s.jsx("div",{className:"tool-fields",children:r.map((f,d)=>s.jsx(Qc,{field:f},`${f.label}:${d}`))}):null,l?s.jsx("pre",{className:"json-box compact",children:a}):null]})}function Cr({messages:e,onClose:t,onCopy:n,t:r}){if(!e.length)return null;const a=e.filter(d=>d.role==="tool").length||e.length,l=r.toolCallCount(a),c=kr(e),f=e.map(d=>d.content).join(`
8
+
9
+ `);return s.jsxs("section",{className:"tool-inline-panel","aria-label":r.toolDetails,children:[s.jsxs("header",{className:"inline-detail-header",children:[s.jsxs("div",{className:"inline-detail-title",children:[s.jsx("strong",{children:l}),s.jsx("span",{title:c,children:c||r.toolDetail})]}),s.jsxs("div",{className:"row-actions",children:[s.jsx("button",{className:"icon-button",onClick:()=>n(f),type:"button",title:r.copyOutput,children:s.jsx(It,{"aria-hidden":"true"})}),s.jsx("button",{className:"icon-button",onClick:t,type:"button",title:r.closeToolDetails,children:s.jsx(we,{"aria-hidden":"true"})})]})]}),s.jsx("div",{className:"tool-detail-list",children:e.map((d,m)=>s.jsx(Zc,{message:d,onCopy:n,t:r},`${d.historyKey??d.timestamp??d.toolName??"tool"}:${m}`))})]})}const Yc=o.lazy(async()=>Ye(()=>import("./mermaid-O7DHMXV3-D0ujIgIK.js").then(e=>e.a),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.MessageMarkdown})));function Jc({activeMatch:e,baseCwd:t,message:n,onCopy:r,onCloseSource:i,onCloseTool:a,onOpenAttachment:l,onOpenRemoteFile:c,onToggleSource:f,onToggleTool:d,sourceOpen:m,toolOpen:S,t:g}){const x=n.role==="tool"?as(n.content):"";return s.jsxs("article",{className:`message ${n.role} ${n.type==="info"?"info":""} ${e?"match":""}`,children:[s.jsxs("div",{className:"message-meta",children:[s.jsx("span",{children:n.type==="info"?"info":n.role}),s.jsxs("div",{className:"message-meta-side",children:[s.jsx("time",{children:ns(n.timestamp)}),s.jsxs("div",{className:"message-actions","aria-label":g.messageActions,role:"group",children:[s.jsx("button",{"aria-label":g.copyMessage,onClick:()=>r(n.content),title:g.copyMessage,type:"button",children:s.jsx(It,{"aria-hidden":"true"})}),s.jsx("button",{"aria-label":g.viewMarkdownSource,"aria-expanded":m,onClick:f,title:m?g.hideMarkdownSource:g.viewMarkdownSource,type:"button",children:s.jsx(qa,{"aria-hidden":"true"})})]})]})]}),n.role==="tool"?s.jsxs("button",{className:"tool-inline-summary","aria-expanded":S,onClick:d,type:"button",children:[s.jsxs("span",{children:[s.jsx(Po,{"aria-hidden":"true"}),n.toolName??g.tool]}),x?s.jsx("small",{children:x}):null]}):n.role==="assistant"?s.jsx(o.Suspense,{fallback:s.jsx("pre",{children:n.content}),children:s.jsx(Yc,{baseCwd:t,content:n.content,onOpenRemoteFile:c})}):s.jsx("pre",{children:n.content}),n.images?.length?s.jsxs("div",{className:"message-files",children:[n.images.map(C=>s.jsxs("button",{className:"file-pill",onClick:()=>c(C,t),title:C,type:"button",children:[s.jsx(Yn,{"aria-hidden":"true"}),vn(C)]},C)),s.jsxs("button",{className:"file-pill",onClick:()=>l(n.images??[]),type:"button",children:[s.jsx(Va,{"aria-hidden":"true"}),g.preview]})]}):null,m?s.jsx(Gc,{message:n,onClose:i,onCopy:r,t:g}):null,n.role==="tool"&&S?s.jsx(Cr,{messages:[n],onClose:a,onCopy:r,t:g}):null]})}function Xc({matchCount:e,query:t,onChange:n,onNext:r,t:i}){return s.jsxs("div",{className:"message-search-bar",children:[s.jsx(Xn,{"aria-hidden":"true"}),s.jsx("input",{value:t,onChange:a=>n(a.target.value),onKeyDown:a=>{a.key==="Enter"&&r()},placeholder:i.searchThisSession}),s.jsx("span",{children:t.trim()?i.messageSearchMatches(e):i.allMessages}),t?s.jsx("button",{"aria-label":i.clearMessageSearch,className:"icon-button mini-button",onClick:()=>n(""),type:"button",children:s.jsx(we,{"aria-hidden":"true"})}):null]})}function el({activeMatch:e,expanded:t,messages:n,onToggle:r}){const i=n.filter(c=>c.role==="tool").length||n.length,a=kr(n),l=i===1?"1 tool call":`${i} tool calls`;return s.jsxs("button",{className:`tool-group-bubble ${e?"match":""} ${t?"expanded":""}`,type:"button",onClick:r,"aria-expanded":t,"aria-label":a?`${l}: ${a}`:l,children:[s.jsxs("span",{className:"tool-group-header",children:[s.jsxs("span",{className:"tool-group-title",children:[s.jsx(ts,{"aria-hidden":"true"}),s.jsx("strong",{children:l})]}),s.jsx(Ma,{className:"tool-group-chevron","aria-hidden":"true"})]}),a?s.jsx("span",{className:"tool-group-summary",children:a}):null]})}const gn=160,tl=120;function dt(e){return Math.max(0,e-gn)}function nl(e,t){const n=t.length,[r,i]=o.useState(()=>({sessionId:e,start:dt(n),total:n})),a=o.useMemo(()=>r.sessionId!==e?dt(n):r.total===n||n<r.total?Math.min(r.start,dt(n)):r.start+gn>=r.total?dt(n):r.start,[e,r,n]);o.useLayoutEffect(()=>{r.sessionId===e&&r.start===a&&r.total===n||i({sessionId:e,start:a,total:n})},[e,a,r,n]);const l=o.useCallback(()=>{i(m=>({sessionId:e,start:Math.max(0,(m.sessionId===e?m.start:dt(n))-tl),total:n}))},[e,n]),c=o.useCallback(m=>{const S=t.findIndex(x=>Vc(x,m));if(S<0||S>=a&&S<a+gn)return!1;const g=Math.min(dt(n),Math.max(0,S-40));return i({sessionId:e,start:g,total:n}),!0},[t,e,a,n]),f=o.useCallback(()=>{i({sessionId:e,start:dt(n),total:n})},[e,n]),d=Math.min(n,a+gn);return{ensureMessageVisible:c,hiddenItemCount:a,hiddenLaterItemCount:Math.max(0,n-d),revealEarlier:l,revealLatest:f,visibleItems:t.slice(a,d)}}function sl({activeSession:e,activeUsage:t,messages:n,renameTitle:r,busy:i,t:a,onBrowseFiles:l,onClose:c,onExport:f,onJumpToMessage:d,onRename:m,onRenameTitleChange:S,onToggleArchived:g,onTogglePinned:x,onViewChanges:C}){const[b,u]=o.useState(""),w=o.useRef(null),h=wn(c,w),v=o.useMemo(()=>Sr(e),[e]),M=o.useMemo(()=>{const A=b.trim().toLowerCase();return A?n.map((k,U)=>({message:k,index:U})).filter(({message:k})=>k.role!=="user"&&k.role!=="assistant"?!1:k.content.toLowerCase().includes(A)).slice(0,20):[]},[n,b]),y=A=>{A.preventDefault(),m()};return s.jsxs("div",{"aria-labelledby":"session-detail-title","aria-modal":"true",className:"session-detail-drawer",ref:h,role:"dialog",tabIndex:-1,children:[s.jsx("div",{className:"drawer-backdrop",onClick:c,"aria-hidden":"true"}),s.jsxs("aside",{className:"session-detail-panel",children:[s.jsxs("header",{className:"drawer-header",children:[s.jsxs("div",{children:[s.jsx("span",{className:"eyebrow",children:e.agent}),s.jsx("strong",{id:"session-detail-title",title:ze(e),children:ze(e)})]}),s.jsx("button",{"aria-label":a.closeSessionDetails,className:"icon-button",onClick:c,ref:w,type:"button",children:s.jsx(we,{"aria-hidden":"true"})})]}),s.jsxs("form",{className:"detail-title-form",onSubmit:y,children:[s.jsx("input",{value:r,onChange:A=>S(A.target.value),placeholder:ze(e)}),s.jsx("button",{className:"primary-button",disabled:i,type:"submit",children:a.rename})]}),s.jsxs("div",{className:"detail-info-grid",children:[s.jsxs("div",{children:[s.jsx(Nt,{"aria-hidden":"true"}),s.jsx("span",{children:a.workingDirectory}),s.jsx("strong",{title:e.cwd,children:e.cwd})]}),s.jsxs("div",{children:[s.jsx(ur,{"aria-hidden":"true"}),s.jsx("span",{children:a.messages}),s.jsx("strong",{children:n.filter(A=>A.role==="user"||A.role==="assistant").length})]}),s.jsxs("div",{children:[s.jsx(so,{"aria-hidden":"true"}),s.jsx("span",{children:a.session}),s.jsx("strong",{title:e.sessionId,children:e.sessionId})]}),s.jsxs("div",{children:[s.jsx(ts,{"aria-hidden":"true"}),s.jsx("span",{children:a.runtime}),s.jsx("strong",{children:e.runtime.state})]})]}),e.branch||e.diffStat?s.jsxs("button",{className:"detail-command-card",type:"button",onClick:C,children:[s.jsx(lr,{"aria-hidden":"true"}),s.jsxs("span",{children:[e.branch??a.changes,e.diffStat?` · +${e.diffStat.additions} -${e.diffStat.deletions}`:""]})]}):null,s.jsxs("label",{className:"detail-search",children:[s.jsx(Xn,{"aria-hidden":"true"}),s.jsx("input",{value:b,onChange:A=>u(A.target.value),placeholder:a.searchMessages}),b.trim()?s.jsx("small",{children:a.searchResultCount(M.length)}):null]}),b.trim()&&M.length?s.jsx("div",{className:"detail-search-results",children:M.map(({message:A,index:k})=>s.jsxs("button",{type:"button",onClick:()=>{d(k,b),c()},children:[s.jsx("span",{children:A.role}),s.jsx("strong",{children:A.content})]},`${A.historyKey??A.timestamp??k}:${k}`))}):null,b.trim()?null:s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"detail-command-card",type:"button",onClick:l,children:[s.jsx(Nt,{"aria-hidden":"true"}),s.jsx("span",{children:a.browseFiles})]}),s.jsxs("button",{className:"detail-command-card",type:"button",onClick:()=>{navigator.clipboard?.writeText(v)},children:[s.jsx(La,{"aria-hidden":"true"}),s.jsx("span",{title:v,children:v})]}),s.jsxs("div",{className:"detail-action-grid",children:[s.jsxs("button",{className:"icon-text-button",disabled:i,type:"button",onClick:x,children:[s.jsx(xn,{"aria-hidden":"true"}),e.pinned?a.unpin:a.pin]}),s.jsxs("button",{className:"icon-text-button",disabled:i,type:"button",onClick:g,children:[s.jsx(Zn,{"aria-hidden":"true"}),e.archived?a.unarchive:a.archive]}),s.jsxs("button",{className:"icon-text-button",type:"button",onClick:f,children:[s.jsx(ma,{"aria-hidden":"true"}),a.exportSession]})]}),t?s.jsxs("p",{className:"detail-usage",children:[a.usage,": ",t.limits?.fiveHour?.usedPercent??"-","% 5h ·"," ",t.limits?.weekly?.usedPercent??"-","% weekly"]}):null,s.jsxs("p",{className:"detail-usage",children:[a.created," ",ns(e.createdAt)]})]})]})]})}function rl({activeSession:e,activeSessionId:t,activeModelOptions:n,activeQueue:r,activeUsage:i,agent:a,approvalMode:l,attachments:c,busy:f,cwd:d,draft:m,effort:S,errorText:g,failedSend:x,fastMode:C,historyLoading:b,messages:u,messagesSessionId:w,model:h,phase:v,quickReplies:M,renameTitle:y,respondingSessionIds:A,sendShortcut:k,skills:U,uploadBusy:fe,detailsOpen:Z,controlsOpen:he,pendingActionsCount:se,t:$,onApprovalModeChange:re,onBrowseFiles:ge,onCancelQueuedTurn:je,onClearInterrupt:_,onDraftChange:E,onDetailsOpenChange:B,onEffortChange:P,onExportActiveSession:ie,onFastModeChange:ye,onRetryFailedSend:We,onModelChange:Ae,onOpenRemoteFile:J,onOpenControls:X,onInterrupt:ke,onRetry:Me,onRefreshSessions:ae,onRefreshSkills:z,onRenameSession:V,onRenameTitleChange:G,onRemoveAttachment:oe,onRestoreSnapshot:le,onSendShortcutChange:be,onSubmit:xe,onToggleArchived:Re,onTogglePinned:K,onUploadFiles:me,onViewChanges:_e}){const[T,Q]=o.useState(""),[Ue,De]=o.useState(0),[Pe,Ce]=o.useState(null),[Ke,Fe]=o.useState(null),[Je,Te]=o.useState(!1),[st,Xe]=o.useState([]),Se=o.useRef(null),et=o.useRef([]),pe=o.useRef(null),I=o.useRef(null),te=o.useMemo(()=>Kc(u),[u]),{ensureMessageVisible:$e,hiddenItemCount:Le,hiddenLaterItemCount:rt,revealEarlier:Ve,revealLatest:ft,visibleItems:Ne}=nl(t,te),N=o.useMemo(()=>!!(x&&Ne.some(D=>D.type==="message"&&D.message.historyKey===x.historyKey)),[x,Ne]),O=o.useRef(null),{copyText:de,feedback:H}=Dc($.messageCopied,$.copyFailed),W=o.useMemo(()=>{const D=T.trim().toLowerCase();return D?u.map((Y,ee)=>({index:ee,message:Y})).filter(({message:Y})=>Y.content.toLowerCase().includes(D)):[]},[T,u]),He=D=>{const Y=$e(D),ee=()=>et.current[D]?.scrollIntoView({behavior:"smooth",block:"center"});Y?requestAnimationFrame(()=>requestAnimationFrame(ee)):ee()},yt=()=>{if(!W.length)return;const D=Ue%W.length,Y=W[D]?.index;typeof Y=="number"&&He(Y),De(ee=>(ee+1)%W.length)},ht=o.useCallback(()=>{const D=Se.current;D&&(D.scrollTop=D.scrollHeight,Te(!1))},[]),Rt=o.useCallback((D="smooth")=>{const Y=()=>{const ee=Se.current;ee&&(ee.scrollTo({top:ee.scrollHeight,behavior:D}),Te(!1))};rt>0?(ft(),requestAnimationFrame(()=>requestAnimationFrame(Y))):Y()},[rt,ft]),Cn=()=>{const D=Se.current;if(!D)return;const Y=D.scrollHeight-D.scrollTop-D.clientHeight;Te(Y>180)},Tt=()=>{I.current=null},Ge=o.useMemo(()=>{const D=u.at(-1);return D?`${u.length}:${D.historyKey??""}:${D.timestamp??""}:${D.content.length}`:"0"},[u]);o.useLayoutEffect(()=>{const D=O.current,Y=Se.current;if(D&&Y){Y.scrollTop=D.top+Y.scrollHeight-D.height,O.current=null;return}pe.current!==t&&(pe.current=t,I.current=t,Ce(null),Fe(null));const ee=Se.current;if(!ee)return;const Oe=w===t;if(t!==null&&I.current===t&&Oe&&(!b||u.length>0)){ht();let at=0,Ee=-1,mt=0;const xt=performance.now(),Be=()=>{if(I.current!==t)return;ht();const St=Se.current?.scrollHeight??0;mt=St===Ee?mt+1:0,Ee=St;const en=performance.now()-xt>=1400;if(!b&&mt>=4||!b&&en){I.current=null;return}en||(at=requestAnimationFrame(Be))};return at=requestAnimationFrame(Be),Te(!1),()=>cancelAnimationFrame(at)}ee.scrollHeight-ee.scrollTop-ee.clientHeight<240&&ht()},[t,b,Ge,u.length,w,v,ht]);const Et=W.length&&T.trim()?W[(Ue+W.length-1)%W.length]?.index:void 0,Yt=e?ze(e):$.newSession,Mt=e?.cwd??(d.trim().length>0&&d!=="."?d:""),Jt=e?.agent??a,Xt=Jt==="codex"?"Codex":"Claude";return s.jsxs("section",{className:"chat-pane","aria-label":$.chat,children:[s.jsxs("header",{className:"chat-header",children:[s.jsxs("button",{className:"chat-title-block chat-title-button",type:"button",onClick:()=>e&&B(!0),children:[s.jsx("span",{className:`agent-status-pill ${Jt}`,children:Xt}),s.jsx("h1",{title:Yt,children:Yt}),Mt?s.jsx("p",{title:Mt,children:Mt}):null,e?.branch||e?.diffStat?s.jsxs("div",{className:"header-metadata",children:[e.branch?s.jsx("span",{children:e.branch}):null,e.diffStat?s.jsxs("span",{children:["+",e.diffStat.additions," -",e.diffStat.deletions]}):null,e.runtime.state?s.jsx("span",{children:e.runtime.state}):null,e.terminal?.mode?s.jsx("span",{children:e.terminal.mode}):null]}):null]}),s.jsx(lc,{activeSession:e,busy:f,controlsOpen:he,pendingActionsCount:se,t:$,onOpenControls:X,onRefreshSessions:ae,onRestoreSnapshot:le,onToggleArchived:Re,onTogglePinned:K,onViewChanges:_e})]}),s.jsxs("div",{className:"chat-notices","aria-live":"polite",children:[g?s.jsx(Fc,{message:g,retryLabel:$.retry,onRetry:Me}):null,x&&!N?s.jsx($s,{failedSend:x,onRetry:()=>{We()},t:$}):null,e?.interruptReason?s.jsxs("div",{className:"notice warning",children:[s.jsx(zt,{"aria-hidden":"true"}),s.jsx("span",{children:e.interruptReason.humanText||e.interruptReason.kind}),s.jsx("button",{className:"icon-text-button",disabled:f,onClick:_,type:"button",children:$.clear})]}):null,e?.stallWarning?s.jsxs("div",{className:"notice warning",children:[s.jsx(ar,{"aria-hidden":"true"}),s.jsx("span",{children:e.stallWarning.humanText||$.agentMayBeStalled})]}):null]}),s.jsxs("div",{className:"message-scroll","aria-busy":b,"data-history-loading":b?"true":"false","data-rendered-items":Ne.length,"data-total-messages":u.length,ref:Se,onScroll:Cn,onPointerDown:Tt,onTouchStart:Tt,onWheel:Tt,children:[s.jsx(Xc,{matchCount:W.length,query:T,onChange:D=>{Q(D),De(0)},onNext:yt,t:$}),b&&u.length===0?s.jsx($c,{label:$.loadingHistory}):null,!b&&u.length===0?s.jsxs("div",{className:"empty-state compact",children:[s.jsx(Sn,{"aria-hidden":"true"}),s.jsx("h2",{children:e?$.noVisibleMessages:$.startDaemonSession}),s.jsx("p",{children:$.emptyChatHint})]}):null,Le>0?s.jsx("div",{className:"conversation-window-gate",children:s.jsx("button",{type:"button",onClick:()=>{const D=Se.current;D&&(O.current={height:D.scrollHeight,top:D.scrollTop}),Ve()},children:$.showEarlierMessages(Le)})}):null,Ne.map(D=>{if(D.type==="toolGroup"){const Ee=D.entries.map(Be=>Be.message),mt=D.entries.some(Be=>Et===Be.index),xt=Ke===D.id;return s.jsx("div",{className:"message-frame tool info",ref:Be=>{for(const St of D.entries)et.current[St.index]=Be},children:s.jsxs("div",{className:"inline-message-stack",children:[s.jsx(el,{activeMatch:mt,expanded:xt,messages:Ee,onToggle:()=>Fe(Be=>Be===D.id?null:D.id)}),xt?s.jsx(Cr,{messages:Ee,onClose:()=>Fe(null),onCopy:de,t:$}):null]})},D.id)}const{index:Y,message:ee}=D,Oe=jr(ee,Y),bt=Pe===Oe,it=Ke===Oe,at=x?.historyKey===ee.historyKey?x:null;return s.jsxs("div",{className:`message-frame ${ee.role} ${ee.type==="info"?"info":""}`,ref:Ee=>{et.current[Y]=Ee},children:[s.jsx(Jc,{activeMatch:Et===Y,baseCwd:e?.cwd,message:ee,onCopy:de,onCloseSource:()=>Ce(null),onCloseTool:()=>Fe(null),onOpenAttachment:Xe,onOpenRemoteFile:J,onToggleSource:()=>Ce(Ee=>Ee===Oe?null:Oe),onToggleTool:()=>Fe(Ee=>Ee===Oe?null:Oe),sourceOpen:bt,toolOpen:it,t:$}),at?s.jsx($s,{failedSend:at,onRetry:()=>{We()},t:$}):null]},Oe)}),rt>0?s.jsx("div",{className:"conversation-window-gate",children:s.jsx("button",{type:"button",onClick:()=>Rt("auto"),children:$.showLatestMessages(rt)})}):null,t&&A.has(t)?s.jsx(Lc,{busy:f,label:$.agentResponding,stopLabel:$.stopGenerating,onStop:ke}):null,s.jsx("div",{"aria-hidden":"true",className:"message-latest-anchor"}),Je?s.jsx(Oc,{label:$.newMessages,onClick:()=>Rt()}):null]}),s.jsx(Pc,{feedback:H}),s.jsx(Tc,{activeModelOptions:n,activeQueue:r,agent:a,approvalMode:l,attachments:c,busy:f,draft:m,effort:S,fastMode:C,model:h,phase:v,quickReplies:M,sendShortcut:k,skills:U,uploadBusy:fe,onApprovalModeChange:re,onCancelQueuedTurn:je,onDraftChange:E,onEffortChange:P,onFastModeChange:ye,onModelChange:Ae,onRemoveAttachment:oe,onRefreshSkills:z,onSendShortcutChange:be,onSubmit:xe,onUploadFiles:me,t:$}),Z&&e?s.jsx(sl,{activeSession:e,activeUsage:i,busy:f,messages:u,renameTitle:y,t:$,onBrowseFiles:()=>{B(!1),ge()},onClose:()=>B(!1),onExport:ie,onJumpToMessage:(D,Y)=>{Q(Y),De(0),He(D)},onRename:V,onRenameTitleChange:G,onToggleArchived:Re,onTogglePinned:K,onViewChanges:()=>_e(e.sessionId)}):null,s.jsx(Mc,{cwd:e?.cwd,paths:st,t:$,onClose:()=>Xe([]),onOpenRemoteFile:J})]})}const il="https://service.lifeos.vip/feedback",Nr=8e3,al=6e4,Bs=4,ol=20*1024*1024;function cl(e){try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}async function ll(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 dl(e,t={}){const n=new AbortController,r=Number.isFinite(t.timeoutMs)&&(t.timeoutMs??0)>0?t.timeoutMs:15e3;let i;try{const a=(t.transport??ll)({url:t.endpoint??il,method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:n.signal}),l=new Promise((d,m)=>{i=setTimeout(()=>{n.abort(),m(new Error("Feedback request timed out"))},r)}),c=await Promise.race([a,l]),f=cl(c.body);if(c.status<200||c.status>=300||f.code!==0)throw new Error(f.message||c.statusText||"Feedback request failed");if(typeof f.data?.id!="string"||!f.data.id||typeof f.data.createdAt!="string")throw new Error("Feedback response is invalid");return{id:f.data.id,createdAt:f.data.createdAt,issueFingerprint:typeof f.data?.issueFingerprint=="string"?f.data.issueFingerprint:void 0,issueOccurrence:typeof f.data?.issueOccurrence=="number"?f.data.issueOccurrence:void 0}}finally{i&&clearTimeout(i)}}const Ir=["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"],Ar=["authorization","proxy-authorization"],Rr=["cookie","set-cookie"],ul=[...Ar,...Rr],kn=(e,t)=>t.length-e.length,Tr=[...Ir].sort(kn).join("|"),fl=Ir.filter(e=>!ul.includes(e)).sort(kn).join("|"),hl=[...Ar].sort(kn).join("|"),ml=[...Rr].sort(kn).join("|"),pl=new RegExp(`(?:${Tr}|credential|private[-_ ]?key|session[-_ ]?id|e-?mail|phone|mobile|address)`,"i"),gl=new RegExp(`(["']?(?:${hl})["']?\\s*[:=]\\s*)("[^"\\r\\n]*"|'[^'\\r\\n]*'|(?:Basic|Bearer)\\s+[^\\s,;}]+|AWS4-HMAC-SHA256[^\\r\\n]*(?=\\r?$)|[^\\s,;}]+)`,"gim"),yl=new RegExp(`(["']?(?:${ml})["']?\\s*[:=]\\s*)("[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\r\\n]+)`,"gi"),bl=new RegExp(`(["']?(?:${fl})["']?\\s*[:=]\\s*)("[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s,;}&]+)`,"gi"),xl=new RegExp(`([?&](?:${Tr})=)[^&\\s]+`,"gi");function Sl(e,t="[REDACTED]"){const n=(r,i,a)=>{const l=a[0]==='"'||a[0]==="'"?a[0]:"";if(!l)return`${i}${t}`;const c=a.slice(1,-1).trim(),f=/^(Basic|Bearer)\b/i.exec(c)?.[1];return`${i}${l}${f?`${f} `:""}${t}${l}`};return e.replace(/-----BEGIN(?: [A-Z0-9]+)? PRIVATE KEY-----[\s\S]*?-----END(?: [A-Z0-9]+)? PRIVATE KEY-----/gi,t).replace(gl,n).replace(yl,n).replace(bl,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(xl,`$1${t}`)}function vl(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 Ct(e){return vl(Sl(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 wl(e,t={}){if(!e)return{};const n=Math.max(0,t.characterBudget??6e4),r=Math.max(0,t.maxArrayEntries??50),i=Math.max(0,t.maxDepth??8),a=Math.max(0,t.maxObjectEntries??80),l=Math.max(0,t.maxStringLength??4e3),c={remaining:n},f=new WeakSet,d=(m,S)=>{if(c.remaining<=0)return"[TRUNCATED]";if(m===null||typeof m=="boolean"||typeof m=="number")return m;if(typeof m=="bigint")return m.toString();if(typeof m=="string"){const C=Ct(m).slice(0,Math.min(l,c.remaining));return c.remaining-=C.length,C}if(S>=i)return"[MAX_DEPTH]";if(typeof m!="object")return Ct(String(m)).slice(0,Math.min(200,c.remaining));if(f.has(m))return"[Circular]";if(f.add(m),Array.isArray(m))return m.slice(0,r).map(x=>d(x,S+1));const g={};for(const[x,C]of Object.entries(m).slice(0,a)){if(c.remaining<=0)break;const b=Ct(x).slice(0,Math.min(120,c.remaining));c.remaining-=b.length,g[b]=pl.test(x)?"[REDACTED]":d(C,S+1)}return g};return d(e,0)}function kl(e,t=al){const n=Ct(e);return n.length<=t?n:`[truncated ${n.length-t} chars]
10
+ ${n.slice(-t)}`}function jl(e){return Ct(e.trim()).slice(0,Nr)}const Cl=["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"],Nl=new Set(Cl);function Il(e){const t={contextSchemaVersion:1};if(e)for(const[n,r]of Object.entries(e))Nl.has(n)&&r!==void 0&&(t[n]=r);return wl(t)}const Al={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"},Rl={title:"意见反馈",subtitle:"报告问题,或告诉我们希望改进的地方。",bug:"问题",feature:"建议",description:"详细说明",descriptionPlaceholder:"发生了什么,或者你希望我们怎样改进?",email:"邮箱(选填)",emailPlaceholder:"便于我们回复你",includeDiagnostics:"附带经过隐私处理的诊断信息",privacyNotice:"仅在需要时附带诊断信息;发送前会移除已识别的凭据、个人标识和本地路径。",submit:"发送反馈",sending:"正在发送…",success:"感谢反馈,已经发送成功。",error:"发送失败,请稍后重试。",close:"关闭"},Tl={title:"意見回饋",subtitle:"回報問題,或告訴我們希望改善的地方。",bug:"問題",feature:"建議",description:"詳細說明",descriptionPlaceholder:"發生了什麼,或你希望我們如何改善?",email:"電子郵件(選填)",emailPlaceholder:"方便我們回覆你",includeDiagnostics:"附上經過隱私處理的診斷資訊",privacyNotice:"僅在需要時附上診斷資訊;傳送前會移除已識別的憑證、個人識別資訊和本機路徑。",submit:"傳送回饋",sending:"正在傳送…",success:"感謝回饋,已成功傳送。",error:"傳送失敗,請稍後再試。",close:"關閉"};function Er(e){const t=e?.trim().toLowerCase().replace(/_/g,"-")??"";return/^zh(?:-(?:tw|hk|mo|hant))(?:-|$)/u.test(t)?Tl:t.startsWith("zh")?Rl:Al}const El=new Set(["image/jpeg","image/png","image/webp","image/gif"]);function Ml(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 _l(e){if(!e?.length)return;if(e.length>Bs)throw new Error(`Feedback supports at most ${Bs} images`);const t=e.map(r=>{if(!El.has(r.mimeType))throw new Error("Feedback image type is not supported");const i=Ml(r.base64);if(!Number.isSafeInteger(r.size)||r.size<=0||i!==r.size)throw new Error("Feedback image size does not match its data");return{name:Ct(r.name.trim()||"image").slice(0,255),mimeType:r.mimeType,size:r.size,base64:r.base64}});if(t.reduce((r,i)=>r+i.size,0)>ol)throw new Error("Feedback images are too large");return t}function Dl(e){const t=jl(e.description);if(!t)throw new Error("Feedback description is required");const n=e.includeLogs===!1||!e.logs?"":kl(e.logs),r=e.email?.trim().slice(0,320);return{product:e.product,source:e.source,type:e.type,description:t,email:r||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:Il(e.metadata),images:_l(e.images)}}function Pl({language:e,entry:t="web-settings"}){const n=Hn(e),r=o.useMemo(()=>Er(n),[n]),[i,a]=o.useState("bug"),[l,c]=o.useState(""),[f,d]=o.useState(""),[m,S]=o.useState("idle"),g=async()=>{if(!(!l.trim()||m==="sending")){S("sending");try{await dl(Dl({product:"vibelet",source:"web",type:i,description:l,email:f,appVersion:"web",locale:n,platform:navigator.platform||"web",metadata:{app:"vibelet-web",entry:t,screen:t==="connection-guide"?"connection-guide":"settings/language",module:"feedback",action:"manual-submit",userAgent:navigator.userAgent}})),c(""),S("success")}catch{S("error")}}};return s.jsxs("section",{className:"control-section compact-section",children:[s.jsx("h2",{children:r.title}),s.jsx("p",{className:"empty-copy",children:r.subtitle}),s.jsxs("div",{className:"feedback-type-grid",children:[s.jsx("button",{className:i==="bug"?"primary-button":"",type:"button","aria-pressed":i==="bug",onClick:()=>a("bug"),children:r.bug}),s.jsx("button",{className:i==="feature"?"primary-button":"",type:"button","aria-pressed":i==="feature",onClick:()=>a("feature"),children:r.feature})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:r.description}),s.jsx("textarea",{rows:5,maxLength:Nr,value:l,placeholder:r.descriptionPlaceholder,onChange:x=>c(x.target.value)})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:r.email}),s.jsx("input",{type:"email",maxLength:320,value:f,placeholder:r.emailPlaceholder,onChange:x=>d(x.target.value)})]}),s.jsx("button",{className:"primary-button",type:"button",disabled:!l.trim()||m==="sending",onClick:()=>{g()},children:m==="sending"?r.sending:r.submit}),m==="success"?s.jsx("p",{className:"empty-copy success-copy",children:r.success}):null,m==="error"?s.jsx("p",{className:"empty-copy error-copy",children:r.error}):null]})}const Bn="vibelet --access=quick";function Fl({errorText:e,t}){const[n,r]=o.useState("idle"),[i,a]=o.useState(!1),l=ir().language,c=Er(l),f=async()=>{try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(Bn);else{const d=document.createElement("textarea");d.value=Bn,d.style.position="fixed",d.style.opacity="0",document.body.append(d),d.select();const m=document.execCommand("copy");if(d.remove(),!m)throw new Error("copy failed")}r("success")}catch{r("error")}window.setTimeout(()=>r("idle"),1800)};return s.jsx("main",{className:"connection-guide",id:"vibelet-main-content",tabIndex:-1,children:s.jsxs("section",{className:"connection-guide-content","aria-labelledby":"connection-guide-title",children:[s.jsx("span",{className:"connection-guide-mark","aria-hidden":"true",children:s.jsx(es,{})}),s.jsx("span",{className:"connection-guide-eyebrow",children:"Vibelet Web"}),s.jsx("h1",{id:"connection-guide-title",children:t.openDaemonWebLink}),s.jsx("p",{children:t.openDaemonWebLinkHint}),s.jsxs("div",{className:"connection-command",children:[s.jsx("code",{children:Bn}),s.jsxs("button",{className:"primary-button",onClick:()=>{f()},type:"button",children:[n==="success"?s.jsx(nt,{"aria-hidden":"true"}):s.jsx(It,{"aria-hidden":"true"}),s.jsx("span",{children:n==="success"?t.commandCopied:n==="error"?t.copyFailed:t.copyStartCommand})]})]}),s.jsx("p",{className:"connection-guide-footnote",children:t.connectionGuideFootnote}),e?s.jsx("p",{className:"connection-guide-error",children:e}):null,s.jsxs("button",{className:"connection-feedback-toggle",type:"button","aria-expanded":i,onClick:()=>a(d=>!d),children:[s.jsx(ur,{"aria-hidden":"true"}),c.title]}),i?s.jsx("div",{className:"connection-feedback-panel",children:s.jsx(Pl,{language:l,entry:"connection-guide"})}):null]})})}const $l=o.lazy(async()=>Ye(()=>import("./FilesControlPanel-B5M5ueO9.js"),__vite__mapDeps([4,1,2,5])).then(e=>({default:e.FilesControlPanel}))),Ll=o.lazy(async()=>Ye(()=>import("./ArchiveSyncPanel-HfbSbAJT.js"),__vite__mapDeps([6,1,2])).then(e=>({default:e.ArchiveSyncPanel}))),Ol=o.lazy(async()=>Ye(()=>import("./ConnectionSettingsPanel-Y8Um-67e.js"),__vite__mapDeps([7,1,2])).then(e=>({default:e.ConnectionSettingsPanel}))),Bl=o.lazy(async()=>Ye(()=>import("./DaemonSettingsPanel--znFJEC6.js"),__vite__mapDeps([8,1,2])).then(e=>({default:e.DaemonSettingsPanel}))),ql=o.lazy(async()=>Ye(()=>import("./LanguageSettingsPanel-BLwzc7Dm.js"),__vite__mapDeps([9,1,2])).then(e=>({default:e.LanguageSettingsPanel}))),Hl=o.lazy(async()=>Ye(()=>import("./ThemeSettingsPanel-vB2Ox3sA.js"),__vite__mapDeps([10,1,2])).then(e=>({default:e.ThemeSettingsPanel}))),zl=o.lazy(async()=>Ye(()=>import("./NotificationSettingsPanel-IgZdwrhi.js"),__vite__mapDeps([11,1,2])).then(e=>({default:e.NotificationSettingsPanel}))),Wl=o.lazy(async()=>Ye(()=>import("./SavedTargetsPanel-DggmoRgT.js"),__vite__mapDeps([12,1,2])).then(e=>({default:e.SavedTargetsPanel}))),Ul=o.lazy(async()=>Ye(()=>import("./DiffDrawer-BI-wtkQ_.js"),__vite__mapDeps([13,1,2,5])).then(e=>({default:e.DiffDrawer})));function qs({t:e}){return s.jsxs("div",{className:"control-panel-loading","aria-live":"polite","aria-busy":"true",children:[s.jsx("span",{className:"loading-spinner","aria-hidden":"true"}),s.jsx("span",{children:e.loadingControls})]})}function Kl({client:e,id:t,sessions:n,t:r,close:i}){const a=n.find(l=>l.sessionId===t);return!a||!e?null:s.jsx(o.Suspense,{fallback:null,children:s.jsx(Ul,{client:e,sessionId:a.sessionId,sessionTitle:ze(a),t:r,onClose:i})})}function Vl({activeApproval:e,activeQuestion:t,busy:n,questionAnswers:r,t:i,onCancelQuestion:a,onQuestionChoice:l,onRespondApproval:c,onRespondQuestion:f}){const d=!!(e||t);return s.jsxs(s.Fragment,{children:[d?null:s.jsxs("section",{className:"control-section",children:[s.jsx("h2",{children:i.pendingActions}),s.jsx("p",{className:"empty-copy",children:i.noPendingActions})]}),e?s.jsxs("section",{className:"attention-panel",children:[s.jsxs("div",{className:"attention-head",children:[s.jsx(Sn,{"aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("h2",{children:i.approvalRequired}),s.jsx("p",{children:e.toolName})]})]}),s.jsx("p",{children:e.description}),s.jsx("pre",{children:xr(e.input)}),s.jsxs("div",{className:"attention-actions",children:[s.jsxs("button",{type:"button",className:"danger-button",onClick:()=>c(!1),disabled:n,children:[s.jsx(we,{"aria-hidden":"true"}),i.deny]}),s.jsxs("button",{type:"button",className:"approve-button",onClick:()=>c(!0),disabled:n,children:[s.jsx(nt,{"aria-hidden":"true"}),i.approve]})]})]}):null,t?s.jsxs("section",{className:"attention-panel",children:[s.jsxs("div",{className:"attention-head",children:[s.jsx(ao,{"aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("h2",{children:i.inputNeeded}),s.jsxs("p",{children:[t.questions.length," question",t.questions.length>1?"s":""]})]})]}),t.questions.map(m=>s.jsxs("div",{className:"question-block",children:[s.jsx("strong",{children:m.question}),s.jsx("div",{className:"choice-list",children:m.options.map(S=>{const g=(r[m.id]??[]).includes(S.label);return s.jsxs("button",{className:g?"selected":"",onClick:()=>l(m.id,S.label,m.multiSelect),type:"button",children:[s.jsx("span",{children:S.label}),S.description?s.jsx("small",{children:S.description}):null]},S.label)})})]},m.id)),s.jsxs("div",{className:"attention-actions",children:[s.jsxs("button",{type:"button",className:"danger-button",onClick:a,disabled:n,children:[s.jsx(we,{"aria-hidden":"true"}),i.cancel]}),s.jsxs("button",{type:"button",className:"approve-button",onClick:f,disabled:n,children:[s.jsx(nt,{"aria-hidden":"true"}),i.submit]})]})]}):null]})}const Gl="/web/assets/splash-logo-SQcOtj-8.png";var Ql=pa();function Zl({folder:e,initialValue:t,t:n,onClose:r,onSave:i}){const[a,l]=o.useState(t),c=o.useRef(null),f=wn(r,c),d=m=>{m.preventDefault(),i(a)};return Ql.createPortal(s.jsxs("div",{"aria-labelledby":"folder-tag-dialog-title","aria-modal":"true",className:"folder-tag-dialog-layer",ref:f,role:"dialog",tabIndex:-1,children:[s.jsx("div",{"aria-hidden":"true",className:"folder-tag-dialog-backdrop",onClick:r}),s.jsxs("form",{className:"folder-tag-dialog",onSubmit:d,children:[s.jsxs("header",{children:[s.jsx("span",{className:"folder-tag-dialog-icon","aria-hidden":"true",children:s.jsx(pr,{})}),s.jsxs("div",{children:[s.jsx("strong",{id:"folder-tag-dialog-title",children:n.editDirectoryTags}),s.jsx("span",{title:e,children:e})]}),s.jsx("button",{"aria-label":n.cancel,className:"mini-button",onClick:r,type:"button",children:s.jsx(we,{"aria-hidden":"true"})})]}),s.jsxs("label",{className:"folder-tag-dialog-field",children:[s.jsx("span",{children:n.directoryTags}),s.jsx("textarea",{"aria-describedby":"folder-tag-dialog-help",placeholder:n.directoryTagsPlaceholder,ref:c,rows:3,value:a,onChange:m=>l(m.target.value)})]}),s.jsx("p",{id:"folder-tag-dialog-help",children:n.directoryTagsDescription}),s.jsxs("footer",{children:[s.jsx("button",{className:"icon-text-button",onClick:r,type:"button",children:n.cancel}),s.jsx("button",{className:"primary-button",type:"submit",children:n.saveDirectoryTags})]})]})]}),document.body)}function Hs({session:e,active:t,responding:n,tagLabels:r,t:i,onSelect:a,onContextMenu:l,onViewChanges:c}){const f=!!e.diffStat&&(e.diffStat.additions>0||e.diffStat.deletions>0),d=ze(e);return s.jsxs("button",{className:`session-row ${t?"active":""} ${e.archived?"archived":""}`,onContextMenu:l,onClick:a,title:d,type:"button",children:[s.jsxs("span",{className:"session-row-head",children:[s.jsx("strong",{children:d}),n?s.jsx(Fa,{"aria-label":i.agentResponding}):null]}),s.jsx("span",{children:e.cwd}),s.jsx("span",{"aria-hidden":r?.length?void 0:"true",className:`directory-tag-row ${r?.length?"":"empty"}`,title:r?.length?i.directoryTags:void 0,children:r?.map(m=>s.jsx("em",{children:m},m))}),s.jsxs("span",{className:"session-row-footer",children:[s.jsxs("small",{children:[e.agent," · ",ns(e.lastActivityAt),e.branch?` · ${e.branch}`:"",e.diffStat&&!c?` · +${e.diffStat.additions}/-${e.diffStat.deletions}`:"",e.pinned?` · ${i.pinned}`:"",e.archived?` · ${i.archived}`:""]}),f&&c&&e.diffStat?s.jsxs("span",{className:"session-diff-badge",role:"button",tabIndex:0,title:i.viewChanges,onClick:m=>{m.stopPropagation(),c()},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.stopPropagation(),c())},children:[s.jsxs("span",{className:"diff-add",children:["+",e.diffStat.additions]}),s.jsxs("span",{className:"diff-del",children:["-",e.diffStat.deletions]})]}):null]})]})}function Yl({activeSessionId:e,busy:t,collapsedFolders:n,folderCounts:r,getFolderTags:i,groupFolders:a,groupedSessions:l,phase:c,respondingSessionIds:f,t:d,visibleSessions:m,onBrowseFolder:S,onEditFolderTags:g,onOpenCreateMenu:x,onOpenSessionMenu:C,onSelectSession:b,onToggleFolder:u,onViewChanges:w}){return a?s.jsxs(s.Fragment,{children:[l.map(h=>{const v=n[h.folder],M=h.kind==="attention"?d.needsAttentionSessionsGroup:h.kind==="running"?d.runningSessionsGroup:h.kind==="pinned"?d.pinnedSessionsGroup:h.folder;return s.jsxs("div",{className:`folder-group ${h.kind!=="folder"?"virtual-session-group":""}`,children:[s.jsxs("div",{className:"folder-header",children:[s.jsxs("button",{onClick:()=>u(h.folder),type:"button",children:[h.kind==="attention"?s.jsx(dr,{"aria-hidden":"true"}):h.kind==="running"?s.jsx(hn,{"aria-hidden":"true"}):h.kind==="pinned"?s.jsx(xn,{"aria-hidden":"true"}):s.jsx(cr,{"aria-hidden":"true"}),s.jsx("span",{children:M}),s.jsx("small",{children:h.kind==="folder"?r[h.folder]??h.sessions.length:h.sessions.length})]}),h.kind==="folder"?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"mini-button",disabled:c!=="connected",onClick:()=>S(h.folder),title:d.browseFolder,type:"button",children:s.jsx(Nt,{"aria-hidden":"true"})}),s.jsx("button",{"aria-label":i(h.folder).length?d.editDirectoryTags:d.addDirectoryTags,className:"mini-button",onClick:()=>g(h.folder),title:i(h.folder).length?d.editDirectoryTags:d.addDirectoryTags,type:"button",children:s.jsx(pr,{"aria-hidden":"true"})}),s.jsx("button",{className:"mini-button",disabled:t||c!=="connected",onClick:y=>x(y,h.folder),title:d.newSession,type:"button",children:s.jsx(Jn,{"aria-hidden":"true"})})]}):null]}),h.kind==="folder"&&i(h.folder).length?s.jsx("div",{className:"folder-tag-row",children:i(h.folder).map(y=>s.jsx("span",{children:y},y))}):null,v?null:h.sessions.map(y=>s.jsx(Hs,{active:y.sessionId===e,responding:f.has(y.sessionId),session:y,tagLabels:i(y.cwd),t:d,onContextMenu:A=>C(A,y),onSelect:()=>b(y.sessionId),onViewChanges:w?()=>w(y.sessionId):void 0},y.sessionId))]},h.folder)}),m.length===0?s.jsx("p",{className:"empty-copy",children:d.noSessionsMatch}):null]}):s.jsxs(s.Fragment,{children:[m.map(h=>s.jsx(Hs,{active:h.sessionId===e,responding:f.has(h.sessionId),session:h,tagLabels:i(h.cwd),t:d,onContextMenu:v=>C(v,h),onSelect:()=>b(h.sessionId),onViewChanges:w?()=>w(h.sessionId):void 0},h.sessionId)),m.length===0?s.jsx("p",{className:"empty-copy",children:d.noSessionsMatch}):null]})}function Jl({ariaLabel:e,options:t,value:n,disabled:r,onChange:i}){return s.jsx("div",{className:"chip-group",role:"radiogroup","aria-label":e,children:t.map(a=>s.jsx("button",{"aria-checked":n===a.value,className:n===a.value?"selected":"",disabled:r,onClick:()=>i(a.value),role:"radio",title:a.title??a.label,type:"button",children:a.label},a.value))})}function Xl({agentFilter:e,t,onAgentFilterChange:n}){return s.jsxs("div",{className:"session-filter-panel",children:[s.jsx("span",{className:"filter-section-label",children:t.agentFilterLabel}),s.jsx(Jl,{ariaLabel:t.agentFilterLabel,value:e,options:[{value:"all",label:t.agentFilterAll},{value:"claude",label:t.agentFilterClaude},{value:"codex",label:t.agentFilterCodex}],onChange:n})]})}function ed({groupFolders:e,hideArchived:t,separatePinnedGroup:n,showNeedsAttentionGroup:r,showRunningGroup:i,t:a,onToggleGroupFolders:l,onToggleHideArchived:c,onToggleNeedsAttentionGroup:f,onToggleRunningGroup:d,onToggleSeparatePinnedGroup:m}){const S=[[a.showNeedsAttentionGroup,r,f],[a.showRunningGroup,i,d],[a.separatePinnedGroup,n,m]];return s.jsxs("div",{className:"filter-section",children:[s.jsx("span",{className:"filter-section-label",children:a.filterViewOptions}),s.jsxs("div",{className:"filter-switch-card",children:[s.jsxs("button",{"aria-pressed":e,className:e?"selected":"",onClick:l,type:"button",children:[s.jsx("span",{children:a.groupByFolder}),s.jsx("span",{className:"filter-switch-track","aria-hidden":"true",children:s.jsx("span",{})})]}),S.map(([g,x,C])=>s.jsxs("button",{"aria-pressed":e&&x,className:`nested-filter-option ${e&&x?"selected":""}`,disabled:!e,onClick:C,type:"button",children:[s.jsx("span",{children:g}),s.jsx("span",{className:"filter-switch-track","aria-hidden":"true",children:s.jsx("span",{})})]},g)),s.jsxs("button",{"aria-pressed":t,className:t?"selected":"",onClick:c,type:"button",children:[s.jsx("span",{children:a.hideArchived}),s.jsx("span",{className:"filter-switch-track","aria-hidden":"true",children:s.jsx("span",{})})]})]})]})}function td(e,t){const n=o.useRef(null),r=o.useRef(null),i=o.useRef(t),[a,l]=o.useState(null),c=!!(e?.lastActivityAt&&e.sessionId),f=c?`${e?.lastActivityAt}:${e?.sessionId}`:null;return o.useEffect(()=>{i.current=t},[t]),o.useEffect(()=>{const d=n.current;if(!d||!e||!f){r.current=null,l(null);return}const m=d.closest(".session-list");if(!(m instanceof HTMLElement))return;let S=!0,g;l(null);const x=new IntersectionObserver(C=>{!C.some(b=>b.isIntersecting)||r.current===f||(r.current=f,l(f),i.current(e).catch(()=>{S&&(g=window.setTimeout(()=>{S&&(r.current=null,x.unobserve(d),x.observe(d))},1500))}).finally(()=>{S&&l(b=>b===f?null:b)}))},{root:m,rootMargin:"0px 0px 240px 0px",threshold:.01});return x.observe(d),()=>{S=!1,g!==void 0&&window.clearTimeout(g),x.disconnect()}},[f,e]),{canLoadMore:c,loading:a===f,sentinelRef:n}}function ut(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function nd({activeSessionId:e,busy:t,collapsedFolders:n,currentCwd:r,displayName:i,directoryTags:a,folderCounts:l,groupFolders:c,groupedSessions:f,hideArchived:d,separatePinnedGroup:m,showNeedsAttentionGroup:S,showRunningGroup:g,inventoryVersion:x,nextCursor:C,phase:b,pendingSessionIds:u,respondingSessionIds:w,search:h,sessionAgentFilter:v,sessionsCount:M,sinceFilter:y,statusText:A,t:k,visibleSessions:U,onLoadMore:fe,onCopyResumeCommand:Z,onCreateDirectory:he,onCreateSession:se,onDeleteSession:$,onListDirectories:re,onBrowseFolder:ge,onEditFolderTags:je,onOpenSessionDetails:_,onResetFilters:E,onSearchChange:B,onSearchCommit:P,onSelectSession:ie,onToggleSessionArchived:ye,onToggleSessionPinned:We,onSessionAgentFilterChange:Ae,onSinceFilterChange:J,onToggleFolder:X,onToggleGroupFolders:ke,onToggleHideArchived:Me,onToggleNeedsAttentionGroup:ae,onToggleRunningGroup:z,onToggleSeparatePinnedGroup:V,onToggleCollapse:G,onViewChanges:oe}){const[le,be]=o.useState(!1),[xe,Re]=o.useState(null),[K,me]=o.useState(null),_e=o.useRef(0),[T,Q]=o.useState(null),Ue=o.useRef(null),De=v!=="all"||y!=="30d"||c||c&&(S||g||m)||d,Pe=td(C,fe),Ce=K?!!u?.has(K.session.sessionId):!1,Ke=N=>a[ut(N)??"/"]??[],Fe=b==="connected"?`${U.length}/${M} sessions · v${x??"-"}`:k.sameOriginAccess,Je=`${A} · ${Fe}`;o.useEffect(()=>{if(!le&&!K&&!T)return;const N=de=>{const H=de.target;H instanceof Node&&Ue.current?.contains(H)||(be(!1),me(null),Q(null))},O=de=>{de.key==="Escape"&&(be(!1),me(null),Q(null))};return document.addEventListener("pointerdown",N),document.addEventListener("keydown",O),()=>{document.removeEventListener("pointerdown",N),document.removeEventListener("keydown",O)}},[K,T,le]);const Te=(N,O)=>{const de=N.currentTarget.getBoundingClientRect(),H=320,W=430,He=ut(O),yt=He??ut(r)??".";me(null),Q({...He?{folder:He}:{},cwd:yt,x:Math.max(10,Math.min(de.right-H,window.innerWidth-H-10)),y:Math.max(10,Math.min(de.bottom+8,window.innerHeight-W-10))})},st=(N,O)=>{N.preventDefault();const de=224,H=306;Q(null),me({session:O,x:Math.min(N.clientX,window.innerWidth-de-10),y:Math.min(N.clientY,window.innerHeight-H-10)})},Xe=()=>me(null),Se=N=>{be(!1),me(null),Q(null),Re({folder:N,value:Ke(N).join(", ")})},et=N=>{xe&&(je(xe.folder,N),Re(null))},pe=N=>{if(!K)return;const{session:O}=K;Xe(),N(O)},I=N=>{if(!T)return;const O=ut(T.cwd)??ut(T.folder)??ut(r)??".";Q(null),se(O,N)},te=N=>{const O=ut(N)??ut(r)??".",de=++_e.current;Q(H=>H&&{...H,browser:{path:O,entries:[],loading:!0,loaded:!1,createMode:!1,newFolderName:"",creating:!1}}),re(O).then(H=>{_e.current===de&&Q(W=>W?.browser?{...W,browser:{...W.browser,path:O,entries:H.filter(He=>He.isDirectory),loading:!1,loaded:!0,error:void 0}}:W)}).catch(H=>{_e.current===de&&Q(W=>W?.browser?{...W,browser:{...W.browser,path:O,entries:[],loading:!1,loaded:!0,error:H instanceof Error?H.message:String(H)}}:W)})},$e=()=>{T&&te(T.cwd||T.folder||r||".")},Le=()=>{Q(N=>N?.browser?{...N,cwd:N.browser.path,browser:void 0}:N)},rt=N=>{Q(O=>O?.browser?{...O,browser:{...O.browser,newFolderName:N,createError:void 0}}:O)},Ve=()=>{Q(N=>N?.browser?{...N,browser:{...N.browser,createMode:!0,newFolderName:"",createError:void 0}}:N)},ft=()=>{Q(N=>N?.browser?{...N,browser:{...N.browser,createMode:!1,newFolderName:"",createError:void 0,creating:!1}}:N)},Ne=()=>{const N=T?.browser,O=N?.newFolderName??"";if(!N||O.trim().length===0||N.creating)return;if(O.includes("/")||O.includes("\\")||O==="."||O===".."){Q(H=>H?.browser?{...H,browser:{...H.browser,createError:k.folderCreateFailed}}:H);return}const de=Un(N.path,O);Q(H=>H?.browser?{...H,browser:{...H.browser,creating:!0,createError:void 0}}:H),he(de).then(()=>{te(N.path)}).catch(H=>{Q(W=>W?.browser?{...W,browser:{...W.browser,creating:!1,createError:H instanceof Error?H.message:String(H)}}:W)})};return s.jsxs("aside",{className:"session-rail","aria-label":k.sessions,children:[s.jsxs("div",{className:"brand-block",title:Je,children:[s.jsx("div",{className:"brand-mark","aria-hidden":"true",children:s.jsx("img",{alt:"",className:"brand-logo",height:"40",src:Gl,width:"40"})}),s.jsxs("div",{className:"brand-copy",children:[s.jsx("strong",{children:"Vibelet Web"}),s.jsxs("span",{className:`brand-connection ${b}`,children:[s.jsx("i",{"aria-hidden":"true"}),b==="connected"&&i?k.connectedTo(i):A]})]}),G?s.jsx("button",{"aria-label":k.collapseSessionSidebar,className:"sidebar-panel-collapse-button session-rail-collapse-button",onClick:G,title:k.collapseSessionSidebar,type:"button",children:s.jsx(fr,{"aria-hidden":"true"})}):null]}),s.jsxs("div",{className:"rail-list-heading",children:[s.jsx("span",{children:k.sessions}),s.jsx("button",{"aria-label":k.newSession,className:"rail-create-button",disabled:t||b!=="connected",onClick:N=>Te(N),title:k.newSession,type:"button",children:s.jsx(Jn,{"aria-hidden":"true"})})]}),s.jsxs("div",{className:"search-filter-wrap",ref:Ue,children:[s.jsxs("div",{className:"search-box",children:[s.jsx(Xn,{"aria-hidden":"true"}),s.jsx("input",{value:h,onBlur:P,onChange:N=>B(N.target.value),onKeyDown:N=>{N.key==="Enter"&&P()},placeholder:k.searchSessions}),s.jsx("button",{"aria-expanded":le,"aria-label":k.sessionFilters,className:`filter-toggle ${le||De?"selected":""}`,onClick:()=>be(N=>!N),title:k.sessionFilters,type:"button",children:s.jsx(Xa,{"aria-hidden":"true"})})]}),le?s.jsxs("div",{className:"filter-popover",role:"dialog","aria-label":k.sessionFilters,children:[s.jsx(Xl,{agentFilter:v,t:k,onAgentFilterChange:Ae}),s.jsxs("div",{className:"filter-section",children:[s.jsx("span",{className:"filter-section-label",children:k.searchTimeRangeLabel}),s.jsx("div",{className:"rail-filters",role:"group","aria-label":k.searchTimeRangeLabel,children:["all","7d","30d","90d"].map(N=>s.jsx("button",{className:y===N?"selected":"",onClick:()=>J(N),type:"button",children:N==="all"?k.searchTimeRangeAllTime:N==="7d"?k.searchTimeRangeLast7Days:N==="30d"?k.searchTimeRangeLast30Days:k.searchTimeRangeLast90Days},N))})]}),s.jsx(ed,{groupFolders:c,hideArchived:d,separatePinnedGroup:m,showNeedsAttentionGroup:S,showRunningGroup:g,t:k,onToggleGroupFolders:ke,onToggleHideArchived:Me,onToggleNeedsAttentionGroup:ae,onToggleRunningGroup:z,onToggleSeparatePinnedGroup:V}),De?s.jsx("button",{className:"filter-reset-button",onClick:E,type:"button",children:k.resetFilters}):null]}):null]}),s.jsxs("div",{className:"session-list",children:[s.jsx(Yl,{activeSessionId:e,busy:t,collapsedFolders:n,folderCounts:l,getFolderTags:Ke,groupFolders:c,groupedSessions:f,phase:b,respondingSessionIds:w,t:k,visibleSessions:U,onBrowseFolder:ge,onEditFolderTags:Se,onOpenCreateMenu:Te,onOpenSessionMenu:st,onSelectSession:ie,onToggleFolder:X,onViewChanges:oe}),Pe.canLoadMore?s.jsx("div",{"aria-live":"polite",className:`session-load-sentinel ${Pe.loading?"loading":""}`,ref:Pe.sentinelRef,role:"status",children:Pe.loading?s.jsxs(s.Fragment,{children:[s.jsx(hn,{className:"spin","aria-hidden":"true"}),s.jsx("span",{children:k.loadingMore})]}):null}):null]}),xe?s.jsx(Zl,{folder:xe.folder,initialValue:xe.value,t:k,onClose:()=>Re(null),onSave:et}):null,T?s.jsxs("div",{className:"session-create-menu",role:"dialog","aria-label":k.newSession,style:{left:T.x,top:T.y},onPointerDown:N=>N.stopPropagation(),children:[s.jsxs("label",{className:"session-create-field",children:[s.jsx("span",{children:k.workingDirectory}),s.jsxs("div",{className:"session-create-input-row",children:[s.jsx("input",{"aria-label":k.workingDirectory,placeholder:k.workingDirectoryPlaceholder,value:T.cwd,onChange:N=>Q(O=>O&&{...O,cwd:N.target.value}),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),I("claude"))}}),s.jsx("button",{"aria-label":k.browseDirectories,className:"session-create-icon-button",onClick:$e,title:k.browseDirectories,type:"button",children:s.jsx(Nt,{"aria-hidden":"true"})})]})]}),T.browser?s.jsxs("div",{className:"session-create-browser",children:[s.jsxs("div",{className:"session-create-browser-bar",children:[s.jsx("span",{title:T.browser.path,children:T.browser.path}),s.jsx("button",{"aria-label":k.refreshSessions,className:"session-create-icon-button",onClick:()=>te(T.browser?.path??T.cwd),title:k.refreshSessions,type:"button",children:T.browser.loading?s.jsx(hn,{className:"spin","aria-hidden":"true"}):s.jsx(Gt,{"aria-hidden":"true"})})]}),T.browser.createMode?s.jsxs("div",{className:"session-create-new-folder",children:[s.jsx("input",{"aria-label":k.newFolder,disabled:T.browser.creating,placeholder:k.newFolderPlaceholder,value:T.browser.newFolderName,onChange:N=>rt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),Ne())}}),s.jsx("button",{"aria-label":k.cancel,className:"session-create-icon-button",disabled:T.browser.creating,onClick:ft,title:k.cancel,type:"button",children:s.jsx(we,{"aria-hidden":"true"})}),s.jsx("button",{"aria-label":k.create,className:"session-create-icon-button",disabled:T.browser.creating||!T.browser.newFolderName.trim(),onClick:Ne,title:k.create,type:"button",children:T.browser.creating?s.jsx(hn,{className:"spin","aria-hidden":"true"}):s.jsx(nt,{"aria-hidden":"true"})})]}):s.jsxs("button",{className:"session-create-secondary-button",onClick:Ve,type:"button",children:[s.jsx(Za,{"aria-hidden":"true"}),k.newFolder]}),T.browser.createError?s.jsx("p",{className:"session-create-error",children:T.browser.createError}):null,s.jsxs("div",{className:"session-create-folder-list",children:[Ms(T.browser.path)?s.jsxs("button",{className:"session-create-folder-row",onClick:()=>te(Ms(T.browser?.path??"")??T.cwd),type:"button",children:[s.jsx(Nt,{"aria-hidden":"true"}),".."]}):null,T.browser.loading?s.jsx("p",{className:"empty-copy",children:k.loadingDirectories}):null,!T.browser.loading&&T.browser.error?s.jsx("p",{className:"session-create-error",children:T.browser.error}):null,!T.browser.loading&&!T.browser.error&&T.browser.loaded&&T.browser.entries.length===0?s.jsx("p",{className:"empty-copy",children:k.remoteFolderEmpty}):null,!T.browser.loading&&!T.browser.error?T.browser.entries.map(N=>{const O=Un(T.browser?.path??T.cwd,N.name);return s.jsxs("button",{className:"session-create-folder-row",onClick:()=>te(O),type:"button",children:[s.jsx(cr,{"aria-hidden":"true"}),s.jsx("span",{children:N.name})]},`${N.name}:${O}`)}):null]}),s.jsxs("button",{className:"session-create-select-button",onClick:Le,type:"button",children:[s.jsx(nt,{"aria-hidden":"true"}),k.chooseThisFolder]})]}):null,s.jsxs("button",{type:"button",onClick:()=>I("claude"),children:[s.jsx(Ra,{"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:"Claude"}),s.jsx("small",{children:k.claudeSession})]})]}),s.jsxs("button",{type:"button",onClick:()=>I("codex"),children:[s.jsx(es,{"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:"Codex"}),s.jsx("small",{children:k.codexSession})]})]})]}):null,K?s.jsxs("div",{className:"session-context-menu",role:"menu",style:{left:K.x,top:K.y},onPointerDown:N=>N.stopPropagation(),children:[s.jsxs("button",{type:"button",role:"menuitem",onClick:()=>pe(N=>ie(N.sessionId)),children:[s.jsx(rr,{"aria-hidden":"true"}),k.open]}),s.jsxs("button",{type:"button",role:"menuitem",disabled:Ce,onClick:()=>pe(_),children:[s.jsx(dr,{"aria-hidden":"true"}),k.details]}),s.jsxs("button",{type:"button",role:"menuitem",disabled:Ce,onClick:()=>pe(Z),children:[s.jsx(It,{"aria-hidden":"true"}),k.copyResumeCommand]}),s.jsxs("button",{type:"button",role:"menuitem",disabled:Ce||!oe||!K.session.branch&&!K.session.diffStat,onClick:()=>pe(N=>oe?.(N.sessionId)),children:[s.jsx(or,{"aria-hidden":"true"}),k.viewChanges]}),s.jsx("span",{className:"context-menu-separator"}),s.jsxs("button",{type:"button",role:"menuitem",disabled:Ce,onClick:()=>pe(We),children:[s.jsx(xn,{"aria-hidden":"true"}),K.session.pinned?k.unpin:k.pin]}),s.jsxs("button",{type:"button",role:"menuitem",disabled:Ce,onClick:()=>pe(ye),children:[s.jsx(Zn,{"aria-hidden":"true"}),K.session.archived?k.unarchive:k.archive]}),s.jsxs("button",{className:"danger",type:"button",role:"menuitem",onClick:()=>pe($),children:[s.jsx(_o,{"aria-hidden":"true"}),k.delete]})]}):null]})}function sd({value:e,t,showSession:n=!0,onChange:r}){const i=[...n?[{tab:"session",label:t.session,Icon:mr}]:[],{tab:"files",label:t.files,Icon:Nt},{tab:"admin",label:t.settings,Icon:wo}];return s.jsx("div",{className:"control-tabs",children:i.map(({tab:a,label:l,Icon:c})=>s.jsxs("button",{"aria-label":l,"aria-pressed":e===a,className:e===a?"selected":"",onClick:()=>r(a),title:l,type:"button",children:[s.jsx(c,{"aria-hidden":"true"}),s.jsx("span",{children:l})]},a))})}function rd({children:e,t,value:n,showSession:r,onChange:i,onClose:a}){const l=o.useRef(null),c=wn(a,l);return s.jsxs("div",{"aria-label":t.controls,"aria-modal":"true",className:"workspace-control-drawer",ref:c,role:"dialog",tabIndex:-1,children:[s.jsx("button",{className:"workspace-control-backdrop",onClick:a,tabIndex:-1,type:"button"}),s.jsxs("aside",{className:"control-pane",children:[s.jsxs("div",{className:"control-pane-toolbar",children:[s.jsx(sd,{value:n,t,showSession:r,onChange:i}),s.jsx("button",{"aria-label":t.collapseControlsSidebar,className:"sidebar-panel-collapse-button",onClick:a,ref:l,title:t.collapseControlsSidebar,type:"button",children:s.jsx(hr,{"aria-hidden":"true"})})]}),e]})]})}function jt(e,t){o.useEffect(()=>{e.current=t},[e,t])}const Mr="pair",gt="vibelet.web.pairing",zs="vibelet.web.deviceId";class bn extends Error{constructor(t,n){super(n),this.code=t,this.name="PairingCreateError"}}function os(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function id(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return decodeURIComponent(Array.from(atob(n),r=>`%${r.charCodeAt(0).toString(16).padStart(2,"0")}`).join(""))}function ad(e){const[t,n,r,i,a,l]=e;return!n||!Number.isFinite(r)||r<=0?null:{kind:t==="relay"?"relay":"direct",host:n,port:Math.floor(r),source:i,stability:a,...l===!0?{secure:!0}:{}}}function od(e){if(!os(e))return null;const{kind:t,host:n,port:r,source:i,stability:a,secure:l}=e;return t!=="direct"&&t!=="relay"||typeof n!="string"||!n.trim()||typeof r!="number"||!Number.isFinite(r)||r<=0||typeof i!="string"||typeof a!="string"?null:{kind:t,host:n.trim(),port:Math.floor(r),source:i,stability:a,...l===!0?{secure:!0}:{}}}function cd(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[r,i]=n;return r===10||r===172&&i>=16&&i<=31||r===192&&i===168}function _r(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 r=n.map(Number);return r.every(i=>i>=0&&i<=255)&&r[0]===127}function ld(e){const t=e.trim();return t.includes(":")&&!t.startsWith("[")?`[${t}]`:t}function dd(e,t){return t.protocol==="https:"&&e.secure!==!0?null:`${e.secure===!0?"wss":"ws"}://${ld(e.host)}:${e.port}`}function Ws(e){return cd(e.host)?0:e.source==="local_network"?1:e.source==="configured_host"?2:3}function ud(e,t){const n=t?.port??e.port,r=t?.canonicalHost??e.canonicalHost;if(!r||typeof n!="number"||!Number.isFinite(n))return[];const i=Math.floor(n);return[{kind:"direct",host:r,port:i,source:"fallback",stability:"stable"},...[...t?.fallbackHosts??[],...e.fallbackHosts??[]].map(a=>({kind:"direct",host:a,port:i,source:"fallback",stability:"stable"}))]}function fd(e,t,n=window.location,r=!0){if(r&&_r(n.hostname))return;const i=[...t?.connections??[],...e.connections??[],...ud(e,t)].map(od).filter(a=>!!a).filter(a=>a.kind==="direct").sort((a,l)=>Ws(a)-Ws(l));for(const a of i){const l=dd(a,n);if(l)return l}}function hd(e){if(!e.d||!e.c)return null;const t=Array.isArray(e.o)?e.o.map(ad).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 md(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 pd(e=window.location.hash){const t=e.startsWith("#")?e.slice(1):e,n=new URLSearchParams(t).get(Mr);if(!n)return null;try{const r=JSON.parse(id(n));if(!os(r))return null;if(r.t==="vp")return hd(r);if(r.type==="vibelet-pair")return md(r)}catch{return null}return null}function gd(){if(!window.location.hash.includes(`${Mr}=`))return;const e=`${window.location.pathname}${window.location.search}`;window.history.replaceState(null,"",e)}function yd(e=window.localStorage){const t=e.getItem(zs);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(zs,n),n}function Us(e){const t=e.getItem(gt);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 cs(e){if(typeof window>"u")return null;try{return e===window.localStorage?window.sessionStorage:null}catch{return null}}function bd(e=window.localStorage,t=cs(e)){const n=Us(e);if(n)return n;const r=t?Us(t):null;return r?(e.setItem(gt,JSON.stringify(r)),t?.removeItem(gt),r):null}function Ks(e,t=window.localStorage,n=cs(t)){t.setItem(gt,JSON.stringify(e)),n?.removeItem(gt)}function Dr(e=window.localStorage,t=cs(e)){e.removeItem(gt),t?.removeItem(gt)}function xd(e,t=Date.now()){if(!e.expiresAt)return!1;const n=new Date(e.expiresAt).getTime();return Number.isFinite(n)&&n<t}async function Sd(e){const t=await e.text().catch(()=>"");try{const n=JSON.parse(t);if(os(n)&&n.error==="pair_window_expired")return new bn("pair_window_expired","Pairing link expired.")}catch{}return new bn("pairing_failed",t||"Pairing failed.")}async function vd(e,t=yd()){if(xd(e))throw new bn("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 Sd(n);const r=await n.json();return{daemonId:r.daemonId,displayName:r.displayName||e.displayName,deviceId:r.deviceId,pairToken:r.pairToken,pairedAt:new Date().toISOString(),webSocketUrl:fd(e,r,window.location,!0)}}function wd(e){return e.filter(t=>t.archived===!0).map(t=>t.sessionId)}function kd(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 jd(e,t,n){if(!e?.isConnected)return{ok:!1,error:"not_connected"};try{const r=await e.request({action:"sessions.archiveSync",id:e.makeId("archive_sync"),mode:t,...t==="pull"?{}:{archivedSessionIds:n??[]}});return{ok:!0,archivedSessionIds:Array.isArray(r.archivedSessionIds)?r.archivedSessionIds.filter(i=>typeof i=="string"&&i.length>0):[]}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}const Pr="vibelet.web.savedTargets",Fr=12;function Cd(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Nd(e){if(!Cd(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 $r(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const r of e){const i=Nd(r);if(!(!i||t.has(i.daemonId))&&(t.add(i.daemonId),n.push(i),n.length>=Fr))break}return n}function Id(e=window.localStorage){const t=e.getItem(Pr);if(!t)return[];try{return $r(JSON.parse(t))}catch{return[]}}function Lr(e,t=window.localStorage){t.setItem(Pr,JSON.stringify($r(e)))}function Ad(e,t,n=new Date().toISOString()){return[{...t,label:t.displayName||t.daemonId.slice(0,10),lastConnectedAt:n},...e.filter(i=>i.daemonId!==t.daemonId)].slice(0,Fr)}function Rd(e,t){return e.filter(n=>n.daemonId!==t)}const Vn={version:"",latestVersion:"",loading:!1,error:null};function Vs(e){const t=e.match(/^\d+/);return t?Number(t[0]):0}function Td(e,t){const n=e.split(/[+-]/,1)[0].split(".").map(Vs),r=t.split(/[+-]/,1)[0].split(".").map(Vs),i=Math.max(n.length,r.length);for(let a=0;a<i;a+=1){const l=n[a]??0,c=r[a]??0;if(l<c)return-1;if(l>c)return 1}return 0}function Ed(e,t){return Td(e,t)<0}function Md(e){const t=e.toLowerCase();if(t.includes("alpha"))return"alpha";if(t.includes("beta"))return"beta";if(e.trim())return"latest"}function _d(e,t,n){const r=e?.webSocketUrl?e.webSocketUrl:t.origin;try{const i=new URL(r);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 Dd(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 Pd(e){const t=o.useCallback((u,w)=>{e.updateSessionListPreferences(h=>({...h,archiveSyncedDaemonIds:w==="synced"?{...h.archiveSyncedDaemonIds,[u]:!0}:h.archiveSyncedDaemonIds,archiveSyncCardDismissedDaemonIds:{...h.archiveSyncCardDismissedDaemonIds,[u]:!0}}))},[e]),n=o.useCallback((u,w)=>{const h=u==="pull"?e.t.archiveSyncSuccessPull:u==="pushMerge"?e.t.archiveSyncSuccessMerge:e.t.archiveSyncSuccessPush;if(e.setArchiveSyncStatus(kd(w,h,{timeout:e.t.archiveSyncFailedTimeout,disconnected:e.t.archiveSyncFailedDisconnected,generic:e.t.archiveSyncFailedGeneric})),!w.ok)return;const v=new Set(w.archivedSessionIds);e.setSessions(M=>M.map(y=>({...y,archived:v.has(y.sessionId)}))),e.pairingRef.current?.daemonId&&t(e.pairingRef.current.daemonId,"synced"),e.requestSessions({force:!0})},[t,e]),r=o.useCallback(async u=>{if(e.archiveSyncBusy)return;e.setArchiveSyncBusy(u),e.setArchiveSyncStatus(null);const w=await jd(e.clientRef.current,u,wd(e.displaySessions));n(u,w),e.setArchiveSyncBusy(null)},[n,e]),i=o.useCallback(()=>{e.pairing?.daemonId&&(t(e.pairing.daemonId,"dismissed"),e.setArchiveSyncStatus({tone:"success",message:e.t.archiveSyncSkipped}))},[t,e]),a=o.useCallback(async u=>{const w=e.clientRef.current;if(w?.isConnected&&!(u==="update"&&!Ut("Update desktop connector?"))&&!(u==="restart"&&!Ut("Restart desktop connector?"))){e.setAdmin(h=>({...h,loading:!0,action:u,statusText:""})),e.setErrorText(null);try{if(u==="update"){const h=Md(e.daemonMetadata.version),v=await w.request({action:"daemon.update",id:w.makeId("daemon_update"),...h?{channel:h}:{}});e.setAdmin(M=>({...M,loading:!1,action:null,statusText:v.alreadyRunning?"Connector update already running":"Connector update started"}));return}await w.request({action:"daemon.restart",id:w.makeId("daemon_restart")}),e.setAdmin(h=>({...h,loading:!1,action:null,statusText:"Connector restart requested"})),e.refreshDaemonMetadata()}catch(h){e.setAdmin(v=>({...v,loading:!1,action:null})),e.setErrorText(h instanceof Error?h.message:String(h))}}},[e]),l=o.useCallback(async()=>{if(!e.activeSession)return;const u=tc(e.activeSession,e.messages);sc(ec(ze(e.activeSession),e.activeSession.sessionId),u),await navigator.clipboard?.writeText(u).catch(()=>{})},[e.activeSession,e.messages]),c=o.useCallback(async()=>{if(!("Notification"in window)){e.setNotificationPermission("unsupported"),e.setErrorText("Browser notifications are not supported.");return}const u=await Notification.requestPermission();e.notificationPermissionRef.current=u,e.setNotificationPermission(u),u==="granted"&&e.updateNotificationSettings({enabled:!0}),e.setStatusText(u==="granted"?"Browser notifications enabled":"Browser notifications not enabled")},[e]),f=o.useCallback(()=>{Ut("Forget this browser pairing?")&&(e.intentionalDisconnectRef.current=!0,e.connectionAttemptIdRef.current+=1,Dr(),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(Vn),e.setPhase("missing-pair"),e.setStatusText(e.t.missingPair))},[e]),d=o.useCallback(u=>{if(u&&e.notificationPermission==="default"){c();return}e.updateNotificationSettings({enabled:u})},[e,c]),m=o.useCallback(u=>{e.connectWithPairingRef.current(u,!0)},[e]),S=o.useCallback(u=>e.saveTargets(Rd(e.savedTargets,u)),[e]),g=o.useCallback(u=>{e.setActiveSessionId(u.sessionId),e.setRenameTitle(u.customTitle??u.title??""),e.setDetailsOpen(!0)},[e]),x=o.useCallback((u,w)=>{const h=ga(w);e.updateSessionListPreferences(v=>({...v,directoryTags:ya(v.directoryTags,u,h)}))},[e]),C=o.useCallback(u=>{e.setControlTab("files"),e.listDirectory(u,{updateRoute:!0})},[e]),b=o.useCallback(u=>{navigator.clipboard?.writeText(Sr(u)).catch(()=>{})},[]);return{runArchiveSync:r,skipArchiveSync:i,runAdminAction:a,exportActiveSession:l,clearPairing:f,setNotificationsEnabled:d,connectSavedTarget:m,forgetSavedTarget:S,openSessionDetails:g,editFolderTags:x,browseFolder:C,copyResumeCommand:b}}function Gs(e){return`${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Fd(e,t=window.location,n=!0){const i=`${t.protocol==="https:"?"wss:":"ws:"}//${t.host}`;return n&&_r(t.hostname)?i:e?.webSocketUrl?e.webSocketUrl:i}class $d{socket=null;pending=new Map;messageListeners=new Set;closeListeners=new Set;async connect(t){this.disconnect();const n=new WebSocket(Fd(t));this.socket=n;const r=new Promise((i,a)=>{n.onopen=()=>i(),n.onerror=()=>a(new Error("WebSocket connection failed."))});return n.onmessage=i=>this.handleSocketMessage(i.data),n.onclose=()=>{this.socket===n&&(this.socket=null),this.rejectPending(new Error("WebSocket disconnected.")),this.closeListeners.forEach(i=>i())},await r,await this.request({action:"auth.hello",id:Gs("auth"),pairToken:t.pairToken,daemonId:t.daemonId,deviceId:t.deviceId,locale:navigator.language})}request(t,n={}){return!this.socket||this.socket.readyState!==WebSocket.OPEN?Promise.reject(new Error("WebSocket is not connected.")):new Promise((r,i)=>{const a={resolve:r,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)}disconnect(){this.rejectPending(new Error("WebSocket disconnected.")),this.socket?.close(1e3,"client disconnect"),this.socket=null}get isConnected(){return this.socket?.readyState===WebSocket.OPEN}makeId(t){return Gs(t)}handleSocketMessage(t){if(typeof t!="string")return;let n;try{n=JSON.parse(t)}catch{return}if(n.type!=="pong"){if(n.type==="response"){const r=this.pending.get(n.id);if(r){this.pending.delete(n.id),r.timeoutId&&clearTimeout(r.timeoutId),n.ok?r.resolve(n.data):r.reject(new Error(n.error||"Request failed."));return}}this.messageListeners.forEach(r=>r(n))}}rejectPending(t){for(const n of this.pending.values())n.timeoutId&&clearTimeout(n.timeoutId),n.reject(t);this.pending.clear()}}const Or="vibelet.web.sessionListCache",Br=120;function Ld(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Od(e){if(!Ld(e)||typeof e.daemonId!="string"||!e.daemonId)return null;const t=br(e.page);return{daemonId:e.daemonId,page:{...t,sessions:t.sessions.slice(0,Br)},cachedAt:typeof e.cachedAt=="string"?e.cachedAt:new Date(0).toISOString()}}function Bd(e,t=window.localStorage){if(!e)return null;try{const n=t.getItem(Or);if(!n)return null;const r=Od(JSON.parse(n));return r?.daemonId===e?r.page:null}catch{return null}}function qd(e,t,n=window.localStorage,r=new Date().toISOString()){if(!e)return;const i={daemonId:e,page:{...t,sessions:t.sessions.slice(0,Br)},cachedAt:r};n.setItem(Or,JSON.stringify(i))}function Hd(e){return e instanceof Error&&e.message==="auth_failed"}function zd(e,t){return e instanceof bn&&e.code==="pair_window_expired"?t.pairingLinkExpired:e instanceof Error?e.message:String(e)}function Wd(e){const t=o.useRef(null),n=o.useRef(e);n.current=e;const r=o.useCallback(a=>{const l=n.current,c=a??l.pairingRef.current;!c||l.intentionalDisconnectRef.current||(l.reconnectTimerRef.current&&window.clearTimeout(l.reconnectTimerRef.current),l.reconnectTimerRef.current=window.setTimeout(()=>{l.reconnectTimerRef.current=null,l.connectWithPairingRef.current(c,!0)},Wo))},[]),i=o.useCallback(async(a,l=!1)=>{const c=n.current;c.reconnectTimerRef.current&&(window.clearTimeout(c.reconnectTimerRef.current),c.reconnectTimerRef.current=null),c.intentionalDisconnectRef.current=!1,c.setPhase("connecting"),c.setStatusText(l?c.t.reconnectingToDaemon:c.t.connectingToDaemon),c.setErrorText(null);const f=new $d,d=c.connectionAttemptIdRef.current+1;c.connectionAttemptIdRef.current=d;const m=c.clientRef.current;c.clientRef.current=f,m?.disconnect();const S=()=>c.connectionAttemptIdRef.current===d&&c.clientRef.current===f;f.onMessage(c.handleServerMessage),f.onClose(()=>{c.clientRef.current===f&&(c.clientRef.current=null,!c.intentionalDisconnectRef.current&&(c.setPhase("connecting"),c.setStatusText(c.t.reconnectingToDaemon),c.setErrorText(c.t.webSocketClosedRetrying),r(c.pairingRef.current??a)))});try{let g=a,x;try{x=await f.connect(a)}catch(u){if(!a.webSocketUrl)throw u;g={...a,webSocketUrl:void 0},c.setStatusText(c.t.reconnectingToDaemon),x=await f.connect(g)}if(!S())return;const C={...g,displayName:x.displayName??g.displayName};c.historyCacheDaemonIdRef.current&&c.historyCacheDaemonIdRef.current!==C.daemonId&&(c.historyCacheRef.current={},c.messagesSessionIdRef.current=null,c.lastHistorySessionIdRef.current=null,c.setMessages([])),c.historyCacheDaemonIdRef.current=C.daemonId,c.setPairing(C),c.pairingRef.current=C,Ks(C);const b=Bd(C.daemonId);b&&c.setSessionsFromPage(b,!1),c.setSavedTargets(u=>{const w=Ad(u,C);return Lr(w),w}),c.setPhase("connected"),c.setStatusText(c.t.connectedTo(x.displayName??a.displayName??"Vibelet Daemon")),c.refreshDaemonMetadata(C),await c.requestReconnectSnapshot(),await c.fetchAgentResources(c.agent,c.cwd),c.reportLog("web.connected",{reconnecting:l})}catch(g){if(!S())return;Hd(g)&&Dr(),c.setPhase("error"),c.setStatusText(c.t.connectionFailed),c.setErrorText(g instanceof Error?g.message:String(g)),r(a)}},[r]);o.useEffect(()=>{const a=n.current;a.connectWithPairingRef.current=i},[i]),o.useEffect(()=>{const a=n.current;let l=!1;async function c(){const f=pd(),m=bd()??a.rememberedTarget;if(!f&&!m){a.setPhase("missing-pair"),a.setStatusText(a.t.missingPair);return}try{a.setPhase("pairing"),f&&t.current?.pairNonce!==f.pairNonce&&(t.current={pairNonce:f.pairNonce,promise:vd(f)});const S=f?await t.current?.promise:m;if(!S||l)return;f&&(Ks(S),t.current=null,gd()),await a.connectWithPairingRef.current(S)}catch(S){if(l)return;f&&(t.current=null),a.setPhase("error"),a.setStatusText(a.t.pairingFailed),a.setErrorText(zd(S,a.t))}}return c(),()=>{l=!0,a.intentionalDisconnectRef.current=!0,a.connectionAttemptIdRef.current+=1,a.reconnectTimerRef.current&&window.clearTimeout(a.reconnectTimerRef.current),a.clientRef.current?.disconnect()}},[e.t]),o.useEffect(()=>{const a=n.current;if(a.phase!=="connected")return;const l=window.setTimeout(()=>{a.requestSessions({force:!0}).catch(c=>a.setErrorText(c instanceof Error?c.message:String(c)))},260);return()=>window.clearTimeout(l)},[e.phase,e.requestSessions,e.search,e.sinceFilter]),o.useEffect(()=>{const a=n.current;a.phase==="connected"&&a.fetchAgentResources(a.agent,a.cwd)},[e.agent,e.cwd,e.fetchAgentResources,e.phase])}function qn(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function Ud(e=window.location.search){const t=new URLSearchParams(e),n=qn(t.get("folder")),r=qn(t.get("file")),i=qn(t.get("cwd"));return{...n?{folder:n}:{},...r?{file:r}:{},...i?{cwd:i}:{}}}function Kd(e,t,n=[]){const r=new URLSearchParams(e);for(const a of n)r.delete(a);for(const[a,l]of Object.entries(t))l?r.set(a,l):r.delete(a);const i=r.toString();return i?`?${i}`:""}function Qs(e,t={}){const n=t.history??window.history,r=t.location??window.location,i=[];e.folder&&i.push("file","cwd"),e.file&&i.push("folder");const a=Kd(r.search,e,i),l=`${r.pathname}${a}${r.hash}`;if(t.replace){n.replaceState(null,"",l);return}n.pushState(null,"",l)}function Vd(e){const{clientRef:t,pairing:n,cwd:r,phase:i,controlTab:a,setControlTab:l,setBusy:c,setErrorText:f,t:d}=e,m=o.useRef(!1),[S,g]=o.useState([]),[x,C]=o.useState(!1),[b,u]=o.useState({path:qe,entries:[],loading:!1,loaded:!1}),[w,h]=o.useState(""),[v,M]=o.useState(null),[y,A]=o.useState(!1),[k,U]=o.useState("edit"),fe=o.useCallback(async _=>{if(!(!_?.length||!n)){C(!0),f(null);try{const E=[];for(const B of Array.from(_)){const P=await fetch(`/upload?name=${encodeURIComponent(B.name)}`,{method:"POST",headers:{authorization:`Bearer ${n.pairToken}`,"content-type":B.type||"application/octet-stream"},body:B});if(!P.ok)throw new Error(await P.text().catch(()=>d.uploadFailed)||d.uploadFailed);const ie=Go(await P.json());if(!ie)throw new Error(d.uploadPathMissing);E.push({path:ie,name:B.name,type:B.type||"application/octet-stream",size:B.size})}g(B=>[...B,...E])}catch(E){f(E instanceof Error?E.message:String(E))}finally{C(!1)}}},[n,f,d.uploadFailed,d.uploadPathMissing]),Z=o.useCallback(async(_,E,B)=>{if(n){f(null);try{v?.objectUrl&&URL.revokeObjectURL(v.objectUrl);const P=await fetch(Ln(_,E),{headers:{authorization:`Bearer ${n.pairToken}`}});if(!P.ok)throw new Error(await P.text().catch(()=>d.fileOpenFailed)||d.fileOpenFailed);const ie=P.headers.get("content-type")??"application/octet-stream";if(Jo(_,ie))M({path:_,cwd:E,kind:"text",contentType:ie,text:await P.text(),etag:un(P.headers,"etag"),lastModified:un(P.headers,"last-modified"),size:Number(P.headers.get("content-length"))||void 0,dirty:!1});else{const ye=await P.blob();M({path:_,cwd:E,kind:Xo(_,ie)?"image":"binary",contentType:ie,text:"",objectUrl:URL.createObjectURL(ye),etag:un(P.headers,"etag"),lastModified:un(P.headers,"last-modified"),size:ye.size,dirty:!1})}A(!1),U("edit"),l("files"),B?.updateRoute&&Qs({file:_,...E?{cwd:E}:{}},{replace:B.replaceRoute})}catch(P){f(P instanceof Error?P.message:String(P))}}},[n,v?.objectUrl,l,f]),he=o.useCallback(async _=>{if(!(!n||!v||v.kind!=="text")){c(!0),f(null);try{const E=await fetch(Ln(v.path,v.cwd),{method:"PUT",headers:{authorization:`Bearer ${n.pairToken}`,"content-type":"text/markdown; charset=utf-8",...v.etag&&!_?.force?{"if-match":v.etag}:{}},body:v.text});if(!E.ok)throw E.status===409?(A(!0),new Error(d.remoteFileConflict(v.path))):new Error(await E.text().catch(()=>d.fileSaveFailed)||d.fileSaveFailed);A(!1);const B=await E.json().catch(()=>({}));M(P=>P&&{...P,dirty:!1,etag:typeof B.etag=="string"?B.etag:P.etag,lastModified:typeof B.lastModified=="string"?B.lastModified:P.lastModified,size:typeof B.size=="number"?B.size:P.size})}catch(E){f(E instanceof Error?E.message:String(E))}finally{c(!1)}}},[n,v,c,f]),se=o.useCallback(async()=>{if(!(!n||!v))try{const _=await fetch(Ln(v.path,v.cwd),{headers:{authorization:`Bearer ${n.pairToken}`}});if(!_.ok)throw new Error(d.downloadFailed);const E=URL.createObjectURL(await _.blob()),B=document.createElement("a");B.href=E,B.download=vn(v.path),B.click(),URL.revokeObjectURL(E)}catch(_){f(_ instanceof Error?_.message:String(_))}},[n,v,f]),$=o.useCallback(async(_=b.path,E)=>{const B=t.current;if(B?.isConnected){u(P=>({...P,path:_,loading:!0,loaded:!1,error:void 0}));try{const P=await B.request({action:"dirs.list",id:B.makeId("dirs"),path:_,cwd:r||void 0});u({path:_,entries:P.entries??[],loading:!1,loaded:!0}),E?.updateRoute&&Qs({folder:_},{replace:E.replaceRoute})}catch(P){u(ie=>({...ie,loading:!1,loaded:!0,error:P instanceof Error?P.message:String(P)}))}}},[t,r,b.path]),re=o.useCallback(async _=>{const E=t.current;if(!E?.isConnected)throw new Error(d.webSocketNotConnected);return((await E.request({action:"dirs.list",id:E.makeId("dirs"),path:_,cwd:r||void 0},{timeoutMs:1e4,timeoutMessage:d.directoryListTimedOut})).entries??[]).filter(P=>P.isDirectory)},[t,r]);o.useEffect(()=>{a!=="files"||i!=="connected"||b.loading||b.loaded||$(b.path||r||qe)},[a,r,b.loaded,b.loading,b.path,$,i]),o.useEffect(()=>{if(i!=="connected"||m.current)return;const _=Ud();if(!_.folder&&!_.file){m.current=!0;return}if(m.current=!0,l("files"),_.folder){$(_.folder,{updateRoute:!1});return}_.file&&(_.cwd&&u(E=>({...E,path:_.cwd,loaded:!1})),Z(_.file,_.cwd,{updateRoute:!1}))},[$,Z,i,l]);const ge=o.useCallback(async()=>{const _=t.current;if(!(!_?.isConnected||w.trim().length===0)){c(!0),f(null);try{await _.request({action:"dirs.create",id:_.makeId("mkdir"),path:Un(b.path,w),cwd:r||void 0}),h(""),await $(b.path)}catch(E){f(E instanceof Error?E.message:String(E))}finally{c(!1)}}},[t,r,b.path,$,w,c,f]),je=o.useCallback(async _=>{const E=t.current;if(!E?.isConnected)throw new Error(d.webSocketNotConnected);await E.request({action:"dirs.create",id:E.makeId("mkdir"),path:_,cwd:r||void 0},{timeoutMs:1e4,timeoutMessage:d.directoryCreationTimedOut})},[t,r]);return{attachments:S,setAttachments:g,uploadBusy:x,directory:b,setDirectory:u,newDirName:w,setNewDirName:h,remoteFile:v,setRemoteFile:M,remoteFileConflict:y,remoteFileMode:k,setRemoteFileMode:U,uploadFiles:fe,openRemoteFile:Z,saveRemoteFile:he,downloadRemoteFile:se,listDirectory:$,listSessionDirectories:re,createDirectory:ge,createSessionDirectory:je}}function Gd({clientRef:e,setSessions:t}){return o.useCallback(async n=>{const r=e.current;if(!r?.isConnected)return;const i=[...new Set(n.map(a=>a.cwd).filter(Boolean))];if(i.length!==0)try{const a=await r.request({action:"sessions.gitMetadata",id:r.makeId("git"),cwds:i});t(l=>l.map(c=>({...c,branch:a.branches[c.cwd]??c.branch,diffStat:a.diffStats[c.cwd]??c.diffStat})))}catch{}},[])}function jn(e,t){return!!t&&Object.hasOwn(e,t)}function Qd(e,t){const n=e.map(r=>({...r}));return t?ss(n,t):n}function Zd(e,t,n){return t?{...e,[t]:n.map(r=>({...r}))}:e}function qr(e,t,n){return!t||n.length===0?e:{...e,[t]:[...e[t]??[],...n.map(r=>({...r}))]}}function Yd(e,t,n){return n.historyKey&&e[t]?.some(r=>r.historyKey===n.historyKey)?e:qr(e,t,[n])}function Jd(e,t,n){return!t||!n?e:{...e,[t]:ss(e[t]??[],n)}}function Xd(e,t,n){if(!t||!n||t===n||!jn(e,t))return e;const r={...e};return r[n]=e[t],delete r[t],r}function eu(e,t){if(!jn(e,t))return e;const n={...e};return delete n[t],n}const Gn=15e3,Zs=500,Ys=1e3;function tu(e){const t=o.useRef({}),n=o.useRef(null),r=o.useRef({}),i=o.useRef(null),[a,l]=o.useState(!1),[c,f]=o.useState([]),d=o.useCallback(y=>y&&n.current&&n.current!==y?!1:(n.current=null,l(!1),!0),[]),m=o.useCallback(y=>jn(t.current,y)?(i.current=y,f(t.current[y]??[]),!0):!1,[]),S=o.useCallback((y,A,k)=>{t.current=Zd(t.current,y,A);const U=t.current[y]??[];return k?.renderActive!==!1&&y===e.activeSessionIdRef.current&&(i.current=y,f(U)),U},[e.activeSessionIdRef]),g=o.useCallback((y,A,k)=>{if(!k)return r.current[y]=void 0,S(y,A);const U=r.current[y];return r.current[y]=k.start,U===void 0||k.start>=U?S(y,A):S(y,[...A,...t.current[y]??[]])},[S]),x=o.useCallback((y,A)=>{const k=S(y,A,{renderActive:!1});i.current=y,f(k)},[S]),C=o.useCallback((y,A)=>{t.current=qr(t.current,y,A),y===e.activeSessionIdRef.current&&(i.current=y,f(t.current[y]??[]))},[e.activeSessionIdRef]),b=o.useCallback((y,A)=>{t.current=Yd(t.current,y,A),y===e.activeSessionIdRef.current&&(i.current=y,f(t.current[y]??[]))},[e.activeSessionIdRef]),u=o.useCallback((y,A)=>{t.current=Jd(t.current,y,A),y===e.activeSessionIdRef.current&&(i.current=y,f(t.current[y]??[]))},[e.activeSessionIdRef]),w=o.useCallback((y,A)=>{C(y,[{role:"assistant",type:"info",content:A,timestamp:new Date().toISOString()}])},[C]),h=o.useCallback(y=>{t.current=eu(t.current,y),delete r.current[y]},[]),v=o.useCallback((y,A)=>{t.current=Xd(t.current,y,A),r.current[A]=r.current[y],delete r.current[y]},[]),M=o.useCallback(async y=>{const A=e.clientRef.current;if(A?.isConnected){if(m(y.sessionId)){d(y.sessionId);return}n.current=y.sessionId,delete r.current[y.sessionId],l(!0),e.setErrorText(null);try{await A.request({action:"session.history",id:A.makeId("history"),sessionId:y.sessionId,agent:y.agent,limit:Zs},{timeoutMessage:e.historyTimeoutMessage,timeoutMs:Gn});let k=r.current[y.sessionId];for(;typeof k=="number"&&k>0&&(t.current[y.sessionId]?.length??0)<Ys;){const U=t.current[y.sessionId]?.length??0;await A.request({action:"session.history",id:A.makeId("history_older"),sessionId:y.sessionId,agent:y.agent,before:k,limit:Math.min(Zs,Ys-U)},{timeoutMessage:e.historyTimeoutMessage,timeoutMs:Gn});const fe=r.current[y.sessionId];if(typeof fe!="number"||fe>=k)break;k=fe}}catch(k){n.current===y.sessionId&&e.setErrorText(k instanceof Error?k.message:String(k))}finally{d(y.sessionId)}}},[d,e.clientRef,e.historyTimeoutMessage,e.setErrorText,m]);return{appendCachedDelta:u,appendCachedHistory:C,appendInfoMessage:w,clearHistoryLoading:d,ensureCachedHistoryEntry:b,historyCacheRef:t,historyLoading:a,hydrateVisibleHistory:x,messages:c,messagesSessionIdRef:i,mergeCachedHistoryPage:g,remapCachedHistory:v,removeCachedHistory:h,renderCachedHistory:m,replaceCachedHistory:S,requestHistory:M,setMessages:f}}function Js(e,t,n){return Math.min(Math.max(Math.round(e),t),n)}function nu(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 At=.9,su=Math.round(280*At),ru=Math.round(560*At),iu=Math.round(260*At),au=Math.round(520*At),ou=Math.round(320*At),cu=Math.round(330*At);function lu(e,t){const[n,r]=o.useState(e),[i,a]=o.useState(""),[l,c]=o.useState(e.sessionList.searchHistory),[f,d]=o.useState(e.sessionList.sinceFilter),[m,S]=o.useState(e.sessionList.hideArchived),[g,x]=o.useState(e.sessionList.groupFolders),[C,b]=o.useState(e.sessionList.showNeedsAttentionGroup),[u,w]=o.useState(e.sessionList.showRunningGroup),[h,v]=o.useState(e.sessionList.separatePinnedGroup),[M,y]=o.useState(e.sessionList.collapsedFolders),[A,k]=o.useState(e.sessionList.agentFilter),[U,fe]=o.useState(t),[Z,he]=o.useState(e.layout.leftSidebarCollapsed),[se,$]=o.useState(e.layout.rightSidebarCollapsed),[re,ge]=o.useState(ou),[je,_]=o.useState(cu),E=n.sessionList.directoryTags,B=n.sessionList.archiveSyncedDaemonIds,P=n.sessionList.archiveSyncCardDismissedDaemonIds,ie=n.composer,ye=nu({leftCollapsed:Z,rightCollapsed:se,leftPaneWidth:re,rightPaneWidth:je}),We=o.useCallback(z=>V=>{V.preventDefault();const G=V.clientX,oe=re,le=je,be=Re=>{const K=Re.clientX-G;if(z==="left"){ge(Js(oe+K,su,ru));return}_(Js(le-K,iu,au))},xe=()=>{document.body.classList.remove("pane-resizing"),window.removeEventListener("pointermove",be),window.removeEventListener("pointerup",xe)};document.body.classList.add("pane-resizing"),window.addEventListener("pointermove",be),window.addEventListener("pointerup",xe,{once:!0})},[re,je]);o.useEffect(()=>{r(z=>{const V={...z,sessionList:{...z.sessionList,searchHistory:l,sinceFilter:f,hideArchived:m,groupFolders:g,showNeedsAttentionGroup:C,showRunningGroup:u,separatePinnedGroup:h,collapsedFolders:M,agentFilter:A},layout:{...z.layout,leftSidebarCollapsed:Z,rightSidebarCollapsed:se}};return Ot(V),V})},[M,g,m,Z,se,l,h,A,C,u,f]);const Ae=o.useCallback(()=>{c(z=>ba(z,i))},[i]),J=o.useCallback(z=>{fe(z),Lr(z)},[]),X=o.useCallback(z=>{r(V=>{const G={...V,language:z};return Ot(G),G})},[]),ke=o.useCallback(z=>{r(V=>{const G={...V,theme:z};return Ot(G),G})},[]),Me=o.useCallback(z=>{r(V=>{const G={...V,sessionList:z(V.sessionList)};return Ot(G),G})},[]),ae=o.useCallback(z=>{r(V=>{const G={...V,composer:z(V.composer)};return Ot(G),G})},[]);return{webPreferences:n,search:i,setSearch:a,sinceFilter:f,setSinceFilter:d,hideArchived:m,setHideArchived:S,groupFolders:g,setGroupFolders:x,showNeedsAttentionGroup:C,setShowNeedsAttentionGroup:b,showRunningGroup:u,setShowRunningGroup:w,separatePinnedGroup:h,setSeparatePinnedGroup:v,collapsedFolders:M,setCollapsedFolders:y,sessionAgentFilter:A,setSessionAgentFilter:k,directoryTags:E,archiveSyncedDaemonIds:B,archiveSyncCardDismissedDaemonIds:P,composerPreferences:ie,savedTargets:U,setSavedTargets:fe,leftSidebarCollapsed:Z,setLeftSidebarCollapsed:he,rightSidebarCollapsed:se,setRightSidebarCollapsed:$,workspaceClassName:ye.workspaceClassName,wideMainClassName:ye.wideMainClassName,workspaceStyle:ye.style,beginPaneResize:We,commitSearch:Ae,saveTargets:J,setLanguagePreference:X,setThemePreference:ke,updateSessionListPreferences:Me,updateComposerPreferences:ae}}function pt(e,t,n){const r=new Set(e);return n?r.add(t):r.delete(t),r}function du(e){const t=o.useCallback((n,r,i,a,l)=>{const c=e.notificationSettingsRef.current;if(!c[a]||e.notifiedEventsRef.current.has(n))return;oc(r,i,{onClick:()=>{window.focus(),l&&e.setActiveSessionId(l)},permission:e.notificationPermissionRef.current,settings:c,tag:n,visibilityState:document.visibilityState})&&e.notifiedEventsRef.current.add(n)},[e]);return o.useCallback(n=>{switch(n.type){case"response":{Wt(n.data)&&typeof n.data.oldSessionId=="string"&&typeof n.data.sessionId=="string"&&e.remapLocalSessionState(n.data.oldSessionId,n.data.sessionId);break}case"sessions.changed":e.requestSessions({force:!0}).catch(r=>e.setErrorText(r instanceof Error?r.message:String(r)));break;case"session.history":e.clearHistoryLoading(n.sessionId),e.mergeCachedHistoryPage(n.sessionId,Qd(n.messages,n.partialReplyText),n.historyPage),n.sessionId===e.activeSessionIdRef.current&&(e.setPendingQueues(r=>({...r,[n.sessionId]:n.pendingQueue??[]})),e.setPendingApprovals(r=>{const i={...r};return n.pendingApproval?i[n.sessionId]={type:"approval.request",sessionId:n.sessionId,...n.pendingApproval}:delete i[n.sessionId],i}),e.setPendingQuestions(r=>{const i={...r};if(n.pendingQuestion){const a={type:"question.request",sessionId:n.sessionId,...n.pendingQuestion};i[n.sessionId]=a,e.setQuestionAnswers(Wn(a))}else delete i[n.sessionId];return i})),e.setRespondingSessions(r=>{const i=pt(r,n.sessionId,!!(n.isResponding||n.externallyResponding));return e.respondingSessionsRef.current=i,i});break;case"session.history.append":e.appendCachedHistory(n.sessionId,n.messages);break;case"text.delta":e.appendCachedDelta(n.sessionId,n.content),e.respondingSessionsRef.current=pt(e.respondingSessionsRef.current,n.sessionId,!0),e.setRespondingSessions(r=>pt(r,n.sessionId,!0));break;case"tool.call":e.appendCachedHistory(n.sessionId,[{role:"tool",type:"info",toolName:n.toolName,toolInput:n.input,content:`${e.t.toolCallLabel}: ${n.toolName}
11
+
12
+ ${xr(n.input)}`,timestamp:new Date().toISOString()}]);break;case"tool.result":e.appendCachedHistory(n.sessionId,[{role:"tool",type:"info",content:n.output,timestamp:new Date().toISOString()}]);break;case"approval.request":e.setPendingApprovals(r=>({...r,[n.sessionId]:n})),e.setActiveSessionId(n.sessionId),t(`approval:${n.sessionId}:${n.requestId}`,e.t.notificationApprovalTitle,n.description||n.toolName,"approvals",n.sessionId);break;case"question.request":e.setPendingQuestions(r=>({...r,[n.sessionId]:n})),e.setQuestionAnswers(Wn(n)),e.setActiveSessionId(n.sessionId),t(`question:${n.sessionId}:${n.requestId}`,e.t.notificationQuestionTitle,e.t.notificationQuestionCount(n.questions.length),"questions",n.sessionId);break;case"question.cleared":e.setPendingQuestions(r=>{const i={...r};return i[n.sessionId]?.requestId===n.requestId&&delete i[n.sessionId],i});break;case"session.queue":e.setPendingQueues(r=>({...r,[n.sessionId]:n.pending}));break;case"session.stall_warning":e.setSessions(r=>r.map(i=>i.sessionId===n.sessionId?{...i,stallWarning:n.warning}:i));break;case"session.interrupted_notice":e.setSessions(r=>r.map(i=>i.sessionId===n.sessionId?{...i,interruptReason:n.reason,stallWarning:void 0}:i));break;case"session.done":if(e.respondingSessionsRef.current.has(n.sessionId)){const r=(e.turnNotificationCountsRef.current[n.sessionId]??0)+1;e.turnNotificationCountsRef.current[n.sessionId]=r,t(`done:${n.sessionId}:${r}`,e.t.notificationReplyTitle,e.t.notificationReplyBody,"replies",n.sessionId)}e.respondingSessionsRef.current=pt(e.respondingSessionsRef.current,n.sessionId,!1),e.setRespondingSessions(r=>pt(r,n.sessionId,!1)),n.sessionId===e.activeSessionIdRef.current&&(e.setPendingApprovals(r=>{const i={...r};return delete i[n.sessionId],i}),e.setPendingQuestions(r=>{const i={...r};return delete i[n.sessionId],i})),n.usage&&e.setSessions(r=>r.map(i=>i.sessionId===n.sessionId?{...i,lastUsage:n.usage}:i)),e.requestSessions({force:!0}).catch(r=>e.setErrorText(r instanceof Error?r.message:String(r)));break;case"session.interrupted":e.respondingSessionsRef.current=pt(e.respondingSessionsRef.current,n.sessionId,!1),e.setRespondingSessions(r=>pt(r,n.sessionId,!1)),e.requestSessions({force:!0}).catch(r=>e.setErrorText(r instanceof Error?r.message:String(r)));break;case"session.renamed":e.setSessions(r=>r.map(i=>i.sessionId===n.sessionId?{...i,customTitle:n.title}:i));break;case"error":e.setErrorText(n.message);break}},[e,t])}const Hr="vibelet.web.composerDrafts",Qn={draftsBySessionId:{},newSessionDraft:""};function Xs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function zr(e){return Xs(e)?{draftsBySessionId:Xs(e.draftsBySessionId)?Object.fromEntries(Object.entries(e.draftsBySessionId).filter(n=>typeof n[1]=="string")):{},newSessionDraft:typeof e.newSessionDraft=="string"?e.newSessionDraft:""}:Qn}function uu(e=window.localStorage){const t=e.getItem(Hr);if(!t)return Qn;try{return zr(JSON.parse(t))}catch{return Qn}}function Kt(e,t=window.localStorage){t.setItem(Hr,JSON.stringify(zr(e)))}function Zt(e,t,n){if(!t)return{...e,newSessionDraft:n};const r={...e.draftsBySessionId};return n.trim()?r[t]=n:delete r[t],{...e,draftsBySessionId:r}}function Vt(e,t){return t?e.draftsBySessionId[t]??"":e.newSessionDraft}function fu(e,t,n){if(!t||!n||t===n)return e;const r=e.draftsBySessionId[t];if(r===void 0)return e;const i={...e.draftsBySessionId};return delete i[t],r.trim()&&(i[n]=r),{...e,draftsBySessionId:i}}function hu(e,t,n,r=!1){if(!r)return{...e,[t]:[n]};const i=e[t]??[],a=i.includes(n)?i.filter(l=>l!==n):[...i,n];return{...e,[t]:a}}function mu(e){const t=o.useCallback(async u=>{const w=e.clientRef.current;if(!(!w?.isConnected||!e.activeApproval)){e.setBusy(!0),e.setErrorText(null);try{await w.request({action:"session.approve",id:w.makeId("approve"),sessionId:e.activeApproval.sessionId,requestId:e.activeApproval.requestId,approved:u}),e.setPendingApprovals(h=>{const v={...h};return delete v[e.activeApproval.sessionId],v})}catch(h){e.setErrorText(h instanceof Error?h.message:String(h))}finally{e.setBusy(!1)}}},[e]),n=o.useCallback(async()=>{const u=e.clientRef.current;if(!(!u?.isConnected||!e.activeQuestion)){e.setBusy(!0),e.setErrorText(null);try{await u.request({action:"session.respondQuestion",id:u.makeId("question"),sessionId:e.activeQuestion.sessionId,requestId:e.activeQuestion.requestId,answers:e.questionAnswers}),e.setPendingQuestions(w=>{const h={...w};return delete h[e.activeQuestion.sessionId],h})}catch(w){e.setErrorText(w instanceof Error?w.message:String(w))}finally{e.setBusy(!1)}}},[e]),r=o.useCallback(async()=>{const u=e.clientRef.current;if(!(!u?.isConnected||!e.activeQuestion)){e.setBusy(!0),e.setErrorText(null);try{await u.request({action:"session.cancelQuestion",id:u.makeId("cancel_question"),sessionId:e.activeQuestion.sessionId,requestId:e.activeQuestion.requestId}),e.setPendingQuestions(w=>{const h={...w};return delete h[e.activeQuestion.sessionId],h})}catch(w){e.setErrorText(w instanceof Error?w.message:String(w))}finally{e.setBusy(!1)}}},[e]),i=o.useCallback((u,w,h)=>{e.setQuestionAnswers(v=>hu(v,u,w,!!h))},[e]),a=o.useCallback(async u=>{const w=e.clientRef.current;if(!w?.isConnected||!e.activeSession||u==="session.delete"&&!Ut(`Delete ${ze(e.activeSession)}?`))return!1;e.setBusy(!0),e.setErrorText(null);try{return u==="session.resume"?await w.request({action:u,id:w.makeId("resume"),sessionId:e.activeSession.sessionId,agent:e.activeSession.agent}):await w.request({action:u,id:w.makeId(u.split(".").at(-1)??"session"),sessionId:e.activeSession.sessionId}),u==="session.delete"&&(e.removeCachedHistory(e.activeSession.sessionId),e.setActiveSessionId(null),e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([])),await e.requestSessions({force:!0}),!0}catch(h){return e.setErrorText(h instanceof Error?h.message:String(h)),!1}finally{e.setBusy(!1)}},[e]),l=o.useCallback(async u=>{e.setApprovalMode(u);const w=e.clientRef.current;if(!(!w?.isConnected||!e.activeSession)){e.setErrorText(null);try{await w.request({action:"session.setApprovalMode",id:w.makeId("approval_mode"),sessionId:e.activeSession.sessionId,approvalMode:u}),e.setSessions(h=>h.map(v=>v.sessionId===e.activeSession.sessionId?{...v,approvalMode:u}:v))}catch(h){e.setErrorText(h instanceof Error?h.message:String(h))}}},[e]),c=o.useCallback(async u=>{const w=e.clientRef.current;if(!(!w?.isConnected||!e.activeSessionId||!u.clientMessageId)){e.setBusy(!0),e.setErrorText(null);try{await w.request({action:"session.queue.cancel",id:w.makeId("queue_cancel"),sessionId:e.activeSessionId,clientMessageId:u.clientMessageId}),e.setPendingQueues(h=>({...h,[e.activeSessionId]:(h[e.activeSessionId]??[]).filter(v=>v.clientMessageId!==u.clientMessageId)}))}catch(h){e.setErrorText(h instanceof Error?h.message:String(h))}finally{e.setBusy(!1)}}},[e]),f=o.useCallback(async(u,w)=>{if(e.pendingSessions[u.sessionId])return;const h=e.clientRef.current;if(h?.isConnected){e.setBusy(!0),e.setErrorText(null);try{const v=w?Date.now():void 0;await h.request({action:"session.setPinned",id:h.makeId("pin"),sessionId:u.sessionId,pinned:w,...v?{pinnedAt:v}:{}}),e.setSessions(M=>M.map(y=>y.sessionId===u.sessionId?{...y,pinned:w,pinnedAt:v}:y)),await e.requestSessions({force:!0})}catch(v){e.setErrorText(v instanceof Error?v.message:String(v))}finally{e.setBusy(!1)}}},[e]),d=o.useCallback(async(u,w)=>{if(e.pendingSessions[u.sessionId])return;const h=e.clientRef.current;if(h?.isConnected){e.setBusy(!0),e.setErrorText(null);try{await h.request({action:"session.setArchived",id:h.makeId("archive"),sessionId:u.sessionId,archived:w}),e.setSessions(v=>v.map(M=>M.sessionId===u.sessionId?{...M,archived:w}:M)),await e.requestSessions({force:!0})}catch(v){e.setErrorText(v instanceof Error?v.message:String(v))}finally{e.setBusy(!1)}}},[e]),m=o.useCallback(async u=>{if(e.pendingSessions[u.sessionId]){e.removeCachedHistory(u.sessionId),e.setPendingSessions(h=>{const v={...h};return delete v[u.sessionId],v}),e.setComposerDrafts(h=>{const v=Zt(h,u.sessionId,"");return e.composerDraftsRef.current=v,Kt(v),v}),e.activeSessionIdRef.current===u.sessionId&&(e.setActiveSessionId(null),e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([]),e.setDraft(Vt(e.composerDraftsRef.current,null)),e.setDetailsOpen(!1));return}const w=e.clientRef.current;if(!(!w?.isConnected||!Ut(`Delete ${ze(u)}?`))){e.setBusy(!0),e.setErrorText(null);try{await w.request({action:"session.delete",id:w.makeId("delete"),sessionId:u.sessionId}),e.removeCachedHistory(u.sessionId),e.setOptimisticSessions(h=>{if(!h[u.sessionId])return h;const v={...h};return delete v[u.sessionId],v}),e.activeSessionIdRef.current===u.sessionId&&(e.setActiveSessionId(null),e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([]),e.setDetailsOpen(!1)),await e.requestSessions({force:!0})}catch(h){e.setErrorText(h instanceof Error?h.message:String(h))}finally{e.setBusy(!1)}}},[e]),S=o.useCallback(async()=>{e.activeSession&&await f(e.activeSession,!e.activeSession.pinned)},[e.activeSession,f]),g=o.useCallback(async()=>{e.activeSession&&await d(e.activeSession,!e.activeSession.archived)},[e.activeSession,d]),x=o.useCallback(()=>{const u=e.activeSessionId;u&&a("session.interrupt").then(w=>{w&&(e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current),e.respondingSessionsRef.current.delete(u),e.setRespondingSessions(h=>{const v=new Set(h);return v.delete(u),v}))})},[e,a]),C=o.useCallback(()=>{e.setErrorText(null),e.phase==="connected"?e.requestSessions({force:!0}):window.location.reload()},[e]),b=o.useCallback(async()=>{const u=e.renameTitle.trim();if(e.activeSession&&e.pendingSessions[e.activeSession.sessionId]){e.setPendingSessions(h=>{const v=h[e.activeSession.sessionId];return v?{...h,[e.activeSession.sessionId]:{...v,title:u||v.title,customTitle:u||void 0}}:h});return}const w=e.clientRef.current;if(!(!w?.isConnected||!e.activeSession)){e.setBusy(!0),e.setErrorText(null);try{await w.request({action:"session.rename",id:w.makeId("rename"),sessionId:e.activeSession.sessionId,title:u||void 0}),e.setSessions(h=>h.map(v=>v.sessionId===e.activeSession.sessionId?{...v,customTitle:u||void 0}:v))}catch(h){e.setErrorText(h instanceof Error?h.message:String(h))}finally{e.setBusy(!1)}}},[e]);return{respondApproval:t,respondQuestion:n,cancelQuestion:r,setQuestionChoice:i,requestActiveAction:a,interruptActiveSession:x,retrySessions:C,updateApprovalMode:l,cancelQueuedTurn:c,setSessionPinned:f,setSessionArchived:d,deleteSession:m,updatePinned:S,updateArchived:g,renameSession:b}}function er(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 tr=15e3,nr="Session send timed out.";function Ht(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function pu(e){const[t,n]=o.useState(null),r=o.useCallback(f=>{e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current),e.respondingSessionsRef.current.delete(f),e.setRespondingSessions(d=>{const m=new Set(d);return m.delete(f),m})},[e]),i=o.useCallback((f,d)=>{const m=Ht(f)??Ht(e.cwd)??qe,S=d??e.agent,g=Qo(),x=Zo({sessionId:g,agent:S,cwd:m,approvalMode:e.approvalMode,model:dn(e.model),effort:e.effort||void 0,fastMode:e.fastMode,title:S==="codex"?e.t.newCodexSession:e.t.newClaudeSession}),C=e.activeSessionIdRef.current?"":Vt(e.composerDraftsRef.current,null);return e.setPendingSessions(b=>({...b,[g]:x})),e.setComposerDrafts(b=>{let u=Zt(b,g,C);return e.activeSessionIdRef.current||(u=Zt(u,null,"")),e.composerDraftsRef.current=u,Kt(u),u}),e.setCwd(m),e.setAgent(S),e.setActiveSessionId(g),e.lastHistorySessionIdRef.current=g,e.messagesSessionIdRef.current=g,e.clearHistoryLoading(),e.setMessages([]),e.setDraft(C),e.setErrorText(null),e.reportLog("web.session.pending_create",{sessionId:g,agent:S,cwd:m}),g},[e]),a=o.useCallback(async(f,d,m)=>{const S=e.clientRef.current;if(!S?.isConnected)return e.setErrorText(e.t.webSocketNotConnected),null;const g=m?e.pendingSessions[m]:void 0,x=Ht(f)??Ht(g?.cwd)??Ht(e.cwd)??qe,C=d??g?.agent??e.agent,b=g?.approvalMode??e.approvalMode,u=g?.model??dn(e.model),w=g?.effort??(e.effort||void 0),h=g?.fastMode??e.fastMode;e.setErrorText(null);try{const v=await S.request({action:"session.create",id:S.makeId("create"),agent:C,cwd:x,approvalMode:b,continueSession:e.continueSession,model:u,effort:w,fastMode:h,...m?{clientSessionId:m}:{}}),M=Vo(v);if(!M)throw new Error(e.t.sessionIdMissing);const y=Wt(v)&&typeof v.oldSessionId=="string"?v.oldSessionId:m;return e.setCwd(x),e.setAgent(C),e.setActiveSessionId(M),e.lastHistorySessionIdRef.current=M,e.messagesSessionIdRef.current=M,e.clearHistoryLoading(),m&&g?(e.setPendingSessions(A=>{const k={...A};return delete k[m],y&&y!==m&&delete k[y],k}),e.setOptimisticSessions(A=>({...A,[M]:Yo(g,M)})),y&&y!==M&&e.remapLocalSessionState(y,M),m!==M&&e.remapLocalSessionState(m,M)):await e.requestSessions({force:!0}),e.reportLog("web.session.create",{sessionId:M,clientSessionId:m,agent:C,cwd:x}),M}catch(v){return e.setErrorText(v instanceof Error?v.message:String(v)),null}},[e]),l=o.useCallback(async f=>{f?.preventDefault();const d=e.draft.trim();if(!d||e.busy)return;const m=e.clientRef.current;if(!m?.isConnected){e.setErrorText(e.t.webSocketNotConnected);return}e.setBusy(!0),e.setErrorText(null),e.updateDraft("");const S=e.attachments;e.setAttachments([]);let g=e.activeSessionId,x=e.activeSession?.agent??e.agent;if(g&&e.pendingSessions[g]){const y=await a(e.pendingSessions[g].cwd,e.pendingSessions[g].agent,g);if(!y){e.setBusy(!1),e.updateDraft(d),e.setAttachments(S);return}g=y,x=e.pendingSessions[e.activeSessionId??""]?.agent??x}else g||(g=await a());if(!g){e.setBusy(!1),e.updateDraft(d),e.setAttachments(S);return}const C=S.length===0?pc(d,x):null;if(C){const y=yc(C.command),A=y?m.makeId("cmd_msg"):void 0;y&&(e.messagesSessionIdRef.current=g,e.appendCachedHistory(g,[{role:"user",content:y,timestamp:new Date().toISOString()}]),e.renderCachedHistory(g));try{const k=await m.request({action:"session.command",id:m.makeId("command"),sessionId:g,agent:x,command:C.command,...A?{clientMessageId:A}:{},featureEntitlements:{agentCommands:"pro"}});await e.handleSessionCommandResponse(g,C.command,k)}catch(k){const U=k instanceof Error?k.message:String(k);e.appendInfoMessage(g,Ps(U)),e.setErrorText(Ps(U))}finally{e.setBusy(!1)}return}const b=gc(d),u=S.map(y=>y.path),w=m.makeId("msg"),h=`client:${w}`;e.messagesSessionIdRef.current=g,e.appendCachedHistory(g,[{role:"user",content:b,timestamp:new Date().toISOString(),historyKey:h,...u.length?{images:u}:{}}]),e.renderCachedHistory(g),e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current).add(g),e.setRespondingSessions(y=>new Set(y).add(g));const v=wc(b)??void 0,M=v?{agentSkills:"pro"}:void 0;try{const y=await m.request({action:"session.send",id:m.makeId("send"),sessionId:g,agent:x,message:b,clientMessageId:w,images:u.length?u:void 0,model:dn(e.model),effort:e.effort||void 0,fastMode:e.fastMode,skillInvocation:v,featureEntitlements:M},{timeoutMs:tr,timeoutMessage:nr});Wt(y)&&typeof y.oldSessionId=="string"&&typeof y.sessionId=="string"&&e.remapLocalSessionState(y.oldSessionId,y.sessionId),e.reportLog("web.telemetry.send_accepted",{attachmentCount:u.length}),n(A=>A?.historyKey===h?null:A)}catch(y){const A=y instanceof Error?y.message:String(y),k=er(_s(A,!!v));e.setErrorText(null),n({sessionId:g,agent:x,message:b,clientMessageId:w,historyKey:h,kind:k,retrying:!1,...u.length?{images:u}:{},model:dn(e.model),effort:e.effort||void 0,fastMode:e.fastMode,skillInvocation:v,featureEntitlements:M}),e.reportLog("web.telemetry.send_failed",{attachmentCount:u.length,failureKind:k},"warn"),r(g)}finally{e.setBusy(!1)}},[r,a,e]),c=o.useCallback(async()=>{if(!t||t.retrying||e.busy)return;const f=e.clientRef.current;if(!f?.isConnected){n(d=>d?{...d,kind:"network"}:null);return}n(d=>d?{...d,retrying:!0}:null),e.ensureCachedHistoryEntry(t.sessionId,{role:"user",content:t.message,historyKey:t.historyKey,...t.images?.length?{images:t.images}:{}}),e.setBusy(!0),e.setErrorText(null),e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current).add(t.sessionId),e.setRespondingSessions(d=>new Set(d).add(t.sessionId));try{const d=await f.request({action:"session.send",id:f.makeId("retry_send"),sessionId:t.sessionId,agent:t.agent,message:t.message,clientMessageId:t.clientMessageId,images:t.images,model:t.model,effort:t.effort,fastMode:t.fastMode,skillInvocation:t.skillInvocation??void 0,featureEntitlements:t.featureEntitlements},{timeoutMs:tr,timeoutMessage:nr});Wt(d)&&typeof d.oldSessionId=="string"&&typeof d.sessionId=="string"&&e.remapLocalSessionState(d.oldSessionId,d.sessionId),e.reportLog("web.telemetry.retry_accepted",{attachmentCount:t.images?.length??0}),n(null)}catch(d){const m=d instanceof Error?d.message:String(d),S=er(_s(m,!!t.skillInvocation));n(g=>g?{...g,kind:S,retrying:!1}:null),e.reportLog("web.telemetry.retry_failed",{attachmentCount:t.images?.length??0,failureKind:S},"warn"),r(t.sessionId)}finally{e.setBusy(!1)}},[r,t,e]);return{failedSend:t,retryFailedSend:c,stagePendingSession:i,sendDraft:l}}function gu(e,t){const n=t.trim().toLowerCase();return n?[ze(e),e.cwd,e.agent,e.branch??"",...e.titleAliases??[]].some(r=>r.toLowerCase().includes(n)):!0}function yu(e,t){return e.filter(n=>t.hideArchived&&n.archived||t.agentFilter!=="all"&&n.agent!==t.agentFilter?!1:gu(n,t.search))}function bu(e){const t=o.useMemo(()=>yn(yn(e.sessions,Object.values(e.optimisticSessions)),Object.values(e.pendingSessions)),[e.optimisticSessions,e.pendingSessions,e.sessions]),n=o.useMemo(()=>new Set(Object.keys(e.pendingSessions)),[e.pendingSessions]),r=o.useMemo(()=>t.find(d=>d.sessionId===e.activeSessionId)??null,[e.activeSessionId,t]),i=o.useMemo(()=>e.activeSessionId&&e.pendingApprovals[e.activeSessionId]?e.pendingApprovals[e.activeSessionId]:Object.values(e.pendingApprovals)[0]??null,[e.activeSessionId,e.pendingApprovals]),a=o.useMemo(()=>e.activeSessionId&&e.pendingQuestions[e.activeSessionId]?e.pendingQuestions[e.activeSessionId]:Object.values(e.pendingQuestions)[0]??null,[e.activeSessionId,e.pendingQuestions]),l=o.useMemo(()=>yu(t,{search:e.search,hideArchived:e.hideArchived,agentFilter:e.sessionAgentFilter}),[t,e.hideArchived,e.search,e.sessionAgentFilter]),c=o.useMemo(()=>new Set([...Object.keys(e.pendingApprovals),...Object.keys(e.pendingQuestions)]),[e.pendingApprovals,e.pendingQuestions]),f=o.useMemo(()=>Ho(l,{needsAttentionSessionIds:c,respondingSessionIds:e.respondingSessionIds,separatePinnedGroup:e.separatePinnedGroup,showNeedsAttentionGroup:e.showNeedsAttentionGroup,showRunningGroup:e.showRunningGroup}),[c,e.respondingSessionIds,e.separatePinnedGroup,e.showNeedsAttentionGroup,e.showRunningGroup,l]);return{activeApproval:i,activeQuestion:a,activeSession:r,displaySessions:t,groupedSessions:f,pendingSessionIds:n,visibleSessions:l}}function xu(e,t,n){o.useEffect(()=>{e!==0&&(t("session"),n(!1))},[e,t,n])}const Su=new Set(["attachmentCount","domNodes","durationMs","errorKind","failureKind","longTaskCount","maxLongTaskMs","online","phase","visibilityState"]);function vu(e){const t={};for(const[n,r]of Object.entries(e))Su.has(n)&&(typeof r=="string"?t[n]=r.slice(0,48):typeof r=="number"&&Number.isFinite(r)?t[n]=Math.round(r):typeof r=="boolean"&&(t[n]=r));return t}function sr(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 wu(e){o.useEffect(()=>{const t=performance.now(),n=(d,m,S="info")=>e(d,vu(m),S),r=d=>{n("web.telemetry.runtime_error",{errorKind:sr(d.error)},"error")},i=d=>{n("web.telemetry.unhandled_rejection",{errorKind:sr(d.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 l=0,c=0,f=null;return typeof PerformanceObserver<"u"&&PerformanceObserver.supportedEntryTypes.includes("longtask")&&(f=new PerformanceObserver(d=>{for(const m of d.getEntries())l+=1,c=Math.max(c,m.duration)}),f.observe({entryTypes:["longtask"]})),window.addEventListener("error",r),window.addEventListener("unhandledrejection",i),()=>{window.clearTimeout(a),window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",i),f?.disconnect(),l>0&&n("web.telemetry.long_tasks",{longTaskCount:l,maxLongTaskMs:c},"warn")}},[e])}function ku(e){o.useEffect(()=>{const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>xa(e,document.documentElement,t.matches);if(n(),e==="system")return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[e])}const ju=6;function Cu(e,t){return t.has(e.sessionId)||e.runtime?.isResponding===!0||e.runtime?.state==="daemonActive"||e.runtime?.state==="externalRunning"}function Nu(e,t,n,r,i=ju){if(i<=0)return[];const a=[];for(const l of e){if(a.length>=i)break;!l.sessionId||!Cu(l,n)||jn(t,l.sessionId)||r.has(l.sessionId)||a.push(l)}return a}function Iu(){const e=o.useRef(null),t=o.useRef(async()=>{}),n=o.useRef(null),r=o.useRef(Kn()),i=o.useRef(rc()),a=o.useRef(ir()),l=o.useRef(uu()),c=o.useRef(Id()),f=o.useRef(r.current),d=o.useRef(i.current),m=o.useRef(l.current),S=o.useRef(null),g=o.useRef(null),x=o.useRef(new Set),C=o.useRef(null),b=o.useRef(new Set),u=o.useRef(null),w=o.useRef(0),h=o.useRef(new Set),v=o.useRef({}),M=o.useRef(!1),[y,A]=o.useState("connecting"),[k,U]=o.useState(()=>As[Hn(a.current.language)].preparingVibeletWeb),[fe,Z]=o.useState(null),[he,se]=o.useState(null),[$,re]=o.useState([]),[ge,je]=o.useState({}),[_,E]=o.useState({}),[B,P]=o.useState(),[ie,ye]=o.useState({}),[We,Ae]=o.useState(),[J,X]=o.useState(null),[ke,Me]=o.useState(null),[ae,z]=o.useState(()=>new Set),[V,G]=o.useState({}),[oe,le]=o.useState({}),[be,xe]=o.useState({}),[Re,K]=o.useState({}),[me,_e]=o.useState("claude"),[T,Q]=o.useState(qe),[Ue,De]=o.useState(zn),[Pe]=o.useState(!1),[Ce,Ke]=o.useState(""),[Fe,Je]=o.useState(""),[Te,st]=o.useState(!1),[Xe,Se]=o.useState(""),[et,pe]=o.useState(l.current),[I,te]=o.useState(()=>Vt(l.current,null)),{webPreferences:$e,search:Le,setSearch:rt,sinceFilter:Ve,setSinceFilter:ft,hideArchived:Ne,setHideArchived:N,groupFolders:O,setGroupFolders:de,showNeedsAttentionGroup:H,setShowNeedsAttentionGroup:W,showRunningGroup:He,setShowRunningGroup:yt,separatePinnedGroup:ht,setSeparatePinnedGroup:Rt,collapsedFolders:Cn,setCollapsedFolders:Tt,sessionAgentFilter:Ge,setSessionAgentFilter:Et,directoryTags:Yt,archiveSyncedDaemonIds:Mt,archiveSyncCardDismissedDaemonIds:Jt,composerPreferences:Xt,savedTargets:D,setSavedTargets:Y,leftSidebarCollapsed:ee,setLeftSidebarCollapsed:Oe,rightSidebarCollapsed:bt,setRightSidebarCollapsed:it,workspaceClassName:at,wideMainClassName:Ee,workspaceStyle:mt,beginPaneResize:xt,commitSearch:Be,saveTargets:St,setLanguagePreference:en,setThemePreference:Wr,updateSessionListPreferences:Ur,updateComposerPreferences:Kr}=lu(a.current,c.current),Vr=Hn($e.language),q=As[Vr],[vt,Nn]=o.useState(!1),[Qe,_t]=o.useState("session"),[Gr,In]=o.useState(!1);ku($e.theme);const An=o.useCallback(p=>{_t(p),it(!1)},[it]),[Qr,Zr]=o.useState({}),[Yr,Jr]=o.useState({}),[Xr,ei]=o.useState([]),[Dt,ti]=o.useState({statusText:"",loading:!1,action:null}),[wt,Pt]=o.useState(Vn),[ls,ni]=o.useState(i.current),[Ft,ds]=o.useState(r.current),[us,si]=o.useState(null),[ri,ii]=o.useState(null),{attachments:fs,setAttachments:hs,uploadBusy:ai,directory:oi,setDirectory:ms,newDirName:ci,setNewDirName:li,remoteFile:tn,setRemoteFile:di,remoteFileConflict:ui,remoteFileMode:fi,setRemoteFileMode:hi,uploadFiles:mi,openRemoteFile:ps,saveRemoteFile:pi,downloadRemoteFile:gi,listDirectory:Rn,listSessionDirectories:yi,createDirectory:bi,createSessionDirectory:xi}=Vd({clientRef:e,pairing:he,cwd:T,phase:y,controlTab:Qe,setControlTab:An,setBusy:Nn,setErrorText:Z,t:q}),nn=Object.keys(V).length+Object.keys(oe).length;xu(nn,_t,it);const Si=J?Re[J]??[]:[],vi=Qr[me]??[],wi=Yr[me],{activeApproval:gs,activeQuestion:ys,activeSession:ot,displaySessions:sn,groupedSessions:ki,pendingSessionIds:ji,visibleSessions:Ci}=bu({activeSessionId:J,hideArchived:Ne,optimisticSessions:_,pendingApprovals:V,pendingQuestions:oe,pendingSessions:ge,respondingSessionIds:ae,search:Le,separatePinnedGroup:ht,sessionAgentFilter:Ge,sessions:$,showNeedsAttentionGroup:H,showRunningGroup:He}),{appendCachedDelta:Ni,appendCachedHistory:bs,appendInfoMessage:Tn,clearHistoryLoading:kt,ensureCachedHistoryEntry:Ii,historyCacheRef:En,historyLoading:Ai,hydrateVisibleHistory:xs,messages:Ss,messagesSessionIdRef:Ie,mergeCachedHistoryPage:Ri,remapCachedHistory:Ti,removeCachedHistory:Ei,renderCachedHistory:$t,replaceCachedHistory:Mn,requestHistory:vs,setMessages:ct}=tu({activeSessionIdRef:n,clientRef:e,historyTimeoutMessage:q.historyRequestTimedOut,setErrorText:Z});jt(n,J),jt(C,he),jt(h,ae),jt(d,ls),jt(f,Ft),jt(m,et);const ws=o.useCallback(p=>{te(p),pe(j=>{const R=Zt(j,n.current,p);return m.current=R,Kt(R),R})},[]),ks=o.useCallback(p=>{pe(j=>{const R=Zt(j,null,p);return m.current=R,Kt(R),R}),n.current||te(p)},[]);o.useEffect(()=>{Sa();const p=va();p&&(ks(p),_t("session"),wa())},[ks]),o.useEffect(()=>{Qe==="admin"&&ds(Kn())},[Qe]),o.useEffect(()=>()=>{u.current&&window.clearTimeout(u.current),tn?.objectUrl&&URL.revokeObjectURL(tn.objectUrl)},[tn?.objectUrl]);const Lt=o.useCallback((p,j=!1)=>{re(R=>yn(j?R:[],p.sessions)),E(R=>{const L=new Set(p.sessions.map(ve=>ve.sessionId)),ne=Object.fromEntries(Object.entries(R).filter(([ve])=>!L.has(ve)));return Object.keys(ne).length===Object.keys(R).length?R:ne}),P(p.nextCursor),Ae(p.inventoryVersion),p.folderCounts&&ye(p.folderCounts),j||qd(C.current?.daemonId,p),U(p.inventoryBackfillInFlight?q.connectedIndexing:q.connected)},[q.connected,q.connectedIndexing]),rn=Gd({clientRef:e,setSessions:re}),an=o.useCallback((p,j=h.current)=>{const R=e.current;if(!R?.isConnected||p.length===0)return;const L=Nu(p,En.current,j,x.current);for(const ne of L)x.current.add(ne.sessionId),R.request({action:"session.history",id:R.makeId("history_prefetch"),sessionId:ne.sessionId,agent:ne.agent},{timeoutMessage:q.historyPrefetchTimedOut,timeoutMs:Gn}).catch(()=>{}).finally(()=>{x.current.delete(ne.sessionId)})},[q.historyPrefetchTimedOut]),js=o.useCallback(p=>{const j=cc(p,{currentActiveSessionId:n.current,currentCwd:T});Lt(j.page,!1),P(j.page.nextCursor),Ae(j.page.inventoryVersion),j.messages&&j.activeSessionId&&xs(j.activeSessionId,j.messages),X(j.activeSessionId),j.activeAgent&&_e(j.activeAgent),j.activeCwd&&Q(j.activeCwd),j.activeApprovalMode&&De(j.activeApprovalMode),j.questionAnswers&&xe(j.questionAnswers),h.current=new Set(j.respondingSessionIds),z(h.current),G(j.pendingApprovals),le(j.pendingQuestions),K(j.pendingQueues),rn(p.sessions),an(p.sessions,new Set(j.respondingSessionIds))},[T,rn,xs,an,Lt]),Cs=o.useCallback(async()=>{const p=e.current;if(!p?.isConnected)return;const j=await p.request({action:"reconnect.snapshot",id:p.makeId("snapshot"),activeSessionId:n.current??void 0,activeAgent:ot?.agent??me,agent:Ge==="all"?void 0:Ge,search:Le.trim()||void 0,sinceMs:Ts(Ve),hideArchived:Ne,skipGitMetadata:!0});js(j.snapshot)},[ot?.agent,me,js,Ne,Le,Ge,Ve]),tt=o.useCallback(async p=>{const j=e.current;if(!j?.isConnected)return;const R=await j.request({action:"sessions.list",id:j.makeId(p?.append?"sessions_more":"sessions"),limit:zo,cursor:p?.cursor,agent:Ge==="all"?void 0:Ge,search:Le.trim()||void 0,sinceMs:Ts(Ve),hideArchived:Ne,skipGitMetadata:!0,force:p?.force}),L=br(R);Lt(L,p?.append),X(ne=>ne??L.sessions[0]?.sessionId??null),rn(L.sessions),an(L.sessions)},[Ne,rn,an,Le,Ge,Lt,Ve]),Ns=o.useCallback(async(p,j)=>{const R=e.current;if(R?.isConnected)try{const[L,ne,ve]=await Promise.all([R.request({action:"models.list",id:R.makeId("models"),agent:p}),R.request({action:"usage.limits.fetch",id:R.makeId("usage"),agent:p}),R.request({action:"skills.list",id:R.makeId("skills"),cwd:j||void 0})]);Zr(ue=>({...ue,[p]:L.options??[]})),Jr(ue=>({...ue,[p]:ne})),ei(Array.isArray(ve.skills)?ve.skills:[])}catch(L){Z(L instanceof Error?L.message:String(L))}},[]),_n=o.useCallback((p,j,R="info")=>{const L=e.current;L?.isConnected&&L.request({action:"log.report",id:L.makeId("log"),entries:[{level:R,event:p,data:j,ts:new Date().toISOString()}]}).catch(()=>{})},[]);wu(_n);const on=o.useCallback(async(p=C.current)=>{if(!p){Pt(Vn);return}Pt(j=>({...j,loading:!0,error:null}));try{const j=await fetch(_d(p,window.location,{sameOrigin:!1}),{cache:"no-store"});if(!j.ok)throw new Error(`HTTP ${j.status}`);const R=Dd(await j.json().catch(()=>null));Pt({...R,loading:!1,error:null})}catch{Pt(j=>({...j,loading:!1,error:q.connectorVersionFailed}))}},[q.connectorVersionFailed]);o.useEffect(()=>{Qe==="admin"&&y==="connected"&&on()},[Qe,y,on]);const Mi=o.useCallback(p=>{ni(j=>{const R={...j,...p};return d.current=R,ic(R),R})},[]),cn=o.useCallback((p,j)=>{!p||!j||p===j||(X(R=>R===p?j:R),S.current===p&&(S.current=j),Ie.current===p&&(Ie.current=j),Ti(p,j),h.current=Es(h.current,p,j),z(R=>Es(R,p,j)),G(R=>$n(R,p,j)),le(R=>$n(R,p,j)),K(R=>$n(R,p,j)),E(R=>{const L=R[p];if(!L)return R;const ne={...R};return delete ne[p],ne[j]={...L,sessionId:j},ne}),pe(R=>{const L=fu(R,p,j);return L!==R&&(m.current=L,Kt(L)),L}))},[]),_i=o.useCallback(async(p,j,R)=>{const L=typeof R.sessionId=="string"?R.sessionId:p,ne=typeof R.oldSessionId=="string"?R.oldSessionId:p;ne&&L&&ne!==L&&cn(ne,L),j.name==="clear"?(Mn(L,[]),K(ve=>{const ue={...ve};return delete ue[L],delete ue[ne],ue}),G(ve=>{const ue={...ve};return delete ue[L],delete ue[ne],ue}),le(ve=>{const ue={...ve};return delete ue[L],delete ue[ne],ue}),X(L)):j.name==="new"?(X(L),Ie.current=L,$t(L)):j.name==="exit"?(re(ve=>ve.map(ue=>ue.sessionId===L?{...ue,archived:!0}:ue)),X(null),Ie.current=null,S.current=null,ct([])):j.name==="goal"&&"goal"in R&&Tn(L,bc(R.goal)),R.turnStarted&&!R.queued&&(h.current=new Set(h.current).add(L),z(ve=>new Set(ve).add(L))),await tt({force:!0})},[Tn,cn,$t,Mn,tt]),Di=du({notificationSettingsRef:d,notifiedEventsRef:b,notificationPermissionRef:f,activeSessionIdRef:n,respondingSessionsRef:h,turnNotificationCountsRef:v,t:q,setActiveSessionId:X,setErrorText:Z,setPendingQueues:K,setPendingApprovals:G,setPendingQuestions:le,setQuestionAnswers:xe,setRespondingSessions:z,setSessions:re,remapLocalSessionState:cn,requestSessions:tt,clearHistoryLoading:kt,replaceCachedHistory:Mn,mergeCachedHistoryPage:Ri,appendCachedHistory:bs,appendCachedDelta:Ni});Wd({clientRef:e,connectWithPairingRef:t,pairingRef:C,reconnectTimerRef:u,connectionAttemptIdRef:w,intentionalDisconnectRef:M,historyCacheRef:En,historyCacheDaemonIdRef:g,messagesSessionIdRef:Ie,lastHistorySessionIdRef:S,rememberedTarget:c.current[0]??null,agent:me,cwd:T,phase:y,search:Le,sinceFilter:Ve,t:q,handleServerMessage:Di,setPhase:A,setStatusText:U,setErrorText:Z,setMessages:ct,setPairing:se,setSavedTargets:Y,setSessionsFromPage:Lt,refreshDaemonMetadata:on,requestReconnectSnapshot:Cs,fetchAgentResources:Ns,reportLog:_n,requestSessions:tt}),o.useEffect(()=>{const p=sn.find(j=>j.sessionId===J);if(!p){S.current=null,Ie.current=null,kt(),ct([]),te(Vt(m.current,null));return}if(_e(p.agent),Q(p.cwd||qe),Ke(p.model??""),Je(p.effort??""),st(p.fastMode??!1),De(p.approvalMode??zn),Se(p.customTitle??p.title??""),te(Vt(m.current,p.sessionId)),ms(j=>({...j,path:p.cwd||qe,loaded:j.path===(p.cwd||qe)?j.loaded:!1})),ge[p.sessionId]){S.current=p.sessionId,kt(),Ie.current!==p.sessionId&&(Ie.current=p.sessionId,ct([]));return}if($t(p.sessionId)){S.current=p.sessionId,kt(p.sessionId);return}S.current!==p.sessionId&&(S.current=p.sessionId,Ie.current!==p.sessionId&&(Ie.current=p.sessionId,ct([])),vs(p))},[J,kt,sn,ge,$t,vs]);const{failedSend:Pi,retryFailedSend:Fi,stagePendingSession:$i,sendDraft:Li}=pu({clientRef:e,activeSessionIdRef:n,composerDraftsRef:m,lastHistorySessionIdRef:S,messagesSessionIdRef:Ie,respondingSessionsRef:h,agent:me,cwd:T,approvalMode:Ue,continueSession:Pe,model:Ce,effort:Fe,fastMode:Te,activeSessionId:J,activeSession:ot,pendingSessions:ge,draft:I,busy:vt,attachments:fs,t:q,setPendingSessions:je,setOptimisticSessions:E,setComposerDrafts:pe,setCwd:Q,setAgent:_e,setActiveSessionId:X,setMessages:ct,setDraft:te,setErrorText:Z,setBusy:Nn,setAttachments:hs,setRespondingSessions:z,clearHistoryLoading:kt,reportLog:_n,remapLocalSessionState:cn,requestSessions:tt,updateDraft:ws,appendCachedHistory:bs,ensureCachedHistoryEntry:Ii,renderCachedHistory:$t,handleSessionCommandResponse:_i,appendInfoMessage:Tn}),{respondApproval:Oi,respondQuestion:Bi,cancelQuestion:qi,setQuestionChoice:Hi,requestActiveAction:zi,interruptActiveSession:Wi,retrySessions:Ui,updateApprovalMode:Ki,cancelQueuedTurn:Vi,setSessionPinned:Gi,setSessionArchived:Qi,deleteSession:Zi,updatePinned:Yi,updateArchived:Ji,renameSession:Xi}=mu({clientRef:e,activeSessionIdRef:n,composerDraftsRef:m,lastHistorySessionIdRef:S,messagesSessionIdRef:Ie,respondingSessionsRef:h,activeApproval:gs,activeQuestion:ys,activeSession:ot,activeSessionId:J,questionAnswers:be,pendingSessions:ge,phase:y,renameTitle:Xe,setBusy:Nn,setErrorText:Z,setPendingApprovals:G,setPendingQuestions:le,setQuestionAnswers:xe,setPendingQueues:K,setActiveSessionId:X,setMessages:ct,setApprovalMode:De,setSessions:re,setPendingSessions:je,setComposerDrafts:pe,setDraft:te,setDetailsOpen:In,setRespondingSessions:z,setOptimisticSessions:E,removeCachedHistory:Ei,requestSessions:tt}),{runArchiveSync:Dn,skipArchiveSync:ea,runAdminAction:Is,exportActiveSession:ta,clearPairing:na,setNotificationsEnabled:sa,connectSavedTarget:ra,forgetSavedTarget:ia,openSessionDetails:aa,editFolderTags:oa,browseFolder:ca,copyResumeCommand:la}=Pd({clientRef:e,pairingRef:C,connectWithPairingRef:t,notificationPermissionRef:f,intentionalDisconnectRef:M,connectionAttemptIdRef:w,historyCacheRef:En,historyCacheDaemonIdRef:g,messagesSessionIdRef:Ie,lastHistorySessionIdRef:S,displaySessions:sn,pairing:he,t:q,archiveSyncBusy:us,daemonMetadata:wt,activeSession:ot,messages:Ss,notificationPermission:Ft,savedTargets:D,setArchiveSyncBusy:si,setArchiveSyncStatus:ii,setSessions:re,setAdmin:ti,setErrorText:Z,setNotificationPermission:ds,setStatusText:U,setMessages:ct,setPairing:se,setDaemonMetadata:Pt,setPhase:A,setActiveSessionId:X,setRenameTitle:Se,setDetailsOpen:In,setControlTab:An,updateSessionListPreferences:Ur,requestSessions:tt,refreshDaemonMetadata:on,updateNotificationSettings:Mi,saveTargets:St,listDirectory:Rn}),da=Ft==="denied"||Ft==="unsupported",ua=!!(wt.version&&wt.latestVersion&&Ed(wt.version,wt.latestVersion)),ln=he?.daemonId,fa=!!(ln&&Mt[ln]),ha=!!(ln&&Jt[ln]);return y==="missing-pair"?s.jsxs(s.Fragment,{children:[s.jsx("a",{className:"skip-link",href:"#vibelet-main-content",children:q.skipToConversation}),s.jsx(Fl,{errorText:fe,t:q})]}):s.jsxs("main",{className:at,id:"vibelet-workspace",style:mt,children:[s.jsx("a",{className:"skip-link",href:"#vibelet-main-content",children:q.skipToConversation}),ee?s.jsx("button",{"aria-label":q.expandSessionSidebar,className:"sidebar-restore-button sidebar-restore-button-left",onClick:()=>Oe(!1),title:q.expandSessionSidebar,type:"button",children:s.jsx(fr,{"aria-hidden":"true"})}):s.jsxs(s.Fragment,{children:[s.jsx(nd,{activeSessionId:J,busy:vt,collapsedFolders:Cn,currentCwd:T,directoryTags:Yt,displayName:he?.displayName,folderCounts:ie,groupFolders:O,groupedSessions:ki,hideArchived:Ne,separatePinnedGroup:ht,showNeedsAttentionGroup:H,showRunningGroup:He,inventoryVersion:We,nextCursor:B,phase:y,respondingSessionIds:ae,search:Le,sessionAgentFilter:Ge,sessionsCount:sn.length,sinceFilter:Ve,statusText:k,t:q,visibleSessions:Ci,onLoadMore:p=>tt({append:!0,cursor:p}),onBrowseFolder:ca,onCopyResumeCommand:la,onCreateDirectory:xi,pendingSessionIds:ji,onCreateSession:(p,j)=>{$i(p,j)},onDeleteSession:p=>{Zi(p)},onEditFolderTags:oa,onListDirectories:yi,onOpenSessionDetails:aa,onResetFilters:()=>{Et("all"),ft("30d"),N(!1),de(!1),W(!1),yt(!1),Rt(!1)},onSearchChange:rt,onSearchCommit:Be,onSelectSession:X,onToggleSessionArchived:p=>{Qi(p,!p.archived)},onToggleSessionPinned:p=>{Gi(p,!p.pinned)},onSessionAgentFilterChange:Et,onSinceFilterChange:ft,onViewChanges:Me,onToggleFolder:p=>Tt(j=>({...j,[p]:!j[p]})),onToggleGroupFolders:()=>de(p=>!p),onToggleHideArchived:()=>N(p=>!p),onToggleNeedsAttentionGroup:()=>W(p=>!p),onToggleRunningGroup:()=>yt(p=>!p),onToggleSeparatePinnedGroup:()=>Rt(p=>!p),onToggleCollapse:()=>Oe(!0)}),s.jsx("button",{"aria-label":q.resizeSessionSidebar,className:"resize-handle",onPointerDown:xt("left"),title:q.resizeSessionSidebar,type:"button",children:s.jsx("span",{})})]}),s.jsxs("section",{className:Ee,"aria-label":q.vibeletWorkspace,id:"vibelet-main-content",tabIndex:-1,children:[s.jsx(rl,{activeSession:ot,activeSessionId:J,activeModelOptions:vi,activeQueue:Si,activeUsage:wi,agent:me,approvalMode:Ue,attachments:fs,busy:vt,cwd:T,draft:I,effort:Fe,errorText:fe,failedSend:Pi,fastMode:Te,historyLoading:Ai,messages:Ss,messagesSessionId:Ie.current,model:Ce,phase:y,quickReplies:Xt.quickReplies,renameTitle:Xe,respondingSessionIds:ae,sendShortcut:Xt.sendShortcut,skills:Xr,uploadBusy:ai,detailsOpen:Gr,controlsOpen:!bt,pendingActionsCount:nn,t:q,onApprovalModeChange:p=>{Ki(p)},onBrowseFiles:()=>{const p=ot?.cwd||T||qe;An("files"),Rn(p,{updateRoute:!0})},onCancelQueuedTurn:p=>{Vi(p)},onClearInterrupt:()=>{zi("session.clearInterrupt")},onDraftChange:ws,onDetailsOpenChange:In,onEffortChange:Je,onExportActiveSession:()=>{ta()},onFastModeChange:st,onRetryFailedSend:Fi,onModelChange:Ke,onOpenRemoteFile:(p,j)=>{ps(p,j,{updateRoute:!0})},onOpenControls:()=>{bt&&nn===0&&Qe==="session"&&_t("files"),it(p=>!p)},onInterrupt:Wi,onRetry:Ui,onRefreshSessions:()=>{tt({force:!0})},onRenameSession:()=>{Xi()},onRenameTitleChange:Se,onRemoveAttachment:p=>hs(j=>j.filter(R=>R.path!==p)),onRestoreSnapshot:()=>{Cs()},onRefreshSkills:()=>{Ns(ot?.agent??me,T)},onSendShortcutChange:p=>Kr(j=>({...j,sendShortcut:p})),onSubmit:Li,onToggleArchived:()=>{Ji()},onTogglePinned:()=>{Yi()},onUploadFiles:mi,onViewChanges:Me}),bt?null:s.jsxs(rd,{t:q,value:Qe,showSession:nn>0,onChange:_t,onClose:()=>it(!0),children:[Qe==="session"?s.jsx(Vl,{activeApproval:gs,activeQuestion:ys,busy:vt,questionAnswers:be,t:q,onCancelQuestion:()=>{qi()},onQuestionChoice:Hi,onRespondApproval:p=>{Oi(p)},onRespondQuestion:()=>{Bi()}}):null,Qe==="files"?s.jsx(o.Suspense,{fallback:s.jsx(qs,{t:q}),children:s.jsx($l,{busy:vt,cwd:T,directory:oi,newDirName:ci,remoteFile:tn,remoteFileConflict:ui,remoteFileMode:fi,t:q,onCreateDirectory:()=>{bi()},onDirectoryPathChange:p=>ms(j=>({...j,path:p,loaded:!1})),onDownloadRemoteFile:()=>{gi()},onListDirectory:p=>{Rn(p,{updateRoute:!0})},onNewDirNameChange:li,onOpenRemoteFile:(p,j)=>{ps(p,j,{updateRoute:!0})},onRemoteFileModeChange:hi,onRemoteFileTextChange:p=>di(j=>j&&{...j,text:p,dirty:!0}),onSaveRemoteFile:p=>{pi(p)}})}):null,Qe==="admin"?s.jsxs(o.Suspense,{fallback:s.jsx(qs,{t:q}),children:[s.jsx(Ol,{pairing:he,phase:y,t:q,onForgetPairing:na}),s.jsx(ql,{language:$e.language,t:q,onLanguageChange:en}),s.jsx(Hl,{t:q,theme:$e.theme,onThemeChange:Wr}),s.jsx(Wl,{activeDaemonId:he?.daemonId,busy:vt,t:q,targets:D,onConnect:ra,onForget:ia}),s.jsx(zl,{notificationsBlocked:da,permission:Ft,settings:ls,t:q,onToggleEnabled:sa}),s.jsx(Ll,{busy:us,connected:y==="connected",dismissed:ha,feedback:ri,synced:fa,t:q,onPull:()=>{Dn("pull")},onPushMerge:()=>{Dn("pushMerge")},onPushReplace:()=>{Dn("pushReplace")},onSkip:ea}),s.jsx(Bl,{connected:y==="connected",metadata:wt,restartBusy:Dt.loading&&Dt.action==="restart",showUpdate:ua,t:q,updateBusy:Dt.loading&&Dt.action==="update",updateStatus:Dt.statusText,onRestart:()=>{Is("restart")},onUpdate:()=>{Is("update")}})]}):null]})]}),s.jsx(Kl,{client:e.current,close:()=>Me(null),id:ke,sessions:$,t:q})]})}const Ru=Object.freeze(Object.defineProperty({__proto__:null,App:Iu},Symbol.toStringTag,{value:"Module"}));export{Ru as A,Jl as C,Pl as F,ao as K,hn as L,Gt as R,_o as T,we as X,Nt as a,cr as b,vn as c,Ko as d,It as e,ns as f,ar as g,Un as j,Ms as p,Ql as r,wn as u};
@@ -1 +1 @@
1
- import{c as a,j as e,D as p}from"./index-DRV2XMZs.js";const u=[["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"}]],x=a("archive-restore",u);const v=[["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"}]],k=a("git-merge",v);const m=[["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"}]],S=a("upload",m);function g({busy:n,connected:s,dismissed:r,feedback:i,synced:o,t:c,onPull:h,onPushMerge:l,onPushReplace:y,onSkip:d}){const t=!s||n!==null;return e.jsxs("section",{className:"control-section compact-section archive-sync-panel",children:[e.jsx("h2",{children:c.archiveSyncTitle}),e.jsx("p",{className:"empty-copy",children:o?c.archiveSyncSynced:r?c.archiveSyncSkippedState:c.archiveSyncBody}),e.jsxs("div",{className:"action-grid archive-sync-actions",children:[e.jsxs("button",{className:"icon-text-button",disabled:t,onClick:l,type:"button",children:[e.jsx(k,{"aria-hidden":"true"}),n==="pushMerge"?c.archiveSyncSyncing:c.archiveSyncPushMerge]}),e.jsxs("button",{className:"icon-text-button",disabled:t,onClick:h,type:"button",children:[e.jsx(p,{"aria-hidden":"true"}),n==="pull"?c.archiveSyncSyncing:c.archiveSyncPull]}),e.jsxs("button",{className:"icon-text-button",disabled:t,onClick:y,type:"button",children:[e.jsx(S,{"aria-hidden":"true"}),n==="pushReplace"?c.archiveSyncSyncing:c.archiveSyncPushReplace]}),e.jsxs("button",{className:"icon-text-button",disabled:t,onClick:d,type:"button",children:[e.jsx(x,{"aria-hidden":"true"}),c.archiveSyncSkip]})]}),i?e.jsx("p",{className:`empty-copy ${i.tone==="error"?"error-copy":"success-copy"}`,children:i.message}):null]})}export{g as ArchiveSyncPanel};
1
+ import{c as a,j as e,D as p}from"./index-CXts92Zv.js";const u=[["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"}]],x=a("archive-restore",u);const v=[["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"}]],k=a("git-merge",v);const m=[["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"}]],S=a("upload",m);function g({busy:n,connected:s,dismissed:r,feedback:i,synced:o,t:c,onPull:h,onPushMerge:l,onPushReplace:y,onSkip:d}){const t=!s||n!==null;return e.jsxs("section",{className:"control-section compact-section archive-sync-panel",children:[e.jsx("h2",{children:c.archiveSyncTitle}),e.jsx("p",{className:"empty-copy",children:o?c.archiveSyncSynced:r?c.archiveSyncSkippedState:c.archiveSyncBody}),e.jsxs("div",{className:"action-grid archive-sync-actions",children:[e.jsxs("button",{className:"icon-text-button",disabled:t,onClick:l,type:"button",children:[e.jsx(k,{"aria-hidden":"true"}),n==="pushMerge"?c.archiveSyncSyncing:c.archiveSyncPushMerge]}),e.jsxs("button",{className:"icon-text-button",disabled:t,onClick:h,type:"button",children:[e.jsx(p,{"aria-hidden":"true"}),n==="pull"?c.archiveSyncSyncing:c.archiveSyncPull]}),e.jsxs("button",{className:"icon-text-button",disabled:t,onClick:y,type:"button",children:[e.jsx(S,{"aria-hidden":"true"}),n==="pushReplace"?c.archiveSyncSyncing:c.archiveSyncPushReplace]}),e.jsxs("button",{className:"icon-text-button",disabled:t,onClick:d,type:"button",children:[e.jsx(x,{"aria-hidden":"true"}),c.archiveSyncSkip]})]}),i?e.jsx("p",{className:`empty-copy ${i.tone==="error"?"error-copy":"success-copy"}`,children:i.message}):null]})}export{g as ArchiveSyncPanel};
@@ -1 +1 @@
1
- import{j as e}from"./index-DRV2XMZs.js";import{K as o}from"./App-20rnW-dS.js";function l({pairing:s,phase:d,t:n,onForgetPairing:t}){const c=d==="connected"?"connected":s?d:n.notPaired;return e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:n.currentDevice}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:n.daemon}),e.jsx("dd",{children:s?.displayName??s?.daemonId??n.notPaired})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n.status}),e.jsx("dd",{children:c})]})]}),e.jsx("div",{className:"action-grid",children:e.jsxs("button",{className:"danger-button",disabled:!s,onClick:t,type:"button",children:[e.jsx(o,{"aria-hidden":"true"}),n.forget]})})]})}export{l as ConnectionSettingsPanel};
1
+ import{j as e}from"./index-CXts92Zv.js";import{K as o}from"./App-1V1UoQkP.js";function l({pairing:s,phase:d,t:n,onForgetPairing:t}){const c=d==="connected"?"connected":s?d:n.notPaired;return e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:n.currentDevice}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:n.daemon}),e.jsx("dd",{children:s?.displayName??s?.daemonId??n.notPaired})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n.status}),e.jsx("dd",{children:c})]})]}),e.jsx("div",{className:"action-grid",children:e.jsxs("button",{className:"danger-button",disabled:!s,onClick:t,type:"button",children:[e.jsx(o,{"aria-hidden":"true"}),n.forget]})})]})}export{l as ConnectionSettingsPanel};
@@ -1 +1 @@
1
- import{j as n,D as h}from"./index-DRV2XMZs.js";import{R as j}from"./App-20rnW-dS.js";function a({connected:r,metadata:s,showUpdate:o,updateBusy:l,restartBusy:i,t:e,updateStatus:c,onUpdate:d,onRestart:t}){const x=s.version&&s.latestVersion&&o?`${s.version} -> ${s.latestVersion}`:s.version||e.unknown;return n.jsxs("section",{className:"control-section compact-section",children:[n.jsx("h2",{children:e.desktopConnector}),n.jsx("dl",{children:n.jsxs("div",{children:[n.jsx("dt",{children:e.version}),n.jsx("dd",{children:s.loading?e.checking:x})]})}),n.jsxs("div",{className:"action-grid",children:[o?n.jsxs("button",{className:"primary-button",disabled:!r||l||i,onClick:d,type:"button",children:[n.jsx(h,{"aria-hidden":"true"}),l?e.updating:e.update]}):null,n.jsxs("button",{className:"danger-button",disabled:!r||i,onClick:t,type:"button",children:[n.jsx(j,{"aria-hidden":"true"}),i?e.restarting:e.restart]})]}),s.error?n.jsx("p",{className:"empty-copy",children:s.error}):null,c?n.jsx("p",{className:"empty-copy",children:c}):null]})}export{a as DaemonSettingsPanel};
1
+ import{j as n,D as h}from"./index-CXts92Zv.js";import{R as j}from"./App-1V1UoQkP.js";function a({connected:r,metadata:s,showUpdate:o,updateBusy:l,restartBusy:i,t:e,updateStatus:c,onUpdate:d,onRestart:t}){const x=s.version&&s.latestVersion&&o?`${s.version} -> ${s.latestVersion}`:s.version||e.unknown;return n.jsxs("section",{className:"control-section compact-section",children:[n.jsx("h2",{children:e.desktopConnector}),n.jsx("dl",{children:n.jsxs("div",{children:[n.jsx("dt",{children:e.version}),n.jsx("dd",{children:s.loading?e.checking:x})]})}),n.jsxs("div",{className:"action-grid",children:[o?n.jsxs("button",{className:"primary-button",disabled:!r||l||i,onClick:d,type:"button",children:[n.jsx(h,{"aria-hidden":"true"}),l?e.updating:e.update]}):null,n.jsxs("button",{className:"danger-button",disabled:!r||i,onClick:t,type:"button",children:[n.jsx(j,{"aria-hidden":"true"}),i?e.restarting:e.restart]})]}),s.error?n.jsx("p",{className:"empty-copy",children:s.error}):null,c?n.jsx("p",{className:"empty-copy",children:c}):null]})}export{a as DaemonSettingsPanel};
@@ -1,2 +1,2 @@
1
- import{r as l,j as e}from"./index-DRV2XMZs.js";import{u as C,X as F}from"./App-20rnW-dS.js";import{F as W}from"./file-text-B-0kY5qg.js";const E={loading:!1,files:null,error:null};function q({client:t,sessionId:f,sessionTitle:x,t:i,onClose:o}){const h=l.useRef(null),j=C(o,h),[n,w]=l.useState("unstaged"),[d,g]=l.useState({unstaged:E,staged:E}),[u,y]=l.useState(null),[p,b]=l.useState(null),[k,N]=l.useState(!1),[S,m]=l.useState(null),c=d[n],v=l.useCallback(async s=>{g(a=>({...a,[s]:{loading:!0,files:a[s].files,error:null}}));try{const a=await t.request({action:"session.gitDiff.list",id:t.makeId("gitDiffList"),sessionId:f,scope:s});g(r=>({...r,[s]:{loading:!1,files:a.files,error:null}}))}catch(a){g(r=>({...r,[s]:{loading:!1,files:null,error:a instanceof Error?a.message:String(a)}}))}},[t,f]);l.useEffect(()=>{!d[n].files&&!d[n].loading&&!d[n].error&&v(n)},[n,d,v]),l.useEffect(()=>{y(null),b(null),m(null)},[n]),l.useEffect(()=>{if(!u){b(null),m(null);return}let s=!1;return N(!0),m(null),t.request({action:"session.gitDiff.file",id:t.makeId("gitDiffFile"),sessionId:f,scope:n,path:u}).then(a=>{s||(b(a),N(!1))}).catch(a=>{s||(m(a instanceof Error?a.message:String(a)),N(!1))}),()=>{s=!0}},[t,f,n,u]);const P=l.useMemo(()=>{const s=a=>a?a.reduce((r,D)=>({adds:r.adds+D.additions,dels:r.dels+D.deletions,count:r.count+1}),{adds:0,dels:0,count:0}):{adds:0,dels:0,count:0};return{unstaged:s(d.unstaged.files),staged:s(d.staged.files)}},[d]);return e.jsxs("div",{"aria-labelledby":"diff-drawer-title","aria-modal":"true",className:"diff-drawer",ref:j,role:"dialog",tabIndex:-1,children:[e.jsx("div",{className:"diff-drawer-backdrop",onClick:o,"aria-hidden":"true"}),e.jsxs("div",{className:"diff-drawer-panel",children:[e.jsxs("header",{className:"diff-drawer-header",children:[e.jsxs("div",{children:[e.jsx("strong",{id:"diff-drawer-title",children:i.changes}),e.jsx("span",{children:x})]}),e.jsx("button",{"aria-label":i.closeChanges,className:"icon-button",onClick:o,ref:h,type:"button",children:e.jsx(F,{"aria-hidden":"true"})})]}),e.jsx("div",{className:"diff-tabs",role:"tablist",children:["unstaged","staged"].map(s=>{const a=P[s],r=n===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":r,className:`diff-tab ${r?"active":""}`,onClick:()=>w(s),children:[e.jsx("span",{className:"diff-tab-label",children:s==="unstaged"?i.workingChanges:i.stagedChanges}),a.count>0?e.jsxs("span",{className:"diff-tab-meta",children:[e.jsxs("span",{className:"diff-add",children:["+",a.adds]}),e.jsxs("span",{className:"diff-del",children:["-",a.dels]})]}):null]},s)})}),e.jsxs("div",{className:"diff-body",children:[e.jsxs("aside",{className:"diff-files","aria-label":i.changedFiles,children:[c.loading&&!c.files?e.jsx("p",{className:"diff-empty",children:i.loading}):null,c.error?e.jsx("p",{className:"diff-empty diff-error",children:c.error}):null,c.files&&c.files.length===0?e.jsx("p",{className:"diff-empty",children:i.noChanges}):null,c.files?.map(s=>e.jsxs("button",{type:"button",className:`diff-file ${u===s.path?"active":""}`,onClick:()=>y(s.path),children:[e.jsx("span",{className:`diff-status diff-status-${s.status}`,children:s.status}),e.jsx("span",{className:"diff-file-path",title:s.path,children:s.path}),e.jsxs("span",{className:"diff-file-stats",children:[s.binary?e.jsx("span",{className:"diff-binary",children:"bin"}):null,!s.binary&&s.additions>0?e.jsxs("span",{className:"diff-add",children:["+",s.additions]}):null,!s.binary&&s.deletions>0?e.jsxs("span",{className:"diff-del",children:["-",s.deletions]}):null]})]},s.path))]}),e.jsx("section",{className:"diff-patch","aria-label":i.fileDiff,children:u?k?e.jsx("p",{className:"diff-empty",children:i.loadingPatch}):S?e.jsx("p",{className:"diff-empty diff-error",children:S}):p?.binary?e.jsx("p",{className:"diff-empty",children:i.binaryDiffUnavailable}):p?e.jsx(T,{patch:p.patch,truncated:p.truncated,truncatedLabel:i.patchTruncated}):null:e.jsxs("div",{className:"diff-empty",children:[e.jsx(W,{"aria-hidden":"true"}),e.jsx("p",{children:i.selectFileForDiff})]})})]})]})]})}function T({patch:t,truncated:f,truncatedLabel:x}){const i=l.useMemo(()=>t.split(`
1
+ import{r as l,j as e}from"./index-CXts92Zv.js";import{u as C,X as F}from"./App-1V1UoQkP.js";import{F as W}from"./file-text-NAVq0aqX.js";const E={loading:!1,files:null,error:null};function q({client:t,sessionId:f,sessionTitle:x,t:i,onClose:o}){const h=l.useRef(null),j=C(o,h),[n,w]=l.useState("unstaged"),[d,g]=l.useState({unstaged:E,staged:E}),[u,y]=l.useState(null),[p,b]=l.useState(null),[k,N]=l.useState(!1),[S,m]=l.useState(null),c=d[n],v=l.useCallback(async s=>{g(a=>({...a,[s]:{loading:!0,files:a[s].files,error:null}}));try{const a=await t.request({action:"session.gitDiff.list",id:t.makeId("gitDiffList"),sessionId:f,scope:s});g(r=>({...r,[s]:{loading:!1,files:a.files,error:null}}))}catch(a){g(r=>({...r,[s]:{loading:!1,files:null,error:a instanceof Error?a.message:String(a)}}))}},[t,f]);l.useEffect(()=>{!d[n].files&&!d[n].loading&&!d[n].error&&v(n)},[n,d,v]),l.useEffect(()=>{y(null),b(null),m(null)},[n]),l.useEffect(()=>{if(!u){b(null),m(null);return}let s=!1;return N(!0),m(null),t.request({action:"session.gitDiff.file",id:t.makeId("gitDiffFile"),sessionId:f,scope:n,path:u}).then(a=>{s||(b(a),N(!1))}).catch(a=>{s||(m(a instanceof Error?a.message:String(a)),N(!1))}),()=>{s=!0}},[t,f,n,u]);const P=l.useMemo(()=>{const s=a=>a?a.reduce((r,D)=>({adds:r.adds+D.additions,dels:r.dels+D.deletions,count:r.count+1}),{adds:0,dels:0,count:0}):{adds:0,dels:0,count:0};return{unstaged:s(d.unstaged.files),staged:s(d.staged.files)}},[d]);return e.jsxs("div",{"aria-labelledby":"diff-drawer-title","aria-modal":"true",className:"diff-drawer",ref:j,role:"dialog",tabIndex:-1,children:[e.jsx("div",{className:"diff-drawer-backdrop",onClick:o,"aria-hidden":"true"}),e.jsxs("div",{className:"diff-drawer-panel",children:[e.jsxs("header",{className:"diff-drawer-header",children:[e.jsxs("div",{children:[e.jsx("strong",{id:"diff-drawer-title",children:i.changes}),e.jsx("span",{children:x})]}),e.jsx("button",{"aria-label":i.closeChanges,className:"icon-button",onClick:o,ref:h,type:"button",children:e.jsx(F,{"aria-hidden":"true"})})]}),e.jsx("div",{className:"diff-tabs",role:"tablist",children:["unstaged","staged"].map(s=>{const a=P[s],r=n===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":r,className:`diff-tab ${r?"active":""}`,onClick:()=>w(s),children:[e.jsx("span",{className:"diff-tab-label",children:s==="unstaged"?i.workingChanges:i.stagedChanges}),a.count>0?e.jsxs("span",{className:"diff-tab-meta",children:[e.jsxs("span",{className:"diff-add",children:["+",a.adds]}),e.jsxs("span",{className:"diff-del",children:["-",a.dels]})]}):null]},s)})}),e.jsxs("div",{className:"diff-body",children:[e.jsxs("aside",{className:"diff-files","aria-label":i.changedFiles,children:[c.loading&&!c.files?e.jsx("p",{className:"diff-empty",children:i.loading}):null,c.error?e.jsx("p",{className:"diff-empty diff-error",children:c.error}):null,c.files&&c.files.length===0?e.jsx("p",{className:"diff-empty",children:i.noChanges}):null,c.files?.map(s=>e.jsxs("button",{type:"button",className:`diff-file ${u===s.path?"active":""}`,onClick:()=>y(s.path),children:[e.jsx("span",{className:`diff-status diff-status-${s.status}`,children:s.status}),e.jsx("span",{className:"diff-file-path",title:s.path,children:s.path}),e.jsxs("span",{className:"diff-file-stats",children:[s.binary?e.jsx("span",{className:"diff-binary",children:"bin"}):null,!s.binary&&s.additions>0?e.jsxs("span",{className:"diff-add",children:["+",s.additions]}):null,!s.binary&&s.deletions>0?e.jsxs("span",{className:"diff-del",children:["-",s.deletions]}):null]})]},s.path))]}),e.jsx("section",{className:"diff-patch","aria-label":i.fileDiff,children:u?k?e.jsx("p",{className:"diff-empty",children:i.loadingPatch}):S?e.jsx("p",{className:"diff-empty diff-error",children:S}):p?.binary?e.jsx("p",{className:"diff-empty",children:i.binaryDiffUnavailable}):p?e.jsx(T,{patch:p.patch,truncated:p.truncated,truncatedLabel:i.patchTruncated}):null:e.jsxs("div",{className:"diff-empty",children:[e.jsx(W,{"aria-hidden":"true"}),e.jsx("p",{children:i.selectFileForDiff})]})})]})]})]})}function T({patch:t,truncated:f,truncatedLabel:x}){const i=l.useMemo(()=>t.split(`
2
2
  `),[t]);return e.jsxs("div",{className:"diff-patch-view",children:[i.map((o,h)=>{const j=L(o);return e.jsx("div",{className:`diff-line ${j}`,children:e.jsx("span",{className:"diff-line-text",children:o||" "})},h)}),f?e.jsx("p",{className:"diff-empty",children:x}):null]})}function L(t){return t.startsWith("diff ")||t.startsWith("index ")||t.startsWith("---")||t.startsWith("+++")?"header":t.startsWith("@@")?"hunk":t.startsWith("+")?"add":t.startsWith("-")?"del":"ctx"}export{q as DiffDrawer};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-O7DHMXV3-D0ujIgIK.js","assets/index-CXts92Zv.js","assets/index-D8mZeSsk.css","assets/App-1V1UoQkP.js","assets/mermaid-O7DHMXV3-BPtfCfol.css"])))=>i.map(i=>d[i]);
2
+ import{c as b,j as e,r as v,_ as C,D as _}from"./index-CXts92Zv.js";import{L as P,R as M,p as m,a as T,j as D,b as g,c as u,d as E,e as I,g as L}from"./App-1V1UoQkP.js";import{F as y}from"./file-text-NAVq0aqX.js";const z=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],R=b("image",z);const S=[["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"}]],U=b("save",S);function V({cwd:n,entries:i,error:t,loaded:l,loading:c,path:s,t:d,onPathChange:a,onListDirectory:o,onOpenRemoteFile:x}){return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"field",children:[e.jsx("span",{children:d.path}),e.jsxs("div",{className:"field-row",children:[e.jsx("input",{value:s,onChange:r=>a(r.target.value)}),e.jsx("button",{className:"icon-button",onClick:()=>o(),type:"button",children:c?e.jsx(P,{"aria-hidden":"true"}):e.jsx(M,{"aria-hidden":"true"})})]})]}),t?e.jsx("p",{className:"empty-copy",children:t}):null,c?e.jsx("p",{className:"empty-copy",children:d.loadingFiles}):null,e.jsxs("div",{className:"file-list tree-list",children:[m(s)?e.jsxs("button",{onClick:()=>o(m(s)??s),type:"button",children:[e.jsx(T,{"aria-hidden":"true"}),".."]}):null,i.map(r=>{const h=D(s,r.name);return e.jsxs("button",{onClick:()=>r.isDirectory?o(h):x(h,n),type:"button",children:[r.isDirectory?e.jsx(g,{"aria-hidden":"true"}):e.jsx(y,{"aria-hidden":"true"}),r.name]},`${r.name}:${r.isDirectory}`)})]}),l&&!c&&!t&&i.length===0?e.jsx("p",{className:"empty-copy",children:d.noFilesInDirectory}):null]})}const $=v.lazy(()=>C(()=>import("./mermaid-O7DHMXV3-D0ujIgIK.js").then(n=>n.a),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.MessageMarkdown})));function F({file:n,mode:i,onModeChange:t,onOpenRemoteFile:l,onTextChange:c}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"segmented editor-mode-tabs",children:[e.jsx("button",{className:i==="edit"?"selected":"",onClick:()=>t("edit"),type:"button",children:"Editor"}),e.jsx("button",{className:i==="preview"?"selected":"",onClick:()=>t("preview"),type:"button",children:"Preview"}),e.jsx("button",{className:i==="source"?"selected":"",onClick:()=>t("source"),type:"button",children:"Source"})]}),i==="edit"?e.jsx("textarea",{className:"remote-editor",value:n.text,onChange:s=>c(s.target.value),rows:14}):i==="preview"?e.jsx("div",{className:"remote-markdown-preview",children:e.jsx(v.Suspense,{fallback:e.jsx("pre",{className:"json-box source-viewer",children:n.text}),children:e.jsx($,{content:n.text,baseCwd:n.cwd,onOpenRemoteFile:l})})}):e.jsx("pre",{className:"json-box source-viewer",children:n.text})]})}function B({busy:n,cwd:i,directory:t,newDirName:l,remoteFileMode:c,remoteFile:s,remoteFileConflict:d,t:a,onCreateDirectory:o,onDirectoryPathChange:x,onDownloadRemoteFile:r,onListDirectory:h,onNewDirNameChange:N,onOpenRemoteFile:j,onRemoteFileModeChange:w,onRemoteFileTextChange:k,onSaveRemoteFile:p}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section",children:[e.jsx("h2",{children:a.fileTree}),e.jsx(V,{cwd:i,entries:t.entries,error:t.error,loaded:t.loaded,loading:t.loading,path:t.path,t:a,onListDirectory:h,onOpenRemoteFile:j,onPathChange:x}),e.jsxs("div",{className:"field-row",children:[e.jsx("input",{value:l,onChange:f=>N(f.target.value),placeholder:a.newFolder}),e.jsxs("button",{className:"icon-text-button",onClick:o,type:"button",disabled:!l.trim(),children:[e.jsx(g,{"aria-hidden":"true"}),a.create]})]})]}),e.jsxs("section",{className:"control-section remote-file-section",children:[e.jsx("h2",{children:a.remoteFile}),s?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"file-title",children:[s.kind==="image"?e.jsx(R,{"aria-hidden":"true"}):e.jsx(y,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:u(s.path)}),e.jsxs("span",{children:[s.contentType," · ",E(s.size)]})]})]}),e.jsxs("div",{className:"attention-actions",children:[e.jsxs("button",{className:"icon-text-button",onClick:r,type:"button",children:[e.jsx(_,{"aria-hidden":"true"}),a.download]}),e.jsxs("button",{className:"icon-text-button",onClick:()=>navigator.clipboard?.writeText(s.path),type:"button",children:[e.jsx(I,{"aria-hidden":"true"}),a.copyPath]})]}),s.kind==="text"?e.jsxs(e.Fragment,{children:[e.jsx(F,{file:s,mode:c,onModeChange:w,onOpenRemoteFile:j,onTextChange:k}),e.jsxs("button",{className:"primary-button full-width",disabled:!s.dirty||n,onClick:()=>p(),type:"button",children:[e.jsx(U,{"aria-hidden":"true"}),a.saveFile]}),d?e.jsxs("div",{className:"notice warning inline-notice",children:[e.jsx(L,{"aria-hidden":"true"}),e.jsx("span",{children:a.remoteFileConflict(s.path)}),e.jsx("button",{className:"danger-button",disabled:n,onClick:()=>window.confirm(a.confirmOverwrite(u(s.path)))&&p({force:!0}),type:"button",children:a.forceSave})]}):null]}):s.kind==="image"&&s.objectUrl?e.jsx("img",{className:"remote-image",src:s.objectUrl,alt:u(s.path)}):e.jsx("p",{className:"empty-copy",children:a.binaryPreviewUnavailable})]}):e.jsx("p",{className:"empty-copy",children:a.selectRemoteFile})]})]})}export{B as FilesControlPanel};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index-CXts92Zv.js";import{C as i,F as o}from"./App-1V1UoQkP.js";function t({language:s,t:a,onLanguageChange:l}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:a.language}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:a.displayLanguage}),e.jsx(i,{ariaLabel:a.displayLanguage,options:[{value:"system",label:a.followSystem},{value:"en",label:a.english},{value:"zh",label:a.chinese}],value:s,onChange:n=>l(n)})]})]}),e.jsx(o,{language:s})]})}export{t as LanguageSettingsPanel};