@jean2/client 1.0.5 → 1.0.6

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 (76) hide show
  1. package/README.md +15 -59
  2. package/dist/apple-touch-icon.png +0 -0
  3. package/dist/assets/ServerContext-DwL_fyZz.js +1 -0
  4. package/dist/assets/SessionContent-BtiY3mu_.js +11 -0
  5. package/dist/assets/SessionMenuButton-bQK4n-kR.js +9 -0
  6. package/dist/assets/SessionMenuButton-kHJ-D0s7.css +1 -0
  7. package/dist/assets/{ThemeProvider-Da23NPAS.js → ThemeProvider-ewislekS.js} +1 -1
  8. package/dist/assets/{_serverId-DXVl_AFQ.js → _serverId-C48-o6-u.js} +1 -1
  9. package/dist/assets/_serverId-D3aDURKI.js +11 -0
  10. package/dist/assets/_sessionId-CGhGqBYc.js +1 -0
  11. package/dist/assets/_sessionId-CvDJrnJN.js +1 -0
  12. package/dist/assets/add-server-CP5wqpVh.js +1 -0
  13. package/dist/assets/alert-DgtoQIaS.js +31 -0
  14. package/dist/assets/{archive-pL5uw9sg.js → archive-CJqmerPG.js} +1 -1
  15. package/dist/assets/arrow-left-CVfrLbQ4.js +1 -0
  16. package/dist/assets/badge-D8GOF5_2.js +1 -0
  17. package/dist/assets/button-BCE1SnDM.js +45 -0
  18. package/dist/assets/{confirmation-dialog-CFCxzDEX.js → confirmation-dialog-jz6z4bio.js} +1 -1
  19. package/dist/assets/{dialog-BNCh4KEM.js → dialog-B-f8lUpV.js} +1 -1
  20. package/dist/assets/http-namespace-DWmi6fC5.js +1 -0
  21. package/dist/assets/index-BtLxCr26.css +2 -0
  22. package/dist/assets/index-DJCUk1OY.js +10 -0
  23. package/dist/assets/mutation-BEKt1T6j.js +1 -0
  24. package/dist/assets/overview-dKJbdHqg.js +1 -0
  25. package/dist/assets/platform-C9rqh4_A.js +1 -0
  26. package/dist/assets/popover-CVyjoKPS.js +1 -0
  27. package/dist/assets/queries-BTzP-7g4.js +1 -0
  28. package/dist/assets/{react-dom-DHWV5rS5.js → react-dom-CZubyneS.js} +1 -1
  29. package/dist/assets/{refresh-cw-BYRFQSBp.js → refresh-cw-DJ3pEikS.js} +1 -1
  30. package/dist/assets/routes-g7_8LIaN.js +1 -0
  31. package/dist/assets/sidebar-lTmDketj.js +1 -0
  32. package/dist/assets/{triangle-alert-Bil68MLf.js → triangle-alert-C32xrDjH.js} +1 -1
  33. package/dist/assets/useNavigate-D0TSLH_-.js +1 -0
  34. package/dist/assets/workspace-CQqKn4Z3.js +1 -0
  35. package/dist/favicon.ico +0 -0
  36. package/dist/icon-192.png +0 -0
  37. package/dist/icon-512.png +0 -0
  38. package/dist/index.html +14 -15
  39. package/dist/manifest.webmanifest +1 -0
  40. package/dist/registerSW.js +1 -0
  41. package/dist/sw.js +1 -0
  42. package/dist/workbox-6829fd8d.js +1 -0
  43. package/package.json +1 -1
  44. package/dist/assets/ServerContext-Dy9T5Mj8.js +0 -1
  45. package/dist/assets/SessionContent-DMPPyidM.js +0 -11
  46. package/dist/assets/SessionMenuButton-B9RQW_iM.css +0 -1
  47. package/dist/assets/SessionMenuButton-DtN_qfRb.js +0 -9
  48. package/dist/assets/_serverId-BOWHyoan.js +0 -12
  49. package/dist/assets/_sessionId-BfVgqUBK.js +0 -1
  50. package/dist/assets/_sessionId-Bp7Qrc4O.js +0 -1
  51. package/dist/assets/add-server-BU3oc_j3.js +0 -1
  52. package/dist/assets/alert-BsN6ZzaK.js +0 -31
  53. package/dist/assets/arrow-left-DSvwF2mY.js +0 -1
  54. package/dist/assets/badge-Cjebg6Sp.js +0 -1
  55. package/dist/assets/button--1wnt03c.js +0 -45
  56. package/dist/assets/classPrivateFieldGet2-BGlEuFdn.js +0 -1
  57. package/dist/assets/core-BYcrozIP.js +0 -1
  58. package/dist/assets/dist-js-s36UjyQ4.js +0 -1
  59. package/dist/assets/event-Crr43Eih.js +0 -1
  60. package/dist/assets/index-Db3JxRbZ.js +0 -10
  61. package/dist/assets/index-DzEyMPKG.css +0 -2
  62. package/dist/assets/mutation-D4xtepYQ.js +0 -1
  63. package/dist/assets/overview-DbKX71kj.js +0 -1
  64. package/dist/assets/platform-cRBZ7eSy.js +0 -1
  65. package/dist/assets/popover-C8mm1NWm.js +0 -1
  66. package/dist/assets/preload-helper-D844vhe4.js +0 -1
  67. package/dist/assets/queries-C0JoQFZb.js +0 -1
  68. package/dist/assets/routes-Ck6V8B0w.js +0 -1
  69. package/dist/assets/sidebar-BqQ-fUFc.js +0 -1
  70. package/dist/assets/src-BALdofIU.js +0 -1
  71. package/dist/assets/useNavigate-Ckup4lZi.js +0 -1
  72. package/dist/assets/workspace-BzFUmInc.js +0 -1
  73. /package/dist/assets/{createLucideIcon-CuVT3KNW.js → createLucideIcon-mdFRYmiK.js} +0 -0
  74. /package/dist/assets/{overview-C91MPxfo.js → overview-B_ZDrH1J.js} +0 -0
  75. /package/dist/assets/{useRouter-C67ywEA3.js → useRouter-C_VHQC31.js} +0 -0
  76. /package/dist/assets/{workspace-84xYPx6s.js → workspace-_n12Hx4o.js} +0 -0
package/README.md CHANGED
@@ -4,8 +4,8 @@ Cross-platform frontend for the Jean2 AI Agent. Connects to a Jean2 server over
4
4
 
5
5
  Three deployment targets:
6
6
 
7
- - **Tauri Desktop** — Native macOS and Windows application with multi-window support
8
- - **Tauri iOS** — Native iPhone application
7
+ - **Web / PWA** — Browser-based with offline support and installable as a PWA
8
+ - **Electron Desktop** — Native macOS and Windows application with multi-window support
9
9
  - **Web CLI** — Run locally via `npx @jean2/client`
10
10
 
11
11
  ## Features
@@ -23,12 +23,11 @@ Three deployment targets:
23
23
  - Dark and light themes (persists per platform)
24
24
  - Responsive layout — works on desktop and mobile viewports
25
25
  - Two view modes — Default (session list) and Overview (multi-workspace dashboard with Quick Switcher)
26
+ - PWA support — install to home screen on mobile and desktop
26
27
 
27
28
  ## Prerequisites
28
29
 
