@vibelet/cli 1.2.183 → 1.2.184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +4 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/inventory-scan-worker.cjs +1 -1
  4. package/dist/runtime-version.cjs +1 -1
  5. package/dist/tailcat/vibelet-tailcat-darwin-amd64 +0 -0
  6. package/dist/tailcat/vibelet-tailcat-darwin-arm64 +0 -0
  7. package/dist/tailcat/vibelet-tailcat-linux-amd64 +0 -0
  8. package/dist/tailcat/vibelet-tailcat-linux-arm64 +0 -0
  9. package/dist/tailcat/vibelet-tailcat-win32-amd64.exe +0 -0
  10. package/dist/tailcat/vibelet-tailcat-win32-arm64.exe +0 -0
  11. package/dist/vibelet.mjs +242 -125
  12. package/dist/web/assets/App-1V1UoQkP.js +12 -0
  13. package/dist/web/assets/{ArchiveSyncPanel-Dnkaspmd.js → ArchiveSyncPanel-HfbSbAJT.js} +1 -1
  14. package/dist/web/assets/{ConnectionSettingsPanel-Br7qHYvB.js → ConnectionSettingsPanel-Y8Um-67e.js} +1 -1
  15. package/dist/web/assets/{DaemonSettingsPanel-BANgginY.js → DaemonSettingsPanel--znFJEC6.js} +1 -1
  16. package/dist/web/assets/{DiffDrawer-DtuLETbo.js → DiffDrawer-BI-wtkQ_.js} +1 -1
  17. package/dist/web/assets/FilesControlPanel-B5M5ueO9.js +2 -0
  18. package/dist/web/assets/LanguageSettingsPanel-BLwzc7Dm.js +1 -0
  19. package/dist/web/assets/{NotificationSettingsPanel-CwhRDEyv.js → NotificationSettingsPanel-IgZdwrhi.js} +1 -1
  20. package/dist/web/assets/{SavedTargetsPanel-BPdvJF_n.js → SavedTargetsPanel-DggmoRgT.js} +1 -1
  21. package/dist/web/assets/ThemeSettingsPanel-vB2Ox3sA.js +1 -0
  22. package/dist/web/assets/{file-text-C6lQdXN2.js → file-text-NAVq0aqX.js} +1 -1
  23. package/dist/web/assets/highlighted-body-TPN3WLV5-ClieluW-.js +1 -0
  24. package/dist/web/assets/{index-uoLYFezU.js → index-CXts92Zv.js} +10 -10
  25. package/dist/web/assets/index-D8mZeSsk.css +1 -0
  26. package/dist/web/assets/{mermaid-O7DHMXV3-nvIRGE2J.js → mermaid-O7DHMXV3-D0ujIgIK.js} +49 -49
  27. package/dist/web/assets/splash-logo-SQcOtj-8.png +0 -0
  28. package/dist/web/index.html +2 -2
  29. package/dist/web/logo.svg +13 -0
  30. package/package.json +2 -1
  31. package/dist/web/assets/App-CVkhf43f.js +0 -11
  32. package/dist/web/assets/FilesControlPanel-DIVZPGG9.js +0 -2
  33. package/dist/web/assets/LanguageSettingsPanel-B-MqFdLO.js +0 -1
  34. package/dist/web/assets/highlighted-body-TPN3WLV5-BMFXSJ1c.js +0 -1
  35. package/dist/web/assets/index-D3gAUQHc.css +0 -1
@@ -9,8 +9,8 @@
9
9
  <link rel="manifest" href="/web/manifest.webmanifest" />
10
10
  <link rel="icon" type="image/svg+xml" href="/web/icon.svg" />
11
11
  <title>Vibelet Web</title>
12
- <script type="module" crossorigin src="/web/assets/index-uoLYFezU.js"></script>
13
- <link rel="stylesheet" crossorigin href="/web/assets/index-D3gAUQHc.css">
12
+ <script type="module" crossorigin src="/web/assets/index-CXts92Zv.js"></script>
13
+ <link rel="stylesheet" crossorigin href="/web/assets/index-D8mZeSsk.css">
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
2
+ <defs>
3
+ <linearGradient id="vibelet-gradient" x1="16" y1="14" x2="112" y2="116" gradientUnits="userSpaceOnUse">
4
+ <stop stop-color="#b978d0" />
5
+ <stop offset="1" stop-color="#e69ab0" />
6
+ </linearGradient>
7
+ </defs>
8
+ <circle cx="64" cy="66" r="58" fill="url(#vibelet-gradient)" />
9
+ <circle cx="64" cy="66" r="54" fill="none" stroke="#fff" stroke-opacity=".28" stroke-width="2" />
10
+ <path d="M37 42 64 96 91 42" fill="none" stroke="#fffaf5" stroke-linecap="round" stroke-linejoin="round" stroke-width="17" />
11
+ <circle cx="102" cy="23" r="11" fill="#fffaf5" />
12
+ <circle cx="102" cy="23" r="6" fill="#ea9999" />
13
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibelet/cli",
3
- "version": "1.2.183",
3
+ "version": "1.2.184",
4
4
  "description": "Cross-platform CLI for installing and running the Vibelet daemon",
5
5
  "homepage": "https://vibelet.icu",
