vibelet 1.2.205 → 1.2.207

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