29
30
  - [Bun](https://bun.sh/)
30
- - For Tauri desktop builds: [Rust](https://www.rust-lang.org/tools/install) and Xcode Command Line Tools (`xcode-select --install`) (macOS) or Visual Studio Build Tools (Windows)
31
- - For iOS builds: Xcode, Apple Developer account — see [README-ios.md](README-ios.md)
32
31
 
33
32
  ## Development
34
33
 
@@ -42,57 +41,15 @@ bun run dev
42
41
 
43
42
  The Vite dev server proxies `/api` and `/ws` to `http://localhost:3000`.
44
43
 
45
- ### Tauri Desktop (Live Reload)
46
-
47
- ```bash
48
- # Opens native window with hot module replacement
49
- bun run tauri:dev
50
- ```
51
-
52
- ### Tauri iOS (Live Reload)
53
-
54
- ```bash
55
- bun run tauri:ios:dev
56
- ```
57
-
58
44
  ## Building
59
45
 
60
- ### Web
46
+ ### Web / PWA
61
47
 
62
48
  ```bash
63
49
  bun run build
64
50
  # Output: dist/
65
51
  ```
66
52
 
67
- ### Tauri Desktop
68
-
69
- ```bash
70
- # macOS (Apple Silicon)
71
- bun run tauri:build:macos
72
-
73
- # Generic (all targets)
74
- bun run tauri:build
75
- ```
76
-
77
- ### macOS Gatekeeper (Unsigned Builds)
78
-
79
- Apps downloaded from GitHub releases are not code-signed. macOS will block opening them by default. Remove the quarantine attribute:
80
-
81
- ```bash
82
- xattr -cr /Applications/Jean2.app
83
- ```
84
-
85
- ### Tauri Windows
86
-
87
- ```bash
88
- # Windows (x64)
89
- bun run tauri:build:windows
90
- ```
91
-
92
- ### Tauri iOS
93
-
94
- See [README-ios.md](README-ios.md) for full build and deployment instructions.
95
-
96
53
  ### CLI / npx
97
54
 
98
55
  ```bash
@@ -142,18 +99,17 @@ packages/client/
142
99
  servers.ts Server CRUD in localStorage
143
100
  lib/
144
101
  utils.ts cn() and Tailwind merge
145
- storage.ts Platform-agnostic storage (Tauri Store / localStorage)
102
+ storage.ts Platform-agnostic storage (Electron store / localStorage)
146
103
  path.ts Path utilities
147
104
  utils/
148
105
  diff.ts Diff parsing utilities
149
- src-tauri/
150
- tauri.conf.json Tauri configuration
151
- src/
152
- lib.rs Platform gate (desktop vs mobile)
153
- desktop.rs Desktop entry multi-window, plugins
154
- mobile.rs iOS entry — plugins only
106
+ public/
107
+ favicon.ico Favicon
108
+ icon-192.png PWA icon (small)
109
+ icon-512.png PWA icon (large)
110
+ apple-touch-icon.png iOS home screen icon
155
111
  components.json shadcn/ui configuration (radix-nova style)
156
- vite.config.ts Vite — React, Tailwind, path aliases, dev proxy
112
+ vite.config.ts Vite — React, Tailwind, path aliases, dev proxy, PWA
157
113
  package.npm.json Minimal manifest for npm publish (CLI mode)
158
114
  VERSION Client version
159
115
  ```
@@ -167,11 +123,11 @@ packages/client/
167
123
  | Styling | Tailwind CSS v4, shadcn/ui, Radix UI |
168
124
  | Fonts | Geist Variable |
169
125
  | Icons | Lucide React |
170
- | Desktop | Tauri 2 (Rust) — macOS, Windows |
171
- | Mobile | Tauri 2 iOS |
126
+ | Desktop | Electron — macOS, Windows |
127
+ | Mobile | Web / PWA |
172
128
  | Markdown | react-markdown + remark-gfm |
173
129
  | Code blocks | prism-react-renderer |
174
- | Storage | @tauri-apps/plugin-store / localStorage |
130
+ | Storage | localStorage (web) / Electron store (desktop) |
175
131
  | CLI | esbuild bundle, Node.js http module |
176
132
 
177
133
  ## Architecture
@@ -184,4 +140,4 @@ The client connects to a Jean2 server via WebSocket (`ws://host:port/ws?token=..
184
140
 
185
141
  **Multi-workspace support** isolates sessions by workspace. The active workspace is persisted and restored on reload.
186
142
 
187
- **Platform abstraction** — the `storage` module (`lib/storage.ts`) transparently uses Tauri Store on native platforms and falls back to localStorage on web. The Tauri Rust layer adds native-only features like multi-window (`Cmd+N`).
143
+ **Platform abstraction** — the `storage` module (`lib/storage.ts`) transparently uses the Electron IPC store on desktop and falls back to localStorage on web/PWA. The Electron layer adds native-only features like multi-window (`Cmd+N`).
Binary file
@@ -0,0 +1 @@
1
+ import{n as e,o as t,r as n,t as r}from"./compiler-runtime-DZXZ41-q.js";var i=t(n(),1),a=i.use,o=typeof window<`u`?i.useLayoutEffect:i.useEffect;function s(e){let t=i.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function c(e,t,n={},r={}){i.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function l(e){let t=i.useRef(null);return i.useImperativeHandle(e,()=>t.current,[]),t}var u=r(),d={SERVERS:`jean2_servers`,QUICK_CONNECTIONS:`jean2_quick_connections`};function f(){try{let e=localStorage.getItem(d.SERVERS);return e?JSON.parse(e):[]}catch(e){return console.error(`Error reading saved servers from localStorage:`,e),[]}}function p(e){try{let t=f();t.push(e),localStorage.setItem(d.SERVERS,JSON.stringify(t))}catch(e){console.error(`Error saving server to localStorage:`,e)}}function m(e,t){try{let n=f(),r=n.findIndex(t=>t.id===e);if(r===-1){console.error(`Server not found:`,e);return}n[r]={...n[r],...t},localStorage.setItem(d.SERVERS,JSON.stringify(n))}catch(e){console.error(`Error updating server in localStorage:`,e)}}function h(e){try{let t=f().filter(t=>t.id!==e);localStorage.setItem(d.SERVERS,JSON.stringify(t));let n=g().filter(t=>t.serverId!==e);localStorage.setItem(d.QUICK_CONNECTIONS,JSON.stringify(n))}catch(e){console.error(`Error deleting server from localStorage:`,e)}}function g(){try{let e=localStorage.getItem(d.QUICK_CONNECTIONS);return e?JSON.parse(e):[]}catch(e){return console.error(`Error reading quick connections from localStorage:`,e),[]}}function _(e){let t=g(),n=t.reduce((e,t)=>Math.max(e,t.order),-1),r={...e,id:crypto.randomUUID(),order:n+1};t.push(r);try{localStorage.setItem(d.QUICK_CONNECTIONS,JSON.stringify(t))}catch(e){console.error(`Error saving quick connection to localStorage:`,e)}return r}function v(e){try{let t=g().filter(t=>t.id!==e);localStorage.setItem(d.QUICK_CONNECTIONS,JSON.stringify(t))}catch(e){console.error(`Error removing quick connection from localStorage:`,e)}}function y(e){try{let t=g().filter(t=>t.workspaceId!==e);localStorage.setItem(d.QUICK_CONNECTIONS,JSON.stringify(t))}catch(e){console.error(`Error removing quick connections for workspace from localStorage:`,e)}}function b(e){try{let t=g(),n=new Map(t.map(e=>[e.id,e]));e.forEach((e,t)=>{let r=n.get(e);r&&(r.order=t)}),localStorage.setItem(d.QUICK_CONNECTIONS,JSON.stringify(t))}catch(e){console.error(`Error reordering quick connections in localStorage:`,e)}}function x(e){return e.length<12?e:`${e.slice(0,4)}...${e.slice(-4)}`}function S(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 C=class extends Error{constructor(e,t){super(e,t),this.name=`Jean2Error`}},w=class extends C{constructor(e,t){super(e,t),this.name=`ConnectionError`}},T=class extends C{constructor(e,t){super(e,t),this.name=`AuthError`}},E=class extends C{retryAfterMs;constructor(e,t,n){super(e,n),this.name=`RateLimitError`,this.retryAfterMs=t}},D=class extends C{statusCode;constructor(e,t,n){super(e,n),this.name=`ServerError`,this.statusCode=t}},O=class extends C{statusCode;constructor(e,t=400,n){super(e,n),this.name=`ValidationError`,this.statusCode=t}},k=class{baseUrl;token;constructor(e){let t=e.apiBase||`/api`;this.baseUrl=`${e.url.startsWith(`https`)?`https`:`http`}://${e.url.replace(/^https?:\/\//,``)}${t}`,this.token=e.token}async request(e,t={}){let{method:n=`GET`,body:r,headers:i={},signal:a,params:o}=t,s=`${this.baseUrl}${e}`;if(o){let e=new URLSearchParams(o);s+=`?${e.toString()}`}let c={...i};r!==void 0&&!(r instanceof FormData)&&(c[`Content-Type`]=`application/json`),this.token&&(c.Authorization=`Bearer ${this.token}`);let l=await fetch(s,{method:n,headers:c,body:r instanceof FormData?r:r?JSON.stringify(r):void 0,signal:a});if(l.status===401)throw new T(`Authentication failed. Your token may be invalid or expired.`);if(l.status===429){let e=l.headers.get(`Retry-After`);throw new E(`Too many requests`,e?parseInt(e,10)*1e3:void 0)}if(!l.ok){let e=`HTTP ${l.status}`;try{let t=await l.json();t.message&&(e=t.message)}catch{}throw l.status>=500?new D(e,l.status):new O(e,l.status)}return l.headers.get(`Content-Type`)?.includes(`application/json`)?l.json():l}get(e,t){return this.request(e,{...t,method:`GET`})}post(e,t,n){return this.request(e,{...n,method:`POST`,body:t})}put(e,t,n){return this.request(e,{...n,method:`PUT`,body:t})}patch(e,t,n){return this.request(e,{...n,method:`PATCH`,body:t})}delete(e,t){return this.request(e,{...t,method:`DELETE`})}static async verifyToken(e,t){let n=e.startsWith(`https`)?`https`:`http`,r=e.replace(/^https?:\/\//,``);try{let e={};return t&&(e.Authorization=`Bearer ${t}`),(await fetch(`${n}://${r}/api/auth/verify`,{headers:e})).status===200}catch(e){throw new w(`Failed to reach server for auth verification: ${e instanceof Error?e.message:String(e)}`)}}},A=`localhost:8742`,j=2e3;async function M(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),j),r=await fetch(`http://${A}/api/info`,{signal:e??t.signal});return clearTimeout(n),!r.ok||((await r.json()).features?.authentication??!1)?{available:!1,url:A}:{available:!0,url:A}}catch{return{available:!1,url:A}}}async function N(e,t){let n=S(e),r;try{let e=n.startsWith(`https`)?`https`:`http`,t=n.replace(/^https?:\/\//,``),i=await fetch(`${e}://${t}/api/info`);if(!i.ok)return{success:!1,error:`Server returned ${i.status}. Check the URL and try again.`};r=(await i.json()).features?.authentication??!1}catch(e){return{success:!1,error:`Could not reach server: ${e instanceof Error?e.message:String(e)}`}}if(!r)return{success:!0,authEnabled:!1};if(!t)return{success:!1,authEnabled:!0,error:`This server requires an API token. Enable the token toggle and enter your token.`};try{if(!await k.verifyToken(n,t))return{success:!1,authEnabled:!0,error:`Invalid token. Check your API token and try again.`}}catch(e){return{success:!1,authEnabled:!0,error:`Could not verify token: ${e instanceof Error?e.message:String(e)}`}}return{success:!0,authEnabled:!0}}var P=e(),F=(0,i.createContext)(null),I=e=>{let t=(0,u.c)(22),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[a,o]=(0,i.useState)(r),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[1]=s):s=t[1];let[c,l]=(0,i.useState)(s),[d,x]=(0,i.useState)(!1),C=(0,i.useRef)(!1),w,T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{let e=f(),t=g();o(e),l(t),x(!0)},T=[],t[2]=w,t[3]=T):(w=t[2],T=t[3]),(0,i.useEffect)(w,T);let E,D;t[4]!==d||t[5]!==a.length?(E=()=>{if(!d||C.current)return;if(a.length>0){C.current=!0;return}C.current=!0;let e=new AbortController;return M(e.signal).then(e=>{e.available&&(p({id:crypto.randomUUID(),name:`Home`,url:S(e.url),createdAt:new Date().toISOString()}),o(f()))}),()=>e.abort()},D=[d,a.length],t[4]=d,t[5]=a.length,t[6]=E,t[7]=D):(E=t[6],D=t[7]),(0,i.useEffect)(E,D);let O;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=(e,t,n)=>{let r=S(t),i={id:crypto.randomUUID(),name:e,url:r,...n?{token:n}:{},createdAt:new Date().toISOString()};return p(i),o(f()),i},t[8]=O):O=t[8];let k=O,A;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=(e,t)=>{m(e,{...t,...t.url&&{url:S(t.url)}}),o(f())},t[9]=A):A=t[9];let j=A,N;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{h(e),o(f()),l(g())},t[10]=N):N=t[10];let I=N,L;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(L=(e,t,n,r)=>{_({serverId:e,serverName:t,workspaceId:n,workspaceName:r}),l(g())},t[11]=L):L=t[11];let R=L,z;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{v(e),l(g())},t[12]=z):z=t[12];let B=z,V;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{y(e),l(g())},t[13]=V):V=t[13];let H=V,U;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{b(e),l(g())},t[14]=U):U=t[14];let W=U,G;t[15]!==d||t[16]!==c||t[17]!==a?(G={servers:a,quickConnections:c,isHydrated:d,addServer:k,editServer:j,removeServer:I,addToQuickConnections:R,removeFromQuickConnections:B,removeFromQuickConnectionsByWorkspace:H,reorderQuick:W},t[15]=d,t[16]=c,t[17]=a,t[18]=G):G=t[18];let K=G,q;return t[19]!==n||t[20]!==K?(q=(0,P.jsx)(F.Provider,{value:K,children:n}),t[19]=n,t[20]=K,t[21]=q):q=t[21],q},L=()=>{let e=(0,i.useContext)(F);if(e===null)throw Error(`useServerContext must be used within a ServerProvider`);return e};export{w as a,f as c,c as d,o as f,k as i,a as l,L as n,x as o,s as p,N as r,S as s,I as t,l as u};
@@ -0,0 +1,11 @@
1
+ import{n as e,o as t,r as n,t as r}from"./compiler-runtime-DZXZ41-q.js";import{t as i}from"./react-dom-CZubyneS.js";import{n as a}from"./ThemeProvider-ewislekS.js";import{$ as o,A as s,B as c,C as l,D as u,G as d,H as f,J as p,K as m,O as h,S as g,T as _,U as v,Y as y,_ as b,a as x,b as S,c as C,d as w,f as T,h as E,i as D,l as O,m as k,n as A,p as j,q as M,r as N,s as P,t as F,u as I,v as L,x as R,y as z}from"./badge-D8GOF5_2.js";import{t as B}from"./createLucideIcon-mdFRYmiK.js";import{t as V}from"./archive-CJqmerPG.js";import{t as H}from"./arrow-left-CVfrLbQ4.js";import{a as U,c as W,f as ee,i as G,l as te,m as ne,n as re,o as ie,p as ae,r as oe,s as se,t as K,u as q}from"./popover-CVyjoKPS.js";import{C as ce,S as le,_ as ue,a as J,b as de,c as fe,d as pe,f as me,g as he,h as ge,i as _e,l as ve,m as ye,n as be,o as xe,p as Se,r as Ce,s as we,t as Te,u as Ee,v as De,w as Oe,x as ke,y as Ae}from"./alert-DgtoQIaS.js";import{i as je,n as Me,r as Ne,t as Pe}from"./triangle-alert-C32xrDjH.js";import{C as Fe,F as Ie,M as Le,N as Re,P as ze,T as Be,b as Ve,j as He,r as Y,t as X,w as Ue,x as We}from"./button-BCE1SnDM.js";import{t as Ge}from"./refresh-cw-DJ3pEikS.js";import{t as Ke}from"./confirmation-dialog-jz6z4bio.js";function qe(e){return e.role===`assistant`}var Je=B(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ye=B(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Xe=B(`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`}]]),Ze=B(`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`}]]),Qe=B(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),$e=B(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),et=B(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),tt=B(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),nt=B(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),rt=B(`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`}]]),it=B(`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`}]]),at=B(`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`}]]),ot=B(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),st=B(`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`}]]),ct=B(`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`}]]),lt=B(`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`}]]),ut=B(`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`}]]),dt=B(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),ft=B(`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`}]]),pt=B(`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`}]]),mt=B(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Z=t(n(),1),Q=e(),ht=`Checkbox`,[gt,_t]=Ue(ht),[vt,yt]=gt(ht);function bt(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=We({prop:n,defaultProp:i??!1,onChange:c,caller:ht}),[m,h]=Z.useState(null),[g,_]=Z.useState(null),v=Z.useRef(!1),y=m?!!o||!!m.closest(`form`):!0,b={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,required:l,defaultChecked:kt(i)?!1:i,isFormControl:y,bubbleInput:g,setBubbleInput:_};return(0,Q.jsx)(vt,{scope:t,...b,children:Ot(d)?d(b):r})}var xt=`CheckboxTrigger`,St=Z.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=yt(xt,e),h=He(i,u),g=Z.useRef(c);return Z.useEffect(()=>{let e=a?.form;if(e){let t=()=>d(g.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,Q.jsx)(Be.button,{type:`button`,role:`checkbox`,"aria-checked":kt(c)?`mixed`:c,"aria-required":l,"data-state":At(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:h,onKeyDown:Fe(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:Fe(n,e=>{d(e=>kt(e)?!0:!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});St.displayName=xt;var Ct=Z.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Q.jsx)(bt,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(St,{...d,ref:t,__scopeCheckbox:n}),e&&(0,Q.jsx)(Dt,{__scopeCheckbox:n})]})})});Ct.displayName=ht;var wt=`CheckboxIndicator`,Tt=Z.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=yt(wt,n);return(0,Q.jsx)(Ve,{present:r||kt(a.checked)||a.checked===!0,children:(0,Q.jsx)(Be.span,{"data-state":At(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});Tt.displayName=wt;var Et=`CheckboxBubbleInput`,Dt=Z.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:l,name:u,value:d,form:f,bubbleInput:p,setBubbleInput:m}=yt(Et,e),h=He(n,m),g=ve(a),_=c(r);Z.useEffect(()=>{let e=p;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(g!==a&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=kt(a),n.call(e,kt(a)?!1:a),e.dispatchEvent(t)}},[p,g,a,i]);let v=Z.useRef(kt(a)?!1:a);return(0,Q.jsx)(Be.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o??v.current,required:s,disabled:l,name:u,value:d,form:f,...t,tabIndex:-1,ref:h,style:{...t.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});Dt.displayName=Et;function Ot(e){return typeof e==`function`}function kt(e){return e===`indeterminate`}function At(e){return kt(e)?`indeterminate`:e?`checked`:`unchecked`}var $=r();function jt(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex flex-col h-full items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(v,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Loading conversation...`})]}),e[0]=t):t=e[0],t}function Mt(e){let t=(0,$.c)(3),{message:n}=e,r=n===void 0?`Connecting to server...`:n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(v,{className:`size-8 animate-spin`}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground`,children:[i,(0,Q.jsx)(`p`,{className:`text-sm`,children:r})]}),t[1]=r,t[2]=a),a}var Nt=e=>{let t=(0,$.c)(26),{serverUrl:n,authError:r,retryCount:i,nextRetryIn:a,onRetry:o,onLogout:s}=e,c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(pt,{className:`size-12 text-destructive mb-4`}),l=(0,Q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground mb-2`,children:`Unable to connect to server`}),t[0]=c,t[1]=l):(c=t[0],l=t[1]);let u=r||`Please check that the server is running.`,d;t[2]===u?d=t[3]:(d=(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-[400px]`,children:u}),t[2]=u,t[3]=d);let f;t[4]===n?f=t[5]:(f=n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-6 font-mono bg-muted px-3 py-1.5 rounded`,children:n}),t[4]=n,t[5]=f);let p;t[6]===a?p=t[7]:(p=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Retrying in `,a,`s...`]}),t[6]=a,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(Ge,{className:`size-4 mr-2`,"data-icon":`inline-start`}),t[8]=m):m=t[8];let h;t[9]===o?h=t[10]:(h=(0,Q.jsxs)(X,{onClick:o,variant:`default`,children:[m,`Retry Now`]}),t[9]=o,t[10]=h);let g;t[11]===s?g=t[12]:(g=(0,Q.jsx)(X,{onClick:s,variant:`ghost`,children:`Change Server`}),t[11]=s,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===i?v=t[17]:(v=i>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retry attempt: `,i]}),t[16]=i,t[17]=v);let y;t[18]!==_||t[19]!==v||t[20]!==p?(y=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[p,_,v]}),t[18]=_,t[19]=v,t[20]=p,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==d||t[24]!==f?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] px-4 text-center`,children:[c,l,d,f,y]}),t[22]=y,t[23]=d,t[24]=f,t[25]=b):b=t[25],b};function Pt(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:e.toString()}function Ft(e){return e>=60?`critical`:e>=40?`warning`:`normal`}function It(e){let t=(0,$.c)(21),{totalTokens:n,contextWindow:r}=e,i=n===void 0?0:n,a=r===void 0?0:r,[o,s]=(0,Z.useState)(!1),c=i===0?0:a,l;t[0]!==c||t[1]!==i?(l=c===0?0:Math.min(100,Math.round(i/c*100)),t[0]=c,t[1]=i,t[2]=l):l=t[2];let u=l,d=Ft(u),f=2*Math.PI*8,p=f*(1-u/100),m=u===0?`text-muted-foreground/30`:d===`critical`?`text-destructive`:d===`warning`?`text-warning`:`text-primary`,h;t[3]===o?h=t[4]:(h=()=>s(!o),t[3]=o,t[4]=h);let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:`text-muted-foreground/20`,strokeWidth:`3`}),t[5]=g):g=t[5];let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_={transition:`stroke-dashoffset 0.3s ease`},t[6]=_):_=t[6];let v;t[7]!==m||t[8]!==p?(v=(0,Q.jsxs)(`svg`,{viewBox:`0 0 20 20`,className:`size-5`,fill:`none`,children:[g,(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:m,strokeWidth:`3`,strokeDasharray:f,strokeDashoffset:p,strokeLinecap:`round`,transform:`rotate(-90 10 10)`,style:_})]}),t[7]=m,t[8]=p,t[9]=v):v=t[9];let y;t[10]!==c||t[11]!==u||t[12]!==o||t[13]!==i?(y=o?`${Pt(i)}/${Pt(c)}`:`${u}%`,t[10]=c,t[11]=u,t[12]=o,t[13]=i,t[14]=y):y=t[14];let b;t[15]===y?b=t[16]:(b=(0,Q.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:y}),t[15]=y,t[16]=b);let x;return t[17]!==h||t[18]!==v||t[19]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:h,children:[v,b]}),t[17]=h,t[18]=v,t[19]=b,t[20]=x):x=t[20],x}function Lt(e){switch(e){case`budget`:return`$`;case`standard`:return`$$`;case`premium`:return`$$$`;default:return``}}function Rt(e,t,n,r){return Object.entries(e).map(([e,i])=>(0,Q.jsx)(se,{heading:e,children:i.map(e=>{let i=r(e);return(0,Q.jsxs)(te,{value:i,showCheck:!1,onSelect:()=>n(i),children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Lt(e.tier)}),(0,Q.jsx)(p,{className:Y(`ml-auto size-4`,t===i?`opacity-100`:`opacity-0`)})]},i)})},e))}function zt(e){let t=(0,$.c)(54),{models:n,selectedModelId:r,selectedProviderId:i,onChangeModel:a,disabled:o,compact:s,iconOnly:c}=e,l=s===void 0?!1:s,u=c===void 0?!1:c,[d,f]=(0,Z.useState)(!1),p,m;if(t[0]!==n||t[1]!==a||t[2]!==r||t[3]!==i){let e=n.reduce(Vt,{}),o=Bt,s;t[6]!==n||t[7]!==a?(s=e=>{let t=e.indexOf(`:`),r=e.slice(0,t),i=e.slice(t+1);n.find(e=>e.providerId===r&&e.id===i)&&(a(i,r),f(!1))},t[6]=n,t[7]=a,t[8]=s):s=t[8];let c=s,l=r&&i?i+`:`+r:null,u;t[9]!==n||t[10]!==r||t[11]!==i?(u=r&&i?n.find(e=>e.providerId===i&&e.id===r):n.find(e=>e.id===r),t[9]=n,t[10]=r,t[11]=i,t[12]=u):u=t[12],p=u,m=Rt(e,l,c,o),t[0]=n,t[1]=a,t[2]=r,t[3]=i,t[4]=p,t[5]=m}else p=t[4],m=t[5];let h=m;if(u){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(le,{className:`size-4 text-muted-foreground`}),t[13]=e):e=t[13];let n;t[14]!==o||t[15]!==d?(n=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,disabled:o,children:e})}),t[14]=o,t[15]=d,t[16]=n):n=t[16];let r;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(W,{placeholder:`Search model...`}),t[17]=r):r=t[17];let i;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(ie,{children:`No model found.`}),t[18]=i):i=t[18];let a;t[19]===h?a=t[20]:(a=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[r,(0,Q.jsxs)(q,{className:`max-h-[50vh] overflow-y-auto`,children:[i,h]})]})}),t[19]=h,t[20]=a);let s;return t[21]!==d||t[22]!==n||t[23]!==a?(s=(0,Q.jsxs)(K,{open:d,onOpenChange:f,children:[n,a]}),t[21]=d,t[22]=n,t[23]=a,t[24]=s):s=t[24],s}if(l){let e,n;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(le,{className:`size-4 flex-shrink-0 text-muted-foreground`}),n=(0,Q.jsx)(ne,{className:`size-3 shrink-0 opacity-50`}),t[25]=e,t[26]=n):(e=t[25],n=t[26]);let r;t[27]!==o||t[28]!==d?(r=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:o,children:[e,n]})}),t[27]=o,t[28]=d,t[29]=r):r=t[29];let i;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(W,{placeholder:`Search model...`}),t[30]=i):i=t[30];let a;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(ie,{children:`No model found.`}),t[31]=a):a=t[31];let s;t[32]===h?s=t[33]:(s=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[i,(0,Q.jsxs)(q,{className:`max-h-[50vh] overflow-y-auto`,children:[a,h]})]})}),t[32]=h,t[33]=s);let c;return t[34]!==d||t[35]!==r||t[36]!==s?(c=(0,Q.jsxs)(K,{open:d,onOpenChange:f,children:[r,s]}),t[34]=d,t[35]=r,t[36]=s,t[37]=c):c=t[37],c}let g;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(le,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[38]=g):g=t[38];let _=p?.name||`Select model`,v;t[39]===_?v=t[40]:(v=(0,Q.jsx)(`span`,{className:`truncate`,children:_}),t[39]=_,t[40]=v);let y;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(ne,{className:`size-3 shrink-0 opacity-50`}),t[41]=y):y=t[41];let b;t[42]!==o||t[43]!==d||t[44]!==v?(b=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:o,children:[g,v,y]})}),t[42]=o,t[43]=d,t[44]=v,t[45]=b):b=t[45];let x;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(W,{placeholder:`Search model...`}),t[46]=x):x=t[46];let S;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(ie,{children:`No model found.`}),t[47]=S):S=t[47];let C;t[48]===h?C=t[49]:(C=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[x,(0,Q.jsxs)(q,{className:`max-h-[50vh] overflow-y-auto`,children:[S,h]})]})}),t[48]=h,t[49]=C);let w;return t[50]!==d||t[51]!==C||t[52]!==b?(w=(0,Q.jsxs)(K,{open:d,onOpenChange:f,children:[b,C]}),t[50]=d,t[51]=C,t[52]=b,t[53]=w):w=t[53],w}function Bt(e){return e.providerId+`:`+e.id}function Vt(e,t){return e[t.providerName]||(e[t.providerName]=[]),e[t.providerName].push(t),e}var Ht={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-High`,minimal:`Minimal`,max:`Max`};function Ut(e){return Ht[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Wt(e){let t=(0,$.c)(69),{variants:n,selectedVariant:r,onChangeVariant:i,disabled:a,compact:o,iconOnly:s}=e,c=o===void 0?!1:o,l=s===void 0?!1:s,[u,d]=(0,Z.useState)(!1);if(!n||Object.keys(n).length===0)return null;let f,m,h,g,_,v,y;if(t[0]!==i||t[1]!==r||t[2]!==n){let e=Object.keys(n),a;t[10]===i?a=t[11]:(a=e=>{i(e===`__none__`?null:e),d(!1)},t[10]=i,t[11]=a);let o=a,s;t[12]===r?s=t[13]:(s=r?Ut(r):`Default`,t[12]=r,t[13]=s),h=s,m=U,t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(W,{placeholder:`Search...`}),t[14]=y):y=t[14],f=q,g=`max-h-[50vh] overflow-y-auto`;let c;t[15]===o?c=t[16]:(c=()=>o(`__none__`),t[15]=o,t[16]=c);let l;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`span`,{children:`Default`}),t[17]=l):l=t[17];let u=r===null?`opacity-100`:`opacity-0`,b;t[18]===u?b=t[19]:(b=Y(`size-4`,u),t[18]=u,t[19]=b);let x;t[20]===b?x=t[21]:(x=(0,Q.jsx)(p,{className:b}),t[20]=b,t[21]=x),t[22]!==x||t[23]!==c?(_=(0,Q.jsxs)(te,{value:`__none__`,onSelect:c,className:`justify-between`,children:[l,x]},`__none__`),t[22]=x,t[23]=c,t[24]=_):_=t[24],v=e.map(e=>(0,Q.jsxs)(te,{value:e,onSelect:()=>o(e),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:Ut(e)}),(0,Q.jsx)(p,{className:Y(`size-4`,r===e?`opacity-100`:`opacity-0`)})]},e)),t[0]=i,t[1]=r,t[2]=n,t[3]=f,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=y}else f=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],y=t[9];let b;t[25]!==f||t[26]!==g||t[27]!==_||t[28]!==v?(b=(0,Q.jsxs)(f,{className:g,children:[_,v]}),t[25]=f,t[26]=g,t[27]=_,t[28]=v,t[29]=b):b=t[29];let x;t[30]!==m||t[31]!==y||t[32]!==b?(x=(0,Q.jsxs)(m,{children:[y,b]}),t[30]=m,t[31]=y,t[32]=b,t[33]=x):x=t[33];let S=x;if(l){let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ze,{className:`size-4 text-muted-foreground`}),t[34]=e):e=t[34];let n;t[35]!==a||t[36]!==u?(n=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":u,"aria-label":`Select variant`,disabled:a,children:e})}),t[35]=a,t[36]=u,t[37]=n):n=t[37];let r;t[38]===S?r=t[39]:(r=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:S}),t[38]=S,t[39]=r);let i;return t[40]!==u||t[41]!==n||t[42]!==r?(i=(0,Q.jsxs)(K,{open:u,onOpenChange:d,children:[n,r]}),t[40]=u,t[41]=n,t[42]=r,t[43]=i):i=t[43],i}if(c){let e,n;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(Ze,{className:`size-4 flex-shrink-0 text-muted-foreground`}),e=(0,Q.jsx)(ne,{className:`size-3 shrink-0 opacity-50`}),t[44]=e,t[45]=n):(e=t[44],n=t[45]);let r;t[46]!==a||t[47]!==u?(r=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":u,"aria-label":`Select variant`,disabled:a,children:[n,e]})}),t[46]=a,t[47]=u,t[48]=r):r=t[48];let i;t[49]===S?i=t[50]:(i=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:S}),t[49]=S,t[50]=i);let o;return t[51]!==u||t[52]!==r||t[53]!==i?(o=(0,Q.jsxs)(K,{open:u,onOpenChange:d,children:[r,i]}),t[51]=u,t[52]=r,t[53]=i,t[54]=o):o=t[54],o}let C;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(Ze,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[55]=C):C=t[55];let w;t[56]===h?w=t[57]:(w=(0,Q.jsx)(`span`,{className:`truncate`,children:h}),t[56]=h,t[57]=w);let T;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(ne,{className:`size-3 shrink-0 opacity-50`}),t[58]=T):T=t[58];let E;t[59]!==a||t[60]!==u||t[61]!==w?(E=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":u,"aria-label":`Select variant`,disabled:a,children:[C,w,T]})}),t[59]=a,t[60]=u,t[61]=w,t[62]=E):E=t[62];let D;t[63]===S?D=t[64]:(D=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:S}),t[63]=S,t[64]=D);let O;return t[65]!==u||t[66]!==E||t[67]!==D?(O=(0,Q.jsxs)(K,{open:u,onOpenChange:d,children:[E,D]}),t[65]=u,t[66]=E,t[67]=D,t[68]=O):O=t[68],O}function Gt(e){let t=(0,$.c)(66),{preconfigs:n,selectedPreconfigId:r,onChangePreconfig:i,disabled:a,compact:o,iconOnly:s}=e,c=o===void 0?!1:o,l=s===void 0?!1:s,[u,d]=(0,Z.useState)(!1),f;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=e=>e.id===r,t[3]=r,t[4]=e),f=n.find(e),t[0]=n,t[1]=r,t[2]=f}else f=t[2];let m=f,h;t[5]===i?h=t[6]:(h=e=>{i(e),d(!1)},t[5]=i,t[6]=h);let g=h;if(l){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(ye,{className:`size-4 text-muted-foreground`}),t[7]=e):e=t[7];let i;t[8]!==a||t[9]!==u?(i=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":u,"aria-label":`Select config`,disabled:a,children:e})}),t[8]=a,t[9]=u,t[10]=i):i=t[10];let o;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(W,{placeholder:`Search config...`}),t[11]=o):o=t[11];let s;if(t[12]!==g||t[13]!==n||t[14]!==r){let e;t[16]!==g||t[17]!==r?(e=e=>(0,Q.jsxs)(te,{onSelect:()=>g(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)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[16]=g,t[17]=r,t[18]=e):e=t[18],s=n.map(e),t[12]=g,t[13]=n,t[14]=r,t[15]=s}else s=t[15];let c;t[19]===s?c=t[20]:(c=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[o,(0,Q.jsx)(q,{className:`max-h-[50vh] overflow-y-auto`,children:s})]})}),t[19]=s,t[20]=c);let l;return t[21]!==u||t[22]!==i||t[23]!==c?(l=(0,Q.jsxs)(K,{open:u,onOpenChange:d,children:[i,c]}),t[21]=u,t[22]=i,t[23]=c,t[24]=l):l=t[24],l}if(c){let e,i;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(ye,{className:`size-4 flex-shrink-0 text-muted-foreground`}),i=(0,Q.jsx)(ne,{className:`size-3 shrink-0 opacity-50`}),t[25]=e,t[26]=i):(e=t[25],i=t[26]);let o;t[27]!==a||t[28]!==u?(o=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":u,"aria-label":`Select config`,disabled:a,children:[e,i]})}),t[27]=a,t[28]=u,t[29]=o):o=t[29];let s;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(W,{placeholder:`Search config...`}),t[30]=s):s=t[30];let c;if(t[31]!==g||t[32]!==n||t[33]!==r){let e;t[35]!==g||t[36]!==r?(e=e=>(0,Q.jsxs)(te,{onSelect:()=>g(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)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[35]=g,t[36]=r,t[37]=e):e=t[37],c=n.map(e),t[31]=g,t[32]=n,t[33]=r,t[34]=c}else c=t[34];let l;t[38]===c?l=t[39]:(l=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[s,(0,Q.jsx)(q,{className:`max-h-[50vh] overflow-y-auto`,children:c})]})}),t[38]=c,t[39]=l);let f;return t[40]!==u||t[41]!==l||t[42]!==o?(f=(0,Q.jsxs)(K,{open:u,onOpenChange:d,children:[o,l]}),t[40]=u,t[41]=l,t[42]=o,t[43]=f):f=t[43],f}let _;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(ye,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[44]=_):_=t[44];let v=m?.name||`Select config`,y;t[45]===v?y=t[46]:(y=(0,Q.jsx)(`span`,{className:`truncate`,children:v}),t[45]=v,t[46]=y);let b;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(ne,{className:`size-3 shrink-0 opacity-50`}),t[47]=b):b=t[47];let x;t[48]!==a||t[49]!==u||t[50]!==y?(x=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":u,"aria-label":`Select config`,disabled:a,children:[_,y,b]})}),t[48]=a,t[49]=u,t[50]=y,t[51]=x):x=t[51];let S;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(W,{placeholder:`Search config...`}),t[52]=S):S=t[52];let C;if(t[53]!==g||t[54]!==n||t[55]!==r){let e;t[57]!==g||t[58]!==r?(e=e=>(0,Q.jsxs)(te,{onSelect:()=>g(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)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[57]=g,t[58]=r,t[59]=e):e=t[59],C=n.map(e),t[53]=g,t[54]=n,t[55]=r,t[56]=C}else C=t[56];let w;t[60]===C?w=t[61]:(w=(0,Q.jsx)(oe,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[S,(0,Q.jsx)(q,{className:`max-h-[50vh] overflow-y-auto`,children:C})]})}),t[60]=C,t[61]=w);let T;return t[62]!==u||t[63]!==w||t[64]!==x?(T=(0,Q.jsxs)(K,{open:u,onOpenChange:d,children:[x,w]}),t[62]=u,t[63]=w,t[64]=x,t[65]=T):T=t[65],T}function Kt(e){switch(e){case`uncontrolled`:return{icon:f,tooltip:`No active controller`,label:`No client currently controls this session.`,ariaLabel:`Session control: no active controller`,variant:`ghost`,iconClass:`text-muted-foreground/60`};case`controller`:return{icon:f,tooltip:`You control this session`,label:`You are controlling this session.`,ariaLabel:`Session control: you control this session`,variant:`ghost`,iconClass:`text-muted-foreground`};case`observer`:return{icon:de,tooltip:`Controlled on another device`,label:`Another client is controlling this session.`,ariaLabel:`Session control: controlled on another device`,variant:`ghost`,iconClass:`text-muted-foreground`};case`takeover_controller`:return{icon:ot,tooltip:`Another client requested control`,label:`Another client wants to take control of this session.`,ariaLabel:`Session control: takeover requested`,variant:`ghost`,iconClass:`text-orange-500`};case`takeover_requester`:return{icon:ot,tooltip:`Takeover request pending`,label:`Your control request is waiting for approval.`,ariaLabel:`Session control: takeover request pending`,variant:`ghost`,iconClass:`text-orange-500`};case`grace`:return{icon:mt,tooltip:`Waiting for previous controller to reconnect`,label:`The previous controller may still reconnect.`,ariaLabel:`Session control: waiting for reconnect`,variant:`ghost`,iconClass:`text-yellow-500`}}}function qt(e){let t=(0,$.c)(54),{uiState:n,sessionId:r,pendingRequesterClientId:i,onClaimControl:a,onReleaseControl:o,onRequestTakeover:s,onRespondTakeover:c}=e,l;t[0]===n?l=t[1]:(l=Kt(n),t[0]=n,t[1]=l);let u=l,d=u.icon;if(!(n===`uncontrolled`&&a||n===`controller`&&o||n===`observer`&&s||n===`takeover_controller`&&c)){let e=`size-4 ${u.iconClass}`,n;t[2]!==d||t[3]!==e?(n=(0,Q.jsx)(d,{className:e}),t[2]=d,t[3]=e,t[4]=n):n=t[4];let r;t[5]!==u.ariaLabel||t[6]!==n?(r=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":u.ariaLabel,children:n})}),t[5]=u.ariaLabel,t[6]=n,t[7]=r):r=t[7];let i;t[8]===u.tooltip?i=t[9]:(i=(0,Q.jsx)(j,{children:u.tooltip}),t[8]=u.tooltip,t[9]=i);let a;return t[10]!==r||t[11]!==i?(a=(0,Q.jsxs)(T,{children:[r,i]}),t[10]=r,t[11]=i,t[12]=a):a=t[12],a}let p=`size-4 ${u.iconClass}`,m;t[13]!==d||t[14]!==p?(m=(0,Q.jsx)(d,{className:p}),t[13]=d,t[14]=p,t[15]=m):m=t[15];let h;t[16]!==u.ariaLabel||t[17]!==u.variant||t[18]!==m?(h=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(w,{asChild:!0,children:(0,Q.jsx)(X,{variant:u.variant,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":u.ariaLabel,children:m})})}),t[16]=u.ariaLabel,t[17]=u.variant,t[18]=m,t[19]=h):h=t[19];let g;t[20]===u.tooltip?g=t[21]:(g=(0,Q.jsx)(j,{children:u.tooltip}),t[20]=u.tooltip,t[21]=g);let _;t[22]!==h||t[23]!==g?(_=(0,Q.jsxs)(T,{children:[h,g]}),t[22]=h,t[23]=g,t[24]=_):_=t[24];let v;t[25]===u.label?v=t[26]:(v=(0,Q.jsx)(O,{children:u.label}),t[25]=u.label,t[26]=v);let y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(I,{}),t[27]=y):y=t[27];let b;t[28]!==a||t[29]!==r||t[30]!==n?(b=n===`uncontrolled`&&a&&(0,Q.jsxs)(C,{onClick:()=>a(r),children:[(0,Q.jsx)(f,{className:`size-4`}),`Claim control`]}),t[28]=a,t[29]=r,t[30]=n,t[31]=b):b=t[31];let S;t[32]!==o||t[33]!==r||t[34]!==n?(S=n===`controller`&&o&&(0,Q.jsxs)(C,{onClick:()=>o(r),children:[(0,Q.jsx)(f,{className:`size-4`}),`Release control`]}),t[32]=o,t[33]=r,t[34]=n,t[35]=S):S=t[35];let D;t[36]!==s||t[37]!==r||t[38]!==n?(D=n===`observer`&&s&&(0,Q.jsxs)(C,{onClick:()=>s(r),children:[(0,Q.jsx)(ot,{className:`size-4`}),`Request control`]}),t[36]=s,t[37]=r,t[38]=n,t[39]=D):D=t[39];let k;t[40]!==c||t[41]!==i||t[42]!==r||t[43]!==n?(k=n===`takeover_controller`&&c&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(C,{onClick:()=>c(r,i,`approve`),children:[(0,Q.jsx)(f,{className:`size-4 text-green-600`}),`Approve`]}),(0,Q.jsxs)(C,{variant:`destructive`,onClick:()=>c(r,i,`deny`),children:[(0,Q.jsx)(f,{className:`size-4`}),`Deny`]})]}),t[40]=c,t[41]=i,t[42]=r,t[43]=n,t[44]=k):k=t[44];let A;t[45]!==S||t[46]!==D||t[47]!==k||t[48]!==v||t[49]!==b?(A=(0,Q.jsxs)(P,{align:`end`,sideOffset:4,className:`w-56`,children:[v,y,b,S,D,k]}),t[45]=S,t[46]=D,t[47]=k,t[48]=v,t[49]=b,t[50]=A):A=t[50];let M;return t[51]!==A||t[52]!==_?(M=(0,Q.jsxs)(x,{children:[_,A]}),t[51]=A,t[52]=_,t[53]=M):M=t[53],M}function Jt(e,t){return!e||e===`uncontrolled`?`uncontrolled`:e===`grace`?`grace`:e===`takeover_requested`?t?`takeover_controller`:`takeover_requester`:e===`controlled`?t?`controller`:`observer`:`uncontrolled`}function Yt(e){let t=(0,$.c)(110),{session:n,preconfigs:r,models:i,usage:a,modelName:o,onChangePreconfig:s,onChangeModel:c,onChangeVariant:l,onRename:u,onNavigateBack:d,isStreaming:f,onInterrupt:p,onCompact:m,isCompacting:h,canCompact:g,selectedVariant:_,variants:v,onClaimControl:y,onReleaseControl:x,onRequestTakeover:C,onRespondTakeover:w}=e,[D,O]=(0,Z.useState)(!1),[A,M]=(0,Z.useState)(n.title||``),N=(0,Z.useRef)(null),P=S(),I=z(),L;t[0]===n.id?L=t[1]:(L=e=>e.controlBySessionId[n.id],t[0]=n.id,t[1]=L);let R=we(L),B=fe(Xt),U=R?.status===`controlled`||R?.status===`takeover_requested`,W=U&&R.controllerClientId===B,ee=U&&R.controllerClientId!==B,G=R?.status,te;t[2]!==W||t[3]!==G?(te=Jt(G,W),t[2]=W,t[3]=G,t[4]=te):te=t[4];let ne=te,re,ie;t[5]===D?(re=t[6],ie=t[7]):(re=()=>{D&&N.current&&(N.current.focus(),N.current.select())},ie=[D],t[5]=D,t[6]=re,t[7]=ie),(0,Z.useEffect)(re,ie);let ae;t[8]===n.title?ae=t[9]:(ae=()=>{M(n.title||``),O(!0)},t[8]=n.title,t[9]=ae);let oe=ae,se;t[10]!==A||t[11]!==u||t[12]!==n.id||t[13]!==n.title?(se=()=>{let e=A.trim();e&&e!==n.title&&u(n.id,e),O(!1)},t[10]=A,t[11]=u,t[12]=n.id,t[13]=n.title,t[14]=se):se=t[14];let K=se,q;t[15]!==K||t[16]!==n.title?(q=e=>{e.key===`Enter`?K():e.key===`Escape`&&(M(n.title||``),O(!1))},t[15]=K,t[16]=n.title,t[17]=q):q=t[17];let ce=q,le;t[18]!==o||t[19]!==r||t[20]!==n.preconfigId||t[21]!==n.selectedModel?(le=n.selectedModel||r.find(e=>e.id===n.preconfigId)?.model||o,t[18]=o,t[19]=r,t[20]=n.preconfigId,t[21]=n.selectedModel,t[22]=le):le=t[22];let ue=le,J;t[23]!==i||t[24]!==ue||t[25]!==n.selectedProvider?(J=n.selectedProvider?i.find(e=>e.providerId===n.selectedProvider&&e.id===ue):i.find(e=>e.id===ue),t[23]=i,t[24]=ue,t[25]=n.selectedProvider,t[26]=J):J=t[26];let de=J?.contextWindow,pe;t[27]!==d||t[28]!==n.parentId?(pe=n.parentId&&d&&(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:d,className:`h-7`,children:[(0,Q.jsx)(H,{className:`size-4`,"data-icon":`inline-start`}),`Back`]}),t[27]=d,t[28]=n.parentId,t[29]=pe):pe=t[29];let me;t[30]!==A||t[31]!==ce||t[32]!==oe||t[33]!==K||t[34]!==D||t[35]!==n.title?(me=D?(0,Q.jsx)(`input`,{ref:N,type:`text`,value:A,onChange:e=>M(e.target.value),onBlur:K,onKeyDown:ce,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:oe,children:n.title||`Untitled Session`}),t[30]=A,t[31]=ce,t[32]=oe,t[33]=K,t[34]=D,t[35]=n.title,t[36]=me):me=t[36];let he;t[37]!==de||t[38]!==P||t[39]!==o||t[40]!==a.completionTokens||t[41]!==a.promptTokens||t[42]!==a.totalTokens?(he=(0,Q.jsx)(It,{promptTokens:a.promptTokens,completionTokens:a.completionTokens,totalTokens:a.totalTokens,contextWindow:de,modelName:o,compact:P}),t[37]=de,t[38]=P,t[39]=o,t[40]=a.completionTokens,t[41]=a.promptTokens,t[42]=a.totalTokens,t[43]=he):he=t[43];let ge;t[44]===n.status?ge=t[45]:(ge=n.status===`closed`&&(0,Q.jsxs)(F,{variant:`secondary`,children:[(0,Q.jsx)(V,{className:`size-3`,"data-icon":`inline-start`}),`Archived`]}),t[44]=n.status,t[45]=ge);let _e;t[46]!==pe||t[47]!==me||t[48]!==he||t[49]!==ge?(_e=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[pe,me,he,ge]}),t[46]=pe,t[47]=me,t[48]=he,t[49]=ge,t[50]=_e):_e=t[50];let ve;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(b,{className:`md:hidden`}),t[51]=ve):ve=t[51];let ye=n.status===`closed`||!!n.parentId||ee,be;t[52]!==I||t[53]!==P||t[54]!==i||t[55]!==c||t[56]!==ue||t[57]!==n.selectedProvider||t[58]!==ye?(be=(0,Q.jsx)(zt,{models:i,selectedModelId:ue,selectedProviderId:n.selectedProvider,onChangeModel:c,disabled:ye,iconOnly:P,compact:I}),t[52]=I,t[53]=P,t[54]=i,t[55]=c,t[56]=ue,t[57]=n.selectedProvider,t[58]=ye,t[59]=be):be=t[59];let xe=n.status===`closed`||!!n.parentId||ee,Se;t[60]!==I||t[61]!==P||t[62]!==l||t[63]!==_||t[64]!==xe||t[65]!==v?(Se=(0,Q.jsx)(Wt,{variants:v,selectedVariant:_,onChangeVariant:l,disabled:xe,iconOnly:P,compact:I}),t[60]=I,t[61]=P,t[62]=l,t[63]=_,t[64]=xe,t[65]=v,t[66]=Se):Se=t[66];let Ce=n.status===`closed`||!!n.parentId||ee,Te;t[67]!==I||t[68]!==P||t[69]!==s||t[70]!==r||t[71]!==n.preconfigId||t[72]!==Ce?(Te=(0,Q.jsx)(Gt,{preconfigs:r,selectedPreconfigId:n.preconfigId,onChangePreconfig:s,disabled:Ce,iconOnly:P,compact:I}),t[67]=I,t[68]=P,t[69]=s,t[70]=r,t[71]=n.preconfigId,t[72]=Ce,t[73]=Te):Te=t[73];let Ee;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,Q.jsx)(b,{orientation:`vertical`,className:`hidden md:block`}),t[74]=Ee):Ee=t[74];let De;t[75]!==R?.pendingTakeover?.requestedByClientId||t[76]!==ne||t[77]!==B||t[78]!==y||t[79]!==x||t[80]!==C||t[81]!==w||t[82]!==n.id?(De=B&&(0,Q.jsx)(qt,{uiState:ne,sessionId:n.id,pendingRequesterClientId:R?.pendingTakeover?.requestedByClientId,onClaimControl:y,onReleaseControl:x,onRequestTakeover:C,onRespondTakeover:w}),t[75]=R?.pendingTakeover?.requestedByClientId,t[76]=ne,t[77]=B,t[78]=y,t[79]=x,t[80]=C,t[81]=w,t[82]=n.id,t[83]=De):De=t[83];let Oe;t[84]!==g||t[85]!==h||t[86]!==f||t[87]!==m?(Oe=m&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(T,{children:[(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:bg-accent`,onClick:m,disabled:f||h||!g,children:(0,Q.jsx)(lt,{className:`size-4`})})}),(0,Q.jsx)(j,{children:h?`Compacting...`:`Compact older messages`})]}),(0,Q.jsx)(b,{orientation:`vertical`,className:`hidden md:block`})]}),t[84]=g,t[85]=h,t[86]=f,t[87]=m,t[88]=Oe):Oe=t[88];let ke=f?`destructive`:`ghost`,Ae=`h-8 w-8 p-0 hover:bg-accent${f?``:` text-muted-foreground opacity-60 hover:opacity-100`}`,je=!p||ee,Ne;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,Q.jsx)(Me,{className:`size-4`}),t[89]=Ne):Ne=t[89];let Pe;t[90]!==p||t[91]!==ke||t[92]!==Ae||t[93]!==je?(Pe=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(X,{variant:ke,size:`sm`,className:Ae,onClick:p,disabled:je,children:Ne})}),t[90]=p,t[91]=ke,t[92]=Ae,t[93]=je,t[94]=Pe):Pe=t[94];let Fe=f?`Interrupt operation`:`Interrupt`,Ie;t[95]===Fe?Ie=t[96]:(Ie=(0,Q.jsx)(j,{children:Fe}),t[95]=Fe,t[96]=Ie);let Le;t[97]!==Pe||t[98]!==Ie?(Le=(0,Q.jsxs)(T,{children:[Pe,Ie]}),t[97]=Pe,t[98]=Ie,t[99]=Le):Le=t[99];let Re;t[100]!==be||t[101]!==Se||t[102]!==Te||t[103]!==De||t[104]!==Oe||t[105]!==Le?(Re=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:gap-4 flex-wrap md:flex-nowrap shrink-0`,children:[be,Se,Te,Ee,De,Oe,Le]}),t[100]=be,t[101]=Se,t[102]=Te,t[103]=De,t[104]=Oe,t[105]=Le,t[106]=Re):Re=t[106];let ze;return t[107]!==_e||t[108]!==Re?(ze=(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:[_e,ve,Re]})})}),t[107]=_e,t[108]=Re,t[109]=ze):ze=t[109],ze}function Xt(e){return e.clientId}function Zt(e){let t=(0,$.c)(25),{prompts:n,query:r,selectedIndex:i,onSelect:a}=e,o,s,c,l;if(t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e;if(t[8]===r?e=t[9]:(e=e=>e.name.toLowerCase().includes(r.toLowerCase()),t[8]=r,t[9]=e),o=n.filter(e),o.length===0){let e;t[10]===r?e=t[11]:(e=(0,Q.jsxs)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:[`No prompts matching "/`,r,`"`]}),t[10]=r,t[11]=e),l=e;break bb0}s=`p-1`;let u;t[12]!==a||t[13]!==i?(u=(e,t)=>(0,Q.jsxs)(`button`,{onClick:()=>a(e),className:Y(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===i&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,Q.jsx)(ct,{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),t[12]=a,t[13]=i,t[14]=u):u=t[14],c=o.map(u)}t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u=o.length===1?``:`s`,d;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↑↓`}),t[15]=d):d=t[15];let f;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↵`}),t[16]=f):f=t[16];let p;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`esc`}),t[17]=p):p=t[17];let m;t[18]!==o.length||t[19]!==u?(m=(0,Q.jsxs)(`div`,{className:`mt-1 pt-1 border-t text-xs text-muted-foreground px-2`,children:[o.length,` prompt`,u,` •`,d,` navigate`,f,` select`,p,` close`]}),t[18]=o.length,t[19]=u,t[20]=m):m=t[20];let h;return t[21]!==s||t[22]!==c||t[23]!==m?(h=(0,Q.jsxs)(`div`,{className:s,children:[c,m]}),t[21]=s,t[22]=c,t[23]=m,t[24]=h):h=t[24],h}function Qt(e){let t=(0,$.c)(26),{id:n,kind:r,filename:i,size:a,previewUrl:o,isUploading:s,onRemove:c}=e,l=s&&`opacity-50`,u;t[0]===l?u=t[1]:(u=Y(`flex items-center gap-2 px-2 py-1.5 bg-muted rounded-lg border border-border max-w-[180px]`,l),t[0]=l,t[1]=u);let d;t[2]!==i||t[3]!==r||t[4]!==o?(d=r===`image`&&o?(0,Q.jsx)(`img`,{src:o,alt:i,className:`size-8 rounded object-cover shrink-0`}):r===`image`?(0,Q.jsx)(st,{className:`size-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(De,{className:`size-4 text-muted-foreground shrink-0`}),t[2]=i,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f;t[6]===i?f=t[7]:(f=(0,Q.jsx)(`div`,{className:`text-xs truncate`,children:i}),t[6]=i,t[7]=f);let p;t[8]===a?p=t[9]:(p=$t(a),t[8]=a,t[9]=p);let m;t[10]===p?m=t[11]:(m=(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:p}),t[10]=p,t[11]=m);let h;t[12]!==f||t[13]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==n||t[16]!==c?(g=()=>c(n),t[15]=n,t[16]=c,t[17]=g):g=t[17];let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(Le,{className:`size-3 text-muted-foreground`}),t[18]=_):_=t[18];let v;t[19]===g?v=t[20]:(v=(0,Q.jsx)(`button`,{type:`button`,onClick:g,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:_}),t[19]=g,t[20]=v);let y;return t[21]!==v||t[22]!==u||t[23]!==d||t[24]!==h?(y=(0,Q.jsxs)(`div`,{className:u,children:[d,h,v]}),t[21]=v,t[22]=u,t[23]=d,t[24]=h,t[25]=y):y=t[25],y}function $t(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function en(e){let t=(0,$.c)(28),{path:n,onRemove:r,onPreview:i}=e,a;t[0]===n?a=t[1]:(a=n.split(`/`).pop()||n,t[0]=n,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=n.slice(0,n.lastIndexOf(`/`)+1),t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(De,{className:`size-4 text-primary shrink-0`}),t[4]=l):l=t[4];let u;t[5]!==i||t[6]!==n?(u=()=>i?.(n),t[5]=i,t[6]=n,t[7]=u):u=t[7];let d;t[8]===c?d=t[9]:(d=(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:c}),t[8]=c,t[9]=d);let f;t[10]===o?f=t[11]:(f=(0,Q.jsx)(`span`,{children:o}),t[10]=o,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`text-xs truncate`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==u||t[16]!==p?(m=(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`min-w-0 flex-1 text-left cursor-pointer`,children:p}),t[15]=u,t[16]=p,t[17]=m):m=t[17];let h;t[18]!==r||t[19]!==n?(h=()=>r(n),t[18]=r,t[19]=n,t[20]=h):h=t[20];let g=`Remove ${o}`,_;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(Le,{className:`size-3 text-muted-foreground`}),t[21]=_):_=t[21];let v;t[22]!==g||t[23]!==h?(v=(0,Q.jsx)(`button`,{type:`button`,onClick:h,"aria-label":g,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:_}),t[22]=g,t[23]=h,t[24]=v):v=t[24];let y;return t[25]!==v||t[26]!==m?(y=(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:[l,m,v]}),t[25]=v,t[26]=m,t[27]=y):y=t[27],y}var tn={off:{icon:dt,iconClass:`text-muted-foreground/60`,tooltip:`Auto-approve: Off`,label:`Always ask for approval.`,ariaLabel:`Auto-approve: off`},none:{icon:f,iconClass:`text-muted-foreground`,tooltip:`Auto-approve: None`,label:`Auto-approve permissions with none risk.`,ariaLabel:`Auto-approve: none risk`},low:{icon:me,iconClass:`text-success`,tooltip:`Auto-approve: Low`,label:`Auto-approve permissions with low risk and below.`,ariaLabel:`Auto-approve: low risk and below`},medium:{icon:me,iconClass:`text-warning`,tooltip:`Auto-approve: Medium`,label:`Auto-approve permissions with medium risk and below.`,ariaLabel:`Auto-approve: medium risk and below`},high:{icon:Se,iconClass:`text-destructive`,tooltip:`Auto-approve: High`,label:`Auto-approve permissions with high risk and below.`,ariaLabel:`Auto-approve: high risk and below`}},nn=[`off`,`none`,`low`,`medium`,`high`];function rn(e){switch(e){case`off`:return``;case`none`:return`text-muted-foreground`;case`low`:return`text-success`;case`medium`:return`text-warning`;case`high`:return`text-destructive`}}function an(e){let t=(0,$.c)(35),{sessionId:n,disabled:r}=e,i=g(sn),a=g(on),o=i[n]??`low`,s=tn[o],c=s.icon;if(r){let e=`size-4 ${s.iconClass}`,n;t[0]!==c||t[1]!==e?(n=(0,Q.jsx)(c,{className:e}),t[0]=c,t[1]=e,t[2]=n):n=t[2];let r;t[3]!==s.ariaLabel||t[4]!==n?(r=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,disabled:!0,"aria-label":s.ariaLabel,children:n})}),t[3]=s.ariaLabel,t[4]=n,t[5]=r):r=t[5];let i;t[6]===s.tooltip?i=t[7]:(i=(0,Q.jsx)(j,{children:s.tooltip}),t[6]=s.tooltip,t[7]=i);let a;return t[8]!==r||t[9]!==i?(a=(0,Q.jsx)(k,{delayDuration:300,children:(0,Q.jsxs)(T,{children:[r,i]})}),t[8]=r,t[9]=i,t[10]=a):a=t[10],a}let l=`size-4 ${s.iconClass}`,u;t[11]!==c||t[12]!==l?(u=(0,Q.jsx)(c,{className:l}),t[11]=c,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==s.ariaLabel||t[15]!==u?(d=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(w,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":s.ariaLabel,children:u})})}),t[14]=s.ariaLabel,t[15]=u,t[16]=d):d=t[16];let f;t[17]===s.tooltip?f=t[18]:(f=(0,Q.jsx)(j,{children:s.tooltip}),t[17]=s.tooltip,t[18]=f);let p;t[19]!==d||t[20]!==f?(p=(0,Q.jsx)(k,{delayDuration:300,children:(0,Q.jsxs)(T,{children:[d,f]})}),t[19]=d,t[20]=f,t[21]=p):p=t[21];let m;t[22]===s.label?m=t[23]:(m=(0,Q.jsx)(O,{children:s.label}),t[22]=s.label,t[23]=m);let h;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(I,{}),t[24]=h):h=t[24];let _;t[25]!==o||t[26]!==n||t[27]!==a?(_=nn.map(e=>{let t=tn[e],r=t.icon;return(0,Q.jsxs)(C,{onClick:()=>a(n,e),className:e===o?`bg-accent`:``,children:[(0,Q.jsx)(r,{className:`size-4 ${rn(e)}`}),(0,Q.jsx)(`span`,{className:`ml-2`,children:t.label})]},e)}),t[25]=o,t[26]=n,t[27]=a,t[28]=_):_=t[28];let v;t[29]!==m||t[30]!==_?(v=(0,Q.jsxs)(P,{align:`end`,sideOffset:4,className:`w-56`,children:[m,h,_]}),t[29]=m,t[30]=_,t[31]=v):v=t[31];let y;return t[32]!==p||t[33]!==v?(y=(0,Q.jsxs)(x,{children:[p,v]}),t[32]=p,t[33]=v,t[34]=y):y=t[34],y}function on(e){return e.setAutoApproveMaxSeverity}function sn(e){return e.autoApproveBySession}function cn(e){let t=(0,$.c)(3),{debounceMs:n}=e,[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),s=un,c=ln,l;return t[0]!==r||t[1]!==a?(l={query:r,setQuery:i,showAutocomplete:a,setShowAutocomplete:o,handleFileSelect:s,insertMention:c},t[0]=r,t[1]=a,t[2]=l):l=t[2],l}function ln(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}}function un(e){return{type:`file`,path:e.path,display:e.name}}function dn(e){let t=/@([^\s@]+)/g,n=new Set,r=[],i;for(;(i=t.exec(e))!==null;){let e=i[1];n.has(e)||(n.add(e),r.push({type:`file`,path:e,display:e.split(`/`).pop()||e}))}return r}function fn(e){return`${y}${e}`}function pn(e,t){if(!(typeof window>`u`))try{localStorage.setItem(fn(e),JSON.stringify({text:t,updatedAt:Date.now()}))}catch(e){console.warn(`Error saving draft:`,e)}}function mn(e){if(typeof window>`u`)return``;try{let t=localStorage.getItem(fn(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(fn(e)),``):n.text}catch{return``}}function hn(e){if(!(typeof window>`u`))try{localStorage.removeItem(fn(e))}catch(e){console.warn(`Error clearing draft:`,e)}}function gn(){o()}function _n(e){let t=(0,$.c)(12),[n,r]=(0,Z.useState)(``),i=(0,Z.useRef)(void 0),a=(0,Z.useRef)(``),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0],(0,Z.useEffect)(vn,o);let s;t[1]===e?s=t[2]:(s=t=>{r(t),a.current=t,e!==void 0&&(t===``?hn(e):pn(e,t))},t[1]=e,t[2]=s);let c=s,l;t[3]===e?l=t[4]:(l=()=>{r(``),a.current=``,e!==void 0&&hn(e)},t[3]=e,t[4]=l);let u=l,d,f;t[5]===e?(d=t[6],f=t[7]):(d=()=>{let t=i.current;if(t!==void 0&&t!==e){let e=a.current;e!==``&&pn(t,e)}if(e!==void 0){let t=mn(e);a.current=t,r(t)}else a.current=``,r(``);i.current=e},f=[e],t[5]=e,t[6]=d,t[7]=f),(0,Z.useEffect)(d,f);let p;return t[8]!==u||t[9]!==n||t[10]!==c?(p={input:n,setInput:c,clearInput:u},t[8]=u,t[9]=n,t[10]=c,t[11]=p):p=t[11],p}function vn(){gn()}function yn(e,t){return t?e.content.includes(`ARG`)?e.content.replace(`ARG`,t):`${e.content}\n${t}`:e.content}function bn(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 xn=(0,Z.forwardRef)(function({onSendMessage:e,disabled:t,isStreaming:n,onStopStreaming:r,placeholder:i=`Type a message...`,workspaceId:a,sdkClient:o,prompts:s=[],sessionId:c,modelSupportsImage:l},u){let{input:d,setInput:f,clearInput:p}=_n(c),[m,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)([]),[b,x]=(0,Z.useState)(0),[S,C]=(0,Z.useState)(`none`),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(``),[O,A]=(0,Z.useState)([]),[j,M]=(0,Z.useState)(!1),N=(0,Z.useRef)(null),P=(0,Z.useRef)(null);(0,Z.useImperativeHandle)(u,()=>({focus:()=>N.current?.focus()}),[]);let{query:F,setQuery:I,showAutocomplete:L,setShowAutocomplete:R,handleFileSelect:z,insertMention:B}=cn({workspaceId:a||``}),V=(0,Z.useMemo)(()=>dn(d),[d]),H=g(e=>e.openFilePreview),U=h(e=>e.activeWorkspace);(0,Z.useEffect)(()=>{x(0),T(null)},[v,E,s]),(0,Z.useEffect)(()=>{let e=N.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[d]);let W=s.filter(e=>e.name.toLowerCase().includes(E.toLowerCase())),G=S===`prompts`&&s.length>0,te=S===`files`&&L&&!!a,ne=(0,Z.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart||0;f(t),_(n);let r=t.lastIndexOf(`/`,n);if(r!==-1){let e=r>0?t[r-1]:`
2
+ `,i=t.slice(r+1,n);if((e===`
3
+ `||e===` `||e===``)&&!i.includes(` `)){D(i),C(`prompts`);return}}let i=t.lastIndexOf(`@`,n);if(i!==-1){let e=t.slice(i+1,n);if(!e.includes(` `)){I(e),R(!0),C(`files`);return}}C(`none`),R(!1)},[I,R,f]),ie=(0,Z.useCallback)(e=>{let t=B(d,m,z(e));f(t.text),C(`none`),R(!1),y([]),setTimeout(()=>{N.current&&(N.current.focus(),N.current.setSelectionRange(t.cursorPos,t.cursorPos))},0)},[d,m,z,B,R,f]),ae=(0,Z.useCallback)(e=>{let t=d.lastIndexOf(`/`,m),n=d.slice(0,t),r=d.slice(t+1),i=r.indexOf(` `),a=i===-1?``:r.slice(i),o=`${n}/${e.name}${a}`,s=t+1+e.name.length+0;f(o),C(`none`),setTimeout(()=>{N.current&&(N.current.focus(),N.current.setSelectionRange(s,s))},0)},[d,m,f]),se=(0,Z.useCallback)(()=>{for(let e of O)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);A([]),p()},[O,p]),q=(0,Z.useCallback)(async e=>{if(!o||!c)return null;try{let t=await o?.http.attachments.upload(c,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}},[o,c]),ce=(0,Z.useCallback)(e=>{A(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),le=(0,Z.useCallback)(e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}`,`g`);f(d.replace(n,``).replace(/\s+/g,` `).trim())},[d,f]),ue=(0,Z.useCallback)(e=>{U?.id&&H({workspaceId:U.id,path:e,name:e.split(`/`).pop()||e})},[U?.id,H]),J=(0,Z.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};A(e=>[...e,n]);let r=await q(e);A(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))}},[q]),de=(0,Z.useCallback)(e=>{let t=e.clipboardData?.files;t&&t.length>0&&(e.preventDefault(),J(t))},[J]),fe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),M(!0)},[]),pe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),M(!1)},[]),me=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),M(!1);let t=e.dataTransfer?.files;t&&t.length>0&&J(t)},[J]),he=async n=>{n?.preventDefault();let r=d.trim();if(!r&&O.length===0||t)return;let i=bn(d);if(i){let t=s.find(e=>e.name===i.command);if(t){let n=yn(t,i.rest),r=O.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(n,r.length>0?r:void 0),se();return}}let a=O.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(r||``,a.length>0?a:void 0),se()},ge=e=>{if(!e.nativeEvent.isComposing){if(G&&W.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>Math.min(e+1,W.length-1));return;case`ArrowUp`:e.preventDefault(),x(e=>Math.max(e-1,0));return;case`Enter`:if(e.shiftKey)return;e.preventDefault(),W[b]&&ae(W[b]);return;case`Tab`:e.preventDefault(),W[b]&&ae(W[b]);return;case`Escape`:e.preventDefault(),C(`none`);return}if(te&&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]&&ie(v[b]);return;case`ArrowRight`:e.preventDefault(),T(b);return;case`ArrowLeft`:e.preventDefault(),T(null);return;case`Escape`:e.preventDefault(),R(!1),C(`none`),T(null);return;case`Tab`:e.preventDefault(),v[b]&&ie(v[b]),T(null);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),he())}},_e=(0,Z.useCallback)(e=>{y(e)},[]);if(n&&r)return(0,Q.jsx)(`div`,{className:`p-4 border-t border-border bg-background`,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)(X,{variant:`outline`,size:`sm`,onClick:r,children:[(0,Q.jsx)(Me,{className:`size-4`,"data-icon":`inline-start`}),`Stop`]})]})});let ve=d.trim(),ye=O.some(e=>e.isUploading),be=ve||O.length>0,Se=!be||t||ye;return(0,Q.jsx)(`form`,{onSubmit:he,onDragOver:fe,onDragLeave:pe,onDrop:me,className:Y(`px-4 pt-2 pb-3 bg-background`,j&&`ring-2 ring-primary`),children:(0,Q.jsxs)(`div`,{className:Y(`rounded-xl bg-input/30 overflow-hidden`,`focus-within:ring-1 focus-within:ring-ring/40`,`transition-shadow`,`border border-border`,j&&`ring-2 ring-primary border-primary`),children:[(O.length>0||!n)&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap px-3 pt-3`,children:O.map(e=>(0,Q.jsx)(Qt,{id:e.id,kind:e.kind,filename:e.filename,size:e.size,previewUrl:e.previewUrl,isUploading:e.isUploading,onRemove:ce},e.id))}),O.length>0&&l===!1&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 pt-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,Q.jsx)(Pe,{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.`})]}),V.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap px-3 pt-2`,children:V.map(e=>(0,Q.jsx)(en,{path:e.path,onRemove:le,onPreview:ue},e.path))}),(0,Q.jsx)(`div`,{className:`relative`,children:(0,Q.jsxs)(K,{open:G||te,onOpenChange:e=>{e||(C(`none`),R(!1),T(null))},children:[(0,Q.jsx)(re,{asChild:!0,children:(0,Q.jsx)(ee,{ref:N,value:d,onChange:ne,onKeyDown:ge,onPaste:de,placeholder:i,disabled:t,className:Y(`min-h-[52px] max-h-[200px] resize-none border-0 bg-transparent dark:bg-transparent shadow-none`,`px-3 pt-3 pb-0 chat-input-scrollbar`,`focus-visible:ring-0 focus-visible:shadow-none`,`placeholder:text-muted-foreground/60`,`disabled:bg-transparent disabled:opacity-100 dark:disabled:bg-transparent`),rows:1,"data-chat-input":`true`})}),(0,Q.jsx)(oe,{className:Y(`p-0`,te?`w-96`:`w-72`),align:`start`,side:`top`,sideOffset:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:te?(0,Q.jsx)(k,{children:(0,Q.jsx)(xe,{workspaceId:a||``,searchQuery:F,selectedIndex:b,tooltipIndex:w,onTooltipIndexChange:T,onSelect:ie,onFilesChange:_e,sdkClient:o})}):(0,Q.jsx)(Zt,{prompts:s,query:E,selectedIndex:b,onSelect:ae})})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-2 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-8 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50 disabled:pointer-events-none`,onClick:()=>P.current?.click(),disabled:t,"aria-label":`Attach file`,children:(0,Q.jsx)(ut,{className:`size-4`})}),(0,Q.jsx)(`input`,{ref:P,type:`file`,accept:`image/*,video/*,.pdf,.doc,.docx,.txt,.csv,.json,.xml,.md`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&J(e.target.files),e.target.value=``}}),c&&(0,Q.jsx)(an,{sessionId:c,disabled:t})]}),(0,Q.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1 text-xs text-muted-foreground`,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-1`,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-1`,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-1`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`⇧ Enter`}),(0,Q.jsx)(`span`,{children:`new line`})]}),(0,Q.jsx)(X,{type:`submit`,disabled:Se,size:`icon`,className:Y(`size-8 rounded-full`,be&&!t?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground`),"aria-label":`Send message`,children:(0,Q.jsx)(Ye,{className:`size-4`})})]})]})})});function Sn(e){return e.startsWith(`https://`)?`https`:`http`}function Cn(e,t){return`${Sn(e)}://${e.replace(/^https?:\/\//,``)}${t}`}function wn(e){let t=(0,$.c)(3),n=(0,Z.useRef)(e),r;t[0]===e?r=t[1]:(r=()=>{n.current=e},t[0]=e,t[1]=r),(0,Z.useLayoutEffect)(r);let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(...e)=>{let t=e;return n.current(...t)},t[2]=i):i=t[2],i}var Tn=t(i(),1);function En(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*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`,`
4
+ font-size: .6rem;
5
+ font-weight: bold;
6
+ color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function Dn(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var On=(e,t)=>Math.abs(e-t)<1.01,kn=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},An=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},jn=e=>e,Mn=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},Nn=(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(An(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(An(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Pn={passive:!0},Fn=typeof window>`u`?!0:`onscrollend`in window,In=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&Fn?()=>void 0:kn(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,Pn);let l=e.options.useScrollendEvent&&Fn;return l&&n.addEventListener(`scrollend`,c,Pn),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},Ln=(e,t,n)=>{if(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`]},Rn=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},zn=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;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},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=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.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:jn,rangeExtractor:Mn,onChange:()=>{},measureElement:Ln,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=En(()=>(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=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,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=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),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=En(()=>[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=En(()=>[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=En(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Vn({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=En(()=>{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=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&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)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=En(()=>[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 Dn(t[Bn(0,t.length-1,e=>Dn(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=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-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??=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&&On(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()}},Bn=(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 Vn({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=Bn(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 Hn=typeof document<`u`?Z.useLayoutEffect:Z.useEffect;function Un({useFlushSync:e=!0,...t}){let n=Z.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Tn.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=Z.useState(()=>new zn(r));return i.setOptions(r),Hn(()=>i._didMount(),[]),Hn(()=>i._willUpdate()),i}function Wn(e){return Un({observeElementRect:Nn,observeElementOffset:In,scrollToFn:Rn,...e})}function Gn(e){let t=(0,$.c)(49),{message:n,textContent:r,children:i,isQueued:a,onRemove:o,onRevert:s,canRevert:c,onFork:l,canFork:u,isClearAll:d}=e,f=a===void 0?!1:a,m=c===void 0?!1:c,h=u===void 0?!1:u,g=d===void 0?!1:d,[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C=n.role===`user`,w;t[0]===r?w=t[1]:(w=async()=>{let e=r||``;await navigator.clipboard.writeText(e),v(!0),setTimeout(()=>v(!1),2e3)},t[0]=r,t[1]=w);let T=w,E=C?`items-end`:`items-stretch`,D;t[2]===E?D=t[3]:(D=Y(`flex flex-col gap-1 animate-slide-up min-w-0`,E),t[2]=E,t[3]=D);let O=C?`mr-3`:`ml-3`,k;t[4]===O?k=t[5]:(k=Y(`flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground`,O),t[4]=O,t[5]=k);let A;t[6]!==h||t[7]!==m||t[8]!==_||t[9]!==T||t[10]!==f||t[11]!==C||t[12]!==n.role||t[13]!==l||t[14]!==s?(A=C?(0,Q.jsxs)(Q.Fragment,{children:[!f&&(0,Q.jsxs)(Q.Fragment,{children:[m&&s&&(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:()=>b(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Revert to this point`,children:(0,Q.jsx)(ft,{className:`size-3`})}),h&&l&&(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:()=>S(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Fork from this point`,children:(0,Q.jsx)(at,{className:`size-3`})}),(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:T,className:`size-5 text-muted-foreground hover:text-foreground`,children:_?(0,Q.jsx)(p,{className:`size-3`}):(0,Q.jsx)(ce,{className:`size-3`})})]}),(0,Q.jsx)(pe,{className:`size-3`}),n.role]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xe,{className:`size-3`}),n.role,(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:T,className:`size-5 text-muted-foreground hover:text-foreground`,children:_?(0,Q.jsx)(p,{className:`size-3`}):(0,Q.jsx)(ce,{className:`size-3`})})]}),t[6]=h,t[7]=m,t[8]=_,t[9]=T,t[10]=f,t[11]=C,t[12]=n.role,t[13]=l,t[14]=s,t[15]=A):A=t[15];let j;t[16]!==A||t[17]!==k?(j=(0,Q.jsx)(`div`,{className:k,children:A}),t[16]=A,t[17]=k,t[18]=j):j=t[18];let M=C?f?`rounded-2xl px-4 py-3 max-w-[90%] bg-muted text-foreground border-2 border-dashed border-muted-foreground/30 opacity-80 rounded-br-md`:`rounded-2xl px-4 py-3 max-w-[90%] bg-primary text-primary-foreground rounded-br-md`:`w-full overflow-visible`,N;t[19]===M?N=t[20]:(N=Y(`relative group min-w-0 overflow-hidden`,M),t[19]=M,t[20]=N);let P;t[21]!==f||t[22]!==o?(P=f&&(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)(nt,{className:`size-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Pending`})]}),o&&(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:o,className:`size-6 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove from queue`,children:(0,Q.jsx)(Le,{className:`size-3`})})]}),t[21]=f,t[22]=o,t[23]=P):P=t[23];let F;t[24]===i?F=t[25]:(F=(0,Q.jsx)(`div`,{className:`min-w-0`,children:i}),t[24]=i,t[25]=F);let I;t[26]!==N||t[27]!==P||t[28]!==F?(I=(0,Q.jsxs)(`div`,{className:N,children:[P,F]}),t[26]=N,t[27]=P,t[28]=F,t[29]=I):I=t[29];let L=g?`Clear Conversation`:`Revert Conversation`,R=g?`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?`,z=g?`Clear All`:`Revert`,B;t[30]===s?B=t[31]:(B=()=>{s?.()},t[30]=s,t[31]=B);let V;t[32]!==y||t[33]!==L||t[34]!==R||t[35]!==z||t[36]!==B?(V=(0,Q.jsx)(Ke,{open:y,onOpenChange:b,title:L,description:R,confirmLabel:z,cancelLabel:`Cancel`,onConfirm:B,variant:`destructive`}),t[32]=y,t[33]=L,t[34]=R,t[35]=z,t[36]=B,t[37]=V):V=t[37];let H;t[38]===l?H=t[39]:(H=()=>{l?.()},t[38]=l,t[39]=H);let U;t[40]!==x||t[41]!==H?(U=(0,Q.jsx)(Ke,{open:x,onOpenChange:S,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:H}),t[40]=x,t[41]=H,t[42]=U):U=t[42];let W;return t[43]!==j||t[44]!==I||t[45]!==V||t[46]!==U||t[47]!==D?(W=(0,Q.jsxs)(`div`,{className:D,children:[j,I,V,U]}),t[43]=j,t[44]=I,t[45]=V,t[46]=U,t[47]=D,t[48]=W):W=t[48],W}var Kn={rate_limit:{label:`Rate Limited`,description:`Too many requests. Please wait a moment and try again.`,icon:(0,Q.jsx)(nt,{className:`size-3.5`})},server_error:{label:`Server Error`,description:`The AI provider encountered an error. Please try again.`,icon:(0,Q.jsx)(ze,{className:`size-3.5`})},timeout:{label:`Request Timed Out`,description:`The request took too long. Please try again.`,icon:(0,Q.jsx)(nt,{className:`size-3.5`})},authentication:{label:`Authentication Failed`,description:`Check your API key configuration.`,icon:(0,Q.jsx)(ue,{className:`size-3.5`})},context_overflow:{label:`Context Overflow`,description:`The conversation is too long. Try compacting or starting a new session.`,icon:(0,Q.jsx)(Pe,{className:`size-3.5`})},invalid_request:{label:`Invalid Request`,description:`The request was rejected by the provider.`,icon:(0,Q.jsx)(Se,{className:`size-3.5`})},unknown:{label:`Error`,description:`An unexpected error occurred.`,icon:(0,Q.jsx)(Pe,{className:`size-3.5`})}};function qn(e){if(!e)return`unknown`;let t=e.toLowerCase();return t.includes(`rate limit`)||t.includes(`429`)?`rate_limit`:t.includes(`timeout`)||t.includes(`timed out`)?`timeout`:t.includes(`auth`)||t.includes(`api key`)||t.includes(`401`)||t.includes(`403`)?`authentication`:t.includes(`context`)||t.includes(`overflow`)||t.includes(`too long`)||t.includes(`token limit`)?`context_overflow`:t.includes(`invalid request`)||t.includes(`400`)?`invalid_request`:t.includes(`server error`)||t.includes(`500`)||t.includes(`502`)||t.includes(`503`)?`server_error`:`unknown`}function Jn(e){let t=(0,$.c)(19),{message:n}=e,r=Kn[qn(n.error)],i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Pe,{className:`size-3`}),t[0]=i):i=t[0];let a;t[1]===r.label?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[i,r.label]}),t[1]=r.label,t[2]=a);let o;t[3]===r.icon?o=t[4]:(o=(0,Q.jsx)(`div`,{className:`text-destructive mt-0.5 shrink-0`,children:r.icon}),t[3]=r.icon,t[4]=o);let s=n.error||r.description,c;t[5]===s?c=t[6]:(c=(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:s}),t[5]=s,t[6]=c);let l;t[7]!==n.error||t[8]!==r.description?(l=n.error&&n.error!==r.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.description}),t[7]=n.error,t[8]=r.description,t[9]=l):l=t[9];let u;t[10]!==c||t[11]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==o||t[14]!==u?(d=(0,Q.jsx)(`div`,{className:`rounded-2xl px-4 py-3 max-w-full bg-destructive/10 border border-destructive/30 rounded-bl-md`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[o,u]})}),t[13]=o,t[14]=u,t[15]=d):d=t[15];let f;return t[16]!==a||t[17]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[a,d]}),t[16]=a,t[17]=d,t[18]=f):f=t[18],f}var Yn=J.oneDark,Xn=J.oneLight;function Zn(e){let t=e.split(`.`).pop()?.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`}[t||``]||t||`text`}var Qn=(0,Z.memo)(function(e){let t=(0,$.c)(35),{type:n,content:r,lineNumber:i,newLineNumber:o,language:s,codeTheme:c}=e,{resolvedMode:l}=a(),u=l===`dark`,d=n===`added`&&(u?`bg-green-500/20`:`bg-green-500/15`),f=n===`removed`&&(u?`bg-red-500/20`:`bg-red-500/15`),p=n===`context`&&`bg-muted/30`,m;t[0]!==d||t[1]!==f||t[2]!==p?(m=Y(`flex font-mono text-xs`,d,f,p),t[0]=d,t[1]=f,t[2]=p,t[3]=m):m=t[3];let h=m,g=n===`added`&&(u?`text-green-400`:`text-green-600`),_=n===`removed`&&(u?`text-red-400`:`text-red-600`),v=n===`context`&&`text-muted-foreground/50`,y;t[4]!==g||t[5]!==_||t[6]!==v?(y=Y(`font-bold w-4 select-none`,g,_,v),t[4]=g,t[5]=_,t[6]=v,t[7]=y):y=t[7];let b=y,x=u?`border-white/10`:`border-border`,S;t[8]===x?S=t[9]:(S=Y(`w-10 text-right pr-2 text-muted-foreground select-none border-r`,x),t[8]=x,t[9]=S);let C=i??``,w;t[10]!==S||t[11]!==C?(w=(0,Q.jsx)(`span`,{className:S,children:C}),t[10]=S,t[11]=C,t[12]=w):w=t[12];let T=u?`border-white/10`:`border-border`,E;t[13]===T?E=t[14]:(E=Y(`w-10 text-right pr-2 text-muted-foreground select-none border-r`,T),t[13]=T,t[14]=E);let D=o??``,O;t[15]!==E||t[16]!==D?(O=(0,Q.jsx)(`span`,{className:E,children:D}),t[15]=E,t[16]=D,t[17]=O):O=t[17];let k=n===`added`&&`+`,A=n===`removed`&&`-`,j=n===`context`&&` `,M;t[18]!==b||t[19]!==k||t[20]!==A||t[21]!==j?(M=(0,Q.jsxs)(`span`,{className:b,children:[k,A,j]}),t[18]=b,t[19]=k,t[20]=A,t[21]=j,t[22]=M):M=t[22];let N;t[23]!==c||t[24]!==r||t[25]!==s?(N=(0,Q.jsx)(_e,{theme:c,code:r,language:s,children:er}),t[23]=c,t[24]=r,t[25]=s,t[26]=N):N=t[26];let P;t[27]!==M||t[28]!==N?(P=(0,Q.jsxs)(`span`,{className:`pl-2 flex-1 whitespace-pre overflow-hidden flex`,children:[M,N]}),t[27]=M,t[28]=N,t[29]=P):P=t[29];let F;return t[30]!==w||t[31]!==O||t[32]!==P||t[33]!==h?(F=(0,Q.jsxs)(`div`,{className:h,children:[w,O,P]}),t[30]=w,t[31]=O,t[32]=P,t[33]=h,t[34]=F):F=t[34],F}),$n=(0,Z.memo)(function(e){let t=(0,$.c)(35),{hunks:n,path:r,language:i,additions:o,deletions:s}=e,[c,l]=(0,Z.useState)(!0),u;t[0]!==r||t[1]!==i?(u=i||Zn(r),t[0]=r,t[1]=i,t[2]=u):u=t[2];let d=u,f=g(tr),p=h(nr),{resolvedMode:m}=a(),_=m===`dark`,v=_?Yn:Xn,y;t[3]!==p||t[4]!==f||t[5]!==r?(y=()=>{p&&f({workspaceId:p.id,path:r,name:r.split(`/`).pop()||r})},t[3]=p,t[4]=f,t[5]=r,t[6]=y):y=t[6];let b=y,x;t[7]===c?x=t[8]:(x=()=>l(!c),t[7]=c,t[8]=x);let S;t[9]===c?S=t[10]:(S=c?(0,Q.jsx)(Qe,{className:`size-3`}):(0,Q.jsx)(M,{className:`size-3`}),t[9]=c,t[10]=S);let C;t[11]!==x||t[12]!==S?(C=(0,Q.jsx)(`button`,{onClick:x,className:`px-1 py-1 hover:bg-muted rounded`,children:S}),t[11]=x,t[12]=S,t[13]=C):C=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(Ae,{className:`size-3`}),t[14]=w):w=t[14];let T;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(ke,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`}),t[15]=T):T=t[15];let E;t[16]!==b||t[17]!==r?(E=(0,Q.jsxs)(`button`,{type:`button`,onClick:b,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 min-w-0 truncate`,title:r,children:[r,T]}),t[16]=b,t[17]=r,t[18]=E):E=t[18];let D;t[19]!==o||t[20]!==s?(D=o!==void 0&&s!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-auto mr-2 text-muted-foreground`,children:[`+`,o,` -`,s]}),t[19]=o,t[20]=s,t[21]=D):D=t[21];let O;t[22]!==C||t[23]!==E||t[24]!==D?(O=(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[C,w,E,D]}),t[22]=C,t[23]=E,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==v||t[27]!==c||t[28]!==n||t[29]!==_||t[30]!==d?(k=c&&(0,Q.jsx)(`div`,{style:{backgroundColor:v.plain.backgroundColor||(_?`#282c34`:`#fafafa`)},children:n.map((e,t)=>(0,Q.jsx)(`div`,{className:Y(`divide-y`,_?`divide-white/5`:`divide-border`),children:e.changes.map((e,t)=>(0,Q.jsx)(Qn,{...e,language:d,codeTheme:v},t))},t))}),t[26]=v,t[27]=c,t[28]=n,t[29]=_,t[30]=d,t[31]=k):k=t[31];let A;return t[32]!==O||t[33]!==k?(A=(0,Q.jsx)(`div`,{className:`visualization-container max-w-full overflow-x-auto border border-border rounded-md`,children:(0,Q.jsxs)(`div`,{children:[O,k]})}),t[32]=O,t[33]=k,t[34]=A):A=t[34],A});function er(e){let{tokens:t,getTokenProps:n}=e;return(0,Q.jsx)(Q.Fragment,{children:t.map((e,t)=>(0,Q.jsx)(`span`,{children:e.map((e,t)=>(0,Q.jsx)(`span`,{...n({token:e})},t))},t))})}function tr(e){return e.openFilePreview}function nr(e){return e.activeWorkspace}var rr=J.oneDark,ir=J.oneLight,ar=20;function or(e){let t=e.split(`.`).pop()?.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`}[t||``]||t||`text`}var sr=(0,Z.memo)(e=>{let t=(0,$.c)(52),{content:n,path:r,language:i,created:o,highlightLines:s}=e,c;t[0]===s?c=t[1]:(c=s===void 0?[]:s,t[0]=s,t[1]=c);let l=c,[u,d]=(0,Z.useState)(!1),f=g(cr),m=h(lr),{resolvedMode:_}=a(),v=_===`dark`,y=v?rr:ir,b;t[2]!==m||t[3]!==f||t[4]!==r?(b=()=>{m&&f({workspaceId:m.id,path:r,name:r.split(`/`).pop()||r})},t[2]=m,t[3]=f,t[4]=r,t[5]=b):b=t[5];let x=b,S;t[6]!==i||t[7]!==r?(S=i||or(r),t[6]=i,t[7]=r,t[8]=S):S=t[8];let C=S,w;t[9]===l?w=t[10]:(w=new Set(l),t[9]=l,t[10]=w);let T=w,E;t[11]===n?E=t[12]:(E=n.split(`
7
+ `),t[11]=n,t[12]=E);let D=E.length,O;t[13]===u?O=t[14]:(O=()=>d(!u),t[13]=u,t[14]=O);let k;t[15]===u?k=t[16]:(k=u?(0,Q.jsx)(Qe,{className:`size-3`}):(0,Q.jsx)(M,{className:`size-3`}),t[15]=u,t[16]=k);let A;t[17]!==O||t[18]!==k?(A=(0,Q.jsx)(`button`,{onClick:O,className:`flex items-center gap-2 px-2 py-1 hover:bg-muted`,children:k}),t[17]=O,t[18]=k,t[19]=A):A=t[19];let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(Ae,{className:`size-3`}),t[20]=j):j=t[20];let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(ke,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`}),t[21]=N):N=t[21];let P;t[22]!==x||t[23]!==r?(P=(0,Q.jsxs)(`button`,{type:`button`,onClick:x,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 min-w-0 truncate`,title:r,children:[r,N]}),t[22]=x,t[23]=r,t[24]=P):P=t[24];let F;t[25]!==u||t[26]!==D?(F=!u&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/70`,children:[D,` lines`]}),t[25]=u,t[26]=D,t[27]=F):F=t[27];let I;t[28]===o?I=t[29]:(I=o===!1?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-warning ml-auto mr-2`,children:[(0,Q.jsx)(Oe,{className:`size-3`}),`Overwrote`]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success ml-auto mr-2`,children:[(0,Q.jsx)(p,{className:`size-3`}),`Created`]}),t[28]=o,t[29]=I);let L;t[30]!==P||t[31]!==F||t[32]!==I||t[33]!==A?(L=(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[A,j,P,F,I]}),t[30]=P,t[31]=F,t[32]=I,t[33]=A,t[34]=L):L=t[34];let R;t[35]===y.plain.backgroundColor?R=t[36]:(R={backgroundColor:y.plain.backgroundColor},t[35]=y.plain.backgroundColor,t[36]=R);let z;t[37]!==u||t[38]!==T||t[39]!==v?(z=e=>{let{tokens:t,getTokenProps:n}=e;return(0,Q.jsx)(Q.Fragment,{children:(u?t:t.slice(0,ar)).map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex font-mono text-xs ${T.has(t+1)?`bg-yellow-500/20`:``}`,children:[(0,Q.jsx)(`span`,{className:Y(`w-10 text-right pr-2 select-none border-r`,v?`text-muted-foreground border-white/10`:`text-muted-foreground border-border`),children:t+1}),(0,Q.jsx)(`span`,{className:`pl-2 flex-1 whitespace-pre overflow-hidden`,children:e.map((e,t)=>(0,Q.jsx)(`span`,{...n({token:e})},t))})]},t))})},t[37]=u,t[38]=T,t[39]=v,t[40]=z):z=t[40];let B;t[41]!==y||t[42]!==n||t[43]!==C||t[44]!==z?(B=(0,Q.jsx)(_e,{theme:y,code:n,language:C,children:z}),t[41]=y,t[42]=n,t[43]=C,t[44]=z,t[45]=B):B=t[45];let V;t[46]!==R||t[47]!==B?(V=(0,Q.jsx)(`div`,{style:R,children:B}),t[46]=R,t[47]=B,t[48]=V):V=t[48];let H;return t[49]!==L||t[50]!==V?(H=(0,Q.jsx)(`div`,{className:`visualization-container max-w-full overflow-x-auto border border-border rounded-md`,children:(0,Q.jsxs)(`div`,{children:[L,V]})}),t[49]=L,t[50]=V,t[51]=H):H=t[51],H});function cr(e){return e.openFilePreview}function lr(e){return e.activeWorkspace}function ur(e){let t=(0,$.c)(3),{message:n}=e,r=n===void 0?`Success`:n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(m,{className:`size-4`}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[i,(0,Q.jsx)(`span`,{className:`break-all`,children:r})]}),t[1]=r,t[2]=a),a}var dr={edit:it,plus:Ie,trash:Re,search:ae};function fr(e){let t=(0,$.c)(7),{text:n}=e,[r,i]=(0,Z.useState)(!1),a;t[0]===n?a=t[1]:(a=async()=>{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)},t[0]=n,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=r?(0,Q.jsx)(`span`,{className:`text-success text-xs`,children:`Copied!`}):(0,Q.jsx)(ce,{className:`size-3`}),t[2]=r,t[3]=s);let c;return t[4]!==o||t[5]!==s?(c=(0,Q.jsx)(`button`,{onClick:o,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Copy path`,children:s}),t[4]=o,t[5]=s,t[6]=c):c=t[6],c}function pr(e){let t=(0,$.c)(16),{title:n,groups:r,files:i,total:a}=e,o;t[0]===i?o=t[1]:(o=i||[],t[0]=i,t[1]=o);let s;t[2]===o?s=t[3]:(s={label:`Files`,files:o,icon:void 0},t[2]=o,t[3]=s);let c=s,l;t[4]!==c||t[5]!==i||t[6]!==r?(l=r||(i?[c]:[]),t[4]=c,t[5]=i,t[6]=r,t[7]=l):l=t[7];let u=l;if(u.length===0)return null;let d;t[8]!==n||t[9]!==a?(d=n&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[n,a!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,a,` files)`]})]}),t[8]=n,t[9]=a,t[10]=d):d=t[10];let f;t[11]===u?f=t[12]:(f=u.map(mr),t[11]=u,t[12]=f);let p;return t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function mr(e,t){return(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=dr[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(hr)})]},t)}function hr(e,t){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs group`,children:[(0,Q.jsx)(Ae,{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:Y(`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)(fr,{text:e.path})]},t)}function gr(e){let t=(0,$.c)(15),{command:n,stdout:r,stderr:i,exitCode:a}=e,o=a===0,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`$ `}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,Q.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground truncate flex-1 mr-2`,children:[s,(0,Q.jsx)(`span`,{className:`text-foreground`,children:n})]}),t[1]=n,t[2]=c);let l=`text-xs font-mono px-2 py-0.5 rounded ${o?`bg-muted text-muted-foreground`:`bg-red-500/20 text-red-400`}`,u;t[3]!==a||t[4]!==l?(u=(0,Q.jsxs)(`span`,{className:l,children:[`[`,a,`]`]}),t[3]=a,t[4]=l,t[5]=u):u=t[5];let d;t[6]!==c||t[7]!==u?(d=(0,Q.jsxs)(`div`,{className:`bg-muted px-3 py-2 flex items-center justify-between`,children:[c,u]}),t[6]=c,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==i||t[10]!==r?(f=(r||i)&&(0,Q.jsxs)(`div`,{className:`bg-black px-3 py-2 font-mono text-xs overflow-x-auto`,children:[r&&(0,Q.jsx)(`pre`,{className:`text-gray-300 whitespace-pre-wrap`,children:r}),i&&(0,Q.jsx)(`pre`,{className:`text-red-400 whitespace-pre-wrap mt-1`,children:i})]}),t[9]=i,t[10]=r,t[11]=f):f=t[11];let p;return t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`visualization-container border border-border rounded-md overflow-hidden`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14],p}var _r={pending:{icon:tt,color:`text-muted-foreground`},in_progress:{icon:v,color:`text-warning`,animate:!0},completed:{icon:m,color:`text-success`},cancelled:{icon:d,color:`text-destructive`}},vr={high:{label:`high`,className:`bg-destructive/20 text-destructive`},medium:{label:``,className:``},low:{label:`low`,className:`text-muted-foreground`}};function yr(e){let t=(0,$.c)(13),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===r?i=t[1]:(i=r.filter(Cr),t[0]=r,t[1]=i);let a=i.length;r.filter(Sr),r.filter(xr);let o;t[2]!==a||t[3]!==r.length||t[4]!==n?(o=(n||r.length>0)&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[n||`Todo List`,(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,r.length,`)`]}),a>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-success text-xs`,children:[a,` completed`]})]}),t[2]=a,t[3]=r.length,t[4]=n,t[5]=o):o=t[5];let s;t[6]===r?s=t[7]:(s=r.map(br),t[6]=r,t[7]=s);let c;t[8]===s?c=t[9]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:s}),t[8]=s,t[9]=c);let l;return t[10]!==o||t[11]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 w-full overflow-hidden`,children:[o,c]}),t[10]=o,t[11]=c,t[12]=l):l=t[12],l}function br(e,t){let n=_r[e.status],r=n.icon,i=vr[e.priority];return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,Q.jsx)(r,{className:Y(`size-4 shrink-0`,n.color,n.animate&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:Y(`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:Y(`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)}function xr(e){return e.status===`pending`}function Sr(e){return e.status===`in_progress`}function Cr(e){return e.status===`completed`}var wr=(0,Z.memo)(function(e){let t=(0,$.c)(38),{visualization:n}=e;if(!n)return null;switch(n.type){case`diff`:{let e;return t[0]!==n.additions||t[1]!==n.deletions||t[2]!==n.hunks||t[3]!==n.language||t[4]!==n.matchInfo||t[5]!==n.path?(e=(0,Q.jsx)($n,{path:n.path,hunks:n.hunks,language:n.language,additions:n.additions,deletions:n.deletions,matchInfo:n.matchInfo}),t[0]=n.additions,t[1]=n.deletions,t[2]=n.hunks,t[3]=n.language,t[4]=n.matchInfo,t[5]=n.path,t[6]=e):e=t[6],e}case`diffs`:{let e;t[7]===n.items?e=t[8]:(e=n.items.map(Tr),t[7]=n.items,t[8]=e);let r;return t[9]===e?r=t[10]:(r=(0,Q.jsx)(`div`,{className:`space-y-3`,children:e}),t[9]=e,t[10]=r),r}case`code`:{let e;return t[11]!==n.content||t[12]!==n.created||t[13]!==n.highlightLines||t[14]!==n.language||t[15]!==n.path?(e=(0,Q.jsx)(sr,{path:n.path,content:n.content,language:n.language,created:n.created,highlightLines:n.highlightLines}),t[11]=n.content,t[12]=n.created,t[13]=n.highlightLines,t[14]=n.language,t[15]=n.path,t[16]=e):e=t[16],e}case`file-list`:{let e;return t[17]!==n.files||t[18]!==n.groups||t[19]!==n.title||t[20]!==n.total?(e=(0,Q.jsx)(pr,{title:n.title,groups:n.groups,files:n.files,total:n.total}),t[17]=n.files,t[18]=n.groups,t[19]=n.title,t[20]=n.total,t[21]=e):e=t[21],e}case`table`:{let e;t[22]===n.rows?e=t[23]:(e=JSON.stringify(n.rows,null,2),t[22]=n.rows,t[23]=e);let r;return t[24]===e?r=t[25]:(r=(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto`,children:e}),t[24]=e,t[25]=r),r}case`markdown`:{let e;return t[26]===n.content?e=t[27]:(e=(0,Q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert`,children:n.content}),t[26]=n.content,t[27]=e),e}case`none`:{let e;return t[28]===n.message?e=t[29]:(e=(0,Q.jsx)(ur,{message:n.message}),t[28]=n.message,t[29]=e),e}case`shell-output`:{let e;return t[30]!==n.command||t[31]!==n.exitCode||t[32]!==n.stderr||t[33]!==n.stdout?(e=(0,Q.jsx)(gr,{command:n.command,stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}),t[30]=n.command,t[31]=n.exitCode,t[32]=n.stderr,t[33]=n.stdout,t[34]=e):e=t[34],e}case`todo-list`:{let e;return t[35]!==n.items||t[36]!==n.title?(e=(0,Q.jsx)(yr,{title:n.title,items:n.items}),t[35]=n.items,t[36]=n.title,t[37]=e):e=t[37],e}default:return null}});function Tr(e,t){return(0,Q.jsx)($n,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo},`${e.path}-${t}`)}function Er(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Y(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Tt,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Q.jsx)(p,{})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Q.jsx)(Ct,{"data-slot":`checkbox`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function Dr(e){let t=(0,$.c)(16),{question:n,onSelect:r}=e,[i,a]=(0,Z.useState)(null),o;t[0]===n.description?o=t[1]:(o=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=o);let s;if(t[2]!==n.options||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e.value),className:`flex flex-col items-start gap-1 p-3 rounded-lg border transition-colors text-left ${i===e.value?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border hover:border-primary/50 hover:bg-muted/50`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(`div`,{className:`size-4 rounded-full border-2 flex items-center justify-center transition-colors ${i===e.value?`border-primary bg-primary`:`border-muted-foreground`}`,children:i===e.value&&(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary-foreground`})}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label})]}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground pl-6`,children:e.description})]},e.value),t[5]=i,t[6]=e),s=n.options.map(e),t[2]=n.options,t[3]=i,t[4]=s}else s=t[4];let c;t[7]===s?c=t[8]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s}),t[7]=s,t[8]=c);let l;t[9]!==r||t[10]!==i?(l=i!==null&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(X,{size:`sm`,onClick:()=>r(i),children:`Confirm`})}),t[9]=r,t[10]=i,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==c||t[14]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,c,l]}),t[12]=o,t[13]=c,t[14]=l,t[15]=u):u=t[15],u}function Or(e){let t=(0,$.c)(36),{question:n,onSelect:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Set,t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s;t[1]===n.max?s=t[2]:(s=e=>{o(t=>{let r=new Set(t);if(r.has(e))r.delete(e);else{if(n.max&&r.size>=n.max)return t;r.add(e)}return r})},t[1]=n.max,t[2]=s);let c=s,l;t[3]!==r||t[4]!==n.min||t[5]!==a?(l=()=>{let e=Array.from(a);n.min&&e.length<n.min||r(e)},t[3]=r,t[4]=n.min,t[5]=a,t[6]=l):l=t[6];let u=l,d=!n.min||a.size>=n.min,f=n.max?a.size>=n.max:!1,p;t[7]===n.description?p=t[8]:(p=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[7]=n.description,t[8]=p);let m;if(t[9]!==f||t[10]!==n.options||t[11]!==a||t[12]!==c){let e;t[14]!==f||t[15]!==a||t[16]!==c?(e=e=>{let t=f&&!a.has(e.value);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(e.value),disabled:t,className:`flex flex-col items-start gap-1 p-3 rounded-lg border transition-colors text-left ${t?`border-border opacity-50 cursor-not-allowed`:a.has(e.value)?`border-primary bg-primary/5 hover:bg-primary/10`:`border-border hover:border-primary/50 hover:bg-muted/50`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(Er,{checked:a.has(e.value),disabled:t,onCheckedChange:()=>c(e.value),className:`pointer-events-none`}),(0,Q.jsx)(`span`,{className:`font-medium pointer-events-none`,children:e.label})]}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground pl-6`,children:e.description})]},e.value)},t[14]=f,t[15]=a,t[16]=c,t[17]=e):e=t[17],m=n.options.map(e),t[9]=f,t[10]=n.options,t[11]=a,t[12]=c,t[13]=m}else m=t[13];let h;t[18]===m?h=t[19]:(h=(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:m}),t[18]=m,t[19]=h);let g;t[20]!==n.max||t[21]!==n.min?(g=n.min!==void 0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select at least `,n.min,` option`,n.min>1?`s`:``,n.max!==void 0&&` (up to ${n.max})`]}),t[20]=n.max,t[21]=n.min,t[22]=g):g=t[22];let _;t[23]!==n.max||t[24]!==n.min?(_=n.max!==void 0&&!n.min&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select up to `,n.max,` option`,n.max>1?`s`:``]}),t[23]=n.max,t[24]=n.min,t[25]=_):_=t[25];let v=!d,y;t[26]!==u||t[27]!==a.size||t[28]!==v?(y=(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(X,{size:`sm`,onClick:u,disabled:v,children:[`Confirm Selection (`,a.size,`)`]})}),t[26]=u,t[27]=a.size,t[28]=v,t[29]=y):y=t[29];let b;return t[30]!==y||t[31]!==p||t[32]!==h||t[33]!==g||t[34]!==_?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p,h,g,_,y]}),t[30]=y,t[31]=p,t[32]=h,t[33]=g,t[34]=_,t[35]=b):b=t[35],b}function kr(e){let t=(0,$.c)(26),{question:n,onSubmit:r}=e,[i,a]=(0,Z.useState)(n.defaultValue||``),o;t[0]===n.description?o=t[1]:(o=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>a(e.target.value),t[2]=s):s=t[2];let c;t[3]!==n.placeholder||t[4]!==i?(c=(0,Q.jsx)(L,{type:`text`,value:i,onChange:s,placeholder:n.placeholder}),t[3]=n.placeholder,t[4]=i,t[5]=c):c=t[5];let l;t[6]!==r||t[7]!==i?(l=(0,Q.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>r(i),children:`Skip`}),t[6]=r,t[7]=i,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==i?(u=()=>r(i),t[9]=r,t[10]=i,t[11]=u):u=t[11];let d;t[12]===i?d=t[13]:(d=i.trim(),t[12]=i,t[13]=d);let f=d.length===0,p;t[14]!==u||t[15]!==f?(p=(0,Q.jsx)(X,{size:`sm`,onClick:u,disabled:f,children:`Submit`}),t[14]=u,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==l||t[18]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[l,p]}),t[17]=l,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==c||t[21]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,m]}),t[20]=c,t[21]=m,t[22]=h):h=t[22];let g;return t[23]!==o||t[24]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,h]}),t[23]=o,t[24]=h,t[25]=g):g=t[25],g}function Ar(e){let t=(0,$.c)(22),{question:n,onConfirm:r}=e,i=n.defaultValue??!1,[a,o]=(0,Z.useState)(null),s;t[0]===n.description?s=t[1]:(s=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=s);let c=a===!1?`default`:`outline`,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>o(!1),t[2]=l):l=t[2];let u=i?`No`:`Cancel`,d;t[3]!==c||t[4]!==u?(d=(0,Q.jsx)(X,{variant:c,size:`sm`,onClick:l,children:u}),t[3]=c,t[4]=u,t[5]=d):d=t[5];let f=a===!0?`default`:`outline`,p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>o(!0),t[6]=p):p=t[6];let m=i?`Yes`:`Confirm`,h;t[7]!==f||t[8]!==m?(h=(0,Q.jsx)(X,{variant:f,size:`sm`,onClick:p,children:m}),t[7]=f,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==d||t[11]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[d,h]}),t[10]=d,t[11]=h,t[12]=g):g=t[12];let _;t[13]!==r||t[14]!==a?(_=a!==null&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(X,{size:`sm`,onClick:()=>r(a),children:`Submit`})}),t[13]=r,t[14]=a,t[15]=_):_=t[15];let v;t[16]!==g||t[17]!==_?(v=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[g,_]}),t[16]=g,t[17]=_,t[18]=v):v=t[18];let y;return t[19]!==s||t[20]!==v?(y=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[s,v]}),t[19]=s,t[20]=v,t[21]=y):y=t[21],y}function jr(e){let t=(0,$.c)(29),{question:n,onSubmit:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={},t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s;if(t[1]!==a||t[2]!==n.questions){let e;t[4]===a?e=t[5]:(e=(e,t)=>a[t]!==void 0,t[4]=a,t[5]=e),s=n.questions.every(e),t[1]=a,t[2]=n.questions,t[3]=s}else s=t[3];let c=s,l;t[6]!==a||t[7]!==r||t[8]!==n.questions?(l=()=>{r({type:`form`,answers:n.questions.map((e,t)=>({question:e.question,answer:a[t]}))})},t[6]=a,t[7]=r,t[8]=n.questions,t[9]=l):l=t[9];let u=l,d;t[10]===n.description?d=t[11]:(d=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[10]=n.description,t[11]=d);let f;if(t[12]!==n.questions){let e;t[14]===n.questions.length?e=t[15]:(e=(e,t)=>(0,Q.jsxs)(`div`,{className:`border-l-2 border-primary/30 pl-3`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:[`Question `,t+1,` of `,n.questions.length]}),(0,Q.jsx)(Mr,{question:e,onAnswer:e=>o(n=>({...n,[t]:e}))})]},t),t[14]=n.questions.length,t[15]=e),f=n.questions.map(e),t[12]=n.questions,t[13]=f}else f=t[13];let p;t[16]===f?p=t[17]:(p=(0,Q.jsx)(`div`,{className:`flex flex-col gap-4`,children:f}),t[16]=f,t[17]=p);let m=!c,h;t[18]===a?h=t[19]:(h=Object.keys(a),t[18]=a,t[19]=h);let g;t[20]!==u||t[21]!==n.questions.length||t[22]!==m||t[23]!==h.length?(g=(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(X,{size:`sm`,onClick:u,disabled:m,children:[`Submit All (`,h.length,`/`,n.questions.length,`)`]})}),t[20]=u,t[21]=n.questions.length,t[22]=m,t[23]=h.length,t[24]=g):g=t[24];let _;return t[25]!==d||t[26]!==p||t[27]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,p,g]}),t[25]=d,t[26]=p,t[27]=g,t[28]=_):_=t[28],_}function Mr(e){let t=(0,$.c)(61),{question:n,onAnswer:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Set,t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),[s,c]=(0,Z.useState)(null);switch(n.type){case`single_select`:{let e;t[1]===n.question?e=t[2]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[1]=n.question,t[2]=e);let i;if(t[3]!==r||t[4]!==n.options||t[5]!==a){let e;t[7]!==r||t[8]!==a?(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{o(new Set([e.value])),r(e.value)},className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a.has(e.value)?`border-primary bg-primary/10`:`border-border hover:border-primary/50`}`,children:e.label},e.value),t[7]=r,t[8]=a,t[9]=e):e=t[9],i=n.options.map(e),t[3]=r,t[4]=n.options,t[5]=a,t[6]=i}else i=t[6];let s;t[10]===i?s=t[11]:(s=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i}),t[10]=i,t[11]=s);let c;return t[12]!==e||t[13]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,s]}),t[12]=e,t[13]=s,t[14]=c):c=t[14],c}case`multi_select`:{let e;t[15]!==r||t[16]!==n.max?(e=e=>{o(t=>{let i=new Set(t);if(i.has(e))i.delete(e);else if(!n.max||i.size<n.max)i.add(e);else return t;return r(Array.from(i)),i})},t[15]=r,t[16]=n.max,t[17]=e):e=t[17];let i=e,s;t[18]===n.question?s=t[19]:(s=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[18]=n.question,t[19]=s);let c;if(t[20]!==n.options||t[21]!==a||t[22]!==i){let e;t[24]!==a||t[25]!==i?(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a.has(e.value)?`border-primary bg-primary/10`:`border-border hover:border-primary/50`}`,children:e.label},e.value),t[24]=a,t[25]=i,t[26]=e):e=t[26],c=n.options.map(e),t[20]=n.options,t[21]=a,t[22]=i,t[23]=c}else c=t[23];let l;t[27]===c?l=t[28]:(l=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c}),t[27]=c,t[28]=l);let u;return t[29]!==s||t[30]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[s,l]}),t[29]=s,t[30]=l,t[31]=u):u=t[31],u}case`text`:{let e;t[32]===n.question?e=t[33]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[32]=n.question,t[33]=e);let i;t[34]===r?i=t[35]:(i=e=>r(e.target.value),t[34]=r,t[35]=i);let a;t[36]!==n.defaultValue||t[37]!==n.placeholder||t[38]!==i?(a=(0,Q.jsx)(L,{type:`text`,placeholder:n.placeholder,defaultValue:n.defaultValue,onChange:i}),t[36]=n.defaultValue,t[37]=n.placeholder,t[38]=i,t[39]=a):a=t[39];let o;return t[40]!==e||t[41]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,a]}),t[40]=e,t[41]=a,t[42]=o):o=t[42],o}case`confirm`:{let e;t[43]===n.question?e=t[44]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[43]=n.question,t[44]=e);let i=s===!1?`default`:`outline`,a;t[45]===r?a=t[46]:(a=()=>{c(!1),r(!1)},t[45]=r,t[46]=a);let o;t[47]!==i||t[48]!==a?(o=(0,Q.jsx)(X,{variant:i,size:`sm`,onClick:a,children:`No`}),t[47]=i,t[48]=a,t[49]=o):o=t[49];let l=s===!0?`default`:`outline`,u;t[50]===r?u=t[51]:(u=()=>{c(!0),r(!0)},t[50]=r,t[51]=u);let d;t[52]!==l||t[53]!==u?(d=(0,Q.jsx)(X,{variant:l,size:`sm`,onClick:u,children:`Yes`}),t[52]=l,t[53]=u,t[54]=d):d=t[54];let f;t[55]!==o||t[56]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[o,d]}),t[55]=o,t[56]=d,t[57]=f):f=t[57];let p;return t[58]!==e||t[59]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,f]}),t[58]=e,t[59]=f,t[60]=p):p=t[60],p}}}function Nr(e){let t=(0,$.c)(79),{ask:n,onRespond:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={none:`text-muted-foreground`,low:`text-success`,medium:`text-warning`,high:`text-destructive`,critical:`text-destructive`},t[0]=i):i=t[0];let a=i,o=n.intents?.[0],s=n.action??o?.action,c=n.resource??o?.resource??`shell-command`,l=s===`read`?`Reading`:s===`write`?`Writing to`:s===`delete`?`Deleting`:s===`request`?`Requesting`:s===`execute`?`Executing`:null,u,d,f,p,m,h,g,_,v,y,b,x;if(t[1]!==n.allowedScopes||t[2]!==n.description||t[3]!==n.metadata||t[4]!==n.paths||t[5]!==n.risk||t[6]!==s||t[7]!==c||t[8]!==r||t[9]!==l||t[10]!==o){let e=n.allowedScopes??[`once`,`session`,`workspace`],i=o?.persistable===!1?o.nonPersistableReason:void 0,S={};c===`file`&&s===`read`?(S.session=`Allow for This Session`,S.workspace=`Always Allow Reading This File`):c===`file`&&s===`write`?(S.session=`Allow for This Session`,S.workspace=`Always Allow Writing This File`):c===`file`&&s===`delete`?S.session=`Allow for This Session`:c===`network`?(S.session=`Allow for This Session`,S.workspace=`Always Allow This Network Request`):c===`shell-command`&&(S.session=`Allow for This Session`);let C=e=>{if(S[e])return S[e];switch(e){case`once`:return`Allow Once`;case`session`:return`Allow for This Session`;case`workspace`:return`Allow for Workspace`;case`always`:return`Allow for Workspace`;default:return`Allow (${e})`}};if(t[23]!==n.description||t[24]!==n.metadata||t[25]!==n.paths||t[26]!==n.risk||t[27]!==c||t[28]!==l||t[29]!==o?.targets){let e=o?.targets??[],r=e.length>0?e.map(Fr):[],i;t[37]!==n.metadata||t[38]!==c?(i=()=>c!==`shell-command`||typeof n.metadata?.command!=`string`?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Command`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:n.metadata.command})]}),t[37]=n.metadata,t[38]=c,t[39]=i):i=t[39];let s=i,f;t[40]!==n.paths||t[41]!==c||t[42]!==l?(f=()=>{let e=n.paths,t=c===`file`||c===`path`||c===`directory`;return!e||e.length===0||!t?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:l??`Accessing`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:e.join(`
8
+ `)})]})},t[40]=n.paths,t[41]=c,t[42]=l,t[43]=f):f=t[43];let p=f,m;t[44]!==n.metadata||t[45]!==c?(m=()=>c!==`network`||typeof n.metadata?.url!=`string`?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`URL`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:n.metadata.url})]}),t[44]=n.metadata,t[45]=c,t[46]=m):m=t[46];let h=m;_=`flex flex-col gap-3`,t[47]===n.description?v=t[48]:(v=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[47]=n.description,t[48]=v),t[49]===n.risk?y=t[50]:(y=n.risk&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`text-xs font-medium uppercase ${a[n.risk??`none`]??`text-muted-foreground`}`,children:[`Risk: `,n.risk]})}),t[49]=n.risk,t[50]=y),t[51]===s?b=t[52]:(b=s(),t[51]=s,t[52]=b),t[53]===p?x=t[54]:(x=p(),t[53]=p,t[54]=x),t[55]===h?u=t[56]:(u=h(),t[55]=h,t[56]=u),d=r.length===0||c===`shell-command`?null:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(Pr)}),t[23]=n.description,t[24]=n.metadata,t[25]=n.paths,t[26]=n.risk,t[27]=c,t[28]=l,t[29]=o?.targets,t[30]=u,t[31]=d,t[32]=_,t[33]=v,t[34]=y,t[35]=b,t[36]=x}else u=t[30],d=t[31],_=t[32],v=t[33],y=t[34],b=t[35],x=t[36];t[57]!==n.description||t[58]!==n.metadata?(f=n.metadata?.description&&typeof n.metadata.description==`string`&&!n.description?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.metadata.description}):null,t[57]=n.description,t[58]=n.metadata,t[59]=f):f=t[59],t[60]===i?p=t[61]:(p=i&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`This command is too dynamic to save as a reusable permission (`,i,`).`]}),t[60]=i,t[61]=p),m=`flex flex-wrap gap-2`,t[62]===r?h=t[63]:(h=(0,Q.jsx)(X,{variant:`destructive`,size:`sm`,onClick:()=>r({type:`permission`,grant:`deny`}),children:`Block`}),t[62]=r,t[63]=h),g=e.map(e=>(0,Q.jsx)(X,{variant:e===`workspace`?`default`:`outline`,size:`sm`,onClick:()=>r({type:`permission`,grant:e}),children:C(e)},e)),t[1]=n.allowedScopes,t[2]=n.description,t[3]=n.metadata,t[4]=n.paths,t[5]=n.risk,t[6]=s,t[7]=c,t[8]=r,t[9]=l,t[10]=o,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h,t[17]=g,t[18]=_,t[19]=v,t[20]=y,t[21]=b,t[22]=x}else u=t[11],d=t[12],f=t[13],p=t[14],m=t[15],h=t[16],g=t[17],_=t[18],v=t[19],y=t[20],b=t[21],x=t[22];let S;t[64]!==m||t[65]!==h||t[66]!==g?(S=(0,Q.jsxs)(`div`,{className:m,children:[h,g]}),t[64]=m,t[65]=h,t[66]=g,t[67]=S):S=t[67];let C;return t[68]!==u||t[69]!==d||t[70]!==f||t[71]!==p||t[72]!==S||t[73]!==_||t[74]!==v||t[75]!==y||t[76]!==b||t[77]!==x?(C=(0,Q.jsxs)(`div`,{className:_,children:[v,y,b,x,u,d,f,p,S]}),t[68]=u,t[69]=d,t[70]=f,t[71]=p,t[72]=S,t[73]=_,t[74]=v,t[75]=y,t[76]=b,t[77]=x,t[78]=C):C=t[78],C}function Pr(e,t){return(0,Q.jsx)(`code`,{className:`text-xs bg-muted/50 border rounded px-1.5 py-0.5 font-mono`,children:e},t)}function Fr(e){return e.target.split(`/`).pop()||e.target}function Ir(e){let t=(0,$.c)(15),{ask:n,onRespond:r}=e,i;t[0]===n.capability?i=t[1]:(i=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Client capability request: `,(0,Q.jsx)(`code`,{className:`text-xs bg-muted px-1.5 py-0.5 rounded`,children:n.capability})]}),t[0]=n.capability,t[1]=i);let a;t[2]===n.metadata?a=t[3]:(a=n.metadata&&(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 overflow-x-auto`,children:JSON.stringify(n.metadata,null,2)}),t[2]=n.metadata,t[3]=a);let o;t[4]===r?o=t[5]:(o=(0,Q.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>r(void 0),children:`Not Available`}),t[4]=r,t[5]=o);let s;t[6]===r?s=t[7]:(s=(0,Q.jsx)(X,{size:`sm`,onClick:()=>r(null),children:`Confirm`}),t[6]=r,t[7]=s);let c;t[8]!==o||t[9]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[o,s]}),t[8]=o,t[9]=s,t[10]=c):c=t[10];let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i,a,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l}function Lr(e){let t=(0,$.c)(78),{request:n,onRespond:r}=e,{toolCallId:i,toolName:a,ask:o,requestId:s}=n,c;t[0]!==r||t[1]!==s||t[2]!==i?(c=e=>{r(i,{type:`single_select`,value:e},s)},t[0]=r,t[1]=s,t[2]=i,t[3]=c):c=t[3];let l=c,u;t[4]!==r||t[5]!==s||t[6]!==i?(u=e=>{r(i,{type:`multi_select`,values:e},s)},t[4]=r,t[5]=s,t[6]=i,t[7]=u):u=t[7];let d=u,p;t[8]!==r||t[9]!==s||t[10]!==i?(p=e=>{r(i,{type:`text`,value:e},s)},t[8]=r,t[9]=s,t[10]=i,t[11]=p):p=t[11];let m=p,h;t[12]!==r||t[13]!==s||t[14]!==i?(h=e=>{r(i,{type:`confirm`,confirmed:e},s)},t[12]=r,t[13]=s,t[14]=i,t[15]=h):h=t[15];let g=h,_;t[16]!==r||t[17]!==s||t[18]!==i?(_=e=>{r(i,e,s)},t[16]=r,t[17]=s,t[18]=i,t[19]=_):_=t[19];let v=_,y;t[20]!==r||t[21]!==s||t[22]!==i?(y=e=>{r(i,e,s)},t[20]=r,t[21]=s,t[22]=i,t[23]=y):y=t[23];let b=y,x;t[24]!==o.capability||t[25]!==o.type||t[26]!==r||t[27]!==s||t[28]!==i?(x=e=>{r(i,{type:`client_capability`,capability:o.type===`client_capability`?o.capability:``,result:e},s)},t[24]=o.capability,t[25]=o.type,t[26]=r,t[27]=s,t[28]=i,t[29]=x):x=t[29];let S=x,C;bb0:{if(`type`in o)switch(o.type){case`single_select`:case`multi_select`:case`text`:case`confirm`:case`form`:{let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:et,borderClass:`border-primary/30 bg-primary/5`,iconClass:`text-primary`},t[30]=e):e=t[30],C=e;break bb0}case`permission`:{let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:f,borderClass:`border-warning/30 bg-warning/5`,iconClass:`text-warning`},t[31]=e):e=t[31],C=e;break bb0}case`client_capability`:{let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:ge,borderClass:`border-info/30 bg-info/5`,iconClass:`text-info`},t[32]=e):e=t[32],C=e;break bb0}}let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:f,borderClass:`border-warning/30 bg-warning/5`,iconClass:`text-warning`},t[33]=e):e=t[33],C=e}let w=C,T=w.icon,E=`border ${w.borderClass} rounded-lg p-4 flex flex-col gap-4`,D=`flex items-start gap-2 ${w.iconClass}`,O;t[34]===T?O=t[35]:(O=(0,Q.jsx)(T,{className:`size-4 mt-0.5 shrink-0`}),t[34]=T,t[35]=O);let k;t[36]===a?k=t[37]:(k=(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:a}),t[36]=a,t[37]=k);let A;t[38]===o?A=t[39]:(A=`question`in o&&(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:o.question}),t[38]=o,t[39]=A);let j;t[40]!==k||t[41]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[k,A]}),t[40]=k,t[41]=A,t[42]=j):j=t[42];let M;t[43]!==D||t[44]!==O||t[45]!==j?(M=(0,Q.jsxs)(`div`,{className:D,children:[O,j]}),t[43]=D,t[44]=O,t[45]=j,t[46]=M):M=t[46];let N;t[47]!==o||t[48]!==l?(N=o.type===`single_select`&&(0,Q.jsx)(Dr,{question:o,onSelect:l}),t[47]=o,t[48]=l,t[49]=N):N=t[49];let P;t[50]!==o||t[51]!==d?(P=o.type===`multi_select`&&(0,Q.jsx)(Or,{question:o,onSelect:d}),t[50]=o,t[51]=d,t[52]=P):P=t[52];let F;t[53]!==o||t[54]!==m?(F=o.type===`text`&&(0,Q.jsx)(kr,{question:o,onSubmit:m}),t[53]=o,t[54]=m,t[55]=F):F=t[55];let I;t[56]!==o||t[57]!==g?(I=o.type===`confirm`&&(0,Q.jsx)(Ar,{question:o,onConfirm:g}),t[56]=o,t[57]=g,t[58]=I):I=t[58];let L;t[59]!==o||t[60]!==v?(L=o.type===`form`&&(0,Q.jsx)(jr,{question:o,onSubmit:v}),t[59]=o,t[60]=v,t[61]=L):L=t[61];let R;t[62]!==o||t[63]!==b?(R=(o.type===`permission`||!(`type`in o))&&(0,Q.jsx)(Nr,{ask:o,onRespond:b}),t[62]=o,t[63]=b,t[64]=R):R=t[64];let z;t[65]!==o||t[66]!==S?(z=o.type===`client_capability`&&(0,Q.jsx)(Ir,{ask:o,onRespond:S}),t[65]=o,t[66]=S,t[67]=z):z=t[67];let B;return t[68]!==M||t[69]!==N||t[70]!==P||t[71]!==F||t[72]!==I||t[73]!==L||t[74]!==R||t[75]!==z||t[76]!==E?(B=(0,Q.jsxs)(`div`,{className:E,children:[M,N,P,F,I,L,R,z]}),t[68]=M,t[69]=N,t[70]=P,t[71]=F,t[72]=I,t[73]=L,t[74]=R,t[75]=z,t[76]=E,t[77]=B):B=t[77],B}var Rr=1536,zr=(0,Z.memo)(function(e){let t=(0,$.c)(16),{content:n,className:r}=e,[i,a]=(0,Z.useState)(!1),o;t[0]===n?o=t[1]:(o=new Blob([n]),t[0]=n,t[1]=o);let s=o.size,c=s>Rr,l=c?n.slice(0,Rr)+`
9
+ ...`:null;if(!c){let e;return t[2]!==r||t[3]!==n?(e=(0,Q.jsx)(`pre`,{className:r,children:n}),t[2]=r,t[3]=n,t[4]=e):e=t[4],e}let u;t[5]===s?u=t[6]:(u=s>1048576?`${(s/1048576).toFixed(1)} MB`:s>1024?`${(s/1024).toFixed(1)} KB`:`${s} bytes`,t[5]=s,t[6]=u);let d=u,f=i?n:l,p;t[7]!==r||t[8]!==f?(p=(0,Q.jsx)(`pre`,{className:r,children:f}),t[7]=r,t[8]=f,t[9]=p):p=t[9];let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>a(Gr),t[10]=m):m=t[10];let h=i?`Show less`:`Show full output (${d})`,g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground mt-1 transition-colors cursor-pointer`,onClick:m,children:h}),t[11]=h,t[12]=g);let _;return t[13]!==p||t[14]!==g?(_=(0,Q.jsxs)(`div`,{children:[p,g]}),t[13]=p,t[14]=g,t[15]=_):_=t[15],_});function Br(e){switch(e){case`pending`:return(0,Q.jsx)(nt,{className:`size-3 text-warning`});case`running`:return(0,Q.jsx)(v,{className:`size-3 text-warning animate-spin`});case`completed`:return(0,Q.jsx)(m,{className:`size-3 text-success`});case`error`:return(0,Q.jsx)(d,{className:`size-3 text-destructive`});case`interrupted`:return(0,Q.jsx)(je,{className:`size-3 text-warning`});default:return null}}function Vr(e){if(e.name!==`task`)return null;let t=e.state;if(`childSessionId`in t&&t.childSessionId)return t.childSessionId;let n=`output`in t?t.output:`partialOutput`in t?t.partialOutput:null;if(n&&typeof n==`string`){let e=n.match(/task_id:\s*([a-f0-9-]{36})/i);if(e)return e[1]}return null}function Hr(e){if(e&&typeof e==`object`&&`_visualization`in e)return e._visualization}function Ur(e,t){let n=new Set,r=[e];for(;r.length>0;){let e=r.shift();for(let i of t)i.parentId===e&&!n.has(i.id)&&(n.add(i.id),r.push(i.id))}return n}var Wr=(0,Z.memo)(function({part:e,pendingAskRequests:t,onAskResponse:n,onNavigateToSubagent:r}){let[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),l=e.state,u=l.status,d=(0,Z.useMemo)(()=>{if(!i)return``;try{return JSON.stringify(l.input,null,2)}catch{return String(l.input)}},[l.input,i]),f=(0,Z.useMemo)(()=>!i||u!==`completed`||!(`output`in l)?null:typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2),[u,l,i]),m=u===`completed`&&`output`in l?Hr(l.output):void 0,h=Vr(e),g=s(e=>e.sessions),_=[];if(u===`pending`||u===`running`){let n=t.find(t=>t.toolCallId===e.callId);if(n&&_.push(n),h){let n=Ur(h,g);n.add(h);let r=t.filter(t=>{let r=t.originSessionId&&n.has(t.originSessionId),i=t.sessionId===h;return(r||i)&&t.toolCallId!==e.callId});_.push(...r)}}let v=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)}},y=(()=>{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)(A,{open:i,onOpenChange:a,children:[(0,Q.jsx)(D,{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:[Br(u),i?(0,Q.jsx)(Qe,{className:`size-4 text-muted-foreground`}):(0,Q.jsx)(M,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(Ee,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`text-xs truncate max-w-[120px] sm:max-w-none`,children:e.name}),!i&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono truncate flex-1 min-w-0 hidden sm:block`,children:y}),h&&r&&(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`ml-auto h-6 w-6 p-0 sm:w-auto sm:px-2`,onClick:e=>{e.stopPropagation(),r(h)},title:`View session`,children:[(0,Q.jsx)(ke,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`View`})]})]})}),i&&(0,Q.jsx)(N,{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)(zr,{content:d,className:`text-xs bg-background border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),(u===`running`||u===`completed`||u===`interrupted`)&&h&&r&&(0,Q.jsxs)(X,{variant:`outline`,className:`w-full`,size:`sm`,onClick:()=>r(h),children:[(0,Q.jsx)(ke,{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)(X,{variant:`ghost`,size:`icon`,onClick:v,className:`size-6`,children:o?(0,Q.jsx)(p,{className:`size-3 text-success`}):(0,Q.jsx)(ce,{className:`size-3`})})]}),(0,Q.jsx)(zr,{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})]})]})})]}),_.length>0&&(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:_.map(e=>(0,Q.jsx)(Lr,{request:e,onRespond:n},e.requestId??e.toolCallId))}),u===`completed`&&m&&(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(wr,{visualization:m})})]})},(e,t)=>{if(e.part!==t.part||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.onAskResponse!==t.onAskResponse||e.pendingAskRequests.find(t=>t.toolCallId===e.part.callId)!==t.pendingAskRequests.find(e=>e.toolCallId===t.part.callId))return!1;let n=Vr(e.part),r=Vr(t.part);if(n||r){let i=e.pendingAskRequests.filter(e=>e.originSessionId===n||e.originSessionId===r||e.sessionId===n||e.sessionId===r),a=t.pendingAskRequests.filter(e=>e.originSessionId===n||e.originSessionId===r||e.sessionId===n||e.sessionId===r);if(i.length!==a.length||i.some((e,t)=>e!==a[t]))return!1}return!0});function Gr(e){return!e}var Kr=60,qr=300,Jr=16;function Yr(e){if(e.length===0)return!1;let t=e[e.length-1];return qe(t.message)&&t.message.status===`streaming`}function Xr(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function Zr(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 Qr(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(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)(lt,{className:`size-4 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Compacting conversation...`})]}),e[0]=t):t=e[0],t}function $r(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(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)($e,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Compaction complete`})]}),e[0]=t):t=e[0],t}function ei(e){let t=(0,$.c)(8),{message:n,textContent:r,onRetry:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[(0,Q.jsx)(Pe,{className:`size-3`}),`Compaction Failed`]}),t[0]=a):a=t[0];let o=r||n.error||`Compaction failed. The conversation could not be summarized.`,s;t[1]===o?s=t[2]:(s=(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:o}),t[1]=o,t[2]=s);let c;t[3]===i?c=t[4]:(c=i&&(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:i,className:`mt-2 h-7 text-xs gap-1.5`,children:[(0,Q.jsx)(Ne,{className:`size-3`}),`Retry`]}),t[3]=i,t[4]=c);let l;return t[5]!==s||t[6]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[a,(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:[s,c]})]}),t[5]=s,t[6]=c,t[7]=l):l=t[7],l}function ti(e,t){return e?.split(`/`).pop()||t?.split(`.`).pop()?.toLowerCase()||``}function ni(e){let t=(0,$.c)(15),{part:n}=e,[r,i]=(0,Z.useState)(!1),a=n.overflow?`overflow`:n.auto?`auto`:`manual`,o;t[0]===r?o=t[1]:(o=()=>i(!r),t[0]=r,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,Q.jsx)(Qe,{className:`size-3`}):(0,Q.jsx)(M,{className:`size-3`}),t[2]=r,t[3]=s);let c=a===`overflow`?`Context overflow`:a===`auto`?`Auto`:`Manual`,l;t[4]===c?l=t[5]:(l=(0,Q.jsxs)(`span`,{className:`border-b border-dashed border-muted-foreground/40 pb-px`,children:[c,` compaction`]}),t[4]=c,t[5]=l);let u;t[6]!==o||t[7]!==s||t[8]!==l?(u=(0,Q.jsxs)(`button`,{onClick:o,className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[s,l]}),t[6]=o,t[7]=s,t[8]=l,t[9]=u):u=t[9];let d;t[10]===r?d=t[11]:(d=r&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Summary available in the assistant message below`}),t[10]=r,t[11]=d);let f;return t[12]!==u||t[13]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center py-3`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14],f}var ri=(0,Z.memo)(function(e){let t=(0,$.c)(15),{parts:n,pendingAskRequests:r,onAskResponse:i,onNavigateToSubagent:a,inverted:o,serverUrl:s}=e,c=o===void 0?!1:o,l;if(t[0]!==c||t[1]!==i||t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==s){let e=[...n].sort(oi),o;t[7]!==c||t[8]!==i||t[9]!==a||t[10]!==r||t[11]!==s?(o=e=>{switch(e.type){case`text`:return(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(Ce,{inverted:c,children:c&&e.text?e.text.replace(/\n(?!\n)/g,`
10
+
11
+ `):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)(Wr,{part:e,pendingAskRequests:r,onAskResponse:i,onNavigateToSubagent:a},e.id);case`image`:return(0,Q.jsx)(`img`,{src:s?Cn(s,e.url):e.url,alt:``,className:Y(`max-w-full max-h-64 rounded-xl mt-2 object-contain`,c&&`ring-2 ring-white/20`)},e.id);case`file`:{let t=s?Cn(s,e.url):e.url,n=ti(e.mimeType,e.filename),r=e.filename||``,i=r.length>30?r.slice(0,27)+`...`:r||`unnamed`;return(0,Q.jsxs)(`a`,{href:t,className:Y(`mt-2 p-2 rounded-lg text-sm flex items-center gap-2 transition-colors`,c?`bg-white/15 hover:bg-white/25 text-primary-foreground`:`bg-muted hover:bg-accent`),target:`_blank`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(De,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:i}),n&&(0,Q.jsx)(`span`,{className:Y(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ml-auto shrink-0`,c?`bg-white/25 text-primary-foreground`:`bg-secondary text-secondary-foreground`),children:n}),(0,Q.jsx)(rt,{className:`size-3.5 shrink-0 opacity-60`})]},e.id)}default:return null}},t[7]=c,t[8]=i,t[9]=a,t[10]=r,t[11]=s,t[12]=o):o=t[12],l=e.map(o),t[0]=c,t[1]=i,t[2]=a,t[3]=n,t[4]=r,t[5]=s,t[6]=l}else l=t[6];let u;return t[13]===l?u=t[14]:(u=(0,Q.jsx)(Q.Fragment,{children:l}),t[13]=l,t[14]=u),u},(e,t)=>!(e.parts!==t.parts||e.inverted!==t.inverted||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.serverUrl!==t.serverUrl||e.pendingAskRequests!==t.pendingAskRequests)),ii=(0,Z.memo)(function(e){let t=(0,$.c)(49),{item:n,messagesWithParts:r,sessionId:i,pendingAskRequests:a,onAskResponse:o,onNavigateToSubagent:s,onRemoveFromQueue:c,onRevert:l,onFork:u,isMainActiveSession:d,isCompacting:f,onCompact:p,serverUrl:m}=e,h=d===void 0?!1:d,g=f===void 0?!1:f,_;t[0]===n.parts?_=t[1]:(_=n.parts.find(si),t[0]=n.parts,t[1]=_);let v=_;if(qe(n.message)&&n.message.mode===`compact_failed`){let e=n.message,r;t[2]===n.parts?r=t[3]:(r=Xr(n.parts),t[2]=n.parts,t[3]=r);let i=h&&!g?p:void 0,a;return t[4]!==e||t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(ei,{message:e,textContent:r,onRetry:i}),t[4]=e,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}if(qe(n.message)&&n.message.status===`error`){let e=n.message,r;return t[8]===e?r=t[9]:(r=(0,Q.jsx)(Jn,{message:e}),t[8]=e,t[9]=r),r}if(v){let e;return t[10]===v?e=t[11]:(e=(0,Q.jsx)(ni,{part:v}),t[10]=v,t[11]=e),e}let y=!n.isQueued&&n.message.role===`user`,b;t[12]!==y||t[13]!==n.message.id||t[14]!==r?(b=y?Zr(n.message.id,r):null,t[12]=y,t[13]=n.message.id,t[14]=r,t[15]=b):b=t[15];let x=b,S=x===n.message.id,C=n.message,w;t[16]===n.parts?w=t[17]:(w=Xr(n.parts),t[16]=n.parts,t[17]=w);let T;t[18]!==n.isQueued||t[19]!==n.queueId||t[20]!==c?(T=n.isQueued?()=>c(n.queueId):void 0,t[18]=n.isQueued,t[19]=n.queueId,t[20]=c,t[21]=T):T=t[21];let E=y&&x!==null,D;t[22]!==l||t[23]!==x||t[24]!==i?(D=x?()=>l?.(i,x):void 0,t[22]=l,t[23]=x,t[24]=i,t[25]=D):D=t[25];let O=y&&x!==null,k;t[26]!==n.message.id||t[27]!==u||t[28]!==x||t[29]!==i?(k=x?()=>u?.(i,n.message.id):void 0,t[26]=n.message.id,t[27]=u,t[28]=x,t[29]=i,t[30]=k):k=t[30];let A;t[31]!==n.message.role||t[32]!==n.parts||t[33]!==o||t[34]!==s||t[35]!==a||t[36]!==m?(A=n.parts.length===0?(0,Q.jsx)(`span`,{className:`opacity-50`,children:`...`}):(0,Q.jsx)(ri,{parts:n.parts,pendingAskRequests:a,onAskResponse:o,onNavigateToSubagent:s,inverted:n.message.role===`user`,serverUrl:m}),t[31]=n.message.role,t[32]=n.parts,t[33]=o,t[34]=s,t[35]=a,t[36]=m,t[37]=A):A=t[37];let j;return t[38]!==S||t[39]!==n.isQueued||t[40]!==n.message||t[41]!==O||t[42]!==k||t[43]!==A||t[44]!==w||t[45]!==T||t[46]!==E||t[47]!==D?(j=(0,Q.jsx)(Gn,{message:C,textContent:w,isQueued:n.isQueued,onRemove:T,canRevert:E,onRevert:D,canFork:O,onFork:k,isClearAll:S,children:A}),t[38]=S,t[39]=n.isQueued,t[40]=n.message,t[41]=O,t[42]=k,t[43]=A,t[44]=w,t[45]=T,t[46]=E,t[47]=D,t[48]=j):j=t[48],j});function ai({displayItems:e,messagesWithParts:t,sessionId:n,sessionStatus:r,pendingAskRequests:i,isCompacting:a=!1,compactionSuccess:o=!1,onClearCompactionSuccess:s,onAskResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,onCompact:p,isMainActiveSession:m=!1,autoFollow:h=!0,onAutoScrollChange:g,scrollToBottomRef:_,serverUrl:v}){let y=(0,Z.useRef)(null),[b,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(h),C=(0,Z.useRef)(e.length),w=(0,Z.useRef)(0),T=(0,Z.useRef)(!1),E=(0,Z.useRef)(!1),D=(0,Z.useRef)(``),O=(0,Z.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}:${qe(t.message)?t.message.status:`n/a`}:${t.parts.length}:${n}`},[]),k=(0,Z.useRef)(null),A=(0,Z.useRef)(null),j=(0,Z.useRef)(new Map),M=(0,Z.useRef)(e);M.current=e;let N=(0,Z.useCallback)(e=>{let t=M.current[e];if(!t)return Kr+Jr;if(t.message.role===`assistant`){let e=100;return t.parts.some(e=>e.type===`text`&&e.text?.includes("```")||e.type===`tool`&&e.state.input?.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),t.message.status===`error`&&(e=100),Math.min(Math.max(e+Jr,Kr+Jr),qr+Jr)}let n=t.parts.length>1?80:60;return Math.min(Math.max(n+Jr,Kr+Jr),qr+Jr)},[]);(0,Z.useLayoutEffect)(()=>{let e=y.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);j.current.set(n,e.offsetHeight)})});return()=>cancelAnimationFrame(t)},[e.length]);let P=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{let e=y.current;if(!e)return;P.current&&P.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;j.current.set(r,i)})});return P.current=t,e.querySelectorAll(`[data-index]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length]);let F=Wn({count:e.length,getScrollElement:()=>y.current,estimateSize:N,overscan:5,getItemKey:t=>e[t]?.message?.id??`fallback-${t}`});(0,Z.useLayoutEffect)(()=>{S.current=h,C.current=e.length,w.current=0,T.current=!1,D.current=``,e.length!==0&&(F.scrollToIndex(e.length-1,{align:`end`}),T.current=!0)},[n]),(0,Z.useEffect)(()=>{let e=y.current;if(!e)return;let t=0,n=e=>{S.current&&e.deltaY<0&&(S.current=!1,g?.(!1))},r=e=>{t=e.touches[0]?.clientY??0},i=e=>{S.current&&(e.touches[0]?.clientY??0)>t+5&&(S.current=!1,g?.(!1))};return e.addEventListener(`wheel`,n,{passive:!1}),e.addEventListener(`touchstart`,r,{passive:!0}),e.addEventListener(`touchmove`,i,{passive:!0}),()=>{e.removeEventListener(`wheel`,n),e.removeEventListener(`touchstart`,r),e.removeEventListener(`touchmove`,i)}},[g]);let I=wn(()=>{if(E.current)return;let e=y.current;if(e)if(S.current){let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r>0&&(E.current=!0,e.scrollTop=n,requestAnimationFrame(()=>{E.current=!1}))}else{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<=5&&(S.current=!0,g?.(!0))}});(0,Z.useLayoutEffect)(()=>{x(a)},[a]);let L=O(e);(0,Z.useLayoutEffect)(()=>{let t=e.length,n=C.current,r=t!==n,i=L,a=i!==D.current;D.current=i;let o=t-1,s=0;o>=0&&(s=j.current.get(o)??0);let c=w.current,l=o>=0&&s>c&&c>0;if(C.current=t,w.current=s,!(t===0||!r&&!a&&!l)){if(n===0&&t>0&&c===0&&!T.current){F.scrollToIndex(t-1,{align:`end`}),T.current=!0;return}S.current&&(y.current.scrollTop=y.current.scrollHeight)}},[e.length,L,F]),(0,Z.useEffect)(()=>{let t=F.getVirtualItems(),n=t.length-1;if(n<0)return;let r=t[n],i=y.current?.querySelector(`[data-index="${r.index}"]`);if(k.current&&k.current.disconnect(),i&&(A.current=i,!(!Yr(e)||!S.current)))return k.current=new ResizeObserver(t=>{S.current&&Yr(e)&&requestAnimationFrame(()=>{S.current&&(y.current.scrollTop=y.current.scrollHeight)})}),k.current.observe(i),()=>{k.current&&=(k.current.disconnect(),null)}},[e,F]),(0,Z.useEffect)(()=>{if(o){let e=setTimeout(()=>{s?.()},3e3);return()=>clearTimeout(e)}},[o,s]),(0,Z.useLayoutEffect)(()=>{_&&(_.current=()=>{S.current=!0,E.current=!0,y.current.scrollTop=y.current.scrollHeight,requestAnimationFrame(()=>{E.current=!1})})},[_]),(0,Z.useLayoutEffect)(()=>{S.current=h},[h]);let R=F.getVirtualItems();return(0,Q.jsxs)(`div`,{ref:y,className:`flex-1 min-h-0 overflow-y-auto relative chat-transcript-scrollbar`,style:{WebkitOverflowScrolling:`touch`},onScroll:I,children:[b&&(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)(Qr,{})}),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)($r,{})}),r===`closed`&&(0,Q.jsx)(Te,{className:`mx-4 mt-4`,children:(0,Q.jsx)(be,{children:`This session is archived. You can reopen it from the sidebar.`})}),(0,Q.jsx)(`div`,{className:`relative w-full`,style:{height:`${F.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(${R[0]?.start??0}px)`},children:R.map(r=>{let o=e[r.index];return(0,Q.jsx)(`div`,{"data-index":r.index,ref:F.measureElement,className:`px-4 py-4`,children:(0,Q.jsx)(ii,{item:o,messagesWithParts:t,sessionId:n,pendingAskRequests:i,onAskResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,isMainActiveSession:m,isCompacting:a,onCompact:p,serverUrl:v})},o.message.id)})})})]})}function oi(e,t){return e.createdAt-t.createdAt}function si(e){return e.type===`compaction`}function ci(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=>{let r=n(e.sessionId,t.id,t.accessKey??``);return t.kind===`image`?{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`image`,url:r,mimeType:t.mimeType}:{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`file`,url:r,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 li(e){let t=(0,$.c)(97),{session:n,messagesWithParts:r,queuedMessages:i,preconfigs:a,prompts:o,models:s,defaultModel:c,onSendMessage:l,onRemoveFromQueue:u,onChangePreconfig:d,onChangeModel:f,onChangeVariant:p,pendingAskRequests:m,onAskResponse:h,onRename:g,usage:_,modelName:v,modelSupportsImage:y,onNavigateToSubagent:b,onNavigateBack:x,isStreaming:S,onInterrupt:C,onRevert:w,onFork:T,onCompact:E,isCompacting:D,compactionSuccess:O,onClearCompactionSuccess:k,serverUrl:A,sdkClient:j,selectedVariant:M,variants:N,inputRef:P,scrollToBottomRef:F,autoFollowToggleRef:I,onClaimControl:L,onReleaseControl:R,onRequestTakeover:z,onRespondTakeover:B}=e,V=!n.parentId&&n.status===`active`,H;t[0]===n.id?H=t[1]:(H=e=>e.controlBySessionId[n.id],t[0]=n.id,t[1]=H);let U=we(H),W=fe(di),ee=U?.status===`controlled`&&U.controllerClientId!==W,G=U?.status===`grace`,te=ee||G,[ne,re]=(0,Z.useState)(null),ie=(0,Z.useRef)(null),ae;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{ie.current&&clearTimeout(ie.current),re(e),ie.current=setTimeout(()=>{re(null),ie.current=null},4e3)},t[2]=ae):ae=t[2];let oe=ae,se,K;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>()=>{ie.current&&clearTimeout(ie.current)},K=[],t[3]=se,t[4]=K):(se=t[3],K=t[4]),(0,Z.useEffect)(se,K);let q,ce;t[5]===n.id?(q=t[6],ce=t[7]):(q=()=>{let e=null;return we.subscribe(t=>{t.lastActionRejection!==e&&(e=t.lastActionRejection,e&&e.sessionId===n.id&&oe(e.message))})},ce=[n.id,oe],t[5]=n.id,t[6]=q,t[7]=ce),(0,Z.useEffect)(q,ce);let[le,ue]=(0,Z.useState)(!0),J;t[8]===F?J=t[9]:(J=()=>{ue(e=>{let t=!e;return t&&F?.current?.(),t})},t[8]=F,t[9]=J);let pe=J,me,ge;t[10]!==I||t[11]!==pe?(me=()=>{I&&(I.current={toggle:()=>{pe()}})},ge=[I,pe],t[10]=I,t[11]=pe,t[12]=me,t[13]=ge):(me=t[12],ge=t[13]),(0,Z.useEffect)(me,ge);let _e=j?.http.attachments.getUrl??ui,ve;t[14]!==r||t[15]!==i||t[16]!==_e?(ve=ci(r,i,_e),t[14]=r,t[15]=i,t[16]=_e,t[17]=ve):ve=t[17];let ye=ve,be=r.length>=2,xe;t[18]!==c||t[19]!==D||t[20]!==S||t[21]!==v||t[22]!==s||t[23]!==f||t[24]!==d||t[25]!==p||t[26]!==L||t[27]!==E||t[28]!==C||t[29]!==x||t[30]!==R||t[31]!==g||t[32]!==z||t[33]!==B||t[34]!==a||t[35]!==M||t[36]!==n||t[37]!==be||t[38]!==_||t[39]!==N?(xe=(0,Q.jsx)(Yt,{session:n,preconfigs:a,models:s,defaultModel:c,usage:_,modelName:v,onChangePreconfig:d,onChangeModel:f,onChangeVariant:p,onRename:g,onNavigateBack:x,isStreaming:S,onInterrupt:C,onCompact:E,isCompacting:D,canCompact:be,selectedVariant:M,variants:N,onClaimControl:L,onReleaseControl:R,onRequestTakeover:z,onRespondTakeover:B}),t[18]=c,t[19]=D,t[20]=S,t[21]=v,t[22]=s,t[23]=f,t[24]=d,t[25]=p,t[26]=L,t[27]=E,t[28]=C,t[29]=x,t[30]=R,t[31]=g,t[32]=z,t[33]=B,t[34]=a,t[35]=M,t[36]=n,t[37]=be,t[38]=_,t[39]=N,t[40]=xe):xe=t[40];let Se;t[41]!==T||t[42]!==w||t[43]!==le||t[44]!==O||t[45]!==ye||t[46]!==D||t[47]!==V||t[48]!==r||t[49]!==h||t[50]!==k||t[51]!==E||t[52]!==b||t[53]!==u||t[54]!==m||t[55]!==F||t[56]!==A||t[57]!==n.id||t[58]!==n.status?(Se=(0,Q.jsx)(ai,{displayItems:ye,messagesWithParts:r,sessionId:n.id,sessionStatus:n.status,pendingAskRequests:m,isCompacting:D,compactionSuccess:O,onClearCompactionSuccess:k,onAskResponse:h,onNavigateToSubagent:b,onRemoveFromQueue:u,onRevert:w,onFork:T,onCompact:E,isMainActiveSession:V,autoFollow:le,onAutoScrollChange:ue,scrollToBottomRef:F,serverUrl:A}),t[41]=T,t[42]=w,t[43]=le,t[44]=O,t[45]=ye,t[46]=D,t[47]=V,t[48]=r,t[49]=h,t[50]=k,t[51]=E,t[52]=b,t[53]=u,t[54]=m,t[55]=F,t[56]=A,t[57]=n.id,t[58]=n.status,t[59]=Se):Se=t[59];let Ce=le?`Auto-follow enabled (Cmd+Shift+F)`:`Auto-follow disabled (Cmd+Shift+F)`,Te;t[60]===le?Te=t[61]:(Te=le?(0,Q.jsx)(Je,{className:`size-3.5`}):(0,Q.jsx)(de,{className:`size-3.5`}),t[60]=le,t[61]=Te);let Ee;t[62]!==pe||t[63]!==Ce||t[64]!==Te?(Ee=(0,Q.jsx)(`button`,{onClick:pe,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:Ce,children:Te}),t[62]=pe,t[63]=Ce,t[64]=Te,t[65]=Ee):Ee=t[65];let De;t[66]!==Se||t[67]!==Ee?(De=(0,Q.jsxs)(`div`,{className:`relative flex flex-col flex-1 min-h-0`,children:[Se,Ee]}),t[66]=Se,t[67]=Ee,t[68]=De):De=t[68];let Oe;t[69]!==P||t[70]!==D||t[71]!==te||t[72]!==y||t[73]!==l||t[74]!==o||t[75]!==j||t[76]!==n.id||t[77]!==n.parentId||t[78]!==n.status||t[79]!==n.workspaceId?(Oe=n.status===`active`&&!n.parentId&&(0,Q.jsx)(xn,{ref:P,onSendMessage:l,disabled:D||te,workspaceId:n.workspaceId,sdkClient:j,prompts:o,sessionId:n.id,modelSupportsImage:y}),t[69]=P,t[70]=D,t[71]=te,t[72]=y,t[73]=l,t[74]=o,t[75]=j,t[76]=n.id,t[77]=n.parentId,t[78]=n.status,t[79]=n.workspaceId,t[80]=Oe):Oe=t[80];let ke;t[81]===n.parentId?ke=t[82]:(ke=n.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)(he,{className:`size-4`}),`This is a subagent session (read-only)`]}),t[81]=n.parentId,t[82]=ke);let Ae;t[83]===ee?Ae=t[84]:(Ae=ee&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-border bg-muted/30 text-center flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(dt,{className:`size-3.5`}),`You are observing this session. Input is disabled.`]}),t[83]=ee,t[84]=Ae);let je;t[85]===G?je=t[86]:(je=G&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-yellow-500/30 bg-yellow-50 dark:bg-yellow-950/30 text-center flex items-center justify-center gap-2 text-xs text-yellow-600 dark:text-yellow-400`,children:[(0,Q.jsx)(mt,{className:`size-3.5`}),`Reconnecting to session… waiting for control to be restored.`]}),t[85]=G,t[86]=je);let Me;t[87]===ne?Me=t[88]:(Me=ne&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-orange-500/30 bg-orange-50 dark:bg-orange-950/30 text-center flex items-center justify-center gap-2 text-xs text-orange-600 dark:text-orange-400`,children:[(0,Q.jsx)(dt,{className:`size-3.5`}),ne]}),t[87]=ne,t[88]=Me);let Ne;return t[89]!==xe||t[90]!==De||t[91]!==Oe||t[92]!==ke||t[93]!==Ae||t[94]!==je||t[95]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 relative`,children:[xe,De,Oe,ke,Ae,je,Me]}),t[89]=xe,t[90]=De,t[91]=Oe,t[92]=ke,t[93]=Ae,t[94]=je,t[95]=Me,t[96]=Ne):Ne=t[96],Ne}function ui(e,t,n){return`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`}function di(e){return e.clientId}function fi(e){let t=(0,$.c)(77),{serverUrl:n,messagesWithParts:r,inputRef:i,sdkClient:a,onRetry:o,onLogout:c,onSendMessage:u,onRemoveFromQueue:d,onChangePreconfig:f,onChangeModel:p,onChangeVariant:m,onAskResponse:g,onRename:_,onNavigateToSubagent:v,onNavigateBack:y,onInterrupt:b,onRevert:x,onFork:S,onCompact:C,onClearCompactionSuccess:w,scrollToBottomRef:T,autoFollowToggleRef:E,onClaimControl:D,onReleaseControl:O,onRequestTakeover:k,onRespondTakeover:A}=e,j=R(ji),M=R(Ai),N=R(ki),P=R(Oi),F=R(Di),I=R(Ei),L=s(Ti),z=s(wi),B=s(Ci),V=s(Si),H=s(xi),U=s(bi),W=h(yi),ee=h(vi),G=h(_i),te=h(gi),ne=l(hi),re;t[0]===W?re=t[1]:(re=W.filter(mi),t[0]=W,t[1]=re);let ie=re,ae=!L?.parentId,oe=L?.compacting??!1,se;t[2]===f?se=t[3]:(se=e=>{f(e)},t[2]=f,t[3]=se);let K=se,q;t[4]===m?q=t[5]:(q=e=>{m(e)},t[4]=m,t[5]=q);let ce=q,le;t[6]===b?le=t[7]:(le=()=>{b()},t[6]=b,t[7]=le);let ue=le;if(!j){if(N){let e;return t[8]!==M||t[9]!==F||t[10]!==c||t[11]!==o||t[12]!==P||t[13]!==n?(e=(0,Q.jsx)(`div`,{className:`flex w-full h-full items-center justify-center bg-background`,children:(0,Q.jsx)(Nt,{serverUrl:n,authError:M,retryCount:P,nextRetryIn:F,onRetry:o,onLogout:c})}),t[8]=M,t[9]=F,t[10]=c,t[11]=o,t[12]=P,t[13]=n,t[14]=e):e=t[14],e}let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Mt,{}),t[15]=e):e=t[15];let r;return t[16]===c?r=t[17]:(r=(0,Q.jsxs)(`div`,{className:`flex flex-col w-full h-full items-center justify-center bg-background gap-4`,children:[e,(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:c,className:`text-muted-foreground`,children:`Change Server`})]}),t[16]=c,t[17]=r),r}if(!L){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(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.`})]}),t[18]=e):e=t[18],e}let J;t[19]===r?J=t[20]:(J=r.filter(pi),t[19]=r,t[20]=J);let de=J.length>=2,fe;if(t[21]!==V||t[22]!==G){let e;t[24]===V?e=t[25]:(e=e=>e.id===V,t[24]=V,t[25]=e),fe=G.find(e),t[21]=V,t[22]=G,t[23]=fe}else fe=t[23];let pe=fe,me;t[26]!==L.id||t[27]!==z?(me=z[L.id]||[],t[26]=L.id,t[27]=z,t[28]=me):me=t[28];let he=ae?ie:W,ge=pe?.variants,_e=pe?.capabilities?.input?.image??!1,ve;t[29]!==L.id||t[30]!==L.runningAt||t[31]!==I?(ve=I.has(L.id)||!!L.runningAt,t[29]=L.id,t[30]=L.runningAt,t[31]=I,t[32]=ve):ve=t[32];let ye;t[33]!==de||t[34]!==L.id||t[35]!==C?(ye=de?()=>C(L.id):void 0,t[33]=de,t[34]=L.id,t[35]=C,t[36]=ye):ye=t[36];let be=n??void 0,xe;return t[37]!==E||t[38]!==U||t[39]!==V||t[40]!==L||t[41]!==te||t[42]!==K||t[43]!==ce||t[44]!==ue||t[45]!==i||t[46]!==oe||t[47]!==r||t[48]!==G||t[49]!==g||t[50]!==p||t[51]!==D||t[52]!==w||t[53]!==S||t[54]!==y||t[55]!==v||t[56]!==O||t[57]!==d||t[58]!==_||t[59]!==k||t[60]!==A||t[61]!==x||t[62]!==u||t[63]!==ne||t[64]!==ee||t[65]!==T||t[66]!==a||t[67]!==H||t[68]!==B||t[69]!==_e||t[70]!==ve||t[71]!==ye||t[72]!==be||t[73]!==me||t[74]!==he||t[75]!==ge?(xe=(0,Q.jsx)(li,{inputRef:i,session:L,messagesWithParts:r,queuedMessages:me,preconfigs:he,prompts:ee,models:G,defaultModel:te,onSendMessage:u,onRemoveFromQueue:d,onChangePreconfig:K,onChangeModel:p,onChangeVariant:ce,selectedVariant:H,variants:ge,pendingAskRequests:ne,onAskResponse:g,onRename:_,usage:B,modelName:V,modelSupportsImage:_e,onNavigateToSubagent:v,onNavigateBack:y,isStreaming:ve,onInterrupt:ue,onRevert:x,onFork:S,onCompact:ye,isCompacting:oe,compactionSuccess:U,onClearCompactionSuccess:w,serverUrl:be,sdkClient:a,scrollToBottomRef:T,autoFollowToggleRef:E,onClaimControl:D,onReleaseControl:O,onRequestTakeover:k,onRespondTakeover:A}),t[37]=E,t[38]=U,t[39]=V,t[40]=L,t[41]=te,t[42]=K,t[43]=ce,t[44]=ue,t[45]=i,t[46]=oe,t[47]=r,t[48]=G,t[49]=g,t[50]=p,t[51]=D,t[52]=w,t[53]=S,t[54]=y,t[55]=v,t[56]=O,t[57]=d,t[58]=_,t[59]=k,t[60]=A,t[61]=x,t[62]=u,t[63]=ne,t[64]=ee,t[65]=T,t[66]=a,t[67]=H,t[68]=B,t[69]=_e,t[70]=ve,t[71]=ye,t[72]=be,t[73]=me,t[74]=he,t[75]=ge,t[76]=xe):xe=t[76],xe}function pi(e){return e.message.role!==`system`}function mi(e){return e.mode!==`subagent`}function hi(e){return e.pendingRequests}function gi(e){return e.defaultModel}function _i(e){return e.models}function vi(e){return e.prompts}function yi(e){return e.preconfigs}function bi(e){return e.compactionSuccess}function xi(e){return e.selectedVariant}function Si(e){return e.currentModel}function Ci(e){return e.sessionUsage}function wi(e){return e.queuedMessages}function Ti(e){return e.currentSession}function Ei(e){return e.streamingSessionIds}function Di(e){return e.nextRetryIn}function Oi(e){return e.retryCount}function ki(e){return e.connectionTimedOut}function Ai(e){return e.authError}function ji(e){return e.connected}function Mi(){let e=(0,$.c)(30),t=_(),{chatInputRef:n,scrollToBottomRef:r,autoFollowToggleRef:i}=u(),{sdkClient:a,messagesWithParts:o,serverUrl:s,currentSession:c,isSessionLoading:l,resumeSession:d,revertSession:f,forkSession:p,compactSession:m,removeFromQueue:h,sendChatMessage:g,handleAskResponse:v,handleInterruptSession:y,updateSessionPreconfig:b,updateSessionModel:x,updateSessionVariant:S,handleNavigateBack:C,handleRenameSession:w,setCompactionSuccess:T}=t;if(l){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(jt,{}),e[0]=t):t=e[0],t}if(!c)return null;let E;e[1]===T?E=e[2]:(E=()=>T(!1),e[1]=T,e[2]=E);let D;return e[3]!==i||e[4]!==n||e[5]!==m||e[6]!==p||e[7]!==v||e[8]!==y||e[9]!==C||e[10]!==w||e[11]!==o||e[12]!==h||e[13]!==d||e[14]!==f||e[15]!==r||e[16]!==a||e[17]!==g||e[18]!==s||e[19]!==t.claimControl||e[20]!==t.handleLogout||e[21]!==t.handleRetry||e[22]!==t.releaseControl||e[23]!==t.requestTakeover||e[24]!==t.respondTakeover||e[25]!==E||e[26]!==x||e[27]!==b||e[28]!==S?(D=(0,Q.jsx)(fi,{sdkClient:a,inputRef:n,messagesWithParts:o,serverUrl:s,onRetry:t.handleRetry,onLogout:t.handleLogout,onSendMessage:g,onRemoveFromQueue:h,onChangePreconfig:b,onChangeModel:x,onChangeVariant:S,onAskResponse:v,onRename:w,onNavigateToSubagent:d,onNavigateBack:C,onInterrupt:y,onRevert:f,onFork:p,onCompact:m,onClearCompactionSuccess:E,scrollToBottomRef:r,autoFollowToggleRef:i,onClaimControl:t.claimControl,onReleaseControl:t.releaseControl,onRequestTakeover:t.requestTakeover,onRespondTakeover:t.respondTakeover}),e[3]=i,e[4]=n,e[5]=m,e[6]=p,e[7]=v,e[8]=y,e[9]=C,e[10]=w,e[11]=o,e[12]=h,e[13]=d,e[14]=f,e[15]=r,e[16]=a,e[17]=g,e[18]=s,e[19]=t.claimControl,e[20]=t.handleLogout,e[21]=t.handleRetry,e[22]=t.releaseControl,e[23]=t.requestTakeover,e[24]=t.respondTakeover,e[25]=E,e[26]=x,e[27]=b,e[28]=S,e[29]=D):D=e[29],D}export{Mi as t};