@jean2/client 0.8.3 → 1.0.2

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 (70) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/ServerContext-CBFiY6IH.js +1 -0
  3. package/dist/assets/SessionContent-BUi72_iy.js +9 -0
  4. package/dist/assets/{SessionMenuButton-BRiMfAN5.js → SessionMenuButton-CMaV4kEA.js} +3 -3
  5. package/dist/assets/ThemeProvider-Da23NPAS.js +1 -0
  6. package/dist/assets/_serverId-BvST5YDe.js +12 -0
  7. package/dist/assets/_serverId-DfPzo4bd.js +1 -0
  8. package/dist/assets/_serverId-MO9g8fX9.js +2 -0
  9. package/dist/assets/_sessionId-CPP8h5aK.js +1 -0
  10. package/dist/assets/_sessionId-DBdXwlmj.js +1 -0
  11. package/dist/assets/alert-3Kbxsvve.js +31 -0
  12. package/dist/assets/badge-CzDK507L.js +45 -0
  13. package/dist/assets/compiler-runtime-DZXZ41-q.js +1 -0
  14. package/dist/assets/confirmation-dialog-x-_jBxq9.js +1 -0
  15. package/dist/assets/core-B5tm5Pq5.js +1 -0
  16. package/dist/assets/createLucideIcon-BYAVpx9Z.js +1 -0
  17. package/dist/assets/dist-js-CnIJv7bh.js +1 -0
  18. package/dist/assets/{event-qUXFERHS.js → event-Bg5mre8h.js} +1 -1
  19. package/dist/assets/index-gpIdz2Xy.css +2 -0
  20. package/dist/assets/index-wGbWnMXW.js +10 -0
  21. package/dist/assets/overview-B_ZDrH1J.js +1 -0
  22. package/dist/assets/overview-mSGJdfsz.js +1 -0
  23. package/dist/assets/platform-5d-ZQG2e.js +1 -0
  24. package/dist/assets/popover-EEh8MoGn.js +1 -0
  25. package/dist/assets/{preload-helper-CYlqXMwt.js → preload-helper-D-tEmku_.js} +1 -1
  26. package/dist/assets/routes-WPmRqSvV.js +1 -0
  27. package/dist/assets/scroll-area-zE8JtjlC.js +1 -0
  28. package/dist/assets/{server-BNi58bIU.js → server-g7It7jLf.js} +1 -1
  29. package/dist/assets/servers-GmYSnzvH.js +1 -0
  30. package/dist/assets/sidebar-BULcvh4r.js +1 -0
  31. package/dist/assets/src-9dJwbSJY.js +1 -0
  32. package/dist/assets/{triangle-alert-DxjucLze.js → triangle-alert-BOCjiWM3.js} +1 -1
  33. package/dist/assets/useNavigate-Dxc8FNpV.js +1 -0
  34. package/dist/assets/useParams-RuFKFrOo.js +1 -0
  35. package/dist/assets/useRouterState-C1XfNwIo.js +1 -0
  36. package/dist/assets/workspace-BDB9L3JR.js +1 -0
  37. package/dist/assets/workspace-_n12Hx4o.js +1 -0
  38. package/dist/index.html +12 -13
  39. package/package.json +1 -1
  40. package/dist/assets/ServerContext-D9RfmQC6.js +0 -1
  41. package/dist/assets/SessionContent-DAoBLNGO.js +0 -9
  42. package/dist/assets/ThemeProvider-JPllbGvS.js +0 -1
  43. package/dist/assets/_serverId-Bd-hxE5e.js +0 -2
  44. package/dist/assets/_serverId-CsnPjy9K.js +0 -12
  45. package/dist/assets/_serverId-XYC72_6_.js +0 -1
  46. package/dist/assets/_sessionId-C96NK5UN.js +0 -1
  47. package/dist/assets/_sessionId-DdW2fnoe.js +0 -1
  48. package/dist/assets/alert-DeW1kArF.js +0 -31
  49. package/dist/assets/badge-DUoauaaV.js +0 -45
  50. package/dist/assets/confirmation-dialog-DeIbHoOu.js +0 -1
  51. package/dist/assets/core-CblztWA2.js +0 -1
  52. package/dist/assets/createLucideIcon-BaO6wACO.js +0 -1
  53. package/dist/assets/dropdown-menu-kSrbs3Xk.js +0 -1
  54. package/dist/assets/index-0foRHKn1.js +0 -10
  55. package/dist/assets/index-Bv9FJWM6.css +0 -2
  56. package/dist/assets/jsx-runtime-D-oznMWL.js +0 -1
  57. package/dist/assets/overview-ZVTPIcDN.js +0 -1
  58. package/dist/assets/overview-b6wqapV-.js +0 -1
  59. package/dist/assets/platform-Bn4qAxt4.js +0 -1
  60. package/dist/assets/popover-DqniPNsl.js +0 -1
  61. package/dist/assets/react-DcCgrBX5.js +0 -1
  62. package/dist/assets/routes-BbfnvJnQ.js +0 -1
  63. package/dist/assets/scroll-area-DVew28V6.js +0 -1
  64. package/dist/assets/servers-CGl9kUR2.js +0 -1
  65. package/dist/assets/src-w2G0llvL.js +0 -1
  66. package/dist/assets/useNavigate-5b_LZg00.js +0 -1
  67. package/dist/assets/useParams-BODsv_8k.js +0 -1
  68. package/dist/assets/useRouterState-FezJSBQO.js +0 -1
  69. package/dist/assets/workspace-B2-0-561.js +0 -1
  70. package/dist/assets/workspace-BfFnK9TP.js +0 -1
package/dist/index.html CHANGED
@@ -38,19 +38,18 @@
38
38
  root.classList.add(mode, scheme);
39
39
  })();
40
40
  </script>
41
- <script type="module" crossorigin src="./assets/index-0foRHKn1.js"></script>
42
- <link rel="modulepreload" crossorigin href="./assets/jsx-runtime-D-oznMWL.js">
43
- <link rel="modulepreload" crossorigin href="./assets/react-DcCgrBX5.js">
44
- <link rel="modulepreload" crossorigin href="./assets/src-w2G0llvL.js">
45
- <link rel="modulepreload" crossorigin href="./assets/servers-CGl9kUR2.js">
46
- <link rel="modulepreload" crossorigin href="./assets/useParams-BODsv_8k.js">
47
- <link rel="modulepreload" crossorigin href="./assets/preload-helper-CYlqXMwt.js">
48
- <link rel="modulepreload" crossorigin href="./assets/platform-Bn4qAxt4.js">
49
- <link rel="modulepreload" crossorigin href="./assets/useNavigate-5b_LZg00.js">
50
- <link rel="modulepreload" crossorigin href="./assets/_serverId-Bd-hxE5e.js">
51
- <link rel="modulepreload" crossorigin href="./assets/ThemeProvider-JPllbGvS.js">
52
- <link rel="modulepreload" crossorigin href="./assets/ServerContext-D9RfmQC6.js">
53
- <link rel="stylesheet" crossorigin href="./assets/index-Bv9FJWM6.css">
41
+ <script type="module" crossorigin src="./assets/index-wGbWnMXW.js"></script>
42
+ <link rel="modulepreload" crossorigin href="./assets/compiler-runtime-DZXZ41-q.js">
43
+ <link rel="modulepreload" crossorigin href="./assets/src-9dJwbSJY.js">
44
+ <link rel="modulepreload" crossorigin href="./assets/servers-GmYSnzvH.js">
45
+ <link rel="modulepreload" crossorigin href="./assets/useParams-RuFKFrOo.js">
46
+ <link rel="modulepreload" crossorigin href="./assets/preload-helper-D-tEmku_.js">
47
+ <link rel="modulepreload" crossorigin href="./assets/platform-5d-ZQG2e.js">
48
+ <link rel="modulepreload" crossorigin href="./assets/useNavigate-Dxc8FNpV.js">
49
+ <link rel="modulepreload" crossorigin href="./assets/_serverId-MO9g8fX9.js">
50
+ <link rel="modulepreload" crossorigin href="./assets/ThemeProvider-Da23NPAS.js">
51
+ <link rel="modulepreload" crossorigin href="./assets/ServerContext-CBFiY6IH.js">
52
+ <link rel="stylesheet" crossorigin href="./assets/index-gpIdz2Xy.css">
54
53
  </head>
55
54
  <body>
56
55
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jean2/client",
3
- "version": "0.8.3",
3
+ "version": "1.0.2",
4
4
  "description": "Jean2 AI Agent Client - Run the Jean2 web UI locally via npx",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./servers-CGl9kUR2.js";var f=e(n(),1);function p(e){return/^[a-f0-9]{64}$/.test(e)}function m(e){return e.length<12?e:`${e.slice(0,4)}...${e.slice(-4)}`}function h(e){let t=e.trim(),n=/^https:\/\//i.test(t),r=t.replace(/^(https?:\/\/|wss?:\/\/)/i,``);return r=r.replace(/\/+$/,``),n&&(r=`https://${r}`),r}var g=t(),_=(0,f.createContext)(null),v=({children:e})=>{let[t,n]=(0,f.useState)([]),[p,m]=(0,f.useState)([]),[v,y]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=a(),t=l();n(e),m(t),y(!0)},[]);let b={servers:t,quickConnections:p,isHydrated:v,addServer:(0,f.useCallback)((e,t,r)=>{let o=h(t),s={id:crypto.randomUUID(),name:e,url:o,token:r,createdAt:new Date().toISOString()};return i(s),n(a()),s},[]),editServer:(0,f.useCallback)((e,t)=>{o(e,{...t,...t.url&&{url:h(t.url)}}),n(a())},[]),removeServer:(0,f.useCallback)(e=>{s(e),n(a()),m(l())},[]),addToQuickConnections:(0,f.useCallback)((e,t,n,r)=>{d({serverId:e,serverName:t,workspaceId:n,workspaceName:r}),m(l())},[]),removeFromQuickConnections:(0,f.useCallback)(e=>{r(e),m(l())},[]),removeFromQuickConnectionsByWorkspace:(0,f.useCallback)(e=>{c(e),m(l())},[]),reorderQuick:(0,f.useCallback)(e=>{u(e),m(l())},[])};return(0,g.jsx)(_.Provider,{value:b,children:e})},y=()=>{let e=(0,f.useContext)(_);if(e===null)throw Error(`useServerContext must be used within a ServerProvider`);return e};export{h as a,m as i,y as n,p as r,v as t};
