tarsk 0.4.29 → 0.4.31
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.
- package/dist/index.js +746 -349
- package/dist/public/assets/{account-view-YvC0mymF.js → account-view-Cdp8xegU.js} +1 -1
- package/dist/public/assets/alert-dialog-DAJFcjdR.js +1 -0
- package/dist/public/assets/api-BYFUablr.js +1 -0
- package/dist/public/assets/{browser-tab-CCXMlmPO.js → browser-tab-Ban23pgA.js} +1 -1
- package/dist/public/assets/chat-input-container-Bc7nCdKX.js +21 -0
- package/dist/public/assets/context-menu-D93N09Jw.js +1 -0
- package/dist/public/assets/conversation-history-view-qm_qW0aD.js +1 -0
- package/dist/public/assets/{dialogs-config-B91VQpxo.js → dialogs-config-VlhyoYms.js} +14 -14
- package/dist/public/assets/diff-view-DUmzPmed.js +3 -0
- package/dist/public/assets/explorer-tab-view-Bbboiq-d.js +2 -0
- package/dist/public/assets/explorer-tree-CX03Vh31.js +1 -0
- package/dist/public/assets/{explorer-view-BCJqE1-z.js → explorer-view-CMcJFEtT.js} +1 -1
- package/dist/public/assets/history-view-Cub-F9g6.js +1 -0
- package/dist/public/assets/index-C-dv630o.css +1 -0
- package/dist/public/assets/index-DaJT5K7g.js +29 -0
- package/dist/public/assets/{markdown-renderer-9nzN0Pk3.js → markdown-renderer-BPXg5AUu.js} +4 -4
- package/dist/public/assets/{mcp-server-card-BSw_FlEC.js → mcp-server-card-BCZmpcVY.js} +1 -1
- package/dist/public/assets/onboarding-BPUo1aJX.js +1 -0
- package/dist/public/assets/onboarding-dialog-vqz8baom.js +1 -0
- package/dist/public/assets/page-toolbar-CU9dGLvm.js +1 -0
- package/dist/public/assets/project-settings-view-BAs5RYWR.js +1 -0
- package/dist/public/assets/providers-list-view-67A5O5vd.js +1 -0
- package/dist/public/assets/radio-group-CRwVSJCp.js +1 -0
- package/dist/public/assets/react-vendor-CtZx3FWA.js +22 -0
- package/dist/public/assets/{resizable-CEv7JjTI.js → resizable-AKojmHeo.js} +1 -1
- package/dist/public/assets/{run-stop-button-CrjPMC0m.js → run-stop-button-DYoC8i6e.js} +2 -2
- package/dist/public/assets/settings-general-view-mu1Qq8cl.js +1 -0
- package/dist/public/assets/{settings-instructions-view-C23spY9Y.js → settings-instructions-view-DQRSZId7.js} +1 -1
- package/dist/public/assets/{settings-mcp-servers-view-ZHar6YbE.js → settings-mcp-servers-view-BqJMRVZJ.js} +4 -4
- package/dist/public/assets/settings-models-skeleton-qdDMv5hS.js +1 -0
- package/dist/public/assets/settings-models-view-DSrdZZfF.js +1 -0
- package/dist/public/assets/settings-rules-view-Dt_lfKVv.js +8 -0
- package/dist/public/assets/{settings-skills-view-D60tD-OE.js → settings-skills-view-Djrk38ol.js} +2 -2
- package/dist/public/assets/{settings-slash-commands-view-DR-pzulT.js → settings-slash-commands-view-Cm5cy2My.js} +1 -1
- package/dist/public/assets/{settings-subagents-view-InXmwmw9.js → settings-subagents-view-CsGwbSvQ.js} +2 -2
- package/dist/public/assets/settings-view-DuTfugUO.js +2 -0
- package/dist/public/assets/{side-panel-container-CO3qgRvc.js → side-panel-container-Cg99BH1l.js} +2 -2
- package/dist/public/assets/skeleton-B1fuNMHm.js +1 -0
- package/dist/public/assets/{standard-list-item-DyALhVYe.js → standard-list-item-0m99qNoa.js} +1 -1
- package/dist/public/assets/{store-D28g9VUj.js → store-DUqJt-K-.js} +1 -1
- package/dist/public/assets/{tab-context-C3z7YU59.js → tab-context-BYpxvaoz.js} +1 -1
- package/dist/public/assets/tabs-ywSKq3qp.js +1 -0
- package/dist/public/assets/{terminal-panel-EifoA6G0.js → terminal-panel-C9XWZHaD.js} +2 -2
- package/dist/public/assets/textarea-DuuNwegn.js +1 -0
- package/dist/public/assets/todos-view-CRzNrsfP.js +1 -0
- package/dist/public/assets/{use-font-size-BCtvz0bm.js → use-font-size-D2A0_bAi.js} +1 -1
- package/dist/public/assets/{use-toast-BZ79E_dX.js → use-toast-BF5WtiOJ.js} +1 -1
- package/dist/public/assets/{utils-Bhu11Tpg.js → utils-CheqpoJ4.js} +1 -1
- package/dist/public/index.html +21 -21
- package/package.json +2 -2
- package/dist/public/assets/alert-dialog-BFhUZsPe.js +0 -1
- package/dist/public/assets/api-DSvSyBH5.js +0 -1
- package/dist/public/assets/chat-input-container-VwmGKJFJ.js +0 -21
- package/dist/public/assets/context-menu-B6K8j1ha.js +0 -1
- package/dist/public/assets/conversation-history-view-DrrLyMbg.js +0 -1
- package/dist/public/assets/diff-view-C09yOc5d.js +0 -3
- package/dist/public/assets/explorer-tab-view-B1DukGdo.js +0 -2
- package/dist/public/assets/explorer-tree-DCeud6YI.js +0 -1
- package/dist/public/assets/history-view-Dj4NiScy.js +0 -1
- package/dist/public/assets/index-7TFkb0ll.css +0 -1
- package/dist/public/assets/index-BLCecayZ.js +0 -29
- package/dist/public/assets/onboarding-ClUE_I5q.js +0 -1
- package/dist/public/assets/onboarding-dialog-C2jig8mT.js +0 -1
- package/dist/public/assets/page-toolbar-DnVFnCgq.js +0 -1
- package/dist/public/assets/project-settings-view-DWn0ty7b.js +0 -1
- package/dist/public/assets/providers-list-view-B0DqNJYK.js +0 -1
- package/dist/public/assets/radio-group-CM_Wwam0.js +0 -1
- package/dist/public/assets/react-vendor-nPkCWaAR.js +0 -22
- package/dist/public/assets/settings-general-view-CwQYmnI2.js +0 -1
- package/dist/public/assets/settings-models-view-Cg6WQ4cy.js +0 -1
- package/dist/public/assets/settings-rules-view-zAx5JL4w.js +0 -8
- package/dist/public/assets/settings-view-DLRDBuwH.js +0 -2
- package/dist/public/assets/skeleton-CXoVAzC1.js +0 -1
- package/dist/public/assets/tabs-sXgL2DZz.js +0 -1
- package/dist/public/assets/textarea-Bp3p1-25.js +0 -1
- package/dist/public/assets/todos-view-DRL4px6A.js +0 -1
- /package/dist/public/assets/{dist-D5DgwfYL.js → dist-CAVGqbBm.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{ya as t}from"./dialogs-config-VlhyoYms.js";var n=e(t(),1),r=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},i=[`light`,`dark`],a=`(prefers-color-scheme: dark)`,o=typeof window>`u`,s=n.createContext(void 0),c={setTheme:e=>{},themes:[]},l=()=>n.useContext(s)??c,u=e=>n.useContext(s)?n.createElement(n.Fragment,null,e.children):n.createElement(f,{...e}),d=[`light`,`dark`],f=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:r=!0,enableColorScheme:o=!0,storageKey:c=`theme`,themes:l=d,defaultTheme:u=r?`system`:`light`,attribute:f=`data-theme`,value:_,children:v,nonce:y,scriptProps:b})=>{let[x,S]=n.useState(()=>m(c,u)),[C,w]=n.useState(()=>x===`system`?g():x),T=_?Object.values(_):l,E=n.useCallback(e=>{let n=e;if(!n)return;e===`system`&&r&&(n=g());let a=_?_[n]:n,s=t?h(y):null,c=document.documentElement,l=e=>{e===`class`?(c.classList.remove(...T),a&&c.classList.add(a)):e.startsWith(`data-`)&&(a?c.setAttribute(e,a):c.removeAttribute(e))};if(Array.isArray(f)?f.forEach(l):l(f),o){let e=i.includes(u)?u:null,t=i.includes(n)?n:e;c.style.colorScheme=t}s?.()},[y]),D=n.useCallback(e=>{let t=typeof e==`function`?e(x):e;S(t);try{localStorage.setItem(c,t)}catch{}},[x]),O=n.useCallback(t=>{w(g(t)),x===`system`&&r&&!e&&E(`system`)},[x,e]);n.useEffect(()=>{let e=window.matchMedia(a);return e.addListener(O),O(e),()=>e.removeListener(O)},[O]),n.useEffect(()=>{let e=e=>{e.key===c&&(e.newValue?S(e.newValue):D(u))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[D]),n.useEffect(()=>{E(e??x)},[e,x]);let k=n.useMemo(()=>({theme:x,setTheme:D,forcedTheme:e,resolvedTheme:x===`system`?C:x,themes:r?[...l,`system`]:l,systemTheme:r?C:void 0}),[x,D,e,C,r,l]);return n.createElement(s.Provider,{value:k},n.createElement(p,{forcedTheme:e,storageKey:c,attribute:f,enableSystem:r,enableColorScheme:o,defaultTheme:u,value:_,themes:l,nonce:y,scriptProps:b}),v)},p=n.memo(({forcedTheme:e,storageKey:t,attribute:i,enableSystem:a,enableColorScheme:o,defaultTheme:s,value:c,themes:l,nonce:u,scriptProps:d})=>{let f=JSON.stringify([i,t,s,e,l,c,a,o]).slice(1,-1);return n.createElement(`script`,{...d,suppressHydrationWarning:!0,nonce:typeof window>`u`?u:``,dangerouslySetInnerHTML:{__html:`(${r.toString()})(${f})`}})}),m=(e,t)=>{if(o)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},h=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`)),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},g=e=>(e||=window.matchMedia(a),e.matches?`dark`:`light`);export{l as n,u as t};
|
package/dist/public/index.html
CHANGED
|
@@ -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-
|
|
22
|
+
<script type="module" crossorigin src="/assets/index-DaJT5K7g.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-
|
|
26
|
-
<link rel="modulepreload" crossorigin href="/assets/history-view-
|
|
27
|
-
<link rel="modulepreload" crossorigin href="/assets/onboarding-
|
|
28
|
-
<link rel="modulepreload" crossorigin href="/assets/react-vendor-
|
|
29
|
-
<link rel="modulepreload" crossorigin href="/assets/alert-dialog-
|
|
30
|
-
<link rel="modulepreload" crossorigin href="/assets/use-toast-
|
|
31
|
-
<link rel="modulepreload" crossorigin href="/assets/store-
|
|
32
|
-
<link rel="modulepreload" crossorigin href="/assets/tab-context-
|
|
25
|
+
<link rel="modulepreload" crossorigin href="/assets/dialogs-config-VlhyoYms.js">
|
|
26
|
+
<link rel="modulepreload" crossorigin href="/assets/history-view-Cub-F9g6.js">
|
|
27
|
+
<link rel="modulepreload" crossorigin href="/assets/onboarding-BPUo1aJX.js">
|
|
28
|
+
<link rel="modulepreload" crossorigin href="/assets/react-vendor-CtZx3FWA.js">
|
|
29
|
+
<link rel="modulepreload" crossorigin href="/assets/alert-dialog-DAJFcjdR.js">
|
|
30
|
+
<link rel="modulepreload" crossorigin href="/assets/use-toast-BF5WtiOJ.js">
|
|
31
|
+
<link rel="modulepreload" crossorigin href="/assets/store-DUqJt-K-.js">
|
|
32
|
+
<link rel="modulepreload" crossorigin href="/assets/tab-context-BYpxvaoz.js">
|
|
33
33
|
<link rel="modulepreload" crossorigin href="/assets/whisper-wasm-C_Ot631g.js">
|
|
34
|
-
<link rel="modulepreload" crossorigin href="/assets/utils-
|
|
35
|
-
<link rel="modulepreload" crossorigin href="/assets/chat-input-container-
|
|
36
|
-
<link rel="modulepreload" crossorigin href="/assets/markdown-renderer-
|
|
37
|
-
<link rel="modulepreload" crossorigin href="/assets/page-toolbar-
|
|
38
|
-
<link rel="modulepreload" crossorigin href="/assets/run-stop-button-
|
|
39
|
-
<link rel="modulepreload" crossorigin href="/assets/side-panel-container-
|
|
40
|
-
<link rel="modulepreload" crossorigin href="/assets/resizable-
|
|
41
|
-
<link rel="modulepreload" crossorigin href="/assets/standard-list-item-
|
|
42
|
-
<link rel="modulepreload" crossorigin href="/assets/tabs-
|
|
43
|
-
<link rel="modulepreload" crossorigin href="/assets/textarea-
|
|
44
|
-
<link rel="modulepreload" crossorigin href="/assets/use-font-size-
|
|
34
|
+
<link rel="modulepreload" crossorigin href="/assets/utils-CheqpoJ4.js">
|
|
35
|
+
<link rel="modulepreload" crossorigin href="/assets/chat-input-container-Bc7nCdKX.js">
|
|
36
|
+
<link rel="modulepreload" crossorigin href="/assets/markdown-renderer-BPXg5AUu.js">
|
|
37
|
+
<link rel="modulepreload" crossorigin href="/assets/page-toolbar-CU9dGLvm.js">
|
|
38
|
+
<link rel="modulepreload" crossorigin href="/assets/run-stop-button-DYoC8i6e.js">
|
|
39
|
+
<link rel="modulepreload" crossorigin href="/assets/side-panel-container-Cg99BH1l.js">
|
|
40
|
+
<link rel="modulepreload" crossorigin href="/assets/resizable-AKojmHeo.js">
|
|
41
|
+
<link rel="modulepreload" crossorigin href="/assets/standard-list-item-0m99qNoa.js">
|
|
42
|
+
<link rel="modulepreload" crossorigin href="/assets/tabs-ywSKq3qp.js">
|
|
43
|
+
<link rel="modulepreload" crossorigin href="/assets/textarea-DuuNwegn.js">
|
|
44
|
+
<link rel="modulepreload" crossorigin href="/assets/use-font-size-D2A0_bAi.js">
|
|
45
45
|
<link rel="stylesheet" crossorigin href="/assets/monaco-Br_kD0ds.css">
|
|
46
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
46
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C-dv630o.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.
|
|
3
|
+
"version": "0.4.31",
|
|
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 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$n as t,Mr as n,Sa as r,Wn as i,wa as a}from"./dialogs-config-B91VQpxo.js";import{_t as o,dt as s,ft as c,gt as l,ht as u,mt as d,pt as f,ut as p}from"./react-vendor-nPkCWaAR.js";var m=r(),h=e(a(),1),g=n(),_=l,v=u,y=h.forwardRef((e,n)=>{let r=(0,m.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(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,g.jsx)(d,{className:o,...a,ref:n}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});y.displayName=d.displayName;var b=h.forwardRef((e,n)=>{let r=(0,m.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]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(y,{}),r[3]=o):o=r[3];let s;r[4]===i?s=r[5]:(s=t(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,i),r[4]=i,r[5]=s);let l;return r[6]!==a||r[7]!==n||r[8]!==s?(l=(0,g.jsxs)(v,{children:[o,(0,g.jsx)(c,{ref:n,className:s,...a})]}),r[6]=a,r[7]=n,r[8]=s,r[9]=l):l=r[9],l});b.displayName=c.displayName;var x=e=>{let n=(0,m.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(`flex flex-col space-y-2 text-center sm:text-left`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let n=(0,m.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(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,n)=>{let r=(0,m.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 s;r[3]===i?s=r[4]:(s=t(`text-lg font-semibold`,i),r[3]=i,r[4]=s);let c;return r[5]!==a||r[6]!==n||r[7]!==s?(c=(0,g.jsx)(o,{ref:n,className:s,...a}),r[5]=a,r[6]=n,r[7]=s,r[8]=c):c=r[8],c});C.displayName=o.displayName;var w=h.forwardRef((e,n)=>{let r=(0,m.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(`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,g.jsx)(f,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});w.displayName=f.displayName;var T=h.forwardRef((e,n)=>{let r=(0,m.c)(9),a,o;r[0]===e?(a=r[1],o=r[2]):({className:a,...o}=e,r[0]=e,r[1]=a,r[2]=o);let s;r[3]===a?s=r[4]:(s=t(i(),a),r[3]=a,r[4]=s);let c;return r[5]!==o||r[6]!==n||r[7]!==s?(c=(0,g.jsx)(p,{ref:n,className:s,...o}),r[5]=o,r[6]=n,r[7]=s,r[8]=c):c=r[8],c});T.displayName=p.displayName;var E=h.forwardRef((e,n)=>{let r=(0,m.c)(9),a,o;r[0]===e?(a=r[1],o=r[2]):({className:a,...o}=e,r[0]=e,r[1]=a,r[2]=o);let c;r[3]===a?c=r[4]:(c=t(i({variant:`outline`}),`mt-2 sm:mt-0`,a),r[3]=a,r[4]=c);let l;return r[5]!==o||r[6]!==n||r[7]!==c?(l=(0,g.jsx)(s,{ref:n,className:c,...o}),r[5]=o,r[6]=n,r[7]=c,r[8]=l):l=r[8],l});E.displayName=s.displayName;export{w as a,C as c,b as i,T as n,S as o,E as r,x as s,_ as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{An as e,Fn as t,In as n,Mn as r,Nn as i,Pn as a,jn as o}from"./dialogs-config-B91VQpxo.js";async function s(e,t){return r(`api/threads/${o(e)}/explorer?path=${encodeURIComponent(t)}`)}async function c(e,t){return r(`api/threads/${o(e)}/ai-file?path=${encodeURIComponent(t)}`)}async function l(e,t,r){return n(`api/threads/${o(e)}/ai-file`,{path:t,content:r})}async function u(t,n){return e(`api/threads/${o(t)}/explorer?path=${encodeURIComponent(n)}`)}async function d(e,t,n){return a(`api/threads/${o(e)}/explorer`,{path:t,newName:n})}async function f(e,n,r){return t(`api/threads/${o(e)}/explorer/file`,{dirPath:n,name:r})}function p(e,t){return`${i()}/api/threads/${o(e)}/explorer/media?path=${encodeURIComponent(t)}`}async function m(e,n,r){return t(`api/threads/${o(e)}/explorer/folder`,{dirPath:n,name:r})}export{p as a,l as c,c as i,m as n,s as o,u as r,d as s,f as t};
|
|
@@ -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,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/explorer-tree-DCeud6YI.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-B91VQpxo.js","assets/api-DSvSyBH5.js","assets/alert-dialog-BFhUZsPe.js","assets/react-vendor-nPkCWaAR.js","assets/monaco-BGyhgQtx.js","assets/monaco-Br_kD0ds.css","assets/history-view-Dj4NiScy.js","assets/context-menu-B6K8j1ha.js","assets/standard-list-item-DyALhVYe.js","assets/use-toast-BZ79E_dX.js","assets/tab-context-C3z7YU59.js","assets/explorer-view-BCJqE1-z.js","assets/markdown-renderer-9nzN0Pk3.js","assets/page-toolbar-DnVFnCgq.js","assets/store-D28g9VUj.js","assets/utils-Bhu11Tpg.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ln as t,Mr as n,Sa as r,wa as i}from"./dialogs-config-B91VQpxo.js";import{Pt as a}from"./monaco-BGyhgQtx.js";import{a as o}from"./store-D28g9VUj.js";import{n as s}from"./tab-context-C3z7YU59.js";import{n as c,r as l,t as u}from"./resizable-CEv7JjTI.js";var d=r(),f=e(i(),1),p=n(),m=(0,f.lazy)(()=>a(()=>import(`./explorer-tree-DCeud6YI.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),h=(0,f.lazy)(()=>a(()=>import(`./explorer-view-BCJqE1-z.js`),__vite__mapDeps([13,1,2,3,14,6,7,8,15,11,16,5,17])));function g(){let e=(0,d.c)(17),{state:n}=o(),r=n.selectedThreadId,[i,a]=(0,f.useState)(null),{pendingExplorerPath:g,setPendingExplorerPath:v,explorerClearPath:y,setExplorerClearPath:b}=s(),x,S;e[0]!==g||e[1]!==v?(x=()=>{g&&(a({name:g.split(`/`).pop()??g,type:`file`,path:g}),v(null))},S=[g,v],e[0]=g,e[1]=v,e[2]=x,e[3]=S):(x=e[2],S=e[3]),(0,f.useEffect)(x,S);let C,w;e[4]!==y||e[5]!==b?(C=()=>{y&&(a(e=>e&&(e.path===y||e.path.startsWith(y+`/`)?null:e)),b(null))},w=[y,b],e[4]=y,e[5]=b,e[6]=C,e[7]=w):(C=e[6],w=e[7]),(0,f.useEffect)(C,w);let T;e[8]!==i?.path||e[9]!==r?(T=(0,p.jsx)(c,{defaultSize:25,minSize:15,maxSize:50,className:`overflow-hidden border-r border-border`,children:(0,p.jsx)(t,{className:`h-full`,children:r?(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`space-y-1 px-2 py-2`,children:[1,2,3].map(_)}),children:(0,p.jsx)(m,{threadId:r,selectedPath:i?.path??null,onFileSelect:a})}):(0,p.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No thread selected.`})})}),e[8]=i?.path,e[9]=r,e[10]=T):T=e[10];let E;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(u,{withHandle:!0}),e[11]=E):E=e[11];let D;e[12]===i?D=e[13]:(D=(0,p.jsx)(c,{className:`overflow-hidden`,children:(0,p.jsx)(f.Suspense,{fallback:null,children:(0,p.jsx)(h,{selectedFile:i})})}),e[12]=i,e[13]=D);let O;return e[14]!==T||e[15]!==D?(O=(0,p.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,p.jsxs)(l,{direction:`horizontal`,className:`flex-1 overflow-hidden`,children:[T,E,D]})}),e[14]=T,e[15]=D,e[16]=O):O=e[16],O}function _(e){return(0,p.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e)}export{g as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Di as t,Gi as n,Hi as r,Mr as i,Sa as a,Ui as o,fa as s,ua as c,wa as l}from"./dialogs-config-B91VQpxo.js";import{t as u}from"./use-toast-BZ79E_dX.js";import{t as d}from"./standard-list-item-DyALhVYe.js";import{a as f,c as p,i as m,n as h,r as g,t as _}from"./alert-dialog-BFhUZsPe.js";import{n as v}from"./tab-context-C3z7YU59.js";import{a as y,i as ee,n as b,r as x,t as S}from"./context-menu-B6K8j1ha.js";import{n as C,o as w,r as T,s as E,t as D}from"./api-DSvSyBH5.js";var O=a(),k=e(l(),1),A=i();function te(e){let t=(0,O.c)(17),{defaultValue:n,onCommit:r,onCancel:i,level:a,basePadding:o,icon:s}=e,c=(0,k.useRef)(null),l,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{c.current?.focus(),c.current?.select()},u=[],t[0]=l,t[1]=u):(l=t[0],u=t[1]),(0,k.useEffect)(l,u);let f;t[2]!==i||t[3]!==r?(f=function(e){if(e.key===`Enter`){let e=c.current?.value.trim()??``;e?r(e):i()}else e.key===`Escape`&&i()},t[2]=i,t[3]=r,t[4]=f):f=t[4];let p=f,m;t[5]!==i||t[6]!==r?(m=function(){let e=c.current?.value.trim()??``;e?r(e):i()},t[5]=i,t[6]=r,t[7]=m):m=t[7];let h=m,g;t[8]!==n||t[9]!==h||t[10]!==p?(g=(0,A.jsx)(`input`,{ref:c,defaultValue:n,onKeyDown:p,onBlur:h,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`,onClick:j}),t[8]=n,t[9]=h,t[10]=p,t[11]=g):g=t[11];let _;return t[12]!==o||t[13]!==s||t[14]!==a||t[15]!==g?(_=(0,A.jsxs)(d,{level:a,basePadding:o,children:[s,g]}),t[12]=o,t[13]=s,t[14]=a,t[15]=g,t[16]=_):_=t[16],_}function j(e){return e.stopPropagation()}function ne(e){let i=(0,O.c)(101),{node:a,level:l,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P}=e,F;i[0]!==f||i[1]!==a.path?(F=f.has(a.path),i[0]=f,i[1]=a.path,i[2]=F):F=i[2];let I=F,L;i[3]!==m||i[4]!==a.path?(L=m.has(a.path),i[3]=m,i[4]=a.path,i[5]=L):L=i[5];let R=L,z,B;if(i[6]!==f||i[7]!==I||i[8]!==R||i[9]!==l||i[10]!==p||i[11]!==m||i[12]!==g||i[13]!==a||i[14]!==P||i[15]!==T||i[16]!==j||i[17]!==w||i[18]!==E||i[19]!==D||i[20]!==k||i[21]!==v||i[22]!==C||i[23]!==_||i[24]!==h||i[25]!==u){B=Symbol.for(`react.early_return_sentinel`);bb0:{let e=p.get(a.path)??[];z=h===a.path;let O=g?.dirPath===a.path&&I;if(a.type===`folder`){let M=a.ignored?`opacity-50`:void 0,F;i[28]!==a||i[29]!==_?(F=e=>{e.stopPropagation(),_(a)},i[28]=a,i[29]=_,i[30]=F):F=i[30];let L;i[31]!==I||i[32]!==R?(L=(0,A.jsx)(`span`,{className:`text-muted-foreground w-3 flex-shrink-0`,children:R?(0,A.jsx)(t,{className:`h-3 w-3 animate-spin`}):I?(0,A.jsx)(s,{className:`h-3 w-3`}):(0,A.jsx)(c,{className:`h-3 w-3`})}),i[31]=I,i[32]=R,i[33]=L):L=i[33];let V;i[34]!==I||i[35]!==z||i[36]!==a||i[37]!==T||i[38]!==w?(V=z?(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(o,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:a.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(a,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(a,t):T()},onClick:N,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`})]}):(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(o,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:a.name})]}),i[34]=I,i[35]=z,i[36]=a,i[37]=T,i[38]=w,i[39]=V):V=i[39];let H;i[40]!==l||i[41]!==M||i[42]!==F||i[43]!==L||i[44]!==V?(H=(0,A.jsxs)(d,{level:l,basePadding:10,className:M,onClick:F,children:[L,V]}),i[40]=l,i[41]=M,i[42]=F,i[43]=L,i[44]=V,i[45]=H):H=i[45];let U=I&&(0,A.jsx)(`div`,{children:R&&!p.has(a.path)?(0,A.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded mx-4 my-1`}):(0,A.jsxs)(A.Fragment,{children:[O&&(0,A.jsx)(te,{defaultValue:``,level:l+1,basePadding:g.type===`folder`?10:22,icon:g.type===`folder`?(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(n,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:j,onCancel:P}),e.map(e=>(0,A.jsx)(ne,{node:e,level:l+1,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P},e.path))]})}),W;i[46]!==H||i[47]!==U?(W=(0,A.jsxs)(`div`,{children:[H,U]}),i[46]=H,i[47]=U,i[48]=W):W=i[48];let G=W,K;i[49]===G?K=i[50]:(K=(0,A.jsx)(y,{asChild:!0,children:G}),i[49]=G,i[50]=K);let q;i[51]!==a.path||i[52]!==D?(q=(0,A.jsx)(x,{onSelect:()=>D(a.path),children:`New File...`}),i[51]=a.path,i[52]=D,i[53]=q):q=i[53];let J;i[54]!==a.path||i[55]!==k?(J=(0,A.jsx)(x,{onSelect:()=>k(a.path),children:`New Folder...`}),i[54]=a.path,i[55]=k,i[56]=J):J=i[56];let Y;i[57]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,A.jsx)(ee,{}),i[57]=Y):Y=i[57];let X;i[58]!==a||i[59]!==C?(X=(0,A.jsx)(x,{onSelect:()=>C(a),children:`Rename...`}),i[58]=a,i[59]=C,i[60]=X):X=i[60];let Z;i[61]!==a||i[62]!==E?(Z=(0,A.jsx)(x,{onSelect:()=>E(a),className:`text-destructive focus:text-destructive`,children:`Delete`}),i[61]=a,i[62]=E,i[63]=Z):Z=i[63];let Q;i[64]!==q||i[65]!==J||i[66]!==X||i[67]!==Z?(Q=(0,A.jsxs)(b,{children:[q,J,Y,X,Z]}),i[64]=q,i[65]=J,i[66]=X,i[67]=Z,i[68]=Q):Q=i[68];let $;i[69]!==K||i[70]!==Q?($=(0,A.jsxs)(S,{children:[K,Q]}),i[69]=K,i[70]=Q,i[71]=$):$=i[71],B=$;break bb0}}i[6]=f,i[7]=I,i[8]=R,i[9]=l,i[10]=p,i[11]=m,i[12]=g,i[13]=a,i[14]=P,i[15]=T,i[16]=j,i[17]=w,i[18]=E,i[19]=D,i[20]=k,i[21]=v,i[22]=C,i[23]=_,i[24]=h,i[25]=u,i[26]=z,i[27]=B}else z=i[26],B=i[27];if(B!==Symbol.for(`react.early_return_sentinel`))return B;let V=u===a.path,H=a.ignored?`opacity-50`:void 0,U;i[72]!==a||i[73]!==v?(U=()=>v(a),i[72]=a,i[73]=v,i[74]=U):U=i[74];let W;i[75]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,A.jsx)(n,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),i[75]=W):W=i[75];let G;i[76]!==z||i[77]!==a||i[78]!==T||i[79]!==w?(G=z?(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:a.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(a,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(a,t):T()},onClick:M,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`}):(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:a.name}),i[76]=z,i[77]=a,i[78]=T,i[79]=w,i[80]=G):G=i[80];let K;i[81]!==l||i[82]!==V||i[83]!==H||i[84]!==U||i[85]!==G?(K=(0,A.jsxs)(d,{level:l,basePadding:22,selected:V,className:H,onClick:U,children:[W,G]}),i[81]=l,i[82]=V,i[83]=H,i[84]=U,i[85]=G,i[86]=K):K=i[86];let q=K,J;i[87]===q?J=i[88]:(J=(0,A.jsx)(y,{asChild:!0,children:q}),i[87]=q,i[88]=J);let Y;i[89]!==a||i[90]!==C?(Y=(0,A.jsx)(x,{onSelect:()=>C(a),children:`Rename...`}),i[89]=a,i[90]=C,i[91]=Y):Y=i[91];let X;i[92]!==a||i[93]!==E?(X=(0,A.jsx)(x,{onSelect:()=>E(a),className:`text-destructive focus:text-destructive`,children:`Delete`}),i[92]=a,i[93]=E,i[94]=X):X=i[94];let Z;i[95]!==Y||i[96]!==X?(Z=(0,A.jsxs)(b,{children:[Y,X]}),i[95]=Y,i[96]=X,i[97]=Z):Z=i[97];let Q;return i[98]!==J||i[99]!==Z?(Q=(0,A.jsxs)(S,{children:[J,Z]}),i[98]=J,i[99]=Z,i[100]=Q):Q=i[100],Q}function M(e){return e.stopPropagation()}function N(e){return e.stopPropagation()}function P({threadId:e,selectedPath:t,onFileSelect:i}){let[a,o]=(0,k.useState)(new Map),[s,c]=(0,k.useState)(new Set),[l,d]=(0,k.useState)(new Set),[ee,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(null),[N,P]=(0,k.useState)(null),{explorerRefreshTick:F,pendingExplorerPath:I}=v();async function L(t){if(!(!e||a.has(t))){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to load directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}}let R=(0,k.useCallback)(async t=>{if(e){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to reload directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}},[e]);(0,k.useEffect)(()=>{e&&(o(new Map),c(new Set),d(new Set),O(null),M(null),L(``))},[e]),(0,k.useEffect)(()=>{if(F>0&&e){R(``);for(let e of s)R(e)}},[F]),(0,k.useEffect)(()=>{if(!I||!e)return;let t=I.split(`/`);t.pop();let n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);if(n.length!==0){c(e=>{let t=new Set(e);for(let e of n)t.add(e);return t});for(let e of n)L(e)}},[I,e]);function z(e){s.has(e.path)?c(t=>{let n=new Set(t);return n.delete(e.path),n}):(c(t=>new Set(t).add(e.path)),L(e.path))}function B(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``}function V(e){P(e)}async function H(){if(!N)return;let t=N;P(null);try{await T(e,t.path),await R(B(t.path)),c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n})}catch{u({title:`Error`,description:`Failed to move "${t.name}" to trash`,variant:`destructive`})}}function U(e){M(null),O(e.path)}async function W(t,n){if(n===t.name){O(null);return}O(null);try{await E(e,t.path,n),await R(B(t.path)),t.type===`folder`&&(c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}))}catch{u({title:`Error`,description:`Failed to rename "${t.name}"`,variant:`destructive`})}}function G(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`file`})}function K(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`folder`})}async function q(t){if(!j)return;let{dirPath:n,type:r}=j;M(null);try{r===`file`?await D(e,n,t):await C(e,n,t),await R(n)}catch{u({title:`Error`,description:`Failed to create ${r} "${t}"`,variant:`destructive`})}}function J(){M(null)}let Y=a.get(``)??[],X=l.has(``),Z=j?.dirPath===``?(0,A.jsx)(te,{defaultValue:``,level:0,basePadding:j.type===`folder`?10:22,icon:j.type===`folder`?(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(n,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:q,onCancel:J}):null;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Move to Trash`}),(0,A.jsxs)(f,{children:[`Move “`,N?.name,`” to trash?`]}),(0,A.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[(0,A.jsx)(g,{children:`Cancel`}),(0,A.jsx)(h,{onClick:()=>void H(),children:`Move to Trash`})]})]})}),(0,A.jsxs)(S,{children:[(0,A.jsx)(y,{asChild:!0,children:(0,A.jsx)(`div`,{className:`py-2 min-h-full`,children:X?(0,A.jsx)(`div`,{className:`space-y-1 px-2`,children:[1,2,3].map(e=>(0,A.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e))}):(0,A.jsxs)(A.Fragment,{children:[Z,Y.map(e=>(0,A.jsx)(ne,{node:e,level:0,selectedPath:t,expandedPaths:s,loadedDirs:a,loadingPaths:l,renamingPath:ee,newItemIn:j,onToggleFolder:z,onSelectFile:i,onStartRename:U,onCommitRename:W,onCancelRename:()=>O(null),onDelete:V,onNewFile:G,onNewFolder:K,onCommitNewItem:q,onCancelNewItem:J},e.path))]})})}),(0,A.jsxs)(b,{children:[(0,A.jsx)(x,{onSelect:()=>G(``),children:`New File...`}),(0,A.jsx)(x,{onSelect:()=>K(``),children:`New Folder...`})]})]})]})}export{P as default};
|