tarsk 0.4.29 → 0.4.30

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 (74) hide show
  1. package/dist/index.js +745 -348
  2. package/dist/public/assets/{account-view-YvC0mymF.js → account-view-wqPOnMfW.js} +1 -1
  3. package/dist/public/assets/{alert-dialog-BFhUZsPe.js → alert-dialog-Dj0hDlZC.js} +1 -1
  4. package/dist/public/assets/{api-DSvSyBH5.js → api-RbLAI1bg.js} +1 -1
  5. package/dist/public/assets/{browser-tab-CCXMlmPO.js → browser-tab-BjqSmZHm.js} +1 -1
  6. package/dist/public/assets/chat-input-container-BNOl7YtC.js +21 -0
  7. package/dist/public/assets/context-menu-XD6khGRr.js +1 -0
  8. package/dist/public/assets/conversation-history-view-BRSNoBYn.js +1 -0
  9. package/dist/public/assets/{dialogs-config-B91VQpxo.js → dialogs-config-BXDglGdB.js} +14 -14
  10. package/dist/public/assets/diff-view-DiNlWcSj.js +3 -0
  11. package/dist/public/assets/{explorer-tab-view-B1DukGdo.js → explorer-tab-view-DbMBihAH.js} +2 -2
  12. package/dist/public/assets/{explorer-tree-DCeud6YI.js → explorer-tree-D0P-HUYS.js} +1 -1
  13. package/dist/public/assets/{explorer-view-BCJqE1-z.js → explorer-view-CL_9lhkq.js} +1 -1
  14. package/dist/public/assets/history-view-i7fGKCkc.js +1 -0
  15. package/dist/public/assets/index-BeLCtY82.css +1 -0
  16. package/dist/public/assets/index-CZZ6Jb9i.js +29 -0
  17. package/dist/public/assets/{markdown-renderer-9nzN0Pk3.js → markdown-renderer-CPSKOcqK.js} +3 -3
  18. package/dist/public/assets/mcp-server-card-DFATg_Ie.js +1 -0
  19. package/dist/public/assets/onboarding-5CTkrfwe.js +1 -0
  20. package/dist/public/assets/onboarding-dialog-gcZ9aKKp.js +1 -0
  21. package/dist/public/assets/{page-toolbar-DnVFnCgq.js → page-toolbar-CbwENcML.js} +1 -1
  22. package/dist/public/assets/project-settings-view-CRRJPGNL.js +1 -0
  23. package/dist/public/assets/providers-list-view-D3CIB4ou.js +1 -0
  24. package/dist/public/assets/radio-group-qCcnwXV3.js +1 -0
  25. package/dist/public/assets/react-vendor-Bpg1hd5i.js +22 -0
  26. package/dist/public/assets/{resizable-CEv7JjTI.js → resizable-BLhzHL_f.js} +1 -1
  27. package/dist/public/assets/{run-stop-button-CrjPMC0m.js → run-stop-button-CIuDOHFg.js} +2 -2
  28. package/dist/public/assets/settings-general-view-7Y0c9534.js +1 -0
  29. package/dist/public/assets/{settings-instructions-view-C23spY9Y.js → settings-instructions-view-B-uTQrNZ.js} +1 -1
  30. package/dist/public/assets/settings-mcp-servers-view-nAMQQWHb.js +5 -0
  31. package/dist/public/assets/settings-models-skeleton-CffyGIvJ.js +1 -0
  32. package/dist/public/assets/settings-models-view-CMZh5LlR.js +1 -0
  33. package/dist/public/assets/settings-rules-view-BaNccq1v.js +8 -0
  34. package/dist/public/assets/{settings-skills-view-D60tD-OE.js → settings-skills-view-DBX7obT7.js} +2 -2
  35. package/dist/public/assets/{settings-slash-commands-view-DR-pzulT.js → settings-slash-commands-view-BoT1nCir.js} +1 -1
  36. package/dist/public/assets/settings-subagents-view-Cy87X2bs.js +2 -0
  37. package/dist/public/assets/settings-view-CS-RnV6J.js +2 -0
  38. package/dist/public/assets/{side-panel-container-CO3qgRvc.js → side-panel-container-B33_hnhc.js} +2 -2
  39. package/dist/public/assets/{skeleton-CXoVAzC1.js → skeleton-n47_ST9G.js} +1 -1
  40. package/dist/public/assets/{standard-list-item-DyALhVYe.js → standard-list-item-BLTOBGFa.js} +1 -1
  41. package/dist/public/assets/{store-D28g9VUj.js → store-B9rEO6q-.js} +1 -1
  42. package/dist/public/assets/{tab-context-C3z7YU59.js → tab-context-BUUT3x3d.js} +1 -1
  43. package/dist/public/assets/{tabs-sXgL2DZz.js → tabs--5y6mYhG.js} +1 -1
  44. package/dist/public/assets/{terminal-panel-EifoA6G0.js → terminal-panel-BCHLDUbD.js} +2 -2
  45. package/dist/public/assets/{textarea-Bp3p1-25.js → textarea-CwXpBxom.js} +1 -1
  46. package/dist/public/assets/todos-view-k0k8R9NT.js +1 -0
  47. package/dist/public/assets/use-font-size-BJl84s49.js +1 -0
  48. package/dist/public/assets/{use-toast-BZ79E_dX.js → use-toast-C5s-Xnwi.js} +1 -1
  49. package/dist/public/assets/{utils-Bhu11Tpg.js → utils-CDrGT12s.js} +1 -1
  50. package/dist/public/index.html +21 -21
  51. package/package.json +2 -2
  52. package/dist/public/assets/chat-input-container-VwmGKJFJ.js +0 -21
  53. package/dist/public/assets/context-menu-B6K8j1ha.js +0 -1
  54. package/dist/public/assets/conversation-history-view-DrrLyMbg.js +0 -1
  55. package/dist/public/assets/diff-view-C09yOc5d.js +0 -3
  56. package/dist/public/assets/history-view-Dj4NiScy.js +0 -1
  57. package/dist/public/assets/index-7TFkb0ll.css +0 -1
  58. package/dist/public/assets/index-BLCecayZ.js +0 -29
  59. package/dist/public/assets/mcp-server-card-BSw_FlEC.js +0 -1
  60. package/dist/public/assets/onboarding-ClUE_I5q.js +0 -1
  61. package/dist/public/assets/onboarding-dialog-C2jig8mT.js +0 -1
  62. package/dist/public/assets/project-settings-view-DWn0ty7b.js +0 -1
  63. package/dist/public/assets/providers-list-view-B0DqNJYK.js +0 -1
  64. package/dist/public/assets/radio-group-CM_Wwam0.js +0 -1
  65. package/dist/public/assets/react-vendor-nPkCWaAR.js +0 -22
  66. package/dist/public/assets/settings-general-view-CwQYmnI2.js +0 -1
  67. package/dist/public/assets/settings-mcp-servers-view-ZHar6YbE.js +0 -5
  68. package/dist/public/assets/settings-models-view-Cg6WQ4cy.js +0 -1
  69. package/dist/public/assets/settings-rules-view-zAx5JL4w.js +0 -8
  70. package/dist/public/assets/settings-subagents-view-InXmwmw9.js +0 -2
  71. package/dist/public/assets/settings-view-DLRDBuwH.js +0 -2
  72. package/dist/public/assets/todos-view-DRL4px6A.js +0 -1
  73. package/dist/public/assets/use-font-size-BCtvz0bm.js +0 -1
  74. /package/dist/public/assets/{dist-D5DgwfYL.js → dist-CAVGqbBm.js} +0 -0
@@ -19,31 +19,31 @@
19
19
  <meta name="apple-mobile-web-app-title" content="Tarsk" />
20
20
 
21
21
  <title>Tarsk</title>
22
- <script type="module" crossorigin src="/assets/index-BLCecayZ.js"></script>
22
+ <script type="module" crossorigin src="/assets/index-CZZ6Jb9i.js"></script>
23
23
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-B1FJdls4.js">
24
24
  <link rel="modulepreload" crossorigin href="/assets/monaco-BGyhgQtx.js">
25
- <link rel="modulepreload" crossorigin href="/assets/dialogs-config-B91VQpxo.js">
26
- <link rel="modulepreload" crossorigin href="/assets/history-view-Dj4NiScy.js">
27
- <link rel="modulepreload" crossorigin href="/assets/onboarding-ClUE_I5q.js">
28
- <link rel="modulepreload" crossorigin href="/assets/react-vendor-nPkCWaAR.js">
29
- <link rel="modulepreload" crossorigin href="/assets/alert-dialog-BFhUZsPe.js">
30
- <link rel="modulepreload" crossorigin href="/assets/use-toast-BZ79E_dX.js">
31
- <link rel="modulepreload" crossorigin href="/assets/store-D28g9VUj.js">
32
- <link rel="modulepreload" crossorigin href="/assets/tab-context-C3z7YU59.js">
25
+ <link rel="modulepreload" crossorigin href="/assets/dialogs-config-BXDglGdB.js">
26
+ <link rel="modulepreload" crossorigin href="/assets/history-view-i7fGKCkc.js">
27
+ <link rel="modulepreload" crossorigin href="/assets/onboarding-5CTkrfwe.js">
28
+ <link rel="modulepreload" crossorigin href="/assets/react-vendor-Bpg1hd5i.js">
29
+ <link rel="modulepreload" crossorigin href="/assets/alert-dialog-Dj0hDlZC.js">
30
+ <link rel="modulepreload" crossorigin href="/assets/use-toast-C5s-Xnwi.js">
31
+ <link rel="modulepreload" crossorigin href="/assets/store-B9rEO6q-.js">
32
+ <link rel="modulepreload" crossorigin href="/assets/tab-context-BUUT3x3d.js">
33
33
  <link rel="modulepreload" crossorigin href="/assets/whisper-wasm-C_Ot631g.js">
34
- <link rel="modulepreload" crossorigin href="/assets/utils-Bhu11Tpg.js">
35
- <link rel="modulepreload" crossorigin href="/assets/chat-input-container-VwmGKJFJ.js">
36
- <link rel="modulepreload" crossorigin href="/assets/markdown-renderer-9nzN0Pk3.js">
37
- <link rel="modulepreload" crossorigin href="/assets/page-toolbar-DnVFnCgq.js">
38
- <link rel="modulepreload" crossorigin href="/assets/run-stop-button-CrjPMC0m.js">
39
- <link rel="modulepreload" crossorigin href="/assets/side-panel-container-CO3qgRvc.js">
40
- <link rel="modulepreload" crossorigin href="/assets/resizable-CEv7JjTI.js">
41
- <link rel="modulepreload" crossorigin href="/assets/standard-list-item-DyALhVYe.js">
42
- <link rel="modulepreload" crossorigin href="/assets/tabs-sXgL2DZz.js">
43
- <link rel="modulepreload" crossorigin href="/assets/textarea-Bp3p1-25.js">
44
- <link rel="modulepreload" crossorigin href="/assets/use-font-size-BCtvz0bm.js">
34
+ <link rel="modulepreload" crossorigin href="/assets/utils-CDrGT12s.js">
35
+ <link rel="modulepreload" crossorigin href="/assets/chat-input-container-BNOl7YtC.js">
36
+ <link rel="modulepreload" crossorigin href="/assets/markdown-renderer-CPSKOcqK.js">
37
+ <link rel="modulepreload" crossorigin href="/assets/page-toolbar-CbwENcML.js">
38
+ <link rel="modulepreload" crossorigin href="/assets/run-stop-button-CIuDOHFg.js">
39
+ <link rel="modulepreload" crossorigin href="/assets/side-panel-container-B33_hnhc.js">
40
+ <link rel="modulepreload" crossorigin href="/assets/resizable-BLhzHL_f.js">
41
+ <link rel="modulepreload" crossorigin href="/assets/standard-list-item-BLTOBGFa.js">
42
+ <link rel="modulepreload" crossorigin href="/assets/tabs--5y6mYhG.js">
43
+ <link rel="modulepreload" crossorigin href="/assets/textarea-CwXpBxom.js">
44
+ <link rel="modulepreload" crossorigin href="/assets/use-font-size-BJl84s49.js">
45
45
  <link rel="stylesheet" crossorigin href="/assets/monaco-Br_kD0ds.css">
46
- <link rel="stylesheet" crossorigin href="/assets/index-7TFkb0ll.css">
46
+ <link rel="stylesheet" crossorigin href="/assets/index-BeLCtY82.css">
47
47
  </head>
48
48
  <body class="font-sans antialiased">
49
49
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tarsk",
3
- "version": "0.4.29",
3
+ "version": "0.4.30",
4
4
  "description": "CLI for Tarsk - Project Threads Manager",