@@ -1,9 +0,0 @@
1
- import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{i as r}from"./src-w2G0llvL.js";import{Q as i,X as a,Z as o,a as s,at as c,bt as l,c as u,ct as d,et as f,f as p,ft as m,gt as h,h as g,ht as _,i as v,lt as y,m as b,mt as x,n as S,nt as C,o as w,p as T,pt as E,r as D,rt as O,s as k,st as A,t as j,u as M,ut as N}from"./badge-DUoauaaV.js";import{t as P}from"./createLucideIcon-BaO6wACO.js";import{n as ee,t as F}from"./confirmation-dialog-DeIbHoOu.js";import{_ as I,a as L,c as R,d as z,f as te,g as B,h as V,i as H,l as U,m as ne,n as re,o as ie,p as ae,r as oe,s as se,t as ce,u as le}from"./alert-DeW1kArF.js";import{a as W,b as ue,c as G,f as de,i as K,l as q,n as fe,o as pe,r as J,s as me,t as Y,u as X,x as Z}from"./popover-DqniPNsl.js";import{i as he,n as ge,r as _e,t as ve}from"./triangle-alert-DxjucLze.js";function ye(e){return e.role===`assistant`}var be=P(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),xe=P(`bot`,[[`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`}]]),Se=P(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ce=P(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),we=P(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Te=P(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ee=P(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),De=P(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Oe=P(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),ke=P(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Ae=P(`image`,[[`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`}]]),je=P(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Me=P(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Ne=P(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Pe=P(`paperclip`,[[`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`}]]),Fe=P(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Ie=P(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Le=P(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Re=P(`wrench`,[[`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`}]]),Q=t();function ze(){return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(N,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Loading conversation...`})]})}function Be({message:e=`Connecting to server...`}){return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(N,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:e})]})}var Ve=({serverUrl:e,authError:t,retryCount:n,nextRetryIn:r,onRetry:i,onLogout:a})=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] px-4 text-center`,children:[(0,Q.jsx)(Le,{className:`size-12 text-destructive mb-4`}),(0,Q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground mb-2`,children:`Unable to connect to server`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-[400px]`,children:t||`Please check that the server is running.`}),e&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-6 font-mono bg-muted px-3 py-1.5 rounded`,children:e}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Retrying in `,r,`s...`]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(p,{onClick:i,variant:`default`,children:[(0,Q.jsx)(U,{className:`size-4 mr-2`,"data-icon":`inline-start`}),`Retry Now`]}),(0,Q.jsx)(p,{onClick:a,variant:`ghost`,children:`Change Server`})]}),n>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retry attempt: `,n]})]})]}),$=e(n(),1);function He(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:e.toString()}function Ue(e){return e>=60?`critical`:e>=40?`warning`:`normal`}function We({totalTokens:e=0,contextWindow:t=0,modelName:n,compact:r}){let[i,a]=(0,$.useState)(!1),o=e===0?0:t,s=o===0?0:Math.min(100,Math.round(e/o*100)),c=Ue(s),l=2*Math.PI*8,u=l*(1-s/100);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:()=>a(!i),children:[(0,Q.jsxs)(`svg`,{viewBox:`0 0 20 20`,className:`size-5`,fill:`none`,children:[(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:`text-muted-foreground/20`,strokeWidth:`3`}),(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:s===0?`text-muted-foreground/30`:c===`critical`?`text-destructive`:c===`warning`?`text-warning`:`text-primary`,strokeWidth:`3`,strokeDasharray:l,strokeDashoffset:u,strokeLinecap:`round`,transform:`rotate(-90 10 10)`,style:{transition:`stroke-dashoffset 0.3s ease`}})]}),(0,Q.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:i?`${He(e)}/${He(o)}`:`${s}%`})]})}function Ge(e){switch(e){case`budget`:return`$`;case`standard`:return`$$`;case`premium`:return`$$$`;default:return``}}function Ke({models:e,selectedModelId:t,onChangeModel:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1),c=e.reduce((e,t)=>(e[t.providerName]||(e[t.providerName]=[]),e[t.providerName].push(t),e),{}),l=t=>{let r=e.find(e=>e.id===t);r&&(n(t,r.providerId),s(!1))},u=e.find(e=>e.id===t);return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,disabled:r,children:(0,Q.jsx)(ne,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:r,children:[(0,Q.jsx)(ne,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:r,children:[(0,Q.jsx)(ne,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:(u==null?void 0:u.name)||`Select model`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]})}var qe={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-High`,minimal:`Minimal`,max:`Max`};function Je(e){return qe[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Ye({variants:e,selectedVariant:t,onChangeVariant:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1);if(!e||Object.keys(e).length===0)return null;let c=Object.keys(e),l=e=>{n(e===`__none__`?null:e),s(!1)},u=t?Je(t):`Default`,d=(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsxs)(q,{value:`__none__`,onSelect:()=>l(`__none__`),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:`Default`}),(0,Q.jsx)(_,{className:T(`size-4`,t===null?`opacity-100`:`opacity-0`)})]},`__none__`),c.map(e=>(0,Q.jsxs)(q,{value:e,onSelect:()=>l(e),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:Je(e)}),(0,Q.jsx)(_,{className:T(`size-4`,t===e?`opacity-100`:`opacity-0`)})]},e))]})]});return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:(0,Q.jsx)(Se,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:[(0,Q.jsx)(Se,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:[(0,Q.jsx)(Se,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:u}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]})}function Xe({preconfigs:e,selectedPreconfigId:t,onChangePreconfig:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1),c=e.find(e=>e.id===t),l=e=>{n(e),s(!1)};return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:(0,Q.jsx)(R,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:[(0,Q.jsx)(R,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:[(0,Q.jsx)(R,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:(c==null?void 0:c.name)||`Select config`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]})}function Ze({session:e,preconfigs:t,models:n,usage:r,modelName:i,onChangePreconfig:a,onChangeModel:o,onChangeVariant:c,onRename:l,onNavigateBack:d,isStreaming:f,onInterrupt:m,onCompact:h,isCompacting:_,canCompact:v,selectedVariant:y,variants:x}){var S;let[C,T]=(0,$.useState)(!1),[E,D]=(0,$.useState)(e.title||``),O=(0,$.useRef)(null),A=g(),N=b();(0,$.useEffect)(()=>{C&&O.current&&(O.current.focus(),O.current.select())},[C]);let P=()=>{D(e.title||``),T(!0)},F=()=>{let t=E.trim();t&&t!==e.title&&l(e.id,t),T(!1)},L=t=>{t.key===`Enter`?F():t.key===`Escape`&&(D(e.title||``),T(!1))},R=e.selectedModel||((S=t.find(t=>t.id===e.preconfigId))==null?void 0:S.model)||i,z=n.find(e=>e.id===R),te=z==null?void 0:z.contextWindow;return(0,Q.jsx)(`header`,{className:`flex flex-col border-b border-border bg-card`,children:(0,Q.jsx)(k,{delayDuration:300,children:(0,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center md:justify-between px-4 py-1 gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[e.parentId&&d&&(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,onClick:d,className:`h-7`,children:[(0,Q.jsx)(I,{className:`size-4`,"data-icon":`inline-start`}),`Back`]}),C?(0,Q.jsx)(`input`,{ref:O,type:`text`,value:E,onChange:e=>D(e.target.value),onBlur:F,onKeyDown:L,className:`text-base font-semibold bg-background border border-primary rounded px-2 py-0.5 outline-none min-w-0 flex-1`,autoFocus:!0}):(0,Q.jsx)(`h2`,{className:`text-base font-semibold cursor-pointer px-2 py-0.5 -mx-2 rounded hover:bg-accent transition-colors truncate min-w-0`,onDoubleClick:P,children:e.title||`Untitled Session`}),(0,Q.jsx)(We,{promptTokens:r.promptTokens,completionTokens:r.completionTokens,totalTokens:r.totalTokens,contextWindow:te,modelName:i,compact:A}),e.status===`closed`&&(0,Q.jsxs)(j,{variant:`secondary`,children:[(0,Q.jsx)(ee,{className:`size-3`,"data-icon":`inline-start`}),`Archived`]})]}),(0,Q.jsx)(M,{className:`md:hidden`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:gap-4 flex-wrap md:flex-nowrap shrink-0`,children:[(0,Q.jsx)(Ke,{models:n,selectedModelId:R,onChangeModel:o,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(Ye,{variants:x,selectedVariant:y,onChangeVariant:c,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(Xe,{preconfigs:t,selectedPreconfigId:e.preconfigId,onChangePreconfig:a,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(M,{orientation:`vertical`,className:`hidden md:block`}),h&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(s,{children:[(0,Q.jsx)(u,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:bg-accent`,onClick:h,disabled:f||_||!v,children:(0,Q.jsx)(Ne,{className:`size-4`})})}),(0,Q.jsx)(w,{children:_?`Compacting...`:`Compact older messages`})]}),(0,Q.jsx)(M,{orientation:`vertical`,className:`hidden md:block`})]}),(0,Q.jsxs)(s,{children:[(0,Q.jsx)(u,{asChild:!0,children:(0,Q.jsx)(p,{variant:f?`destructive`:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent${f?``:` text-muted-foreground opacity-60 hover:opacity-100`}`,onClick:m,disabled:!m,children:(0,Q.jsx)(ge,{className:`size-4`})})}),(0,Q.jsx)(w,{children:f?`Interrupt operation`:`Interrupt`})]})]})]})})})}function Qe({prompts:e,query:t,selectedIndex:n,onSelect:r}){let i=e.filter(e=>e.name.toLowerCase().includes(t.toLowerCase()));return i.length===0?(0,Q.jsxs)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:[`No prompts matching "/`,t,`"`]}):(0,Q.jsxs)(`div`,{className:`p-1`,children:[i.map((e,t)=>(0,Q.jsxs)(`button`,{onClick:()=>r(e),className:T(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===n&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,Q.jsx)(Me,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-xs`,children:[`/`,e.name]}),(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.description})]})]},e.name)),(0,Q.jsxs)(`div`,{className:`mt-1 pt-1 border-t text-xs text-muted-foreground px-2`,children:[i.length,` prompt`,i.length===1?``:`s`,` •`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↑↓`}),` navigate`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↵`}),` select`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`esc`}),` close`]})]})}function $e({id:e,kind:t,filename:n,size:r,previewUrl:i,isUploading:a,onRemove:o}){return(0,Q.jsxs)(`div`,{className:T(`flex items-center gap-2 px-2 py-1.5 bg-muted rounded-lg border border-border max-w-[180px]`,a&&`opacity-50`),children:[t===`image`&&i?(0,Q.jsx)(`img`,{src:i,alt:n,className:`size-8 rounded object-cover shrink-0`}):t===`image`?(0,Q.jsx)(Ae,{className:`size-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(le,{className:`size-4 text-muted-foreground shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs truncate`,children:n}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:et(r)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:(0,Q.jsx)(A,{className:`size-3 text-muted-foreground`})})]})}function et(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function tt({path:e,onRemove:t,onPreview:n}){let r=e.split(`/`).pop()||e,i=e.slice(0,e.lastIndexOf(`/`)+1);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 bg-primary/15 rounded-lg border border-primary/30 max-w-[220px]`,children:[(0,Q.jsx)(le,{className:`size-4 text-primary shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n==null?void 0:n(e),className:`min-w-0 flex-1 text-left cursor-pointer`,children:(0,Q.jsxs)(`div`,{className:`text-xs truncate`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,Q.jsx)(`span`,{children:r})]})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Remove ${r}`,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:(0,Q.jsx)(A,{className:`size-3 text-muted-foreground`})})]})}function nt(e){let t=getComputedStyle(document.documentElement).getPropertyValue(`--primary`).trim();if(!t)return`rgba(59, 130, 246, 0.15)`;let n=document.createElement(`div`);n.style.color=`color-mix(in oklch, ${t} 25%, transparent)`,document.body.appendChild(n);let r=getComputedStyle(n).color;return document.body.removeChild(n),r}function rt(e,t,n,r,i,a){e.fillStyle=a,e.roundRect?(e.beginPath(),e.roundRect(t,n,r,i,3),e.fill()):e.fillRect(t,n,r,i)}function it(e,t,n,r,i){let a=e.getContext(`2d`);if(!a)return;if(!n||r.size===0){e.width=0,e.height=0;return}let o=getComputedStyle(t);i.style.fontFamily=o.fontFamily,i.style.fontSize=o.fontSize,i.style.fontWeight=o.fontWeight,i.style.fontStyle=o.fontStyle,i.style.letterSpacing=o.letterSpacing,i.style.lineHeight=o.lineHeight,i.style.paddingTop=o.paddingTop,i.style.paddingRight=o.paddingRight,i.style.paddingBottom=o.paddingBottom,i.style.paddingLeft=o.paddingLeft,i.style.width=`${t.clientWidth}px`,i.style.whiteSpace=`pre-wrap`,i.style.wordWrap=`break-word`,i.style.overflowWrap=`break-word`,i.style.boxSizing=`border-box`,i.innerHTML=n.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/@([^\s@&<>]+)/g,(e,t)=>r.has(t)?`<span data-mention>${e}</span>`:e)+`
2
- `;let s=t.clientWidth,c=t.scrollHeight;e.width=s,e.height=c,a.clearRect(0,0,s,c);let l=nt(t),u=i.querySelectorAll(`[data-mention]`);for(let e of u){let t=e.offsetLeft,n=e.offsetTop,r=e.offsetWidth,i=e.offsetHeight;rt(a,t,n,r,i,l)}}function at(e,t,n){let r=(0,$.useRef)(null),i=(0,$.useRef)(null),a=(0,$.useRef)(null),o=(0,$.useRef)(``),s=(0,$.useRef)([]),c=(0,$.useMemo)(()=>new Set(n),[n]),l=(0,$.useCallback)(()=>{let a=e.current;if(a){if(r.current||(r.current=document.createElement(`canvas`)),!i.current){let e=document.createElement(`div`);e.style.position=`absolute`,e.style.visibility=`hidden`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),document.body.appendChild(e),i.current=e}if(!t||n.length===0){r.current.width=0,r.current.height=0,a.style.backgroundImage=``,a.style.backgroundRepeat=``,a.style.backgroundSize=``,a.style.backgroundPosition=``;return}try{it(r.current,a,t,c,i.current),a.style.backgroundImage=`url(${r.current.toDataURL()})`,a.style.backgroundRepeat=`no-repeat`,a.style.backgroundSize=`${a.clientWidth}px ${a.scrollHeight}px`,a.style.backgroundPosition=`${-a.scrollLeft}px ${-a.scrollTop}px`}catch(e){console.warn(`Failed to paint mention highlights:`,e)}}},[e,t,n,c]);(0,$.useEffect)(()=>{t===o.current&&n.length===s.current.length&&n.every((e,t)=>e===s.current[t])||(o.current=t,s.current=[...n],a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{l()}))},[t,n,l]),(0,$.useEffect)(()=>{let t=e.current;if(!t)return;let n=new ResizeObserver(()=>{a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{l()})});return n.observe(t),()=>{n.disconnect(),a.current!==null&&(cancelAnimationFrame(a.current),a.current=null)}},[e,l]),(0,$.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{t.style.backgroundPosition=`${-t.scrollLeft}px ${-t.scrollTop}px`};return t.addEventListener(`scroll`,n,{passive:!0}),()=>{t.removeEventListener(`scroll`,n)}},[e]),(0,$.useEffect)(()=>()=>{let t=e.current;t&&(t.style.backgroundImage=``,t.style.backgroundRepeat=``,t.style.backgroundSize=``,t.style.backgroundPosition=``),i.current&&(document.body.removeChild(i.current),i.current=null),a.current!==null&&cancelAnimationFrame(a.current)},[e])}function ot({workspaceId:e,debounceMs:t=150}){let[n,r]=(0,$.useState)(``),[i,a]=(0,$.useState)(!1),[o,s]=(0,$.useState)([]);return{query:n,setQuery:r,showAutocomplete:i,setShowAutocomplete:a,mentions:o,handleFileSelect:(0,$.useCallback)(e=>{let t={type:`file`,path:e.path,display:e.name};return s(e=>[...e,t]),a(!1),r(``),t},[]),insertMention:(0,$.useCallback)((e,t,n)=>{let r=e.lastIndexOf(`@`,t);return r===-1?{text:e,cursorPos:t}:{text:e.slice(0,r)+`@${n.path}`+e.slice(t),cursorPos:r+n.path.length+1}},[]),extractMentions:(0,$.useCallback)(e=>{let t=/@([^\s@]+)/g,n=[],r;for(;(r=t.exec(e))!==null;){let e=r[1];o.some(t=>t.path===e)&&!n.some(t=>t.path===e)&&n.push({type:`file`,path:e,display:e.split(`/`).pop()||e})}return n},[o]),clearMentions:(0,$.useCallback)(()=>s([]),[]),removeMention:(0,$.useCallback)(e=>{s(t=>t.filter(t=>t.path!==e))},[])}}function st(e){return`${h}${e}`}function ct(e,t){if(!(typeof window>`u`))try{localStorage.setItem(st(e),JSON.stringify({text:t,updatedAt:Date.now()}))}catch(e){console.warn(`Error saving draft:`,e)}}function lt(e){if(typeof window>`u`)return``;try{let t=localStorage.getItem(st(e));if(t===null)return``;let n=JSON.parse(t);return typeof n.text!=`string`||typeof n.updatedAt!=`number`||Date.now()-n.updatedAt>2592e6?(localStorage.removeItem(st(e)),``):n.text}catch{return``}}function ut(e){if(!(typeof window>`u`))try{localStorage.removeItem(st(e))}catch(e){console.warn(`Error clearing draft:`,e)}}function dt(){l()}function ft(e){let[t,n]=(0,$.useState)(``),r=(0,$.useRef)(void 0),i=(0,$.useRef)(``);(0,$.useEffect)(()=>{dt()},[]);let a=(0,$.useCallback)(t=>{n(t),i.current=t,e!==void 0&&(t===``?ut(e):ct(e,t))},[e]),o=(0,$.useCallback)(()=>{n(``),i.current=``,e!==void 0&&ut(e)},[e]);return(0,$.useEffect)(()=>{let t=r.current;if(t!==void 0&&t!==e){let e=i.current;e!==``&&ct(t,e)}if(e!==void 0){let t=lt(e);i.current=t,n(t)}else i.current=``,n(``);r.current=e},[e]),{input:t,setInput:a,clearInput:o}}function pt(e,t){return t?e.content.includes(`ARG`)?e.content.replace(`ARG`,t):`${e.content}\n${t}`:e.content}function mt(e){let t=e.trimStart();if(!t.startsWith(`/`))return null;let n=t.indexOf(` `);return n===-1?{command:t.slice(1),rest:``}:{command:t.slice(1,n),rest:t.slice(n+1).trim()}}var ht=(0,$.forwardRef)(function({onSendMessage:e,disabled:t,isStreaming:n,onStopStreaming:r,placeholder:i=`Type a message...`,workspaceId:a,sdkClient:s,prompts:c=[],sessionId:l,modelSupportsImage:u},d){let{input:f,setInput:m,clearInput:h}=ft(l),[g,_]=(0,$.useState)(0),[v,y]=(0,$.useState)([]),[b,x]=(0,$.useState)(0),[S,C]=(0,$.useState)(`none`),[w,E]=(0,$.useState)(``),[D,k]=(0,$.useState)([]),[A,j]=(0,$.useState)(!1),M=(0,$.useRef)(null),N=(0,$.useRef)(null);(0,$.useImperativeHandle)(d,()=>({focus:()=>{var e;return(e=M.current)==null?void 0:e.focus()}}),[]);let{query:P,setQuery:ee,showAutocomplete:F,setShowAutocomplete:I,mentions:L,handleFileSelect:R,insertMention:z,clearMentions:te,removeMention:B}=ot({workspaceId:a||``}),V=o(e=>e.openFilePreview),H=O(e=>e.activeWorkspace);at(M,f,(0,$.useMemo)(()=>L.map(e=>e.path),[L])),(0,$.useEffect)(()=>{if(L.length===0)return;let e=new Set(L.map(e=>e.path)),t=/@([^\s@]+)/g,n,r=new Set;for(;(n=t.exec(f))!==null;)e.has(n[1])&&r.add(n[1]);for(let e of L)r.has(e.path)||B(e.path)},[f,L,B]),(0,$.useEffect)(()=>{x(0)},[v,w,c]),(0,$.useEffect)(()=>{let e=M.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[f]);let U=c.filter(e=>e.name.toLowerCase().includes(w.toLowerCase())),ne=S===`prompts`&&c.length>0,re=S===`files`&&F&&!!a,ae=(0,$.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart||0;m(t),_(n);let r=t.lastIndexOf(`/`,n);if(r!==-1){let e=r>0?t[r-1]:`
3
- `,i=t.slice(r+1,n);if((e===`
4
- `||e===` `||e===``)&&!i.includes(` `)){E(i),C(`prompts`);return}}let i=t.lastIndexOf(`@`,n);if(i!==-1){let e=t.slice(i+1,n);if(!e.includes(` `)){ee(e),I(!0),C(`files`);return}}C(`none`),I(!1)},[ee,I,m]),oe=(0,$.useCallback)(e=>{let t=z(f,g,R(e));m(t.text),C(`none`),I(!1),y([]),setTimeout(()=>{M.current&&(M.current.focus(),M.current.setSelectionRange(t.cursorPos,t.cursorPos))},0)},[f,g,R,z,I,m]),se=(0,$.useCallback)(e=>{let t=f.lastIndexOf(`/`,g),n=f.slice(0,t),r=f.slice(t+1),i=r.indexOf(` `),a=i===-1?``:r.slice(i),o=`${n}/${e.name}${a}`,s=t+1+e.name.length+0;m(o),C(`none`),setTimeout(()=>{M.current&&(M.current.focus(),M.current.setSelectionRange(s,s))},0)},[f,g,m]),ce=(0,$.useCallback)(()=>{for(let e of D)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);k([]),h(),te()},[D,h,te]),le=(0,$.useCallback)(async e=>{if(!s||!l)return null;try{let t=await(s==null?void 0:s.http.attachments.upload(l,e));return{id:crypto.randomUUID(),kind:t.kind,filename:t.filename,size:t.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploadedId:t.id,uploadedKind:t.kind}}catch(e){return console.error(`Upload error:`,e),null}},[s,l]),W=(0,$.useCallback)(e=>{k(t=>{let n=t.find(t=>t.id===e);return n!=null&&n.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),ue=(0,$.useCallback)(e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}`,`g`);m(f.replace(n,``).replace(/\s+/g,` `).trim()),B(e)},[f,m,B]),G=(0,$.useCallback)(e=>{H!=null&&H.id&&V({workspaceId:H.id,path:e,name:e.split(`/`).pop()||e})},[H==null?void 0:H.id,V]),K=(0,$.useCallback)(async e=>{let t=Array.from(e);for(let e of t){if(e.size>20*1024*1024)continue;let t=e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`file`,n={id:crypto.randomUUID(),kind:t,filename:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,isUploading:!0};k(e=>[...e,n]);let r=await le(e);k(r?e=>e.map(e=>e.id===n.id?(e.previewUrl&&e.previewUrl!==r.previewUrl&&URL.revokeObjectURL(e.previewUrl),{...r,isUploading:!1}):e):e=>e.filter(e=>e.id!==n.id))}},[le]),q=(0,$.useCallback)(e=>{var t;let n=(t=e.clipboardData)==null?void 0:t.files;n&&n.length>0&&(e.preventDefault(),K(n))},[K]),pe=(0,$.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!0)},[]),me=(0,$.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!1)},[]),X=(0,$.useCallback)(e=>{var t;e.preventDefault(),e.stopPropagation(),j(!1);let n=(t=e.dataTransfer)==null?void 0:t.files;n&&n.length>0&&K(n)},[K]),Z=async n=>{n==null||n.preventDefault();let r=f.trim();if(!r&&D.length===0||t)return;let i=mt(f);if(i){let t=c.find(e=>e.name===i.command);if(t){let n=pt(t,i.rest),r=D.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(n,r.length>0?r:void 0),ce();return}}let a=D.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(r||``,a.length>0?a:void 0),ce()},he=e=>{if(!e.nativeEvent.isComposing){if(ne&&U.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>Math.min(e+1,U.length-1));return;case`ArrowUp`:e.preventDefault(),x(e=>Math.max(e-1,0));return;case`Enter`:if(e.shiftKey)return;e.preventDefault(),U[b]&&se(U[b]);return;case`Tab`:e.preventDefault(),U[b]&&se(U[b]);return;case`Escape`:e.preventDefault(),C(`none`);return}if(re&&v.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>Math.min(e+1,v.length-1));return;case`ArrowUp`:e.preventDefault(),x(e=>Math.max(e-1,0));return;case`Enter`:e.preventDefault(),v[b]&&oe(v[b]);return;case`Escape`:e.preventDefault(),I(!1),C(`none`);return;case`Tab`:e.preventDefault(),v[b]&&oe(v[b]);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Z())}},_e=(0,$.useCallback)(e=>{y(e)},[]);if(n&&r)return(0,Q.jsx)(`div`,{className:`p-4 border-t border-border bg-card`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`animate-pulse flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.1s]`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.2s]`}),(0,Q.jsx)(`span`,{className:`text-sm ml-2`,children:`Generating...`})]}),(0,Q.jsxs)(p,{variant:`outline`,size:`sm`,onClick:r,children:[(0,Q.jsx)(ge,{className:`size-4`,"data-icon":`inline-start`}),`Stop`]})]})});let ye=f.trim(),be=D.some(e=>e.isUploading),xe=!(ye||D.length>0)||t||be;return(0,Q.jsxs)(`form`,{onSubmit:Z,onDragOver:pe,onDragLeave:me,onDrop:X,className:T(`p-4 border-t border-border bg-card`,A&&`ring-2 ring-primary`),children:[(D.length>0||!n)&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap mb-2`,children:D.map(e=>(0,Q.jsx)($e,{id:e.id,kind:e.kind,filename:e.filename,size:e.size,previewUrl:e.previewUrl,isUploading:e.isUploading,onRemove:W},e.id))}),D.length>0&&u===!1&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,Q.jsx)(ve,{className:`size-3 shrink-0`}),(0,Q.jsx)(`span`,{children:`This model will not inspect images directly. They will be sent as file paths instead.`})]}),L.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap mb-2`,children:L.map(e=>(0,Q.jsx)(tt,{path:e.path,onRemove:ue,onPreview:G},e.path))}),(0,Q.jsxs)(`div`,{className:`flex gap-3 items-end`,children:[(0,Q.jsx)(`div`,{className:`flex-1 relative`,children:(0,Q.jsxs)(Y,{open:ne||re,onOpenChange:e=>{e||(C(`none`),I(!1))},children:[(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(de,{ref:M,value:f,onChange:ae,onKeyDown:he,onPaste:q,placeholder:i,disabled:t,className:T(`min-h-[44px] max-h-[150px] resize-none pr-12 chat-input-scrollbar`,`focus-visible:ring-1`),rows:1,"data-chat-input":`true`})}),(0,Q.jsx)(J,{className:`w-72 p-0`,align:`start`,side:`top`,sideOffset:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:re?(0,Q.jsx)(ie,{workspaceId:a||``,searchQuery:P,selectedIndex:b,onSelect:oe,onFilesChange:_e,sdkClient:s}):(0,Q.jsx)(Qe,{prompts:c,query:w,selectedIndex:b,onSelect:se})})]})}),(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-11 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50 disabled:pointer-events-none`,onClick:()=>{var e;return(e=N.current)==null?void 0:e.click()},disabled:t,children:(0,Q.jsx)(Pe,{className:`size-4`})}),(0,Q.jsx)(`input`,{ref:N,type:`file`,accept:`image/*,video/*,.pdf,.doc,.docx,.txt,.csv,.json,.xml,.md`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&K(e.target.files),e.target.value=``}}),(0,Q.jsx)(p,{type:`submit`,disabled:xe,size:`default`,className:`h-11`,children:(0,Q.jsx)(Fe,{className:`size-4`})})]}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground text-center hidden sm:flex items-center justify-center gap-1`,children:[(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`/`}),(0,Q.jsx)(`span`,{children:`prompts`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`@`}),(0,Q.jsx)(`span`,{children:`files`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Enter`}),(0,Q.jsx)(`span`,{children:`to send`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Shift + Enter`}),(0,Q.jsx)(`span`,{children:`for new line`})]})]})});function gt(e){return e.startsWith(`https://`)?`https`:`http`}function _t(e,t){return`${gt(e)}://${e.replace(/^https?:\/\//,``)}${t}`}function vt(e){let t=(0,$.useRef)(e);return(0,$.useLayoutEffect)(()=>{t.current=e}),(0,$.useCallback)((...e)=>t.current(...e),[])}var yt=e(r(),1);function bt(e,t,n){var r;let i=(r=n.initialDeps)==null?[]:r,a,o=!0;function s(){var r,s,c;let l;n.key&&(r=n.debug)!=null&&r.call(n)&&(l=Date.now());let u=e();if(!(u.length!==i.length||u.some((e,t)=>i[t]!==e)))return a;i=u;let d;if(n.key&&(s=n.debug)!=null&&s.call(n)&&(d=Date.now()),a=t(...u),n.key&&(c=n.debug)!=null&&c.call(n)){let e=Math.round((Date.now()-l)*100)/100,t=Math.round((Date.now()-d)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
5
- font-size: .6rem;
6
- font-weight: bold;
7
- color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(a),o=!1,a}return s.updateDeps=e=>{i=e},s}function xt(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var St=(e,t)=>Math.abs(e-t)<1.01,Ct=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},wt=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Tt=e=>e,Et=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Dt=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(wt(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e!=null&&e.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(wt(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Ot={passive:!0},kt=typeof window>`u`?!0:`onscrollend`in window,At=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&kt?()=>void 0:Ct(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,Ot);let l=e.options.useScrollendEvent&&kt;return l&&n.addEventListener(`scrollend`,c,Ot),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},jt=(e,t,n)=>{if(t!=null&&t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Mt=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},Nt=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e,t,n,r;return(e=(r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))==null?Date.now():e},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>{var n;return(n=t())==null?void 0:n.observe(e,{box:`border-box`})},unobserve:e=>{var n;return(n=t())==null?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Tt,rangeExtractor:Et,onChange:()=>{},measureElement:jt,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=bt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}if(this.scrollElement=t,this.scrollElement&&`ownerDocument`in this.scrollElement)this.targetWindow=this.scrollElement.ownerDocument.defaultView;else{var n;this.targetWindow=(n=(e=this.scrollElement)==null?void 0:e.window)==null?null:n}this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>{var e;return this.options.enabled?(this.scrollRect=(e=this.scrollRect)==null?this.options.initialRect:e,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0)},this.getScrollOffset=()=>{var e;return this.options.enabled?(this.scrollOffset=(e=this.scrollOffset)==null?typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset:e,this.scrollOffset):(this.scrollOffset=null,0)},this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=bt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=bt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=bt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Ft({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=bt(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t,n;if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let r=(t=this.scrollState.index)==null?(n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index:t;if(r!==void 0&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,r-t),i=Math.min(this.options.count-1,r+t);return e>=n&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n,r;let i=this.measurementsCache[e];if(!i)return;let a=t-((n=this.itemSizeCache.get(i.key))==null?i.size:n);a!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?i.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(i,a,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,t)),this.notify(!1))},this.getVirtualItems=bt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return xt(t[Pt(0,t.length-1,e=>xt(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var e;let t=this.getMeasurements(),n;if(t.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){var r;n=(r=(e=t[t.length-1])==null?void 0:e.end)==null?0:r}else{let e=Array(this.options.lanes).fill(null),r=t.length-1;for(;r>=0&&e.some(e=>e===null);){let n=t[r];e[n.lane]===null&&(e[n.lane]=n.end),r--}n=Math.max(...e.filter(e=>e!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&St(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},Pt=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Ft({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=Pt(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var It=typeof document<`u`?$.useLayoutEffect:$.useEffect;function Lt({useFlushSync:e=!0,...t}){let n=$.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,yt.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=$.useState(()=>new Nt(r));return i.setOptions(r),It(()=>i._didMount(),[]),It(()=>i._willUpdate()),i}function Rt(e){return Lt({observeElementRect:Dt,observeElementOffset:At,scrollToFn:Mt,...e})}function zt({message:e,textContent:t,children:n,isQueued:r=!1,onRemove:i,onRevert:a,canRevert:o=!1,onFork:s,canFork:c=!1,isClearAll:l=!1}){let[u,d]=(0,$.useState)(!1),[f,m]=(0,$.useState)(!1),[h,g]=(0,$.useState)(!1),v=e.role===`user`,y=async()=>{let e=t||``;await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3)};return(0,Q.jsxs)(`div`,{className:T(`flex flex-col gap-1 animate-slide-up min-w-0`,v?`items-end`:`items-start`),children:[(0,Q.jsx)(`div`,{className:T(`flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground`,v?`mr-3`:`ml-3`),children:v?(0,Q.jsxs)(Q.Fragment,{children:[!r&&(0,Q.jsxs)(Q.Fragment,{children:[o&&a&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:()=>m(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Revert to this point`,children:(0,Q.jsx)(Ie,{className:`size-3`})}),c&&s&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:()=>g(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Fork from this point`,children:(0,Q.jsx)(ke,{className:`size-3`})}),(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:y,className:`size-5 text-muted-foreground hover:text-foreground`,children:u?(0,Q.jsx)(_,{className:`size-3`}):(0,Q.jsx)(V,{className:`size-3`})})]}),(0,Q.jsx)(se,{className:`size-3`}),e.role]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xe,{className:`size-3`}),e.role,(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:y,className:`size-5 text-muted-foreground hover:text-foreground`,children:u?(0,Q.jsx)(_,{className:`size-3`}):(0,Q.jsx)(V,{className:`size-3`})})]})}),(0,Q.jsxs)(`div`,{className:T(`rounded-2xl px-4 py-3 relative group min-w-0 overflow-hidden`,v?`max-w-[90%]`:`max-w-full`,r?`bg-muted border-2 border-dashed border-muted-foreground/30 opacity-80`:v?`bg-primary text-primary-foreground rounded-br-md`:`bg-card text-card-foreground border border-border rounded-bl-md`),children:[r&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2 pb-2 border-b border-muted-foreground/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Ee,{className:`size-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Pending`})]}),i&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:i,className:`size-6 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove from queue`,children:(0,Q.jsx)(A,{className:`size-3`})})]}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:n})]}),(0,Q.jsx)(F,{open:f,onOpenChange:m,title:l?`Clear Conversation`:`Revert Conversation`,description:l?`This will delete all messages in this session, leaving it completely empty. Are you sure you want to continue?`:`This will delete this message and all messages after it. Are you sure you want to continue?`,confirmLabel:l?`Clear All`:`Revert`,cancelLabel:`Cancel`,onConfirm:()=>{a==null||a()},variant:`destructive`}),(0,Q.jsx)(F,{open:h,onOpenChange:g,title:`Fork Conversation`,description:`This will create a new session with messages up to and including this point. The original session will be unchanged.`,confirmLabel:`Fork`,cancelLabel:`Cancel`,onConfirm:()=>{s==null||s()}})]})}var Bt=L.oneDark;function Vt(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var Ht=(0,$.memo)(function({type:e,content:t,lineNumber:n,newLineNumber:r,language:i}){let a=T(`flex font-mono text-xs`,e===`added`&&`bg-green-500/20`,e===`removed`&&`bg-red-500/20`,e===`context`&&`bg-muted/30`),o=T(`font-bold w-4 select-none`,e===`added`&&`text-green-400`,e===`removed`&&`text-red-400`,e===`context`&&`text-muted-foreground/50`);return(0,Q.jsxs)(`div`,{className:a,children:[(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:n==null?``:n}),(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:r==null?``:r}),(0,Q.jsxs)(`span`,{className:`pl-2 flex-1 whitespace-pre flex`,children:[(0,Q.jsxs)(`span`,{className:o,children:[e===`added`&&`+`,e===`removed`&&`-`,e===`context`&&` `]}),(0,Q.jsx)(H,{theme:Bt,code:t,language:i,children:({tokens:e,getTokenProps:t})=>(0,Q.jsx)(Q.Fragment,{children:e.map((e,n)=>(0,Q.jsx)(`span`,{children:e.map((e,n)=>(0,Q.jsx)(`span`,{...t({token:e})},n))},n))})})]})]})}),Ut=(0,$.memo)(function({hunks:e,path:t,language:n,additions:r,deletions:i}){let[a,s]=(0,$.useState)(!0),c=n||Vt(t),l=o(e=>e.openFilePreview),u=O(e=>e.activeWorkspace);return(0,Q.jsx)(`div`,{className:`visualization-container overflow-x-auto border border-white/10 rounded-md`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`button`,{onClick:()=>s(!a),className:`px-1 py-1 hover:bg-muted rounded`,children:a?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`})}),(0,Q.jsx)(z,{className:`size-3`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{u&&l({workspaceId:u.id,path:t,name:t.split(`/`).pop()||t})},className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted`,title:`Open file preview`,children:[t,(0,Q.jsx)(ae,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`})]}),r!==void 0&&i!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-auto mr-2 text-muted-foreground`,children:[`+`,r,` -`,i]})]}),a&&(0,Q.jsx)(`div`,{style:{backgroundColor:`#282c34`},children:e.map((e,t)=>(0,Q.jsx)(`div`,{className:`divide-y divide-white/5`,children:e.changes.map((e,t)=>(0,Q.jsx)(Ht,{...e,language:c},t))},t))})]})})}),Wt=L.oneDark,Gt=20;function Kt(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var qt=(0,$.memo)(({content:e,path:t,language:n,created:r,highlightLines:i=[]})=>{let[a,s]=(0,$.useState)(!1),c=o(e=>e.openFilePreview),l=O(e=>e.activeWorkspace),u=()=>{l&&c({workspaceId:l.id,path:t,name:t.split(`/`).pop()||t})},d=n||Kt(t),f=(0,$.useMemo)(()=>new Set(i),[i]),p=(0,$.useMemo)(()=>e.split(`
8
- `).length,[e]);return(0,Q.jsx)(`div`,{className:`visualization-container overflow-x-auto border border-white/10 rounded-md`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`button`,{onClick:()=>s(!a),className:`flex items-center gap-2 px-2 py-1 hover:bg-muted`,children:a?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`})}),(0,Q.jsx)(z,{className:`size-3`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted`,title:`Open file preview`,children:[t,(0,Q.jsx)(ae,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`})]}),!a&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/70`,children:[p,` lines`]}),r===!1?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-warning ml-auto mr-2`,children:[(0,Q.jsx)(B,{className:`size-3`}),`Overwrote`]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success ml-auto mr-2`,children:[(0,Q.jsx)(_,{className:`size-3`}),`Created`]})]}),(0,Q.jsx)(`div`,{style:{backgroundColor:`#282c34`},children:(0,Q.jsx)(H,{theme:Wt,code:e,language:d,children:({tokens:e,getTokenProps:t})=>(0,Q.jsx)(Q.Fragment,{children:(a?e:e.slice(0,Gt)).map((e,n)=>(0,Q.jsxs)(`div`,{className:`flex font-mono text-xs ${f.has(n+1)?`bg-yellow-500/20`:``}`,children:[(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:n+1}),(0,Q.jsx)(`span`,{className:`pl-2 flex-1 whitespace-pre`,children:e.map((e,n)=>(0,Q.jsx)(`span`,{...t({token:e})},n))})]},n))})})})]})})});function Jt({message:e=`Success`}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(E,{className:`size-4`}),(0,Q.jsx)(`span`,{className:`break-all`,children:e})]})}var Yt={edit:Oe,plus:y,trash:d,search:ue};function Xt({text:e}){let[t,n]=(0,$.useState)(!1);return(0,Q.jsx)(`button`,{onClick:async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Copy path`,children:t?(0,Q.jsx)(`span`,{className:`text-success text-xs`,children:`Copied!`}):(0,Q.jsx)(V,{className:`size-3`})})}function Zt({title:e,groups:t,files:n,total:r}){let i=t||(n?[{label:`Files`,files:n||[],icon:void 0}]:[]);return i.length===0?null:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[e,r!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,r,` files)`]})]}),i.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`flex items-center`,children:(()=>{let t=Yt[e.icon];return(0,Q.jsx)(t,{className:`size-3`})})()}),(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[`(`,e.files.length,`)`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5 pl-5`,children:e.files.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs group`,children:[(0,Q.jsx)(z,{className:`size-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`font-mono text-foreground/80 truncate`,children:e.path}),e.line!==void 0&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[`:`,e.line]}),e.action&&(0,Q.jsx)(`span`,{className:T(`text-xs px-1 rounded shrink-0`,e.action===`created`&&`bg-success/20 text-success`,e.action===`modified`&&`bg-warning/20 text-warning`,e.action===`deleted`&&`bg-destructive/20 text-destructive`),children:e.action}),(0,Q.jsx)(Xt,{text:e.path})]},t))})]},t))]})}function Qt({command:e,stdout:t,stderr:n,exitCode:r}){return(0,Q.jsxs)(`div`,{className:`visualization-container border border-white/10 rounded-md overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`bg-muted px-3 py-2 flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground truncate flex-1 mr-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`$ `}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:e})]}),(0,Q.jsxs)(`span`,{className:`text-xs font-mono px-2 py-0.5 rounded ${r===0?`bg-muted text-muted-foreground`:`bg-red-500/20 text-red-400`}`,children:[`[`,r,`]`]})]}),(t||n)&&(0,Q.jsxs)(`div`,{className:`bg-black px-3 py-2 font-mono text-xs overflow-x-auto`,children:[t&&(0,Q.jsx)(`pre`,{className:`text-gray-300 whitespace-pre-wrap`,children:t}),n&&(0,Q.jsx)(`pre`,{className:`text-red-400 whitespace-pre-wrap mt-1`,children:n})]})]})}var $t={pending:{icon:Te,color:`text-muted-foreground`},in_progress:{icon:N,color:`text-warning`,animate:!0},completed:{icon:E,color:`text-success`},cancelled:{icon:m,color:`text-destructive`}},en={high:{label:`high`,className:`bg-destructive/20 text-destructive`},medium:{label:``,className:``},low:{label:`low`,className:`text-muted-foreground`}};function tn({title:e,items:t}){if(t.length===0)return null;let n=t.filter(e=>e.status===`completed`).length;return t.filter(e=>e.status===`in_progress`).length,t.filter(e=>e.status===`pending`).length,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 w-full overflow-hidden`,children:[(e||t.length>0)&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[e||`Todo List`,(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,t.length,`)`]}),n>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-success text-xs`,children:[n,` completed`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:t.map((e,t)=>{let n=$t[e.status],r=n.icon,i=en[e.priority];return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,Q.jsx)(r,{className:T(`size-4 shrink-0`,n.color,n.animate&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:T(`flex-1 break-all`,e.status===`completed`&&`line-through text-muted-foreground`,e.status===`cancelled`&&`text-muted-foreground`),children:e.content}),i.label&&e.priority===`high`&&(0,Q.jsx)(`span`,{className:T(`text-xs px-1.5 py-0.5 rounded shrink-0`,i.className),children:i.label}),e.priority===`low`&&e.status!==`completed`&&e.status!==`cancelled`&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:i.label})]},t)})})]})}var nn=(0,$.memo)(function({visualization:e}){if(!e)return null;switch(e.type){case`diff`:return(0,Q.jsx)(Ut,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo});case`diffs`:return(0,Q.jsx)(`div`,{className:`space-y-3`,children:e.items.map((e,t)=>(0,Q.jsx)(Ut,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo},`${e.path}-${t}`))});case`code`:return(0,Q.jsx)(qt,{path:e.path,content:e.content,language:e.language,created:e.created,highlightLines:e.highlightLines});case`file-list`:return(0,Q.jsx)(Zt,{title:e.title,groups:e.groups,files:e.files,total:e.total});case`table`:return(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto`,children:JSON.stringify(e.rows,null,2)});case`markdown`:return(0,Q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert`,children:e.content});case`none`:return(0,Q.jsx)(Jt,{message:e.message});case`shell-output`:return(0,Q.jsx)(Qt,{command:e.command,stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode});case`todo-list`:return(0,Q.jsx)(tn,{title:e.title,items:e.items});default:return null}}),rn=1536,an=(0,$.memo)(function({content:e,className:t}){let[n,r]=(0,$.useState)(!1),i=new Blob([e]).size,a=i>rn,o=a?e.slice(0,rn)+`
9
- ...`:null;if(!a)return(0,Q.jsx)(`pre`,{className:t,children:e});let s=i>1024*1024?`${(i/(1024*1024)).toFixed(1)} MB`:i>1024?`${(i/1024).toFixed(1)} KB`:`${i} bytes`;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`pre`,{className:t,children:n?e:o}),(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground mt-1 transition-colors cursor-pointer`,onClick:()=>r(e=>!e),children:n?`Show less`:`Show full output (${s})`})]})});function on(e){switch(e){case`pending`:return(0,Q.jsx)(Ee,{className:`size-3 text-warning`});case`running`:return(0,Q.jsx)(N,{className:`size-3 text-warning animate-spin`});case`completed`:return(0,Q.jsx)(E,{className:`size-3 text-success`});case`error`:return(0,Q.jsx)(m,{className:`size-3 text-destructive`});case`interrupted`:return(0,Q.jsx)(he,{className:`size-3 text-warning`});default:return null}}function sn(e){if(e&&typeof e==`object`&&`_visualization`in e)return e._visualization}var cn=(0,$.memo)(function({part:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r}){var i;let[a,o]=(0,$.useState)(!1),[s,c]=(0,$.useState)(!1),l=e.state,u=l.status,d=(0,$.useMemo)(()=>{if(!a)return``;try{return JSON.stringify(l.input,null,2)}catch{return String(l.input)}},[l.input,a]),f=(0,$.useMemo)(()=>!a||u!==`completed`||!(`output`in l)?null:typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2),[u,l,a]),m=u===`completed`&&`output`in l?sn(l.output):void 0,h=u===`pending`?t.find(t=>t.toolCallId===e.callId):void 0,g=h?typeof((i=h.args)==null?void 0:i.command)==`string`?h.args.command:JSON.stringify(h.args,null,2):null,y=null;if(e.name===`task`){if(`childSessionId`in l&&l.childSessionId)y=l.childSessionId;else if(u===`completed`&&`output`in l){let e=(typeof l.output==`string`?l.output:``).match(/task_id:\s*([a-f0-9-]{36})/i);e&&(y=e[1])}}let b=async()=>{if(`output`in l){let e=typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2);await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3)}},C=(()=>{try{let e=JSON.stringify(l.input);return e.length>50?e.slice(0,47)+`...`:e}catch{return String(l.input)}})();return(0,Q.jsxs)(`div`,{className:`my-1`,children:[(0,Q.jsxs)(S,{open:a,onOpenChange:o,children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1 cursor-pointer hover:text-foreground transition-colors text-muted-foreground`,children:[a?(0,Q.jsx)(Ce,{className:`size-4 text-muted-foreground`}):(0,Q.jsx)(x,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(Re,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`text-xs truncate max-w-[120px] sm:max-w-none`,children:e.name}),!a&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono truncate flex-1 min-w-0 sm:max-w-[200px] hidden sm:block`,children:C}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[on(u),y&&r&&(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 sm:w-auto sm:px-2`,onClick:e=>{e.stopPropagation(),r(y)},title:`View session`,children:[(0,Q.jsx)(ae,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`View`})]})]})]})}),a&&(0,Q.jsx)(D,{children:(0,Q.jsxs)(`div`,{className:`pl-5 pb-2 flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Input`}),(0,Q.jsx)(an,{content:d,className:`text-xs bg-background border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),(u===`running`||u===`completed`)&&y&&r&&(0,Q.jsxs)(p,{variant:`outline`,className:`w-full`,size:`sm`,onClick:()=>r(y),children:[(0,Q.jsx)(ae,{className:`size-4`,"data-icon":`inline-start`}),u===`running`?`Watch Subagent`:`View Session`]}),u===`completed`&&f!==null&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Output`}),(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:b,className:`size-6`,children:s?(0,Q.jsx)(_,{className:`size-3 text-success`}):(0,Q.jsx)(V,{className:`size-3`})})]}),(0,Q.jsx)(an,{content:f,className:`text-xs bg-success/10 border border-success/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),u===`error`&&`error`in l&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Error`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-destructive/10 border border-destructive/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words text-destructive`,children:l.error})]})]})})]}),u===`pending`&&h&&(0,Q.jsxs)(`div`,{className:`border border-warning/50 bg-warning/10 rounded-md p-3 flex flex-col gap-3 mt-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ve,{className:`size-4 text-warning`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:`Permission Required`})]}),h.message&&(0,Q.jsx)(`p`,{className:`text-sm`,children:h.message}),h.dangerous&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-destructive font-medium`,children:[(0,Q.jsx)(ve,{className:`size-4`}),`This operation is marked as dangerous`]}),g&&(0,Q.jsxs)(S,{children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full text-left`,children:[(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`uppercase tracking-wide`,children:`Command`})]})}),(0,Q.jsx)(D,{children:(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 mt-1 overflow-x-auto whitespace-pre-wrap break-words overflow-wrap-break`,children:g})})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 flex-wrap`,children:[(0,Q.jsx)(p,{variant:`outline`,size:`sm`,onClick:()=>n(e.callId,!1,!1),children:`Deny`}),(0,Q.jsx)(p,{variant:`secondary`,size:`sm`,onClick:()=>n(e.callId,!0,!1),children:`Approve`}),(0,Q.jsx)(p,{size:`sm`,onClick:()=>n(e.callId,!0,!0),children:`Always Allow`})]})]}),u===`completed`&&m&&(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(nn,{visualization:m})})]})},(e,t)=>e.part!==t.part||e.onNavigateToSubagent!==t.onNavigateToSubagent?!1:e.part.state.status===`pending`?e.pendingPermissions.find(t=>t.toolCallId===e.part.callId)===t.pendingPermissions.find(e=>e.toolCallId===t.part.callId):!0),ln=60,un=300,dn=16;function fn(e){if(e.length===0)return!1;let t=e[e.length-1];return ye(t.message)&&t.message.status===`streaming`}function pn(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function mn(e,t){let n=t.findIndex(t=>t.message.id===e);if(n<0)return null;if(n===0)return e;for(let e=n-1;e>=0;e--){let n=t[e];if(n.message.role===`assistant`&&n.message.status!==`streaming`)return n.message.id}return null}function hn(){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground bg-muted rounded-lg px-3 py-2 border border-border shadow-sm`,children:[(0,Q.jsx)(Ne,{className:`size-4 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Compacting conversation...`})]})}function gn(){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-green-700 dark:text-green-400 bg-green-500/15 rounded-lg px-3 py-2 border border-green-500/30 shadow-sm`,children:[(0,Q.jsx)(we,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Compaction complete`})]})}function _n({message:e,textContent:t,onRetry:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[(0,Q.jsx)(ve,{className:`size-3`}),`Compaction Failed`]}),(0,Q.jsxs)(`div`,{className:`rounded-2xl px-4 py-3 max-w-full bg-destructive/10 border border-destructive/30 rounded-bl-md`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:t||e.error||`Compaction failed. The conversation could not be summarized.`}),n&&(0,Q.jsxs)(p,{variant:`outline`,size:`sm`,onClick:n,className:`mt-2 h-7 text-xs gap-1.5`,children:[(0,Q.jsx)(_e,{className:`size-3`}),`Retry`]})]})]})}function vn(e,t){var n;return(e==null?void 0:e.split(`/`).pop())||(t==null||(n=t.split(`.`).pop())==null?void 0:n.toLowerCase())||``}function yn({part:e}){let[t,n]=(0,$.useState)(!1),r=e.overflow?`overflow`:e.auto?`auto`:`manual`;return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center py-3`,children:[(0,Q.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[t?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsxs)(`span`,{className:`border-b border-dashed border-muted-foreground/40 pb-px`,children:[r===`overflow`?`Context overflow`:r===`auto`?`Auto`:`Manual`,` compaction`]})]}),t&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Summary available in the assistant message below`})]})}var bn=(0,$.memo)(function({parts:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r,inverted:i=!1,serverUrl:a}){return(0,Q.jsx)(Q.Fragment,{children:[...e].sort((e,t)=>e.createdAt-t.createdAt).map(e=>{switch(e.type){case`text`:return(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(oe,{inverted:i,children:e.text||`...`})},e.id);case`reasoning`:return(0,Q.jsx)(`div`,{className:`visualization-container text-muted-foreground text-sm italic border-l-2 border-muted-foreground/30 pl-3 my-2 wrap-break-word`,children:e.text},e.id);case`tool`:return(0,Q.jsx)(cn,{part:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r},e.id);case`image`:return(0,Q.jsx)(`img`,{src:a?_t(a,e.url):e.url,alt:``,className:T(`max-w-full max-h-64 rounded-xl mt-2 object-contain`,i&&`ring-2 ring-white/20`)},e.id);case`file`:{let t=a?_t(a,e.url):e.url,n=vn(e.mimeType,e.filename),r=e.filename||``,o=r.length>30?r.slice(0,27)+`...`:r||`unnamed`;return(0,Q.jsxs)(`a`,{href:t,className:T(`mt-2 p-2 rounded-lg text-sm flex items-center gap-2 transition-colors`,i?`bg-white/15 hover:bg-white/25 text-primary-foreground`:`bg-muted hover:bg-accent`),target:`_blank`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(le,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:o}),n&&(0,Q.jsx)(`span`,{className:T(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ml-auto shrink-0`,i?`bg-white/25 text-primary-foreground`:`bg-secondary text-secondary-foreground`),children:n}),(0,Q.jsx)(De,{className:`size-3.5 shrink-0 opacity-60`})]},e.id)}default:return null}})})},(e,t)=>{if(e.parts!==t.parts||e.inverted!==t.inverted||e.onPermissionResponse!==t.onPermissionResponse||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.serverUrl!==t.serverUrl)return!1;if(!e.parts.some(e=>e.type===`tool`&&e.state.status===`pending`))return!0;let n=new Set(e.parts.filter(e=>e.type===`tool`).map(e=>e.callId)),r=e.pendingPermissions.filter(e=>n.has(e.toolCallId)),i=t.pendingPermissions.filter(e=>n.has(e.toolCallId));if(r.length!==i.length)return!1;for(let e=0;e<r.length;e++)if(r[e].toolCallId!==i[e].toolCallId)return!1;return!0}),xn=(0,$.memo)(function({item:e,messagesWithParts:t,sessionId:n,pendingPermissions:r,onPermissionResponse:i,onNavigateToSubagent:a,onRemoveFromQueue:o,onRevert:s,onFork:c,isMainActiveSession:l=!1,isCompacting:u=!1,onCompact:d,serverUrl:f}){let p=e.parts.find(e=>e.type===`compaction`);if(ye(e.message)&&e.message.mode===`compact_failed`)return(0,Q.jsx)(_n,{message:e.message,textContent:pn(e.parts),onRetry:l&&!u?d:void 0});if(p)return(0,Q.jsx)(yn,{part:p});let m=!e.isQueued&&e.message.role===`user`,h=m?mn(e.message.id,t):null,g=h===e.message.id;return(0,Q.jsx)(zt,{message:e.message,textContent:pn(e.parts),isQueued:e.isQueued,onRemove:e.isQueued?()=>o(e.queueId):void 0,canRevert:m&&h!==null,onRevert:h?()=>s==null?void 0:s(n,h):void 0,canFork:m&&h!==null,onFork:h?()=>c==null?void 0:c(n,e.message.id):void 0,isClearAll:g,children:e.parts.length===0?(0,Q.jsx)(`span`,{className:`opacity-50`,children:`...`}):(0,Q.jsx)(bn,{parts:e.parts,pendingPermissions:r,onPermissionResponse:i,onNavigateToSubagent:a,inverted:e.message.role===`user`,serverUrl:f})})});function Sn({displayItems:e,messagesWithParts:t,sessionId:n,sessionStatus:r,pendingPermissions:i,isCompacting:a=!1,compactionSuccess:o=!1,onClearCompactionSuccess:s,onPermissionResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,onCompact:p,isMainActiveSession:m=!1,autoFollow:h=!0,onAutoScrollChange:g,scrollToBottomRef:_,serverUrl:v}){var y,b;let x=(0,$.useRef)(null),[S,C]=(0,$.useState)(!1),w=(0,$.useRef)(h),T=(0,$.useRef)(e.length),E=(0,$.useRef)(0),D=(0,$.useRef)(!1),O=(0,$.useRef)(!1),k=(0,$.useRef)(``),A=(0,$.useCallback)(e=>{if(e.length===0)return``;let t=e[e.length-1],n=t.parts.filter(e=>e.type===`text`).reduce((e,t)=>e+t.text.length,0);return`${t.message.id}:${ye(t.message)?t.message.status:`n/a`}:${t.parts.length}:${n}`},[]),j=(0,$.useRef)(null),M=(0,$.useRef)(null),N=(0,$.useRef)(new Map),P=(0,$.useRef)(e);P.current=e;let ee=(0,$.useCallback)(e=>{let t=P.current[e];if(!t)return ln+dn;if(t.message.role===`assistant`){let e=100;return t.parts.some(e=>{var t,n;return e.type===`text`&&((t=e.text)==null?void 0:t.includes("```"))||e.type===`tool`&&((n=e.state.input)==null?void 0:n.command)})&&(e=180),t.parts.some(e=>e.type===`tool`)&&(e=Math.max(e,150)),t.parts.some(e=>e.type===`compaction`)&&(e=60),t.message.mode===`compact_failed`&&(e=100),Math.min(Math.max(e+dn,ln+dn),un+dn)}let n=t.parts.length>1?80:60;return Math.min(Math.max(n+dn,ln+dn),un+dn)},[]);(0,$.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=requestAnimationFrame(()=>{e.querySelectorAll(`[data-index]`).forEach(e=>{let t=e.getAttribute(`data-index`);if(t===null)return;let n=parseInt(t,10);N.current.set(n,e.offsetHeight)})});return()=>cancelAnimationFrame(t)},[e.length]);let F=(0,$.useRef)(null);(0,$.useLayoutEffect)(()=>{let e=x.current;if(!e)return;F.current&&F.current.disconnect();let t=new ResizeObserver(e=>{e.forEach(e=>{let t=e.target,n=t.getAttribute(`data-index`);if(n===null)return;let r=parseInt(n,10),i=t.offsetHeight;N.current.set(r,i)})});return F.current=t,e.querySelectorAll(`[data-index]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length]);let I=Rt({count:e.length,getScrollElement:()=>x.current,estimateSize:ee,overscan:5,getItemKey:t=>{var n,r;let i=e[t];return(n=i==null||(r=i.message)==null?void 0:r.id)==null?`fallback-${t}`:n}});(0,$.useLayoutEffect)(()=>{w.current=h,T.current=e.length,E.current=0,D.current=!1,k.current=``,e.length!==0&&(I.scrollToIndex(e.length-1,{align:`end`}),D.current=!0)},[n]),(0,$.useEffect)(()=>{let e=x.current;if(!e)return;let t=e=>{w.current&&e.deltaY<0&&(w.current=!1,g==null||g(!1))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[g]);let L=vt(()=>{if(O.current)return;let e=x.current;if(e)if(w.current){let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r>0&&(O.current=!0,e.scrollTop=n,requestAnimationFrame(()=>{O.current=!1}))}else{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<=5&&(w.current=!0,g==null||g(!0))}});(0,$.useLayoutEffect)(()=>{C(a)},[a]);let R=A(e);(0,$.useLayoutEffect)(()=>{let t=e.length,n=T.current,r=t!==n,i=R,a=i!==k.current;k.current=i;let o=t-1,s=0;if(o>=0){var c;s=(c=N.current.get(o))==null?0:c}let l=E.current,u=o>=0&&s>l&&l>0;if(T.current=t,E.current=s,!(t===0||!r&&!a&&!u)){if(n===0&&t>0&&l===0&&!D.current){I.scrollToIndex(t-1,{align:`end`}),D.current=!0;return}w.current&&(x.current.scrollTop=x.current.scrollHeight)}},[e.length,R,I]),(0,$.useEffect)(()=>{var t;let n=I.getVirtualItems(),r=n.length-1;if(r<0)return;let i=n[r],a=(t=x.current)==null?void 0:t.querySelector(`[data-index="${i.index}"]`);if(j.current&&j.current.disconnect(),a&&(M.current=a,!(!fn(e)||!w.current)))return j.current=new ResizeObserver(t=>{w.current&&fn(e)&&requestAnimationFrame(()=>{w.current&&(x.current.scrollTop=x.current.scrollHeight)})}),j.current.observe(a),()=>{j.current&&(j.current.disconnect(),j.current=null)}},[e,I]),(0,$.useEffect)(()=>{if(o){let e=setTimeout(()=>{s==null||s()},3e3);return()=>clearTimeout(e)}},[o,s]),(0,$.useLayoutEffect)(()=>{_&&(_.current=()=>{w.current=!0,O.current=!0,x.current.scrollTop=x.current.scrollHeight,requestAnimationFrame(()=>{O.current=!1})})},[_]),(0,$.useLayoutEffect)(()=>{w.current=h},[h]);let z=I.getVirtualItems();return(0,Q.jsxs)(`div`,{ref:x,className:`flex-1 min-h-0 overflow-y-auto relative chat-transcript-scrollbar`,style:{WebkitOverflowScrolling:`touch`},onScroll:L,children:[S&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(hn,{})}),o&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(gn,{})}),r===`closed`&&(0,Q.jsx)(ce,{className:`mx-4 mt-4`,children:(0,Q.jsx)(re,{children:`This session is archived. You can reopen it from the sidebar.`})}),(0,Q.jsx)(`div`,{className:`relative w-full`,style:{height:`${I.getTotalSize()}px`},children:e.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground px-4`,children:[(0,Q.jsx)(`p`,{className:`text-lg mb-2`,children:`Start a conversation`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Send a message below to begin.`})]}):(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 w-full`,style:{transform:`translateY(${(y=(b=z[0])==null?void 0:b.start)==null?0:y}px)`},children:z.map(r=>{let o=e[r.index];return(0,Q.jsx)(`div`,{"data-index":r.index,ref:I.measureElement,className:`px-4 py-4`,children:(0,Q.jsx)(xn,{item:o,messagesWithParts:t,sessionId:n,pendingPermissions:i,onPermissionResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,isMainActiveSession:m,isCompacting:a,onCompact:p,serverUrl:v})},o.message.id)})})})]})}function Cn(e,t,n){let r=e.map(e=>({message:e.message,parts:e.parts,isQueued:!1})),i=t.map(e=>{let t=(e.attachments||[]).map(t=>{var r;let i=n(e.sessionId,t.id,(r=t.accessKey)==null?``:r);return t.kind===`image`?{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`image`,url:i,mimeType:t.mimeType}:{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`file`,url:i,mimeType:t.mimeType||``,filename:t.filename}});return{message:{id:e.id,role:`user`,sessionId:e.sessionId,createdAt:e.createdAt},parts:[...t,...e.content.trim()?[{id:`${e.id}-part`,messageId:e.id,createdAt:e.createdAt,type:`text`,text:e.content}]:[]],isQueued:!0,queueId:e.id}}),a=[...r].sort((e,t)=>e.message.createdAt-t.message.createdAt),o=[...i].sort((e,t)=>e.message.createdAt-t.message.createdAt);return[...a,...o]}function wn({permissions:e,onPermissionResponse:t}){return e.length===0?null:(0,Q.jsxs)(`div`,{className:`border-t border-border bg-muted/30 flex flex-col gap-2 p-4`,style:{overflow:`overlay`},children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground uppercase tracking-wide font-medium`,children:`Pending Requests`}),e.map(e=>{var n;let r=typeof((n=e.args)==null?void 0:n.command)==`string`?e.args.command:JSON.stringify(e.args,null,2);return(0,Q.jsxs)(`div`,{className:`p-3 bg-warning/10 border border-warning/30 rounded-lg flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:e.toolName})}),(0,Q.jsx)(`p`,{className:`text-sm`,children:e.message}),(0,Q.jsxs)(S,{children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full text-left`,children:[(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`uppercase tracking-wide`,children:`Command`})]})}),(0,Q.jsx)(D,{children:(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 mt-1 overflow-x-auto whitespace-pre-wrap break-words`,children:r})})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 flex-wrap`,children:[(0,Q.jsx)(p,{variant:`outline`,size:`sm`,onClick:()=>t(e.toolCallId,!1,!1),children:`Deny`}),(0,Q.jsx)(p,{variant:`secondary`,size:`sm`,onClick:()=>t(e.toolCallId,!0,!1),children:`Approve`}),(0,Q.jsx)(p,{size:`sm`,onClick:()=>t(e.toolCallId,!0,!0),children:`Always Allow`})]})]},e.toolCallId)})]})}function Tn({session:e,messagesWithParts:t,queuedMessages:n,preconfigs:r,prompts:i,models:a,defaultModel:o,onSendMessage:s,onRemoveFromQueue:c,onChangePreconfig:l,onChangeModel:u,onChangeVariant:d,pendingPermissions:f,onPermissionResponse:p,onRename:m,usage:h,modelName:g,modelSupportsImage:_,onNavigateToSubagent:v,onNavigateBack:y,isStreaming:b,onInterrupt:x,onRevert:S,onFork:C,onCompact:w,isCompacting:T,compactionSuccess:E,onClearCompactionSuccess:D,serverUrl:O,sdkClient:k,selectedVariant:A,variants:j,inputRef:M,scrollToBottomRef:N,autoFollowToggleRef:P}){let ee=!e.parentId&&e.status===`active`,[F,I]=(0,$.useState)(!0),L=(0,$.useCallback)(()=>{I(e=>{let t=!e;if(t){var n;N==null||(n=N.current)==null||n.call(N)}return t})},[N]);(0,$.useEffect)(()=>{P&&(P.current={toggle:()=>{L()}})},[P,L]);let R=(0,$.useMemo)(()=>{var e;return Cn(t,n,(e=k==null?void 0:k.http.attachments.getUrl)==null?((e,t,n)=>`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`):e)},[t,n,k]),z=(0,$.useMemo)(()=>f.filter(n=>n.sessionId===e.id?!t.some(e=>e.parts.some(e=>e.type===`tool`&&e.callId===n.toolCallId)):!1),[f,e.id,t]);return(0,Q.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 relative`,children:[(0,Q.jsx)(Ze,{session:e,preconfigs:r,models:a,defaultModel:o,usage:h,modelName:g,onChangePreconfig:l,onChangeModel:u,onChangeVariant:d,onRename:m,onNavigateBack:y,isStreaming:b,onInterrupt:x,onCompact:w,isCompacting:T,canCompact:t.length>=2,selectedVariant:A,variants:j}),(0,Q.jsxs)(`div`,{className:`relative flex flex-col flex-1 min-h-0`,children:[(0,Q.jsx)(Sn,{displayItems:R,messagesWithParts:t,sessionId:e.id,sessionStatus:e.status,pendingPermissions:f,isCompacting:T,compactionSuccess:E,onClearCompactionSuccess:D,onPermissionResponse:p,onNavigateToSubagent:v,onRemoveFromQueue:c,onRevert:S,onFork:C,onCompact:w,isMainActiveSession:ee,autoFollow:F,onAutoScrollChange:I,scrollToBottomRef:N,serverUrl:O}),(0,Q.jsx)(`button`,{onClick:L,className:`absolute bottom-4 right-4 z-50 flex items-center p-1.5 text-xs rounded-full transition-colors cursor-pointer bg-background/80 backdrop-blur-sm hover:bg-background border border-border/50 shadow-sm pointer-events-auto`,title:F?`Auto-follow enabled (Cmd+Shift+F)`:`Auto-follow disabled (Cmd+Shift+F)`,children:F?(0,Q.jsx)(be,{className:`size-3.5`}):(0,Q.jsx)(te,{className:`size-3.5`})})]}),z.length>0&&(0,Q.jsx)(wn,{permissions:z,onPermissionResponse:p}),e.status===`active`&&!e.parentId&&(0,Q.jsx)(ht,{ref:M,onSendMessage:s,disabled:T,workspaceId:e.workspaceId,sdkClient:k,prompts:i,sessionId:e.id,modelSupportsImage:_}),e.parentId&&(0,Q.jsxs)(`div`,{className:`p-4 border-t border-border bg-muted/50 text-center flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(je,{className:`size-4`}),`This is a subagent session (read-only)`]})]})}function En({serverUrl:e,messagesWithParts:t,inputRef:n,sdkClient:r,onRetry:o,onLogout:s,onSendMessage:l,onRemoveFromQueue:u,onChangePreconfig:d,onChangeModel:f,onChangeVariant:m,onPermissionResponse:h,onRename:g,onNavigateToSubagent:_,onNavigateBack:v,onInterrupt:y,onRevert:b,onFork:x,onCompact:S,onClearCompactionSuccess:C,scrollToBottomRef:w,autoFollowToggleRef:T}){var E,D,k;let A=a(e=>e.connected),j=a(e=>e.authError),M=a(e=>e.connectionTimedOut),N=a(e=>e.retryCount),P=a(e=>e.nextRetryIn),ee=a(e=>e.streamingSessionIds),F=c(e=>e.currentSession),I=c(e=>e.queuedMessages),L=c(e=>e.sessionUsage),R=c(e=>e.currentModel),z=c(e=>e.selectedVariant),te=c(e=>e.compactionSuccess),B=O(e=>e.preconfigs),V=O(e=>e.prompts),H=O(e=>e.models),U=O(e=>e.defaultModel),ne=i(e=>e.pendingPermissions),re=B.filter(e=>e.mode!==`subagent`),ie=!(F!=null&&F.parentId),ae=(E=F==null?void 0:F.compacting)==null?!1:E,oe=e=>{d(e)},se=e=>{m(e)},ce=()=>{y()};if(!A)return M?(0,Q.jsx)(`div`,{className:`flex w-full h-full items-center justify-center bg-background`,children:(0,Q.jsx)(Ve,{serverUrl:e,authError:j,retryCount:N,nextRetryIn:P,onRetry:o,onLogout:s})}):(0,Q.jsxs)(`div`,{className:`flex flex-col w-full h-full items-center justify-center bg-background gap-4`,children:[(0,Q.jsx)(Be,{}),(0,Q.jsx)(p,{variant:`ghost`,size:`sm`,onClick:s,className:`text-muted-foreground`,children:`Change Server`})]});if(!F)return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-muted-foreground px-6`,children:[(0,Q.jsx)(`h2`,{className:`mb-2`,children:`Select or create a session`}),(0,Q.jsx)(`p`,{children:`Choose a session from the sidebar or create a new one to start chatting.`})]});let le=t.filter(e=>e.message.role!==`system`).length>=2,W=H.find(e=>e.id===R);return(0,Q.jsx)(Tn,{inputRef:n,session:F,messagesWithParts:t,queuedMessages:I[F.id]||[],preconfigs:ie?re:B,prompts:V,models:H,defaultModel:U,onSendMessage:l,onRemoveFromQueue:u,onChangePreconfig:oe,onChangeModel:f,onChangeVariant:se,selectedVariant:z,variants:W==null?void 0:W.variants,pendingPermissions:ne,onPermissionResponse:h,onRename:g,usage:L,modelName:R,modelSupportsImage:(D=W==null||(k=W.capabilities)==null||(k=k.input)==null?void 0:k.image)==null?!1:D,onNavigateToSubagent:_,onNavigateBack:v,isStreaming:ee.has(F.id)||!!F.runningAt,onInterrupt:ce,onRevert:b,onFork:x,onCompact:le?()=>S(F.id):void 0,isCompacting:ae,compactionSuccess:te,onClearCompactionSuccess:C,serverUrl:e==null?void 0:e,sdkClient:r,scrollToBottomRef:w,autoFollowToggleRef:T})}function Dn(){let e=f(),{chatInputRef:t,scrollToBottomRef:n,autoFollowToggleRef:r}=C(),{sdkClient:i,messagesWithParts:a,serverUrl:o,currentSession:s,isSessionLoading:c,resumeSession:l,revertSession:u,forkSession:d,compactSession:p,removeFromQueue:m,sendChatMessage:h,handlePermissionResponse:g,handleInterruptSession:_,updateSessionPreconfig:v,updateSessionModel:y,updateSessionVariant:b,handleNavigateBack:x,handleRenameSession:S,setCompactionSuccess:w}=e;return c?(0,Q.jsx)(ze,{}):s?(0,Q.jsx)(En,{sdkClient:i,inputRef:t,messagesWithParts:a,serverUrl:o,onRetry:e.handleRetry,onLogout:e.handleLogout,onSendMessage:h,onRemoveFromQueue:m,onChangePreconfig:v,onChangeModel:y,onChangeVariant:b,onPermissionResponse:g,onRename:S,onNavigateToSubagent:l,onNavigateBack:x,onInterrupt:_,onRevert:u,onFork:d,onCompact:p,onClearCompactionSuccess:()=>w(!1),scrollToBottomRef:n,autoFollowToggleRef:r}):null}export{Dn as t};
@@ -1 +0,0 @@
1
- import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";var r=e(n(),1),i=t(),a=`jean2-theme`,o=`neutral`,s=`system`,c=(0,r.createContext)({mode:s,scheme:o,setMode:()=>null,setScheme:()=>null,resolvedMode:`dark`});function l(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function u(e){return e===`system`?l():e}function d(e){let t=localStorage.getItem(a);if(!t||![`light`,`dark`,`system`].includes(t))return null;let n={mode:t,scheme:o};return localStorage.setItem(e,JSON.stringify(n)),localStorage.removeItem(a),n}function f({children:e,defaultMode:t=s,defaultScheme:n=o,storageKey:a=`jean2-theme-settings`,...l}){let[f,p]=(0,r.useState)(()=>{let e=d(a);if(e)return e;let r=localStorage.getItem(a);if(r)try{let e=JSON.parse(r);if(typeof e==`object`&&e&&`mode`in e&&`scheme`in e)return e}catch{}return{mode:t,scheme:n}}),[m,h]=(0,r.useState)(()=>u(f.mode)),g=(0,r.useCallback)((e,t)=>{let n=window.document.documentElement,r=u(e);n.classList.remove(`light`,`dark`),n.classList.remove(`neutral`,`ocean`,`forest`,`sunset`,`amethyst`),n.classList.add(r),n.classList.add(t),h(r)},[]);(0,r.useEffect)(()=>{g(f.mode,f.scheme)},[f,g]),(0,r.useEffect)(()=>{if(f.mode!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{g(f.mode,f.scheme)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[f.mode,f.scheme,g]);let _=(0,r.useCallback)(e=>{let t={...f,mode:e};p(t),localStorage.setItem(a,JSON.stringify(t))},[f,a]),v=(0,r.useCallback)(e=>{let t={...f,scheme:e};p(t),localStorage.setItem(a,JSON.stringify(t))},[f,a]),y={mode:f.mode,scheme:f.scheme,setMode:_,setScheme:v,resolvedMode:m};return(0,i.jsx)(c.Provider,{...l,value:y,children:e})}var p=()=>{let e=(0,r.useContext)(c);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};export{p as n,f as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./_serverId-CsnPjy9K.js","./dropdown-menu-kSrbs3Xk.js","./src-w2G0llvL.js","./jsx-runtime-D-oznMWL.js","./react-DcCgrBX5.js","./badge-DUoauaaV.js","./createLucideIcon-BaO6wACO.js","./platform-Bn4qAxt4.js","./useParams-BODsv_8k.js","./servers-CGl9kUR2.js","./preload-helper-CYlqXMwt.js","./scroll-area-DVew28V6.js","./popover-DqniPNsl.js","./useNavigate-5b_LZg00.js","./useRouterState-FezJSBQO.js","./alert-DeW1kArF.js","./server-BNi58bIU.js","./ThemeProvider-JPllbGvS.js","./ServerContext-D9RfmQC6.js","./_serverId-XYC72_6_.js"])))=>i.map(i=>d[i]);
2
- import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{i as r,n as i,r as a}from"./src-w2G0llvL.js";import{D as o,O as s,_ as c,b as l,d as ee,k as te,u as ne,x as u,y as d}from"./servers-CGl9kUR2.js";import{E as f,a as re,c as p,f as ie,h as ae,m,n as h,s as g,t as _,v,y as oe}from"./useParams-BODsv_8k.js";import{n as y,t as b}from"./preload-helper-CYlqXMwt.js";import{t as x}from"./useNavigate-5b_LZg00.js";var se=`Error preloading route! ☝️`,S=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{var t,n;this.originalIndex=e.originalIndex;let r=this.options,i=!(r!=null&&r.path)&&!(r!=null&&r.id);this.parentRoute=(t=(n=this.options).getParentRoute)==null?void 0:t.call(n),i?this._path=p:this.parentRoute||f();let a=i?p:r==null?void 0:r.path;a&&a!==`/`&&(a=v(a));let o=(r==null?void 0:r.id)||a,s=i?p:m([this.parentRoute.id===`__root__`?``:this.parentRoute.id,o]);a===`__root__`&&(a=`/`),s!==`__root__`&&(s=m([`/`,s]));let c=s===`__root__`?`/`:m([this.parentRoute.fullPath,a]);this._path=a,this._id=s,this._fullPath=c,this._to=oe(c)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>g({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!(e!=null&&e.getParentRoute),e!=null&&e.id&&e!=null&&e.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},C=class extends S{constructor(e){super(e)}};function w(e){let{select:t,...n}=e;return h({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function T(e){return h({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function E(e){return h({...e,select:t=>e.select?e.select(t.context):t.context})}var D=e(n(),1),O=t(),ce=e(r(),1);function k(e,t){var n,r,i;let a=ee(),o=s(t),{activeProps:u,inactiveProps:f,activeOptions:p,to:m,preload:h,preloadDelay:g,preloadIntentProximity:_,hashScrollIntoView:v,replace:oe,startTransition:y,resetScroll:b,viewTransition:x,children:S,target:C,disabled:w,style:T,className:E,onClick:O,onBlur:k,onFocus:N,onMouseEnter:P,onMouseLeave:F,onTouchStart:I,ignoreBlocker:L,params:_e,search:R,hash:z,state:B,mask:ve,reloadDocument:ye,unsafeRelative:be,from:xe,_fromLocation:Se,...Ce}=e,V=re(),H=D.useMemo(()=>e,[a,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),U=ne(a.stores.location,e=>e,(e,t)=>e.href===t.href),W=D.useMemo(()=>{let e={_fromLocation:U,...H};return a.buildLocation(e)},[a,U,H]),we=W.maskedLocation?W.maskedLocation.publicHref:W.publicHref,Te=W.maskedLocation?W.maskedLocation.external:W.external,G=D.useMemo(()=>me(we,Te,a.history,w),[w,Te,we,a.history]),K=D.useMemo(()=>{if(G!=null&&G.external)return l(G.href,a.protocolAllowlist)?void 0:G.href;if(!he(m)&&!(typeof m!=`string`||m.indexOf(`:`)===-1))try{return new URL(m),l(m,a.protocolAllowlist)?void 0:m}catch{}},[m,G,a.protocolAllowlist]),q=D.useMemo(()=>{var e;if(K)return!1;if(p!=null&&p.exact){if(!ie(U.pathname,W.pathname,a.basepath))return!1}else{let e=ae(U.pathname,a.basepath),t=ae(W.pathname,a.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return((e=p==null?void 0:p.includeSearch)==null||e)&&!c(U.search,W.search,{partial:!(p!=null&&p.exact),ignoreUndefined:!(p!=null&&p.explicitUndefined)})?!1:p!=null&&p.includeHash?V&&U.hash===W.hash:!0},[p==null?void 0:p.exact,p==null?void 0:p.explicitUndefined,p==null?void 0:p.includeHash,p==null?void 0:p.includeSearch,U,K,V,W.hash,W.pathname,W.search,a.basepath]),J=q?(n=d(u,{}))==null?le:n:A,Y=q||(r=d(f,{}))==null?A:r,Ee=[E,J.className,Y.className].filter(Boolean).join(` `),De=(T||J.style||Y.style)&&{...T,...J.style,...Y.style},[Oe,ke]=D.useState(!1),Ae=D.useRef(!1),X=e.reloadDocument||K?!1:h==null?a.options.defaultPreload:h,Z=(i=g==null?a.options.defaultPreloadDelay:g)==null?0:i,Q=D.useCallback(()=>{a.preloadRoute({...H,_builtLocation:W}).catch(e=>{console.warn(e),console.warn(se)})},[a,H,W]);te(o,D.useCallback(e=>{e!=null&&e.isIntersecting&&Q()},[Q]),pe,{disabled:!!w||X!==`viewport`}),D.useEffect(()=>{Ae.current||!w&&X===`render`&&(Q(),Ae.current=!0)},[w,Q,X]);let je=e=>{let t=e.currentTarget.getAttribute(`target`),n=C===void 0?t:C;if(!w&&!ge(e)&&!e.defaultPrevented&&(!n||n===`_self`)&&e.button===0){e.preventDefault(),(0,ce.flushSync)(()=>{ke(!0)});let t=a.subscribe(`onResolved`,()=>{t(),ke(!1)});a.navigate({...H,replace:oe,resetScroll:b,hashScrollIntoView:v,startTransition:y,viewTransition:x,ignoreBlocker:L})}};if(K)return{...Ce,ref:o,href:K,...S&&{children:S},...C&&{target:C},...w&&{disabled:w},...T&&{style:T},...E&&{className:E},...O&&{onClick:O},...k&&{onBlur:k},...N&&{onFocus:N},...P&&{onMouseEnter:P},...F&&{onMouseLeave:F},...I&&{onTouchStart:I}};let Me=e=>{if(w||X!==`intent`)return;if(!Z){Q();return}let t=e.currentTarget;if(j.has(t))return;let n=setTimeout(()=>{j.delete(t),Q()},Z);j.set(t,n)},Ne=e=>{w||X!==`intent`||Q()},$=e=>{if(w||!X||!Z)return;let t=e.currentTarget,n=j.get(t);n&&(clearTimeout(n),j.delete(t))};return{...Ce,...J,...Y,href:G==null?void 0:G.href,ref:o,onClick:M([O,je]),onBlur:M([k,$]),onFocus:M([N,Me]),onMouseEnter:M([P,Me]),onMouseLeave:M([F,$]),onTouchStart:M([I,Ne]),disabled:!!w,target:C,...De&&{style:De},...Ee&&{className:Ee},...w&&ue,...q&&de,...V&&Oe&&fe}}var A={},le={className:`active`},ue={role:`link`,"aria-disabled":!0},de={"data-status":`active`,"aria-current":`page`},fe={"data-transitioning":`transitioning`},j=new WeakMap,pe={rootMargin:`100px`},M=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function me(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function he(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var N=D.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=k(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return D.createElement(`a`,t,o)}return D.createElement(n,a,o)});function ge(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var P=class extends S{constructor(e){super(e),this.useMatch=e=>h({select:e==null?void 0:e.select,from:this.id,structuralSharing:e==null?void 0:e.structuralSharing}),this.useRouteContext=e=>E({...e,from:this.id}),this.useSearch=e=>T({select:e==null?void 0:e.select,structuralSharing:e==null?void 0:e.structuralSharing,from:this.id}),this.useParams=e=>_({select:e==null?void 0:e.select,structuralSharing:e==null?void 0:e.structuralSharing,from:this.id}),this.useLoaderDeps=e=>w({...e,from:this.id}),this.useLoaderData=e=>y({...e,from:this.id}),this.useNavigate=()=>x({from:this.fullPath}),this.Link=D.forwardRef((e,t)=>(0,O.jsx)(N,{ref:t,from:this.fullPath,...e}))}};function F(e){return new P(e)}function I(){return e=>_e(e)}var L=class extends C{constructor(e){super(e),this.useMatch=e=>h({select:e==null?void 0:e.select,from:this.id,structuralSharing:e==null?void 0:e.structuralSharing}),this.useRouteContext=e=>E({...e,from:this.id}),this.useSearch=e=>T({select:e==null?void 0:e.select,structuralSharing:e==null?void 0:e.structuralSharing,from:this.id}),this.useParams=e=>_({select:e==null?void 0:e.select,structuralSharing:e==null?void 0:e.structuralSharing,from:this.id}),this.useLoaderDeps=e=>w({...e,from:this.id}),this.useLoaderData=e=>y({...e,from:this.id}),this.useNavigate=()=>x({from:this.fullPath}),this.Link=D.forwardRef((e,t)=>(0,O.jsx)(N,{ref:t,from:this.fullPath,...e}))}};function _e(e){return new L(e)}function R(e){return typeof e==`object`?new z(e,{silent:!0}).createRoute(e):new z(e,{silent:!0}).createRoute}var z=class{constructor(e,t){this.path=e,this.createRoute=e=>{let t=F(e);return t.isRoot=!1,t},this.silent=t==null?void 0:t.silent}};function B(e,t){let n,r,i,a,s=()=>(n||(n=e().then(e=>{n=void 0,r=e[t==null?`default`:t]}).catch(e=>{if(i=e,u(i)&&i instanceof Error&&typeof window<`u`&&typeof sessionStorage<`u`){let e=`tanstack_router_reload:${i.message}`;sessionStorage.getItem(e)||(sessionStorage.setItem(e,`1`),a=!0)}})),n),c=function(e){if(a)throw window.location.reload(),new Promise(()=>{});if(i)throw i;if(!r)if(o)o(s());else throw s();return D.createElement(r,e)};return c.preload=s,c}async function ve(e,t,n){return new i(new a({url:e,token:t})).loadAll({signal:n})}var ye=R(`/server/$serverId`)({beforeLoad:({params:e,context:t})=>{let n=t.serverRegistry.getServer(e.serverId);if(!n){let e=t.serverRegistry.getServers();throw e.length>0?g({to:`/server/$serverId`,params:{serverId:e[0].id},replace:!0,throw:!0}):g({to:`/`,replace:!0,throw:!0})}return{server:n}},loader:async({params:e,context:t,abortController:n})=>{let r=t.serverRegistry.getServer(e.serverId);if(!r)throw g({to:`/`,replace:!0,throw:!0});try{return await ve(r.url,r.token,n.signal)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw e;let t=e instanceof Error?e.message:String(e);throw Error(`Failed to connect to server: ${t}`,{cause:e})}},component:B(()=>b(()=>import(`./_serverId-CsnPjy9K.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]),import.meta.url),`component`),errorComponent:B(()=>b(()=>import(`./_serverId-XYC72_6_.js`),__vite__mapDeps([19,3,9,4]),import.meta.url),`errorComponent`),pendingComponent:()=>(0,O.jsx)(`div`,{className:`w-full flex items-center justify-center min-h-screen bg-background text-foreground`,children:(0,O.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,O.jsx)(`div`,{className:`h-8 w-8 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin mx-auto`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connecting to server...`})]})})});export{I as i,B as n,R as r,ye as t};