6
6
  "files": [
@@ -8,6 +8,7 @@
8
8
  "dist/index.cjs",
9
9
  "dist/inventory-scan-worker.cjs",
10
10
  "dist/runtime-version.cjs",
11
+ "dist/tailcat",
11
12
  "dist/web",
12
13
  "README.md",
13
14
  "package.json"
@@ -1,11 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-O7DHMXV3-nvIRGE2J.js","assets/index-uoLYFezU.js","assets/index-D3gAUQHc.css","assets/mermaid-O7DHMXV3-BPtfCfol.css","assets/FilesControlPanel-DIVZPGG9.js","assets/file-text-C6lQdXN2.js","assets/ArchiveSyncPanel-Dnkaspmd.js","assets/ConnectionSettingsPanel-Br7qHYvB.js","assets/DaemonSettingsPanel-BANgginY.js","assets/LanguageSettingsPanel-B-MqFdLO.js","assets/NotificationSettingsPanel-CwhRDEyv.js","assets/SavedTargetsPanel-BPdvJF_n.js","assets/DiffDrawer-DtuLETbo.js"])))=>i.map(i=>d[i]);
2
- import{c as L,r as o,j as s,E as Xs,_ as Ye,D as Vi,n as Ki,f as Qi,p as Gi,s as Ji,a as nn,b as Yi,l as Zi,W as ws,d as vs,e as Xi,g as ea,h as ta}from"./index-uoLYFezU.js";const na=[["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=L("archive",na);const sa=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ra=L("arrow-down",sa);const ia=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],aa=L("arrow-up",ia);const oa=[["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"}]],ca=L("bot",oa);const la=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Je=L("check",la);const da=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ua=L("chevron-right",da);const fa=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ha=L("chevron-up",fa);const ma=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],pa=L("circle-dot",ma);const ga=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],ya=L("clipboard",ga);const ba=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],er=L("clock-3",ba);const xa=[["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"}]],Sa=L("code-xml",xa);const wa=[["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"}]],gt=L("copy",wa);const va=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],ks=L("corner-down-left",va);const ka=[["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"}]],Tn=L("cpu",ka);const ja=[["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"}]],tr=L("ellipsis",ja);const Ca=[["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"}]],Ia=L("eye",Ca);const Na=[["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"}]],mt=L("folder-open",Na);const Ra=[["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"}]],Ta=L("folder-plus",Ra);const Ma=[["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"}]],js=L("folder",Ma);const Aa=[["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"}]],Ea=L("funnel",Aa);const Da=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],He=L("gauge",Da);const _a=[["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"}]],nr=L("git-compare",_a);const Pa=[["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"}]],Fa=L("hash",Pa);const $a=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],La=L("info",$a);const Oa=[["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"}]],qa=L("key-round",Oa);const Ba=[["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"}]],Ha=L("keyboard",Ba);const Wa=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Cs=L("loader-circle",Wa);const za=[["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"}]],Ua=L("message-circle",za);const Va=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],sr=L("panel-left",Va);const Ka=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],rr=L("panel-right",Ka);const Qa=[["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"}]],Un=L("paperclip",Qa);const Ga=[["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"}]],Vn=L("pin",Ga);const Ja=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Fn=L("plus",Ja);const Ya=[["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"}]],pt=L("refresh-cw",Ya);const Za=[["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"}]],Xa=L("rotate-ccw",Za);const eo=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Kn=L("search",eo);const to=[["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"}]],no=L("settings",to);const so=[["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"}]],hn=L("shield-check",so);const ro=[["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"}]],ir=L("sliders-horizontal",ro);const io=[["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"}]],ao=L("sparkles",io);const oo=[["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"}]],un=L("square-terminal",oo);const co=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],lo=L("square",co);const uo=[["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"}]],fo=L("tag",uo);const ho=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Qn=L("terminal",ho);const mo=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],po=L("trash-2",mo);const go=[["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"}]],yo=L("wrench",go);const bo=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],we=L("x",bo);const xo=[["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"}]],Pt=L("zap",xo);function ar(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 Ne=".",$n="normal",So=80,wo=1600,or="vibelet.web.notificationSettings",vo="pending_local_",rt={enabled:!1,approvals:!0,questions:!0,replies:!0,hiddenOnly:!0};function Ft(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Gn(e,t=Date.now()){if(!e)return"unknown";const n=Date.parse(e);if(!Number.isFinite(n))return e;const r=t-n,i=60*1e3,a=60*i,l=24*a;return r<i?"now":r<a?`${Math.floor(r/i)}m ago`:r<l?`${Math.floor(r/a)}h ago`:`${Math.floor(r/l)}d ago`}function ko(e){if(!Number.isFinite(e))return"unknown";const t=e??0;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function qe(e){return e.customTitle||e.title||e.sessionId.slice(0,10)}function Jn(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 cr(e){const t=e;return{sessions:Array.isArray(t.sessions)?t.sessions:[],nextCursor:ar(t.nextCursor),inventoryVersion:t.inventoryVersion,inventoryBackfillInFlight:t.inventoryBackfillInFlight,folderCounts:t.folderCounts}}function jo(e){const t=e;return typeof t.sessionId=="string"?t.sessionId:null}function Co(e){const t=e;return typeof t.path=="string"?t.path:null}function mn(e){return e.split("/").filter(Boolean).at(-1)??e}function lr(e){return Object.entries(e).length===0?"No structured input.":JSON.stringify(e,null,2)}function Ln(e){return Object.fromEntries(e.questions.map(t=>[t.id,t.options[0]?[t.options[0].label]:[]]))}function sn(e){return e.trim()||void 0}function Is(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 rn(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 Mn=0;function Io(e=Date.now()){return Mn=(Mn+1)%1e4,`${vo}${e}_${Mn}`}function No(e){const t=e.now??new Date().toISOString();return{sessionId:e.sessionId,agent:e.agent,cwd:e.cwd||Ne,...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 Ro(e,t,n=new Date().toISOString()){return{...e,sessionId:t,lastActivityAt:n}}function An(e,t,n){if(!t||!n||t===n||!Object.hasOwn(e,t))return e;const{[t]:r,...i}=e;return{...i,[n]:r}}function Ns(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 To(e){const t=new Map;for(const n of e){const r=n.cwd||Ne;t.set(r,[...t.get(r)??[],n])}return Array.from(t.entries()).map(([n,r])=>({folder:n,sessions:r}))}function On(e,t){const n=e.replace(/\\/g,"/").replace(/\/+$/,"");return!n||n==="."?t:`${n}/${t}`}function Rs(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 Mo(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 Ao(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 an(e,t){return e.get(t)||void 0}function Eo(e,t){return`${e.replace(/[<>:"/\\|?*\u0000-\u001F]/g," ").replace(/\s+/g," ").trim().slice(0,80)||t.slice(0,12)||"session"}.txt`}function Do(e,t){const n=[`# ${qe(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 dr(e){const t=[`cd ${_o(e.cwd||Ne)} &&`],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 _o(e){return/^[a-zA-Z0-9._/~-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Po(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 Fo(e=window.localStorage){try{const t=e.getItem(or);if(!t)return{...rt};const n=JSON.parse(t);return Ft(n)?{enabled:typeof n.enabled=="boolean"?n.enabled:rt.enabled,approvals:typeof n.approvals=="boolean"?n.approvals:rt.approvals,questions:typeof n.questions=="boolean"?n.questions:rt.questions,replies:typeof n.replies=="boolean"?n.replies:rt.replies,hiddenOnly:typeof n.hiddenOnly=="boolean"?n.hiddenOnly:rt.hiddenOnly}:{...rt}}catch{return{...rt}}}function $o(e,t=window.localStorage){t.setItem(or,JSON.stringify(e))}function qn(e=typeof Notification>"u"?void 0:Notification){return e?.permission??"unsupported"}function Lo(e,t,n=typeof document>"u"?"visible":document.visibilityState){return!(!e.enabled||t!=="granted"||e.hiddenOnly&&n==="visible")}function Oo(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??qn(),l=n.visibilityState??(typeof document>"u"?"visible":document.visibilityState);if(!Lo(i,a,l))return!1;const c=new r(e,{body:t,tag:n.tag});return n.onClick&&(c.onclick=n.onClick),!0}function qo(e,t={}){const n=new Set,r={},i={},a={};for(const C of e.sessions)(C.runtime.isResponding||C.runtime.state==="daemonActive")&&n.add(C.sessionId);for(const C of e.pendingApprovals??[])r[C.sessionId]={type:"approval.request",...C};for(const C of e.pendingQuestions??[])i[C.sessionId]={type:"question.request",...C};let l=null,c,b,h,g,k,f;if(e.activeSession){const C=e.activeSession,N=e.sessions.find(d=>d.sessionId===C.sessionId);l=C.sessionId,c=C.agent,b=N?.cwd||t.currentCwd||Ne,h=C.approvalMode??N?.approvalMode??$n,g=C.approvalMode??null;const v=C.messages??[];if(k=C.partialReplyText?Jn(v,C.partialReplyText):v,(C.isResponding||C.externallyResponding)&&n.add(C.sessionId),C.pendingApproval&&(r[C.sessionId]={type:"approval.request",sessionId:C.sessionId,...C.pendingApproval}),C.pendingQuestion){const d={type:"question.request",sessionId:C.sessionId,...C.pendingQuestion};i[C.sessionId]=d,f=Ln(d)}C.pendingQueue?.length&&(a[C.sessionId]=C.pendingQueue)}else{const C=t.currentActiveSessionId??null;if(C){const N=e.sessionAliases?.[C];N?l=N:e.sessions.some(v=>v.sessionId===C)&&(l=C)}l=l??e.sessions[0]?.sessionId??null}return{page:{sessions:e.sessions,nextCursor:ar(e.nextCursor),inventoryVersion:e.inventoryVersion,inventoryBackfillInFlight:e.inventoryBackfillInFlight},activeSessionId:l,activeAgent:c,activeCwd:b,activeApprovalMode:h,activeApprovalOverride:g,messages:k,respondingSessionIds:Array.from(n),pendingApprovals:r,pendingQuestions:i,pendingQueues:a,questionAnswers:f}}function $t(e,t=n=>window.confirm(n)){return t(`${e}
4
-
5
- This action cannot be undone from Vibelet Web.`)}function Ts(e,t){return e==="subscriptionRequired"?t?"Agent skills require an active Pro subscription.":"Terminal takeover requires an active Pro subscription.":e==="skillNotFound"?"Skill not found on the paired computer.":e==="skillResolveFailed"?"Could not load the skill on the paired computer.":e}function Bo({activeSession:e,busy:t,controlsOpen:n,pendingActionsCount:r,t:i,onOpenControls:a,onRefreshSessions:l,onRestoreSnapshot:c,onToggleArchived:b,onTogglePinned:h,onViewChanges:g}){const[k,f]=o.useState(!1),C=o.useRef(null);o.useEffect(()=>{if(!k)return;const v=j=>{j.target instanceof Node&&!C.current?.contains(j.target)&&f(!1)},d=j=>{j.key==="Escape"&&f(!1)};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",d),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",d)}},[k]);const N=v=>{f(!1),v()};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(pt,{"aria-hidden":"true"})}),s.jsxs("button",{"aria-expanded":n,"aria-label":r>0?`${i.workspaceTools}, ${r} ${i.pendingActions}`:i.workspaceTools,className:`header-tool-button ${n?"selected":""}`,onClick:a,type:"button",children:[s.jsx(rr,{"aria-hidden":"true"}),s.jsx("span",{children:i.workspaceTools}),r>0?s.jsx("strong",{"aria-hidden":"true",children:r}):null]}),e?s.jsxs("div",{className:"header-more-wrap",ref:C,children:[s.jsx("button",{"aria-expanded":k,"aria-haspopup":"menu","aria-label":i.moreActions,className:"icon-button",onClick:()=>f(v=>!v),title:i.moreActions,type:"button",children:s.jsx(tr,{"aria-hidden":"true"})}),k?s.jsxs("div",{className:"header-action-menu",role:"menu",children:[s.jsxs("button",{onClick:()=>N(()=>g(e.sessionId)),role:"menuitem",type:"button",children:[s.jsx(nr,{"aria-hidden":"true"}),s.jsx("span",{children:i.viewChanges})]}),s.jsxs("button",{disabled:t,onClick:()=>N(h),role:"menuitem",type:"button",children:[s.jsx(Vn,{"aria-hidden":"true"}),s.jsx("span",{children:e.pinned?i.unpin:i.pin})]}),s.jsxs("button",{disabled:t,onClick:()=>N(b),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:()=>N(c),role:"menuitem",type:"button",children:[s.jsx(Xa,{"aria-hidden":"true"}),s.jsx("span",{children:i.restoreSnapshot})]}),s.jsxs("button",{onClick:()=>N(l),role:"menuitem",type:"button",children:[s.jsx(pt,{"aria-hidden":"true"}),s.jsx("span",{children:i.refreshSessions})]})]}):null]}):null]})}const Ho=/^[A-Za-z][A-Za-z0-9_-]*$/,Wo=[{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 ur(e){return Wo.filter(t=>!e||t.agents.includes(e))}function Yn(e){return e.trim().toLowerCase()}function cn(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&&!Ho.test(n)?null:{start:0,end:e.length,keyword:Yn(n)}}function zo(e,t,n=8){const r=Yn(t);return(r?e.filter(a=>a.name.includes(r)||a.title.toLowerCase().includes(r)).sort((a,l)=>Ms(a,r)-Ms(l,r)):[...e]).slice(0,n)}function Ms(e,t){return e.name===t?0:e.name.startsWith(t)?1:e.name.includes(t)?2:3}function Uo(e,t,n){return`${e.slice(0,t.start)}${fr(n,"")}${e.slice(t.end)}`}function Vo(e,t,n){return t?Uo(e,t,n):`${fr(n,e)}${e}`}function fr(e,t){const n=t.length>0,r=n&&!/^\s/.test(t),i=!!(e.argsHint&&!n);return`/${e.name}${i||r?" ":""}`}function Ko(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=Yn(r[1]??""),a=ur(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 Qo(e){return e.startsWith("//")?e.slice(1):e}function Go(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 Jo(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 As(e){return e==="subscriptionRequired"?"Error: Agent commands require an active Pro subscription.":`Error: ${e||"Command failed."}`}function Yo(e,t){return!t||!cn(e)?e:t.draftBeforeInsertion}const Zo=/^[A-Za-z_][A-Za-z0-9._:-]*$/,Xo=/(?:^|\s)\$([A-Za-z_][A-Za-z0-9._:-]*|)$/;function qt(e){return e.trim().toLowerCase()}function ec(e){const t=e.trim(),n=/^\$([A-Za-z_][A-Za-z0-9._:-]*)(?:\s+([\s\S]*))?$/.exec(t);return n?{name:qt(n[1]??""),...n[2]?.trim()?{args:n[2].trim()}:{}}:null}function ln(e){const t=Xo.exec(e);if(!t||t.index+t[0].length!==e.length)return null;const n=t[1]??"";if(n&&!Zo.test(n))return null;const r=t[0].lastIndexOf("$");return{start:t.index+r,end:e.length,keyword:qt(n)}}function tc(e,t,n){return`${e.slice(0,t.start)}$${qt(n)} ${e.slice(t.end)}`}function nc(e,t){if(!t)return e;const n=ln(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 sc(e,t,n=8){const r=qt(t);return(r?e.filter(a=>qt(a.name).includes(r)):e).slice(0,n)}function Et({icon:e,label:t,menuLabel:n,options:r,value:i,onSelect:a,align:l="left",disabled:c,selected:b,wide:h}){const[g,k]=o.useState(!1);return s.jsxs("div",{className:"composer-menu",onBlur:f=>{const C=f.relatedTarget;(!C||!f.currentTarget.contains(C))&&k(!1)},onKeyDown:f=>{f.key==="Escape"&&k(!1)},children:[s.jsxs("button",{"aria-expanded":g,"aria-haspopup":"menu",className:`composer-option-button ${g||b?"selected":""}`,disabled:c,onClick:()=>k(f=>!f),title:n,type:"button",children:[s.jsx(e,{"aria-hidden":"true"}),s.jsx("span",{children:t}),s.jsx(ha,{"aria-hidden":"true"})]}),g?s.jsx("div",{"aria-label":n,className:`composer-option-popover ${h?"wide":""} ${l==="right"?"align-right":""}`,role:"menu",children:r.map(f=>{const C=f.icon,N=f.value===i;return s.jsxs("button",{"aria-checked":N,className:N?"selected":"",disabled:f.disabled,onClick:()=>{a(f.value),k(!1)},role:"menuitemradio",title:f.description??f.label,type:"button",children:[s.jsx("span",{className:"composer-menu-icon",children:C?s.jsx(C,{"aria-hidden":"true"}):N?s.jsx(Je,{"aria-hidden":"true"}):null}),s.jsxs("span",{children:[s.jsx("strong",{children:f.label}),f.description?s.jsx("small",{children:f.description}):null]}),N?s.jsx(Je,{className:"composer-menu-check","aria-hidden":"true"}):null]},f.value)})}):null]})}function rc({visible:e,skills:t,onClose:n,onSelect:r,t:i}){return e?s.jsxs("div",{className:"skill-suggestion-popover",children:[s.jsxs("header",{children:[s.jsx("strong",{children:i.skills}),s.jsx("button",{type:"button",className:"icon-button",onClick:n,title:i.closeSkills,children:s.jsx(we,{"aria-hidden":"true"})})]}),t.length?s.jsx("div",{className:"skill-suggestion-list",children:t.map(a=>s.jsxs("button",{onClick:()=>r(a),title:a.description??a.name,type:"button",children:[s.jsxs("span",{children:[s.jsxs("strong",{children:["$",a.name]}),a.description?s.jsx("small",{children:a.description}):null]}),s.jsx("em",{children:a.source})]},`${a.source}:${a.name}`))}):s.jsx("p",{children:i.noSkillsFound})]}):null}function ic({visible:e,commands:t,onClose:n,onSelect:r,t:i}){return e?s.jsxs("div",{className:"skill-suggestion-popover command-suggestion-popover",children:[s.jsxs("header",{children:[s.jsx("strong",{children:i.commands}),s.jsx("button",{type:"button",className:"icon-button",onClick:n,title:i.closeCommands,children:s.jsx(we,{"aria-hidden":"true"})})]}),t.length?s.jsx("div",{className:"skill-suggestion-list",children:t.map(a=>s.jsxs("button",{onClick:()=>r(a),title:a.description,type:"button",children:[s.jsxs("span",{children:[s.jsxs("strong",{children:["/",a.name]}),s.jsx("small",{children:a.argsHint?`${a.title} ${a.argsHint}`:a.title})]}),s.jsx("em",{children:a.source})]},a.name))}):s.jsx("p",{children:i.noCommandsFound})]}):null}function ac(e){return[{value:"normal",label:e.approvalNormal,description:e.approvalNormalDescription,icon:hn},{value:"plan",label:e.approvalPlan,description:e.approvalPlanDescription,icon:ir},{value:"acceptEdits",label:e.approvalEdits,description:e.approvalEditsDescription,icon:Je},{value:"autoApprove",label:e.approvalAuto,description:e.approvalAutoDescription,icon:Pt}]}function oc(e){return[{value:"",label:e.effort,description:e.useDaemonDefault,icon:He},{value:"minimal",label:e.effortMinimal,icon:He},{value:"low",label:e.effortLow,icon:He},{value:"medium",label:e.effortMedium,icon:He},{value:"high",label:e.effortHigh,icon:He},{value:"xhigh",label:e.effortXHigh,icon:He},{value:"max",label:e.effortMax,icon:He},{value:"ultra",label:e.effortUltra,icon:He}]}function cc({activeQueue:e,agent:t,attachments:n,approvalMode:r,activeModelOptions:i,busy:a,draft:l,effort:c,fastMode:b,model:h,phase:g,quickReplies:k,sendShortcut:f,skills:C,uploadBusy:N,t:v,onApprovalModeChange:d,onCancelQueuedTurn:j,onDraftChange:m,onEffortChange:w,onFastModeChange:y,onModelChange:p,onRefreshSkills:R,onRemoveAttachment:_,onSendShortcutChange:z,onSubmit:ue,onUploadFiles:J}){const ae=o.useRef(null),O=o.useRef(null),[oe,de]=o.useState(!1),[ne,ve]=o.useState(!1),[D,A]=o.useState(!1),[W,$]=o.useState(!1),[ce,ye]=o.useState(""),[Y,K]=o.useState(""),B=o.useRef(null),Z=o.useRef(null),se=g==="connected",fe=o.useMemo(()=>ur(t),[t]),X=o.useMemo(()=>cn(l),[l]),U=X?`${X.start}:${X.end}:${X.keyword}`:"",te=!!(W||X&&Y!==U),Ce=o.useMemo(()=>zo(fe,X?.keyword??"",8),[fe,X?.keyword]),M=o.useMemo(()=>ln(l),[l]),V=M?`${M.start}:${M.end}:${M.keyword}`:"",_e=!!(!te&&(D||M&&ce!==V)),Pe=o.useMemo(()=>sc(C,M?.keyword??"",8),[M?.keyword,C]),We=o.useMemo(()=>ac(v),[v]),be=o.useMemo(()=>oc(v),[v]),Re=i.find(S=>S.value===h)?.label??(h||v.defaultOption),me=We.find(S=>S.value===r)?.label??r,Fe=be.find(S=>S.value===c)?.label??c,$e=f==="enter"?v.sendShortcutEnter:v.sendShortcutModEnter,ze=o.useMemo(()=>[{value:"enter",label:v.sendShortcutEnter,description:v.sendShortcutEnterDescription,icon:ks},{value:"modEnter",label:v.sendShortcutModEnter,description:v.sendShortcutModEnterDescription,icon:Ha}],[v]),pe=i.map(S=>({value:S.value,label:S.label,description:S.desc,icon:Tn}));pe.some(S=>S.value==="")||pe.unshift({value:"",label:v.defaultOption,description:v.useDaemonDefaultModel,icon:Tn}),o.useEffect(()=>{M||(B.current=null,ye(""),A(!1))},[M]),o.useEffect(()=>{X||(Z.current=null,K(""),$(!1))},[X]);const Le=async(S,F)=>{await J(S),F.value=""},xe=async S=>{S.preventDefault(),de(!1),se&&await J(S.dataTransfer.files)},Ze=async S=>{!se||!S.clipboardData.files.length||await J(S.clipboardData.files)},Te=()=>{const S=nc(l,B.current);B.current=null,S!==l&&m(S),V&&ye(V),A(!1),O.current?.focus()},Ue=()=>{const S=Yo(l,Z.current);Z.current=null,S!==l&&m(S),U&&K(U),$(!1),O.current?.focus()},Ve=()=>{if(te){Ue();return}K(""),!cn(l)&&l.length===0&&(Z.current={draftBeforeInsertion:l},m("/")),$(!0),O.current?.focus()},ke=S=>{const F=cn(l),Q=Vo(l,F,S);m(Q),Z.current=null,$(!1),K(""),O.current?.focus()},Me=()=>{if(_e){Te();return}if(R(),ye(""),!ln(l)){const S=l.length===0||/\s$/.test(l)?"":" ";B.current={draftBeforeInsertion:l,triggerStart:l.length+S.length},m(`${l}${S}$`)}A(!0),O.current?.focus()},x=S=>{const F=ln(l),Q=F?tc(l,F,S.name):l.trim().length?`${l}${/\s$/.test(l)?"":" "}$${S.name} `:`$${S.name} `;m(Q),B.current=null,A(!1),ye(""),O.current?.focus()},P=S=>{S.key!=="Enter"||S.nativeEvent.isComposing||!(f==="enter"?!S.shiftKey:S.metaKey||S.ctrlKey)||(S.preventDefault(),ue())};return s.jsxs("form",{className:`composer ${oe?"dragging":""}`,onDragEnter:S=>{S.preventDefault(),de(!0)},onDragLeave:()=>de(!1),onDragOver:S=>S.preventDefault(),onDrop:S=>{xe(S)},onSubmit:S=>{ue(S)},children:[e.length?s.jsxs("div",{className:"composer-queue-banner",children:[s.jsx(er,{"aria-hidden":"true"}),s.jsxs("div",{children:[s.jsxs("strong",{children:[e.length," queued"]}),s.jsx("span",{children:e[0]?.content??"A turn is waiting for this session."})]}),s.jsxs("button",{className:"icon-text-button",disabled:a||!e[0],onClick:()=>e[0]&&j(e[0]),type:"button",children:[s.jsx(we,{"aria-hidden":"true"}),"Withdraw"]})]}):null,ne&&k.length?s.jsx("div",{className:"quick-reply-row",children:k.slice(0,6).map(S=>s.jsx("button",{onClick:()=>m(l?`${l}
6
- ${S}`:S),type:"button",children:S},S))}):null,s.jsx(rc,{visible:_e,skills:Pe,onClose:Te,onSelect:x,t:v}),s.jsx(ic,{visible:te,commands:Ce,onClose:Ue,onSelect:ke,t:v}),s.jsx("textarea",{ref:O,value:l,onChange:S=>m(S.target.value),onPaste:S=>{Ze(S)},onKeyDown:P,placeholder:v.messagePlaceholder,rows:3,disabled:!se}),s.jsxs("div",{className:"composer-toolbar",children:[s.jsxs("div",{className:"composer-leading-controls",children:[s.jsx("button",{type:"button",className:"icon-button",onClick:()=>ae.current?.click(),title:v.uploadFiles,disabled:!se||N,children:s.jsx(Fn,{"aria-hidden":"true"})}),k.length?s.jsx("button",{className:`icon-button ${ne?"selected":""}`,type:"button",title:ne?v.hideQuickReplies:v.showQuickReplies,onClick:()=>ve(S=>!S),children:s.jsx(ao,{"aria-hidden":"true"})}):null,s.jsx("button",{className:`icon-button ${_e?"selected":""}`,type:"button",title:v.skills,onClick:Me,disabled:!se||N,children:s.jsx(Pt,{"aria-hidden":"true"})}),s.jsx("button",{className:`icon-button ${te?"selected":""}`,type:"button",title:v.commands,onClick:Ve,disabled:!se||N,children:s.jsx(un,{"aria-hidden":"true"})})]}),s.jsx("input",{ref:ae,type:"file",multiple:!0,hidden:!0,onChange:S=>{Le(S.currentTarget.files,S.currentTarget)}}),s.jsxs("div",{className:"composer-control-strip",children:[s.jsx(Et,{icon:hn,label:me,menuLabel:v.approvalMode,options:We,value:r,onSelect:d,wide:!0}),s.jsx(Et,{icon:Tn,label:Re,menuLabel:v.model,options:pe,value:h,onSelect:p,align:"right",wide:!0}),s.jsx(Et,{icon:He,label:Fe||v.effort,menuLabel:v.effort,options:be,value:c,onSelect:w,align:"right"}),s.jsx(Et,{icon:Pt,label:b?v.fast:v.normal,menuLabel:v.fastMode,options:[{value:"off",label:v.normal,description:v.standardExecution,icon:He},{value:"on",label:v.fast,description:v.preferFasterResponses,icon:Pt}],value:b?"on":"off",onSelect:S=>y(S==="on"),align:"right",selected:b,wide:!0}),s.jsx(Et,{icon:ks,label:$e,menuLabel:v.sendShortcut,options:ze,value:f,onSelect:z,align:"right",wide:!0})]}),s.jsx("button",{type:"submit",className:"send-button",disabled:!se||a||!l.trim(),"aria-label":v.send,title:v.send,children:s.jsx(aa,{"aria-hidden":"true"})})]}),n.length||N?s.jsx("div",{className:"attachment-row",children:n.length?s.jsx("div",{className:"attachment-list",children:n.map(S=>s.jsxs("span",{children:[s.jsx(Un,{"aria-hidden":"true"}),S.name||mn(S.path),s.jsx("small",{children:ko(S.size)}),s.jsx("button",{type:"button",onClick:()=>_(S.path),title:v.removeAttachment,children:s.jsx(we,{"aria-hidden":"true"})})]},S.path))}):s.jsxs("span",{className:"attachment-empty",children:[s.jsx("span",{className:"loading-spinner small","aria-hidden":"true"}),v.uploading]})}):null]})}const lc=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Es(e){return Array.from(e.querySelectorAll(lc)).filter(t=>!t.hidden&&t.getAttribute("aria-hidden")!=="true")}function Zn(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??Es(a)[0]??a).focus();const b=h=>{if(h.key==="Escape"){h.preventDefault(),i.current();return}if(h.key!=="Tab")return;const g=Es(a);if(!g.length){h.preventDefault(),a.focus();return}const k=g[0],f=g.at(-1);h.shiftKey&&(document.activeElement===k||!a.contains(document.activeElement))?(h.preventDefault(),f.focus()):!h.shiftKey&&document.activeElement===f&&(h.preventDefault(),k.focus())};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),requestAnimationFrame(()=>l?.focus())}},[n,t]),r}function dc({cwd:e,paths:t,t:n,onClose:r,onOpenRemoteFile:i}){const a=o.useRef(null),l=Zn(r,a,t.length>0);return t.length?s.jsxs("div",{"aria-labelledby":"attachment-preview-title","aria-modal":"true",className:"side-drawer",ref:l,role:"dialog",tabIndex:-1,children:[s.jsx("button",{className:"side-drawer-backdrop",onClick:r,type:"button","aria-label":n.closeAttachmentPreview}),s.jsxs("aside",{className:"side-drawer-panel",children:[s.jsxs("header",{className:"side-drawer-header",children:[s.jsxs("div",{children:[s.jsx("strong",{id:"attachment-preview-title",children:n.attachments}),s.jsx("span",{children:n.fileCount(t.length)})]}),s.jsx("button",{"aria-label":n.closeAttachmentPreview,className:"icon-button",onClick:r,ref:a,type:"button",children:s.jsx(we,{"aria-hidden":"true"})})]}),s.jsx("div",{className:"stack-list",children:t.map(c=>s.jsxs("button",{className:"data-row attachment-preview-row",onClick:()=>i(c,e),type:"button",children:[s.jsx(Un,{"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:mn(c)}),s.jsx("small",{children:c})]}),s.jsx(Xs,{"aria-hidden":"true"})]},c))})]})]}):null}async function uc(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 fc(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 uc(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"?Je:we;return s.jsxs("div",{className:`copy-feedback ${e.tone}`,role:"status",children:[s.jsx(t,{"aria-hidden":"true"}),e.message]})}function mc({message:e,retryLabel:t,onRetry:n}){return s.jsxs("div",{className:"notice error",children:[s.jsx(we,{"aria-hidden":"true"}),s.jsx("span",{children:e}),s.jsxs("button",{className:"icon-text-button",onClick:n,type:"button",children:[s.jsx(pt,{"aria-hidden":"true"}),t]})]})}function pc({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 Ds({failedSend:e,onRetry:t,t:n}){const r={network:n.sendFailedNetwork,timeout:n.sendFailedTimeout,permission:n.sendFailedPermission,subscription:n.sendFailedSubscription,"missing-resource":n.sendFailedMissingResource,unknown:n.sendFailedUnknown}[e.kind];return s.jsxs("div",{className:"failed-send-notice",role:"alert",children:[s.jsx(we,{"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:n.sendFailed}),r]}),s.jsxs("button",{disabled:e.retrying,onClick:t,type:"button",children:[s.jsx(pt,{"aria-hidden":"true",className:e.retrying?"spin":void 0}),e.retrying?n.retrying:n.retrySend]})]})}function gc({busy:e,label:t,stopLabel:n,onStop:r}){return s.jsxs("div",{className:"typing-line",role:"status",children:[s.jsx("span",{className:"typing-indicator","aria-hidden":"true"}),s.jsx("span",{children:t}),s.jsxs("button",{className:"stop-generating-button",disabled:e,onClick:r,type:"button",children:[s.jsx(lo,{"aria-hidden":"true"}),n]})]})}function yc({label:e,onClick:t}){return s.jsxs("button",{className:"scroll-latest-button",type:"button","aria-label":e,title:e,onClick:t,children:[s.jsx(ra,{"aria-hidden":"true"}),s.jsx("span",{children:e})]})}const bc=/\u001B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,xc=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u00AD\u061C\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFEFF]/g,Sc=new Set(["","{}","[]","null","undefined",'""']);function on(e){return e.replace(/\s+/g," ").trim()}function ie(e,t){return typeof e[t]=="string"?e[t]:""}function _s(e,t){return typeof e[t]=="number"?e[t]:void 0}function Dt(e,t){return e.length<=t?e:`${e.slice(0,t)}...`}function Dn(e){const t=[],n=ie(e,"file_path")||ie(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 wc(e){return typeof e!="string"?"":e.replace(/\r\n?/g,`
7
- `).replace(bc,"").replace(xc,"").trim()}function Xn(e){const t=wc(e);return Sc.has(t)?"":t}function vc(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"?on(n.query):"";if(r)return r;const i=typeof n.command=="string"?on(n.command):"";if(i)return i;const a=typeof n.description=="string"?on(n.description):"";if(a)return a}}catch{}return on(t)}function kc(e,t){if(!t)return[];switch((e??"").toLowerCase()){case"read":return Dn(t);case"write":{const r=Dn(t),i=ie(t,"content");return i&&r.push({label:"Content",isDiff:!0,value:"",diffNew:Dt(i,500)}),r}case"edit":{const r=Dn(t),i=ie(t,"old_string")||ie(t,"oldString"),a=ie(t,"new_string")||ie(t,"newString");return(i||a)&&r.push({label:"Change",isDiff:!0,value:"",diffOld:Dt(i,300),diffNew:Dt(a,300)}),r}case"bash":{const r=ie(t,"command");return r?[{label:"Command",value:r,isCode:!0}]:[]}case"websearch":{const r=ie(t,"query");return r?[{label:"Query",value:r}]:[]}case"webfetch":{const r=[],i=ie(t,"url");i&&r.push({label:"URL",value:i});const a=ie(t,"prompt");return a&&r.push({label:"Prompt",value:Dt(a,200)}),r}case"glob":{const r=ie(t,"pattern");return r?[{label:"Pattern",value:r}]:[]}case"grep":{const r=[],i=ie(t,"pattern");i&&r.push({label:"Pattern",value:i,isCode:!0});const a=ie(t,"path");return a&&r.push({label:"In",value:a,isFilePath:!0}),r}default:{const r=[],i=ie(t,"command");if(i)return[{label:"Command",value:i,isCode:!0}];const a=ie(t,"file_path")||ie(t,"filePath");a&&r.push({label:"Path",value:a,isFilePath:!0});const l=ie(t,"description");l&&r.push({label:"Description",value:Dt(l,200)});const c=ie(t,"query");c&&r.push({label:"Query",value:c});const b=ie(t,"url");return b&&r.push({label:"URL",value:b}),r}}}function Ps(e){return e.role==="tool"?!0:e.type!=="info"?!1:!/^Error:/i.test(e.content.trim())}function hr(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 mr(e,t){return`${e.historyKey??e.timestamp??e.toolName??e.content.slice(0,24)??"message"}:${t}`}function jc(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e[n];if(!Ps(r)){t.push({type:"message",index:n,message:r});continue}const i=[];let a=n;for(;a<e.length&&Ps(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})=>mr(c,l)).join("|")}`}),n=a-1}return t}function Cc(e,t){return e.type==="message"?e.index===t:e.entries.some(n=>n.index===t)}function Ic({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(gt,{"aria-hidden":"true"})}),s.jsx("button",{className:"icon-button",onClick:t,type:"button",title:r.closeSource,children:s.jsx(we,{"aria-hidden":"true"})})]})]}),s.jsx("pre",{className:"json-box markdown-source-box",children:i})]})}function Nc({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 Rc({message:e,onCopy:t,t:n}){const r=kc(e.toolName,e.toolInput),i=es(e.content),a=Xn(e.content),l=vc(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(Qn,{"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(gt,{"aria-hidden":"true"})})]}),r.length?s.jsx("div",{className:"tool-fields",children:r.map((b,h)=>s.jsx(Nc,{field:b},`${b.label}:${h}`))}):null,l?s.jsx("pre",{className:"json-box compact",children:a}):null]})}function pr({messages:e,onClose:t,onCopy:n,t:r}){if(!e.length)return null;const a=e.filter(h=>h.role==="tool").length||e.length,l=r.toolCallCount(a),c=hr(e),b=e.map(h=>h.content).join(`
8
-
9
- `);return s.jsxs("section",{className:"tool-inline-panel","aria-label":r.toolDetails,children:[s.jsxs("header",{className:"inline-detail-header",children:[s.jsxs("div",{className:"inline-detail-title",children:[s.jsx("strong",{children:l}),s.jsx("span",{title:c,children:c||r.toolDetail})]}),s.jsxs("div",{className:"row-actions",children:[s.jsx("button",{className:"icon-button",onClick:()=>n(b),type:"button",title:r.copyOutput,children:s.jsx(gt,{"aria-hidden":"true"})}),s.jsx("button",{className:"icon-button",onClick:t,type:"button",title:r.closeToolDetails,children:s.jsx(we,{"aria-hidden":"true"})})]})]}),s.jsx("div",{className:"tool-detail-list",children:e.map((h,g)=>s.jsx(Rc,{message:h,onCopy:n,t:r},`${h.historyKey??h.timestamp??h.toolName??"tool"}:${g}`))})]})}const Tc=o.lazy(async()=>Ye(()=>import("./mermaid-O7DHMXV3-nvIRGE2J.js").then(e=>e.a),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.MessageMarkdown})));function Mc({activeMatch:e,baseCwd:t,message:n,onCopy:r,onCloseSource:i,onCloseTool:a,onOpenAttachment:l,onOpenRemoteFile:c,onToggleSource:b,onToggleTool:h,sourceOpen:g,toolOpen:k,t:f}){const C=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:Gn(n.timestamp)}),s.jsxs("div",{className:"message-actions","aria-label":f.messageActions,role:"group",children:[s.jsx("button",{"aria-label":f.copyMessage,onClick:()=>r(n.content),title:f.copyMessage,type:"button",children:s.jsx(gt,{"aria-hidden":"true"})}),s.jsx("button",{"aria-label":f.viewMarkdownSource,"aria-expanded":g,onClick:b,title:g?f.hideMarkdownSource:f.viewMarkdownSource,type:"button",children:s.jsx(Sa,{"aria-hidden":"true"})})]})]})]}),n.role==="tool"?s.jsxs("button",{className:"tool-inline-summary","aria-expanded":k,onClick:h,type:"button",children:[s.jsxs("span",{children:[s.jsx(yo,{"aria-hidden":"true"}),n.toolName??f.tool]}),C?s.jsx("small",{children:C}):null]}):n.role==="assistant"?s.jsx(o.Suspense,{fallback:s.jsx("pre",{children:n.content}),children:s.jsx(Tc,{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(N=>s.jsxs("button",{className:"file-pill",onClick:()=>c(N,t),title:N,type:"button",children:[s.jsx(Un,{"aria-hidden":"true"}),mn(N)]},N)),s.jsxs("button",{className:"file-pill",onClick:()=>l(n.images??[]),type:"button",children:[s.jsx(Ia,{"aria-hidden":"true"}),f.preview]})]}):null,g?s.jsx(Ic,{message:n,onClose:i,onCopy:r,t:f}):null,n.role==="tool"&&k?s.jsx(pr,{messages:[n],onClose:a,onCopy:r,t:f}):null]})}function Ac({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(we,{"aria-hidden":"true"})}):null]})}function Ec({activeMatch:e,expanded:t,messages:n,onToggle:r}){const i=n.filter(c=>c.role==="tool").length||n.length,a=hr(n),l=i===1?"1 tool call":`${i} tool calls`;return s.jsxs("button",{className:`tool-group-bubble ${e?"match":""} ${t?"expanded":""}`,type:"button",onClick:r,"aria-expanded":t,"aria-label":a?`${l}: ${a}`:l,children:[s.jsxs("span",{className:"tool-group-header",children:[s.jsxs("span",{className:"tool-group-title",children:[s.jsx(Qn,{"aria-hidden":"true"}),s.jsx("strong",{children:l})]}),s.jsx(ua,{className:"tool-group-chevron","aria-hidden":"true"})]}),a?s.jsx("span",{className:"tool-group-summary",children:a}):null]})}const dn=160,Dc=120;function it(e){return Math.max(0,e-dn)}function _c(e,t){const n=t.length,[r,i]=o.useState(()=>({sessionId:e,start:it(n),total:n})),a=o.useMemo(()=>r.sessionId!==e?it(n):r.total===n||n<r.total?Math.min(r.start,it(n)):r.start+dn>=r.total?it(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(g=>({sessionId:e,start:Math.max(0,(g.sessionId===e?g.start:it(n))-Dc),total:n}))},[e,n]),c=o.useCallback(g=>{const k=t.findIndex(C=>Cc(C,g));if(k<0||k>=a&&k<a+dn)return!1;const f=Math.min(it(n),Math.max(0,k-40));return i({sessionId:e,start:f,total:n}),!0},[t,e,a,n]),b=o.useCallback(()=>{i({sessionId:e,start:it(n),total:n})},[e,n]),h=Math.min(n,a+dn);return{ensureMessageVisible:c,hiddenItemCount:a,hiddenLaterItemCount:Math.max(0,n-h),revealEarlier:l,revealLatest:b,visibleItems:t.slice(a,h)}}function Pc({activeSession:e,activeUsage:t,messages:n,renameTitle:r,busy:i,t:a,onBrowseFiles:l,onClose:c,onExport:b,onJumpToMessage:h,onRename:g,onRenameTitleChange:k,onToggleArchived:f,onTogglePinned:C,onViewChanges:N}){const[v,d]=o.useState(""),j=o.useRef(null),m=Zn(c,j),w=o.useMemo(()=>dr(e),[e]),y=o.useMemo(()=>{const R=v.trim().toLowerCase();return R?n.map((_,z)=>({message:_,index:z})).filter(({message:_})=>_.role!=="user"&&_.role!=="assistant"?!1:_.content.toLowerCase().includes(R)).slice(0,20):[]},[n,v]),p=R=>{R.preventDefault(),g()};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:qe(e),children:qe(e)})]}),s.jsx("button",{"aria-label":a.closeSessionDetails,className:"icon-button",onClick:c,ref:j,type:"button",children:s.jsx(we,{"aria-hidden":"true"})})]}),s.jsxs("form",{className:"detail-title-form",onSubmit:p,children:[s.jsx("input",{value:r,onChange:R=>k(R.target.value),placeholder:qe(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(mt,{"aria-hidden":"true"}),s.jsx("span",{children:a.workingDirectory}),s.jsx("strong",{title:e.cwd,children:e.cwd})]}),s.jsxs("div",{children:[s.jsx(Ua,{"aria-hidden":"true"}),s.jsx("span",{children:a.messages}),s.jsx("strong",{children:n.filter(R=>R.role==="user"||R.role==="assistant").length})]}),s.jsxs("div",{children:[s.jsx(Fa,{"aria-hidden":"true"}),s.jsx("span",{children:a.session}),s.jsx("strong",{title:e.sessionId,children:e.sessionId})]}),s.jsxs("div",{children:[s.jsx(Qn,{"aria-hidden":"true"}),s.jsx("span",{children:a.runtime}),s.jsx("strong",{children:e.runtime.state})]})]}),e.branch||e.diffStat?s.jsxs("button",{className:"detail-command-card",type:"button",onClick:N,children:[s.jsx(nr,{"aria-hidden":"true"}),s.jsxs("span",{children:[e.branch??a.changes,e.diffStat?` · +${e.diffStat.additions} -${e.diffStat.deletions}`:""]})]}):null,s.jsxs("label",{className:"detail-search",children:[s.jsx(Kn,{"aria-hidden":"true"}),s.jsx("input",{value:v,onChange:R=>d(R.target.value),placeholder:a.searchMessages}),v.trim()?s.jsx("small",{children:a.searchResultCount(y.length)}):null]}),v.trim()&&y.length?s.jsx("div",{className:"detail-search-results",children:y.map(({message:R,index:_})=>s.jsxs("button",{type:"button",onClick:()=>{h(_,v),c()},children:[s.jsx("span",{children:R.role}),s.jsx("strong",{children:R.content})]},`${R.historyKey??R.timestamp??_}:${_}`))}):null,v.trim()?null:s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"detail-command-card",type:"button",onClick:l,children:[s.jsx(mt,{"aria-hidden":"true"}),s.jsx("span",{children:a.browseFiles})]}),s.jsxs("button",{className:"detail-command-card",type:"button",onClick:()=>{navigator.clipboard?.writeText(w)},children:[s.jsx(ya,{"aria-hidden":"true"}),s.jsx("span",{title:w,children:w})]}),s.jsxs("div",{className:"detail-action-grid",children:[s.jsxs("button",{className:"icon-text-button",disabled:i,type:"button",onClick:C,children:[s.jsx(Vn,{"aria-hidden":"true"}),e.pinned?a.unpin:a.pin]}),s.jsxs("button",{className:"icon-text-button",disabled:i,type:"button",onClick:f,children:[s.jsx(zn,{"aria-hidden":"true"}),e.archived?a.unarchive:a.archive]}),s.jsxs("button",{className:"icon-text-button",type:"button",onClick:b,children:[s.jsx(Vi,{"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," ",Gn(e.createdAt)]})]})]})]})}function Fc({activeSession:e,activeSessionId:t,activeModelOptions:n,activeQueue:r,activeUsage:i,agent:a,approvalMode:l,attachments:c,busy:b,cwd:h,draft:g,effort:k,errorText:f,failedSend:C,fastMode:N,historyLoading:v,messages:d,model:j,phase:m,quickReplies:w,renameTitle:y,respondingSessionIds:p,sendShortcut:R,skills:_,uploadBusy:z,detailsOpen:ue,controlsOpen:J,pendingActionsCount:ae,t:O,onApprovalModeChange:oe,onBrowseFiles:de,onCancelQueuedTurn:ne,onClearInterrupt:ve,onDraftChange:D,onDetailsOpenChange:A,onEffortChange:W,onExportActiveSession:$,onFastModeChange:ce,onRetryFailedSend:ye,onModelChange:Y,onOpenRemoteFile:K,onOpenControls:B,onInterrupt:Z,onRetry:se,onRefreshSessions:fe,onRefreshSkills:X,onRenameSession:U,onRenameTitleChange:te,onRemoveAttachment:Ce,onRestoreSnapshot:M,onSendShortcutChange:V,onSubmit:_e,onToggleArchived:Pe,onTogglePinned:We,onUploadFiles:be,onViewChanges:he}){const[Re,me]=o.useState(""),[Fe,$e]=o.useState(0),[ze,pe]=o.useState(null),[Le,xe]=o.useState(null),[Ze,Te]=o.useState(!1),[Ue,Ve]=o.useState([]),ke=o.useRef(null),Me=o.useRef([]),x=o.useRef(null),P=o.useRef(null),S=o.useRef(0),F=o.useMemo(()=>jc(d),[d]),{ensureMessageVisible:Q,hiddenItemCount:ge,hiddenLaterItemCount:Xe,revealEarlier:et,revealLatest:bt,visibleItems:Ae}=_c(t,F),Ht=o.useMemo(()=>!!(C&&Ae.some(E=>E.type==="message"&&E.message.historyKey===C.historyKey)),[C,Ae]),xt=o.useRef(null),{copyText:St,feedback:gn}=fc(O.messageCopied,O.copyFailed),Oe=o.useMemo(()=>{const E=Re.trim().toLowerCase();return E?d.map((G,re)=>({index:re,message:G})).filter(({message:G})=>G.content.toLowerCase().includes(E)):[]},[Re,d]),Ee=E=>{const G=Q(E),re=()=>Me.current[E]?.scrollIntoView({behavior:"smooth",block:"center"});G?requestAnimationFrame(()=>requestAnimationFrame(re)):re()},Wt=()=>{if(!Oe.length)return;const E=Fe%Oe.length,G=Oe[E]?.index;typeof G=="number"&&Ee(G),$e(re=>(re+1)%Oe.length)},Ke=o.useCallback(()=>{const E=ke.current;E&&(E.scrollTop=E.scrollHeight,Te(!1))},[]),zt=o.useCallback((E="smooth")=>{const G=()=>{const re=ke.current;re&&(re.scrollTo({top:re.scrollHeight,behavior:E}),Te(!1))};Xe>0?(bt(),requestAnimationFrame(()=>requestAnimationFrame(G))):G()},[Xe,bt]),yn=()=>{const E=ke.current;if(!E)return;const G=E.scrollHeight-E.scrollTop-E.clientHeight;Te(G>180)},Ut=o.useMemo(()=>{const E=d.at(-1);return E?`${d.length}:${E.historyKey??""}:${E.timestamp??""}:${E.content.length}`:"0"},[d]);o.useLayoutEffect(()=>{const E=xt.current,G=ke.current;if(E&&G){G.scrollTop=E.top+G.scrollHeight-E.height,xt.current=null;return}x.current!==t&&(x.current=t,P.current=t,S.current=0,pe(null),xe(null));const re=S.current===0&&d.length>0;S.current=d.length;const je=ke.current;if(!je)return;if(re||P.current===t&&(!v||d.length>0)){Ke();const lt=requestAnimationFrame(Ke),De=window.setTimeout(Ke,120),Ct=window.setTimeout(Ke,360);return P.current=null,Te(!1),()=>{cancelAnimationFrame(lt),window.clearTimeout(De),window.clearTimeout(Ct)}}je.scrollHeight-je.scrollTop-je.clientHeight<240&&Ke()},[t,v,Ut,d.length,m,Ke]);const wt=Oe.length&&Re.trim()?Oe[(Fe+Oe.length-1)%Oe.length]?.index:void 0,Vt=e?qe(e):O.newSession,vt=e?.cwd??(h.trim().length>0&&h!=="."?h:""),kt=e?.agent??a,jt=kt==="codex"?"Codex":"Claude";return s.jsxs("section",{className:"chat-pane","aria-label":O.chat,children:[s.jsxs("header",{className:"chat-header",children:[s.jsxs("button",{className:"chat-title-block chat-title-button",type:"button",onClick:()=>e&&A(!0),children:[s.jsx("span",{className:`agent-status-pill ${kt}`,children:jt}),s.jsx("h1",{title:Vt,children:Vt}),vt?s.jsx("p",{title:vt,children:vt}):null,e?.branch||e?.diffStat?s.jsxs("div",{className:"header-metadata",children:[e.branch?s.jsx("span",{children:e.branch}):null,e.diffStat?s.jsxs("span",{children:["+",e.diffStat.additions," -",e.diffStat.deletions]}):null,e.runtime.state?s.jsx("span",{children:e.runtime.state}):null,e.terminal?.mode?s.jsx("span",{children:e.terminal.mode}):null]}):null]}),s.jsx(Bo,{activeSession:e,busy:b,controlsOpen:J,pendingActionsCount:ae,t:O,onOpenControls:B,onRefreshSessions:fe,onRestoreSnapshot:M,onToggleArchived:Pe,onTogglePinned:We,onViewChanges:he})]}),s.jsxs("div",{className:"chat-notices","aria-live":"polite",children:[f?s.jsx(mc,{message:f,retryLabel:O.retry,onRetry:se}):null,C&&!Ht?s.jsx(Ds,{failedSend:C,onRetry:()=>{ye()},t:O}):null,e?.interruptReason?s.jsxs("div",{className:"notice warning",children:[s.jsx(Pt,{"aria-hidden":"true"}),s.jsx("span",{children:e.interruptReason.humanText||e.interruptReason.kind}),s.jsx("button",{className:"icon-text-button",disabled:b,onClick:ve,type:"button",children:O.clear})]}):null,e?.stallWarning?s.jsxs("div",{className:"notice warning",children:[s.jsx(er,{"aria-hidden":"true"}),s.jsx("span",{children:e.stallWarning.humanText||O.agentMayBeStalled})]}):null]}),s.jsxs("div",{className:"message-scroll","data-rendered-items":Ae.length,"data-total-messages":d.length,ref:ke,onScroll:yn,children:[s.jsx(Ac,{matchCount:Oe.length,query:Re,onChange:E=>{me(E),$e(0)},onNext:Wt,t:O}),v&&d.length===0?s.jsx(pc,{label:O.loadingHistory}):null,!v&&d.length===0?s.jsxs("div",{className:"empty-state compact",children:[s.jsx(hn,{"aria-hidden":"true"}),s.jsx("h2",{children:e?O.noVisibleMessages:O.startDaemonSession}),s.jsx("p",{children:O.emptyChatHint})]}):null,ge>0?s.jsx("div",{className:"conversation-window-gate",children:s.jsx("button",{type:"button",onClick:()=>{const E=ke.current;E&&(xt.current={height:E.scrollHeight,top:E.scrollTop}),et()},children:O.showEarlierMessages(ge)})}):null,Ae.map(E=>{if(E.type==="toolGroup"){const De=E.entries.map(Qe=>Qe.message),Ct=E.entries.some(Qe=>wt===Qe.index),Gt=Le===E.id;return s.jsx("div",{className:"message-frame tool info",ref:Qe=>{for(const H of E.entries)Me.current[H.index]=Qe},children:s.jsxs("div",{className:"inline-message-stack",children:[s.jsx(Ec,{activeMatch:Ct,expanded:Gt,messages:De,onToggle:()=>xe(Qe=>Qe===E.id?null:E.id)}),Gt?s.jsx(pr,{messages:De,onClose:()=>xe(null),onCopy:St,t:O}):null]})},E.id)}const{index:G,message:re}=E,je=mr(re,G),Kt=ze===je,Qt=Le===je,lt=C?.historyKey===re.historyKey?C:null;return s.jsxs("div",{className:`message-frame ${re.role} ${re.type==="info"?"info":""}`,ref:De=>{Me.current[G]=De},children:[s.jsx(Mc,{activeMatch:wt===G,baseCwd:e?.cwd,message:re,onCopy:St,onCloseSource:()=>pe(null),onCloseTool:()=>xe(null),onOpenAttachment:Ve,onOpenRemoteFile:K,onToggleSource:()=>pe(De=>De===je?null:je),onToggleTool:()=>xe(De=>De===je?null:je),sourceOpen:Kt,toolOpen:Qt,t:O}),lt?s.jsx(Ds,{failedSend:lt,onRetry:()=>{ye()},t:O}):null]},je)}),Xe>0?s.jsx("div",{className:"conversation-window-gate",children:s.jsx("button",{type:"button",onClick:()=>zt("auto"),children:O.showLatestMessages(Xe)})}):null,t&&p.has(t)?s.jsx(gc,{busy:b,label:O.agentResponding,stopLabel:O.stopGenerating,onStop:Z}):null,Ze?s.jsx(yc,{label:O.newMessages,onClick:()=>zt()}):null]}),s.jsx(hc,{feedback:gn}),s.jsx(cc,{activeModelOptions:n,activeQueue:r,agent:a,approvalMode:l,attachments:c,busy:b,draft:g,effort:k,fastMode:N,model:j,phase:m,quickReplies:w,sendShortcut:R,skills:_,uploadBusy:z,onApprovalModeChange:oe,onCancelQueuedTurn:ne,onDraftChange:D,onEffortChange:W,onFastModeChange:ce,onModelChange:Y,onRemoveAttachment:Ce,onRefreshSkills:X,onSendShortcutChange:V,onSubmit:_e,onUploadFiles:be,t:O}),ue&&e?s.jsx(Pc,{activeSession:e,activeUsage:i,busy:b,messages:d,renameTitle:y,t:O,onBrowseFiles:()=>{A(!1),de()},onClose:()=>A(!1),onExport:$,onJumpToMessage:(E,G)=>{me(G),$e(0),Ee(E)},onRename:U,onRenameTitleChange:te,onToggleArchived:Pe,onTogglePinned:We,onViewChanges:()=>he(e.sessionId)}):null,s.jsx(dc,{cwd:e?.cwd,paths:Ue,t:O,onClose:()=>Ve([]),onOpenRemoteFile:K})]})}const _n="vibelet --access=quick";function $c({errorText:e,t}){const[n,r]=o.useState("idle"),i=async()=>{try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(_n);else{const a=document.createElement("textarea");a.value=_n,a.style.position="fixed",a.style.opacity="0",document.body.append(a),a.select();const l=document.execCommand("copy");if(a.remove(),!l)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(un,{})}),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:()=>{i()},type:"button",children:[n==="success"?s.jsx(Je,{"aria-hidden":"true"}):s.jsx(gt,{"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]})})}const Lc=o.lazy(async()=>Ye(()=>import("./FilesControlPanel-DIVZPGG9.js"),__vite__mapDeps([4,1,2,5])).then(e=>({default:e.FilesControlPanel}))),Oc=o.lazy(async()=>Ye(()=>import("./ArchiveSyncPanel-Dnkaspmd.js"),__vite__mapDeps([6,1,2])).then(e=>({default:e.ArchiveSyncPanel}))),qc=o.lazy(async()=>Ye(()=>import("./ConnectionSettingsPanel-Br7qHYvB.js"),__vite__mapDeps([7,1,2])).then(e=>({default:e.ConnectionSettingsPanel}))),Bc=o.lazy(async()=>Ye(()=>import("./DaemonSettingsPanel-BANgginY.js"),__vite__mapDeps([8,1,2])).then(e=>({default:e.DaemonSettingsPanel}))),Hc=o.lazy(async()=>Ye(()=>import("./LanguageSettingsPanel-B-MqFdLO.js"),__vite__mapDeps([9,1,2])).then(e=>({default:e.LanguageSettingsPanel}))),Wc=o.lazy(async()=>Ye(()=>import("./NotificationSettingsPanel-CwhRDEyv.js"),__vite__mapDeps([10,1,2])).then(e=>({default:e.NotificationSettingsPanel}))),zc=o.lazy(async()=>Ye(()=>import("./SavedTargetsPanel-BPdvJF_n.js"),__vite__mapDeps([11,1,2])).then(e=>({default:e.SavedTargetsPanel}))),Uc=o.lazy(async()=>Ye(()=>import("./DiffDrawer-DtuLETbo.js"),__vite__mapDeps([12,1,2,5])).then(e=>({default:e.DiffDrawer})));function Fs({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 Vc({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(Uc,{client:e,sessionId:a.sessionId,sessionTitle:qe(a),t:r,onClose:i})})}function Kc({activeApproval:e,activeQuestion:t,busy:n,questionAnswers:r,t:i,onCancelQuestion:a,onQuestionChoice:l,onRespondApproval:c,onRespondQuestion:b}){const h=!!(e||t);return s.jsxs(s.Fragment,{children:[h?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(hn,{"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:lr(e.input)}),s.jsxs("div",{className:"attention-actions",children:[s.jsxs("button",{type:"button",className:"danger-button",onClick:()=>c(!1),disabled:n,children:[s.jsx(we,{"aria-hidden":"true"}),i.deny]}),s.jsxs("button",{type:"button",className:"approve-button",onClick:()=>c(!0),disabled:n,children:[s.jsx(Je,{"aria-hidden":"true"}),i.approve]})]})]}):null,t?s.jsxs("section",{className:"attention-panel",children:[s.jsxs("div",{className:"attention-head",children:[s.jsx(qa,{"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(g=>s.jsxs("div",{className:"question-block",children:[s.jsx("strong",{children:g.question}),s.jsx("div",{className:"choice-list",children:g.options.map(k=>{const f=(r[g.id]??[]).includes(k.label);return s.jsxs("button",{className:f?"selected":"",onClick:()=>l(g.id,k.label,g.multiSelect),type:"button",children:[s.jsx("span",{children:k.label}),k.description?s.jsx("small",{children:k.description}):null]},k.label)})})]},g.id)),s.jsxs("div",{className:"attention-actions",children:[s.jsxs("button",{type:"button",className:"danger-button",onClick:a,disabled:n,children:[s.jsx(we,{"aria-hidden":"true"}),i.cancel]}),s.jsxs("button",{type:"button",className:"approve-button",onClick:b,disabled:n,children:[s.jsx(Je,{"aria-hidden":"true"}),i.submit]})]})]}):null]})}function $s({session:e,active:t,responding:n,tagLabels:r,t:i,onSelect:a,onContextMenu:l,onViewChanges:c}){const b=!!e.diffStat&&(e.diffStat.additions>0||e.diffStat.deletions>0),h=qe(e);return s.jsxs("button",{className:`session-row ${t?"active":""} ${e.archived?"archived":""}`,onContextMenu:l,onClick:a,title:h,type:"button",children:[s.jsxs("span",{className:"session-row-head",children:[s.jsx("strong",{children:h}),n?s.jsx(pa,{"aria-label":i.agentResponding}):null]}),s.jsx("span",{children:e.cwd}),r?.length?s.jsx("span",{className:"directory-tag-row",title:i.directoryTags,children:r.map(g=>s.jsx("em",{children:g},g))}):null,s.jsxs("small",{children:[e.agent," · ",Gn(e.lastActivityAt),e.branch?` · ${e.branch}`:"",e.diffStat&&!c?` · +${e.diffStat.additions}/-${e.diffStat.deletions}`:"",e.pinned?` · ${i.pinned}`:"",e.archived?` · ${i.archived}`:""]}),b&&c&&e.diffStat?s.jsxs("span",{className:"session-diff-badge",role:"button",tabIndex:0,title:i.viewChanges,onClick:g=>{g.stopPropagation(),c()},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.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 Qc({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 Gc({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(Qc,{ariaLabel:t.agentFilterLabel,value:e,options:[{value:"all",label:t.agentFilterAll},{value:"claude",label:t.agentFilterClaude},{value:"codex",label:t.agentFilterCodex}],onChange:n})]})}function at(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function Jc({activeSessionId:e,busy:t,collapsedFolders:n,currentCwd:r,displayName:i,directoryTags:a,folderCounts:l,groupFolders:c,groupedSessions:b,hideArchived:h,inventoryVersion:g,nextCursor:k,phase:f,pendingSessionIds:C,respondingSessionIds:N,search:v,sessionAgentFilter:d,sessionsCount:j,sinceFilter:m,statusText:w,t:y,visibleSessions:p,onLoadMore:R,onCopyResumeCommand:_,onCreateDirectory:z,onCreateSession:ue,onDeleteSession:J,onListDirectories:ae,onBrowseFolder:O,onEditFolderTags:oe,onOpenSessionDetails:de,onResetFilters:ne,onSearchChange:ve,onSearchCommit:D,onSelectSession:A,onToggleSessionArchived:W,onToggleSessionPinned:$,onSessionAgentFilterChange:ce,onSinceFilterChange:ye,onToggleFolder:Y,onToggleGroupFolders:K,onToggleHideArchived:B,onToggleCollapse:Z,onViewChanges:se}){const[fe,X]=o.useState(!1),[U,te]=o.useState(null),Ce=o.useRef(0),[M,V]=o.useState(null),_e=o.useRef(null),Pe=d!=="all"||m!=="30d"||c||h,We=!!(k?.lastActivityAt&&k.sessionId),be=U?!!C?.has(U.session.sessionId):!1,he=x=>a[at(x)??"/"]??[],Re=f==="connected"?`${p.length}/${j} sessions · v${g??"-"}`:y.sameOriginAccess,me=`${w} · ${Re}`;o.useEffect(()=>{if(!fe&&!U&&!M)return;const x=S=>{const F=S.target;F instanceof Node&&_e.current?.contains(F)||(X(!1),te(null),V(null))},P=S=>{S.key==="Escape"&&(X(!1),te(null),V(null))};return document.addEventListener("pointerdown",x),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",P)}},[U,M,fe]);const Fe=(x,P)=>{const S=x.currentTarget.getBoundingClientRect(),F=320,Q=430,ge=at(P),Xe=ge??at(r)??".";te(null),V({...ge?{folder:ge}:{},cwd:Xe,x:Math.max(10,Math.min(S.right-F,window.innerWidth-F-10)),y:Math.max(10,Math.min(S.bottom+8,window.innerHeight-Q-10))})},$e=(x,P)=>{x.preventDefault();const S=224,F=306;V(null),te({session:P,x:Math.min(x.clientX,window.innerWidth-S-10),y:Math.min(x.clientY,window.innerHeight-F-10)})},ze=()=>te(null),pe=x=>{if(!U)return;const{session:P}=U;ze(),x(P)},Le=x=>{if(!M)return;const P=at(M.cwd)??at(M.folder)??at(r)??".";V(null),ue(P,x)},xe=x=>{const P=at(x)??at(r)??".",S=++Ce.current;V(F=>F&&{...F,browser:{path:P,entries:[],loading:!0,loaded:!1,createMode:!1,newFolderName:"",creating:!1}}),ae(P).then(F=>{Ce.current===S&&V(Q=>Q?.browser?{...Q,browser:{...Q.browser,path:P,entries:F.filter(ge=>ge.isDirectory),loading:!1,loaded:!0,error:void 0}}:Q)}).catch(F=>{Ce.current===S&&V(Q=>Q?.browser?{...Q,browser:{...Q.browser,path:P,entries:[],loading:!1,loaded:!0,error:F instanceof Error?F.message:String(F)}}:Q)})},Ze=()=>{M&&xe(M.cwd||M.folder||r||".")},Te=()=>{V(x=>x?.browser?{...x,cwd:x.browser.path,browser:void 0}:x)},Ue=x=>{V(P=>P?.browser?{...P,browser:{...P.browser,newFolderName:x,createError:void 0}}:P)},Ve=()=>{V(x=>x?.browser?{...x,browser:{...x.browser,createMode:!0,newFolderName:"",createError:void 0}}:x)},ke=()=>{V(x=>x?.browser?{...x,browser:{...x.browser,createMode:!1,newFolderName:"",createError:void 0,creating:!1}}:x)},Me=()=>{const x=M?.browser,P=x?.newFolderName??"";if(!x||P.trim().length===0||x.creating)return;if(P.includes("/")||P.includes("\\")||P==="."||P===".."){V(F=>F?.browser?{...F,browser:{...F.browser,createError:y.folderCreateFailed}}:F);return}const S=On(x.path,P);V(F=>F?.browser?{...F,browser:{...F.browser,creating:!0,createError:void 0}}:F),z(S).then(()=>{xe(x.path)}).catch(F=>{V(Q=>Q?.browser?{...Q,browser:{...Q.browser,creating:!1,createError:F instanceof Error?F.message:String(F)}}:Q)})};return s.jsxs("aside",{className:"session-rail","aria-label":y.sessions,children:[s.jsxs("div",{className:"brand-block",title:me,children:[s.jsx("div",{className:"brand-mark",children:s.jsx(un,{"aria-hidden":"true"})}),s.jsxs("div",{className:"brand-copy",children:[s.jsx("strong",{children:"Vibelet Web"}),s.jsxs("span",{className:`brand-connection ${f}`,children:[s.jsx("i",{"aria-hidden":"true"}),f==="connected"&&i?y.connectedTo(i):w]})]}),Z?s.jsx("button",{"aria-label":y.collapseSessionSidebar,className:"sidebar-panel-collapse-button session-rail-collapse-button",onClick:Z,title:y.collapseSessionSidebar,type:"button",children:s.jsx(sr,{"aria-hidden":"true"})}):null]}),s.jsxs("div",{className:"rail-list-heading",children:[s.jsx("span",{children:y.sessions}),s.jsx("button",{"aria-label":y.newSession,className:"rail-create-button",disabled:t||f!=="connected",onClick:x=>Fe(x),title:y.newSession,type:"button",children:s.jsx(Fn,{"aria-hidden":"true"})})]}),s.jsxs("div",{className:"search-filter-wrap",ref:_e,children:[s.jsxs("div",{className:"search-box",children:[s.jsx(Kn,{"aria-hidden":"true"}),s.jsx("input",{value:v,onBlur:D,onChange:x=>ve(x.target.value),onKeyDown:x=>{x.key==="Enter"&&D()},placeholder:y.searchSessions}),s.jsx("button",{"aria-expanded":fe,"aria-label":y.sessionFilters,className:`filter-toggle ${fe||Pe?"selected":""}`,onClick:()=>X(x=>!x),title:y.sessionFilters,type:"button",children:s.jsx(Ea,{"aria-hidden":"true"})})]}),fe?s.jsxs("div",{className:"filter-popover",role:"dialog","aria-label":y.sessionFilters,children:[s.jsx(Gc,{agentFilter:d,t:y,onAgentFilterChange:ce}),s.jsxs("div",{className:"filter-section",children:[s.jsx("span",{className:"filter-section-label",children:y.searchTimeRangeLabel}),s.jsx("div",{className:"rail-filters",role:"group","aria-label":y.searchTimeRangeLabel,children:["all","7d","30d","90d"].map(x=>s.jsx("button",{className:m===x?"selected":"",onClick:()=>ye(x),type:"button",children:x==="all"?y.searchTimeRangeAllTime:x==="7d"?y.searchTimeRangeLast7Days:x==="30d"?y.searchTimeRangeLast30Days:y.searchTimeRangeLast90Days},x))})]}),s.jsxs("div",{className:"filter-section",children:[s.jsx("span",{className:"filter-section-label",children:y.filterViewOptions}),s.jsxs("div",{className:"filter-switch-card",children:[s.jsxs("button",{"aria-pressed":c,className:c?"selected":"",onClick:K,type:"button",children:[s.jsx("span",{children:y.groupByFolder}),s.jsx("span",{className:"filter-switch-track","aria-hidden":"true",children:s.jsx("span",{})})]}),s.jsxs("button",{"aria-pressed":h,className:h?"selected":"",onClick:B,type:"button",children:[s.jsx("span",{children:y.hideArchived}),s.jsx("span",{className:"filter-switch-track","aria-hidden":"true",children:s.jsx("span",{})})]})]})]}),Pe?s.jsx("button",{className:"filter-reset-button",onClick:ne,type:"button",children:y.resetFilters}):null]}):null]}),s.jsxs("div",{className:"session-list",children:[c?b.map(x=>{const P=n[x.folder];return s.jsxs("div",{className:"folder-group",children:[s.jsxs("div",{className:"folder-header",children:[s.jsxs("button",{onClick:()=>Y(x.folder),type:"button",children:[s.jsx(js,{"aria-hidden":"true"}),s.jsx("span",{children:x.folder}),s.jsx("small",{children:l[x.folder]??x.sessions.length})]}),s.jsx("button",{className:"mini-button",disabled:f!=="connected",onClick:()=>O(x.folder),title:y.browseFolder,type:"button",children:s.jsx(mt,{"aria-hidden":"true"})}),s.jsx("button",{className:"mini-button",onClick:()=>oe(x.folder),title:y.editDirectoryTags,type:"button",children:s.jsx(fo,{"aria-hidden":"true"})}),s.jsx("button",{className:"mini-button",disabled:t||f!=="connected",onClick:S=>Fe(S,x.folder),title:y.newSession,type:"button",children:s.jsx(Fn,{"aria-hidden":"true"})})]}),he(x.folder).length?s.jsx("div",{className:"folder-tag-row",children:he(x.folder).map(S=>s.jsx("span",{children:S},S))}):null,P?null:x.sessions.map(S=>s.jsx($s,{active:S.sessionId===e,responding:N.has(S.sessionId),session:S,tagLabels:he(S.cwd),t:y,onContextMenu:F=>$e(F,S),onSelect:()=>A(S.sessionId),onViewChanges:se?()=>se(S.sessionId):void 0},S.sessionId))]},x.folder)}):p.map(x=>s.jsx($s,{active:x.sessionId===e,responding:N.has(x.sessionId),session:x,tagLabels:he(x.cwd),t:y,onContextMenu:P=>$e(P,x),onSelect:()=>A(x.sessionId),onViewChanges:se?()=>se(x.sessionId):void 0},x.sessionId)),p.length===0?s.jsx("p",{className:"empty-copy",children:y.noSessionsMatch}):null,We&&k?s.jsxs("button",{className:"icon-text-button load-more-button",disabled:t,onClick:()=>R(k),type:"button",children:[s.jsx(pt,{"aria-hidden":"true"}),y.loadMore]}):null]}),M?s.jsxs("div",{className:"session-create-menu",role:"dialog","aria-label":y.newSession,style:{left:M.x,top:M.y},onPointerDown:x=>x.stopPropagation(),children:[s.jsxs("label",{className:"session-create-field",children:[s.jsx("span",{children:y.workingDirectory}),s.jsxs("div",{className:"session-create-input-row",children:[s.jsx("input",{"aria-label":y.workingDirectory,placeholder:y.workingDirectoryPlaceholder,value:M.cwd,onChange:x=>V(P=>P&&{...P,cwd:x.target.value}),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Le("claude"))}}),s.jsx("button",{"aria-label":y.browseDirectories,className:"session-create-icon-button",onClick:Ze,title:y.browseDirectories,type:"button",children:s.jsx(mt,{"aria-hidden":"true"})})]})]}),M.browser?s.jsxs("div",{className:"session-create-browser",children:[s.jsxs("div",{className:"session-create-browser-bar",children:[s.jsx("span",{title:M.browser.path,children:M.browser.path}),s.jsx("button",{"aria-label":y.refreshSessions,className:"session-create-icon-button",onClick:()=>xe(M.browser?.path??M.cwd),title:y.refreshSessions,type:"button",children:M.browser.loading?s.jsx(Cs,{className:"spin","aria-hidden":"true"}):s.jsx(pt,{"aria-hidden":"true"})})]}),M.browser.createMode?s.jsxs("div",{className:"session-create-new-folder",children:[s.jsx("input",{"aria-label":y.newFolder,disabled:M.browser.creating,placeholder:y.newFolderPlaceholder,value:M.browser.newFolderName,onChange:x=>Ue(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Me())}}),s.jsx("button",{"aria-label":y.cancel,className:"session-create-icon-button",disabled:M.browser.creating,onClick:ke,title:y.cancel,type:"button",children:s.jsx(we,{"aria-hidden":"true"})}),s.jsx("button",{"aria-label":y.create,className:"session-create-icon-button",disabled:M.browser.creating||!M.browser.newFolderName.trim(),onClick:Me,title:y.create,type:"button",children:M.browser.creating?s.jsx(Cs,{className:"spin","aria-hidden":"true"}):s.jsx(Je,{"aria-hidden":"true"})})]}):s.jsxs("button",{className:"session-create-secondary-button",onClick:Ve,type:"button",children:[s.jsx(Ta,{"aria-hidden":"true"}),y.newFolder]}),M.browser.createError?s.jsx("p",{className:"session-create-error",children:M.browser.createError}):null,s.jsxs("div",{className:"session-create-folder-list",children:[Rs(M.browser.path)?s.jsxs("button",{className:"session-create-folder-row",onClick:()=>xe(Rs(M.browser?.path??"")??M.cwd),type:"button",children:[s.jsx(mt,{"aria-hidden":"true"}),".."]}):null,M.browser.loading?s.jsx("p",{className:"empty-copy",children:y.loadingDirectories}):null,!M.browser.loading&&M.browser.error?s.jsx("p",{className:"session-create-error",children:M.browser.error}):null,!M.browser.loading&&!M.browser.error&&M.browser.loaded&&M.browser.entries.length===0?s.jsx("p",{className:"empty-copy",children:y.remoteFolderEmpty}):null,!M.browser.loading&&!M.browser.error?M.browser.entries.map(x=>{const P=On(M.browser?.path??M.cwd,x.name);return s.jsxs("button",{className:"session-create-folder-row",onClick:()=>xe(P),type:"button",children:[s.jsx(js,{"aria-hidden":"true"}),s.jsx("span",{children:x.name})]},`${x.name}:${P}`)}):null]}),s.jsxs("button",{className:"session-create-select-button",onClick:Te,type:"button",children:[s.jsx(Je,{"aria-hidden":"true"}),y.chooseThisFolder]})]}):null,s.jsxs("button",{type:"button",onClick:()=>Le("claude"),children:[s.jsx(ca,{"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:"Claude"}),s.jsx("small",{children:y.claudeSession})]})]}),s.jsxs("button",{type:"button",onClick:()=>Le("codex"),children:[s.jsx(un,{"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:"Codex"}),s.jsx("small",{children:y.codexSession})]})]})]}):null,U?s.jsxs("div",{className:"session-context-menu",role:"menu",style:{left:U.x,top:U.y},onPointerDown:x=>x.stopPropagation(),children:[s.jsxs("button",{type:"button",role:"menuitem",onClick:()=>pe(x=>A(x.sessionId)),children:[s.jsx(Xs,{"aria-hidden":"true"}),y.open]}),s.jsxs("button",{type:"button",role:"menuitem",disabled:be,onClick:()=>pe(de),children:[s.jsx(La,{"aria-hidden":"true"}),y.details]}),s.jsxs("button",{type:"button",role:"menuitem",disabled:be,onClick:()=>pe(_),children:[s.jsx(gt,{"aria-hidden":"true"}),y.copyResumeCommand]}),s.jsxs("button",{type:"button",role:"menuitem",disabled:be||!se||!U.session.branch&&!U.session.diffStat,onClick:()=>pe(x=>se?.(x.sessionId)),children:[s.jsx(tr,{"aria-hidden":"true"}),y.viewChanges]}),s.jsx("span",{className:"context-menu-separator"}),s.jsxs("button",{type:"button",role:"menuitem",disabled:be,onClick:()=>pe($),children:[s.jsx(Vn,{"aria-hidden":"true"}),U.session.pinned?y.unpin:y.pin]}),s.jsxs("button",{type:"button",role:"menuitem",disabled:be,onClick:()=>pe(W),children:[s.jsx(zn,{"aria-hidden":"true"}),U.session.archived?y.unarchive:y.archive]}),s.jsxs("button",{className:"danger",type:"button",role:"menuitem",onClick:()=>pe(J),children:[s.jsx(po,{"aria-hidden":"true"}),y.delete]})]}):null]})}function Yc({value:e,t,showSession:n=!0,onChange:r}){const i=[...n?[{tab:"session",label:t.session,Icon:ir}]:[],{tab:"files",label:t.files,Icon:mt},{tab:"admin",label:t.settings,Icon:no}];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 Zc({children:e,t,value:n,showSession:r,onChange:i,onClose:a}){const l=o.useRef(null),c=Zn(a,l);return s.jsxs("div",{"aria-label":t.controls,"aria-modal":"true",className:"workspace-control-drawer",ref:c,role:"dialog",tabIndex:-1,children:[s.jsx("button",{className:"workspace-control-backdrop",onClick:a,tabIndex:-1,type:"button"}),s.jsxs("aside",{className:"control-pane",children:[s.jsxs("div",{className:"control-pane-toolbar",children:[s.jsx(Yc,{value:n,t,showSession:r,onChange:i}),s.jsx("button",{"aria-label":t.collapseControlsSidebar,className:"sidebar-panel-collapse-button",onClick:a,ref:l,title:t.collapseControlsSidebar,type:"button",children:s.jsx(rr,{"aria-hidden":"true"})})]}),e]})]})}const gr="pair",ct="vibelet.web.pairing",Ls="vibelet.web.deviceId";class fn 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 Xc(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 el(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 tl(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 nl(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 sl(e){const t=e.trim();return t.includes(":")&&!t.startsWith("[")?`[${t}]`:t}function rl(e,t){return t.protocol==="https:"&&e.secure!==!0?null:`${e.secure===!0?"wss":"ws"}://${sl(e.host)}:${e.port}`}function Os(e){return nl(e.host)?0:e.source==="local_network"?1:e.source==="configured_host"?2:3}function il(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 al(e,t,n=window.location){const r=[...t?.connections??[],...e.connections??[],...il(e,t)].map(tl).filter(i=>!!i).filter(i=>i.kind==="direct").sort((i,a)=>Os(i)-Os(a));for(const i of r){const a=rl(i,n);if(a)return a}}function ol(e){if(!e.d||!e.c)return null;const t=Array.isArray(e.o)?e.o.map(el).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 cl(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 ll(e=window.location.hash){const t=e.startsWith("#")?e.slice(1):e,n=new URLSearchParams(t).get(gr);if(!n)return null;try{const r=JSON.parse(Xc(n));if(!ts(r))return null;if(r.t==="vp")return ol(r);if(r.type==="vibelet-pair")return cl(r)}catch{return null}return null}function dl(){if(!window.location.hash.includes(`${gr}=`))return;const e=`${window.location.pathname}${window.location.search}`;window.history.replaceState(null,"",e)}function ul(e=window.localStorage){const t=e.getItem(Ls);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(Ls,n),n}function qs(e){const t=e.getItem(ct);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 fl(e=window.localStorage,t=ns(e)){const n=qs(e);if(n)return n;const r=t?qs(t):null;return r?(e.setItem(ct,JSON.stringify(r)),t?.removeItem(ct),r):null}function Bs(e,t=window.localStorage,n=ns(t)){t.setItem(ct,JSON.stringify(e)),n?.removeItem(ct)}function yr(e=window.localStorage,t=ns(e)){e.removeItem(ct),t?.removeItem(ct)}function hl(e,t=Date.now()){if(!e.expiresAt)return!1;const n=new Date(e.expiresAt).getTime();return Number.isFinite(n)&&n<t}async function ml(e){const t=await e.text().catch(()=>"");try{const n=JSON.parse(t);if(ts(n)&&n.error==="pair_window_expired")return new fn("pair_window_expired","Pairing link expired.")}catch{}return new fn("pairing_failed",t||"Pairing failed.")}async function pl(e,t=ul()){if(hl(e))throw new fn("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 ml(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:al(e,r)}}function gl(e){return e.filter(t=>t.archived===!0).map(t=>t.sessionId)}function yl(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 bl(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 br="vibelet.web.savedTargets",xr=12;function xl(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Sl(e){if(!xl(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 Sr(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const r of e){const i=Sl(r);if(!(!i||t.has(i.daemonId))&&(t.add(i.daemonId),n.push(i),n.length>=xr))break}return n}function wl(e=window.localStorage){const t=e.getItem(br);if(!t)return[];try{return Sr(JSON.parse(t))}catch{return[]}}function wr(e,t=window.localStorage){t.setItem(br,JSON.stringify(Sr(e)))}function vl(e,t,n=new Date().toISOString()){return[{...t,label:t.displayName||t.daemonId.slice(0,10),lastConnectedAt:n},...e.filter(i=>i.daemonId!==t.daemonId)].slice(0,xr)}function kl(e,t){return e.filter(n=>n.daemonId!==t)}const Bn={version:"",latestVersion:"",loading:!1,error:null};function Hs(e){const t=e.match(/^\d+/);return t?Number(t[0]):0}function jl(e,t){const n=e.split(/[+-]/,1)[0].split(".").map(Hs),r=t.split(/[+-]/,1)[0].split(".").map(Hs),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 Cl(e,t){return jl(e,t)<0}function Il(e){const t=e.toLowerCase();if(t.includes("alpha"))return"alpha";if(t.includes("beta"))return"beta";if(e.trim())return"latest"}function Nl(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 Rl(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 Tl(e){const t=o.useCallback((d,j)=>{e.updateSessionListPreferences(m=>({...m,archiveSyncedDaemonIds:j==="synced"?{...m.archiveSyncedDaemonIds,[d]:!0}:m.archiveSyncedDaemonIds,archiveSyncCardDismissedDaemonIds:{...m.archiveSyncCardDismissedDaemonIds,[d]:!0}}))},[e]),n=o.useCallback((d,j)=>{const m=d==="pull"?e.t.archiveSyncSuccessPull:d==="pushMerge"?e.t.archiveSyncSuccessMerge:e.t.archiveSyncSuccessPush;if(e.setArchiveSyncStatus(yl(j,m,{timeout:e.t.archiveSyncFailedTimeout,disconnected:e.t.archiveSyncFailedDisconnected,generic:e.t.archiveSyncFailedGeneric})),!j.ok)return;const w=new Set(j.archivedSessionIds);e.setSessions(y=>y.map(p=>({...p,archived:w.has(p.sessionId)}))),e.pairingRef.current?.daemonId&&t(e.pairingRef.current.daemonId,"synced"),e.requestSessions({force:!0})},[t,e]),r=o.useCallback(async d=>{if(e.archiveSyncBusy)return;e.setArchiveSyncBusy(d),e.setArchiveSyncStatus(null);const j=await bl(e.clientRef.current,d,gl(e.displaySessions));n(d,j),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 d=>{const j=e.clientRef.current;if(j?.isConnected&&!(d==="update"&&!$t("Update desktop connector?"))&&!(d==="restart"&&!$t("Restart desktop connector?"))){e.setAdmin(m=>({...m,loading:!0,action:d,statusText:""})),e.setErrorText(null);try{if(d==="update"){const m=Il(e.daemonMetadata.version),w=await j.request({action:"daemon.update",id:j.makeId("daemon_update"),...m?{channel:m}:{}});e.setAdmin(y=>({...y,loading:!1,action:null,statusText:w.alreadyRunning?"Connector update already running":"Connector update started"}));return}await j.request({action:"daemon.restart",id:j.makeId("daemon_restart")}),e.setAdmin(m=>({...m,loading:!1,action:null,statusText:"Connector restart requested"})),e.refreshDaemonMetadata()}catch(m){e.setAdmin(w=>({...w,loading:!1,action:null})),e.setErrorText(m instanceof Error?m.message:String(m))}}},[e]),l=o.useCallback(async()=>{if(!e.activeSession)return;const d=Do(e.activeSession,e.messages);Po(Eo(qe(e.activeSession),e.activeSession.sessionId),d),await navigator.clipboard?.writeText(d).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 d=await Notification.requestPermission();e.notificationPermissionRef.current=d,e.setNotificationPermission(d),d==="granted"&&e.updateNotificationSettings({enabled:!0}),e.setStatusText(d==="granted"?"Browser notifications enabled":"Browser notifications not enabled")},[e]),b=o.useCallback(()=>{$t("Forget this browser pairing?")&&(e.intentionalDisconnectRef.current=!0,e.connectionAttemptIdRef.current+=1,yr(),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]),h=o.useCallback(d=>{if(d&&e.notificationPermission==="default"){c();return}e.updateNotificationSettings({enabled:d})},[e,c]),g=o.useCallback(d=>{e.connectWithPairingRef.current(d,!0)},[e]),k=o.useCallback(d=>e.saveTargets(kl(e.savedTargets,d)),[e]),f=o.useCallback(d=>{e.setActiveSessionId(d.sessionId),e.setRenameTitle(d.customTitle??d.title??""),e.setDetailsOpen(!0)},[e]),C=o.useCallback(d=>{const j=e.directoryTags[Ki(d)]??[],m=window.prompt(e.t.directoryTags,Qi(j));if(m===null)return;const w=Gi(m);e.updateSessionListPreferences(y=>({...y,directoryTags:Ji(y.directoryTags,d,w)}))},[e]),N=o.useCallback(d=>{e.setControlTab("files"),e.listDirectory(d,{updateRoute:!0})},[e]),v=o.useCallback(d=>{navigator.clipboard?.writeText(dr(d)).catch(()=>{})},[]);return{runArchiveSync:r,skipArchiveSync:i,runAdminAction:a,exportActiveSession:l,clearPairing:b,setNotificationsEnabled:h,connectSavedTarget:g,forgetSavedTarget:k,openSessionDetails:f,editFolderTags:C,browseFolder:N,copyResumeCommand:v}}function Ws(e){return`${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Ml(e,t=window.location){return e?.webSocketUrl?e.webSocketUrl:`${t.protocol==="https:"?"wss:":"ws:"}//${t.host}`}class Al{socket=null;pending=new Map;messageListeners=new Set;closeListeners=new Set;async connect(t){this.disconnect();const n=new WebSocket(Ml(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:Ws("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 Ws(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 vr="vibelet.web.sessionListCache",kr=120;function El(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Dl(e){if(!El(e)||typeof e.daemonId!="string"||!e.daemonId)return null;const t=cr(e.page);return{daemonId:e.daemonId,page:{...t,sessions:t.sessions.slice(0,kr)},cachedAt:typeof e.cachedAt=="string"?e.cachedAt:new Date(0).toISOString()}}function _l(e,t=window.localStorage){if(!e)return null;try{const n=t.getItem(vr);if(!n)return null;const r=Dl(JSON.parse(n));return r?.daemonId===e?r.page:null}catch{return null}}function Pl(e,t,n=window.localStorage,r=new Date().toISOString()){if(!e)return;const i={daemonId:e,page:{...t,sessions:t.sessions.slice(0,kr)},cachedAt:r};n.setItem(vr,JSON.stringify(i))}function Fl(e){return e instanceof Error&&e.message==="auth_failed"}function $l(e,t){return e instanceof fn&&e.code==="pair_window_expired"?t.pairingLinkExpired:e instanceof Error?e.message:String(e)}function Ll(e){const t=o.useRef(null),n=o.useRef(e);n.current=e;const r=o.useCallback(a=>{const l=n.current,c=a??l.pairingRef.current;!c||l.intentionalDisconnectRef.current||(l.reconnectTimerRef.current&&window.clearTimeout(l.reconnectTimerRef.current),l.reconnectTimerRef.current=window.setTimeout(()=>{l.reconnectTimerRef.current=null,l.connectWithPairingRef.current(c,!0)},wo))},[]),i=o.useCallback(async(a,l=!1)=>{const c=n.current;c.reconnectTimerRef.current&&(window.clearTimeout(c.reconnectTimerRef.current),c.reconnectTimerRef.current=null),c.intentionalDisconnectRef.current=!1,c.setPhase("connecting"),c.setStatusText(l?c.t.reconnectingToDaemon:c.t.connectingToDaemon),c.setErrorText(null);const b=new Al,h=c.connectionAttemptIdRef.current+1;c.connectionAttemptIdRef.current=h;const g=c.clientRef.current;c.clientRef.current=b,g?.disconnect();const k=()=>c.connectionAttemptIdRef.current===h&&c.clientRef.current===b;b.onMessage(c.handleServerMessage),b.onClose(()=>{c.clientRef.current===b&&(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 f=a,C;try{C=await b.connect(a)}catch(d){if(!a.webSocketUrl)throw d;f={...a,webSocketUrl:void 0},c.setStatusText(c.t.reconnectingToDaemon),C=await b.connect(f)}if(!k())return;const N={...f,displayName:C.displayName??f.displayName};c.historyCacheDaemonIdRef.current&&c.historyCacheDaemonIdRef.current!==N.daemonId&&(c.historyCacheRef.current={},c.messagesSessionIdRef.current=null,c.lastHistorySessionIdRef.current=null,c.setMessages([])),c.historyCacheDaemonIdRef.current=N.daemonId,c.setPairing(N),c.pairingRef.current=N,Bs(N);const v=_l(N.daemonId);v&&c.setSessionsFromPage(v,!1),c.setSavedTargets(d=>{const j=vl(d,N);return wr(j),j}),c.setPhase("connected"),c.setStatusText(c.t.connectedTo(C.displayName??a.displayName??"Vibelet Daemon")),c.refreshDaemonMetadata(N),await c.requestReconnectSnapshot(),await c.fetchAgentResources(c.agent,c.cwd),c.reportLog("web.connected",{reconnecting:l})}catch(f){if(!k())return;Fl(f)&&yr(),c.setPhase("error"),c.setStatusText(c.t.connectionFailed),c.setErrorText(f instanceof Error?f.message:String(f)),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 b=ll(),g=fl()??a.rememberedTarget;if(!b&&!g){a.setPhase("missing-pair"),a.setStatusText(a.t.missingPair);return}try{a.setPhase("pairing"),b&&t.current?.pairNonce!==b.pairNonce&&(t.current={pairNonce:b.pairNonce,promise:pl(b)});const k=b?await t.current?.promise:g;if(!k||l)return;b&&(Bs(k),t.current=null,dl()),await a.connectWithPairingRef.current(k)}catch(k){if(l)return;b&&(t.current=null),a.setPhase("error"),a.setStatusText(a.t.pairingFailed),a.setErrorText($l(k,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 Ol(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 ql(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 zs(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=ql(r.search,e,i),l=`${r.pathname}${a}${r.hash}`;if(t.replace){n.replaceState(null,"",l);return}n.pushState(null,"",l)}function Bl(e){const{clientRef:t,pairing:n,cwd:r,phase:i,controlTab:a,setControlTab:l,setBusy:c,setErrorText:b,t:h}=e,g=o.useRef(!1),[k,f]=o.useState([]),[C,N]=o.useState(!1),[v,d]=o.useState({path:Ne,entries:[],loading:!1,loaded:!1}),[j,m]=o.useState(""),[w,y]=o.useState(null),[p,R]=o.useState(!1),[_,z]=o.useState("edit"),ue=o.useCallback(async D=>{if(!(!D?.length||!n)){N(!0),b(null);try{const A=[];for(const W of Array.from(D)){const $=await fetch(`/upload?name=${encodeURIComponent(W.name)}`,{method:"POST",headers:{authorization:`Bearer ${n.pairToken}`,"content-type":W.type||"application/octet-stream"},body:W});if(!$.ok)throw new Error(await $.text().catch(()=>h.uploadFailed)||h.uploadFailed);const ce=Co(await $.json());if(!ce)throw new Error(h.uploadPathMissing);A.push({path:ce,name:W.name,type:W.type||"application/octet-stream",size:W.size})}f(W=>[...W,...A])}catch(A){b(A instanceof Error?A.message:String(A))}finally{N(!1)}}},[n,b,h.uploadFailed,h.uploadPathMissing]),J=o.useCallback(async(D,A,W)=>{if(n){b(null);try{w?.objectUrl&&URL.revokeObjectURL(w.objectUrl);const $=await fetch(En(D,A),{headers:{authorization:`Bearer ${n.pairToken}`}});if(!$.ok)throw new Error(await $.text().catch(()=>h.fileOpenFailed)||h.fileOpenFailed);const ce=$.headers.get("content-type")??"application/octet-stream";if(Mo(D,ce))y({path:D,cwd:A,kind:"text",contentType:ce,text:await $.text(),etag:an($.headers,"etag"),lastModified:an($.headers,"last-modified"),size:Number($.headers.get("content-length"))||void 0,dirty:!1});else{const ye=await $.blob();y({path:D,cwd:A,kind:Ao(D,ce)?"image":"binary",contentType:ce,text:"",objectUrl:URL.createObjectURL(ye),etag:an($.headers,"etag"),lastModified:an($.headers,"last-modified"),size:ye.size,dirty:!1})}R(!1),z("edit"),l("files"),W?.updateRoute&&zs({file:D,...A?{cwd:A}:{}},{replace:W.replaceRoute})}catch($){b($ instanceof Error?$.message:String($))}}},[n,w?.objectUrl,l,b]),ae=o.useCallback(async D=>{if(!(!n||!w||w.kind!=="text")){c(!0),b(null);try{const A=await fetch(En(w.path,w.cwd),{method:"PUT",headers:{authorization:`Bearer ${n.pairToken}`,"content-type":"text/markdown; charset=utf-8",...w.etag&&!D?.force?{"if-match":w.etag}:{}},body:w.text});if(!A.ok)throw A.status===409?(R(!0),new Error(h.remoteFileConflict(w.path))):new Error(await A.text().catch(()=>h.fileSaveFailed)||h.fileSaveFailed);R(!1);const W=await A.json().catch(()=>({}));y($=>$&&{...$,dirty:!1,etag:typeof W.etag=="string"?W.etag:$.etag,lastModified:typeof W.lastModified=="string"?W.lastModified:$.lastModified,size:typeof W.size=="number"?W.size:$.size})}catch(A){b(A instanceof Error?A.message:String(A))}finally{c(!1)}}},[n,w,c,b]),O=o.useCallback(async()=>{if(!(!n||!w))try{const D=await fetch(En(w.path,w.cwd),{headers:{authorization:`Bearer ${n.pairToken}`}});if(!D.ok)throw new Error(h.downloadFailed);const A=URL.createObjectURL(await D.blob()),W=document.createElement("a");W.href=A,W.download=mn(w.path),W.click(),URL.revokeObjectURL(A)}catch(D){b(D instanceof Error?D.message:String(D))}},[n,w,b]),oe=o.useCallback(async(D=v.path,A)=>{const W=t.current;if(W?.isConnected){d($=>({...$,path:D,loading:!0,loaded:!1,error:void 0}));try{const $=await W.request({action:"dirs.list",id:W.makeId("dirs"),path:D,cwd:r||void 0});d({path:D,entries:$.entries??[],loading:!1,loaded:!0}),A?.updateRoute&&zs({folder:D},{replace:A.replaceRoute})}catch($){d(ce=>({...ce,loading:!1,loaded:!0,error:$ instanceof Error?$.message:String($)}))}}},[t,r,v.path]),de=o.useCallback(async D=>{const A=t.current;if(!A?.isConnected)throw new Error(h.webSocketNotConnected);return((await A.request({action:"dirs.list",id:A.makeId("dirs"),path:D,cwd:r||void 0},{timeoutMs:1e4,timeoutMessage:h.directoryListTimedOut})).entries??[]).filter($=>$.isDirectory)},[t,r]);o.useEffect(()=>{a!=="files"||i!=="connected"||v.loading||v.loaded||oe(v.path||r||Ne)},[a,r,v.loaded,v.loading,v.path,oe,i]),o.useEffect(()=>{if(i!=="connected"||g.current)return;const D=Ol();if(!D.folder&&!D.file){g.current=!0;return}if(g.current=!0,l("files"),D.folder){oe(D.folder,{updateRoute:!1});return}D.file&&(D.cwd&&d(A=>({...A,path:D.cwd,loaded:!1})),J(D.file,D.cwd,{updateRoute:!1}))},[oe,J,i,l]);const ne=o.useCallback(async()=>{const D=t.current;if(!(!D?.isConnected||j.trim().length===0)){c(!0),b(null);try{await D.request({action:"dirs.create",id:D.makeId("mkdir"),path:On(v.path,j),cwd:r||void 0}),m(""),await oe(v.path)}catch(A){b(A instanceof Error?A.message:String(A))}finally{c(!1)}}},[t,r,v.path,oe,j,c,b]),ve=o.useCallback(async D=>{const A=t.current;if(!A?.isConnected)throw new Error(h.webSocketNotConnected);await A.request({action:"dirs.create",id:A.makeId("mkdir"),path:D,cwd:r||void 0},{timeoutMs:1e4,timeoutMessage:h.directoryCreationTimedOut})},[t,r]);return{attachments:k,setAttachments:f,uploadBusy:C,directory:v,setDirectory:d,newDirName:j,setNewDirName:m,remoteFile:w,setRemoteFile:y,remoteFileConflict:p,remoteFileMode:_,setRemoteFileMode:z,uploadFiles:ue,openRemoteFile:J,saveRemoteFile:ae,downloadRemoteFile:O,listDirectory:oe,listSessionDirectories:de,createDirectory:ne,createSessionDirectory:ve}}function Hl({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 pn(e,t){return!!t&&Object.hasOwn(e,t)}function Wl(e,t){const n=e.map(r=>({...r}));return t?Jn(n,t):n}function zl(e,t,n){return t?{...e,[t]:n.map(r=>({...r}))}:e}function jr(e,t,n){return!t||n.length===0?e:{...e,[t]:[...e[t]??[],...n.map(r=>({...r}))]}}function Ul(e,t,n){return n.historyKey&&e[t]?.some(r=>r.historyKey===n.historyKey)?e:jr(e,t,[n])}function Vl(e,t,n){return!t||!n?e:{...e,[t]:Jn(e[t]??[],n)}}function Kl(e,t,n){if(!t||!n||t===n||!pn(e,t))return e;const r={...e};return r[n]=e[t],delete r[t],r}function Ql(e,t){if(!pn(e,t))return e;const n={...e};return delete n[t],n}const Hn=15e3,Us=500,Vs=1e3;function Gl(e){const t=o.useRef({}),n=o.useRef(null),r=o.useRef({}),i=o.useRef(null),[a,l]=o.useState(!1),[c,b]=o.useState([]),h=o.useCallback(p=>p&&n.current&&n.current!==p?!1:(n.current=null,l(!1),!0),[]),g=o.useCallback(p=>pn(t.current,p)?(i.current=p,b(t.current[p]??[]),!0):!1,[]),k=o.useCallback((p,R,_)=>{t.current=zl(t.current,p,R);const z=t.current[p]??[];return _?.renderActive!==!1&&p===e.activeSessionIdRef.current&&(i.current=p,b(z)),z},[e.activeSessionIdRef]),f=o.useCallback((p,R,_)=>{if(!_)return r.current[p]=void 0,k(p,R);const z=r.current[p];return r.current[p]=_.start,z===void 0||_.start>=z?k(p,R):k(p,[...R,...t.current[p]??[]])},[k]),C=o.useCallback((p,R)=>{const _=k(p,R,{renderActive:!1});i.current=p,b(_)},[k]),N=o.useCallback((p,R)=>{t.current=jr(t.current,p,R),p===e.activeSessionIdRef.current&&(i.current=p,b(t.current[p]??[]))},[e.activeSessionIdRef]),v=o.useCallback((p,R)=>{t.current=Ul(t.current,p,R),p===e.activeSessionIdRef.current&&(i.current=p,b(t.current[p]??[]))},[e.activeSessionIdRef]),d=o.useCallback((p,R)=>{t.current=Vl(t.current,p,R),p===e.activeSessionIdRef.current&&(i.current=p,b(t.current[p]??[]))},[e.activeSessionIdRef]),j=o.useCallback((p,R)=>{N(p,[{role:"assistant",type:"info",content:R,timestamp:new Date().toISOString()}])},[N]),m=o.useCallback(p=>{t.current=Ql(t.current,p),delete r.current[p]},[]),w=o.useCallback((p,R)=>{t.current=Kl(t.current,p,R),r.current[R]=r.current[p],delete r.current[p]},[]),y=o.useCallback(async p=>{const R=e.clientRef.current;if(R?.isConnected){if(g(p.sessionId)){h(p.sessionId);return}n.current=p.sessionId,delete r.current[p.sessionId],l(!0),e.setErrorText(null);try{await R.request({action:"session.history",id:R.makeId("history"),sessionId:p.sessionId,agent:p.agent,limit:Us},{timeoutMessage:e.historyTimeoutMessage,timeoutMs:Hn});let _=r.current[p.sessionId];for(;typeof _=="number"&&_>0&&(t.current[p.sessionId]?.length??0)<Vs;){const z=t.current[p.sessionId]?.length??0;await R.request({action:"session.history",id:R.makeId("history_older"),sessionId:p.sessionId,agent:p.agent,before:_,limit:Math.min(Us,Vs-z)},{timeoutMessage:e.historyTimeoutMessage,timeoutMs:Hn});const ue=r.current[p.sessionId];if(typeof ue!="number"||ue>=_)break;_=ue}}catch(_){n.current===p.sessionId&&e.setErrorText(_ instanceof Error?_.message:String(_))}finally{h(p.sessionId)}}},[h,e.clientRef,e.historyTimeoutMessage,e.setErrorText,g]);return{appendCachedDelta:d,appendCachedHistory:N,appendInfoMessage:j,clearHistoryLoading:h,ensureCachedHistoryEntry:v,historyCacheRef:t,historyLoading:a,hydrateVisibleHistory:C,messages:c,messagesSessionIdRef:i,mergeCachedHistoryPage:f,remapCachedHistory:w,removeCachedHistory:m,renderCachedHistory:g,replaceCachedHistory:k,requestHistory:y,setMessages:b}}function Ks(e,t,n){return Math.min(Math.max(Math.round(e),t),n)}function Jl(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 yt=.9,Yl=Math.round(280*yt),Zl=Math.round(560*yt),Xl=Math.round(260*yt),ed=Math.round(520*yt),td=Math.round(320*yt),nd=Math.round(330*yt);function sd(e,t){const[n,r]=o.useState(e),[i,a]=o.useState(""),[l,c]=o.useState(e.sessionList.searchHistory),[b,h]=o.useState(e.sessionList.sinceFilter),[g,k]=o.useState(e.sessionList.hideArchived),[f,C]=o.useState(e.sessionList.groupFolders),[N,v]=o.useState(e.sessionList.collapsedFolders),[d,j]=o.useState(e.sessionList.agentFilter),[m,w]=o.useState(t),[y,p]=o.useState(e.layout.leftSidebarCollapsed),[R,_]=o.useState(e.layout.rightSidebarCollapsed),[z,ue]=o.useState(td),[J,ae]=o.useState(nd),O=n.sessionList.directoryTags,oe=n.sessionList.archiveSyncedDaemonIds,de=n.sessionList.archiveSyncCardDismissedDaemonIds,ne=n.composer,ve=Jl({leftCollapsed:y,rightCollapsed:R,leftPaneWidth:z,rightPaneWidth:J}),D=o.useCallback(Y=>K=>{K.preventDefault();const B=K.clientX,Z=z,se=J,fe=U=>{const te=U.clientX-B;if(Y==="left"){ue(Ks(Z+te,Yl,Zl));return}ae(Ks(se-te,Xl,ed))},X=()=>{document.body.classList.remove("pane-resizing"),window.removeEventListener("pointermove",fe),window.removeEventListener("pointerup",X)};document.body.classList.add("pane-resizing"),window.addEventListener("pointermove",fe),window.addEventListener("pointerup",X,{once:!0})},[z,J]);o.useEffect(()=>{r(Y=>{const K={...Y,sessionList:{...Y.sessionList,searchHistory:l,sinceFilter:b,hideArchived:g,groupFolders:f,collapsedFolders:N,agentFilter:d},layout:{...Y.layout,leftSidebarCollapsed:y,rightSidebarCollapsed:R}};return nn(K),K})},[N,f,g,y,R,l,d,b]);const A=o.useCallback(()=>{c(Y=>Yi(Y,i))},[i]),W=o.useCallback(Y=>{w(Y),wr(Y)},[]),$=o.useCallback(Y=>{r(K=>{const B={...K,language:Y};return nn(B),B})},[]),ce=o.useCallback(Y=>{r(K=>{const B={...K,sessionList:Y(K.sessionList)};return nn(B),B})},[]),ye=o.useCallback(Y=>{r(K=>{const B={...K,composer:Y(K.composer)};return nn(B),B})},[]);return{webPreferences:n,search:i,setSearch:a,sinceFilter:b,setSinceFilter:h,hideArchived:g,setHideArchived:k,groupFolders:f,setGroupFolders:C,collapsedFolders:N,setCollapsedFolders:v,sessionAgentFilter:d,setSessionAgentFilter:j,directoryTags:O,archiveSyncedDaemonIds:oe,archiveSyncCardDismissedDaemonIds:de,composerPreferences:ne,savedTargets:m,setSavedTargets:w,leftSidebarCollapsed:y,setLeftSidebarCollapsed:p,rightSidebarCollapsed:R,setRightSidebarCollapsed:_,workspaceClassName:ve.workspaceClassName,wideMainClassName:ve.wideMainClassName,workspaceStyle:ve.style,beginPaneResize:D,commitSearch:A,saveTargets:W,setLanguagePreference:$,updateSessionListPreferences:ce,updateComposerPreferences:ye}}function ot(e,t,n){const r=new Set(e);return n?r.add(t):r.delete(t),r}function rd(e){const t=o.useCallback((n,r,i,a,l)=>{const c=e.notificationSettingsRef.current;if(!c[a]||e.notifiedEventsRef.current.has(n))return;Oo(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":{Ft(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,Wl(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(Ln(a))}else delete i[n.sessionId];return i})),e.setRespondingSessions(r=>{const i=ot(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=ot(e.respondingSessionsRef.current,n.sessionId,!0),e.setRespondingSessions(r=>ot(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}
10
-
11
- ${lr(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(Ln(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=ot(e.respondingSessionsRef.current,n.sessionId,!1),e.setRespondingSessions(r=>ot(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=ot(e.respondingSessionsRef.current,n.sessionId,!1),e.setRespondingSessions(r=>ot(r,n.sessionId,!1)),e.requestSessions({force:!0}).catch(r=>e.setErrorText(r instanceof Error?r.message:String(r)));break;case"session.renamed":e.setSessions(r=>r.map(i=>i.sessionId===n.sessionId?{...i,customTitle:n.title}:i));break;case"error":e.setErrorText(n.message);break}},[e,t])}const Cr="vibelet.web.composerDrafts",Wn={draftsBySessionId:{},newSessionDraft:""};function Qs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ir(e){return Qs(e)?{draftsBySessionId:Qs(e.draftsBySessionId)?Object.fromEntries(Object.entries(e.draftsBySessionId).filter(n=>typeof n[1]=="string")):{},newSessionDraft:typeof e.newSessionDraft=="string"?e.newSessionDraft:""}:Wn}function id(e=window.localStorage){const t=e.getItem(Cr);if(!t)return Wn;try{return Ir(JSON.parse(t))}catch{return Wn}}function Lt(e,t=window.localStorage){t.setItem(Cr,JSON.stringify(Ir(e)))}function Bt(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 Ot(e,t){return t?e.draftsBySessionId[t]??"":e.newSessionDraft}function ad(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 od(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 cd(e){const t=o.useCallback(async d=>{const j=e.clientRef.current;if(!(!j?.isConnected||!e.activeApproval)){e.setBusy(!0),e.setErrorText(null);try{await j.request({action:"session.approve",id:j.makeId("approve"),sessionId:e.activeApproval.sessionId,requestId:e.activeApproval.requestId,approved:d}),e.setPendingApprovals(m=>{const w={...m};return delete w[e.activeApproval.sessionId],w})}catch(m){e.setErrorText(m instanceof Error?m.message:String(m))}finally{e.setBusy(!1)}}},[e]),n=o.useCallback(async()=>{const d=e.clientRef.current;if(!(!d?.isConnected||!e.activeQuestion)){e.setBusy(!0),e.setErrorText(null);try{await d.request({action:"session.respondQuestion",id:d.makeId("question"),sessionId:e.activeQuestion.sessionId,requestId:e.activeQuestion.requestId,answers:e.questionAnswers}),e.setPendingQuestions(j=>{const m={...j};return delete m[e.activeQuestion.sessionId],m})}catch(j){e.setErrorText(j instanceof Error?j.message:String(j))}finally{e.setBusy(!1)}}},[e]),r=o.useCallback(async()=>{const d=e.clientRef.current;if(!(!d?.isConnected||!e.activeQuestion)){e.setBusy(!0),e.setErrorText(null);try{await d.request({action:"session.cancelQuestion",id:d.makeId("cancel_question"),sessionId:e.activeQuestion.sessionId,requestId:e.activeQuestion.requestId}),e.setPendingQuestions(j=>{const m={...j};return delete m[e.activeQuestion.sessionId],m})}catch(j){e.setErrorText(j instanceof Error?j.message:String(j))}finally{e.setBusy(!1)}}},[e]),i=o.useCallback((d,j,m)=>{e.setQuestionAnswers(w=>od(w,d,j,!!m))},[e]),a=o.useCallback(async d=>{const j=e.clientRef.current;if(!j?.isConnected||!e.activeSession||d==="session.delete"&&!$t(`Delete ${qe(e.activeSession)}?`))return!1;e.setBusy(!0),e.setErrorText(null);try{return d==="session.resume"?await j.request({action:d,id:j.makeId("resume"),sessionId:e.activeSession.sessionId,agent:e.activeSession.agent}):await j.request({action:d,id:j.makeId(d.split(".").at(-1)??"session"),sessionId:e.activeSession.sessionId}),d==="session.delete"&&(e.removeCachedHistory(e.activeSession.sessionId),e.setActiveSessionId(null),e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([])),await e.requestSessions({force:!0}),!0}catch(m){return e.setErrorText(m instanceof Error?m.message:String(m)),!1}finally{e.setBusy(!1)}},[e]),l=o.useCallback(async d=>{e.setApprovalMode(d);const j=e.clientRef.current;if(!(!j?.isConnected||!e.activeSession)){e.setErrorText(null);try{await j.request({action:"session.setApprovalMode",id:j.makeId("approval_mode"),sessionId:e.activeSession.sessionId,approvalMode:d}),e.setSessions(m=>m.map(w=>w.sessionId===e.activeSession.sessionId?{...w,approvalMode:d}:w))}catch(m){e.setErrorText(m instanceof Error?m.message:String(m))}}},[e]),c=o.useCallback(async d=>{const j=e.clientRef.current;if(!(!j?.isConnected||!e.activeSessionId||!d.clientMessageId)){e.setBusy(!0),e.setErrorText(null);try{await j.request({action:"session.queue.cancel",id:j.makeId("queue_cancel"),sessionId:e.activeSessionId,clientMessageId:d.clientMessageId}),e.setPendingQueues(m=>({...m,[e.activeSessionId]:(m[e.activeSessionId]??[]).filter(w=>w.clientMessageId!==d.clientMessageId)}))}catch(m){e.setErrorText(m instanceof Error?m.message:String(m))}finally{e.setBusy(!1)}}},[e]),b=o.useCallback(async(d,j)=>{if(e.pendingSessions[d.sessionId])return;const m=e.clientRef.current;if(m?.isConnected){e.setBusy(!0),e.setErrorText(null);try{const w=j?Date.now():void 0;await m.request({action:"session.setPinned",id:m.makeId("pin"),sessionId:d.sessionId,pinned:j,...w?{pinnedAt:w}:{}}),e.setSessions(y=>y.map(p=>p.sessionId===d.sessionId?{...p,pinned:j,pinnedAt:w}:p)),await e.requestSessions({force:!0})}catch(w){e.setErrorText(w instanceof Error?w.message:String(w))}finally{e.setBusy(!1)}}},[e]),h=o.useCallback(async(d,j)=>{if(e.pendingSessions[d.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:d.sessionId,archived:j}),e.setSessions(w=>w.map(y=>y.sessionId===d.sessionId?{...y,archived:j}:y)),await e.requestSessions({force:!0})}catch(w){e.setErrorText(w instanceof Error?w.message:String(w))}finally{e.setBusy(!1)}}},[e]),g=o.useCallback(async d=>{if(e.pendingSessions[d.sessionId]){e.removeCachedHistory(d.sessionId),e.setPendingSessions(m=>{const w={...m};return delete w[d.sessionId],w}),e.setComposerDrafts(m=>{const w=Bt(m,d.sessionId,"");return e.composerDraftsRef.current=w,Lt(w),w}),e.activeSessionIdRef.current===d.sessionId&&(e.setActiveSessionId(null),e.messagesSessionIdRef.current=null,e.lastHistorySessionIdRef.current=null,e.setMessages([]),e.setDraft(Ot(e.composerDraftsRef.current,null)),e.setDetailsOpen(!1));return}const j=e.clientRef.current;if(!(!j?.isConnected||!$t(`Delete ${qe(d)}?`))){e.setBusy(!0),e.setErrorText(null);try{await j.request({action:"session.delete",id:j.makeId("delete"),sessionId:d.sessionId}),e.removeCachedHistory(d.sessionId),e.setOptimisticSessions(m=>{if(!m[d.sessionId])return m;const w={...m};return delete w[d.sessionId],w}),e.activeSessionIdRef.current===d.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]),k=o.useCallback(async()=>{e.activeSession&&await b(e.activeSession,!e.activeSession.pinned)},[e.activeSession,b]),f=o.useCallback(async()=>{e.activeSession&&await h(e.activeSession,!e.activeSession.archived)},[e.activeSession,h]),C=o.useCallback(()=>{const d=e.activeSessionId;d&&a("session.interrupt").then(j=>{j&&(e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current),e.respondingSessionsRef.current.delete(d),e.setRespondingSessions(m=>{const w=new Set(m);return w.delete(d),w}))})},[e,a]),N=o.useCallback(()=>{e.setErrorText(null),e.phase==="connected"?e.requestSessions({force:!0}):window.location.reload()},[e]),v=o.useCallback(async()=>{const d=e.renameTitle.trim();if(e.activeSession&&e.pendingSessions[e.activeSession.sessionId]){e.setPendingSessions(m=>{const w=m[e.activeSession.sessionId];return w?{...m,[e.activeSession.sessionId]:{...w,title:d||w.title,customTitle:d||void 0}}:m});return}const j=e.clientRef.current;if(!(!j?.isConnected||!e.activeSession)){e.setBusy(!0),e.setErrorText(null);try{await j.request({action:"session.rename",id:j.makeId("rename"),sessionId:e.activeSession.sessionId,title:d||void 0}),e.setSessions(m=>m.map(w=>w.sessionId===e.activeSession.sessionId?{...w,customTitle:d||void 0}:w))}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:C,retrySessions:N,updateApprovalMode:l,cancelQueuedTurn:c,setSessionPinned:b,setSessionArchived:h,deleteSession:g,updatePinned:k,updateArchived:f,renameSession:v}}function Gs(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 Js=15e3,Ys="Session send timed out.";function _t(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function ld(e){const[t,n]=o.useState(null),r=o.useCallback(b=>{e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current),e.respondingSessionsRef.current.delete(b),e.setRespondingSessions(h=>{const g=new Set(h);return g.delete(b),g})},[e]),i=o.useCallback((b,h)=>{const g=_t(b)??_t(e.cwd)??Ne,k=h??e.agent,f=Io(),C=No({sessionId:f,agent:k,cwd:g,approvalMode:e.approvalMode,model:sn(e.model),effort:e.effort||void 0,fastMode:e.fastMode,title:k==="codex"?e.t.newCodexSession:e.t.newClaudeSession}),N=e.activeSessionIdRef.current?"":Ot(e.composerDraftsRef.current,null);return e.setPendingSessions(v=>({...v,[f]:C})),e.setComposerDrafts(v=>{let d=Bt(v,f,N);return e.activeSessionIdRef.current||(d=Bt(d,null,"")),e.composerDraftsRef.current=d,Lt(d),d}),e.setCwd(g),e.setAgent(k),e.setActiveSessionId(f),e.lastHistorySessionIdRef.current=f,e.messagesSessionIdRef.current=f,e.clearHistoryLoading(),e.setMessages([]),e.setDraft(N),e.setErrorText(null),e.reportLog("web.session.pending_create",{sessionId:f,agent:k,cwd:g}),f},[e]),a=o.useCallback(async(b,h,g)=>{const k=e.clientRef.current;if(!k?.isConnected)return e.setErrorText(e.t.webSocketNotConnected),null;const f=g?e.pendingSessions[g]:void 0,C=_t(b)??_t(f?.cwd)??_t(e.cwd)??Ne,N=h??f?.agent??e.agent,v=f?.approvalMode??e.approvalMode,d=f?.model??sn(e.model),j=f?.effort??(e.effort||void 0),m=f?.fastMode??e.fastMode;e.setErrorText(null);try{const w=await k.request({action:"session.create",id:k.makeId("create"),agent:N,cwd:C,approvalMode:v,continueSession:e.continueSession,model:d,effort:j,fastMode:m,...g?{clientSessionId:g}:{}}),y=jo(w);if(!y)throw new Error(e.t.sessionIdMissing);const p=Ft(w)&&typeof w.oldSessionId=="string"?w.oldSessionId:g;return e.setCwd(C),e.setAgent(N),e.setActiveSessionId(y),e.lastHistorySessionIdRef.current=y,e.messagesSessionIdRef.current=y,e.clearHistoryLoading(),g&&f?(e.setPendingSessions(R=>{const _={...R};return delete _[g],p&&p!==g&&delete _[p],_}),e.setOptimisticSessions(R=>({...R,[y]:Ro(f,y)})),p&&p!==y&&e.remapLocalSessionState(p,y),g!==y&&e.remapLocalSessionState(g,y)):await e.requestSessions({force:!0}),e.reportLog("web.session.create",{sessionId:y,clientSessionId:g,agent:N,cwd:C}),y}catch(w){return e.setErrorText(w instanceof Error?w.message:String(w)),null}},[e]),l=o.useCallback(async b=>{b?.preventDefault();const h=e.draft.trim();if(!h||e.busy)return;const g=e.clientRef.current;if(!g?.isConnected){e.setErrorText(e.t.webSocketNotConnected);return}e.setBusy(!0),e.setErrorText(null),e.updateDraft("");const k=e.attachments;e.setAttachments([]);let f=e.activeSessionId,C=e.activeSession?.agent??e.agent;if(f&&e.pendingSessions[f]){const p=await a(e.pendingSessions[f].cwd,e.pendingSessions[f].agent,f);if(!p){e.setBusy(!1),e.updateDraft(h),e.setAttachments(k);return}f=p,C=e.pendingSessions[e.activeSessionId??""]?.agent??C}else f||(f=await a());if(!f){e.setBusy(!1),e.updateDraft(h),e.setAttachments(k);return}const N=k.length===0?Ko(h,C):null;if(N){const p=Go(N.command),R=p?g.makeId("cmd_msg"):void 0;p&&(e.messagesSessionIdRef.current=f,e.appendCachedHistory(f,[{role:"user",content:p,timestamp:new Date().toISOString()}]),e.renderCachedHistory(f));try{const _=await g.request({action:"session.command",id:g.makeId("command"),sessionId:f,agent:C,command:N.command,...R?{clientMessageId:R}:{},featureEntitlements:{agentCommands:"pro"}});await e.handleSessionCommandResponse(f,N.command,_)}catch(_){const z=_ instanceof Error?_.message:String(_);e.appendInfoMessage(f,As(z)),e.setErrorText(As(z))}finally{e.setBusy(!1)}return}const v=Qo(h),d=k.map(p=>p.path),j=g.makeId("msg"),m=`client:${j}`;e.messagesSessionIdRef.current=f,e.appendCachedHistory(f,[{role:"user",content:v,timestamp:new Date().toISOString(),historyKey:m,...d.length?{images:d}:{}}]),e.renderCachedHistory(f),e.respondingSessionsRef.current=new Set(e.respondingSessionsRef.current).add(f),e.setRespondingSessions(p=>new Set(p).add(f));const w=ec(v)??void 0,y=w?{agentSkills:"pro"}:void 0;try{const p=await g.request({action:"session.send",id:g.makeId("send"),sessionId:f,agent:C,message:v,clientMessageId:j,images:d.length?d:void 0,model:sn(e.model),effort:e.effort||void 0,fastMode:e.fastMode,skillInvocation:w,featureEntitlements:y},{timeoutMs:Js,timeoutMessage:Ys});Ft(p)&&typeof p.oldSessionId=="string"&&typeof p.sessionId=="string"&&e.remapLocalSessionState(p.oldSessionId,p.sessionId),e.reportLog("web.telemetry.send_accepted",{attachmentCount:d.length}),n(R=>R?.historyKey===m?null:R)}catch(p){const R=p instanceof Error?p.message:String(p),_=Gs(Ts(R,!!w));e.setErrorText(null),n({sessionId:f,agent:C,message:v,clientMessageId:j,historyKey:m,kind:_,retrying:!1,...d.length?{images:d}:{},model:sn(e.model),effort:e.effort||void 0,fastMode:e.fastMode,skillInvocation:w,featureEntitlements:y}),e.reportLog("web.telemetry.send_failed",{attachmentCount:d.length,failureKind:_},"warn"),r(f)}finally{e.setBusy(!1)}},[r,a,e]),c=o.useCallback(async()=>{if(!t||t.retrying||e.busy)return;const b=e.clientRef.current;if(!b?.isConnected){n(h=>h?{...h,kind:"network"}:null);return}n(h=>h?{...h,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(h=>new Set(h).add(t.sessionId));try{const h=await b.request({action:"session.send",id:b.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:Js,timeoutMessage:Ys});Ft(h)&&typeof h.oldSessionId=="string"&&typeof h.sessionId=="string"&&e.remapLocalSessionState(h.oldSessionId,h.sessionId),e.reportLog("web.telemetry.retry_accepted",{attachmentCount:t.images?.length??0}),n(null)}catch(h){const g=h instanceof Error?h.message:String(h),k=Gs(Ts(g,!!t.skillInvocation));n(f=>f?{...f,kind:k,retrying:!1}:null),e.reportLog("web.telemetry.retry_failed",{attachmentCount:t.images?.length??0,failureKind:k},"warn"),r(t.sessionId)}finally{e.setBusy(!1)}},[r,t,e]);return{failedSend:t,retryFailedSend:c,stagePendingSession:i,sendDraft:l}}const dd=new Set(["attachmentCount","domNodes","durationMs","errorKind","failureKind","longTaskCount","maxLongTaskMs","online","phase","visibilityState"]);function ud(e){const t={};for(const[n,r]of Object.entries(e))dd.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 Zs(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 fd(e){o.useEffect(()=>{const t=performance.now(),n=(h,g,k="info")=>e(h,ud(g),k),r=h=>{n("web.telemetry.runtime_error",{errorKind:Zs(h.error)},"error")},i=h=>{n("web.telemetry.unhandled_rejection",{errorKind:Zs(h.reason)},"error")},a=window.setTimeout(()=>{n("web.telemetry.workspace_ready",{durationMs:performance.now()-t,domNodes:document.getElementsByTagName("*").length,online:navigator.onLine,visibilityState:document.visibilityState})},1500);let l=0,c=0,b=null;return typeof PerformanceObserver<"u"&&PerformanceObserver.supportedEntryTypes.includes("longtask")&&(b=new PerformanceObserver(h=>{for(const g of h.getEntries())l+=1,c=Math.max(c,g.duration)}),b.observe({entryTypes:["longtask"]})),window.addEventListener("error",r),window.addEventListener("unhandledrejection",i),()=>{window.clearTimeout(a),window.removeEventListener("error",r),window.removeEventListener("unhandledrejection",i),b?.disconnect(),l>0&&n("web.telemetry.long_tasks",{longTaskCount:l,maxLongTaskMs:c},"warn")}},[e])}const hd=6;function md(e,t){return t.has(e.sessionId)||e.runtime?.isResponding===!0||e.runtime?.state==="daemonActive"||e.runtime?.state==="externalRunning"}function pd(e,t,n,r,i=hd){if(i<=0)return[];const a=[];for(const l of e){if(a.length>=i)break;!l.sessionId||!md(l,n)||pn(t,l.sessionId)||r.has(l.sessionId)||a.push(l)}return a}function gd(e,t){const n=t.trim().toLowerCase();return n?[qe(e),e.cwd,e.agent,e.branch??"",...e.titleAliases??[]].some(r=>r.toLowerCase().includes(n)):!0}function yd(e,t){return e.filter(n=>t.hideArchived&&n.archived||t.agentFilter!=="all"&&n.agent!==t.agentFilter?!1:gd(n,t.search))}function bd(){const e=o.useRef(null),t=o.useRef(async()=>{}),n=o.useRef(null),r=o.useRef(qn()),i=o.useRef(Fo()),a=o.useRef(Zi()),l=o.useRef(id()),c=o.useRef(wl()),b=o.useRef(r.current),h=o.useRef(i.current),g=o.useRef(l.current),k=o.useRef(null),f=o.useRef(null),C=o.useRef(new Set),N=o.useRef(null),v=o.useRef(new Set),d=o.useRef(null),j=o.useRef(0),m=o.useRef(new Set),w=o.useRef({}),y=o.useRef(!1),[p,R]=o.useState("connecting"),[_,z]=o.useState(()=>ws[vs(a.current.language)].preparingVibeletWeb),[ue,J]=o.useState(null),[ae,O]=o.useState(null),[oe,de]=o.useState([]),[ne,ve]=o.useState({}),[D,A]=o.useState({}),[W,$]=o.useState(),[ce,ye]=o.useState({}),[Y,K]=o.useState(),[B,Z]=o.useState(null),[se,fe]=o.useState(null),[X,U]=o.useState(()=>new Set),[te,Ce]=o.useState({}),[M,V]=o.useState({}),[_e,Pe]=o.useState({}),[We,be]=o.useState({}),[he,Re]=o.useState("claude"),[me,Fe]=o.useState(Ne),[$e,ze]=o.useState($n),[pe]=o.useState(!1),[Le,xe]=o.useState(""),[Ze,Te]=o.useState(""),[Ue,Ve]=o.useState(!1),[ke,Me]=o.useState(""),[x,P]=o.useState(l.current),[S,F]=o.useState(()=>Ot(l.current,null)),{webPreferences:Q,search:ge,setSearch:Xe,sinceFilter:et,setSinceFilter:bt,hideArchived:Ae,setHideArchived:Ht,groupFolders:xt,setGroupFolders:St,collapsedFolders:gn,setCollapsedFolders:Oe,sessionAgentFilter:Ee,setSessionAgentFilter:Wt,directoryTags:Ke,archiveSyncedDaemonIds:zt,archiveSyncCardDismissedDaemonIds:yn,composerPreferences:Ut,savedTargets:wt,setSavedTargets:Vt,leftSidebarCollapsed:vt,setLeftSidebarCollapsed:kt,rightSidebarCollapsed:jt,setRightSidebarCollapsed:E,workspaceClassName:G,wideMainClassName:re,workspaceStyle:je,beginPaneResize:Kt,commitSearch:Qt,saveTargets:lt,setLanguagePreference:De,updateSessionListPreferences:Ct,updateComposerPreferences:Gt}=sd(a.current,c.current),Qe=vs(Q.language),H=ws[Qe],[dt,bn]=o.useState(!1),[Be,It]=o.useState("session"),[Nr,xn]=o.useState(!1),Sn=o.useCallback(u=>{It(u),E(!1)},[E]),[Rr,Tr]=o.useState({}),[Mr,Ar]=o.useState({}),[Er,Dr]=o.useState([]),[Nt,_r]=o.useState({statusText:"",loading:!1,action:null}),[ut,Rt]=o.useState(Bn),[wn,Pr]=o.useState(i.current),[ft,ss]=o.useState(r.current),[rs,Fr]=o.useState(null),[$r,Lr]=o.useState(null),{attachments:is,setAttachments:as,uploadBusy:Or,directory:qr,setDirectory:os,newDirName:Br,setNewDirName:Hr,remoteFile:Jt,setRemoteFile:Wr,remoteFileConflict:zr,remoteFileMode:Ur,setRemoteFileMode:Vr,uploadFiles:Kr,openRemoteFile:cs,saveRemoteFile:Qr,downloadRemoteFile:Gr,listDirectory:vn,listSessionDirectories:Jr,createDirectory:Yr,createSessionDirectory:Zr}=Bl({clientRef:e,pairing:ae,cwd:me,phase:p,controlTab:Be,setControlTab:Sn,setBusy:bn,setErrorText:J,t:H}),tt=o.useMemo(()=>rn(rn(oe,Object.values(D)),Object.values(ne)),[D,ne,oe]),Xr=o.useMemo(()=>new Set(Object.keys(ne)),[ne]),nt=o.useMemo(()=>tt.find(u=>u.sessionId===B)??null,[B,tt]),ls=o.useMemo(()=>B&&te[B]?te[B]:Object.values(te)[0]??null,[B,te]),ds=o.useMemo(()=>B&&M[B]?M[B]:Object.values(M)[0]??null,[B,M]),Tt=Object.keys(te).length+Object.keys(M).length;o.useEffect(()=>{Tt!==0&&(It("session"),E(!1))},[Tt,E]);const ei=B?We[B]??[]:[],ti=Rr[he]??[],ni=Mr[he],kn=o.useMemo(()=>yd(tt,{search:ge,hideArchived:Ae,agentFilter:Ee}),[tt,Ae,ge,Ee]),si=o.useMemo(()=>To(kn),[kn]),{appendCachedDelta:ri,appendCachedHistory:us,appendInfoMessage:jn,clearHistoryLoading:ht,ensureCachedHistoryEntry:ii,historyCacheRef:Cn,historyLoading:ai,hydrateVisibleHistory:fs,messages:hs,messagesSessionIdRef:Ie,mergeCachedHistoryPage:oi,remapCachedHistory:ci,removeCachedHistory:li,renderCachedHistory:Mt,replaceCachedHistory:In,requestHistory:ms,setMessages:st}=Gl({activeSessionIdRef:n,clientRef:e,historyTimeoutMessage:H.historyRequestTimedOut,setErrorText:J});o.useEffect(()=>{n.current=B},[B]),o.useEffect(()=>{N.current=ae},[ae]),o.useEffect(()=>{m.current=X},[X]),o.useEffect(()=>{h.current=wn},[wn]),o.useEffect(()=>{b.current=ft},[ft]),o.useEffect(()=>{g.current=x},[x]);const ps=o.useCallback(u=>{F(u),P(I=>{const T=Bt(I,n.current,u);return g.current=T,Lt(T),T})},[]),gs=o.useCallback(u=>{P(I=>{const T=Bt(I,null,u);return g.current=T,Lt(T),T}),n.current||F(u)},[]);o.useEffect(()=>{Xi();const u=ea();u&&(gs(u),It("session"),ta())},[gs]),o.useEffect(()=>{Be==="admin"&&ss(qn())},[Be]),o.useEffect(()=>()=>{d.current&&window.clearTimeout(d.current),Jt?.objectUrl&&URL.revokeObjectURL(Jt.objectUrl)},[Jt?.objectUrl]);const At=o.useCallback((u,I=!1)=>{de(T=>rn(I?T:[],u.sessions)),A(T=>{const q=new Set(u.sessions.map(Se=>Se.sessionId)),ee=Object.fromEntries(Object.entries(T).filter(([Se])=>!q.has(Se)));return Object.keys(ee).length===Object.keys(T).length?T:ee}),$(u.nextCursor),K(u.inventoryVersion),u.folderCounts&&ye(u.folderCounts),I||Pl(N.current?.daemonId,u),z(u.inventoryBackfillInFlight?H.connectedIndexing:H.connected)},[H.connected,H.connectedIndexing]),Yt=Hl({clientRef:e,setSessions:de}),Zt=o.useCallback((u,I=m.current)=>{const T=e.current;if(!T?.isConnected||u.length===0)return;const q=pd(u,Cn.current,I,C.current);for(const ee of q)C.current.add(ee.sessionId),T.request({action:"session.history",id:T.makeId("history_prefetch"),sessionId:ee.sessionId,agent:ee.agent},{timeoutMessage:H.historyPrefetchTimedOut,timeoutMs:Hn}).catch(()=>{}).finally(()=>{C.current.delete(ee.sessionId)})},[H.historyPrefetchTimedOut]),ys=o.useCallback(u=>{const I=qo(u,{currentActiveSessionId:n.current,currentCwd:me});At(I.page,!1),$(I.page.nextCursor),K(I.page.inventoryVersion),I.messages&&I.activeSessionId&&fs(I.activeSessionId,I.messages),Z(I.activeSessionId),I.activeAgent&&Re(I.activeAgent),I.activeCwd&&Fe(I.activeCwd),I.activeApprovalMode&&ze(I.activeApprovalMode),I.questionAnswers&&Pe(I.questionAnswers),m.current=new Set(I.respondingSessionIds),U(m.current),Ce(I.pendingApprovals),V(I.pendingQuestions),be(I.pendingQueues),Yt(u.sessions),Zt(u.sessions,new Set(I.respondingSessionIds))},[me,Yt,fs,Zt,At]),bs=o.useCallback(async()=>{const u=e.current;if(!u?.isConnected)return;const I=await u.request({action:"reconnect.snapshot",id:u.makeId("snapshot"),activeSessionId:n.current??void 0,activeAgent:nt?.agent??he,agent:Ee==="all"?void 0:Ee,search:ge.trim()||void 0,sinceMs:Is(et),hideArchived:Ae,skipGitMetadata:!0});ys(I.snapshot)},[nt?.agent,he,ys,Ae,ge,Ee,et]),Ge=o.useCallback(async u=>{const I=e.current;if(!I?.isConnected)return;const T=await I.request({action:"sessions.list",id:I.makeId(u?.append?"sessions_more":"sessions"),limit:So,cursor:u?.cursor,agent:Ee==="all"?void 0:Ee,search:ge.trim()||void 0,sinceMs:Is(et),hideArchived:Ae,skipGitMetadata:!0,force:u?.force}),q=cr(T);At(q,u?.append),Z(ee=>ee??q.sessions[0]?.sessionId??null),Yt(q.sessions),Zt(q.sessions)},[Ae,Yt,Zt,ge,Ee,At,et]),xs=o.useCallback(async(u,I)=>{const T=e.current;if(T?.isConnected)try{const[q,ee,Se]=await Promise.all([T.request({action:"models.list",id:T.makeId("models"),agent:u}),T.request({action:"usage.limits.fetch",id:T.makeId("usage"),agent:u}),T.request({action:"skills.list",id:T.makeId("skills"),cwd:I||void 0})]);Tr(le=>({...le,[u]:q.options??[]})),Ar(le=>({...le,[u]:ee})),Dr(Array.isArray(Se.skills)?Se.skills:[])}catch(q){J(q instanceof Error?q.message:String(q))}},[]),Nn=o.useCallback((u,I,T="info")=>{const q=e.current;q?.isConnected&&q.request({action:"log.report",id:q.makeId("log"),entries:[{level:T,event:u,data:I,ts:new Date().toISOString()}]}).catch(()=>{})},[]);fd(Nn);const Xt=o.useCallback(async(u=N.current)=>{if(!u){Rt(Bn);return}Rt(I=>({...I,loading:!0,error:null}));try{const I=await fetch(Nl(u,window.location,{sameOrigin:!1}),{cache:"no-store"});if(!I.ok)throw new Error(`HTTP ${I.status}`);const T=Rl(await I.json().catch(()=>null));Rt({...T,loading:!1,error:null})}catch{Rt(I=>({...I,loading:!1,error:H.connectorVersionFailed}))}},[H.connectorVersionFailed]);o.useEffect(()=>{Be==="admin"&&p==="connected"&&Xt()},[Be,p,Xt]);const di=o.useCallback(u=>{Pr(I=>{const T={...I,...u};return h.current=T,$o(T),T})},[]),en=o.useCallback((u,I)=>{!u||!I||u===I||(Z(T=>T===u?I:T),k.current===u&&(k.current=I),Ie.current===u&&(Ie.current=I),ci(u,I),m.current=Ns(m.current,u,I),U(T=>Ns(T,u,I)),Ce(T=>An(T,u,I)),V(T=>An(T,u,I)),be(T=>An(T,u,I)),A(T=>{const q=T[u];if(!q)return T;const ee={...T};return delete ee[u],ee[I]={...q,sessionId:I},ee}),P(T=>{const q=ad(T,u,I);return q!==T&&(g.current=q,Lt(q)),q}))},[]),ui=o.useCallback(async(u,I,T)=>{const q=typeof T.sessionId=="string"?T.sessionId:u,ee=typeof T.oldSessionId=="string"?T.oldSessionId:u;ee&&q&&ee!==q&&en(ee,q),I.name==="clear"?(In(q,[]),be(Se=>{const le={...Se};return delete le[q],delete le[ee],le}),Ce(Se=>{const le={...Se};return delete le[q],delete le[ee],le}),V(Se=>{const le={...Se};return delete le[q],delete le[ee],le}),Z(q)):I.name==="new"?(Z(q),Ie.current=q,Mt(q)):I.name==="exit"?(de(Se=>Se.map(le=>le.sessionId===q?{...le,archived:!0}:le)),Z(null),Ie.current=null,k.current=null,st([])):I.name==="goal"&&"goal"in T&&jn(q,Jo(T.goal)),T.turnStarted&&!T.queued&&(m.current=new Set(m.current).add(q),U(Se=>new Set(Se).add(q))),await Ge({force:!0})},[jn,en,Mt,In,Ge]),fi=rd({notificationSettingsRef:h,notifiedEventsRef:v,notificationPermissionRef:b,activeSessionIdRef:n,respondingSessionsRef:m,turnNotificationCountsRef:w,t:H,setActiveSessionId:Z,setErrorText:J,setPendingQueues:be,setPendingApprovals:Ce,setPendingQuestions:V,setQuestionAnswers:Pe,setRespondingSessions:U,setSessions:de,remapLocalSessionState:en,requestSessions:Ge,clearHistoryLoading:ht,replaceCachedHistory:In,mergeCachedHistoryPage:oi,appendCachedHistory:us,appendCachedDelta:ri});Ll({clientRef:e,connectWithPairingRef:t,pairingRef:N,reconnectTimerRef:d,connectionAttemptIdRef:j,intentionalDisconnectRef:y,historyCacheRef:Cn,historyCacheDaemonIdRef:f,messagesSessionIdRef:Ie,lastHistorySessionIdRef:k,rememberedTarget:c.current[0]??null,agent:he,cwd:me,phase:p,search:ge,sinceFilter:et,t:H,handleServerMessage:fi,setPhase:R,setStatusText:z,setErrorText:J,setMessages:st,setPairing:O,setSavedTargets:Vt,setSessionsFromPage:At,refreshDaemonMetadata:Xt,requestReconnectSnapshot:bs,fetchAgentResources:xs,reportLog:Nn,requestSessions:Ge}),o.useEffect(()=>{const u=tt.find(I=>I.sessionId===B);if(!u){k.current=null,Ie.current=null,ht(),st([]),F(Ot(g.current,null));return}if(Re(u.agent),Fe(u.cwd||Ne),xe(u.model??""),Te(u.effort??""),Ve(u.fastMode??!1),ze(u.approvalMode??$n),Me(u.customTitle??u.title??""),F(Ot(g.current,u.sessionId)),os(I=>({...I,path:u.cwd||Ne,loaded:I.path===(u.cwd||Ne)?I.loaded:!1})),ne[u.sessionId]){k.current=u.sessionId,ht(),Ie.current!==u.sessionId&&(Ie.current=u.sessionId,st([]));return}if(Mt(u.sessionId)){k.current=u.sessionId,ht(u.sessionId);return}k.current!==u.sessionId&&(k.current=u.sessionId,Ie.current!==u.sessionId&&(Ie.current=u.sessionId,st([])),ms(u))},[B,ht,tt,ne,Mt,ms]);const{failedSend:hi,retryFailedSend:mi,stagePendingSession:pi,sendDraft:gi}=ld({clientRef:e,activeSessionIdRef:n,composerDraftsRef:g,lastHistorySessionIdRef:k,messagesSessionIdRef:Ie,respondingSessionsRef:m,agent:he,cwd:me,approvalMode:$e,continueSession:pe,model:Le,effort:Ze,fastMode:Ue,activeSessionId:B,activeSession:nt,pendingSessions:ne,draft:S,busy:dt,attachments:is,t:H,setPendingSessions:ve,setOptimisticSessions:A,setComposerDrafts:P,setCwd:Fe,setAgent:Re,setActiveSessionId:Z,setMessages:st,setDraft:F,setErrorText:J,setBusy:bn,setAttachments:as,setRespondingSessions:U,clearHistoryLoading:ht,reportLog:Nn,remapLocalSessionState:en,requestSessions:Ge,updateDraft:ps,appendCachedHistory:us,ensureCachedHistoryEntry:ii,renderCachedHistory:Mt,handleSessionCommandResponse:ui,appendInfoMessage:jn}),{respondApproval:yi,respondQuestion:bi,cancelQuestion:xi,setQuestionChoice:Si,requestActiveAction:wi,interruptActiveSession:vi,retrySessions:ki,updateApprovalMode:ji,cancelQueuedTurn:Ci,setSessionPinned:Ii,setSessionArchived:Ni,deleteSession:Ri,updatePinned:Ti,updateArchived:Mi,renameSession:Ai}=cd({clientRef:e,activeSessionIdRef:n,composerDraftsRef:g,lastHistorySessionIdRef:k,messagesSessionIdRef:Ie,respondingSessionsRef:m,activeApproval:ls,activeQuestion:ds,activeSession:nt,activeSessionId:B,questionAnswers:_e,pendingSessions:ne,phase:p,renameTitle:ke,setBusy:bn,setErrorText:J,setPendingApprovals:Ce,setPendingQuestions:V,setQuestionAnswers:Pe,setPendingQueues:be,setActiveSessionId:Z,setMessages:st,setApprovalMode:ze,setSessions:de,setPendingSessions:ve,setComposerDrafts:P,setDraft:F,setDetailsOpen:xn,setRespondingSessions:U,setOptimisticSessions:A,removeCachedHistory:li,requestSessions:Ge}),{runArchiveSync:Rn,skipArchiveSync:Ei,runAdminAction:Ss,exportActiveSession:Di,clearPairing:_i,setNotificationsEnabled:Pi,connectSavedTarget:Fi,forgetSavedTarget:$i,openSessionDetails:Li,editFolderTags:Oi,browseFolder:qi,copyResumeCommand:Bi}=Tl({clientRef:e,pairingRef:N,connectWithPairingRef:t,notificationPermissionRef:b,intentionalDisconnectRef:y,connectionAttemptIdRef:j,historyCacheRef:Cn,historyCacheDaemonIdRef:f,messagesSessionIdRef:Ie,lastHistorySessionIdRef:k,displaySessions:tt,pairing:ae,t:H,archiveSyncBusy:rs,daemonMetadata:ut,activeSession:nt,messages:hs,notificationPermission:ft,savedTargets:wt,directoryTags:Ke,setArchiveSyncBusy:Fr,setArchiveSyncStatus:Lr,setSessions:de,setAdmin:_r,setErrorText:J,setNotificationPermission:ss,setStatusText:z,setMessages:st,setPairing:O,setDaemonMetadata:Rt,setPhase:R,setActiveSessionId:Z,setRenameTitle:Me,setDetailsOpen:xn,setControlTab:Sn,updateSessionListPreferences:Ct,requestSessions:Ge,refreshDaemonMetadata:Xt,updateNotificationSettings:di,saveTargets:lt,listDirectory:vn}),Hi=ft==="denied"||ft==="unsupported",Wi=!!(ut.version&&ut.latestVersion&&Cl(ut.version,ut.latestVersion)),tn=ae?.daemonId,zi=!!(tn&&zt[tn]),Ui=!!(tn&&yn[tn]);return p==="missing-pair"?s.jsxs(s.Fragment,{children:[s.jsx("a",{className:"skip-link",href:"#vibelet-main-content",children:H.skipToConversation}),s.jsx($c,{errorText:ue,t:H})]}):s.jsxs("main",{className:G,id:"vibelet-workspace",style:je,children:[s.jsx("a",{className:"skip-link",href:"#vibelet-main-content",children:H.skipToConversation}),vt?s.jsx("button",{"aria-label":H.expandSessionSidebar,className:"sidebar-restore-button sidebar-restore-button-left",onClick:()=>kt(!1),title:H.expandSessionSidebar,type:"button",children:s.jsx(sr,{"aria-hidden":"true"})}):s.jsxs(s.Fragment,{children:[s.jsx(Jc,{activeSessionId:B,busy:dt,collapsedFolders:gn,currentCwd:me,directoryTags:Ke,displayName:ae?.displayName,folderCounts:ce,groupFolders:xt,groupedSessions:si,hideArchived:Ae,inventoryVersion:Y,nextCursor:W,phase:p,respondingSessionIds:X,search:ge,sessionAgentFilter:Ee,sessionsCount:tt.length,sinceFilter:et,statusText:_,t:H,visibleSessions:kn,onLoadMore:u=>{Ge({append:!0,cursor:u})},onBrowseFolder:qi,onCopyResumeCommand:Bi,onCreateDirectory:Zr,pendingSessionIds:Xr,onCreateSession:(u,I)=>{pi(u,I)},onDeleteSession:u=>{Ri(u)},onEditFolderTags:Oi,onListDirectories:Jr,onOpenSessionDetails:Li,onResetFilters:()=>{Wt("all"),bt("30d"),Ht(!1),St(!1)},onSearchChange:Xe,onSearchCommit:Qt,onSelectSession:Z,onToggleSessionArchived:u=>{Ni(u,!u.archived)},onToggleSessionPinned:u=>{Ii(u,!u.pinned)},onSessionAgentFilterChange:Wt,onSinceFilterChange:bt,onViewChanges:fe,onToggleFolder:u=>Oe(I=>({...I,[u]:!I[u]})),onToggleGroupFolders:()=>St(u=>!u),onToggleHideArchived:()=>Ht(u=>!u),onToggleCollapse:()=>kt(!0)}),s.jsx("button",{"aria-label":H.resizeSessionSidebar,className:"resize-handle",onPointerDown:Kt("left"),title:H.resizeSessionSidebar,type:"button",children:s.jsx("span",{})})]}),s.jsxs("section",{className:re,"aria-label":H.vibeletWorkspace,id:"vibelet-main-content",tabIndex:-1,children:[s.jsx(Fc,{activeSession:nt,activeSessionId:B,activeModelOptions:ti,activeQueue:ei,activeUsage:ni,agent:he,approvalMode:$e,attachments:is,busy:dt,cwd:me,draft:S,effort:Ze,errorText:ue,failedSend:hi,fastMode:Ue,historyLoading:ai,messages:hs,model:Le,phase:p,quickReplies:Ut.quickReplies,renameTitle:ke,respondingSessionIds:X,sendShortcut:Ut.sendShortcut,skills:Er,uploadBusy:Or,detailsOpen:Nr,controlsOpen:!jt,pendingActionsCount:Tt,t:H,onApprovalModeChange:u=>{ji(u)},onBrowseFiles:()=>{const u=nt?.cwd||me||Ne;Sn("files"),vn(u,{updateRoute:!0})},onCancelQueuedTurn:u=>{Ci(u)},onClearInterrupt:()=>{wi("session.clearInterrupt")},onDraftChange:ps,onDetailsOpenChange:xn,onEffortChange:Te,onExportActiveSession:()=>{Di()},onFastModeChange:Ve,onRetryFailedSend:mi,onModelChange:xe,onOpenRemoteFile:(u,I)=>{cs(u,I,{updateRoute:!0})},onOpenControls:()=>{jt&&Tt===0&&Be==="session"&&It("files"),E(u=>!u)},onInterrupt:vi,onRetry:ki,onRefreshSessions:()=>{Ge({force:!0})},onRenameSession:()=>{Ai()},onRenameTitleChange:Me,onRemoveAttachment:u=>as(I=>I.filter(T=>T.path!==u)),onRestoreSnapshot:()=>{bs()},onRefreshSkills:()=>{xs(nt?.agent??he,me)},onSendShortcutChange:u=>Gt(I=>({...I,sendShortcut:u})),onSubmit:gi,onToggleArchived:()=>{Mi()},onTogglePinned:()=>{Ti()},onUploadFiles:Kr,onViewChanges:fe}),jt?null:s.jsxs(Zc,{t:H,value:Be,showSession:Tt>0,onChange:It,onClose:()=>E(!0),children:[Be==="session"?s.jsx(Kc,{activeApproval:ls,activeQuestion:ds,busy:dt,questionAnswers:_e,t:H,onCancelQuestion:()=>{xi()},onQuestionChoice:Si,onRespondApproval:u=>{yi(u)},onRespondQuestion:()=>{bi()}}):null,Be==="files"?s.jsx(o.Suspense,{fallback:s.jsx(Fs,{t:H}),children:s.jsx(Lc,{busy:dt,cwd:me,directory:qr,newDirName:Br,remoteFile:Jt,remoteFileConflict:zr,remoteFileMode:Ur,t:H,onCreateDirectory:()=>{Yr()},onDirectoryPathChange:u=>os(I=>({...I,path:u,loaded:!1})),onDownloadRemoteFile:()=>{Gr()},onListDirectory:u=>{vn(u,{updateRoute:!0})},onNewDirNameChange:Hr,onOpenRemoteFile:(u,I)=>{cs(u,I,{updateRoute:!0})},onRemoteFileModeChange:Vr,onRemoteFileTextChange:u=>Wr(I=>I&&{...I,text:u,dirty:!0}),onSaveRemoteFile:u=>{Qr(u)}})}):null,Be==="admin"?s.jsxs(o.Suspense,{fallback:s.jsx(Fs,{t:H}),children:[s.jsx(qc,{pairing:ae,phase:p,t:H,onForgetPairing:_i}),s.jsx(Hc,{language:Q.language,t:H,onLanguageChange:De}),s.jsx(zc,{activeDaemonId:ae?.daemonId,busy:dt,t:H,targets:wt,onConnect:Fi,onForget:$i}),s.jsx(Wc,{notificationsBlocked:Hi,permission:ft,settings:wn,t:H,onToggleEnabled:Pi}),s.jsx(Oc,{busy:rs,connected:p==="connected",dismissed:Ui,feedback:$r,synced:zi,t:H,onPull:()=>{Rn("pull")},onPushMerge:()=>{Rn("pushMerge")},onPushReplace:()=>{Rn("pushReplace")},onSkip:Ei}),s.jsx(Bc,{connected:p==="connected",metadata:ut,restartBusy:Nt.loading&&Nt.action==="restart",showUpdate:Wi,t:H,updateBusy:Nt.loading&&Nt.action==="update",updateStatus:Nt.statusText,onRestart:()=>{Ss("restart")},onUpdate:()=>{Ss("update")}})]}):null]})]}),s.jsx(Vc,{client:e.current,close:()=>fe(null),id:se,sessions:oe,t:H})]})}const Sd=Object.freeze(Object.defineProperty({__proto__:null,App:bd},Symbol.toStringTag,{value:"Module"}));export{Sd as A,Qc as C,mt as F,qa as K,Cs as L,pt as R,po as T,we as X,js as a,mn as b,ko as c,gt as d,er as e,Gn as f,On as j,Rs as p,Zn as u};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-O7DHMXV3-nvIRGE2J.js","assets/index-uoLYFezU.js","assets/index-D3gAUQHc.css","assets/mermaid-O7DHMXV3-BPtfCfol.css"])))=>i.map(i=>d[i]);
2
- import{c as b,j as e,r as v,_ as C,D as _}from"./index-uoLYFezU.js";import{L as P,R as M,p as m,F as T,j as D,a as y,b as u,c as E,d as I,e as L}from"./App-CVkhf43f.js";import{F as g}from"./file-text-C6lQdXN2.js";const z=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],F=b("image",z);const R=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],S=b("save",R);function U({cwd:n,entries:i,error:t,loaded:l,loading:c,path:s,t:d,onPathChange:a,onListDirectory:o,onOpenRemoteFile:x}){return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"field",children:[e.jsx("span",{children:d.path}),e.jsxs("div",{className:"field-row",children:[e.jsx("input",{value:s,onChange:r=>a(r.target.value)}),e.jsx("button",{className:"icon-button",onClick:()=>o(),type:"button",children:c?e.jsx(P,{"aria-hidden":"true"}):e.jsx(M,{"aria-hidden":"true"})})]})]}),t?e.jsx("p",{className:"empty-copy",children:t}):null,c?e.jsx("p",{className:"empty-copy",children:d.loadingFiles}):null,e.jsxs("div",{className:"file-list tree-list",children:[m(s)?e.jsxs("button",{onClick:()=>o(m(s)??s),type:"button",children:[e.jsx(T,{"aria-hidden":"true"}),".."]}):null,i.map(r=>{const h=D(s,r.name);return e.jsxs("button",{onClick:()=>r.isDirectory?o(h):x(h,n),type:"button",children:[r.isDirectory?e.jsx(y,{"aria-hidden":"true"}):e.jsx(g,{"aria-hidden":"true"}),r.name]},`${r.name}:${r.isDirectory}`)})]}),l&&!c&&!t&&i.length===0?e.jsx("p",{className:"empty-copy",children:d.noFilesInDirectory}):null]})}const V=v.lazy(()=>C(()=>import("./mermaid-O7DHMXV3-nvIRGE2J.js").then(n=>n.a),__vite__mapDeps([0,1,2,3])).then(n=>({default:n.MessageMarkdown})));function $({file:n,mode:i,onModeChange:t,onOpenRemoteFile:l,onTextChange:c}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"segmented editor-mode-tabs",children:[e.jsx("button",{className:i==="edit"?"selected":"",onClick:()=>t("edit"),type:"button",children:"Editor"}),e.jsx("button",{className:i==="preview"?"selected":"",onClick:()=>t("preview"),type:"button",children:"Preview"}),e.jsx("button",{className:i==="source"?"selected":"",onClick:()=>t("source"),type:"button",children:"Source"})]}),i==="edit"?e.jsx("textarea",{className:"remote-editor",value:n.text,onChange:s=>c(s.target.value),rows:14}):i==="preview"?e.jsx("div",{className:"remote-markdown-preview",children:e.jsx(v.Suspense,{fallback:e.jsx("pre",{className:"json-box source-viewer",children:n.text}),children:e.jsx(V,{content:n.text,baseCwd:n.cwd,onOpenRemoteFile:l})})}):e.jsx("pre",{className:"json-box source-viewer",children:n.text})]})}function B({busy:n,cwd:i,directory:t,newDirName:l,remoteFileMode:c,remoteFile:s,remoteFileConflict:d,t:a,onCreateDirectory:o,onDirectoryPathChange:x,onDownloadRemoteFile:r,onListDirectory:h,onNewDirNameChange:N,onOpenRemoteFile:j,onRemoteFileModeChange:w,onRemoteFileTextChange:k,onSaveRemoteFile:p}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section",children:[e.jsx("h2",{children:a.fileTree}),e.jsx(U,{cwd:i,entries:t.entries,error:t.error,loaded:t.loaded,loading:t.loading,path:t.path,t:a,onListDirectory:h,onOpenRemoteFile:j,onPathChange:x}),e.jsxs("div",{className:"field-row",children:[e.jsx("input",{value:l,onChange:f=>N(f.target.value),placeholder:a.newFolder}),e.jsxs("button",{className:"icon-text-button",onClick:o,type:"button",disabled:!l.trim(),children:[e.jsx(y,{"aria-hidden":"true"}),a.create]})]})]}),e.jsxs("section",{className:"control-section remote-file-section",children:[e.jsx("h2",{children:a.remoteFile}),s?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"file-title",children:[s.kind==="image"?e.jsx(F,{"aria-hidden":"true"}):e.jsx(g,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:u(s.path)}),e.jsxs("span",{children:[s.contentType," · ",E(s.size)]})]})]}),e.jsxs("div",{className:"attention-actions",children:[e.jsxs("button",{className:"icon-text-button",onClick:r,type:"button",children:[e.jsx(_,{"aria-hidden":"true"}),a.download]}),e.jsxs("button",{className:"icon-text-button",onClick:()=>navigator.clipboard?.writeText(s.path),type:"button",children:[e.jsx(I,{"aria-hidden":"true"}),a.copyPath]})]}),s.kind==="text"?e.jsxs(e.Fragment,{children:[e.jsx($,{file:s,mode:c,onModeChange:w,onOpenRemoteFile:j,onTextChange:k}),e.jsxs("button",{className:"primary-button full-width",disabled:!s.dirty||n,onClick:()=>p(),type:"button",children:[e.jsx(S,{"aria-hidden":"true"}),a.saveFile]}),d?e.jsxs("div",{className:"notice warning inline-notice",children:[e.jsx(L,{"aria-hidden":"true"}),e.jsx("span",{children:a.remoteFileConflict(s.path)}),e.jsx("button",{className:"danger-button",disabled:n,onClick:()=>window.confirm(a.confirmOverwrite(u(s.path)))&&p({force:!0}),type:"button",children:a.forceSave})]}):null]}):s.kind==="image"&&s.objectUrl?e.jsx("img",{className:"remote-image",src:s.objectUrl,alt:u(s.path)}):e.jsx("p",{className:"empty-copy",children:a.binaryPreviewUnavailable})]}):e.jsx("p",{className:"empty-copy",children:a.selectRemoteFile})]})]})}export{B as FilesControlPanel};
@@ -1 +0,0 @@
1
- import{j as a}from"./index-uoLYFezU.js";import{C as i}from"./App-CVkhf43f.js";function c({language:l,t:e,onLanguageChange:s}){return a.jsxs("section",{className:"control-section compact-section",children:[a.jsx("h2",{children:e.language}),a.jsxs("label",{className:"field",children:[a.jsx("span",{children:e.displayLanguage}),a.jsx(i,{ariaLabel:e.displayLanguage,options:[{value:"system",label:e.followSystem},{value:"en",label:e.english},{value:"zh",label:e.chinese}],value:l,onChange:n=>s(n)})]})]})}export{c as LanguageSettingsPanel};
@@ -1 +0,0 @@
1
- import{R as c,M as p,B as x}from"./mermaid-O7DHMXV3-nvIRGE2J.js";import{r,j as d}from"./index-uoLYFezU.js";var R=({code:i,language:e,raw:t,className:g,startLine:u,...m})=>{let{shikiTheme:o}=r.useContext(c),a=p(),[n,s]=r.useState(t);return r.useEffect(()=>{if(!a){s(t);return}let l=a.highlight({code:i,language:e,themes:o},h=>{s(h)});l&&s(l)},[i,e,o,a,t]),d.jsx(x,{className:g,language:e,result:n,startLine:u,...m})};export{R as HighlightedCodeBlockBody};