5
5
  "keywords": [
6
6
  "cli",
@@ -28,7 +28,7 @@
28
28
  "build": "bun run build:app-assets && bun run build:server && electrobun build --targets macos-arm64",
29
29
  "start": "bun run dev",
30
30
  "lint": "bunx tsgo --noEmit",
31
- "test": "vp test run",
31
+ "test": "env -u TARSK_DEBUG vp test run",
32
32
  "web": "MODE=development bun run build:server && bun dist/index.js",
33
33
  "api-serve-462": "bun run build:server && MODE=development bun dist/index.js --debug",
34
34
  "electrobun:dev:signed": "bunx electrobun dev",
@@ -1,21 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$n as t,C as n,Ci as r,Di as i,Gr as a,It as o,Jn as s,Jr as c,Ki as l,Lr as u,Lt as d,Mi as f,Mr as p,Mt as m,Nn as h,Nt as g,O as _,Oi as v,On as y,Pi as b,Qn as x,Qr as S,Rr as C,Rt as w,Sa as T,Ui as E,Un as D,Vi as O,Wr as k,Wt as A,Xn as j,Xr as M,Yn as N,Zn as P,aa as F,ai as I,bn as ee,ca as L,d as te,et as R,gn as ne,h as re,ht as ie,ia as z,it as B,j as V,ki as H,kn as U,la as W,li as G,lt as K,ma as q,mi as J,mn as ae,nn as oe,ot as se,pa as ce,qi as le,qn as ue,rt as de,sa as fe,st as pe,ua as me,ui as he,va as ge,wa as _e,xn as ve,yi as ye,zi as be,zt as xe}from"./dialogs-config-B91VQpxo.js";import{$ as Se,Ct as Ce,G as we,H as Te,J as Ee,K as De,Q as Oe,U as ke,X as Ae,Z as je,et as Me,it as Ne,nt as Pe,q as Fe,rt as Ie,tt as Le}from"./react-vendor-nPkCWaAR.js";import{a as Re,l as ze,s as Be,t as Y,u as Ve}from"./store-D28g9VUj.js";import{c as He,s as Ue,u as We}from"./history-view-Dj4NiScy.js";import{n as Ge,t as Ke}from"./use-toast-BZ79E_dX.js";import{a as qe,c as Je,i as Ye,o as Xe,s as Ze,t as Qe}from"./alert-dialog-BFhUZsPe.js";import{n as $e}from"./tab-context-C3z7YU59.js";import{s as et}from"./onboarding-ClUE_I5q.js";import{i as tt,n as nt,r as rt,t as it}from"./whisper-wasm-C_Ot631g.js";import{n as at}from"./utils-Bhu11Tpg.js";var X=T(),Z=e(_e(),1),Q=p();function ot(e){let t=(0,X.c)(30),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u}=e,d=!!(n.children&&n.children.length>0),f,p,m;if(t[0]!==a||t[1]!==u||t[2]!==d||t[3]!==r||t[4]!==n||t[5]!==l||t[6]!==c||t[7]!==i){f=u?.has(n.id)||(c[n.id]??a);let e;t[11]!==n.id||t[12]!==l?(e=()=>l(n.id),t[11]=n.id,t[12]=l,t[13]=e):e=t[13];let o=e;p=`min-w-0`,m=i(n,{isOpen:f,level:r,toggle:o,hasChildren:d}),t[0]=a,t[1]=u,t[2]=d,t[3]=r,t[4]=n,t[5]=l,t[6]=c,t[7]=i,t[8]=f,t[9]=p,t[10]=m}else f=t[8],p=t[9],m=t[10];let h;t[14]!==s||t[15]!==a||t[16]!==u||t[17]!==d||t[18]!==o||t[19]!==f||t[20]!==r||t[21]!==n.children||t[22]!==l||t[23]!==c||t[24]!==i?(h=d&&f&&(0,Q.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,Q.jsx)(ot,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u},e.id))}),t[14]=s,t[15]=a,t[16]=u,t[17]=d,t[18]=o,t[19]=f,t[20]=r,t[21]=n.children,t[22]=l,t[23]=c,t[24]=i,t[25]=h):h=t[25];let g;return t[26]!==p||t[27]!==m||t[28]!==h?(g=(0,Q.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function st(e){let n=(0,X.c)(27),{nodes:r,renderNode:i,resetKey:a,defaultOpen:o,forceOpenIds:s,indent:c,childContainerClassName:l,className:u}=e,d=o===void 0?!1:o,f=c===void 0?16:c,p;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={},n[0]=p):p=n[0];let[m,h]=(0,Z.useState)(p),[g,_]=(0,Z.useState)(a);a!==g&&(_(a),h({}));let v;n[1]===s?v=n[2]:(v=s?new Set(s):void 0,n[1]=s,n[2]=v);let y=v,b;n[3]===d?b=n[4]:(b=e=>{h(t=>({...t,[e]:!(t[e]??d)}))},n[3]=d,n[4]=b);let x=b,S;n[5]===u?S=n[6]:(S=t(`min-w-0`,u),n[5]=u,n[6]=S);let C;if(n[7]!==l||n[8]!==d||n[9]!==y||n[10]!==x||n[11]!==f||n[12]!==r||n[13]!==m||n[14]!==i){let e;n[16]!==l||n[17]!==d||n[18]!==y||n[19]!==x||n[20]!==f||n[21]!==m||n[22]!==i?(e=e=>(0,Q.jsx)(ot,{node:e,level:0,renderNode:i,defaultOpen:d,indent:f,childContainerClassName:l,openState:m,onToggle:x,forceOpenIds:y},e.id),n[16]=l,n[17]=d,n[18]=y,n[19]=x,n[20]=f,n[21]=m,n[22]=i,n[23]=e):e=n[23],C=r.map(e),n[7]=l,n[8]=d,n[9]=y,n[10]=x,n[11]=f,n[12]=r,n[13]=m,n[14]=i,n[15]=C}else C=n[15];let w;return n[24]!==S||n[25]!==C?(w=(0,Q.jsx)(`div`,{className:S,children:C}),n[24]=S,n[25]=C,n[26]=w):w=n[26],w}var ct=(0,Z.createContext)({todos:[],setTodos:()=>{}});function lt(e){let t=(0,X.c)(10),{children:n,threadId: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=(0,Z.useRef)(-1),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{t>=s.current&&(s.current=t,o(e))},t[1]=c):c=t[1];let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{s.current=-1,o([])},t[2]=u):u=t[2];let d;t[3]===r?d=t[4]:(d=[r],t[3]=r,t[4]=d),(0,Z.useEffect)(u,d);let f;t[5]===a?f=t[6]:(f={todos:a,setTodos:l},t[5]=a,t[6]=f);let p;return t[7]!==n||t[8]!==f?(p=(0,Q.jsx)(ct.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function ut(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function dt(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Z.useContext)(ct),a,o;return t[0]!==r||t[1]!==i||t[2]!==n?(a=()=>{i(n,r)},o=[n,i,r],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o):(a=t[3],o=t[4]),(0,Z.useEffect)(a,o),null}var ft=new Map,pt=new Map;function mt(e){return ft.get(e)}function ht(e,t){let n=pt.get(e);return n||(n=new Set,pt.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&pt.delete(e)}}function gt(e){let t=pt.get(e);if(t)for(let e of t)e()}function _t(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function vt(e,t,n){if(ft.has(e))return;ft.set(e,{status:`running`}),gt(e);let r=h();(async()=>{try{let i=_t(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;ft.set(e,{status:`success`,result:s}),gt(e),await ee(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);ft.set(e,{status:`error`,error:n}),gt(e);try{await ee(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function yt({initialValue:e}={}){let{state:t,dispatch:n}=Re(),[r,i]=(0,Z.useState)(()=>{let n=t.selectedThreadId;return n&&t.chatInputDrafts[n]?t.chatInputDrafts[n]:e??``}),[a,o]=(0,Z.useState)(-1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(0),d=(0,Z.useRef)(r);(0,Z.useEffect)(()=>{d.current=r},[r]);let f=(0,Z.useRef)(t.chatInputDrafts);(0,Z.useEffect)(()=>{f.current=t.chatInputDrafts},[t.chatInputDrafts]);let p=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let[h,g]=(0,Z.useState)([]),[v,b]=(0,Z.useState)(()=>(t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0)??null),x=(0,Z.useRef)(v?.id??``),S=(0,Z.useRef)(v?.provider??``),C=(0,Z.useRef)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1),[I,ee]=(0,Z.useState)([]),[L,te]=(0,Z.useState)(null),[R,ne]=(0,Z.useState)([]),[re,ie]=(0,Z.useState)(!1),[z,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(0),[W,G]=(0,Z.useState)([]),[K,q]=(0,Z.useState)([]),[J,ae]=(0,Z.useState)(!1),[oe,ce]=(0,Z.useState)(``),le=(0,Z.useRef)(null),ue=(0,Z.useRef)(null),fe=(0,Z.useRef)(null),pe=(0,Z.useRef)(null),me=(0,Z.useRef)(null),he=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{x.current=v?.id??``,S.current=v?.provider??``},[v?.id,v?.provider]);let ge=(0,Z.useCallback)((e,r)=>{b(e);let i=t.selectedThreadId;if(!i||(n({type:Y.SetProjectModel,threadId:i,model:e}),r?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;C.current!==a&&(C.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),y(i,{model:e.id,modelProvider:e.provider}).then(()=>{C.current===a&&(C.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{C.current===a&&(C.current=null),console.error(`Failed to save model to thread:`,e)}))},[t.selectedThreadId,n]);(0,Z.useEffect)(()=>{(async()=>{let e=t.selectedProjectId?t.projects.find(e=>e.projectId===t.selectedProjectId)?.threads.find(e=>e.threadId===t.selectedThreadId):void 0,n=t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0,r=e?.model??n?.id??null,i=e?.modelProvider??n?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:t.selectedThreadId,projectId:t.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:n?{id:n.id,provider:n.provider}:void 0,savedModelId:r,savedModelProvider:i});try{let e=await B(),t=Object.values(e).flat();if(t.length===0){g([]),b(null);return}g(t);let n=r&&i?t.find(e=>e.id===r&&e.provider===i)??null:null,a=t[0],o=n??a,s=!n&&!!(r||i),c=x.current===o.id&&S.current===o.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:n?{id:n.id}:null,fallbackModel:{id:a.id},modelToSelect:{id:o.id},shouldPersistFallback:s,hasSameSelection:c,currentSelected:{id:x.current,provider:S.current}}),c||ge(o,{persist:s})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[t.selectedThreadId,t.selectedProjectId,t.projects,ge]);let _e=(0,Z.useRef)(ge);(0,Z.useEffect)(()=>{_e.current=ge},[ge]),(0,Z.useEffect)(()=>{t.configUpdatedAt!==0&&(async()=>{try{let e=await B(),t=Object.values(e).flat();if(t.length>0){g(t);let e=x.current,n=S.current;t.some(t=>t.id===e&&t.provider===n)||_e.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[t.configUpdatedAt]),(0,Z.useEffect)(()=>{!P||I.length>0||(async()=>{try{let e=await de(),t=Object.values(e).flat();t.length>0&&(ee(t),te(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[P,I.length]);let[ve,ye]=(0,Z.useState)(t.selectedThreadId);return(0,Z.useEffect)(()=>{if(t.selectedThreadId!==ve){ve&&d.current.trim()&&f.current[ve]!==d.current&&n({type:Y.SetChatInputDraft,threadId:ve,draft:d.current});let e=!1;return queueMicrotask(()=>{e||!p.current||(ye(t.selectedThreadId),i(t.selectedThreadId?f.current[t.selectedThreadId]??``:``),ne([]),ie(!1),G([]),q([]),ae(!1),j(!1),F(!1),N(!1))}),()=>{e=!0}}},[t.selectedThreadId,ve]),(0,Z.useEffect)(()=>{t.selectedThreadId&&m(t.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),G(e),q(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[t.selectedThreadId]),(0,Z.useEffect)(()=>{t.focusChatInput&&t.selectedThreadId&&!t.isStreaming&&(ue.current?.focus(),n({type:Y.ClearFocusChatInput}))},[t.focusChatInput,t.selectedThreadId,t.isStreaming,n]),(0,Z.useEffect)(()=>{let e=t.selectedThreadId;return()=>{e&&d.current.trim()&&f.current[e]!==d.current&&n({type:Y.SetChatInputDraft,threadId:e,draft:d.current})}},[t.selectedThreadId,n]),(0,Z.useEffect)(()=>{let e=e=>{fe.current&&!fe.current.contains(e.target)&&T(!1),pe.current&&!pe.current.contains(e.target)&&D(!1)};if(w||E)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[w,E]),{message:r,setMessage:i,historyIndex:a,setHistoryIndex:o,draftMessage:s,setDraftMessage:c,cursorPosition:l,setCursorPosition:u,availableModels:h,setAvailableModels:g,selectedModel:v,setSelectedModel:ge,selectedModelIdRef:x,showModelMenu:w,setShowModelMenu:T,showPlusMenu:E,setShowPlusMenu:D,attachments:O,setAttachments:k,planMode:A,setPlanMode:j,ralphMode:M,setRalphMode:N,imageMode:P,setImageMode:F,availableImageModels:I,setAvailableImageModels:ee,selectedImageModel:L,setSelectedImageModel:te,allFiles:R,setAllFiles:ne,showSuggestions:re,setShowSuggestions:ie,suggestionQuery:z,setSuggestionQuery:V,selectedIndex:H,setSelectedIndex:U,slashCommands:W,setSlashCommands:G,skills:K,setSkills:q,showCommandSuggestions:J,setShowCommandSuggestions:ae,commandQuery:oe,setCommandQuery:ce,fileInputRef:le,textareaRef:ue,modelMenuRef:fe,plusMenuRef:pe,suggestionsRef:me,commandSuggestionsRef:he,handleNewChat:async()=>{if(t.selectedThreadId)try{let e=await _(t.selectedThreadId);n({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let r=await se(t.selectedThreadId);n({type:Y.SetMessages,messages:r.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:t,dispatch:n}}var bt=e=>{te(e)};function xt(e){let t=(0,X.c)(102),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:s,isStreaming:c,selectedThreadId:l,isListening:u,stopListening:d,resetTranscript:f,dispatch:p,historyIndex:m,setHistoryIndex:h,draftMessage:g,setDraftMessage:_,cursorPosition:v,setCursorPosition:y,showSuggestions:b,setShowSuggestions:x,suggestionQuery:S,setSuggestionQuery:C,allFiles:w,setAllFiles:T,selectedIndex:E,setSelectedIndex:D,showCommandSuggestions:O,setShowCommandSuggestions:k,commandQuery:A,setCommandQuery:j,slashCommands:M,skills:N,textareaRef:P,setAttachments:F,planMode:I,setPlanMode:ee,ralphMode:L,setRalphMode:te,imageMode:R,setImageMode:ne,selectedImageModel:ie}=e,z;t[0]!==i||t[1]!==p||t[2]!==R||t[3]!==u||t[4]!==c||t[5]!==n||t[6]!==s||t[7]!==I||t[8]!==L||t[9]!==f||t[10]!==ie||t[11]!==a||t[12]!==l||t[13]!==F||t[14]!==_||t[15]!==h||t[16]!==r||t[17]!==d||t[18]!==P?(z=()=>{if(!n.trim()&&i.length===0||!l)return;let e=R?ie:a;e&&(u&&(d(),f()),c?p({type:Y.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:l,message:n,model:e.id,attachments:i,provider:e.provider,planMode:I,imageMode:R,ralphMode:L}}):s(n,e.id,i,e.provider,I,R,L),bt(n),r(``),F([]),h(-1),_(``),l&&p({type:Y.ClearChatInputDraft,threadId:l}),P.current&&(P.current.style.height=`auto`))},t[0]=i,t[1]=p,t[2]=R,t[3]=u,t[4]=c,t[5]=n,t[6]=s,t[7]=I,t[8]=L,t[9]=f,t[10]=ie,t[11]=a,t[12]=l,t[13]=F,t[14]=_,t[15]=h,t[16]=r,t[17]=d,t[18]=P,t[19]=z):z=t[19];let B=z,V;t[20]!==v||t[21]!==n||t[22]!==r||t[23]!==x||t[24]!==S||t[25]!==P?(V=e=>{let t=n.substring(0,v-S.length-1);r(`${t}${e} ${n.substring(v)}`),x(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.length+1;P.current.setSelectionRange(n,n)}},0)},t[20]=v,t[21]=n,t[22]=r,t[23]=x,t[24]=S,t[25]=P,t[26]=V):V=t[26];let H=V,U;t[27]!==A||t[28]!==v||t[29]!==n||t[30]!==ne||t[31]!==r||t[32]!==ee||t[33]!==te||t[34]!==k||t[35]!==P?(U=e=>{let t=n.substring(0,v-A.length-1),i=n.substring(v);r(`${t}${e.content}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.content.length;P.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`?(ee(!0),te(!1),ne(!1)):e.metadata.mode===`ralph`&&(te(!0),ee(!1),ne(!1))},t[27]=A,t[28]=v,t[29]=n,t[30]=ne,t[31]=r,t[32]=ee,t[33]=te,t[34]=k,t[35]=P,t[36]=U):U=t[36];let W=U,G;t[37]!==A||t[38]!==v||t[39]!==n||t[40]!==r||t[41]!==k||t[42]!==P?(G=e=>{let t=n.substring(0,v-A.length-1),i=n.substring(v),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let e=t.length+a.length;P.current.setSelectionRange(e,e)}},0)},t[37]=A,t[38]=v,t[39]=n,t[40]=r,t[41]=k,t[42]=P,t[43]=G):G=t[43];let K=G,q,J,ae,oe;if(t[44]!==w||t[45]!==A||t[46]!==g||t[47]!==B||t[48]!==m||t[49]!==W||t[50]!==H||t[51]!==K||t[52]!==n||t[53]!==E||t[54]!==l||t[55]!==T||t[56]!==j||t[57]!==y||t[58]!==_||t[59]!==h||t[60]!==r||t[61]!==D||t[62]!==k||t[63]!==x||t[64]!==C||t[65]!==O||t[66]!==b||t[67]!==N||t[68]!==M||t[69]!==S){ae=e=>{if(O){if(e.key===`ArrowDown`){e.preventDefault(),D((E+1)%q.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D((E-1+q.length)%q.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=q[E];t&&(t.type===`command`?W(t.data):K(t.data));return}if(e.key===`Escape`){k(!1);return}}if(b){let t=J.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),D((E+1)%J.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),D((E-1+J.length)%J.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),J[E]&&H(J[E]);return}if(e.key===`Escape`){x(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),B();return}let t=re();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),m===-1?(_(n),h(t.length-1),r(t[t.length-1])):m>0&&(h(m-1),r(t[m-1]))):e.key===`ArrowDown`&&(e.preventDefault(),m>0?(h(m-1),r(t[m-1])):m===0&&(h(-1),r(g))))};let e;t[74]!==w||t[75]!==l||t[76]!==T||t[77]!==j||t[78]!==y||t[79]!==r||t[80]!==D||t[81]!==k||t[82]!==x||t[83]!==C?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),y(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?k(!1):(j(e),k(!0),x(!1),D(0))}else k(!1)}else{k(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?x(!1):(C(t),x(!0),D(0),w.length===0&&l&&o(l).then(e=>{T(e)}).catch(wt))}else x(!1)}else x(!1)}let s=e.target;s.style.height=`auto`,s.style.height=`${Math.min(s.scrollHeight,160)}px`},t[74]=w,t[75]=l,t[76]=T,t[77]=j,t[78]=y,t[79]=r,t[80]=D,t[81]=k,t[82]=x,t[83]=C,t[84]=e):e=t[84],oe=e;let i;if(t[85]!==A||t[86]!==N||t[87]!==M){let e;t[89]===A?e=t[90]:(e=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[89]=A,t[90]=e);let n=M.filter(e),r;t[91]===A?r=t[92]:(r=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[91]=A,t[92]=r);let a=N.filter(r);i=[...n.map(Ct),...a.map(St)],t[85]=A,t[86]=N,t[87]=M,t[88]=i}else i=t[88];q=i.slice(0,10),J=b?w.filter(e=>e.toLowerCase().includes(S.toLowerCase())).slice(0,10):[],t[44]=w,t[45]=A,t[46]=g,t[47]=B,t[48]=m,t[49]=W,t[50]=H,t[51]=K,t[52]=n,t[53]=E,t[54]=l,t[55]=T,t[56]=j,t[57]=y,t[58]=_,t[59]=h,t[60]=r,t[61]=D,t[62]=k,t[63]=x,t[64]=C,t[65]=O,t[66]=b,t[67]=N,t[68]=M,t[69]=S,t[70]=q,t[71]=J,t[72]=ae,t[73]=oe}else q=t[70],J=t[71],ae=t[72],oe=t[73];let se;return t[93]!==q||t[94]!==J||t[95]!==ae||t[96]!==B||t[97]!==oe||t[98]!==W||t[99]!==H||t[100]!==K?(se={handleSend:B,handleKeyDown:ae,handleTextareaInput:oe,insertFileReference:H,insertCommand:W,insertSkill:K,allSuggestions:q,fileSuggestions:J},t[93]=q,t[94]=J,t[95]=ae,t[96]=B,t[97]=oe,t[98]=W,t[99]=H,t[100]=K,t[101]=se):se=t[101],se}function St(e){return{type:`skill`,data:e}}function Ct(e){return{type:`command`,data:e}}function wt(e){return console.error(`Failed to fetch files:`,e)}function Tt(e){let n=(0,X.c)(21),{visible:r,commands:i,skills:a,query:o,selectedIndex:s,onSelectCommand:l,onSelectSkill:d,onMouseEnterSuggestion:f,containerRef:p}=e;if(!r)return null;let m;if(n[0]!==i||n[1]!==o||n[2]!==a){let e;n[4]===o?e=n[5]:(e=e=>e.name.toLowerCase().includes(o.toLowerCase()),n[4]=o,n[5]=e);let t=i.filter(e),r;n[6]===o?r=n[7]:(r=e=>e.name.toLowerCase().includes(o.toLowerCase()),n[6]=o,n[7]=r);let s=a.filter(r);m=[...t.map(Dt),...s.map(Et)].slice(0,10),n[0]=i,n[1]=o,n[2]=a,n[3]=m}else m=n[3];let h=m,g;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(c,{className:`h-3 w-3`}),n[8]=g):g=n[8];let _=o&&` matching "${o}"`,v;n[9]===_?v=n[10]:(v=(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[g,`Commands & Skills`,_]}),n[9]=_,n[10]=v);let y;n[11]!==h||n[12]!==f||n[13]!==l||n[14]!==d||n[15]!==s?(y=h.length>0?h.map((e,n)=>{let r=n===s;if(e.type===`command`){let i=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:t(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,r?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>l(i),onMouseEnter:()=>f(n),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,i.name]}),i.metadata.argumentHint&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i.metadata.argumentHint}),i.scope===`project`&&(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),i.metadata.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i.metadata.description})]},`cmd-${i.name}`)}else{let i=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:t(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,r?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>d(i),onMouseEnter:()=>f(n),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(u,{className:`h-3 w-3 text-amber-500`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,i.name]}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`,children:`skill`}),i.scope===`project`&&(0,Q.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i.description})]},`skill-${i.name}`)}}):(0,Q.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,Q.jsx)(`br`,{}),(0,Q.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),n[11]=h,n[12]=f,n[13]=l,n[14]=d,n[15]=s,n[16]=y):y=n[16];let b;return n[17]!==p||n[18]!==v||n[19]!==y?(b=(0,Q.jsxs)(`div`,{ref:p,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[v,y]}),n[17]=p,n[18]=v,n[19]=y,n[20]=b):b=n[20],b}function Et(e){return{type:`skill`,data:e}}function Dt(e){return{type:`command`,data:e}}function Ot(e){return e.startsWith(`image/`)}function kt(e){let t=(0,X.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,Q.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:Ot(e.mimeType)?(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,Q.jsx)(C,{className:`h-2.5 w-2.5`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,Q.jsx)(J,{className:`h-3 w-3`}),e.fileName,(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,Q.jsx)(C,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function At(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function jt(e){let n=(0,X.c)(16),{showSuggestions:r,fileSuggestions:i,suggestionQuery:a,selectedIndex:o,onSelectFile:s,onMouseEnterSuggestion:c,containerRef:u}=e;if(!r||i.length===0)return null;let d;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(I,{className:`h-3 w-3`}),n[0]=d):d=n[0];let f;n[1]===a?f=n[2]:(f=(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[d,`Files matching "`,a,`"`]}),n[1]=a,n[2]=f);let p;if(n[3]!==i||n[4]!==c||n[5]!==s||n[6]!==o){let e;n[8]!==c||n[9]!==s||n[10]!==o?(e=(e,n)=>{let r=e.split(`/`).pop()??e;return(0,Q.jsxs)(`button`,{type:`button`,className:t(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,n===o?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>s(e),onMouseEnter:()=>c(n),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,Q.jsx)(le,{className:`h-4 w-4 text-blue-500`}):(0,Q.jsx)(l,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,Q.jsx)(`span`,{className:`truncate font-medium`,children:r}),(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},n[8]=c,n[9]=s,n[10]=o,n[11]=e):e=n[11],p=i.map(e),n[3]=i,n[4]=c,n[5]=s,n[6]=o,n[7]=p}else p=n[7];let m;return n[12]!==u||n[13]!==f||n[14]!==p?(m=(0,Q.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[f,p]}),n[12]=u,n[13]=f,n[14]=p,n[15]=m):m=n[15],m}function Mt(e){let t=(0,X.c)(3),{provider:n}=e;if(!n)return null;let r=`https://models.tarsk.io/svg/${n}.svg`,i=`${n} logo`,a;return t[0]!==r||t[1]!==i?(a=(0,Q.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0 dark:invert`,onError:Nt}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Nt(e){e.currentTarget.style.visibility=`hidden`}function Pt(e){let t=(0,X.c)(26),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Z.useState(!1),s=Z.useRef(null),c,l;t[0]===a?(c=t[1],l=t[2]):(c=()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},l=[a],t[0]=a,t[1]=c,t[2]=l),Z.useEffect(c,l);let u;t[3]===i?u=t[4]:(u=e=>{i(e),o(!1)},t[3]=i,t[4]=u);let d=u,f;t[5]===a?f=t[6]:(f=()=>o(!a),t[5]=a,t[6]=f);let p=r?.provider,m;t[7]===p?m=t[8]:(m=(0,Q.jsx)(Mt,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?et(r.id):`No model`,t[9]=r,t[10]=h);let g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:h}),t[11]=h,t[12]=g);let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(W,{className:`h-3 w-3`}),t[13]=_):_=t[13];let v;t[14]!==f||t[15]!==m||t[16]!==g?(v=(0,Q.jsxs)(D,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:f,children:[m,g,_]}),t[14]=f,t[15]=m,t[16]=g,t[17]=v):v=t[17];let y;t[18]!==n||t[19]!==d||t[20]!==r?.id||t[21]!==a?(y=a&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Object.entries(n.reduce(Ft,{})).map(e=>{let[t,n]=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[(0,Q.jsx)(Mt,{provider:t}),t]}),n.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-sm text-popover-foreground hover:bg-accent ${e.id===r?.id?`bg-accent font-medium`:``}`,onClick:()=>d(e),children:et(e.id)},e.id))]},t)})}),t[18]=n,t[19]=d,t[20]=r?.id,t[21]=a,t[22]=y):y=t[22];let b;return t[23]!==v||t[24]!==y?(b=(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[v,y]}),t[23]=v,t[24]=y,t[25]=b):b=t[25],b}function Ft(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var It=[{value:`build`,label:`Build`,icon:b},{value:`plan`,label:`Plan`,icon:H},{value:`image`,label:`Image`,icon:f},{value:`ralph`,label:`Ralph`,icon:G}];function Lt(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function Rt(e){let t=(0,X.c)(31),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s}=e,[c,l]=Z.useState(!1),u=Z.useRef(null),d;t[0]!==r||t[1]!==n||t[2]!==i?(d=Lt(n,r,i),t[0]=r,t[1]=n,t[2]=i,t[3]=d):d=t[3];let f=d,p;t[4]===f?p=t[5]:(p=It.find(e=>e.value===f),t[4]=f,t[5]=p);let m=p,h=m.icon,g,_;t[6]===c?(g=t[7],_=t[8]):(g=()=>{let e=function(e){u.current&&!u.current.contains(e.target)&&l(!1)};if(c)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},_=[c],t[6]=c,t[7]=g,t[8]=_),Z.useEffect(g,_);let v;t[9]!==o||t[10]!==a||t[11]!==s?(v=function(e){a(e===`plan`),o(e===`image`),s(e===`ralph`),l(!1)},t[9]=o,t[10]=a,t[11]=s,t[12]=v):v=t[12];let y=v,b;t[13]===c?b=t[14]:(b=()=>l(!c),t[13]=c,t[14]=b);let x;t[15]===h?x=t[16]:(x=(0,Q.jsx)(h,{className:`h-3.5 w-3.5`}),t[15]=h,t[16]=x);let S;t[17]===m.label?S=t[18]:(S=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:m.label}),t[17]=m.label,t[18]=S);let C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(W,{className:`h-3 w-3`}),t[19]=C):C=t[19];let w;t[20]!==b||t[21]!==x||t[22]!==S?(w=(0,Q.jsxs)(D,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:b,children:[x,S,C]}),t[20]=b,t[21]=x,t[22]=S,t[23]=w):w=t[23];let T;t[24]!==f||t[25]!==c||t[26]!==y?(T=c&&(0,Q.jsx)(`div`,{className:`absolute bottom-full right-0 mb-1 w-40 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:It.map(e=>{let t=e.icon,n=e.value===f;return(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:()=>y(e.value),children:[(0,Q.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,Q.jsx)(ce,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})}),t[24]=f,t[25]=c,t[26]=y,t[27]=T):T=t[27];let E;return t[28]!==w||t[29]!==T?(E=(0,Q.jsxs)(`div`,{className:`relative`,ref:u,children:[w,T]}),t[28]=w,t[29]=T,t[30]=E):E=t[30],E}function zt(e){let t=(0,X.c)(17),{onFileAttach:n}=e,[r,i]=Z.useState(!1),a=Z.useRef(null),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};if(r)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},s=[r],t[0]=r,t[1]=o,t[2]=s),Z.useEffect(o,s);let c;t[3]===n?c=t[4]:(c=function(){n(),i(!1)},t[3]=n,t[4]=c);let l=c,u;t[5]===r?u=t[6]:(u=()=>i(!r),t[5]=r,t[6]=u);let d,f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(he,{}),f=(0,Q.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[7]=d,t[8]=f):(d=t[7],f=t[8]);let p;t[9]===u?p=t[10]:(p=(0,Q.jsxs)(D,{variant:`action`,size:`icon-sm`,onClick:u,children:[d,f]}),t[9]=u,t[10]=p);let m;t[11]!==l||t[12]!==r?(m=r&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:l,children:[(0,Q.jsx)(J,{className:`h-3.5 w-3.5`}),`Attach File`]})}),t[11]=l,t[12]=r,t[13]=m):m=t[13];let h;return t[14]!==p||t[15]!==m?(h=(0,Q.jsxs)(`div`,{className:`relative`,ref:a,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}var $=tt(`useWhisperSpeech`),Bt=`/api/voice-model/download`;function Vt(){let[e,t]=(0,Z.useState)(`idle`),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(0),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=!1;async function n(){t(`checking-support`),$.separator(`VOICE SESSION START`),$.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform});try{let n=new rt;m.current=n;let i=await n.checkWasmSupport();if(e)return;if($.info(`WASM SIMD support check result`,{supported:i}),r(i),!i){$.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`);return}let o=new nt;h.current=o,$.info(`Checking IndexedDB model cache`,{url:Bt});try{let r=await o.loadModelByUrl(Bt);if(e||($.info(`Cached model found — initializing WASM`,{sizeBytes:r.byteLength,sizeMB:(r.byteLength/1024/1024).toFixed(2)}),a(!0),t(`initializing`),await n.initModel(r),e))return;$.info(`WASM model initialized from cache — ready`),t(`ready`)}catch(n){if(e)return;$.info(`Model not in cache — download required`,{reason:n instanceof Error?n.message:String(n)}),t(`needs-model`)}}catch(n){if(e)return;let r=n instanceof Error?n.message:`Unknown error`;$.error(`Failed to check speech recognition support`,{error:r}),t(`error`),d(`Failed to check speech recognition support: ${r}`)}}return n().catch(e=>{console.error(`Failed to check speech recognition support:`,e)}),()=>{e=!0,g.current&&g.current.getTracks().forEach(e=>e.stop())}},[]);let b=(0,Z.useCallback)(async()=>{if(!(!m.current||!h.current)){t(`downloading-model`),p(0),d(null),$.info(`Model download requested`,{url:Bt});try{let e=await h.current.loadModelByUrl(Bt,e=>{p(e),e%10==0&&$.debug(`Model download progress`,{progress:e})});$.info(`Model download complete — initializing WASM`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),t(`initializing`),await m.current.initModel(e),$.info(`WASM model initialized after download — ready`),a(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;$.error(`Model download or initialization failed`,{error:n}),t(`needs-model`),d(n)}}},[]),x=(0,Z.useCallback)(async()=>{if(!(!m.current||!i)){if(y.current=!1,t(`requesting-mic`),d(null),l(``),$.separator(`RECORDING START`),$.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){$.error(`navigator.mediaDevices.getUserMedia not available in this environment`),t(`ready`),s(!1),d(`Microphone is not available in this environment.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),n=e.getAudioTracks();$.info(`Microphone access granted`,{trackCount:n.length,tracks:n.map(e=>({label:e.label,readyState:e.readyState,settings:e.getSettings()}))}),g.current=e,s(!0);let r=new AbortController;_.current=r,t(`recording`),$.info(`Recording started`),v.current=it(e,{signal:r.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{$.error(`Audio conversion error during recording`,{error:e instanceof Error?e.message:String(e)})}})}catch(e){if(t(`ready`),e instanceof DOMException&&e.name===`NotAllowedError`)$.error(`Microphone access denied (NotAllowedError)`),s(!1),d(`Microphone access was denied. Please allow microphone access to use voice input.`);else if(e instanceof DOMException&&e.name===`NotFoundError`)$.error(`No microphone found (NotFoundError)`),s(!1),d(`No microphone was found. Please connect a microphone to use voice input.`);else{let t=e instanceof Error?e.message:`Unknown error`;$.error(`Microphone error`,{error:t,type:e instanceof DOMException?e.name:typeof e}),d(`Microphone error: ${t}`)}}}},[i]),S=(0,Z.useCallback)(async()=>{if(!v.current){$.info(`stopListening called but no active recording`),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null),i&&t(`ready`);return}$.info(`Stopping recording — waiting for audio data`),_.current?.abort(),t(`transcribing`);try{let e=await v.current;if(y.current){$.info(`Transcription cancelled by user`),t(`ready`);return}let n=(e.audioData.length/16e3).toFixed(2);$.info(`Audio capture complete — starting transcription`,{sampleCount:e.audioData.length,durationSec:n,sampleRate:16e3}),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null);let r=Date.now(),i=typeof SharedArrayBuffer<`u`?4:1,a=m.current.createSession().streaming(e.audioData,{language:`en`,threads:i,translate:!1}),o=``,s=0;for await(let e of a){if(y.current)break;s++,o+=e.text.trim()+` `,$.debug(`Transcription segment received`,{index:s,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),l(o.trim())}$.info(`Transcription complete`,{segmentCount:s,durationMs:Date.now()-r,textLength:o.trim().length,text:o.trim().slice(0,100)}),t(`ready`)}catch(e){if(y.current){t(`ready`);return}let n=e instanceof Error?e.message:`Unknown transcription error`;if($.error(`Transcription failed`,{error:n,errorType:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
2
- `).slice(0,5).join(` | `):void 0}),m.current&&n.includes(`Aborted`)){$.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await m.current.restartModel(),$.info(`WASM reinitialized successfully`)}catch(e){$.error(`WASM reinitialization failed`,{error:e instanceof Error?e.message:String(e)})}}t(`ready`),d(`Transcription failed: ${n}`)}finally{v.current=null,_.current=null}},[i]),C=(0,Z.useCallback)(()=>{l(``),d(null)},[]);return{state:e,isSupported:n===!0,isWasmSupported:n,isModelLoaded:i,isMicrophoneAvailable:o,transcript:c,error:u,downloadProgress:f,startListening:x,stopListening:S,requestModelDownload:b,resetTranscript:C}}var Ht=Z.forwardRef((e,n)=>{let r=(0,X.c)(13),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,value:o,...a}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s;r[4]===i?s=r[5]:(s=t(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,i),r[4]=i,r[5]=s);let c=`translateX(-${100-(o||0)}%)`,l;r[6]===c?l=r[7]:(l=(0,Q.jsx)(Ie,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:c}}),r[6]=c,r[7]=l);let u;return r[8]!==a||r[9]!==n||r[10]!==s||r[11]!==l?(u=(0,Q.jsx)(Ne,{ref:n,className:s,...a,children:l}),r[8]=a,r[9]=n,r[10]=s,r[11]=l,r[12]=u):u=r[12],u});Ht.displayName=Ne.displayName;var Ut=75;function Wt(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:o,error:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsxs)(P,{children:[(0,Q.jsx)(x,{children:`Download Voice Model`}),(0,Q.jsxs)(N,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,Ut,`MB. The model will be cached locally for future use.`]})]}),t[0]=l):l=t[0];let u;t[1]!==a||t[2]!==c||t[3]!==i||t[4]!==r||t[5]!==o?(u=(0,Q.jsxs)(s,{children:[l,a?(0,Q.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,Q.jsx)(Ht,{value:o,className:`w-full`}),(0,Q.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:o<100?`Downloading model... ${o}%`:`Initializing model...`})]}):c?(0,Q.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Q.jsx)(L,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`p`,{children:c})]}),(0,Q.jsxs)(j,{children:[(0,Q.jsx)(D,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(D,{onClick:i,children:`Try Again`})]})]}):(0,Q.jsxs)(j,{children:[(0,Q.jsx)(D,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(D,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=c,t[3]=i,t[4]=r,t[5]=o,t[6]=u):u=t[6];let d;return t[7]!==r||t[8]!==n||t[9]!==u?(d=(0,Q.jsx)(ue,{open:n,onOpenChange:r,children:u}),t[7]=r,t[8]=n,t[9]=u,t[10]=d):d=t[10],d}function Gt(e){let t=(0,X.c)(65),{onTranscript:n}=e,{state:a,isWasmSupported:o,transcript:s,error:c,downloadProgress:l,startListening:u,stopListening:d,requestModelDownload:f,resetTranscript:p}=Vt(),{toast:m}=Ge(),[h,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(``),v=(0,Z.useRef)(null),y=a===`recording`,b=a===`transcribing`,x=y||b,S=a===`needs-model`,C=a===`downloading-model`||a===`initializing`,w=a===`checking-support`||a===`idle`,T,E;t[0]!==h||t[1]!==c||t[2]!==m?(T=()=>{c&&c!==v.current&&!h&&m({title:`Voice Input Error`,description:c,variant:`destructive`}),v.current=c},E=[c,h,m],t[0]=h,t[1]=c,t[2]=m,t[3]=T,t[4]=E):(T=t[3],E=t[4]),(0,Z.useEffect)(T,E);let O,k;t[5]!==n||t[6]!==s?(O=()=>{if(s&&s!==_.current){let e=s.substring(_.current.length);_.current=s,n(e)}},k=[s,n],t[5]=n,t[6]=s,t[7]=O,t[8]=k):(O=t[7],k=t[8]),(0,Z.useEffect)(O,k);let A,j;t[9]===s?(A=t[10],j=t[11]):(A=()=>{s||(_.current=``)},j=[s],t[9]=s,t[10]=A,t[11]=j),(0,Z.useEffect)(A,j);let M;t[12]!==x||t[13]!==S||t[14]!==p||t[15]!==u||t[16]!==a||t[17]!==d?(M=()=>{if(S){g(!0);return}x?d():a===`ready`&&(p(),u())},t[12]=x,t[13]=S,t[14]=p,t[15]=u,t[16]=a,t[17]=d,t[18]=M):M=t[18];let N=M,P;t[19]===f?P=t[20]:(P=()=>{f()},t[19]=f,t[20]=P);let F=P,I,ee;if(t[21]!==h||t[22]!==a?(ee=()=>{a===`ready`&&h&&g(!1)},I=[a,h],t[21]=h,t[22]=a,t[23]=I,t[24]=ee):(I=t[23],ee=t[24]),(0,Z.useEffect)(ee,I),w)return null;if(o===!1){let e;return t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(D,{variant:`ghost`,size:`icon-sm`,disabled:!0,className:`text-muted-foreground`,children:[(0,Q.jsx)(r,{className:`opacity-50`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`})]})}),(0,Q.jsx)(He,{side:`top`,className:`bg-popover text-popover-foreground`,children:`Voice input not supported in this browser`})]}),t[25]=e):e=t[25],e}let L;t[26]!==c||t[27]!==C||t[28]!==y||t[29]!==b||t[30]!==S?(L=()=>c||(C?`Downloading speech model...`:b?`Transcribing...`:y?`Stop listening`:S?`Click to download speech model`:`Start listening`),t[26]=c,t[27]=C,t[28]=y,t[29]=b,t[30]=S,t[31]=L):L=t[31];let te=L,R;t[32]!==C||t[33]!==y||t[34]!==b?(R=()=>C||b?(0,Q.jsx)(i,{className:`animate-spin`}):y?(0,Q.jsxs)(`span`,{className:`recording-waveform`,"aria-hidden":!0,children:[(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`0ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`150ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`75ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`225ms`}})]}):(0,Q.jsx)(r,{}),t[32]=C,t[33]=y,t[34]=b,t[35]=R):R=t[35];let ne=R,re;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(`style`,{children:`
3
- .recording-waveform {
4
- display: flex;
5
- align-items: center;
6
- gap: 2px;
7
- height: 16px;
8
- }
9
- .recording-waveform-bar {
10
- display: block;
11
- width: 3px;
12
- height: 4px;
13
- border-radius: 2px;
14
- background: currentColor;
15
- animation: waveform-bounce 0.7s ease-in-out infinite alternate;
16
- }
17
- @keyframes waveform-bounce {
18
- from { height: 3px; }
19
- to { height: 14px; }
20
- }
21
- `}),t[36]=re):re=t[36];let ie=y?`bg-primary text-primary-foreground hover:bg-primary/90`:b?`text-muted-foreground`:`text-muted-foreground hover:text-background`,z=w||C||b,B;t[37]===ne?B=t[38]:(B=ne(),t[37]=ne,t[38]=B);let V;t[39]===te?V=t[40]:(V=te(),t[39]=te,t[40]=V);let H;t[41]===V?H=t[42]:(H=(0,Q.jsx)(`span`,{className:`sr-only`,children:V}),t[41]=V,t[42]=H);let U;t[43]!==N||t[44]!==ie||t[45]!==z||t[46]!==B||t[47]!==H?(U=(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(D,{variant:`ghost`,size:`icon-sm`,className:ie,onClick:N,disabled:z,children:[B,H]})}),t[43]=N,t[44]=ie,t[45]=z,t[46]=B,t[47]=H,t[48]=U):U=t[48];let W;t[49]===te?W=t[50]:(W=te(),t[49]=te,t[50]=W);let G;t[51]===W?G=t[52]:(G=(0,Q.jsx)(He,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:W}),t[51]=W,t[52]=G);let K;t[53]!==U||t[54]!==G?(K=(0,Q.jsxs)(Ue,{children:[U,G]}),t[53]=U,t[54]=G,t[55]=K):K=t[55];let q;t[56]!==h||t[57]!==l||t[58]!==c||t[59]!==F||t[60]!==C?(q=(0,Q.jsx)(Wt,{open:h,onOpenChange:g,onConfirm:F,downloading:C,progress:l,error:c}),t[56]=h,t[57]=l,t[58]=c,t[59]=F,t[60]=C,t[61]=q):q=t[61];let J;return t[62]!==K||t[63]!==q?(J=(0,Q.jsxs)(Q.Fragment,{children:[re,K,q]}),t[62]=K,t[63]=q,t[64]=J):J=t[64],J}function Kt(e){let t=(0,X.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm`,children:[(0,Q.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,Q.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,Q.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function qt(e){let t=(0,X.c)(136),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l}=e,u=i===void 0?!1:i,d=l===void 0?!1:l,f;t[0]===o?f=t[1]:(f={initialValue:o},t[0]=o,t[1]=f);let{message:p,setMessage:m,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,availableModels:x,selectedModel:C,setSelectedModel:w,attachments:T,setAttachments:E,planMode:O,setPlanMode:A,ralphMode:j,setRalphMode:M,imageMode:N,setImageMode:P,availableImageModels:F,selectedImageModel:I,setSelectedImageModel:ee,allFiles:L,setAllFiles:te,showSuggestions:R,setShowSuggestions:ne,suggestionQuery:re,setSuggestionQuery:ie,selectedIndex:z,setSelectedIndex:B,slashCommands:V,skills:H,showCommandSuggestions:U,setShowCommandSuggestions:W,commandQuery:G,setCommandQuery:K,fileInputRef:q,textareaRef:J,suggestionsRef:ae,commandSuggestionsRef:oe,state:se,dispatch:ce}=yt(f),le=N?I:C,ue=N?F:x,de=se.selectedThreadId??void 0,fe;t[2]!==L||t[3]!==T||t[4]!==G||t[5]!==y||t[6]!==ce||t[7]!==_||t[8]!==h||t[9]!==N||t[10]!==u||t[11]!==p||t[12]!==n||t[13]!==O||t[14]!==j||t[15]!==I||t[16]!==z||t[17]!==C||t[18]!==te||t[19]!==E||t[20]!==K||t[21]!==b||t[22]!==v||t[23]!==g||t[24]!==P||t[25]!==m||t[26]!==A||t[27]!==M||t[28]!==B||t[29]!==W||t[30]!==ne||t[31]!==ie||t[32]!==U||t[33]!==R||t[34]!==H||t[35]!==V||t[36]!==re||t[37]!==de||t[38]!==J?(fe={message:p,setMessage:m,attachments:T,selectedModel:C,onSend:n,isStreaming:u,selectedThreadId:de,isListening:!1,stopListening:Zt,resetTranscript:Xt,dispatch:ce,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,showSuggestions:R,setShowSuggestions:ne,suggestionQuery:re,setSuggestionQuery:ie,allFiles:L,setAllFiles:te,selectedIndex:z,setSelectedIndex:B,showCommandSuggestions:U,setShowCommandSuggestions:W,commandQuery:G,setCommandQuery:K,slashCommands:V,skills:H,textareaRef:J,setAttachments:E,planMode:O,setPlanMode:A,ralphMode:j,setRalphMode:M,imageMode:N,setImageMode:P,selectedImageModel:I},t[2]=L,t[3]=T,t[4]=G,t[5]=y,t[6]=ce,t[7]=_,t[8]=h,t[9]=N,t[10]=u,t[11]=p,t[12]=n,t[13]=O,t[14]=j,t[15]=I,t[16]=z,t[17]=C,t[18]=te,t[19]=E,t[20]=K,t[21]=b,t[22]=v,t[23]=g,t[24]=P,t[25]=m,t[26]=A,t[27]=M,t[28]=B,t[29]=W,t[30]=ne,t[31]=ie,t[32]=U,t[33]=R,t[34]=H,t[35]=V,t[36]=re,t[37]=de,t[38]=J,t[39]=fe):fe=t[39];let{handleSend:pe,handleKeyDown:me,handleTextareaInput:he,insertFileReference:_e,insertCommand:ve,insertSkill:ye,fileSuggestions:be}=xt(fe),xe;t[40]===m?xe=t[41]:(xe=e=>{m(t=>(t.endsWith(` `),t+e))},t[40]=m,t[41]=xe);let Se=xe,Ce;t[42]===E?Ce=t[43]:(Ce=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(Yt);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];E(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[42]=E,t[43]=Ce);let we=Ce,Te=d?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,Ee=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${d?`border-border/50 bg-background/80 shadow-lg backdrop-blur-sm`:`border-border bg-background shadow-2xl`}`,De;t[44]!==c||t[45]!==s?(De=(0,Q.jsx)(Kt,{queuedMessages:s,onRemoveQueuedMessage:c}),t[44]=c,t[45]=s,t[46]=De):De=t[46];let Oe=j?`Describe stories for Ralph to implement autonomously...`:O?`Describe what you want Tarsk to plan...`:N?`Describe the image you want to generate...`:`Ask Tarsk anything, # for files, / for commands & skills`,ke;t[47]!==a||t[48]!==me||t[49]!==we||t[50]!==he||t[51]!==p||t[52]!==Oe||t[53]!==J?(ke=(0,Q.jsx)(`textarea`,{ref:J,value:p,onChange:he,onKeyDown:me,onPaste:we,placeholder:Oe,rows:1,className:`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none`,disabled:a}),t[47]=a,t[48]=me,t[49]=we,t[50]=he,t[51]=p,t[52]=Oe,t[53]=J,t[54]=ke):ke=t[54];let Ae;t[55]!==G||t[56]!==oe||t[57]!==ve||t[58]!==ye||t[59]!==z||t[60]!==B||t[61]!==U||t[62]!==H||t[63]!==V?(Ae=(0,Q.jsx)(Tt,{visible:U,commands:V,skills:H,query:G,selectedIndex:z,onSelectCommand:ve,onSelectSkill:ye,onMouseEnterSuggestion:B,containerRef:oe}),t[55]=G,t[56]=oe,t[57]=ve,t[58]=ye,t[59]=z,t[60]=B,t[61]=U,t[62]=H,t[63]=V,t[64]=Ae):Ae=t[64];let je;t[65]!==be||t[66]!==_e||t[67]!==z||t[68]!==B||t[69]!==R||t[70]!==re||t[71]!==ae?(je=(0,Q.jsx)(jt,{showSuggestions:R,fileSuggestions:be,suggestionQuery:re,selectedIndex:z,onSelectFile:_e,onMouseEnterSuggestion:B,containerRef:ae}),t[65]=be,t[66]=_e,t[67]=z,t[68]=B,t[69]=R,t[70]=re,t[71]=ae,t[72]=je):je=t[72];let Me;t[73]!==T||t[74]!==C?.id||t[75]!==C?.name||t[76]!==C?.supportsImages||t[77]!==E?(Me=T.length>0&&(0,Q.jsxs)(`div`,{className:`px-4`,children:[(0,Q.jsx)(kt,{attachments:T,onRemove:e=>E(t=>t.filter((t,n)=>n!==e))}),T.some(Jt)&&C?.supportsImages===!1&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,Q.jsx)(k,{className:`h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Images are not supported by `,C?.name||C?.id]})]})]}),t[73]=T,t[74]=C?.id,t[75]=C?.name,t[76]=C?.supportsImages,t[77]=E,t[78]=Me):Me=t[78];let Ne;t[79]===q?Ne=t[80]:(Ne=(0,Q.jsx)(zt,{onFileAttach:()=>q.current?.click()}),t[79]=q,t[80]=Ne);let Pe;t[81]===Se?Pe=t[82]:(Pe=(0,Q.jsx)(Gt,{onTranscript:Se}),t[81]=Se,t[82]=Pe);let Fe=N?ee:w,Ie;t[83]!==ue||t[84]!==le||t[85]!==Fe?(Ie=(0,Q.jsx)(Pt,{availableModels:ue,selectedModel:le,onModelSelect:Fe}),t[83]=ue,t[84]=le,t[85]=Fe,t[86]=Ie):Ie=t[86];let Le;t[87]!==Ne||t[88]!==Pe||t[89]!==Ie?(Le=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ne,Pe,Ie]}),t[87]=Ne,t[88]=Pe,t[89]=Ie,t[90]=Le):Le=t[90];let Re;t[91]!==N||t[92]!==O||t[93]!==j||t[94]!==P||t[95]!==A||t[96]!==M?(Re=(0,Q.jsx)(Rt,{planMode:O,imageMode:N,ralphMode:j,setPlanMode:A,setImageMode:P,setRalphMode:M}),t[91]=N,t[92]=O,t[93]=j,t[94]=P,t[95]=A,t[96]=M,t[97]=Re):Re=t[97];let ze=u?r:pe,Be;t[98]!==T.length||t[99]!==a||t[100]!==le||t[101]!==u||t[102]!==p?(Be=!u&&((a??!1)||!p.trim()&&T.length===0||!le),t[98]=T.length,t[99]=a,t[100]=le,t[101]=u,t[102]=p,t[103]=Be):Be=t[103];let Y;t[104]===u?Y=t[105]:(Y=u?(0,Q.jsx)(S,{className:`h-3 w-3 fill-current`}):(0,Q.jsx)(ge,{className:`h-3 w-3`}),t[104]=u,t[105]=Y);let Ve=u?`Stop generation`:`Send message`,He;t[106]===Ve?He=t[107]:(He=(0,Q.jsx)(`span`,{className:`sr-only`,children:Ve}),t[106]=Ve,t[107]=He);let Ue;t[108]!==ze||t[109]!==Be||t[110]!==Y||t[111]!==He?(Ue=(0,Q.jsxs)(D,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:ze,disabled:Be,children:[Y,He]}),t[108]=ze,t[109]=Be,t[110]=Y,t[111]=He,t[112]=Ue):Ue=t[112];let We;t[113]!==Re||t[114]!==Ue?(We=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Re,Ue]}),t[113]=Re,t[114]=Ue,t[115]=We):We=t[115];let Ge;t[116]!==Le||t[117]!==We?(Ge=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[Le,We]}),t[116]=Le,t[117]=We,t[118]=Ge):Ge=t[118];let Ke;t[119]!==De||t[120]!==ke||t[121]!==Ae||t[122]!==je||t[123]!==Me||t[124]!==Ge||t[125]!==Ee?(Ke=(0,Q.jsxs)(`div`,{className:Ee,children:[De,ke,Ae,je,Me,Ge]}),t[119]=De,t[120]=ke,t[121]=Ae,t[122]=je,t[123]=Me,t[124]=Ge,t[125]=Ee,t[126]=Ke):Ke=t[126];let qe;t[127]===E?qe=t[128]:(qe=e=>At(e,e=>E(t=>[...t,...e])),t[127]=E,t[128]=qe);let Je;t[129]!==q||t[130]!==qe?(Je=(0,Q.jsx)(`input`,{ref:q,type:`file`,multiple:!0,className:`hidden`,onChange:qe}),t[129]=q,t[130]=qe,t[131]=Je):Je=t[131];let Ye;return t[132]!==Ke||t[133]!==Je||t[134]!==Te?(Ye=(0,Q.jsxs)(`div`,{className:Te,children:[Ke,Je]}),t[132]=Ke,t[133]=Je,t[134]=Te,t[135]=Ye):Ye=t[135],Ye}function Jt(e){return e.mimeType.startsWith(`image/`)}function Yt(e){return e.type.startsWith(`image/`)}function Xt(){}function Zt(){}var Qt=je,$t=Pe,en=Se,tn=Z.forwardRef((e,n)=>{let r=(0,X.c)(14),i,a,o,s;r[0]===e?(i=r[1],a=r[2],o=r[3],s=r[4]):({className:a,inset:o,children:i,...s}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=o&&`pl-8`,l;r[5]!==a||r[6]!==c?(l=t(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,c,a),r[5]=a,r[6]=c,r[7]=l):l=r[7];let u;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(me,{className:`ml-auto`}),r[8]=u):u=r[8];let d;return r[9]!==i||r[10]!==s||r[11]!==n||r[12]!==l?(d=(0,Q.jsxs)(Le,{ref:n,className:l,...s,children:[i,u]}),r[9]=i,r[10]=s,r[11]=n,r[12]=l,r[13]=d):d=r[13],d});tn.displayName=Le.displayName;var nn=Z.forwardRef((e,n)=>{let r=(0,X.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,Q.jsx)(Me,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});nn.displayName=Me.displayName;var rn=Z.forwardRef((e,n)=>{let r=(0,X.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,sideOffset:o,...a}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=o===void 0?4:o,c;r[4]===i?c=r[5]:(c=t(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[4]=i,r[5]=c);let l;return r[6]!==a||r[7]!==n||r[8]!==s||r[9]!==c?(l=(0,Q.jsx)(Ee,{children:(0,Q.jsx)(ke,{ref:n,sideOffset:s,className:c,...a})}),r[6]=a,r[7]=n,r[8]=s,r[9]=c,r[10]=l):l=r[10],l});rn.displayName=ke.displayName;var an=Z.forwardRef((e,n)=>{let r=(0,X.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=t(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==n||r[9]!==c?(l=(0,Q.jsx)(we,{ref:n,className:c,...o}),r[7]=o,r[8]=n,r[9]=c,r[10]=l):l=r[10],l});an.displayName=we.displayName;var on=Z.forwardRef((e,n)=>{let r=(0,X.c)(14),i,a,o,s;r[0]===e?(i=r[1],a=r[2],o=r[3],s=r[4]):({className:o,children:a,checked:i,...s}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c;r[5]===o?c=r[6]:(c=t(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),r[5]=o,r[6]=c);let l;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(De,{children:(0,Q.jsx)(ce,{className:`h-4 w-4`})})}),r[7]=l):l=r[7];let u;return r[8]!==i||r[9]!==a||r[10]!==s||r[11]!==n||r[12]!==c?(u=(0,Q.jsxs)(Te,{ref:n,className:c,checked:i,...s,children:[l,a]}),r[8]=i,r[9]=a,r[10]=s,r[11]=n,r[12]=c,r[13]=u):u=r[13],u});on.displayName=Te.displayName;var sn=Z.forwardRef((e,n)=>{let r=(0,X.c)(12),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:a,children:i,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s;r[4]===a?s=r[5]:(s=t(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),r[4]=a,r[5]=s);let c;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(De,{children:(0,Q.jsx)(F,{className:`h-2 w-2 fill-current`})})}),r[6]=c):c=r[6];let l;return r[7]!==i||r[8]!==o||r[9]!==n||r[10]!==s?(l=(0,Q.jsxs)(Ae,{ref:n,className:s,...o,children:[c,i]}),r[7]=i,r[8]=o,r[9]=n,r[10]=s,r[11]=l):l=r[11],l});sn.displayName=Ae.displayName;var cn=Z.forwardRef((e,n)=>{let r=(0,X.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=t(`px-2 py-1.5 text-sm font-semibold`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==n||r[9]!==c?(l=(0,Q.jsx)(Fe,{ref:n,className:c,...o}),r[7]=o,r[8]=n,r[9]=c,r[10]=l):l=r[10],l});cn.displayName=Fe.displayName;var ln=Z.forwardRef((e,n)=>{let r=(0,X.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`-mx-1 my-1 h-px bg-muted`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,Q.jsx)(Oe,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});ln.displayName=Oe.displayName;var un=e=>{let n=(0,X.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=t(`ml-auto text-xs tracking-widest opacity-60`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,Q.jsx)(`span`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};un.displayName=`DropdownMenuShortcut`;function dn(e){let t=(0,X.c)(17),{currentBranch:n,availableBranches:r,isLoadingBranches:a,isCheckingOut:o,onLoadBranches:s,onCheckoutBranch:c}=e,l;t[0]===s?l=t[1]:(l=e=>{e&&s()},t[0]=s,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(O,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=u):u=t[2];let d=n||`Unknown`,f;t[3]===d?f=t[4]:(f=(0,Q.jsx)($t,{asChild:!0,children:(0,Q.jsxs)(D,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background gap-1.5 border-none text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:[u,d]})}),t[3]=d,t[4]=f);let p;t[5]!==r||t[6]!==n||t[7]!==o||t[8]!==a||t[9]!==c?(p=a?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,Q.jsx)(i,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):r.map(e=>(0,Q.jsxs)(an,{disabled:e===n||o,onClick:()=>c(e),children:[(0,Q.jsx)(O,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,Q.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[5]=r,t[6]=n,t[7]=o,t[8]=a,t[9]=c,t[10]=p):p=t[10];let m;t[11]===p?m=t[12]:(m=(0,Q.jsx)(rn,{align:`start`,children:p}),t[11]=p,t[12]=m);let h;return t[13]!==l||t[14]!==f||t[15]!==m?(h=(0,Q.jsxs)(Qt,{onOpenChange:l,children:[f,m]}),t[13]=l,t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function fn({threadId:e,currentConversationId:t,refreshKey:n,children:r}){let[i,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{x(!1)},[n]),(0,Z.useEffect)(()=>{if(!v||!e||b&&!n)return;async function r(){m(!0),_(null);try{let n=(await g(e)).currentConversationId??t,[r,i]=await Promise.allSettled([d(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?K(e,n).catch(e=>{throw console.error(`Conversation usage failed:`,e),e}):Promise.resolve(null)]);if(r.status===`fulfilled`)o(r.value);else throw console.error(`Failed to fetch thread usage summary:`,r.reason),r.reason;if(i?.status===`fulfilled`&&i.value){if(c(i.value),i.value.model?.model){let e=i.value.model.model,t=i.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),ie(n).then(f).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(i?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,i.reason),i.reason;x(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),_(`Failed to load usage data`)}finally{m(!1)}}r()},[v,e,t,n]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,Q.jsx)(Q.Fragment,{children:r});let S=e=>e==null||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString();return e?(0,Q.jsxs)(Ue,{open:v,onOpenChange:e=>{y(e),!e&&b&&x(!1)},children:[(0,Q.jsx)(We,{asChild:!0,children:r}),(0,Q.jsx)(He,{side:`top`,align:`center`,className:`max-w-xs`,children:(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[p&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(q,{className:`h-3 w-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Loading usage...`})]}),h&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(q,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:`No usage information for this thread`})]}),!p&&!h&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(q,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[S(i.totalTokens),` tokens`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(a,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[i.conversationCount,` chats`]})]})]}),s&&(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`Current Chat:`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(u,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[((e,t)=>{let n=S(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(s.footprint?.totalTokens??s.usage.totalTokens,typeof l?.contextWindow==`number`?l.contextWindow:typeof l?.context_length==`number`?l.context_length:void 0),` `,`tokens`]})]}),s.model.model&&(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:s.model.model}),(l?.contextWindow||l?.context_length)&&(0,Q.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Max context:`,` `,S(typeof l.contextWindow==`number`?l.contextWindow:typeof l.context_length==`number`?l.context_length:0),` `,`tokens`]})]}),(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2 flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{children:[`In: `,S(i.totalInputTokens)]}),(0,Q.jsxs)(`span`,{children:[`Out: `,S(i.totalOutputTokens)]}),(0,Q.jsxs)(`span`,{children:[`Avg: `,S(i.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,Q.jsx)(Q.Fragment,{children:r})}function pn(e,t){return`${e.filter(e=>e.sender===`agent`).length}:${t?`streaming`:`idle`}`}function mn(e){if(typeof e?.contextWindow==`number`)return e.contextWindow;if(typeof e?.context_length==`number`)return e.context_length}function hn(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function gn(e){let t=(0,X.c)(8),{percentage:n}=e,r=2*Math.PI*7,i=r*(1-Math.min(n,100)/100),a;t[0]===n?a=t[1]:(a=hn(n),t[0]=n,t[1]=a);let o=`h-4 w-4 ${a}`,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`circle`,{className:`text-muted-foreground/25`,cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`}),t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:i,transform:`rotate(-90 10 10)`}),t[3]=i,t[4]=c);let l;return t[5]!==o||t[6]!==c?(l=(0,Q.jsxs)(`svg`,{className:o,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[s,c]}),t[5]=o,t[6]=c,t[7]=l):l=t[7],l}function _n({threadId:e,isStreaming:t=!1,messages:n=[]}){let[r,i]=(0,Z.useState)(),[o,s]=(0,Z.useState)(),c=(0,Z.useMemo)(()=>pn(n,t),[n,t]);return(0,Z.useEffect)(()=>{async function t(){if(!e){i(void 0),s(void 0);return}try{let t=(await g(e)).currentConversationId;if(i(t),!t){s(void 0);return}let n=await K(e,t),r=n.model?.model;if(!r){s(void 0);return}let a=n.model.provider,o=mn(await ie(a?`${a}/${r}`:r));if(!o){s(void 0);return}let c=n.footprint?.totalTokens??n.usage.totalTokens;s(Math.round(c/o*100))}catch(e){console.error(`Failed to fetch thread usage data:`,e),s(void 0)}}t()},[e,c]),!e||e===``?null:(0,Q.jsx)(fn,{threadId:e,currentConversationId:r,refreshKey:c,children:(0,Q.jsxs)(D,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[typeof o==`number`&&o>25?(0,Q.jsx)(gn,{percentage:o}):(0,Q.jsx)(a,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`View token usage`})]})})}var vn=3e4,yn=new Map;function bn(e,t){let n=yn.get(e);if(n)for(let e of n)e(t)}function xn(e,t){let n=yn.get(e);return n||(n=new Set,yn.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&yn.delete(e)}}function Sn(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(void 0),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`Up to date`),[x,S]=(0,Z.useState)(null),[C,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(void 0),[O,k]=(0,Z.useState)(void 0),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),P=(0,Z.useRef)(!0),F=(0,Z.useRef)(void 0),I=(0,Z.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),c(e.currentBranch),v(e.hasRemoteBranch),u(e.isOnGitHub),f(e.remoteUrl),m(e.canCreateRepo),g(e.repoUrl),b(e.status),S(e.defaultBranch??null),T(e.prExists),D(e.prUrl),k(e.prState),j(e.commitsAheadOfDefault??!1)},[]),ee=(0,Z.useRef)(I);ee.current=I;let L=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>N(!0),100);try{let n=`unified-git-status-${e}`;t&&U.invalidate(n);let r=await U.get(n,()=>w(e,t),vn);I(r),bn(e,r)}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),N(!1)}},[e,I]);return(0,Z.useEffect)(()=>{if(e)return xn(e,e=>{ee.current(e)})},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=F.current!==e;t&&(F.current=e,P.current=!0),(async()=>{if(P.current){let t=`unified-git-status-${e}`,n=U.getSync(t);n&&I(n),P.current=!1}await L(t)})()},[e,L,I]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:C,prUrl:E,prState:O,commitsAheadOfDefault:A,isRefreshing:M,fetchUnifiedStatus:L}}function Cn(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=Sn(e);async function c(){if(!(!e||r)){i(!0);try{n((await A(e)).branches)}catch{n([])}finally{i(!1)}}}async function l(t){if(!(!e||t===s.currentBranch)){o(!0);try{await xe(e,t),await s.fetchUnifiedStatus(!0),Ke({title:`Switched to branch "${t}"`})}catch(e){Ke({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}return{currentBranch:s.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:c,checkoutBranch:l,fetchUnifiedStatus:s.fetchUnifiedStatus}}function wn(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=at();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(M,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,Q.jsx)(ye,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,Q.jsxs)(D,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}function Tn({threadId:e,isStreaming:t=!1,messages:n=[]}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=Cn(e);return(0,Z.useEffect)(()=>{e&&pe(e).then(o).catch(()=>{})},[e]),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,Q.jsx)(dn,{currentBranch:s.currentBranch,availableBranches:s.availableBranches,isLoadingBranches:s.isLoadingBranches,isCheckingOut:s.isCheckingOut,onLoadBranches:s.loadBranches,onCheckoutBranch:s.checkoutBranch}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(wn,{collapsed:!1}),(0,Q.jsx)(_n,{threadId:e,isStreaming:t,messages:n}),e&&(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||r)){i(!0);try{let t=await pe(e);await navigator.clipboard.writeText(t)}finally{i(!1)}}},disabled:r,"aria-label":`Copy repository folder path`,children:(0,Q.jsx)(E,{className:`h-4 w-4`})})}),(0,Q.jsxs)(He,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,Q.jsx)(`div`,{children:`Copy repository folder path`}),a&&(0,Q.jsx)(`div`,{className:`opacity-70 text-xs`,children:a})]})]})]})]})}function En(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&vt(e.id,e.input.code,t)}catch{}}function Dn(){let{state:e,dispatch:t}=Re(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(null),u=(0,Z.useRef)(new Map),{selectedThreadId:d,selectedProjectId:f,messages:p,queuedChatMessages:m,isStreaming:h,processingThreadIds:g}=e;l.current=d;let _=(0,Z.useCallback)((e,n,r)=>{if(u.current.get(e)!==r||(u.current.delete(e),r.stopHandled))return;let i=Be(r.segments)||`...`;if(r.error&&(r.segments.length===0||i===`...`)){let i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r.error}`,contentType:`text`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};t({type:Y.AddMessage,message:i,threadId:e}),t({type:Y.ResetStream,threadId:e}),t({type:Y.RemoveProcessingThread,threadId:e});return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};t({type:Y.AddMessage,message:a,threadId:e}),t({type:Y.ResetStream,threadId:e}),t({type:Y.MarkThreadCompleted,threadId:e}),t({type:Y.RemoveProcessingThread,threadId:e})},[t]),v=(0,Z.useCallback)(()=>{if(!d)return;c(d);let n=u.current.get(d);n&&(n.stopHandled=!0,n.controller.abort(),n.cancel?.(),u.current.delete(d)),ne(d);let r={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||`default`,isThinking:!1};t({type:Y.AddMessage,message:r,threadId:d}),t({type:Y.ResetStream,threadId:d}),t({type:Y.MarkThreadCompleted,threadId:d}),t({type:Y.RemoveProcessingThread,threadId:d})},[d,t,e.streamingModel]);(0,Z.useEffect)(()=>()=>{for(let e of u.current.values())e.controller.abort(),e.cancel?.();u.current.clear()},[]),(0,Z.useEffect)(()=>{if(!d)return;let e=!1;async function n(){try{let n=await se(d);e||t({type:Y.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:Y.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[d,f,t]);let b=(0,Z.useCallback)((e,r,a)=>{let s=u.current.get(e);s&&(s.controller.abort(),s.cancel?.());let c=new AbortController,d={controller:c,cancel:null,segments:[],assistantMessage:``,assistantThinking:``,hasStructuredContent:!1,error:null,stopHandled:!1};return u.current.set(e,d),t({type:Y.ResetStream,threadId:e}),t({type:Y.SetStreaming,isStreaming:!0,threadId:e}),r(c.signal).then(n=>{if(!n||c.signal.aborted){_(e,a,d);return}d.cancel=oe(n,n=>{if(t({type:Y.IncrementStreamEventCount,threadId:e}),n.type===`error`){let t=n.content||`Unknown error occurred`;d.error=t,e===l.current&&i(t);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){n.partial?.content?.[0]?.id&&n.delta&&t({type:Y.UpdateToolCallProgress,toolCallId:n.partial.content[0].id,progress:{toolCallId:n.partial.content[0].id,toolName:n.partial.content[0].name,delta:n.delta,partial:n.partial}});return}if(n.model&&t({type:Y.SetStreamModel,model:n.model,threadId:e}),n.type===`thinking`||n.isThinking){let r=n.content??``;En(r,e),d.assistantThinking+=r,d.segments=ze(d.segments,`thinking`,r),t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:d.segments,threadId:e})}else if(n.type===`result`)d.hasStructuredContent=!0,d.assistantMessage=n.content??``,d.segments=Ve(d.segments,n.content??``),t({type:Y.SetStreamContent,content:n.content??``,threadId:e});else{if(d.hasStructuredContent)return;let r=n.content??``;d.assistantMessage+=r,d.segments=ze(d.segments,`content`,r),t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:d.segments,threadId:e})}}},()=>{_(e,a,d)},t=>{if(t.includes(`AbortError`)||t.includes(`canceled`)||t.includes(`BodyStreamBuffer was aborted`)){_(e,a,d);return}d.error=t,e===l.current&&i(t)},n=>{if(t({type:Y.IncrementStreamEventCount,threadId:e}),n.role===`assistant`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);if(n.isThinking??!1){d.assistantThinking+=i,d.segments=ze(d.segments,`thinking`,i),t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:i,segments:d.segments,threadId:e});return}let a=!1;if(typeof r==`object`&&Array.isArray(r)&&r.length>0)a=!0;else if(typeof i==`string`&&i.trim().startsWith(`[`))try{let e=JSON.parse(i);a=Array.isArray(e)&&e.length>0}catch{}a?(d.hasStructuredContent=!0,d.assistantMessage=i,d.segments=Ve(d.segments,i),t({type:Y.SetStreamContent,content:i,threadId:e})):(d.assistantMessage+=i,d.segments=ze(d.segments,`content`,i),t({type:Y.AppendStreamChunk,chunkType:`content`,content:i,segments:d.segments,threadId:e}))}else if(n.role===`tool`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);i&&(d.assistantMessage+=i,d.segments=ze(d.segments,`content`,i),t({type:Y.AppendStreamChunk,chunkType:`content`,content:i,segments:d.segments,threadId:e}))}})}).catch(r=>{if(u.current.delete(e),r instanceof Error&&r.name===`AbortError`){t({type:Y.ResetStream,threadId:e});return}if(r instanceof n){t({type:Y.ResetStream,threadId:e}),o(!0);return}if(r instanceof Error&&r.message.includes(`not currently processing`)){t({type:Y.ResetStream,threadId:e});return}let a=r instanceof Error?r.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`;e===l.current&&i(a),console.error(`Failed to subscribe to chat stream:`,r),t({type:Y.ResetStream,threadId:e})}),c},[t,_]);(0,Z.useEffect)(()=>{for(let t of g)u.current.has(t)||e.threadStreamingStates[t]?.isStreaming||b(t,e=>ve(t,e),`default`)},[b,g,e.threadStreamingStates]);let x=(0,Z.useCallback)(async(e,n,r,a,o,s,l)=>{if(!d)return;let u=d;i(null),c(null);let p=`msg-${Date.now()}`,m;try{let e=await V(u,p);e.success&&e.stashed&&e.checkpointRef&&(m=e.checkpointRef)}catch{}let h={messageId:p,sender:`user`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,attachments:r.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:m};t({type:Y.AddMessage,message:h,threadId:u});let g=e.trim().replace(/\n/g,` `).slice(0,100);if(f&&(y(u,{title:g}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:Y.UpdateThreadTitle,projectId:f,threadId:u,title:g})),s){let r=a??void 0;if(!r&&typeof n==`string`){let e=n.split(/[:/]/)[0]?.trim();e&&(r=e)}if(!r){let e={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:e,threadId:u}),t({type:Y.ResetStream,threadId:u});return}t({type:Y.SetStreaming,isStreaming:!0,threadId:u});try{let i=await R(e,n,r,u),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1,generatedImageUrl:i.imageUrl,generatedImageData:i.imageData};t({type:Y.AddMessage,message:a,threadId:u})}catch(e){let r=e instanceof Error?e.message:`Image generation failed`,i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r}`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:i,threadId:u})}finally{t({type:Y.ResetStream,threadId:u})}return}b(u,t=>ae(u,e,n,r,t,a,o,l),n)},[d,f,t,b]);(0,Z.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||h||n.threadId!==d)return;let r=setTimeout(()=>{t({type:Y.ClearPendingChatMessage}),x(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,h,d,t,x]);let S=(0,Z.useMemo)(()=>d?m.filter(e=>e.threadId===d):[],[d,m]),C=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(h||!d||S.length===0||C.current)return;let[e]=S;C.current=!0,t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{x(e.message,e.model,e.attachments,e.provider,e.planMode,e.imageMode,e.ralphMode),C.current=!1},0);return()=>{clearTimeout(n),C.current=!1}},[t,x,h,S,d]),{error:r,setError:i,handleSend:x,handleStop:v,isStreaming:h,selectedThreadId:d,queuedMessagesForThread:S,handleRemoveQueuedMessage:(0,Z.useCallback)(e=>{let n=S.find(t=>t.id===e);t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||h||p.length>0||!d)&&x(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[t,x,h,p.length,S,d]),showEmptyBalanceDialog:a,setShowEmptyBalanceDialog:o}}function On(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=Ce(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(Ze,{children:[(0,Q.jsx)(Je,{children:`Balance empty`}),(0,Q.jsx)(qe,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,Q.jsxs)(Ye,{children:[o,(0,Q.jsx)(Xe,{children:(0,Q.jsx)(D,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,Q.jsx)(Qe,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function kn(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(jn),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(An),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[i,`/`,n.length,` completed`]}),t[6]=i,t[7]=n.length,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[a,o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function An(e){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,Q.jsx)(fe,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,Q.jsx)(z,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,Q.jsx)(F,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function jn(e){return e.status===`done`}function Mn(){let e=(0,X.c)(16),{todos:t}=(0,Z.useContext)(ct),[n,r]=(0,Z.useState)(!1),i;e[0]===t?i=e[1]:(i=t.filter(Nn),e[0]=t,e[1]=i);let a=i.length;if(t.length-a<=0)return null;let o,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r(!0),c=(0,Q.jsx)(v,{className:`h-4 w-4 shrink-0`}),e[2]=o,e[3]=c):(o=e[2],c=e[3]);let l;e[4]!==a||e[5]!==t.length?(l=(0,Q.jsxs)(D,{variant:`outline`,size:`sm`,className:`gap-2 bg-background ml-2`,onClick:o,children:[c,a,` of `,t.length,` complete`]}),e[4]=a,e[5]=t.length,e[6]=l):l=e[6];let u;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(P,{children:(0,Q.jsx)(x,{children:`Tasks`})}),e[7]=u):u=e[7];let d;e[8]===t?d=e[9]:(d=(0,Q.jsxs)(s,{className:`max-w-md`,children:[u,(0,Q.jsx)(kn,{todos:t})]}),e[8]=t,e[9]=d);let f;e[10]!==n||e[11]!==d?(f=(0,Q.jsx)(ue,{open:n,onOpenChange:r,children:d}),e[10]=n,e[11]=d,e[12]=f):f=e[12];let p;return e[13]!==l||e[14]!==f?(p=(0,Q.jsxs)(Q.Fragment,{children:[l,f]}),e[13]=l,e[14]=f,e[15]=p):p=e[15],p}function Nn(e){return e.status===`done`}function Pn(e){let t=(0,X.c)(36),{messages:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?[]:n,t[0]=n,t[1]=r);let i=r,{state:a,dispatch:o}=Re(),{isCreatingProject:s,selectedThreadId:c}=a,{handleSend:l,handleStop:u,isStreaming:d,queuedMessagesForThread:f,handleRemoveQueuedMessage:p,showEmptyBalanceDialog:m,setShowEmptyBalanceDialog:h}=Dn(),g=a.pendingChatMessage?.threadId===c,v=d||g,y=i.length>0,{hasChanges:b,changedFilesCount:x}=Sn(c??void 0),{setActiveMainTab:S}=$e(),C;t[2]!==o||t[3]!==c?(C=async()=>{if(c)try{let e=await _(c);o({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let t=await se(c);o({type:Y.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},t[2]=o,t[3]=c,t[4]=C):C=t[4];let w=C,T;t[5]===h?T=t[6]:(T=()=>h(!1),t[5]=h,t[6]=T);let E;t[7]!==m||t[8]!==T?(E=(0,Q.jsx)(On,{open:m,onClose:T}),t[7]=m,t[8]=T,t[9]=E):E=t[9];let O;t[10]!==x||t[11]!==w||t[12]!==b||t[13]!==y||t[14]!==S?(O=(y||b)&&(0,Q.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8 flex items-center gap-2`,children:[y&&(0,Q.jsxs)(D,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:w,children:[(0,Q.jsx)(he,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),b&&(0,Q.jsxs)(D,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:()=>S(`review`),children:[(0,Q.jsx)(be,{className:`h-4 w-4 shrink-0`}),x,` `,x===1?`File`:`Files`,` Changed`]}),y&&(0,Q.jsx)(Mn,{})]}),t[10]=x,t[11]=w,t[12]=b,t[13]=y,t[14]=S,t[15]=O):O=t[15];let k=!c&&!s,A;t[16]!==v||t[17]!==p||t[18]!==l||t[19]!==u||t[20]!==f||t[21]!==k?(A=(0,Q.jsx)(qt,{onSend:l,onStop:u,isStreaming:v,disabled:k,initialValue:``,queuedMessages:f,onRemoveQueuedMessage:p,isOverlay:!1}),t[16]=v,t[17]=p,t[18]=l,t[19]=u,t[20]=f,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==O||t[24]!==A?(j=(0,Q.jsxs)(`div`,{className:`relative`,children:[O,A]}),t[23]=O,t[24]=A,t[25]=j):j=t[25];let M=c??void 0,N;t[26]!==v||t[27]!==i||t[28]!==M?(N=(0,Q.jsx)(Tn,{threadId:M,isStreaming:v,messages:i}),t[26]=v,t[27]=i,t[28]=M,t[29]=N):N=t[29];let P;t[30]!==N||t[31]!==j?(P=(0,Q.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[j,N]}),t[30]=N,t[31]=j,t[32]=P):P=t[32];let F;return t[33]!==P||t[34]!==E?(F=(0,Q.jsxs)(Q.Fragment,{children:[E,P]}),t[33]=P,t[34]=E,t[35]=F):F=t[35],F}export{st as _,an as a,nn as c,vt as d,mt as f,ut as g,lt as h,rn as i,tn as l,dt as m,Sn as n,ln as o,ht as p,Qt as r,en as s,Pn as t,$t as u};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$n as t,Mr as n,Sa as r,aa as i,pa as a,ua as o,wa as s}from"./dialogs-config-B91VQpxo.js";import{C as c,T as l,_ as u,b as d,d as f,f as p,g as m,h,m as g,w as _,x as v,y}from"./react-vendor-nPkCWaAR.js";var b=r(),x=e(s(),1),S=n(),C=d,w=l,T=x.forwardRef((e,n)=>{let r=(0,b.c)(14),i,a,s,c;r[0]===e?(i=r[1],a=r[2],s=r[3],c=r[4]):({className:a,inset:s,children:i,...c}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=s,r[4]=c);let l=s&&`pl-8`,u;r[5]!==a||r[6]!==l?(u=t(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,l,a),r[5]=a,r[6]=l,r[7]=u):u=r[7];let d;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(o,{className:`ml-auto h-4 w-4`}),r[8]=d):d=r[8];let f;return r[9]!==i||r[10]!==c||r[11]!==n||r[12]!==u?(f=(0,S.jsxs)(_,{ref:n,className:u,...c,children:[i,d]}),r[9]=i,r[10]=c,r[11]=n,r[12]=u,r[13]=f):f=r[13],f});T.displayName=_.displayName;var E=x.forwardRef((e,n)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,S.jsx)(c,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});E.displayName=c.displayName;var D=x.forwardRef((e,n)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,S.jsx)(u,{children:(0,S.jsx)(p,{ref:n,className:o,...a})}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});D.displayName=p.displayName;var O=x.forwardRef((e,n)=>{let r=(0,b.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=t(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==n||r[9]!==c?(l=(0,S.jsx)(g,{ref:n,className:c,...o}),r[7]=o,r[8]=n,r[9]=c,r[10]=l):l=r[10],l});O.displayName=g.displayName;var k=x.forwardRef((e,n)=>{let r=(0,b.c)(14),i,o,s,c;r[0]===e?(i=r[1],o=r[2],s=r[3],c=r[4]):({className:s,children:o,checked:i,...c}=e,r[0]=e,r[1]=i,r[2]=o,r[3]=s,r[4]=c);let l;r[5]===s?l=r[6]:(l=t(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s),r[5]=s,r[6]=l);let u;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(h,{children:(0,S.jsx)(a,{className:`h-4 w-4`})})}),r[7]=u):u=r[7];let d;return r[8]!==i||r[9]!==o||r[10]!==c||r[11]!==n||r[12]!==l?(d=(0,S.jsxs)(f,{ref:n,className:l,checked:i,...c,children:[u,o]}),r[8]=i,r[9]=o,r[10]=c,r[11]=n,r[12]=l,r[13]=d):d=r[13],d});k.displayName=f.displayName;var A=x.forwardRef((e,n)=>{let r=(0,b.c)(12),a,o,s;r[0]===e?(a=r[1],o=r[2],s=r[3]):({className:o,children:a,...s}=e,r[0]=e,r[1]=a,r[2]=o,r[3]=s);let c;r[4]===o?c=r[5]:(c=t(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),r[4]=o,r[5]=c);let l;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(h,{children:(0,S.jsx)(i,{className:`h-2 w-2 fill-current`})})}),r[6]=l):l=r[6];let u;return r[7]!==a||r[8]!==s||r[9]!==n||r[10]!==c?(u=(0,S.jsxs)(y,{ref:n,className:c,...s,children:[l,a]}),r[7]=a,r[8]=s,r[9]=n,r[10]=c,r[11]=u):u=r[11],u});A.displayName=y.displayName;var j=x.forwardRef((e,n)=>{let r=(0,b.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=t(`px-2 py-1.5 text-sm font-semibold text-foreground`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==n||r[9]!==c?(l=(0,S.jsx)(m,{ref:n,className:c,...o}),r[7]=o,r[8]=n,r[9]=c,r[10]=l):l=r[10],l});j.displayName=m.displayName;var M=x.forwardRef((e,n)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`-mx-1 my-1 h-px bg-border`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,S.jsx)(v,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});M.displayName=v.displayName;var N=e=>{let n=(0,b.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=t(`ml-auto text-xs tracking-widest text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,S.jsx)(`span`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};N.displayName=`ContextMenuShortcut`;export{w as a,M as i,D as n,O as r,C as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./history-view-Dj4NiScy.js";export{e as ConversationHistoryView,e as default};
@@ -1,3 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$n as t,Di as n,Gi as r,Hi as i,Jn as a,Ln as o,Mr as s,Nt as c,On as l,Q as u,Qn as d,Sa as f,Si as p,Ti as m,Ui as h,Un as g,Xn as _,Zn as v,ci as y,da as b,gi as x,hi as S,it as C,qn as w,qt as T,ua as E,ut as D,wa as O,wi as k}from"./dialogs-config-B91VQpxo.js";import{D as ee}from"./react-vendor-nPkCWaAR.js";import{Mt as A}from"./monaco-BGyhgQtx.js";import{a as j,t as M}from"./store-D28g9VUj.js";import{t as N}from"./textarea-Bp3p1-25.js";import{c as P,s as te,u as ne}from"./history-view-Dj4NiScy.js";import{_ as re,t as ie}from"./chat-input-container-VwmGKJFJ.js";import{t as F}from"./standard-list-item-DyALhVYe.js";import{n as ae}from"./utils-Bhu11Tpg.js";import{t as oe}from"./page-toolbar-DnVFnCgq.js";import{n as se,r as ce,t as I}from"./resizable-CEv7JjTI.js";import{a as L,n as R,r as le,t as z}from"./context-menu-B6K8j1ha.js";var B=e(O(),1),V=f(),H=s();function U(e){let t=(0,V.c)(17),{children:n,title:r,headerAction:i,footer:a}=e,s;t[0]===r?s=t[1]:(s=r&&(0,H.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:r}),t[0]=r,t[1]=s);let c;t[2]===s?c=t[3]:(c=(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:s}),t[2]=s,t[3]=c);let l;t[4]===i?l=t[5]:(l=i&&(0,H.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:i}),t[4]=i,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-6`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===n?d=t[10]:(d=(0,H.jsx)(o,{className:`flex-1`,children:n}),t[9]=n,t[10]=d);let f;t[11]===a?f=t[12]:(f=a&&(0,H.jsx)(`div`,{className:`border-t border-sidebar-border`,children:a}),t[11]=a,t[12]=f);let p;return t[13]!==u||t[14]!==d||t[15]!==f?(p=(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[u,d,f]}),t[13]=u,t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function ue(e){let t=[],n={};return e.forEach((e,r)=>{let i=e.path.split(`/`),a=t,o=``;for(let e=0;e<i.length-1;e++){if(o=o?`${o}/${i[e]}`:i[e],!n[o]){let t={id:`dir:${o}`,name:i[e],children:[]};n[o]=t,a.push(t)}a=n[o].children}a.push({id:`file:${e.path}`,name:i[i.length-1],fileIndex:r,status:e.status})}),t}var W={added:`text-green-500`,deleted:`text-red-500`,untracked:`text-green-500`,renamed:`text-blue-500`,modified:`text-orange-500`},G={added:`A`,deleted:`D`,untracked:`U`,renamed:`R`,modified:`M`};function K(e){return t(`status-badge font-mono text-xs font-semibold`,W[e]??`text-orange-500`)}function de(e){return G[e]??`M`}function fe(e){let a=(0,V.c)(37),{treeData:o,files:s,isLoading:c,error:l,selectedFileIndex:u,onFileSelect:d,onRevertFile:f}=e,p;a[0]===s?p=a[1]:(p=s.reduce(me,0),a[0]=s,a[1]=p);let m=p,g;a[2]===s?g=a[3]:(g=s.reduce(q,0),a[2]=s,a[3]=g);let _=g,v=s.length===1?``:`s`,b;a[4]!==s.length||a[5]!==v?(b=(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s.length,` file`,v]}),a[4]=s.length,a[5]=v,a[6]=b):b=a[6];let x;a[7]===m?x=a[8]:(x=(0,H.jsxs)(`span`,{className:`text-xs text-green-500`,children:[`+`,m]}),a[7]=m,a[8]=x);let S;a[9]===_?S=a[10]:(S=(0,H.jsxs)(`span`,{className:`text-xs text-red-500`,children:[`-`,_]}),a[9]=_,a[10]=S);let C;a[11]!==b||a[12]!==x||a[13]!==S?(C=(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b,x,S]}),a[11]=b,a[12]=x,a[13]=S,a[14]=C):C=a[14];let w=C;if(c){let e;a[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center pt-3 pb-2`,children:(0,H.jsx)(n,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),a[15]=e):e=a[15];let t;return a[16]===w?t=a[17]:(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:w,children:e}),a[16]=w,a[17]=t),t}if(l){let e;a[18]===l?e=a[19]:(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-destructive text-xs text-center`,children:l})}),a[18]=l,a[19]=e);let t;return a[20]!==w||a[21]!==e?(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:w,children:e}),a[20]=w,a[21]=e,a[22]=t):t=a[22],t}if(s.length===0){let e;a[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs text-center`,children:`No changes to review`})}),a[23]=e):e=a[23];let t;return a[24]===w?t=a[25]:(t=(0,H.jsx)(U,{title:`Review Changes`,headerAction:w,children:e}),a[24]=w,a[25]=t),t}let T;a[26]!==s||a[27]!==d||a[28]!==f||a[29]!==u?(T=(e,n)=>{let{isOpen:a,toggle:o}=n,c=!!e.children,l=(0,H.jsxs)(F,{onClick:()=>{c?o():e.fileIndex!==void 0&&d(e.fileIndex)},selected:!c&&e.fileIndex===u,className:`gap-1.5`,children:[c?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(E,{className:t(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,a&&`rotate-90`)}),a?(0,H.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,H.jsx)(i,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}):(0,H.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.name}),!c&&e.status&&(0,H.jsx)(`span`,{className:K(e.status),children:de(e.status)})]});return c?l:(0,H.jsxs)(z,{children:[(0,H.jsx)(L,{asChild:!0,children:l}),(0,H.jsx)(R,{children:(0,H.jsxs)(le,{onClick:()=>{e.fileIndex!==void 0&&f?.(s[e.fileIndex])},children:[(0,H.jsx)(y,{className:`mr-2 h-3.5 w-3.5`}),`Revert Change`]})})]})},a[26]=s,a[27]=d,a[28]=f,a[29]=u,a[30]=T):T=a[30];let D;a[31]!==T||a[32]!==o?(D=(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto pt-3 pb-2 px-1`,children:(0,H.jsx)(re,{nodes:o,defaultOpen:!0,resetKey:o,indent:16,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:T})}),a[31]=T,a[32]=o,a[33]=D):D=a[33];let O;return a[34]!==w||a[35]!==D?(O=(0,H.jsx)(U,{title:`Review Changes`,headerAction:w,children:D}),a[34]=w,a[35]=D,a[36]=O):O=a[36],O}function q(e,t){return e+t.hunks.reduce(J,0)}function J(e,t){return e+t.changes.filter(pe).length}function pe(e){return e.type===`delete`}function me(e,t){return e+t.hunks.reduce(Y,0)}function Y(e,t){return e+t.changes.filter(he).length}function he(e){return e.type===`add`}function ge(e){let t=(0,V.c)(2),{isOpen:n}=e,r=n===void 0||n?`ml-[-40px]`:``,i;return t[0]===r?i=t[1]:(i=(0,H.jsx)(I,{withHandle:!0,className:r}),t[0]=r,t[1]=i),i}function _e(e){let t=(0,V.c)(35),{open:n,lineNumber:r,lineContent:i,initialComment:o,isEditing:s,onSave:c,onDelete:l,onClose:u}=e,[f,p]=(0,B.useState)((o===void 0?``:o)??``),m;t[0]!==c||t[1]!==f?(m=()=>{f.trim()&&c(f.trim())},t[0]=c,t[1]=f,t[2]=m):m=t[2];let h=m,y;t[3]===h?y=t[4]:(y=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),h())},t[3]=h,t[4]=y);let b=y,x;t[5]===u?x=t[6]:(x=e=>{e||u()},t[5]=u,t[6]=x);let S;t[7]===r?S=t[8]:(S=(0,H.jsx)(v,{children:(0,H.jsxs)(d,{className:`text-sm font-medium`,children:[`Comment on line `,r]})}),t[7]=r,t[8]=S);let C=i||` `,T;t[9]===C?T=t[10]:(T=(0,H.jsx)(`div`,{className:`rounded bg-muted px-3 py-2 font-mono text-xs text-muted-foreground overflow-x-auto whitespace-pre`,children:C}),t[9]=C,t[10]=T);let E;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>p(e.target.value),t[11]=E):E=t[11];let D;t[12]!==b||t[13]!==f?(D=(0,H.jsx)(N,{autoFocus:!0,placeholder:`Add a comment... (Cmd+Enter to save)`,value:f,onChange:E,onKeyDown:b,rows:12,className:`resize-none text-sm`}),t[12]=b,t[13]=f,t[14]=D):D=t[14];let O;t[15]!==s||t[16]!==l?(O=s&&l&&(0,H.jsx)(g,{variant:`destructive`,size:`sm`,onClick:l,className:`mr-auto`,children:`Delete`}),t[15]=s,t[16]=l,t[17]=O):O=t[17];let k;t[18]===f?k=t[19]:(k=f.trim(),t[18]=f,t[19]=k);let ee=!k,A;t[20]!==h||t[21]!==ee?(A=(0,H.jsx)(g,{size:`sm`,onClick:h,disabled:ee,children:`Save`}),t[20]=h,t[21]=ee,t[22]=A):A=t[22];let j;t[23]!==O||t[24]!==A?(j=(0,H.jsxs)(_,{className:`gap-2 sm:gap-0`,children:[O,A]}),t[23]=O,t[24]=A,t[25]=j):j=t[25];let M;t[26]!==j||t[27]!==S||t[28]!==T||t[29]!==D?(M=(0,H.jsxs)(a,{className:`max-w-2xl`,children:[S,T,D,j]}),t[26]=j,t[27]=S,t[28]=T,t[29]=D,t[30]=M):M=t[30];let P;return t[31]!==n||t[32]!==M||t[33]!==x?(P=(0,H.jsx)(w,{open:n,onOpenChange:x,children:M}),t[31]=n,t[32]=M,t[33]=x,t[34]=P):P=t[34],P}function X({threadId:e,onExit:n}){let{state:r,dispatch:i}=j(),{resolvedTheme:a}=ae(),[o,s]=(0,B.useState)([]),[d,f]=(0,B.useState)(!0),[h,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(0),[w,O]=(0,B.useState)(!1),[N,re]=(0,B.useState)(!1),F=(0,B.useRef)(null),I=(0,B.useMemo)(()=>r.diffComments[e]??[],[r.diffComments,e]),L=(0,B.useCallback)(t=>{let n=r.diffComments[e]??[],a=typeof t==`function`?t(n):t;i({type:M.SetDiffComments,threadId:e,comments:a})},[i,e,r.diffComments]),[R,le]=(0,B.useState)(null),[z,V]=(0,B.useState)(null),[U,W]=(0,B.useState)(null),G=(0,B.useRef)(null),K=(0,B.useRef)(I),de=(0,B.useRef)(R),q=(0,B.useRef)({isFullView:w,selectedFileIndex:v,files:o}),J=(0,B.useRef)({original:[],modified:[]}),pe=(0,B.useRef)(!0);(0,B.useEffect)(()=>{K.current=I},[I]),(0,B.useEffect)(()=>{de.current=R},[R]),(0,B.useEffect)(()=>{q.current={isFullView:w,selectedFileIndex:v,files:o}},[w,v,o]);let me=(0,B.useCallback)(()=>{F.current&&(N?F.current.expand():F.current.collapse())},[N]),Y=(0,B.useCallback)(async()=>{if(e){f(!0),_(null);try{s((await D(e)).files||[]),y(0)}catch(e){_(e instanceof Error?e.message:`Failed to load diff`)}finally{f(!1)}}},[e]);(0,B.useEffect)(()=>{Y()},[Y]);let he=(0,B.useCallback)(async t=>{try{await T(e,t.path),await Y()}catch(e){_(e instanceof Error?e.message:`Failed to revert file`)}},[e,Y]),X=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if((r.diffComments[e]??[]).length>0){X.current=!0;return}c(e).then(t=>{t.diffComments&&t.diffComments.length>0&&i({type:M.SetDiffComments,threadId:e,comments:t.diffComments}),X.current=!0}).catch(()=>{X.current=!0})},[e]),(0,B.useEffect)(()=>{X.current&&l(e,{diffComments:I}).catch(()=>{})},[e,I]);let ve=(0,B.useMemo)(()=>ue(o),[o]),Z=e=>{if(e.hunks.length===0)return null;let t=1/0,n=0;return e.hunks.forEach(e=>{let r=Math.min(e.oldStart,e.newStart),i=e.oldStart+e.oldLines,a=e.newStart+e.newLines,o=Math.max(i,a);t=Math.min(t,r),n=Math.max(n,o)}),t===1/0?null:{startLine:Math.max(1,t-2),endLine:n+2}},ye=(e,t,n)=>e.split(`
2
- `).slice(t-1,n).join(`
3
- `),be=e=>{let t=Z(e);return t?t.startLine<=1:!0},xe=e=>({ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sh:`shell`,yaml:`yaml`,yml:`yaml`,xml:`xml`,sql:`sql`})[e.split(`.`).pop()??``]||`plaintext`,Q=o[v],Se=Q?w?Q.oldContent:(()=>{let e=Z(Q);return e?ye(Q.oldContent,e.startLine,e.endLine):Q.oldContent})():``,Ce=Q?w?Q.newContent:(()=>{let e=Z(Q);return e?ye(Q.newContent,e.startLine,e.endLine):Q.newContent})():``,$=(0,B.useCallback)(()=>{if(!pe.current)return;let e=G.current;if(!e)return;let{isFullView:t,selectedFileIndex:n,files:r}=q.current,i=K.current,a=de.current,o=r[n];if(!o)return;let s=(e,r)=>{let s=t?null:Z(o),c=i.filter(e=>e.fileIndex===n&&e.side===r),l=new Set(c.map(e=>s?e.lineNumber-s.startLine+1:e.lineNumber)),u=e.getModel()?.getLineCount()??0,d=[];for(let e=1;e<=u;e++)l.has(e)||d.push({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:1},options:{isWholeLine:!0,glyphMarginClassName:`diff-gutter-add-comment`,glyphMarginHoverMessage:{value:`$(add) Click to add a comment`},stickiness:A.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}});let f=c.map(e=>{let t=s?e.lineNumber-s.startLine+1:e.lineNumber;if(t<1)return null;let n=i.indexOf(e)===a;return{range:{startLineNumber:t,startColumn:1,endLineNumber:t,endColumn:1},options:{isWholeLine:!0,className:n?`diff-comment-active-line`:`diff-comment-marked-line`,glyphMarginClassName:n?`diff-comment-glyph-active`:`diff-comment-glyph`,glyphMarginHoverMessage:{value:e.comment},stickiness:A.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}}}).filter(e=>e!==null);d.push(...f);let p=r===`original`?J.current.original:J.current.modified,m=e.deltaDecorations(p,d);r===`original`?J.current.original=m:J.current.modified=m};s(e.getOriginalEditor(),`original`),s(e.getModifiedEditor(),`modified`)},[]);(0,B.useEffect)(()=>{$()},[$,I,R,v,w,Q]),(0,B.useEffect)(()=>()=>{G.current=null,J.current={original:[],modified:[]}},[v]),(0,B.useEffect)(()=>()=>{pe.current=!1,G.current&&=(G.current.getOriginalEditor().getModel()?.dispose(),G.current.getModifiedEditor().getModel()?.dispose(),G.current.dispose(),null),J.current={original:[],modified:[]}},[]);let we=(0,B.useCallback)(e=>{G.current=e;let t=e=>e===A.MouseTargetType.GUTTER_GLYPH_MARGIN||e===A.MouseTargetType.GUTTER_LINE_NUMBERS||e===A.MouseTargetType.GUTTER_LINE_DECORATIONS||e===A.MouseTargetType.GUTTER_VIEW_ZONE,n=(e,n)=>{e.onMouseDown(r=>{if(!r.target?.position||!t(r.target.type))return;let i=r.target.position.lineNumber,{isFullView:a,selectedFileIndex:o,files:s}=q.current,c=s[o];if(!c)return;let l=a?null:Z(c),u=l?l.startLine+i-1:i,d=e.getModel()?.getLineContent(i)??``,f=K.current.find(e=>e.fileIndex===o&&e.lineNumber===u&&e.side===n);f?W(f):V({lineNumber:u,lineContent:d,side:n})})};n(e.getOriginalEditor(),`original`),n(e.getModifiedEditor(),`modified`),setTimeout(()=>{G.current===e&&$()},150)},[$]),Te=(0,B.useCallback)(e=>{if(z&&Q){let t={id:`comment-${Date.now()}`,filePath:Q.path,fileIndex:v,lineNumber:z.lineNumber,lineContent:z.lineContent,comment:e,side:z.side};L(e=>[...e,t]),V(null)}else U&&(L(t=>t.map(t=>t.id===U.id?{...t,comment:e}:t)),W(null))},[z,U,Q,v,L]),Ee=(0,B.useCallback)(()=>{U&&(L(e=>e.filter(e=>e.id!==U.id)),W(null))},[U,L]),De=(0,B.useCallback)(e=>{if(I.length===0)return;let t=(e%I.length+I.length)%I.length,n=I[t];le(t),y(n.fileIndex),setTimeout(()=>{let e=G.current;if(!e)return;let t=o[n.fileIndex];if(!t)return;let r=w?null:Z(t),i=r?n.lineNumber-r.startLine+1:n.lineNumber;(n.side===`original`?e.getOriginalEditor():e.getModifiedEditor()).revealLineInCenter(Math.max(1,i)),$()},100)},[I,o,w,$]),Oe=(0,B.useCallback)(()=>{De((R??0)-1)},[De,R]),ke=(0,B.useCallback)(()=>{De((R??-1)+1)},[De,R]),Ae=(0,B.useCallback)(async()=>{let t=r.projectModelSelections[e];if(!t)try{let e=await C(),n=Object.values(e).flat();if(n.length>0)t=n[0];else{console.error(`No models available to process comments`);return}}catch(e){console.error(`Failed to load models:`,e);return}let a=t.id,o=t.provider;try{let{prompt:t}=await u(e,I);L([]),i({type:M.SetPendingChatMessage,message:{threadId:e,message:t,model:a,provider:o}}),n()}catch(e){console.error(`Failed to fix comments:`,e),typeof window<`u`&&window.alert(`Failed to process comments. Please try again.`)}},[I,r.projectModelSelections,i,e,n,L]),je={readOnly:!0,renderSideBySide:!0,ignoreTrimWhitespace:!1,renderOverviewRuler:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},folding:!1,glyphMargin:!0,lineNumbers:Q&&(w||be(Q))?`on`:`off`,diffWordWrap:`on`,originalEditable:!1,automaticLayout:!0};return(0,H.jsxs)(`div`,{className:`diff-view-root flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`diff-body flex flex-1 overflow-hidden`,children:(0,H.jsxs)(ce,{direction:`horizontal`,children:[(0,H.jsx)(se,{ref:F,defaultSize:25,minSize:12,maxSize:40,collapsible:!0,collapsedSize:0,onCollapse:()=>re(!0),onExpand:()=>re(!1),className:`border-r border-transparent`,children:(0,H.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,H.jsx)(fe,{treeData:ve,files:o,isLoading:d,error:h,selectedFileIndex:v,onFileSelect:y,onRevertFile:he})})}),(0,H.jsx)(ge,{isOpen:!N}),(0,H.jsx)(se,{className:`overflow-hidden bg-transparent`,children:(0,H.jsxs)(`div`,{className:`diff-editor-panel flex h-full bg-transparent flex-col overflow-hidden`,children:[(0,H.jsxs)(oe,{className:t(`bg-transparent`,N&&`h-auto py-3 flex-col items-start gap-3 md:flex-row md:items-center md:h-[71px] md:py-0 md:gap-2 justify-between`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(g,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0`,onClick:me,children:[N?(0,H.jsx)(S,{className:`h-4 w-4`}):(0,H.jsx)(x,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Toggle file tree`})]}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:Q?Q.path:`Review Changes`})]}),(0,H.jsxs)(`div`,{className:t(`flex items-center gap-2`,N&&`ml-0`,!N&&`ml-auto`,`md:ml-auto`),children:[(0,H.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>O(e=>!e),disabled:!Q,className:`h-8 gap-1 px-2 text-xs`,children:w?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(p,{className:`h-3 w-3`}),` Show changes only`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(m,{className:`h-3 w-3`}),` Show full file`]})}),I.length>0&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(te,{children:[(0,H.jsx)(ne,{asChild:!0,children:(0,H.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:Oe,disabled:(R??0)===0,children:(0,H.jsx)(b,{className:`h-3 w-3`})})}),(0,H.jsx)(P,{children:`Previous comment`})]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:I.length===1?`1 Comment`:`Comment ${(R??0)+1} of ${I.length}`}),(0,H.jsxs)(te,{children:[(0,H.jsx)(ne,{asChild:!0,children:(0,H.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:ke,disabled:(R??0)===I.length-1,children:(0,H.jsx)(E,{className:`h-3 w-3`})})}),(0,H.jsx)(P,{children:`Next comment`})]})]}),I.length>0&&(0,H.jsxs)(te,{children:[(0,H.jsx)(ne,{asChild:!0,children:(0,H.jsxs)(g,{size:`sm`,onClick:Ae,className:`h-8 gap-1 px-3 text-xs bg-foreground text-background hover:bg-foreground/90`,children:[(0,H.jsx)(k,{className:`h-3 w-3`}),`Fix all comments`]})}),(0,H.jsx)(P,{children:`Send all comments to Tarsk for resolution`})]})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 bg-transparent relative`,children:[(0,H.jsx)(ee,{height:`100%`,language:xe(Q?.path||``),original:Se,modified:Ce,theme:a===`dark`?`vs-dark`:`vs-light`,onMount:we,options:je},`diff-${v}`),(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0`,children:(0,H.jsx)(ie,{})})]})]})})]})}),(0,H.jsx)(_e,{open:z!==null||U!==null,lineNumber:U?.lineNumber??z?.lineNumber??0,lineContent:U?.lineContent??z?.lineContent??``,initialComment:U?.comment,isEditing:U!==null,onSave:Te,onDelete:Ee,onClose:()=>{V(null),W(null)}},`${U?.id??``}-${z?.lineNumber??``}-${z?.side??``}`)]})}export{X as DiffView,X as default};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$n as t,Ar as n,Ca as r,Cr as i,Dr as a,Er as o,Fr as s,Ln as c,Mr as l,Or as u,Pr as d,Rn as f,Rr as p,Sa as m,Un as h,_r as g,a as _,ct as v,da as y,ea as b,fa as x,gr as S,hr as C,i as w,ia as T,jr as E,kr as D,la as O,mr as k,n as A,pa as j,r as M,u as N,ua as ee,vr as te,wa as P,wr as F,xr as ne,yr as re,zn as ie}from"./dialogs-config-B91VQpxo.js";var I=e(P(),1),L=e(r(),1),R=m(),z=l(),ae=[`top`,`right`,`bottom`,`left`],B=Math.min,V=Math.max,oe=Math.round,se=Math.floor,H=e=>({x:e,y:e}),ce={left:`right`,right:`left`,bottom:`top`,top:`bottom`},le={start:`end`,end:`start`};function ue(e,t,n){return V(e,B(t,n))}function U(e,t){return typeof e==`function`?e(t):e}function W(e){return e.split(`-`)[0]}function de(e){return e.split(`-`)[1]}function fe(e){return e===`x`?`y`:`x`}function pe(e){return e===`y`?`height`:`width`}var me=new Set([`top`,`bottom`]);function G(e){return me.has(W(e))?`y`:`x`}function he(e){return fe(G(e))}function ge(e,t,n){n===void 0&&(n=!1);let r=de(e),i=he(e),a=pe(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Te(o)),[o,Te(o)]}function _e(e){let t=Te(e);return[ve(e),t,ve(t)]}function ve(e){return e.replace(/start|end/g,e=>le[e])}var ye=[`left`,`right`],be=[`right`,`left`],xe=[`top`,`bottom`],Se=[`bottom`,`top`];function Ce(e,t,n){switch(e){case`top`:case`bottom`:return n?t?be:ye:t?ye:be;case`left`:case`right`:return t?xe:Se;default:return[]}}function we(e,t,n,r){let i=de(e),a=Ce(W(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ve)))),a}function Te(e){return e.replace(/left|right|bottom|top/g,e=>ce[e])}function Ee(e){return{top:0,right:0,bottom:0,left:0,...e}}function De(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ee(e)}function Oe(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ke(e,t,n){let{reference:r,floating:i}=e,a=G(t),o=he(t),s=pe(o),c=W(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(de(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function Ae(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=U(t,e),p=De(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Oe(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Oe(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var je=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ke(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:{...o,detectOverflow:o.detectOverflow??Ae},elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=ke(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},Me=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=U(e,t)||{};if(l==null)return{};let d=De(u),f={x:n,y:r},p=he(i),m=pe(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=B(d[_],T),D=B(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=ue(O,A,k),M=!c.arrow&&de(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),Ne=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=U(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=W(r),_=G(o),v=W(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Te(o)]:_e(o)),x=p!==`none`;!d&&x&&b.push(...we(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ge(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==G(t))||T.every(e=>G(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=G(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function Pe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Fe(e){return ae.some(t=>e[t]>=0)}var Ie=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=U(e,t);switch(i){case`referenceHidden`:{let e=Pe(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Fe(e)}}}case`escaped`:{let e=Pe(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Fe(e)}}}default:return{}}}}},Le=new Set([`left`,`top`]);async function Re(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=W(n),s=de(n),c=G(n)===`y`,l=Le.has(o)?-1:1,u=a&&c?-1:1,d=U(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ze=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Re(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Be=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=U(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=G(W(i)),p=fe(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=ue(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=ue(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Ve=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=U(e,t),u={x:n,y:r},d=G(i),f=fe(d),p=u[f],m=u[d],h=U(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Le.has(W(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},He=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=U(e,t),u=await o.detectOverflow(t,l),d=W(i),f=de(i),p=G(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=B(h-u[g],v),x=B(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=V(u.left,0),t=V(u.right,0),n=V(u.top,0),r=V(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:V(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:V(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Ue(){return typeof window<`u`}function We(e){return Ge(e)?(e.nodeName||``).toLowerCase():`#document`}function K(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function q(e){return((Ge(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Ge(e){return Ue()?e instanceof Node||e instanceof K(e).Node:!1}function J(e){return Ue()?e instanceof Element||e instanceof K(e).Element:!1}function Y(e){return Ue()?e instanceof HTMLElement||e instanceof K(e).HTMLElement:!1}function Ke(e){return!Ue()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof K(e).ShadowRoot}var qe=new Set([`inline`,`contents`]);function Je(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!qe.has(i)}var Ye=new Set([`table`,`td`,`th`]);function Xe(e){return Ye.has(We(e))}var Ze=[`:popover-open`,`:modal`];function Qe(e){return Ze.some(t=>{try{return e.matches(t)}catch{return!1}})}var $e=[`transform`,`translate`,`scale`,`rotate`,`perspective`],et=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],tt=[`paint`,`layout`,`strict`,`content`];function nt(e){let t=it(),n=J(e)?X(e):e;return $e.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||et.some(e=>(n.willChange||``).includes(e))||tt.some(e=>(n.contain||``).includes(e))}function rt(e){let t=Z(e);for(;Y(t)&&!ot(t);){if(nt(t))return t;if(Qe(t))return null;t=Z(t)}return null}function it(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var at=new Set([`html`,`body`,`#document`]);function ot(e){return at.has(We(e))}function X(e){return K(e).getComputedStyle(e)}function st(e){return J(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Z(e){if(We(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ke(e)&&e.host||q(e);return Ke(t)?t.host:t}function ct(e){let t=Z(e);return ot(t)?e.ownerDocument?e.ownerDocument.body:e.body:Y(t)&&Je(t)?t:ct(t)}function lt(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ct(e),i=r===e.ownerDocument?.body,a=K(r);if(i){let e=ut(a);return t.concat(a,a.visualViewport||[],Je(r)?r:[],e&&n?lt(e):[])}return t.concat(r,lt(r,[],n))}function ut(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function dt(e){let t=X(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Y(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=oe(n)!==a||oe(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ft(e){return J(e)?e:e.contextElement}function pt(e){let t=ft(e);if(!Y(t))return H(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=dt(t),o=(a?oe(n.width):n.width)/r,s=(a?oe(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var mt=H(0);function ht(e){let t=K(e);return!it()||!t.visualViewport?mt:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function gt(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==K(e)?!1:t}function _t(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ft(e),o=H(1);t&&(r?J(r)&&(o=pt(r)):o=pt(e));let s=gt(a,n,r)?ht(a):H(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=K(a),t=r&&J(r)?K(r):r,n=e,i=ut(n);for(;i&&r&&t!==n;){let e=pt(i),t=i.getBoundingClientRect(),r=X(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=K(i),i=ut(n)}}return Oe({width:u,height:d,x:c,y:l})}function vt(e,t){let n=st(e).scrollLeft;return t?t.left+n:_t(q(e)).left+n}function yt(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-vt(e,n),y:n.top+t.scrollTop}}function bt(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=q(r),s=t?Qe(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=H(1),u=H(0),d=Y(r);if((d||!d&&!a)&&((We(r)!==`body`||Je(o))&&(c=st(r)),Y(r))){let e=_t(r);l=pt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?yt(o,c):H(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function xt(e){return Array.from(e.getClientRects())}function St(e){let t=q(e),n=st(e),r=e.ownerDocument.body,i=V(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=V(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+vt(e),s=-n.scrollTop;return X(r).direction===`rtl`&&(o+=V(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Ct=25;function wt(e,t){let n=K(e),r=q(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=it();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=vt(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Ct&&(a-=o)}else l<=Ct&&(a+=l);return{width:a,height:o,x:s,y:c}}var Tt=new Set([`absolute`,`fixed`]);function Et(e,t){let n=_t(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Y(e)?pt(e):H(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Dt(e,t,n){let r;if(t===`viewport`)r=wt(e,n);else if(t===`document`)r=St(q(e));else if(J(t))r=Et(t,n);else{let n=ht(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Oe(r)}function Ot(e,t){let n=Z(e);return n===t||!J(n)||ot(n)?!1:X(n).position===`fixed`||Ot(n,t)}function kt(e,t){let n=t.get(e);if(n)return n;let r=lt(e,[],!1).filter(e=>J(e)&&We(e)!==`body`),i=null,a=X(e).position===`fixed`,o=a?Z(e):e;for(;J(o)&&!ot(o);){let t=X(o),n=nt(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&Tt.has(i.position)||Je(o)&&!n&&Ot(e,o))?r=r.filter(e=>e!==o):i=t,o=Z(o)}return t.set(e,r),r}function At(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Qe(t)?[]:kt(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=Dt(t,n,i);return e.top=V(r.top,e.top),e.right=B(r.right,e.right),e.bottom=B(r.bottom,e.bottom),e.left=V(r.left,e.left),e},Dt(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function jt(e){let{width:t,height:n}=dt(e);return{width:t,height:n}}function Mt(e,t,n){let r=Y(t),i=q(t),a=n===`fixed`,o=_t(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=H(0);function l(){c.x=vt(i)}if(r||!r&&!a)if((We(t)!==`body`||Je(i))&&(s=st(t)),r){let e=_t(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?yt(i,s):H(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Nt(e){return X(e).position===`static`}function Pt(e,t){if(!Y(e)||X(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return q(e)===n&&(n=n.ownerDocument.body),n}function Ft(e,t){let n=K(e);if(Qe(e))return n;if(!Y(e)){let t=Z(e);for(;t&&!ot(t);){if(J(t)&&!Nt(t))return t;t=Z(t)}return n}let r=Pt(e,t);for(;r&&Xe(r)&&Nt(r);)r=Pt(r,t);return r&&ot(r)&&Nt(r)&&!nt(r)?n:r||rt(e)||n}var It=async function(e){let t=this.getOffsetParent||Ft,n=this.getDimensions,r=await n(e.floating);return{reference:Mt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lt(e){return X(e).direction===`rtl`}var Rt={convertOffsetParentRelativeRectToViewportRelativeRect:bt,getDocumentElement:q,getClippingRect:At,getOffsetParent:Ft,getElementRects:It,getClientRects:xt,getDimensions:jt,getScale:pt,isElement:J,isRTL:Lt};function zt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bt(e,t){let n=null,r,i=q(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=se(d),h=se(i.clientWidth-(u+f)),g=se(i.clientHeight-(d+p)),_=se(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:V(0,B(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!zt(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Vt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=ft(e),u=i||a?[...l?lt(l):[],...lt(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Bt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?_t(e):null;c&&g();function g(){let t=_t(e);h&&!zt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Ht=ze,Ut=Be,Wt=Ne,Gt=He,Kt=Ie,qt=Me,Jt=Ve,Yt=(e,t,n)=>{let r=new Map,i={platform:Rt,...n},a={...i.platform,_c:r};return je(e,t,{...i,platform:a})},Xt=typeof document<`u`?I.useLayoutEffect:function(){};function Zt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Zt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Zt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Qt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $t(e,t){let n=Qt(e);return Math.round(t*n)/n}function en(e){let t=I.useRef(e);return Xt(()=>{t.current=e}),t}function tn(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=I.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=I.useState(r);Zt(f,r)||p(r);let[m,h]=I.useState(null),[g,_]=I.useState(null),v=I.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=I.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=I.useRef(null),C=I.useRef(null),w=I.useRef(u),T=c!=null,E=en(c),D=en(i),O=en(l),k=I.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Yt(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Zt(w.current,t)&&(w.current=t,L.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Xt(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=I.useRef(!1);Xt(()=>(A.current=!0,()=>{A.current=!1}),[]),Xt(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=I.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=I.useMemo(()=>({reference:b,floating:x}),[b,x]),N=I.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=$t(M.floating,u.x),r=$t(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Qt(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return I.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var nn=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:qt({element:r.current,padding:i}).fn(n):r?qt({element:r,padding:i}).fn(n):{}}}},rn=(e,t)=>({...Ht(e),options:[e,t]}),an=(e,t)=>({...Ut(e),options:[e,t]}),on=(e,t)=>({...Jt(e),options:[e,t]}),sn=(e,t)=>({...Wt(e),options:[e,t]}),cn=(e,t)=>({...Gt(e),options:[e,t]}),ln=(e,t)=>({...Kt(e),options:[e,t]}),un=(e,t)=>({...nn(e),options:[e,t]}),dn=`Arrow`,fn=I.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,z.jsx)(F.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,z.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});fn.displayName=dn;var pn=fn;function mn(e){let[t,r]=I.useState(void 0);return n(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let n=t[0],i,a;if(`borderBoxSize`in n){let e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;r({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else r(void 0)},[e]),t}var hn=`Popper`,[gn,_n]=E(hn),[vn,yn]=gn(hn),bn=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null);return(0,z.jsx)(vn,{scope:t,anchor:r,onAnchorChange:i,children:n})};bn.displayName=hn;var xn=`PopperAnchor`,Sn=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=yn(xn,n),o=I.useRef(null),s=d(t,o),c=I.useRef(null);return I.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,z.jsx)(F.div,{...i,ref:s})});Sn.displayName=xn;var Cn=`PopperContent`,[wn,Tn]=gn(Cn),En=I.forwardRef((e,t)=>{let{__scopePopper:r,side:a=`bottom`,sideOffset:o=0,align:s=`center`,alignOffset:c=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:m=`partial`,hideWhenDetached:h=!1,updatePositionStrategy:g=`optimized`,onPlaced:_,...v}=e,y=yn(Cn,r),[b,x]=I.useState(null),S=d(t,e=>x(e)),[C,w]=I.useState(null),T=mn(C),E=T?.width??0,D=T?.height??0,O=a+(s===`center`?``:`-`+s),k=typeof p==`number`?p:{top:0,right:0,bottom:0,left:0,...p},A=Array.isArray(f)?f:[f],j=A.length>0,M={padding:k,boundary:A.filter(An),altBoundary:j},{refs:N,floatingStyles:ee,placement:te,isPositioned:P,middlewareData:ne}=tn({strategy:`fixed`,placement:O,whileElementsMounted:(...e)=>Vt(...e,{animationFrame:g===`always`}),elements:{reference:y.anchor},middleware:[rn({mainAxis:o+D,alignmentAxis:c}),u&&an({mainAxis:!0,crossAxis:!1,limiter:m===`partial`?on():void 0,...M}),u&&sn({...M}),cn({...M,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),C&&un({element:C,padding:l}),jn({arrowWidth:E,arrowHeight:D}),h&&ln({strategy:`referenceHidden`,...M})]}),[re,ie]=Mn(te),L=i(_);n(()=>{P&&L?.()},[P,L]);let R=ne.arrow?.x,ae=ne.arrow?.y,B=ne.arrow?.centerOffset!==0,[V,oe]=I.useState();return n(()=>{b&&oe(window.getComputedStyle(b).zIndex)},[b]),(0,z.jsx)(`div`,{ref:N.setFloating,"data-radix-popper-content-wrapper":``,style:{...ee,transform:P?ee.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:V,"--radix-popper-transform-origin":[ne.transformOrigin?.x,ne.transformOrigin?.y].join(` `),...ne.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,z.jsx)(wn,{scope:r,placedSide:re,onArrowChange:w,arrowX:R,arrowY:ae,shouldHideArrow:B,children:(0,z.jsx)(F.div,{"data-side":re,"data-align":ie,...v,ref:S,style:{...v.style,animation:P?void 0:`none`}})})})});En.displayName=Cn;var Dn=`PopperArrow`,On={top:`bottom`,right:`left`,bottom:`top`,left:`right`},kn=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Tn(Dn,n),a=On[i.placedSide];return(0,z.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,z.jsx)(pn,{...r,ref:t,style:{...r.style,display:`block`}})})});kn.displayName=Dn;function An(e){return e!==null}var jn=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Mn(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Mn(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Nn=bn,Pn=Sn,Fn=En,In=kn,Ln=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Rn=`VisuallyHidden`,zn=I.forwardRef((e,t)=>(0,z.jsx)(F.span,{...e,ref:t,style:{...Ln,...e.style}}));zn.displayName=Rn;var Bn=zn,[Vn,Hn]=E(`Tooltip`,[_n]),Un=_n(),Wn=`TooltipProvider`,Gn=700,Kn=`tooltip.open`,[qn,Jn]=Vn(Wn),Yn=e=>{let{__scopeTooltip:t,delayDuration:n=Gn,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=I.useRef(!0),s=I.useRef(!1),c=I.useRef(0);return I.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,z.jsx)(qn,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:I.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:I.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:I.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Yn.displayName=Wn;var Xn=`Tooltip`,[Zn,Qn]=Vn(Xn),$n=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Jn(Xn,e.__scopeTooltip),l=Un(t),[d,f]=I.useState(null),p=D(),m=I.useRef(0),h=o??c.disableHoverableContent,g=s??c.delayDuration,_=I.useRef(!1),[v,y]=u({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Kn))):c.onClose(),a?.(e)},caller:Xn}),b=I.useMemo(()=>v?_.current?`delayed-open`:`instant-open`:`closed`,[v]),x=I.useCallback(()=>{window.clearTimeout(m.current),m.current=0,_.current=!1,y(!0)},[y]),S=I.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y(!1)},[y]),C=I.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{_.current=!0,y(!0),m.current=0},g)},[g,y]);return I.useEffect(()=>()=>{m.current&&=(window.clearTimeout(m.current),0)},[]),(0,z.jsx)(Nn,{...l,children:(0,z.jsx)(Zn,{scope:t,contentId:p,open:v,stateAttribute:b,trigger:d,onTriggerChange:f,onTriggerEnter:I.useCallback(()=>{c.isOpenDelayedRef.current?C():x()},[c.isOpenDelayedRef,C,x]),onTriggerLeave:I.useCallback(()=>{h?S():(window.clearTimeout(m.current),m.current=0)},[S,h]),onOpen:x,onClose:S,disableHoverableContent:h,children:n})})};$n.displayName=Xn;var er=`TooltipTrigger`,tr=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Qn(er,n),a=Jn(er,n),o=Un(n),c=d(t,I.useRef(null),i.onTriggerChange),l=I.useRef(!1),u=I.useRef(!1),f=I.useCallback(()=>l.current=!1,[]);return I.useEffect(()=>()=>document.removeEventListener(`pointerup`,f),[f]),(0,z.jsx)(Pn,{asChild:!0,...o,children:(0,z.jsx)(F.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:s(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:s(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:s(e.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener(`pointerup`,f,{once:!0})}),onFocus:s(e.onFocus,()=>{l.current||i.onOpen()}),onBlur:s(e.onBlur,i.onClose),onClick:s(e.onClick,i.onClose)})})});tr.displayName=er;var nr=`TooltipPortal`,[rr,ir]=Vn(nr,{forceMount:void 0}),ar=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Qn(nr,t);return(0,z.jsx)(rr,{scope:t,forceMount:n,children:(0,z.jsx)(g,{present:n||a.open,children:(0,z.jsx)(te,{asChild:!0,container:i,children:r})})})};ar.displayName=nr;var or=`TooltipContent`,sr=I.forwardRef((e,t)=>{let n=ir(or,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Qn(or,e.__scopeTooltip);return(0,z.jsx)(g,{present:r||o.open,children:o.disableHoverableContent?(0,z.jsx)(fr,{side:i,...a,ref:t}):(0,z.jsx)(cr,{side:i,...a,ref:t})})}),cr=I.forwardRef((e,t)=>{let n=Qn(or,e.__scopeTooltip),r=Jn(or,e.__scopeTooltip),i=I.useRef(null),a=d(t,i),[o,s]=I.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:f}=r,p=I.useCallback(()=>{s(null),f(!1)},[f]),m=I.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=gr(r,hr(r,n.getBoundingClientRect())),a=_r(t.getBoundingClientRect());s(yr([...i,...a])),f(!0)},[f]);return I.useEffect(()=>()=>p(),[p]),I.useEffect(()=>{if(c&&u){let e=e=>m(e,u),t=e=>m(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,m,p]),I.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!vr(n,o);r?p():i&&(p(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,p]),(0,z.jsx)(fr,{...e,ref:a})}),[lr,ur]=Vn(Xn,{isInside:!1}),dr=a(`TooltipContent`),fr=I.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Qn(or,n),l=Un(n),{onClose:u}=c;return I.useEffect(()=>(document.addEventListener(Kn,u),()=>document.removeEventListener(Kn,u)),[u]),I.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,z.jsx)(ne,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,z.jsxs)(Fn,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,z.jsx)(dr,{children:r}),(0,z.jsx)(lr,{scope:n,isInside:!0,children:(0,z.jsx)(Bn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});sr.displayName=or;var pr=`TooltipArrow`,mr=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Un(n);return ur(pr,n).isInside?null:(0,z.jsx)(In,{...i,...r,ref:t})});mr.displayName=pr;function hr(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function gr(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function _r(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function vr(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function yr(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),br(t)}function br(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xr=Yn,Sr=$n,Cr=tr,wr=sr,Tr=xr,Er=Sr,Dr=Cr,Or=I.forwardRef((e,n)=>{let r=(0,R.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,sideOffset:o,...a}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=o===void 0?4:o,c;r[4]===i?c=r[5]:(c=t(`z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[4]=i,r[5]=c);let l;return r[6]!==a||r[7]!==n||r[8]!==s||r[9]!==c?(l=(0,z.jsx)(wr,{ref:n,sideOffset:s,className:c,...a}),r[6]=a,r[7]=n,r[8]=s,r[9]=c,r[10]=l):l=r[10],l});Or.displayName=wr.displayName;function kr(e){let t=I.useRef({value:e,previous:e});return I.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ar=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`w-full caption-bottom text-sm`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(`div`,{className:`relative w-full overflow-auto`,children:(0,z.jsx)(`table`,{ref:n,className:o,...a})}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});Ar.displayName=`Table`;var jr=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`[&_tr]:border-b`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(`thead`,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});jr.displayName=`TableHeader`;var Mr=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`[&_tr:last-child]:border-0`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(`tbody`,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});Mr.displayName=`TableBody`;var Nr=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`border-t bg-muted/50 font-medium [&>tr]:last:border-b-0`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(`tfoot`,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});Nr.displayName=`TableFooter`;var Pr=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(`tr`,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});Pr.displayName=`TableRow`;var Q=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(`th`,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});Q.displayName=`TableHead`;var Fr=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`p-4 align-middle [&:has([role=checkbox])]:pr-0`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(`td`,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});Fr.displayName=`TableCell`;var Ir=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`mt-4 text-sm text-muted-foreground`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(`caption`,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});Ir.displayName=`TableCaption`;var Lr=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Rr=[` `,`Enter`],zr=`Select`,[Br,Vr,Hr]=N(zr),[Ur,Wr]=E(zr,[Hr,_n]),Gr=_n(),[Kr,qr]=Ur(zr),[Jr,Yr]=Ur(zr),Xr=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:d,autoComplete:f,disabled:p,required:m,form:h}=e,g=Gr(t),[_,v]=I.useState(null),[y,b]=I.useState(null),[x,S]=I.useState(!1),C=ie(l),[w,T]=u({prop:r,defaultProp:i??!1,onChange:a,caller:zr}),[E,O]=u({prop:o,defaultProp:s,onChange:c,caller:zr}),k=I.useRef(null),A=_?h||!!_.closest(`form`):!0,[j,M]=I.useState(new Set),N=Array.from(j).map(e=>e.props.value).join(`;`);return(0,z.jsx)(Nn,{...g,children:(0,z.jsxs)(Kr,{required:m,scope:t,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:D(),value:E,onValueChange:O,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:k,disabled:p,children:[(0,z.jsx)(Br.Provider,{scope:t,children:(0,z.jsx)(Jr,{scope:e.__scopeSelect,onNativeOptionAdd:I.useCallback(e=>{M(t=>new Set(t).add(e))},[]),onNativeOptionRemove:I.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),A?(0,z.jsxs)(Wi,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:E,onChange:e=>O(e.target.value),disabled:p,form:h,children:[E===void 0?(0,z.jsx)(`option`,{value:``}):null,Array.from(j)]},N):null]})})};Xr.displayName=zr;var Zr=`SelectTrigger`,Qr=I.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Gr(n),o=qr(Zr,n),c=o.disabled||r,l=d(t,o.onTriggerChange),u=Vr(n),f=I.useRef(`touch`),[p,m,h]=Ki(e=>{let t=u().filter(e=>!e.disabled),n=qi(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),g=e=>{c||(o.onOpenChange(!0),h()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,z.jsx)(Pn,{asChild:!0,...a,children:(0,z.jsx)(F.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":Gi(o.value)?``:void 0,...i,ref:l,onClick:s(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&g(e)}),onPointerDown:s(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(g(e),e.preventDefault())}),onKeyDown:s(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&m(e.key),!(t&&e.key===` `)&&Lr.includes(e.key)&&(g(),e.preventDefault())})})})});Qr.displayName=Zr;var $r=`SelectValue`,ei=I.forwardRef((e,t)=>{let{__scopeSelect:r,className:i,style:a,children:o,placeholder:s=``,...c}=e,l=qr($r,r),{onValueNodeHasChildrenChange:u}=l,f=o!==void 0,p=d(t,l.onValueNodeChange);return n(()=>{u(f)},[u,f]),(0,z.jsx)(F.span,{...c,ref:p,style:{pointerEvents:`none`},children:Gi(l.value)?(0,z.jsx)(z.Fragment,{children:s}):o})});ei.displayName=$r;var ti=`SelectIcon`,ni=I.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,z.jsx)(F.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ni.displayName=ti;var ri=`SelectPortal`,ii=e=>(0,z.jsx)(te,{asChild:!0,...e});ii.displayName=ri;var ai=`SelectContent`,oi=I.forwardRef((e,t)=>{let r=qr(ai,e.__scopeSelect),[i,a]=I.useState();if(n(()=>{a(new DocumentFragment)},[]),!r.open){let t=i;return t?L.createPortal((0,z.jsx)(si,{scope:e.__scopeSelect,children:(0,z.jsx)(Br.Slot,{scope:e.__scopeSelect,children:(0,z.jsx)(`div`,{children:e.children})})}),t):null}return(0,z.jsx)(di,{...e,ref:t})});oi.displayName=ai;var $=10,[si,ci]=Ur(ai),li=`SelectContentImpl`,ui=o(`SelectContent.RemoveScroll`),di=I.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:l,align:u,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:_,avoidCollisions:v,...y}=e,b=qr(ai,n),[x,w]=I.useState(null),[T,E]=I.useState(null),D=d(t,e=>w(e)),[O,A]=I.useState(null),[j,M]=I.useState(null),N=Vr(n),[ee,te]=I.useState(!1),P=I.useRef(!1);I.useEffect(()=>{if(x)return k(x)},[x]),S();let F=I.useCallback(e=>{let[t,...n]=N().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&T&&(T.scrollTop=0),n===r&&T&&(T.scrollTop=T.scrollHeight),n?.focus(),document.activeElement!==i))return},[N,T]),ie=I.useCallback(()=>F([O,x]),[F,O,x]);I.useEffect(()=>{ee&&ie()},[ee,ie]);let{onOpenChange:L,triggerPointerDownPosRef:R}=b;I.useEffect(()=>{if(x){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(R.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(R.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():x.contains(n.target)||L(!1),document.removeEventListener(`pointermove`,t),R.current=null};return R.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[x,L,R]),I.useEffect(()=>{let e=()=>L(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[L]);let[ae,B]=Ki(e=>{let t=N().filter(e=>!e.disabled),n=qi(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),V=I.useCallback((e,t,n)=>{let r=!P.current&&!n;(b.value!==void 0&&b.value===t||r)&&(A(e),r&&(P.current=!0))},[b.value]),oe=I.useCallback(()=>x?.focus(),[x]),se=I.useCallback((e,t,n)=>{let r=!P.current&&!n;(b.value!==void 0&&b.value===t||r)&&M(e)},[b.value]),H=r===`popper`?hi:pi,ce=H===hi?{side:c,sideOffset:l,align:u,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:_,avoidCollisions:v}:{};return(0,z.jsx)(si,{scope:n,content:x,viewport:T,onViewportChange:E,itemRefCallback:V,selectedItem:O,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:ie,selectedItemText:j,position:r,isPositioned:ee,searchRef:ae,children:(0,z.jsx)(C,{as:ui,allowPinchZoom:!0,children:(0,z.jsx)(re,{asChild:!0,trapped:b.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:s(i,e=>{b.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,z.jsx)(ne,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:(0,z.jsx)(H,{role:`listbox`,id:b.contentId,"data-state":b.open?`open`:`closed`,dir:b.dir,onContextMenu:e=>e.preventDefault(),...y,...ce,onPlaced:()=>te(!0),ref:D,style:{display:`flex`,flexDirection:`column`,outline:`none`,...y.style},onKeyDown:s(y.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&B(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=N().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>F(t)),e.preventDefault()}})})})})})})});di.displayName=li;var fi=`SelectItemAlignedPosition`,pi=I.forwardRef((e,t)=>{let{__scopeSelect:r,onPlaced:i,...a}=e,o=qr(ai,r),s=ci(ai,r),[c,l]=I.useState(null),[u,p]=I.useState(null),m=d(t,e=>p(e)),h=Vr(r),g=I.useRef(!1),_=I.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=s,S=I.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&u&&v&&y&&b){let e=o.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=o.valueNode.getBoundingClientRect(),r=b.getBoundingClientRect();if(o.dir!==`rtl`){let i=r.left-t.left,a=n.left-i,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-$,d=f(a,[$,Math.max($,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let i=t.right-r.right,a=window.innerWidth-n.right-i,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-$,d=f(a,[$,Math.max($,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let a=h(),s=window.innerHeight-$*2,l=v.scrollHeight,d=window.getComputedStyle(u),p=parseInt(d.borderTopWidth,10),m=parseInt(d.paddingTop,10),_=parseInt(d.borderBottomWidth,10),x=parseInt(d.paddingBottom,10),S=p+m+l+x+_,C=Math.min(y.offsetHeight*5,S),w=window.getComputedStyle(v),T=parseInt(w.paddingTop,10),E=parseInt(w.paddingBottom,10),D=e.top+e.height/2-$,O=s-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=p+m+A,M=S-j;if(j<=D){let e=a.length>0&&y===a[a.length-1].ref.current;c.style.bottom=`0px`;let t=u.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?E:0)+t+_);c.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;c.style.top=`0px`;let t=Math.max(D,p+v.offsetTop+(e?T:0)+k)+M;c.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}c.style.margin=`${$}px 0`,c.style.minHeight=C+`px`,c.style.maxHeight=s+`px`,i?.(),requestAnimationFrame(()=>g.current=!0)}},[h,o.trigger,o.valueNode,c,u,v,y,b,o.dir,i]);n(()=>S(),[S]);let[C,w]=I.useState();return n(()=>{u&&w(window.getComputedStyle(u).zIndex)},[u]),(0,z.jsx)(gi,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:I.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]),children:(0,z.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,z.jsx)(F.div,{...a,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...a.style}})})})});pi.displayName=fi;var mi=`SelectPopperPosition`,hi=I.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=$,...a}=e,o=Gr(n);return(0,z.jsx)(Fn,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});hi.displayName=mi;var[gi,_i]=Ur(ai,{}),vi=`SelectViewport`,yi=I.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=ci(vi,n),o=_i(vi,n),c=d(t,a.onViewportChange),l=I.useRef(0);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,z.jsx)(Br.Slot,{scope:n,children:(0,z.jsx)(F.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:s(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-$*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})});yi.displayName=vi;var bi=`SelectGroup`,[xi,Si]=Ur(bi),Ci=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=D();return(0,z.jsx)(xi,{scope:n,id:i,children:(0,z.jsx)(F.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Ci.displayName=bi;var wi=`SelectLabel`,Ti=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Si(wi,n);return(0,z.jsx)(F.div,{id:i.id,...r,ref:t})});Ti.displayName=wi;var Ei=`SelectItem`,[Di,Oi]=Ur(Ei),ki=I.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,c=qr(Ei,n),l=ci(Ei,n),u=c.value===r,[f,p]=I.useState(a??``),[m,h]=I.useState(!1),g=d(t,e=>l.itemRefCallback?.(e,r,i)),_=D(),v=I.useRef(`touch`),y=()=>{i||(c.onValueChange(r),c.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,z.jsx)(Di,{scope:n,value:r,disabled:i,textId:_,isSelected:u,onItemTextChange:I.useCallback(e=>{p(t=>t||(e?.textContent??``).trim())},[]),children:(0,z.jsx)(Br.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:(0,z.jsx)(F.div,{role:`option`,"aria-labelledby":_,"data-highlighted":m?``:void 0,"aria-selected":u&&m,"data-state":u?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:g,onFocus:s(o.onFocus,()=>h(!0)),onBlur:s(o.onBlur,()=>h(!1)),onClick:s(o.onClick,()=>{v.current!==`mouse`&&y()}),onPointerUp:s(o.onPointerUp,()=>{v.current===`mouse`&&y()}),onPointerDown:s(o.onPointerDown,e=>{v.current=e.pointerType}),onPointerMove:s(o.onPointerMove,e=>{v.current=e.pointerType,i?l.onItemLeave?.():v.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:s(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:s(o.onKeyDown,e=>{l.searchRef?.current!==``&&e.key===` `||(Rr.includes(e.key)&&y(),e.key===` `&&e.preventDefault())})})})})});ki.displayName=Ei;var Ai=`SelectItemText`,ji=I.forwardRef((e,t)=>{let{__scopeSelect:r,className:i,style:a,...o}=e,s=qr(Ai,r),c=ci(Ai,r),l=Oi(Ai,r),u=Yr(Ai,r),[f,p]=I.useState(null),m=d(t,e=>p(e),l.onItemTextChange,e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),h=f?.textContent,g=I.useMemo(()=>(0,z.jsx)(`option`,{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:_,onNativeOptionRemove:v}=u;return n(()=>(_(g),()=>v(g)),[_,v,g]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(F.span,{id:l.textId,...o,ref:m}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?L.createPortal(o.children,s.valueNode):null]})});ji.displayName=Ai;var Mi=`SelectItemIndicator`,Ni=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Oi(Mi,n).isSelected?(0,z.jsx)(F.span,{"aria-hidden":!0,...r,ref:t}):null});Ni.displayName=Mi;var Pi=`SelectScrollUpButton`,Fi=I.forwardRef((e,t)=>{let r=ci(Pi,e.__scopeSelect),i=_i(Pi,e.__scopeSelect),[a,o]=I.useState(!1),s=d(t,i.onScrollButtonChange);return n(()=>{if(r.viewport&&r.isPositioned){let e=function(){o(t.scrollTop>0)},t=r.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[r.viewport,r.isPositioned]),a?(0,z.jsx)(Ri,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Fi.displayName=Pi;var Ii=`SelectScrollDownButton`,Li=I.forwardRef((e,t)=>{let r=ci(Ii,e.__scopeSelect),i=_i(Ii,e.__scopeSelect),[a,o]=I.useState(!1),s=d(t,i.onScrollButtonChange);return n(()=>{if(r.viewport&&r.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;o(Math.ceil(t.scrollTop)<e)},t=r.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[r.viewport,r.isPositioned]),a?(0,z.jsx)(Ri,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Li.displayName=Ii;var Ri=I.forwardRef((e,t)=>{let{__scopeSelect:r,onAutoScroll:i,...a}=e,o=ci(`SelectScrollButton`,r),c=I.useRef(null),l=Vr(r),u=I.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return I.useEffect(()=>()=>u(),[u]),n(()=>{l().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[l]),(0,z.jsx)(F.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:s(a.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(i,50))}),onPointerMove:s(a.onPointerMove,()=>{o.onItemLeave?.(),c.current===null&&(c.current=window.setInterval(i,50))}),onPointerLeave:s(a.onPointerLeave,()=>{u()})})}),zi=`SelectSeparator`,Bi=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,z.jsx)(F.div,{"aria-hidden":!0,...r,ref:t})});Bi.displayName=zi;var Vi=`SelectArrow`,Hi=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Gr(n),a=qr(Vi,n),o=ci(Vi,n);return a.open&&o.position===`popper`?(0,z.jsx)(In,{...i,...r,ref:t}):null});Hi.displayName=Vi;var Ui=`SelectBubbleInput`,Wi=I.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=I.useRef(null),a=d(r,i),o=kr(t);return I.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,z.jsx)(F.select,{...n,style:{...Ln,...n.style},ref:a,defaultValue:t})});Wi.displayName=Ui;function Gi(e){return e===``||e===void 0}function Ki(e){let t=i(e),n=I.useRef(``),r=I.useRef(0),a=I.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),o=I.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,o]}function qi(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ji(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Ji(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Yi=Xr,Xi=Qr,Zi=ei,Qi=ni,$i=ii,ea=oi,ta=yi,na=Ti,ra=ki,ia=ji,aa=Ni,oa=Fi,sa=Li,ca=Bi,la=Yi,ua=Zi,da=I.forwardRef((e,n)=>{let r=(0,R.c)(12),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:a,children:i,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s;r[4]===a?s=r[5]:(s=t(`flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,a),r[4]=a,r[5]=s);let c;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,z.jsx)(Qi,{asChild:!0,children:(0,z.jsx)(x,{className:`h-4 w-4 opacity-50`})}),r[6]=c):c=r[6];let l;return r[7]!==i||r[8]!==o||r[9]!==n||r[10]!==s?(l=(0,z.jsxs)(Xi,{ref:n,className:s,...o,children:[i,c]}),r[7]=i,r[8]=o,r[9]=n,r[10]=s,r[11]=l):l=r[11],l});da.displayName=Xi.displayName;var fa=I.forwardRef((e,n)=>{let r=(0,R.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`flex cursor-default items-center justify-center py-1`,i),r[3]=i,r[4]=o);let s;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(O,{className:`h-4 w-4`}),r[5]=s):s=r[5];let c;return r[6]!==a||r[7]!==n||r[8]!==o?(c=(0,z.jsx)(oa,{ref:n,className:o,...a,children:s}),r[6]=a,r[7]=n,r[8]=o,r[9]=c):c=r[9],c});fa.displayName=oa.displayName;var pa=I.forwardRef((e,n)=>{let r=(0,R.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`flex cursor-default items-center justify-center py-1`,i),r[3]=i,r[4]=o);let s;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(x,{className:`h-4 w-4`}),r[5]=s):s=r[5];let c;return r[6]!==a||r[7]!==n||r[8]!==o?(c=(0,z.jsx)(sa,{ref:n,className:o,...a,children:s}),r[6]=a,r[7]=n,r[8]=o,r[9]=c):c=r[9],c});pa.displayName=sa.displayName;var ma=I.forwardRef((e,n)=>{let r=(0,R.c)(21),i,a,o,s;r[0]===e?(i=r[1],a=r[2],o=r[3],s=r[4]):({className:a,children:i,position:s,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=s===void 0?`popper`:s,l=c===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,u;r[5]!==a||r[6]!==l?(u=t(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,l,a),r[5]=a,r[6]=l,r[7]=u):u=r[7];let d;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,z.jsx)(fa,{}),r[8]=d):d=r[8];let f=c===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`,p;r[9]===f?p=r[10]:(p=t(`p-1`,f),r[9]=f,r[10]=p);let m;r[11]!==i||r[12]!==p?(m=(0,z.jsx)(ta,{className:p,children:i}),r[11]=i,r[12]=p,r[13]=m):m=r[13];let h;r[14]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,z.jsx)(pa,{}),r[14]=h):h=r[14];let g;return r[15]!==c||r[16]!==o||r[17]!==n||r[18]!==u||r[19]!==m?(g=(0,z.jsx)($i,{children:(0,z.jsxs)(ea,{ref:n,className:u,position:c,...o,children:[d,m,h]})}),r[15]=c,r[16]=o,r[17]=n,r[18]=u,r[19]=m,r[20]=g):g=r[20],g});ma.displayName=ea.displayName;var ha=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`py-1.5 pl-8 pr-2 text-sm font-semibold`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(na,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});ha.displayName=na.displayName;var ga=I.forwardRef((e,n)=>{let r=(0,R.c)(14),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:a,children:i,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s;r[4]===a?s=r[5]:(s=t(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),r[4]=a,r[5]=s);let c;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,z.jsx)(aa,{children:(0,z.jsx)(j,{className:`h-4 w-4`})})}),r[6]=c):c=r[6];let l;r[7]===i?l=r[8]:(l=(0,z.jsx)(ia,{children:i}),r[7]=i,r[8]=l);let u;return r[9]!==o||r[10]!==n||r[11]!==s||r[12]!==l?(u=(0,z.jsxs)(ra,{ref:n,className:s,...o,children:[c,l]}),r[9]=o,r[10]=n,r[11]=s,r[12]=l,r[13]=u):u=r[13],u});ga.displayName=ra.displayName;var _a=I.forwardRef((e,n)=>{let r=(0,R.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`-mx-1 my-1 h-px bg-muted`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,z.jsx)(ca,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});_a.displayName=ca.displayName;var va=`__ALL_PROJECTS__`;function ya(e){let t=(0,R.c)(8),{text:n,maxLength:r}=e,i=r===void 0?100:r;if(n.length<=i){let e;return t[0]===n?e=t[1]:(e=(0,z.jsx)(z.Fragment,{children:n}),t[0]=n,t[1]=e),e}let a;t[2]!==i||t[3]!==n?(a=n.substring(0,i),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsx)(`span`,{className:`text-muted-foreground ml-2`,children:`...`}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,z.jsxs)(z.Fragment,{children:[a,o]}),t[6]=a,t[7]=s),s}function ba(e,t){let n=`${t} - `,r=e.title??e.threadId;return r.startsWith(n)?r.slice(n.length):r}async function xa(e){let t=[],n=new Set,r=``;for(let i of e)try{let e=await v(i.threadId);e?.messages&&(t.push(...e.messages),e.conversationIds&&e.conversationIds.forEach(e=>n.add(e)),e.lastUpdated>r&&(r=e.lastUpdated))}catch(e){console.warn(`Failed to load history for thread ${i.threadId}:`,e)}return t.sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),{messages:t,conversationIds:Array.from(n),lastUpdated:r??new Date().toISOString()}}var Sa=(0,I.memo)(function({isOpen:e,onClose:t,initialFilter:n,projects:r,inline:i}){let[a,o]=(0,I.useState)(null),[s,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[f,m]=(0,I.useState)(0),[g,x]=(0,I.useState)(``),[S,C]=(0,I.useState)(``),E=(0,I.useCallback)(async e=>{l(!0),d(null);try{o(await v(e))}catch(e){d(e instanceof Error?e.message:`Failed to load conversation history`)}finally{l(!1)}},[]),D=(0,I.useCallback)(async e=>{if(e){l(!0),d(null);try{let t=r.find(t=>t.projectId===e);if(!t||t.threads.length===0){o({threadId:e,messages:[],lastUpdated:new Date().toISOString(),conversationIds:[]});return}o({threadId:e,...await xa(t.threads)})}catch(e){d(e instanceof Error?e.message:`Failed to load project history`)}finally{l(!1)}}},[r]),O=(0,I.useCallback)(async()=>{l(!0),d(null);try{o({threadId:va,...await xa(r.flatMap(e=>e.threads))})}catch(e){d(e instanceof Error?e.message:`Failed to load all projects history`)}finally{l(!1)}},[r]);(0,I.useEffect)(()=>{e&&n?n.type===`thread`?(C(n.id),x(``),m(0),E(n.id)):n.type===`project`&&(x(n.id),C(``),m(0),D(n.id)):e&&!n?(x(va),C(``),m(0),O()):e||(o(null),C(``),x(``),m(0),d(null))},[e,n,E,D,O]);let k=e=>{C(e),x(``),m(0),E(e)},j=e=>{x(e),C(``),m(0),e===va?O():D(e)},N=e=>new Date(e).toLocaleString(),te=(e,t)=>{let n=new Date(e),r=new Date(t).getTime()-n.getTime();if(r<0)return{display:`0:00`,tooltip:`0 seconds`};let i=Math.floor(r/1e3),a=Math.floor(i/60),o=i%60,s=`${a}:${o.toString().padStart(2,`0`)}`,c;return c=a===0?`${o} second${o===1?``:`s`}`:o===0?`${a} minute${a===1?``:`s`}`:`${a} minute${a===1?``:`s`} ${o} second${o===1?``:`s`}`,{display:s,tooltip:c}},P=e=>({inputTokens:e.inputTokens??0,outputTokens:e.outputTokens??0});return e?(0,z.jsx)(`div`,{className:i?`h-full bg-background`:`fixed inset-0 z-50 bg-background`,children:(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[i?(0,z.jsxs)(`div`,{className:`flex items-center justify-between mb-6 px-6 pt-6`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-2xl font-bold`,children:`History`}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`View and browse conversation history across projects and threads.`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(la,{value:g,onValueChange:j,children:[(0,z.jsx)(da,{className:`w-48`,children:(0,z.jsx)(ua,{placeholder:`Select project`})}),(0,z.jsxs)(ma,{children:[(0,z.jsx)(ga,{value:va,children:`All Projects`}),r.map(e=>(0,z.jsx)(ga,{value:e.projectId,children:e.name??e.projectId},e.projectId))]})]}),(0,z.jsxs)(la,{value:S,onValueChange:k,children:[(0,z.jsx)(da,{className:`w-48`,children:(0,z.jsx)(ua,{placeholder:`Select thread`})}),(0,z.jsx)(ma,{children:r.flatMap(e=>e.threads.map(t=>(0,z.jsx)(ga,{value:t.threadId,children:ba(t,e.name??e.projectId)},t.threadId)))})]})]})]}):(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,z.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Conversation History`}),(0,z.jsxs)(la,{value:S,onValueChange:k,children:[(0,z.jsx)(da,{className:`w-48`,children:(0,z.jsx)(ua,{placeholder:`Select thread`})}),(0,z.jsx)(ma,{children:r.flatMap(e=>e.threads.map(t=>(0,z.jsx)(ga,{value:t.threadId,children:ba(t,e.name??e.projectId)},t.threadId)))})]}),(0,z.jsxs)(la,{value:g,onValueChange:j,children:[(0,z.jsx)(da,{className:`w-48`,children:(0,z.jsx)(ua,{placeholder:`Select project`})}),(0,z.jsxs)(ma,{children:[(0,z.jsx)(ga,{value:va,children:`All Projects`}),r.map(e=>(0,z.jsx)(ga,{value:e.projectId,children:e.name??e.projectId},e.projectId))]})]})]}),(0,z.jsx)(h,{variant:`action`,size:`icon-sm`,onClick:t,children:(0,z.jsx)(p,{})})]}),a?.messages&&a.messages.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b ${i?`px-6 py-3`:`p-4`}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>{f>0&&m(f-1)},disabled:f===0,children:(0,z.jsx)(y,{className:`h-4 w-4 mr-1`})}),(0,z.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>{a?.messages&&f<a.messages.length-1&&m(f+1)},disabled:!a||f>=a.messages.length-1,children:(0,z.jsx)(ee,{className:`h-4 w-4 ml-1`})})]}),(0,z.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[f+1,` of `,a?.messages.length??0,` messages`]})]}),(0,z.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:s?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,z.jsxs)(`div`,{className:`text-center`,children:[(0,z.jsx)(T,{className:`h-8 w-8 animate-spin mx-auto mb-2`}),(0,z.jsx)(`p`,{children:`Loading conversation history...`})]})}):u?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,z.jsxs)(A,{className:`max-w-md`,children:[(0,z.jsx)(w,{children:(0,z.jsx)(_,{className:`text-destructive`,children:`Error`})}),(0,z.jsxs)(M,{children:[(0,z.jsx)(`p`,{children:u}),(0,z.jsx)(h,{onClick:t,className:`mt-4`,children:`Close`})]})]})}):a?.messages?.length&&a.messages.length>0?(0,z.jsx)(c,{className:`h-full`,children:(0,z.jsx)(`div`,{className:i?`px-6 py-4`:`p-4`,children:(0,z.jsxs)(Ar,{children:[(0,z.jsx)(jr,{children:(0,z.jsxs)(Pr,{children:[(0,z.jsx)(Q,{children:`Prompt`}),(0,z.jsx)(Q,{children:`Answer`}),(0,z.jsx)(Q,{className:`w-24`,children:`Model`}),(0,z.jsx)(Q,{className:`w-24 text-right`,children:`Duration`}),(0,z.jsx)(Q,{className:`w-20 text-right`,children:`Input Tokens`}),(0,z.jsx)(Q,{className:`w-20 text-right`,children:`Output Tokens`}),(0,z.jsx)(Q,{className:`w-32 text-right`,children:`Timestamp`})]})}),(0,z.jsx)(Mr,{children:a.messages.map((e,t)=>{let{inputTokens:n,outputTokens:r}=P(e);return(0,z.jsxs)(Pr,{className:t===f?`bg-muted/50`:``,children:[(0,z.jsx)(Fr,{className:`max-w-md`,children:(0,z.jsx)(`div`,{className:`text-sm`,children:(0,z.jsx)(ya,{text:e.request.message})})}),(0,z.jsx)(Fr,{className:`max-w-md`,children:e.response?(0,z.jsx)(`div`,{className:`text-sm`,children:(0,z.jsx)(ya,{text:e.response.content})}):(0,z.jsx)(`span`,{className:`text-muted-foreground italic`,children:`No response`})}),(0,z.jsx)(Fr,{className:`text-sm`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(b,{className:`h-3 w-3 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.request.model})]})}),(0,z.jsx)(Fr,{className:`text-sm text-right`,children:e.response?(0,z.jsx)(Tr,{children:(0,z.jsxs)(Er,{children:[(0,z.jsx)(Dr,{asChild:!0,children:(0,z.jsx)(`div`,{className:`cursor-help`,children:te(e.timestamp,e.response.completedAt).display})}),(0,z.jsx)(Or,{children:(0,z.jsx)(`p`,{children:te(e.timestamp,e.response.completedAt).tooltip})})]})}):(0,z.jsx)(`span`,{className:`text-muted-foreground italic`,children:`-`})}),(0,z.jsx)(Fr,{className:`text-sm text-muted-foreground text-right`,children:n>0?n.toLocaleString():`-`}),(0,z.jsx)(Fr,{className:`text-sm text-muted-foreground text-right`,children:r>0?r.toLocaleString():`-`}),(0,z.jsx)(Fr,{className:`text-sm text-muted-foreground text-right`,children:N(e.timestamp)})]},e.id)})})]})})}):(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,z.jsxs)(`div`,{className:`max-w-md text-center space-y-2`,children:[(0,z.jsx)(`h3`,{className:`text-lg font-semibold`,children:`No History`}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`No conversation history found for this thread.`})]})})})]})}):null});export{mn as _,da as a,Or as c,zn as d,Pn as f,_n as g,Nn as h,ga as i,Tr as l,Fn as m,la as n,kr as o,In as p,ma as r,Er as s,Sa as t,Dr as u};