promptmic 0.1.3 → 0.1.4
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/apps/server/dist/pty-spawner.js +22 -4
- package/apps/web/dist/assets/{DirectoryPickerDialog-D7IDk0pz.js → DirectoryPickerDialog-CIdtkYr4.js} +1 -1
- package/apps/web/dist/assets/{SettingsDialog-uQLxj7UI.js → SettingsDialog-D9VZ2obu.js} +1 -1
- package/apps/web/dist/assets/index-y1qudB0y.js +5 -0
- package/apps/web/dist/assets/{scroll-area-C8DJNmaJ.js → scroll-area-jnu2WsBi.js} +1 -1
- package/apps/web/dist/index.html +1 -1
- package/package.json +1 -1
- package/apps/web/dist/assets/index-BBNxXHaX.js +0 -5
|
@@ -75,7 +75,20 @@ function readShebang(filePath) {
|
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
function assertValidWorkingDirectory(cwd) {
|
|
79
|
+
let stat;
|
|
80
|
+
try {
|
|
81
|
+
stat = fs.statSync(cwd);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
throw new Error(`Working directory "${cwd}" does not exist. Choose another folder or reset the saved local config.`);
|
|
85
|
+
}
|
|
86
|
+
if (!stat.isDirectory()) {
|
|
87
|
+
throw new Error(`Working directory "${cwd}" is not a directory. Choose another folder or reset the saved local config.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
78
90
|
function resolveDirectSpawnTarget(command, args, env, platform, userShell, execFileSyncFn) {
|
|
91
|
+
const expandedCommand = expandTilde(command);
|
|
79
92
|
const executableFromPath = resolveDirectExecutable(command, getEnvValue(env, 'PATH', platform), platform, getEnvValue(env, 'PATHEXT', platform));
|
|
80
93
|
const shellProbe = executableFromPath ? null : readShellProbe(command, userShell, env, platform, execFileSyncFn);
|
|
81
94
|
if (shellProbe?.shellPath) {
|
|
@@ -83,7 +96,8 @@ function resolveDirectSpawnTarget(command, args, env, platform, userShell, execF
|
|
|
83
96
|
if (mergedPath)
|
|
84
97
|
setEnvValue(env, 'PATH', mergedPath, platform);
|
|
85
98
|
}
|
|
86
|
-
const executable = shellProbe?.executablePath || executableFromPath ||
|
|
99
|
+
const executable = shellProbe?.executablePath || executableFromPath || expandedCommand;
|
|
100
|
+
const commandFound = Boolean(shellProbe?.executablePath || executableFromPath);
|
|
87
101
|
try {
|
|
88
102
|
const realPath = fs.realpathSync(executable);
|
|
89
103
|
const shebang = readShebang(realPath)?.toLowerCase() ?? '';
|
|
@@ -91,6 +105,7 @@ function resolveDirectSpawnTarget(command, args, env, platform, userShell, execF
|
|
|
91
105
|
return {
|
|
92
106
|
file: process.execPath,
|
|
93
107
|
args: [realPath, ...args],
|
|
108
|
+
commandFound: true,
|
|
94
109
|
};
|
|
95
110
|
}
|
|
96
111
|
}
|
|
@@ -100,6 +115,7 @@ function resolveDirectSpawnTarget(command, args, env, platform, userShell, execF
|
|
|
100
115
|
return {
|
|
101
116
|
file: executable,
|
|
102
117
|
args,
|
|
118
|
+
commandFound,
|
|
103
119
|
};
|
|
104
120
|
}
|
|
105
121
|
export function expandTilde(value) {
|
|
@@ -170,10 +186,11 @@ function readShellProbe(command, userShell, env, platform, execFileSyncFn = exec
|
|
|
170
186
|
return null;
|
|
171
187
|
}
|
|
172
188
|
}
|
|
173
|
-
function formatSpawnError(entry, error) {
|
|
189
|
+
function formatSpawnError(entry, error, commandFound = true) {
|
|
174
190
|
const errorMessage = error instanceof Error ? error.message : String(error ?? '');
|
|
175
191
|
const errorCode = error && typeof error === 'object' && 'code' in error && typeof error.code === 'string' ? error.code : undefined;
|
|
176
192
|
if (entry.executionMode === 'direct' &&
|
|
193
|
+
!commandFound &&
|
|
177
194
|
(errorCode === 'ENOENT' ||
|
|
178
195
|
/posix_spawnp failed/i.test(errorMessage) ||
|
|
179
196
|
/spawn .* ENOENT/i.test(errorMessage) ||
|
|
@@ -222,9 +239,10 @@ export function createPtySpawner(options = {}) {
|
|
|
222
239
|
...baseEnv,
|
|
223
240
|
...command.envOverrides,
|
|
224
241
|
};
|
|
242
|
+
assertValidWorkingDirectory(cwd);
|
|
225
243
|
const spawnTarget = command.executionMode === 'direct'
|
|
226
244
|
? resolveDirectSpawnTarget(command.file, command.args, env, platform, shell, execFileSyncFn)
|
|
227
|
-
: { file: command.file, args: command.args };
|
|
245
|
+
: { file: command.file, args: command.args, commandFound: true };
|
|
228
246
|
try {
|
|
229
247
|
return spawn(spawnTarget.file, spawnTarget.args, {
|
|
230
248
|
name: 'xterm-256color',
|
|
@@ -235,7 +253,7 @@ export function createPtySpawner(options = {}) {
|
|
|
235
253
|
});
|
|
236
254
|
}
|
|
237
255
|
catch (error) {
|
|
238
|
-
throw formatSpawnError(entry, error);
|
|
256
|
+
throw formatSpawnError(entry, error, spawnTarget.commandFound);
|
|
239
257
|
}
|
|
240
258
|
};
|
|
241
259
|
}
|
package/apps/web/dist/assets/{DirectoryPickerDialog-D7IDk0pz.js → DirectoryPickerDialog-CIdtkYr4.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./react-vendor-DQ3p2tNP.js";import{u as E,p as R,c as m,B as a}from"./index-
|
|
1
|
+
import{j as e}from"./react-vendor-DQ3p2tNP.js";import{u as E,p as R,c as m,B as a}from"./index-y1qudB0y.js";import{D as A,a as H,b as L,c as O,I as v,S as Q,d as T}from"./scroll-area-jnu2WsBi.js";import{q,r as y,s as x,u as K}from"./ui-vendor-Btc0UVaC.js";import"./terminal-CnuCQtKf.js";function V(N){const{messages:t}=E(),{pickerOpen:b,browsePath:o,browseParent:w,cwd:k,searchQuery:p,setSearchQuery:C,pickerLoading:r,pickerError:h,pathInput:c,setPathInput:D,filteredDirectories:d,favoriteDirs:u,recentDirs:g,isBrowsePathFavorite:n,loadDirectories:i,closePicker:f,openCurrentFolder:F,openHomeFolder:z,openParentFolder:P,selectCurrentFolder:S,toggleFavorite:I,directories:j}=N;return e.jsx(A,{open:b,onOpenChange:s=>{s||f()},children:e.jsxs(H,{className:"max-w-2xl gap-0 p-0",children:[e.jsxs("div",{className:"space-y-3 border-b px-6 pb-4 pt-6",children:[e.jsx(L,{className:"p-0",children:e.jsx(O,{className:"text-xl",children:t.directory.title})}),e.jsx("p",{className:"text-base leading-relaxed text-muted-foreground",children:t.directory.description}),e.jsx("nav",{className:"flex flex-wrap items-center gap-0.5 rounded-md bg-muted/50 px-2.5 py-2.5 font-mono text-sm","aria-label":t.directory.pathAriaLabel,children:o?R(o).map((s,l,B)=>e.jsxs("span",{className:"flex items-center gap-0.5",children:[l>0&&e.jsx(q,{className:"h-3.5 w-3.5 text-muted-foreground/40"}),e.jsx("button",{className:m("rounded px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",l===B.length-1?"font-medium text-foreground":"text-muted-foreground"),onClick:()=>{i(s.path)},disabled:r,children:s.label})]},s.path)):e.jsx("span",{className:"text-muted-foreground",children:t.directory.loading})})]}),e.jsxs("div",{className:"space-y-4 border-b px-6 py-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(a,{variant:"secondary",size:"sm",className:"h-9 text-sm",onClick:z,disabled:r,children:t.directory.home}),e.jsx(a,{variant:"secondary",size:"sm",className:"h-9 text-sm",onClick:P,disabled:!w||r,children:t.directory.up}),e.jsx(a,{variant:"secondary",size:"sm",className:"h-9 text-sm",onClick:F,disabled:!k||r,children:t.directory.currentFolder})]}),u.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:[e.jsx(y,{className:"h-3.5 w-3.5"}),t.directory.favorites]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:u.map(s=>e.jsx(a,{variant:"secondary",size:"sm",className:"h-8 text-sm",title:s.path,onClick:()=>{i(s.path)},disabled:r,children:s.label},s.path))})]}),g.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:[e.jsx(x,{className:"h-3.5 w-3.5"}),t.directory.recent]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:g.map(s=>e.jsx(a,{variant:"secondary",size:"sm",className:"h-8 text-sm",title:s.path,onClick:()=>{i(s.path)},disabled:r,children:s.label},s.path))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{value:c,onChange:s=>D(s.target.value),onKeyDown:s=>{if(s.key==="Enter"){s.preventDefault();const l=c.trim();l&&i(l)}},placeholder:t.directory.goToPath,className:"h-10 font-mono text-sm"}),e.jsx(a,{variant:"secondary",size:"sm",className:"h-10 px-4 text-sm",onClick:()=>{const s=c.trim();s&&i(s)},disabled:!c.trim()||r,children:t.directory.openPath}),e.jsx(a,{variant:"ghost",size:"icon",className:m("h-9 w-9 shrink-0",n?"text-yellow-500 hover:text-yellow-400":"text-muted-foreground hover:text-yellow-500"),onClick:I,disabled:!o||r,title:n?t.directory.removeFavorite:t.directory.addFavorite,children:e.jsx(y,{className:m("h-4 w-4",n&&"fill-current")})})]})]}),e.jsxs("div",{className:"space-y-3 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:[e.jsx(x,{className:"h-3.5 w-3.5"}),t.directory.subfolders]}),e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[d.length,p.trim()?` / ${j.length}`:""]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(K,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/60"}),e.jsx(v,{value:p,onChange:s=>C(s.target.value),placeholder:t.directory.filter,className:"h-10 pl-9 text-sm"})]}),h&&e.jsx("p",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-base text-destructive-foreground",children:h}),e.jsx(Q,{className:"h-[260px] rounded-md border",children:e.jsxs("div",{className:"grid gap-1 p-2","aria-busy":r,children:[d.map(s=>e.jsxs("button",{className:"flex items-center gap-2 rounded-md px-3 py-2.5 text-left font-mono text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",onClick:()=>{i(s.path)},disabled:r,children:[e.jsx(x,{className:"h-4 w-4 shrink-0"}),s.name]},s.path)),!r&&d.length===0&&e.jsx("p",{className:"py-8 text-center text-base text-muted-foreground",children:j.length===0?t.directory.noSubfolders:t.directory.noResults})]})})]}),e.jsxs(T,{className:"border-t px-6 py-4",children:[e.jsx(a,{variant:"outline",size:"sm",className:"h-10 px-4 text-sm",onClick:f,children:t.directory.cancel}),e.jsx(a,{size:"sm",className:"h-10 px-4 text-sm",onClick:S,disabled:!o||r,children:t.directory.selectFolder})]})]})})}export{V as DirectoryPickerDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v,j as e}from"./react-vendor-DQ3p2tNP.js";import{v as X,X as q,w as V,a as S}from"./ui-vendor-Btc0UVaC.js";import{s as G,t as D,a as Q,u as U,B as f,c as H,S as T,b as z,d as I,e as O,f as P}from"./index-
|
|
1
|
+
import{r as v,j as e}from"./react-vendor-DQ3p2tNP.js";import{v as X,X as q,w as V,a as S}from"./ui-vendor-Btc0UVaC.js";import{s as G,t as D,a as Q,u as U,B as f,c as H,S as T,b as z,d as I,e as O,f as P}from"./index-y1qudB0y.js";import{D as W,a as Y,b as Z,c as ee,S as se,I as k,d as te}from"./scroll-area-jnu2WsBi.js";import"./terminal-CnuCQtKf.js";const _=c=>({_key:c,label:"",executionMode:"direct",command:"",env:[]}),ae=(c,i)=>Object.entries(c.providers??{}).map(([,r])=>({_key:i(),label:r.label,executionMode:r.executionMode,command:G(r.command,r.args),env:Object.entries(r.env).map(([t,d])=>({key:t,value:d}))})),le=c=>c.length>0&&c.every(i=>i.label.trim()&&i.command.trim()),ne=(c,i)=>{const r=new Set,t=c.map(m=>{let x=D(m.label);for(;r.has(x);)x=`${x}-${r.size}`;r.add(x);const j={};for(const p of m.env){const u=p.key.trim();u&&(j[u]=p.value)}const{command:y,args:N}=Q(m.command.trim());return[x,{label:m.label.trim(),executionMode:m.executionMode,command:y,args:N,env:j}]}),d=Object.fromEntries(t),o=Object.keys(d),b=i&&o.includes(i)?i:void 0;return{providers:d,...b?{defaultProvider:b}:{}}};function me({open:c,onOpenChange:i,onSaved:r}){const{messages:t}=U(),[d,o]=v.useState([]),[b,m]=v.useState(""),[x,j]=v.useState(!1),[y,N]=v.useState(!1),p=v.useRef(0),u=()=>p.current++;v.useEffect(()=>{c&&(N(!0),fetch("/api/config").then(s=>s.json()).then(s=>{const a=ae(s,u);o(a.length>0?a:[_(u())]),m(s.defaultProvider??"")}).catch(()=>{o([_(u())]),m("")}).finally(()=>N(!1)))},[c]);const F=()=>{o(s=>[...s,_(u())])},K=s=>{o(a=>a.filter(l=>l._key!==s))},w=(s,a,l)=>{o(n=>n.map(h=>h._key===s?{...h,[a]:l}:h))},A=(s,a)=>{o(l=>l.map(n=>n._key===s?{...n,executionMode:a}:n))},B=s=>{o(a=>a.map(l=>l._key===s?{...l,env:[...l.env,{key:"",value:""}]}:l))},C=(s,a,l,n)=>{o(h=>h.map(g=>{if(g._key!==s)return g;const $=g.env.map((E,J)=>J===a?{...E,[l]:n}:E);return{...g,env:$}}))},L=(s,a)=>{o(l=>l.map(n=>n._key!==s?n:{...n,env:n.env.filter((h,g)=>g!==a)}))},M=le(d),R=async()=>{if(M){j(!0);try{const s=ne(d,b);if(!(await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).ok){S.error(t.settings.saveError);return}S.success(t.settings.saveSuccess),i(!1),r()}catch{S.error(t.settings.saveError)}finally{j(!1)}}};return e.jsx(W,{open:c,onOpenChange:i,children:e.jsxs(Y,{className:"max-w-2xl gap-0 p-0",children:[e.jsxs("div",{className:"border-b px-6 pt-6 pb-4",children:[e.jsx(Z,{className:"p-0",children:e.jsx(ee,{className:"text-xl sm:text-2xl",children:t.settings.title})}),e.jsx("p",{className:"mt-3 max-w-3xl text-base leading-relaxed text-muted-foreground",children:t.settings.description})]}),e.jsx(se,{className:"max-h-[68vh]",children:e.jsxs("div",{className:"space-y-5 px-6 py-5",children:[y&&e.jsx("p",{className:"text-base text-muted-foreground",children:t.settings.loading}),d.map(s=>e.jsxs("div",{className:"space-y-4 rounded-xl border p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("code",{className:"text-base text-muted-foreground",children:D(s.label)}),e.jsxs(f,{variant:"destructive",size:"sm",className:"h-9 gap-1.5 px-3 text-sm",onClick:()=>K(s._key),children:[e.jsx(X,{className:"h-3.5 w-3.5"}),t.settings.remove]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-base font-medium text-foreground",children:t.settings.name}),e.jsx(k,{value:s.label,onChange:a=>w(s._key,"label",a.target.value),placeholder:t.settings.namePlaceholder,className:H("h-11 text-base",!s.label.trim()&&"border-destructive")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-base font-medium text-foreground",children:t.settings.executionMode}),e.jsxs(T,{value:s.executionMode,onValueChange:a=>A(s._key,a),children:[e.jsx(z,{className:"h-11 w-full text-base",children:e.jsx(I,{})}),e.jsxs(O,{children:[e.jsx(P,{value:"direct",children:t.settings.executionModeDirect}),e.jsx(P,{value:"shell",children:t.settings.executionModeShell})]})]}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground",children:s.executionMode==="direct"?t.settings.executionModeDirectHint:t.settings.executionModeShellHint})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-base font-medium text-foreground",children:t.settings.command}),e.jsx(k,{value:s.command,onChange:a=>w(s._key,"command",a.target.value),placeholder:s.executionMode==="direct"?t.settings.commandDirectPlaceholder:t.settings.commandShellPlaceholder,className:H("h-11 font-mono text-base",!s.command.trim()&&"border-destructive")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground",children:s.executionMode==="direct"?t.settings.commandDirectHint:t.settings.commandShellHint})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-base font-medium text-foreground",children:t.settings.envVars}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:t.settings.envVarsHint}),s.env.map((a,l)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{value:a.key,onChange:n=>C(s._key,l,"key",n.target.value),placeholder:t.settings.envKeyPlaceholder,className:"h-11 w-[45%] font-mono text-base"}),e.jsx("span",{className:"text-base text-muted-foreground",children:"="}),e.jsx(k,{value:a.value,onChange:n=>C(s._key,l,"value",n.target.value),placeholder:t.settings.envValuePlaceholder,className:"h-11 flex-1 font-mono text-base"}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-10 w-10 shrink-0 text-muted-foreground",onClick:()=>L(s._key,l),children:e.jsx(q,{className:"h-4 w-4"})})]},l)),e.jsxs(f,{variant:"secondary",size:"sm",className:"h-10 text-sm",onClick:()=>B(s._key),children:[e.jsx(V,{className:"mr-1.5 h-4 w-4"}),t.settings.addVariable]})]})]})]},s._key)),e.jsxs(f,{variant:"secondary",onClick:F,className:"h-11 w-full border border-dashed border-border text-base",children:[e.jsx(V,{className:"mr-2 h-4.5 w-4.5"}),t.settings.addAssistant]}),d.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-base font-medium text-foreground",children:t.settings.defaultProvider}),e.jsxs(T,{value:b,onValueChange:m,children:[e.jsx(z,{className:"h-11 w-full text-base",children:e.jsx(I,{placeholder:t.settings.selectPlaceholder})}),e.jsx(O,{children:d.map(s=>{const a=D(s.label);return e.jsx(P,{value:a,children:s.label||a},s._key)})})]})]})]})}),e.jsxs(te,{className:"border-t px-6 py-4",children:[e.jsx(f,{variant:"ghost",className:"h-11 px-5 text-base",onClick:()=>i(!1),children:t.settings.cancel}),e.jsx(f,{variant:"default",className:"h-11 px-5 text-base",onClick:R,disabled:!M||x,children:x?t.settings.saving:t.settings.save})]})]})})}export{me as SettingsDialog};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-CnuCQtKf.js","assets/react-vendor-DQ3p2tNP.js","assets/terminal-Beg8tuEN.css","assets/DirectoryPickerDialog-CIdtkYr4.js","assets/scroll-area-jnu2WsBi.js","assets/ui-vendor-Btc0UVaC.js","assets/SettingsDialog-D9VZ2obu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as o,j as t,d as Pe,R as Re}from"./react-vendor-DQ3p2tNP.js";import{t as Ie,c as Le,a as F,S as Fe,b as ue,d as Te,e as De,M as Ae,T as me,I as He,C as fe,f as pe,g as _e,h as ge,P as ze,i as he,V as Me,L as xe,j as ve,k as Be,l as Ue,m as Ve,n as be,R as Oe,o as $e,F as qe,p as Ke}from"./ui-vendor-Btc0UVaC.js";import"./terminal-CnuCQtKf.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))i(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const m of u.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function r(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(c){if(c.ep)return;c.ep=!0;const u=r(c);fetch(c.href,u)}})();const We="modulepreload",Ge=function(e){return"/"+e},ne={},Y=function(s,r,i){let c=Promise.resolve();if(r&&r.length>0){let m=function(h){return Promise.all(h.map(l=>Promise.resolve(l).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),x=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));c=m(r.map(h=>{if(h=Ge(h),h in ne)return;ne[h]=!0;const l=h.endsWith(".css"),d=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${d}`))return;const n=document.createElement("link");if(n.rel=l?"stylesheet":We,l||(n.as="script"),n.crossOrigin="",n.href=h,x&&n.setAttribute("nonce",x),document.head.appendChild(n),l)return new Promise((g,f)=>{n.addEventListener("load",g),n.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(m){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=m,window.dispatchEvent(a),!a.defaultPrevented)throw m}return c.then(m=>{for(const a of m||[])a.status==="rejected"&&u(a.reason);return s().catch(u)})};function j(...e){return Ie(Le(e))}const Je={en:{app:{sessionStartedTerminal:"Session started",sessionStartedToast:"Session started.",sessionClosedTerminal:"Terminal closed. Start a new session to begin from scratch.",sessionClosedToast:"Session ended. Start a new session to continue.",errorLabel:"error",terminalIdleTitle:"TermSpeak terminal",speechUnsupported:"Your browser does not support the Web Speech API. Use Chrome or Edge for the MVP."},connection:{active:"Active session",ready:"Ready",connecting:"Connecting..."},steps:{assistant:"1. Assistant",folder:"2. Folder",session:"3. Session"},toolbar:{settings:"Settings",lightMode:"Light mode",darkMode:"Dark mode",subtitle:"Voice-first local UI for terminal-based coding assistants.",serverUnavailable:"Server unavailable. Run `npm run dev` to start it."},controls:{assistant:"Assistant",configureAssistants:"Configure assistants",configureAssistantsHint:"Add your first assistant in Settings.",assistantReadyHint:"Choose which assistant to use in this session.",interfaceLanguage:"Interface",dictationLanguage:"Dictation",fontSize:"Text size",folder:"Project folder",noFolder:"None",selectedFolder:"Selected folder",noFolderSelected:"No folder selected",chooseFolder:"Choose folder",chooseFolderHint:"Choose the folder where the assistant should work.",waitingConnection:"Waiting for connection...",startSession:"Start session",endSession:"End session",startHintNeedsAssistant:"First, add an assistant.",startHintNeedsFolder:"Now choose a project folder.",startHintReady:"Everything is ready. Start the session.",english:"English",portuguese:"Portuguese (Brazil)",fontSmall:"Small",fontMedium:"Medium",fontLarge:"Large"},prompt:{quickFlowTitle:"Quick flow",quickFlowDescription:"1. Configure an assistant if you have not added one yet. 2. Choose the project folder. 3. Start the session. 4. Dictate or type prompts after the terminal connects.",stopDictation:"Stop dictation",dictatePrompt:"Dictate prompt",placeholder:"Say what you need, review the text, and press Enter...",send:"Send",shortcuts:"Enter sends · Shift+Enter adds a line break · Ctrl+K focuses · Arrow keys browse history",pushToTalkHint:e=>`Hold ${e} to talk`},settings:{title:"Configure assistants",description:"If you normally type `codex`, `claude`, or `aider` in the terminal, choose Normal command. If you use your own shortcut such as `personal` or `work`, choose Shell shortcut.",loading:"Loading...",remove:"Remove",name:"Name",namePlaceholder:"e.g. Claude Code CLI",executionMode:"Execution mode",executionModeDirect:"Normal command (`codex`)",executionModeShell:"Shell shortcut (`personal`)",executionModeDirectHint:"Use this when the command already works normally in your terminal.",executionModeShellHint:"Use this when the command is your own shell shortcut, alias, or function.",command:"What you type in the terminal",commandPlaceholder:"e.g. claude, codex, aider --no-auto-commits",commandDirectPlaceholder:"e.g. codex, claude, aider --no-auto-commits",commandShellPlaceholder:"e.g. personal, work, source-env && claude",commandDirectHint:"Examples: `codex`, `claude`, `aider --no-auto-commits`.",commandShellHint:"Examples: `personal`, `work`.",envVars:"Environment variables (optional)",envVarsHint:"Use this only if the assistant needs extra values when it starts. Example: `CLAUDE_CONFIG_DIR=~/.claude-work`.",envKeyPlaceholder:"KEY",envValuePlaceholder:"value",addVariable:"Add variable",addAssistant:"Add assistant",defaultProvider:"Default provider",selectPlaceholder:"Select...",cancel:"Cancel",saving:"Saving...",save:"Save",saveError:"Could not save configuration.",saveSuccess:"Configuration saved."},directory:{title:"Select directory",description:"Choose the folder where the assistant should run.",pathAriaLabel:"Path",favorites:"Favorites",recent:"Recent",goToPath:"Go to path... (Enter)",openPath:"Open",home:"Home",up:"Up",currentFolder:"Current folder",removeFavorite:"Remove from favorites",addFavorite:"Add to favorites",subfolders:"Subfolders",filter:"Filter...",loading:"Loading...",noSubfolders:"No subfolders.",noResults:"No results.",cancel:"Cancel",selectFolder:"Select this folder",folderSelected:"Folder selected.",favoriteRemoved:"Favorite removed.",favoriteAdded:"Favorite added.",maxFavorites:e=>`Maximum of ${e} favorites.`,openDirectoryError:"Could not open directory.",savedFolderReset:"The saved project folder is no longer available. Choose another folder.",homeLabel:"Home"},speech:{captureError:"Voice capture failed."},terminal:{title:"TermSpeak Terminal",helper:"Choose an assistant, select a folder, and start the session.",processClosed:"process exited"}},"pt-BR":{app:{sessionStartedTerminal:"Sessão iniciada",sessionStartedToast:"Sessão iniciada.",sessionClosedTerminal:"Terminal fechado. Inicie uma nova sessão para começar do zero.",sessionClosedToast:"Sessão encerrada. Inicie uma nova sessão para continuar.",errorLabel:"erro",terminalIdleTitle:"terminal do TermSpeak",speechUnsupported:"Seu navegador não suporta Web Speech API. Use Chrome ou Edge para o MVP."},connection:{active:"Sessão ativa",ready:"Pronto",connecting:"Conectando..."},steps:{assistant:"1. Assistente",folder:"2. Pasta",session:"3. Sessão"},toolbar:{settings:"Configurações",lightMode:"Modo claro",darkMode:"Modo escuro",subtitle:"Interface local com voz para assistentes de código baseados em terminal.",serverUnavailable:"Servidor indisponível. Execute `npm run dev` para iniciar."},controls:{assistant:"Assistente",configureAssistants:"Configurar assistentes",configureAssistantsHint:"Adicione seu primeiro assistente em Configurações.",assistantReadyHint:"Escolha qual assistente usar nesta sessão.",interfaceLanguage:"Interface",dictationLanguage:"Ditado",fontSize:"Tamanho do texto",folder:"Pasta do projeto",noFolder:"Nenhuma",selectedFolder:"Pasta selecionada",noFolderSelected:"Nenhuma pasta selecionada",chooseFolder:"Escolher pasta",chooseFolderHint:"Escolha a pasta onde o assistente deve trabalhar.",waitingConnection:"Aguardando conexão...",startSession:"Iniciar sessão",endSession:"Encerrar sessão",startHintNeedsAssistant:"Primeiro, adicione um assistente.",startHintNeedsFolder:"Agora escolha a pasta do projeto.",startHintReady:"Tudo pronto. Inicie a sessão.",english:"Inglês",portuguese:"Português (Brasil)",fontSmall:"Pequeno",fontMedium:"Médio",fontLarge:"Grande"},prompt:{quickFlowTitle:"Fluxo rápido",quickFlowDescription:"1. Configure um assistente se ainda não existir nenhum. 2. Escolha a pasta do projeto. 3. Inicie a sessão. 4. Depois dite ou digite seus prompts quando o terminal conectar.",stopDictation:"Parar ditado",dictatePrompt:"Ditar prompt",placeholder:"Diga seu pedido, revise o texto e pressione Enter...",send:"Enviar",shortcuts:"Enter envia · Shift+Enter quebra linha · Ctrl+K foca · Setas navegam no histórico",pushToTalkHint:e=>`Segure ${e} para falar`},settings:{title:"Configurar assistentes",description:"Se você normalmente digita `codex`, `claude` ou `aider` no terminal, escolha Comando normal. Se você usa um atalho seu, como `personal` ou `work`, escolha Atalho do shell.",loading:"Carregando...",remove:"Remover",name:"Nome",namePlaceholder:"Ex.: Claude Code CLI",executionMode:"Modo de execução",executionModeDirect:"Comando normal (`codex`)",executionModeShell:"Atalho do shell (`personal`)",executionModeDirectHint:"Use quando o comando já funciona normalmente no seu terminal.",executionModeShellHint:"Use quando o comando é um atalho, alias ou função do seu shell.",command:"O que você digita no terminal",commandPlaceholder:"Ex.: claude, codex, aider --no-auto-commits",commandDirectPlaceholder:"Ex.: codex, claude, aider --no-auto-commits",commandShellPlaceholder:"Ex.: personal, work, source-env && claude",commandDirectHint:"Exemplos: `codex`, `claude`, `aider --no-auto-commits`.",commandShellHint:"Exemplos: `personal`, `work`.",envVars:"Variáveis de ambiente (opcional)",envVarsHint:"Use isso só se o assistente precisar de valores extras ao iniciar. Exemplo: `CLAUDE_CONFIG_DIR=~/.claude-work`.",envKeyPlaceholder:"CHAVE",envValuePlaceholder:"valor",addVariable:"Adicionar variável",addAssistant:"Adicionar assistente",defaultProvider:"Provider padrão",selectPlaceholder:"Selecionar...",cancel:"Cancelar",saving:"Salvando...",save:"Salvar",saveError:"Erro ao salvar configuração.",saveSuccess:"Configuração salva."},directory:{title:"Selecionar diretório",description:"Escolha a pasta onde o assistente deve rodar.",pathAriaLabel:"Caminho",favorites:"Favoritos",recent:"Recentes",goToPath:"Ir para caminho... (Enter)",openPath:"Abrir",home:"Home",up:"Acima",currentFolder:"Pasta atual",removeFavorite:"Remover dos favoritos",addFavorite:"Adicionar aos favoritos",subfolders:"Subpastas",filter:"Filtrar...",loading:"Carregando...",noSubfolders:"Nenhuma subpasta.",noResults:"Nenhum resultado.",cancel:"Cancelar",selectFolder:"Selecionar esta pasta",folderSelected:"Pasta selecionada.",favoriteRemoved:"Favorito removido.",favoriteAdded:"Favorito adicionado.",maxFavorites:e=>`Máximo de ${e} favoritos.`,openDirectoryError:"Falha ao abrir diretório.",savedFolderReset:"A pasta do projeto salva não está mais disponível. Escolha outra pasta.",homeLabel:"Home"},speech:{captureError:"Falha ao capturar voz."},terminal:{title:"Terminal TermSpeak",helper:"Escolha um assistente, selecione uma pasta e inicie a sessão.",processClosed:"processo encerrado"}}},we=o.createContext(null);function Ye(e){return e==="pt-BR"?"pt-BR":"en"}function ae(){return(typeof navigator>"u"?[]:[navigator.language,...navigator.languages??[]]).some(s=>s==null?void 0:s.toLowerCase().startsWith("pt"))?"pt-BR":"en"}function Qe({language:e,children:s}){return o.useEffect(()=>{document.documentElement.lang=e},[e]),t.jsx(we.Provider,{value:{language:e,messages:Je[e]},children:s})}function B(){const e=o.useContext(we);if(!e)throw new Error("useI18n must be used within I18nProvider");return e}const E={speechLang:"voice-control.speech-lang",uiLanguage:"voice-control.ui-language",fontSize:"voice-control.font-size",preferences:"voice-control.preferences",promptHistory:"voice-control.prompt-history",dirUsage:"voice-control.dir-usage",favorites:"voice-control.favorites",theme:"voice-control.theme"},ie=30,Xe=80,re=6,M=(e,s)=>{try{const r=window.localStorage.getItem(e);return r?JSON.parse(r):s}catch{return s}},Q=(e,s)=>{window.localStorage.setItem(e,JSON.stringify(s))},Ze=e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(s=>typeof s[0]=="string"&&typeof s[1]=="number"&&Number.isFinite(s[1])&&s[1]>0)),ce=e=>Object.fromEntries(Object.entries(e).sort((s,r)=>r[1]-s[1]).slice(0,Xe)),le=(e,s,r="Home")=>s&&e===s?r:e.split("/").filter(Boolean).at(-1)??e,yt=e=>{const s=e.split("/").filter(Boolean),r=[{label:"/",path:"/"}];for(let i=0;i<s.length;i++)r.push({label:s[i],path:"/"+s.slice(0,i+1).join("/")});return r},jt=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,30)||"provider",Nt=(e,s)=>[e,...s].map(r=>r.length===0?"''":/^[A-Za-z0-9_./:@%+=,-]+$/.test(r)?r:`'${r.replace(/'/g,"'\\''")}'`).join(" ");function Ct(e){const s=[];let r="",i="plain",c=!1;const u=()=>{r.length>0&&(s.push(r),r="")};for(let m=0;m<e.length;m+=1){const a=e[m];if(c){r+=a,c=!1;continue}if(i==="single"){a==="'"?i="plain":r+=a;continue}if(i==="double"){if(a==='"')i="plain";else if(a==="\\"){const x=e[m+1];x&&["\\",'"',"$","`"].includes(x)?(r+=x,m+=1):r+=a}else r+=a;continue}if(/\s/.test(a)){u();continue}if(a==="\\"){c=!0;continue}if(a==="'"){i="single";continue}if(a==='"'){i="double";continue}r+=a}if(c&&(r+="\\"),u(),i!=="plain")throw new Error("Unterminated quoted string.");return{command:s[0]??"",args:s.slice(1)}}function et(){const[e,s]=o.useState(()=>{const p=window.localStorage.getItem(E.theme);if(p==="light"||p==="dark"){const w=p==="dark";return document.documentElement.classList.toggle("dark",w),w}return document.documentElement.classList.contains("dark")}),r=()=>{s(p=>{const w=!p;return document.documentElement.classList.toggle("dark",w),window.localStorage.setItem(E.theme,w?"dark":"light"),w})},[i,c]=o.useState(()=>{const p=window.localStorage.getItem(E.speechLang);return p==="en-US"||p==="pt-BR"?p:ae()==="pt-BR"?"pt-BR":"en-US"}),[u,m]=o.useState(()=>{const p=window.localStorage.getItem(E.uiLanguage);if(p)return Ye(p);const w=M(E.preferences,{});return w.uiLanguage?w.uiLanguage:ae()}),[a,x]=o.useState(()=>{const p=window.localStorage.getItem(E.fontSize);if(p==="sm"||p==="md"||p==="lg")return p;const w=M(E.preferences,{});return w.fontSize==="sm"||w.fontSize==="md"||w.fontSize==="lg"?w.fontSize:"md"}),[h,l]=o.useState(()=>M(E.preferences,{}).provider??""),[d,n]=o.useState(()=>M(E.preferences,{}).cwd??""),[g,f]=o.useState("");return o.useEffect(()=>{window.localStorage.setItem(E.speechLang,i)},[i]),o.useEffect(()=>{window.localStorage.setItem(E.uiLanguage,u)},[u]),o.useEffect(()=>{window.localStorage.setItem(E.fontSize,a),document.body.dataset.fontSize=a,document.documentElement.dataset.fontSize=a},[a]),o.useEffect(()=>{Q(E.preferences,{provider:h,cwd:d.trim(),uiLanguage:u,fontSize:a})},[d,h,u,a]),{darkMode:e,toggleTheme:r,uiLanguage:u,setUiLanguage:m,fontSize:a,setFontSize:x,speechLang:i,setSpeechLang:c,provider:h,setProvider:l,cwd:d,setCwd:n,homeDir:g,setHomeDir:f}}function tt(e){const[s,r]=o.useState("connecting"),[i,c]=o.useState(null),u=o.useRef(null),m=o.useRef(null),a=o.useRef(e);a.current=e,o.useEffect(()=>{m.current=i},[i]);const x=o.useCallback(h=>{const l=u.current;!l||l.readyState!==WebSocket.OPEN||l.send(JSON.stringify(h))},[]);return o.useEffect(()=>{const h=window.location.protocol==="https:"?"wss":"ws",l=new WebSocket(`${h}://${window.location.host}/ws`);return u.current=l,l.onopen=()=>{r("connected")},l.onclose=()=>{r("disconnected"),c(null)},l.onmessage=d=>{const n=JSON.parse(d.data);n.type==="session_started"&&(c(n.sessionId),a.current.onSessionStarted(n)),n.type==="output"&&a.current.onOutput(n),n.type==="session_exit"&&(c(null),a.current.onSessionExit(n)),n.type==="error"&&a.current.onError(n)},()=>{l.close()}},[]),{status:s,sessionId:i,setSessionId:c,sessionIdRef:m,sendWs:x}}function st({sendWs:e,sessionIdRef:s,sessionId:r,fontSize:i}){const{messages:c}=B(),u=o.useRef(null),m=o.useRef(i),a=o.useRef(null),x=o.useRef(null),h=()=>{const l=x.current;l&&(l.reset(),l.writeln(`\x1B[1m ${c.terminal.title} \x1B[0m`),l.writeln(`\x1B[2m ${c.terminal.helper}\x1B[0m`),l.writeln(""))};return m.current=i,o.useEffect(()=>{if(!u.current)return;let l=!1,d;return(async()=>{const[{Terminal:n},{FitAddon:g}]=await Promise.all([Y(()=>import("./terminal-CnuCQtKf.js").then(C=>C.x),__vite__mapDeps([0,1,2])),Y(()=>import("./terminal-CnuCQtKf.js").then(C=>C.a),__vite__mapDeps([0,1,2]))]);if(l||!u.current)return;const f=new n({cursorBlink:!0,fontFamily:'"JetBrains Mono", monospace',fontSize:m.current,lineHeight:1.35,theme:{background:"#0a0a0a",foreground:"#fafafa",cursor:"#fafafa",cursorAccent:"#0a0a0a",selectionBackground:"rgba(250, 250, 250, 0.15)",black:"#0a0a0a",red:"#ff7b72",green:"#3fb950",yellow:"#d29922",blue:"#58a6ff",magenta:"#bc8cff",cyan:"#39d2e0",white:"#fafafa",brightBlack:"#484f58",brightRed:"#ffa198",brightGreen:"#56d364",brightYellow:"#e3b341",brightBlue:"#79c0ff",brightMagenta:"#d2a8ff",brightCyan:"#56d4dd",brightWhite:"#f0f6fc"}}),p=new g;f.loadAddon(p),f.open(u.current),p.fit(),a.current=p,x.current=f,h();const w=()=>{p.fit();const C=s.current;C&&e({type:"resize",sessionId:C,cols:f.cols,rows:f.rows})},P=f.onData(C=>{const v=s.current;v&&e({type:"input",sessionId:v,data:C})});window.addEventListener("resize",w),d=()=>{window.removeEventListener("resize",w),P.dispose(),a.current=null,x.current=null,f.dispose()}})(),()=>{l=!0,d==null||d()}},[e,s]),o.useEffect(()=>{r||h()},[c.terminal.helper,c.terminal.title,r]),o.useEffect(()=>{var n;const l=x.current;if(!l)return;l.options.fontSize=i,(n=a.current)==null||n.fit(),l.refresh(0,l.rows-1);const d=s.current;d&&e({type:"resize",sessionId:d,cols:l.cols,rows:l.rows})},[i,e,s]),{terminalRef:x,containerRef:u}}function rt({speechLang:e,onTranscript:s}){const{messages:r}=B(),[i,c]=o.useState(!1),u=o.useRef(!1),m=o.useRef(""),a=o.useRef(null),x=o.useRef(s);x.current=s;const h=o.useMemo(()=>typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition),[]);o.useEffect(()=>{u.current=i},[i]),o.useEffect(()=>{a.current&&(a.current.lang=e)},[e]),o.useEffect(()=>{if(!h)return;const g=window.SpeechRecognition||window.webkitSpeechRecognition,f=new g;return f.lang=e,f.interimResults=!0,f.continuous=!0,f.onresult=p=>{var C,v;let w="";for(let D=p.resultIndex;D<p.results.length;D+=1){const k=p.results[D],z=((v=(C=k[0])==null?void 0:C.transcript)==null?void 0:v.trim())??"";z&&(k.isFinal?m.current=`${m.current} ${z}`.trim():w=`${w} ${z}`.trim())}const P=`${m.current} ${w}`.trim();x.current(P)},f.onend=()=>{if(u.current){f.start();return}c(!1)},f.onerror=p=>{if(u.current&&(p.error==="aborted"||p.error==="no-speech")){f.start();return}c(!1),F.error(r.speech.captureError)},a.current=f,()=>{f.stop()}},[r.speech.captureError,h,e]);const l=()=>{const g=a.current;if(g&&!u.current){m.current="";try{g.start(),c(!0)}catch{}}},d=()=>{const g=a.current;g&&u.current&&(g.stop(),c(!1))};return{isListening:i,startVoice:l,stopVoice:d,toggleVoice:()=>{if(u.current){d();return}l()},speechSupported:h,dictatedFinalRef:m}}function ot({sendWs:e,sessionId:s}){const[r,i]=o.useState(""),[c,u]=o.useState(()=>M(E.promptHistory,[])),[m,a]=o.useState(null),x=o.useRef(null);return o.useEffect(()=>{Q(E.promptHistory,c.slice(0,ie))},[c]),o.useEffect(()=>{const d=x.current;if(!d)return;d.style.height="0px";const n=Math.min(d.scrollHeight,200);d.style.height=`${n}px`,d.scrollTop=d.scrollHeight},[r]),o.useEffect(()=>{var d;s&&((d=x.current)==null||d.focus())},[s]),o.useEffect(()=>{const d=n=>{var g;(n.ctrlKey||n.metaKey)&&n.key.toLowerCase()==="k"&&(n.preventDefault(),(g=x.current)==null||g.focus())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[]),{promptDraft:r,setPromptDraft:i,sendPrompt:()=>{const d=r.trim();!s||!d||(e({type:"input",sessionId:s,data:d}),u(n=>[d,...n.filter(g=>g!==d)].slice(0,ie)),a(null),i(""),F.success("Prompt enviado."))},navigateHistory:d=>{if(c.length!==0){if(d==="older"){a(n=>{const g=n===null?0:Math.min(n+1,c.length-1),f=c[g];return f&&i(f),g});return}a(n=>{if(n===null)return null;const g=n-1;if(g<0)return i(""),null;const f=c[g];return f&&i(f),g})}},promptTextareaRef:x,promptHistory:c,promptHistoryIndex:m,setPromptHistoryIndex:a}}function nt({cwd:e,setCwd:s,homeDir:r}){const{messages:i}=B(),[c,u]=o.useState(()=>Ze(M(E.dirUsage,{}))),[m,a]=o.useState(()=>M(E.favorites,[])),[x,h]=o.useState(!1),[l,d]=o.useState(""),[n,g]=o.useState(null),[f,p]=o.useState([]),[w,P]=o.useState(""),[C,v]=o.useState(!1),[D,k]=o.useState(""),[z,U]=o.useState("");o.useEffect(()=>{Q(E.dirUsage,ce(c))},[c]),o.useEffect(()=>{Q(E.favorites,m)},[m]),o.useEffect(()=>{U(l)},[l]);const V=o.useMemo(()=>{const y=w.trim().toLowerCase();return y?f.filter(R=>R.name.toLowerCase().includes(y)):f},[f,w]),Z=o.useMemo(()=>m.slice(0,re).map(y=>({label:le(y,r,i.directory.homeLabel),path:y})),[m,r,i.directory.homeLabel]),ee=o.useMemo(()=>Object.entries(c).sort((y,R)=>R[1]-y[1]).map(([y])=>y).filter(y=>y!==e&&!m.includes(y)).slice(0,5).map(y=>({label:le(y,r,i.directory.homeLabel),path:y})),[e,c,m,r,i.directory.homeLabel]),te=o.useMemo(()=>!!l&&m.includes(l),[l,m]),K=(y,R=1)=>{const T=y.trim();T&&u(W=>{const ke={...W,[T]:(W[T]??0)+R};return ce(ke)})},_=async y=>{v(!0),k(""),P("");try{const R=await fetch(`/api/fs/list?path=${encodeURIComponent(y)}`);if(!R.ok){const W=await R.json();throw new Error(W.error||i.directory.openDirectoryError)}const T=await R.json();d(T.path),g(T.parent),p(T.directories)}catch(R){const T=R instanceof Error?R.message:i.directory.openDirectoryError;k(T),F.error(T)}finally{v(!1)}},b=()=>{h(!0),_(e||r||"/")},S=()=>{h(!1),k(""),P("")};return{dirUsage:c,favoritePaths:m,pickerOpen:x,browsePath:l,browseParent:n,directories:f,searchQuery:w,setSearchQuery:P,pickerLoading:C,pickerError:D,cwd:e,pathInput:z,setPathInput:U,filteredDirectories:V,favoriteDirs:Z,recentDirs:ee,isBrowsePathFavorite:te,loadDirectories:_,openPicker:b,closePicker:S,openCurrentFolder:()=>{e&&_(e)},openHomeFolder:()=>{_(r||"/")},openParentFolder:()=>{n&&_(n)},selectCurrentFolder:()=>{l&&(s(l),K(l,1),F.success(i.directory.folderSelected),S())},toggleFavorite:()=>{l&&a(y=>y.includes(l)?(F.success(i.directory.favoriteRemoved),y.filter(R=>R!==l)):y.length>=re?(F.error(i.directory.maxFavorites(re)),y):(F.success(i.directory.favoriteAdded),[...y,l]))},registerDirUsage:K}}const at=ue("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),H=o.forwardRef(({className:e,variant:s,size:r,asChild:i=!1,...c},u)=>{const m=i?Fe:"button";return t.jsx(m,{className:j(at({variant:s,size:r,className:e})),ref:u,...c})});H.displayName="Button";const it=ue("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function de({className:e,variant:s,...r}){return t.jsx("div",{className:j(it({variant:s}),e),...r})}const X=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("rounded-xl border bg-card text-card-foreground shadow",e),...s}));X.displayName="Card";const Se=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("flex flex-col space-y-1.5 p-6",e),...s}));Se.displayName="CardHeader";const ye=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("font-semibold leading-none tracking-tight",e),...s}));ye.displayName="CardTitle";const je=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("text-sm text-muted-foreground",e),...s}));je.displayName="CardDescription";const oe=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("p-6 pt-0",e),...s}));oe.displayName="CardContent";const ct=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("flex items-center p-6 pt-0",e),...s}));ct.displayName="CardFooter";function lt({onSettingsClick:e,toggleTheme:s,darkMode:r,connectionBadge:i,stepState:c,sessionId:u,status:m,configError:a,children:x}){const{messages:h}=B();return t.jsx(X,{className:"border-border/50 bg-card/88 shadow-[0_14px_36px_-30px_rgba(15,23,42,0.14)] backdrop-blur-sm",children:t.jsxs(oe,{className:"space-y-6 p-6 sm:p-7",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:["Term",t.jsx("span",{className:"text-muted-foreground",children:"Speak"})]}),t.jsx("p",{className:"max-w-2xl text-base leading-relaxed text-muted-foreground sm:text-lg",children:h.toolbar.subtitle})]}),t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsxs(de,{variant:i.variant,className:"rounded-full border border-border/30 px-4 py-1.5 text-sm font-medium shadow-none",children:[t.jsx("span",{className:j("mr-2 inline-block h-2 w-2 rounded-full",u?"bg-green-500 animate-pulse":m==="connected"?"bg-blue-500":"bg-muted-foreground animate-pulse")}),i.label]}),t.jsxs(H,{variant:"ghost",size:"sm",className:"h-10 gap-2 rounded-full px-4 text-base text-muted-foreground",onClick:e,children:[t.jsx(Te,{className:"h-4.5 w-4.5"}),h.toolbar.settings]}),t.jsx(H,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full",onClick:s,title:r?h.toolbar.lightMode:h.toolbar.darkMode,children:r?t.jsx(De,{className:"h-4.5 w-4.5"}):t.jsx(Ae,{className:"h-4.5 w-4.5"})})]})]}),t.jsx("div",{className:"flex flex-wrap gap-2.5",children:c.map(l=>t.jsxs(de,{variant:"secondary",className:j("rounded-full px-3.5 py-1.5 text-sm font-medium sm:text-base",l.done?"border border-primary/10 bg-primary/6 text-foreground":"border border-border/35 bg-background/40 text-muted-foreground"),children:[l.done&&t.jsx("span",{className:"mr-1",children:"✓"}),l.label]},l.label))}),t.jsx("div",{className:"rounded-2xl border border-border/45 bg-background/52 p-5 shadow-[inset_0_1px_0_rgba(255,255,255,0.12)] sm:p-6",children:x}),a&&t.jsx("p",{className:"rounded-xl border border-destructive/40 bg-destructive/8 px-4 py-3 text-base leading-relaxed text-destructive-foreground",children:h.toolbar.serverUnavailable})]})})}const G=Oe,J=$e,$=o.forwardRef(({className:e,children:s,...r},i)=>t.jsxs(me,{ref:i,className:j("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[s,t.jsx(He,{asChild:!0,children:t.jsx(fe,{className:"h-4 w-4 opacity-50"})})]}));$.displayName=me.displayName;const Ne=o.forwardRef(({className:e,...s},r)=>t.jsx(pe,{ref:r,className:j("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(_e,{className:"h-4 w-4"})}));Ne.displayName=pe.displayName;const Ce=o.forwardRef(({className:e,...s},r)=>t.jsx(ge,{ref:r,className:j("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(fe,{className:"h-4 w-4"})}));Ce.displayName=ge.displayName;const q=o.forwardRef(({className:e,children:s,position:r="popper",...i},c)=>t.jsx(ze,{children:t.jsxs(he,{ref:c,className:j("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...i,children:[t.jsx(Ne,{}),t.jsx(Me,{className:j("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),t.jsx(Ce,{})]})}));q.displayName=he.displayName;const dt=o.forwardRef(({className:e,...s},r)=>t.jsx(xe,{ref:r,className:j("px-2 py-1.5 text-sm font-semibold",e),...s}));dt.displayName=xe.displayName;const A=o.forwardRef(({className:e,children:s,...r},i)=>t.jsxs(ve,{ref:i,className:j("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[t.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Be,{children:t.jsx(Ue,{className:"h-4 w-4"})})}),t.jsx(Ve,{children:s})]}));A.displayName=ve.displayName;const ut=o.forwardRef(({className:e,...s},r)=>t.jsx(be,{ref:r,className:j("-mx-1 my-1 h-px bg-muted",e),...s}));ut.displayName=be.displayName;function mt({providers:e,provider:s,setProvider:r,cwd:i,hasFolder:c,openPicker:u,canStartSession:m,sessionId:a,startSession:x,stopSession:h,status:l,onSettingsClick:d,speechLang:n,setSpeechLang:g,uiLanguage:f,setUiLanguage:p,fontSize:w,setFontSize:P,isListening:C}){const{messages:v}=B(),D=c?i.split("/").filter(Boolean).at(-1)??(i==="/"?"/":i):v.controls.noFolder;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.35fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.assistant}),e.length>0?t.jsxs(t.Fragment,{children:[t.jsxs(G,{value:s,onValueChange:r,disabled:!!a,children:[t.jsx($,{className:"h-12 w-full rounded-xl bg-background/80 text-base",children:t.jsx(J,{})}),t.jsx(q,{children:e.map(k=>t.jsx(A,{value:k.id,children:k.label},k.id))})]}),t.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:v.controls.assistantReadyHint})]}):t.jsxs(t.Fragment,{children:[t.jsx(H,{variant:"outline",className:"h-12 w-full justify-start rounded-xl px-4 text-base",onClick:d,children:v.controls.configureAssistants}),t.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:v.controls.configureAssistantsHint})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.folder}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex min-h-14 items-start gap-3.5 rounded-xl border border-input bg-background/80 px-4 py-3 shadow-sm",title:i||v.controls.noFolder,children:[t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-accent/55 text-muted-foreground",children:t.jsx(qe,{className:"h-4 w-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-base font-medium text-foreground",children:D}),t.jsx("div",{className:"mt-1 truncate text-sm text-muted-foreground",children:c?i:v.controls.noFolderSelected})]})]}),t.jsx(H,{variant:"outline",size:"sm",className:"h-12 rounded-xl px-4 text-base",onClick:u,disabled:!!a,children:v.controls.chooseFolder}),t.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:v.controls.chooseFolderHint})]})]})]}),t.jsxs("div",{className:"grid gap-5 md:grid-cols-2 2xl:grid-cols-3",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.interfaceLanguage}),t.jsxs(G,{value:f,onValueChange:k=>p(k),disabled:C,children:[t.jsx($,{className:"h-12 w-full rounded-xl bg-background/80 text-base",children:t.jsx(J,{})}),t.jsxs(q,{children:[t.jsx(A,{value:"en",children:v.controls.english}),t.jsx(A,{value:"pt-BR",children:v.controls.portuguese})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.dictationLanguage}),t.jsxs(G,{value:n,onValueChange:k=>g(k),disabled:C,children:[t.jsx($,{className:"h-12 w-full rounded-xl bg-background/80 text-base",children:t.jsx(J,{})}),t.jsxs(q,{children:[t.jsx(A,{value:"pt-BR",children:v.controls.portuguese}),t.jsx(A,{value:"en-US",children:v.controls.english})]})]})]}),t.jsxs("div",{className:"space-y-3 md:col-span-2 2xl:col-span-1",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.fontSize}),t.jsxs(G,{value:w,onValueChange:k=>P(k),children:[t.jsx($,{className:"h-12 w-full rounded-xl bg-background/80 text-base",children:t.jsx(J,{})}),t.jsxs(q,{children:[t.jsx(A,{value:"sm",children:v.controls.fontSmall}),t.jsx(A,{value:"md",children:v.controls.fontMedium}),t.jsx(A,{value:"lg",children:v.controls.fontLarge})]})]})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-3 pt-2",children:[t.jsx(H,{className:"h-12 rounded-xl px-6 text-base",onClick:x,disabled:!m,children:l!=="connected"?v.controls.waitingConnection:v.controls.startSession}),t.jsx(H,{variant:"destructive",className:"h-12 rounded-xl px-6 text-base",onClick:h,disabled:!a,children:v.controls.endSession})]}),!a&&t.jsx("p",{className:"text-base leading-relaxed text-muted-foreground",children:e.length===0?v.controls.startHintNeedsAssistant:c?v.controls.startHintReady:v.controls.startHintNeedsFolder})]})}const Ee=o.forwardRef(({className:e,...s},r)=>t.jsx("textarea",{className:j("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...s}));Ee.displayName="Textarea";function ft({sessionId:e,promptDraft:s,setPromptDraft:r,sendPrompt:i,navigateHistory:c,setPromptHistoryIndex:u,promptTextareaRef:m,isListening:a,toggleVoice:x,speechSupported:h,pushToTalkLabel:l}){const{messages:d}=B();return e?t.jsx(X,{className:j("border-border/45 bg-card/84 shadow-[0_12px_30px_-28px_rgba(15,23,42,0.12)]",a&&"border-destructive/35 shadow-[0_0_14px_rgba(239,68,68,0.06)]"),children:t.jsxs(oe,{className:"grid grid-cols-[auto_1fr_auto] items-start gap-4 p-5 sm:p-6",children:[t.jsx(H,{variant:a?"destructive":"outline",size:"sm",onClick:x,disabled:!h,className:j("h-12 rounded-xl px-5 text-base",a&&"voice-pulse"),children:a?d.prompt.stopDictation:d.prompt.dictatePrompt}),t.jsx(Ee,{ref:m,value:s,onChange:n=>{r(n.target.value),u(null)},onKeyDown:n=>{if(n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),i()),n.key==="ArrowUp"){const g=n.currentTarget;g.selectionStart===0&&g.selectionEnd===0&&(n.preventDefault(),c("older"))}if(n.key==="ArrowDown"){const g=n.currentTarget;g.selectionStart===g.value.length&&g.selectionEnd===g.value.length&&(n.preventDefault(),c("newer"))}},placeholder:d.prompt.placeholder,rows:1,className:"min-h-[48px] resize-none rounded-xl bg-background/72 px-4 py-3 text-base leading-relaxed"}),t.jsx(H,{className:"h-12 rounded-xl px-6 text-base",onClick:i,disabled:!s.trim(),children:d.prompt.send}),t.jsxs("p",{className:"col-span-full pt-2 text-base leading-relaxed text-muted-foreground",children:[d.prompt.shortcuts," · ",d.prompt.pushToTalkHint(l)]})]})}):t.jsx(X,{className:"border-border/45 bg-card/84 shadow-[0_12px_30px_-28px_rgba(15,23,42,0.12)]",children:t.jsxs(Se,{className:"p-5 sm:p-6",children:[t.jsx(ye,{className:"text-xl sm:text-2xl",children:d.prompt.quickFlowTitle}),t.jsx(je,{className:"max-w-3xl pt-1 text-base leading-relaxed sm:text-lg",children:d.prompt.quickFlowDescription})]})})}const pt=o.lazy(()=>Y(()=>import("./DirectoryPickerDialog-CIdtkYr4.js"),__vite__mapDeps([3,1,4,5,0,2])).then(e=>({default:e.DirectoryPickerDialog}))),gt=o.lazy(()=>Y(()=>import("./SettingsDialog-D9VZ2obu.js"),__vite__mapDeps([6,1,5,4,0,2])).then(e=>({default:e.SettingsDialog})));function ht({prefs:e}){var _;const{messages:s}=B(),[r,i]=o.useState([]),[c,u]=o.useState(!1),[m,a]=o.useState(!1),x=o.useRef(!1),h=o.useRef(null),l=o.useMemo(()=>typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),[]),d=l?"Cmd+Shift+Space":"Ctrl+Shift+Space",n=tt({onSessionStarted:b=>{var I,L;const S=g.terminalRef.current;S&&(S.writeln(`\r
|
|
3
|
+
\x1B[32m●\x1B[0m ${s.app.sessionStartedTerminal}: \x1B[1m${b.provider}\x1B[0m @ \x1B[36m${b.cwd}\x1B[0m`),F.success(s.app.sessionStartedToast),(I=h.current)==null||I.scrollIntoView({behavior:"smooth",block:"start"}),(L=h.current)==null||L.focus({preventScroll:!0}),n.sendWs({type:"resize",sessionId:b.sessionId,cols:S.cols,rows:S.rows}))},onOutput:b=>{var S;(S=g.terminalRef.current)==null||S.write(b.data)},onSessionExit:b=>{const S=g.terminalRef.current;S&&(S.writeln(`\r
|
|
4
|
+
\x1B[2m[${s.terminal.processClosed} | exit=${b.exitCode}]\x1B[0m`),S.writeln(`\x1B[2m${s.app.sessionClosedTerminal}\x1B[0m`),F.success(s.app.sessionClosedToast))},onError:b=>{var S;(S=g.terminalRef.current)==null||S.writeln(`\r
|
|
5
|
+
\x1B[31m[${s.app.errorLabel}]\x1B[0m ${b.message}`),F.error(b.message)}}),g=st({sendWs:n.sendWs,sessionIdRef:n.sessionIdRef,sessionId:n.sessionId,fontSize:e.fontSize==="lg"?16:e.fontSize==="sm"?14:15}),f=ot({sendWs:n.sendWs,sessionId:n.sessionId}),p=rt({speechLang:e.speechLang,onTranscript:b=>f.setPromptDraft(b)}),w=nt({cwd:e.cwd,setCwd:e.setCwd,homeDir:e.homeDir}),P=e.cwd.trim().length>0,C=e.provider!==""&&r.some(b=>b.id===e.provider),v=n.status==="connected"&&!n.sessionId&&P&&C,D=o.useMemo(()=>n.sessionId?{label:s.connection.active,variant:"default"}:n.status==="connected"?{label:s.connection.ready,variant:"secondary"}:{label:s.connection.connecting,variant:"outline"},[s.connection.active,s.connection.connecting,s.connection.ready,n.sessionId,n.status]),k=o.useMemo(()=>[{label:s.steps.assistant,done:C},{label:s.steps.folder,done:P},{label:s.steps.session,done:!!n.sessionId}],[P,C,s.steps.assistant,s.steps.folder,s.steps.session,n.sessionId]),z=((_=r.find(b=>b.id===e.provider))==null?void 0:_.label)??e.provider,U=o.useCallback(async(b,S=!0)=>{const I=b.trim();if(!I)return!1;try{return(await fetch(`/api/fs/list?path=${encodeURIComponent(I)}`)).ok?!0:(e.setCwd(""),S&&F.error(s.directory.savedFolderReset),!1)}catch{return!1}},[s.directory.savedFolderReset,e.setCwd]),V=o.useCallback(async()=>{try{const b=await fetch("/api/info");if(!b.ok){u(!0);return}const S=await b.json();e.setHomeDir(S.home),i(S.providers),u(!1);const I=S.providers.map(L=>L.id);e.setProvider(L=>L&&I.includes(L)?L:S.defaultProvider||I[0]||""),S.providers.length===0&&a(!0)}catch{u(!0)}},[e.setCwd,e.setHomeDir,e.setProvider]);o.useEffect(()=>{V()},[V]),o.useEffect(()=>{const b=e.cwd.trim();b&&U(b,!1)},[U,e.cwd]);const Z=()=>{p.isListening||(f.setPromptDraft(""),f.setPromptHistoryIndex(null)),p.toggleVoice()};o.useEffect(()=>{const b=N=>{const O=N;if(!O)return!1;const se=O.tagName;return O.isContentEditable||se==="INPUT"||se==="SELECT"},S=N=>{!p.speechSupported||!n.sessionId||N.repeat||x.current||!(N.code==="Space"&&N.shiftKey&&(l?N.metaKey:N.ctrlKey))||b(N.target)||(N.preventDefault(),x.current=!0,f.setPromptDraft(""),f.setPromptHistoryIndex(null),p.startVoice())},I=()=>{var N;x.current&&(x.current=!1,p.stopVoice(),(N=f.promptTextareaRef.current)==null||N.focus())},L=N=>{(N.code==="Space"||N.key==="Shift"||N.code.startsWith("Shift")||!l&&(N.key==="Control"||N.code.startsWith("Control"))||l&&(N.key==="Meta"||N.code.startsWith("Meta")))&&I()};return window.addEventListener("keydown",S),window.addEventListener("keyup",L),window.addEventListener("blur",I),()=>{window.removeEventListener("keydown",S),window.removeEventListener("keyup",L),window.removeEventListener("blur",I)}},[l,f,p,n.sessionId]);const ee=()=>{var b;f.sendPrompt(),p.dictatedFinalRef.current="",(b=g.terminalRef.current)==null||b.focus()},te=async()=>{const b=e.cwd.trim();!b||!await U(b)||(b&&w.registerDirUsage(b,1),n.sendWs({type:"start_session",provider:e.provider,cwd:b||void 0}))},K=()=>{n.sessionId&&n.sendWs({type:"stop_session",sessionId:n.sessionId})};return t.jsxs("main",{className:j("mx-auto grid min-h-screen max-w-6xl grid-rows-[auto_auto_auto_1fr] gap-4 p-4 sm:gap-5 sm:p-6"),children:[m&&t.jsx(o.Suspense,{fallback:null,children:t.jsx(gt,{open:m,onOpenChange:a,onSaved:V})}),t.jsx(lt,{onSettingsClick:()=>a(!0),toggleTheme:e.toggleTheme,darkMode:e.darkMode,connectionBadge:D,stepState:k,sessionId:n.sessionId,status:n.status,configError:c,children:t.jsx(mt,{providers:r,provider:e.provider,setProvider:e.setProvider,cwd:e.cwd,hasFolder:P,openPicker:w.openPicker,canStartSession:v,sessionId:n.sessionId,startSession:te,stopSession:K,status:n.status,onSettingsClick:()=>a(!0),speechLang:e.speechLang,setSpeechLang:e.setSpeechLang,uiLanguage:e.uiLanguage,setUiLanguage:e.setUiLanguage,fontSize:e.fontSize,setFontSize:e.setFontSize,isListening:p.isListening})}),w.pickerOpen&&t.jsx(o.Suspense,{fallback:null,children:t.jsx(pt,{...w})}),t.jsx(ft,{sessionId:n.sessionId,promptDraft:f.promptDraft,setPromptDraft:f.setPromptDraft,sendPrompt:ee,navigateHistory:f.navigateHistory,setPromptHistoryIndex:f.setPromptHistoryIndex,promptTextareaRef:f.promptTextareaRef,isListening:p.isListening,toggleVoice:Z,speechSupported:p.speechSupported,pushToTalkLabel:d}),!p.speechSupported&&t.jsx("p",{className:"rounded-xl border border-yellow-500/30 bg-yellow-500/10 px-4 py-3 text-base leading-relaxed text-yellow-500",children:s.app.speechUnsupported}),t.jsxs("section",{ref:h,tabIndex:-1,className:j("overflow-hidden rounded-xl border border-slate-800/80 bg-[#11161b] p-2 transition-colors focus:outline-none","min-h-[58vh]",n.sessionId&&"border-primary/30"),children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 border-b border-slate-700/60 px-2 py-2.5",children:[t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-red-500/70"}),t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-yellow-500/70"}),t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-green-500/70"})]}),t.jsx("span",{className:"flex-1 text-center font-mono text-sm text-slate-400",children:n.sessionId?`${z} - ${e.cwd}`:s.app.terminalIdleTitle})]}),t.jsx("div",{className:"h-[calc(100%-34px)] overflow-hidden",ref:g.containerRef})]})]})}function xt(){const e=et();return t.jsx(Qe,{language:e.uiLanguage,children:t.jsx(ht,{prefs:e})})}const vt=({...e})=>t.jsx(Ke,{theme:"dark",className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e});Pe.createRoot(document.getElementById("root")).render(t.jsxs(Re.StrictMode,{children:[t.jsx(xt,{}),t.jsx(vt,{position:"bottom-right"})]}));export{H as B,G as S,Ct as a,$ as b,j as c,J as d,q as e,A as f,yt as p,Nt as s,jt as t,B as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as a}from"./react-vendor-DQ3p2tNP.js";import{c as o}from"./index-
|
|
1
|
+
import{r,j as a}from"./react-vendor-DQ3p2tNP.js";import{c as o}from"./index-y1qudB0y.js";import{x as u,y as g,z as d,A as b,X as N,B as n,O as i,D as c,E as f,G as y,H as h,J as m,K as j}from"./ui-vendor-Btc0UVaC.js";const w=r.forwardRef(({className:s,type:e,...t},l)=>a.jsx("input",{type:e,className:o("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:l,...t}));w.displayName="Input";const I=u,v=g,p=r.forwardRef(({className:s,...e},t)=>a.jsx(i,{ref:t,className:o("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",s),...e}));p.displayName=i.displayName;const D=r.forwardRef(({className:s,children:e,...t},l)=>a.jsxs(v,{children:[a.jsx(p,{}),a.jsxs(d,{ref:l,className:o("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",s),...t,children:[e,a.jsxs(b,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[a.jsx(N,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));D.displayName=d.displayName;const R=({className:s,...e})=>a.jsx("div",{className:o("flex flex-col space-y-1.5 text-center sm:text-left",s),...e});R.displayName="DialogHeader";const z=({className:s,...e})=>a.jsx("div",{className:o("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...e});z.displayName="DialogFooter";const S=r.forwardRef(({className:s,...e},t)=>a.jsx(n,{ref:t,className:o("text-lg font-semibold leading-none tracking-tight",s),...e}));S.displayName=n.displayName;const C=r.forwardRef(({className:s,...e},t)=>a.jsx(c,{ref:t,className:o("text-sm text-muted-foreground",s),...e}));C.displayName=c.displayName;const k=r.forwardRef(({className:s,children:e,...t},l)=>a.jsxs(f,{ref:l,className:o("relative overflow-hidden",s),...t,children:[a.jsx(y,{className:"h-full w-full rounded-[inherit]",children:e}),a.jsx(x,{}),a.jsx(h,{})]}));k.displayName=f.displayName;const x=r.forwardRef(({className:s,orientation:e="vertical",...t},l)=>a.jsx(m,{ref:l,orientation:e,className:o("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...t,children:a.jsx(j,{className:"relative flex-1 rounded-full bg-border"})}));x.displayName=m.displayName;export{I as D,w as I,k as S,D as a,R as b,S as c,z as d};
|
package/apps/web/dist/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-y1qudB0y.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-DQ3p2tNP.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/ui-vendor-Btc0UVaC.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/terminal-CnuCQtKf.js">
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-CnuCQtKf.js","assets/react-vendor-DQ3p2tNP.js","assets/terminal-Beg8tuEN.css","assets/DirectoryPickerDialog-D7IDk0pz.js","assets/scroll-area-C8DJNmaJ.js","assets/ui-vendor-Btc0UVaC.js","assets/SettingsDialog-uQLxj7UI.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as o,j as t,d as ke,R as Pe}from"./react-vendor-DQ3p2tNP.js";import{t as Re,c as Ie,a as T,S as Le,b as de,d as Fe,e as Te,M as De,T as ue,I as He,C as me,f as fe,g as _e,h as pe,P as Ae,i as ge,V as Me,L as he,j as xe,k as ze,l as Be,m as Ue,n as ve,R as Ve,o as Oe,F as $e,p as qe}from"./ui-vendor-Btc0UVaC.js";import"./terminal-CnuCQtKf.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))i(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const m of u.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function r(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(c){if(c.ep)return;c.ep=!0;const u=r(c);fetch(c.href,u)}})();const Ke="modulepreload",We=function(e){return"/"+e},oe={},G=function(s,r,i){let c=Promise.resolve();if(r&&r.length>0){let m=function(h){return Promise.all(h.map(l=>Promise.resolve(l).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),x=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));c=m(r.map(h=>{if(h=We(h),h in oe)return;oe[h]=!0;const l=h.endsWith(".css"),d=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${d}`))return;const n=document.createElement("link");if(n.rel=l?"stylesheet":Ke,l||(n.as="script"),n.crossOrigin="",n.href=h,x&&n.setAttribute("nonce",x),document.head.appendChild(n),l)return new Promise((g,f)=>{n.addEventListener("load",g),n.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(m){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=m,window.dispatchEvent(a),!a.defaultPrevented)throw m}return c.then(m=>{for(const a of m||[])a.status==="rejected"&&u(a.reason);return s().catch(u)})};function j(...e){return Re(Ie(e))}const Ge={en:{app:{sessionStartedTerminal:"Session started",sessionStartedToast:"Session started.",sessionClosedTerminal:"Terminal closed. Start a new session to begin from scratch.",sessionClosedToast:"Session ended. Start a new session to continue.",errorLabel:"error",terminalIdleTitle:"TermSpeak terminal",speechUnsupported:"Your browser does not support the Web Speech API. Use Chrome or Edge for the MVP."},connection:{active:"Active session",ready:"Ready",connecting:"Connecting..."},steps:{assistant:"1. Assistant",folder:"2. Folder",session:"3. Session"},toolbar:{settings:"Settings",lightMode:"Light mode",darkMode:"Dark mode",subtitle:"Voice-first local UI for terminal-based coding assistants.",serverUnavailable:"Server unavailable. Run `npm run dev` to start it."},controls:{assistant:"Assistant",configureAssistants:"Configure assistants",configureAssistantsHint:"Add your first assistant in Settings.",assistantReadyHint:"Choose which assistant to use in this session.",interfaceLanguage:"Interface",dictationLanguage:"Dictation",fontSize:"Text size",folder:"Project folder",noFolder:"None",selectedFolder:"Selected folder",noFolderSelected:"No folder selected",chooseFolder:"Choose folder",chooseFolderHint:"Choose the folder where the assistant should work.",waitingConnection:"Waiting for connection...",startSession:"Start session",endSession:"End session",startHintNeedsAssistant:"First, add an assistant.",startHintNeedsFolder:"Now choose a project folder.",startHintReady:"Everything is ready. Start the session.",english:"English",portuguese:"Portuguese (Brazil)",fontSmall:"Small",fontMedium:"Medium",fontLarge:"Large"},prompt:{quickFlowTitle:"Quick flow",quickFlowDescription:"1. Configure an assistant if you have not added one yet. 2. Choose the project folder. 3. Start the session. 4. Dictate or type prompts after the terminal connects.",stopDictation:"Stop dictation",dictatePrompt:"Dictate prompt",placeholder:"Say what you need, review the text, and press Enter...",send:"Send",shortcuts:"Enter sends · Shift+Enter adds a line break · Ctrl+K focuses · Arrow keys browse history",pushToTalkHint:e=>`Hold ${e} to talk`},settings:{title:"Configure assistants",description:"If you normally type `codex`, `claude`, or `aider` in the terminal, choose Normal command. If you use your own shortcut such as `personal` or `work`, choose Shell shortcut.",loading:"Loading...",remove:"Remove",name:"Name",namePlaceholder:"e.g. Claude Code CLI",executionMode:"Execution mode",executionModeDirect:"Normal command (`codex`)",executionModeShell:"Shell shortcut (`personal`)",executionModeDirectHint:"Use this when the command already works normally in your terminal.",executionModeShellHint:"Use this when the command is your own shell shortcut, alias, or function.",command:"What you type in the terminal",commandPlaceholder:"e.g. claude, codex, aider --no-auto-commits",commandDirectPlaceholder:"e.g. codex, claude, aider --no-auto-commits",commandShellPlaceholder:"e.g. personal, work, source-env && claude",commandDirectHint:"Examples: `codex`, `claude`, `aider --no-auto-commits`.",commandShellHint:"Examples: `personal`, `work`.",envVars:"Environment variables (optional)",envVarsHint:"Use this only if the assistant needs extra values when it starts. Example: `CLAUDE_CONFIG_DIR=~/.claude-work`.",envKeyPlaceholder:"KEY",envValuePlaceholder:"value",addVariable:"Add variable",addAssistant:"Add assistant",defaultProvider:"Default provider",selectPlaceholder:"Select...",cancel:"Cancel",saving:"Saving...",save:"Save",saveError:"Could not save configuration.",saveSuccess:"Configuration saved."},directory:{title:"Select directory",description:"Choose the folder where the assistant should run.",pathAriaLabel:"Path",favorites:"Favorites",recent:"Recent",goToPath:"Go to path... (Enter)",openPath:"Open",home:"Home",up:"Up",currentFolder:"Current folder",removeFavorite:"Remove from favorites",addFavorite:"Add to favorites",subfolders:"Subfolders",filter:"Filter...",loading:"Loading...",noSubfolders:"No subfolders.",noResults:"No results.",cancel:"Cancel",selectFolder:"Select this folder",folderSelected:"Folder selected.",favoriteRemoved:"Favorite removed.",favoriteAdded:"Favorite added.",maxFavorites:e=>`Maximum of ${e} favorites.`,openDirectoryError:"Could not open directory.",homeLabel:"Home"},speech:{captureError:"Voice capture failed."},terminal:{title:"TermSpeak Terminal",helper:"Choose an assistant, select a folder, and start the session.",processClosed:"process exited"}},"pt-BR":{app:{sessionStartedTerminal:"Sessão iniciada",sessionStartedToast:"Sessão iniciada.",sessionClosedTerminal:"Terminal fechado. Inicie uma nova sessão para começar do zero.",sessionClosedToast:"Sessão encerrada. Inicie uma nova sessão para continuar.",errorLabel:"erro",terminalIdleTitle:"terminal do TermSpeak",speechUnsupported:"Seu navegador não suporta Web Speech API. Use Chrome ou Edge para o MVP."},connection:{active:"Sessão ativa",ready:"Pronto",connecting:"Conectando..."},steps:{assistant:"1. Assistente",folder:"2. Pasta",session:"3. Sessão"},toolbar:{settings:"Configurações",lightMode:"Modo claro",darkMode:"Modo escuro",subtitle:"Interface local com voz para assistentes de código baseados em terminal.",serverUnavailable:"Servidor indisponível. Execute `npm run dev` para iniciar."},controls:{assistant:"Assistente",configureAssistants:"Configurar assistentes",configureAssistantsHint:"Adicione seu primeiro assistente em Configurações.",assistantReadyHint:"Escolha qual assistente usar nesta sessão.",interfaceLanguage:"Interface",dictationLanguage:"Ditado",fontSize:"Tamanho do texto",folder:"Pasta do projeto",noFolder:"Nenhuma",selectedFolder:"Pasta selecionada",noFolderSelected:"Nenhuma pasta selecionada",chooseFolder:"Escolher pasta",chooseFolderHint:"Escolha a pasta onde o assistente deve trabalhar.",waitingConnection:"Aguardando conexão...",startSession:"Iniciar sessão",endSession:"Encerrar sessão",startHintNeedsAssistant:"Primeiro, adicione um assistente.",startHintNeedsFolder:"Agora escolha a pasta do projeto.",startHintReady:"Tudo pronto. Inicie a sessão.",english:"Inglês",portuguese:"Português (Brasil)",fontSmall:"Pequeno",fontMedium:"Médio",fontLarge:"Grande"},prompt:{quickFlowTitle:"Fluxo rápido",quickFlowDescription:"1. Configure um assistente se ainda não existir nenhum. 2. Escolha a pasta do projeto. 3. Inicie a sessão. 4. Depois dite ou digite seus prompts quando o terminal conectar.",stopDictation:"Parar ditado",dictatePrompt:"Ditar prompt",placeholder:"Diga seu pedido, revise o texto e pressione Enter...",send:"Enviar",shortcuts:"Enter envia · Shift+Enter quebra linha · Ctrl+K foca · Setas navegam no histórico",pushToTalkHint:e=>`Segure ${e} para falar`},settings:{title:"Configurar assistentes",description:"Se você normalmente digita `codex`, `claude` ou `aider` no terminal, escolha Comando normal. Se você usa um atalho seu, como `personal` ou `work`, escolha Atalho do shell.",loading:"Carregando...",remove:"Remover",name:"Nome",namePlaceholder:"Ex.: Claude Code CLI",executionMode:"Modo de execução",executionModeDirect:"Comando normal (`codex`)",executionModeShell:"Atalho do shell (`personal`)",executionModeDirectHint:"Use quando o comando já funciona normalmente no seu terminal.",executionModeShellHint:"Use quando o comando é um atalho, alias ou função do seu shell.",command:"O que você digita no terminal",commandPlaceholder:"Ex.: claude, codex, aider --no-auto-commits",commandDirectPlaceholder:"Ex.: codex, claude, aider --no-auto-commits",commandShellPlaceholder:"Ex.: personal, work, source-env && claude",commandDirectHint:"Exemplos: `codex`, `claude`, `aider --no-auto-commits`.",commandShellHint:"Exemplos: `personal`, `work`.",envVars:"Variáveis de ambiente (opcional)",envVarsHint:"Use isso só se o assistente precisar de valores extras ao iniciar. Exemplo: `CLAUDE_CONFIG_DIR=~/.claude-work`.",envKeyPlaceholder:"CHAVE",envValuePlaceholder:"valor",addVariable:"Adicionar variável",addAssistant:"Adicionar assistente",defaultProvider:"Provider padrão",selectPlaceholder:"Selecionar...",cancel:"Cancelar",saving:"Salvando...",save:"Salvar",saveError:"Erro ao salvar configuração.",saveSuccess:"Configuração salva."},directory:{title:"Selecionar diretório",description:"Escolha a pasta onde o assistente deve rodar.",pathAriaLabel:"Caminho",favorites:"Favoritos",recent:"Recentes",goToPath:"Ir para caminho... (Enter)",openPath:"Abrir",home:"Home",up:"Acima",currentFolder:"Pasta atual",removeFavorite:"Remover dos favoritos",addFavorite:"Adicionar aos favoritos",subfolders:"Subpastas",filter:"Filtrar...",loading:"Carregando...",noSubfolders:"Nenhuma subpasta.",noResults:"Nenhum resultado.",cancel:"Cancelar",selectFolder:"Selecionar esta pasta",folderSelected:"Pasta selecionada.",favoriteRemoved:"Favorito removido.",favoriteAdded:"Favorito adicionado.",maxFavorites:e=>`Máximo de ${e} favoritos.`,openDirectoryError:"Falha ao abrir diretório.",homeLabel:"Home"},speech:{captureError:"Falha ao capturar voz."},terminal:{title:"Terminal TermSpeak",helper:"Escolha um assistente, selecione uma pasta e inicie a sessão.",processClosed:"processo encerrado"}}},be=o.createContext(null);function Je(e){return e==="pt-BR"?"pt-BR":"en"}function ne(){return(typeof navigator>"u"?[]:[navigator.language,...navigator.languages??[]]).some(s=>s==null?void 0:s.toLowerCase().startsWith("pt"))?"pt-BR":"en"}function Ye({language:e,children:s}){return o.useEffect(()=>{document.documentElement.lang=e},[e]),t.jsx(be.Provider,{value:{language:e,messages:Ge[e]},children:s})}function z(){const e=o.useContext(be);if(!e)throw new Error("useI18n must be used within I18nProvider");return e}const E={speechLang:"voice-control.speech-lang",uiLanguage:"voice-control.ui-language",fontSize:"voice-control.font-size",preferences:"voice-control.preferences",promptHistory:"voice-control.prompt-history",dirUsage:"voice-control.dir-usage",favorites:"voice-control.favorites",theme:"voice-control.theme"},ae=30,Qe=80,se=6,M=(e,s)=>{try{const r=window.localStorage.getItem(e);return r?JSON.parse(r):s}catch{return s}},J=(e,s)=>{window.localStorage.setItem(e,JSON.stringify(s))},Xe=e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(s=>typeof s[0]=="string"&&typeof s[1]=="number"&&Number.isFinite(s[1])&&s[1]>0)),ie=e=>Object.fromEntries(Object.entries(e).sort((s,r)=>r[1]-s[1]).slice(0,Qe)),ce=(e,s,r="Home")=>s&&e===s?r:e.split("/").filter(Boolean).at(-1)??e,yt=e=>{const s=e.split("/").filter(Boolean),r=[{label:"/",path:"/"}];for(let i=0;i<s.length;i++)r.push({label:s[i],path:"/"+s.slice(0,i+1).join("/")});return r},jt=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,30)||"provider",Nt=(e,s)=>[e,...s].map(r=>r.length===0?"''":/^[A-Za-z0-9_./:@%+=,-]+$/.test(r)?r:`'${r.replace(/'/g,"'\\''")}'`).join(" ");function Ct(e){const s=[];let r="",i="plain",c=!1;const u=()=>{r.length>0&&(s.push(r),r="")};for(let m=0;m<e.length;m+=1){const a=e[m];if(c){r+=a,c=!1;continue}if(i==="single"){a==="'"?i="plain":r+=a;continue}if(i==="double"){if(a==='"')i="plain";else if(a==="\\"){const x=e[m+1];x&&["\\",'"',"$","`"].includes(x)?(r+=x,m+=1):r+=a}else r+=a;continue}if(/\s/.test(a)){u();continue}if(a==="\\"){c=!0;continue}if(a==="'"){i="single";continue}if(a==='"'){i="double";continue}r+=a}if(c&&(r+="\\"),u(),i!=="plain")throw new Error("Unterminated quoted string.");return{command:s[0]??"",args:s.slice(1)}}function Ze(){const[e,s]=o.useState(()=>{const p=window.localStorage.getItem(E.theme);if(p==="light"||p==="dark"){const w=p==="dark";return document.documentElement.classList.toggle("dark",w),w}return document.documentElement.classList.contains("dark")}),r=()=>{s(p=>{const w=!p;return document.documentElement.classList.toggle("dark",w),window.localStorage.setItem(E.theme,w?"dark":"light"),w})},[i,c]=o.useState(()=>{const p=window.localStorage.getItem(E.speechLang);return p==="en-US"||p==="pt-BR"?p:ne()==="pt-BR"?"pt-BR":"en-US"}),[u,m]=o.useState(()=>{const p=window.localStorage.getItem(E.uiLanguage);if(p)return Je(p);const w=M(E.preferences,{});return w.uiLanguage?w.uiLanguage:ne()}),[a,x]=o.useState(()=>{const p=window.localStorage.getItem(E.fontSize);if(p==="sm"||p==="md"||p==="lg")return p;const w=M(E.preferences,{});return w.fontSize==="sm"||w.fontSize==="md"||w.fontSize==="lg"?w.fontSize:"md"}),[h,l]=o.useState(()=>M(E.preferences,{}).provider??""),[d,n]=o.useState(()=>M(E.preferences,{}).cwd??""),[g,f]=o.useState("");return o.useEffect(()=>{window.localStorage.setItem(E.speechLang,i)},[i]),o.useEffect(()=>{window.localStorage.setItem(E.uiLanguage,u)},[u]),o.useEffect(()=>{window.localStorage.setItem(E.fontSize,a),document.body.dataset.fontSize=a,document.documentElement.dataset.fontSize=a},[a]),o.useEffect(()=>{J(E.preferences,{provider:h,cwd:d.trim(),uiLanguage:u,fontSize:a})},[d,h,u,a]),{darkMode:e,toggleTheme:r,uiLanguage:u,setUiLanguage:m,fontSize:a,setFontSize:x,speechLang:i,setSpeechLang:c,provider:h,setProvider:l,cwd:d,setCwd:n,homeDir:g,setHomeDir:f}}function et(e){const[s,r]=o.useState("connecting"),[i,c]=o.useState(null),u=o.useRef(null),m=o.useRef(null),a=o.useRef(e);a.current=e,o.useEffect(()=>{m.current=i},[i]);const x=o.useCallback(h=>{const l=u.current;!l||l.readyState!==WebSocket.OPEN||l.send(JSON.stringify(h))},[]);return o.useEffect(()=>{const h=window.location.protocol==="https:"?"wss":"ws",l=new WebSocket(`${h}://${window.location.host}/ws`);return u.current=l,l.onopen=()=>{r("connected")},l.onclose=()=>{r("disconnected"),c(null)},l.onmessage=d=>{const n=JSON.parse(d.data);n.type==="session_started"&&(c(n.sessionId),a.current.onSessionStarted(n)),n.type==="output"&&a.current.onOutput(n),n.type==="session_exit"&&(c(null),a.current.onSessionExit(n)),n.type==="error"&&a.current.onError(n)},()=>{l.close()}},[]),{status:s,sessionId:i,setSessionId:c,sessionIdRef:m,sendWs:x}}function tt({sendWs:e,sessionIdRef:s,sessionId:r,fontSize:i}){const{messages:c}=z(),u=o.useRef(null),m=o.useRef(i),a=o.useRef(null),x=o.useRef(null),h=()=>{const l=x.current;l&&(l.reset(),l.writeln(`\x1B[1m ${c.terminal.title} \x1B[0m`),l.writeln(`\x1B[2m ${c.terminal.helper}\x1B[0m`),l.writeln(""))};return m.current=i,o.useEffect(()=>{if(!u.current)return;let l=!1,d;return(async()=>{const[{Terminal:n},{FitAddon:g}]=await Promise.all([G(()=>import("./terminal-CnuCQtKf.js").then(C=>C.x),__vite__mapDeps([0,1,2])),G(()=>import("./terminal-CnuCQtKf.js").then(C=>C.a),__vite__mapDeps([0,1,2]))]);if(l||!u.current)return;const f=new n({cursorBlink:!0,fontFamily:'"JetBrains Mono", monospace',fontSize:m.current,lineHeight:1.35,theme:{background:"#0a0a0a",foreground:"#fafafa",cursor:"#fafafa",cursorAccent:"#0a0a0a",selectionBackground:"rgba(250, 250, 250, 0.15)",black:"#0a0a0a",red:"#ff7b72",green:"#3fb950",yellow:"#d29922",blue:"#58a6ff",magenta:"#bc8cff",cyan:"#39d2e0",white:"#fafafa",brightBlack:"#484f58",brightRed:"#ffa198",brightGreen:"#56d364",brightYellow:"#e3b341",brightBlue:"#79c0ff",brightMagenta:"#d2a8ff",brightCyan:"#56d4dd",brightWhite:"#f0f6fc"}}),p=new g;f.loadAddon(p),f.open(u.current),p.fit(),a.current=p,x.current=f,h();const w=()=>{p.fit();const C=s.current;C&&e({type:"resize",sessionId:C,cols:f.cols,rows:f.rows})},P=f.onData(C=>{const v=s.current;v&&e({type:"input",sessionId:v,data:C})});window.addEventListener("resize",w),d=()=>{window.removeEventListener("resize",w),P.dispose(),a.current=null,x.current=null,f.dispose()}})(),()=>{l=!0,d==null||d()}},[e,s]),o.useEffect(()=>{r||h()},[c.terminal.helper,c.terminal.title,r]),o.useEffect(()=>{var n;const l=x.current;if(!l)return;l.options.fontSize=i,(n=a.current)==null||n.fit(),l.refresh(0,l.rows-1);const d=s.current;d&&e({type:"resize",sessionId:d,cols:l.cols,rows:l.rows})},[i,e,s]),{terminalRef:x,containerRef:u}}function st({speechLang:e,onTranscript:s}){const{messages:r}=z(),[i,c]=o.useState(!1),u=o.useRef(!1),m=o.useRef(""),a=o.useRef(null),x=o.useRef(s);x.current=s;const h=o.useMemo(()=>typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition),[]);o.useEffect(()=>{u.current=i},[i]),o.useEffect(()=>{a.current&&(a.current.lang=e)},[e]),o.useEffect(()=>{if(!h)return;const g=window.SpeechRecognition||window.webkitSpeechRecognition,f=new g;return f.lang=e,f.interimResults=!0,f.continuous=!0,f.onresult=p=>{var C,v;let w="";for(let D=p.resultIndex;D<p.results.length;D+=1){const k=p.results[D],A=((v=(C=k[0])==null?void 0:C.transcript)==null?void 0:v.trim())??"";A&&(k.isFinal?m.current=`${m.current} ${A}`.trim():w=`${w} ${A}`.trim())}const P=`${m.current} ${w}`.trim();x.current(P)},f.onend=()=>{if(u.current){f.start();return}c(!1)},f.onerror=p=>{if(u.current&&(p.error==="aborted"||p.error==="no-speech")){f.start();return}c(!1),T.error(r.speech.captureError)},a.current=f,()=>{f.stop()}},[r.speech.captureError,h,e]);const l=()=>{const g=a.current;if(g&&!u.current){m.current="";try{g.start(),c(!0)}catch{}}},d=()=>{const g=a.current;g&&u.current&&(g.stop(),c(!1))};return{isListening:i,startVoice:l,stopVoice:d,toggleVoice:()=>{if(u.current){d();return}l()},speechSupported:h,dictatedFinalRef:m}}function rt({sendWs:e,sessionId:s}){const[r,i]=o.useState(""),[c,u]=o.useState(()=>M(E.promptHistory,[])),[m,a]=o.useState(null),x=o.useRef(null);return o.useEffect(()=>{J(E.promptHistory,c.slice(0,ae))},[c]),o.useEffect(()=>{const d=x.current;if(!d)return;d.style.height="0px";const n=Math.min(d.scrollHeight,200);d.style.height=`${n}px`,d.scrollTop=d.scrollHeight},[r]),o.useEffect(()=>{var d;s&&((d=x.current)==null||d.focus())},[s]),o.useEffect(()=>{const d=n=>{var g;(n.ctrlKey||n.metaKey)&&n.key.toLowerCase()==="k"&&(n.preventDefault(),(g=x.current)==null||g.focus())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[]),{promptDraft:r,setPromptDraft:i,sendPrompt:()=>{const d=r.trim();!s||!d||(e({type:"input",sessionId:s,data:d}),u(n=>[d,...n.filter(g=>g!==d)].slice(0,ae)),a(null),i(""),T.success("Prompt enviado."))},navigateHistory:d=>{if(c.length!==0){if(d==="older"){a(n=>{const g=n===null?0:Math.min(n+1,c.length-1),f=c[g];return f&&i(f),g});return}a(n=>{if(n===null)return null;const g=n-1;if(g<0)return i(""),null;const f=c[g];return f&&i(f),g})}},promptTextareaRef:x,promptHistory:c,promptHistoryIndex:m,setPromptHistoryIndex:a}}function ot({cwd:e,setCwd:s,homeDir:r}){const{messages:i}=z(),[c,u]=o.useState(()=>Xe(M(E.dirUsage,{}))),[m,a]=o.useState(()=>M(E.favorites,[])),[x,h]=o.useState(!1),[l,d]=o.useState(""),[n,g]=o.useState(null),[f,p]=o.useState([]),[w,P]=o.useState(""),[C,v]=o.useState(!1),[D,k]=o.useState(""),[A,B]=o.useState("");o.useEffect(()=>{J(E.dirUsage,ie(c))},[c]),o.useEffect(()=>{J(E.favorites,m)},[m]),o.useEffect(()=>{B(l)},[l]);const Q=o.useMemo(()=>{const y=w.trim().toLowerCase();return y?f.filter(R=>R.name.toLowerCase().includes(y)):f},[f,w]),X=o.useMemo(()=>m.slice(0,se).map(y=>({label:ce(y,r,i.directory.homeLabel),path:y})),[m,r,i.directory.homeLabel]),Z=o.useMemo(()=>Object.entries(c).sort((y,R)=>R[1]-y[1]).map(([y])=>y).filter(y=>y!==e&&!m.includes(y)).slice(0,5).map(y=>({label:ce(y,r,i.directory.homeLabel),path:y})),[e,c,m,r,i.directory.homeLabel]),ee=o.useMemo(()=>!!l&&m.includes(l),[l,m]),U=(y,R=1)=>{const F=y.trim();F&&u(q=>{const Ee={...q,[F]:(q[F]??0)+R};return ie(Ee)})},b=async y=>{v(!0),k(""),P("");try{const R=await fetch(`/api/fs/list?path=${encodeURIComponent(y)}`);if(!R.ok){const q=await R.json();throw new Error(q.error||i.directory.openDirectoryError)}const F=await R.json();d(F.path),g(F.parent),p(F.directories)}catch(R){const F=R instanceof Error?R.message:i.directory.openDirectoryError;k(F),T.error(F)}finally{v(!1)}},S=()=>{h(!0),b(e||r||"/")},I=()=>{h(!1),k(""),P("")};return{dirUsage:c,favoritePaths:m,pickerOpen:x,browsePath:l,browseParent:n,directories:f,searchQuery:w,setSearchQuery:P,pickerLoading:C,pickerError:D,cwd:e,pathInput:A,setPathInput:B,filteredDirectories:Q,favoriteDirs:X,recentDirs:Z,isBrowsePathFavorite:ee,loadDirectories:b,openPicker:S,closePicker:I,openCurrentFolder:()=>{e&&b(e)},openHomeFolder:()=>{b(r||"/")},openParentFolder:()=>{n&&b(n)},selectCurrentFolder:()=>{l&&(s(l),U(l,1),T.success(i.directory.folderSelected),I())},toggleFavorite:()=>{l&&a(y=>y.includes(l)?(T.success(i.directory.favoriteRemoved),y.filter(R=>R!==l)):y.length>=se?(T.error(i.directory.maxFavorites(se)),y):(T.success(i.directory.favoriteAdded),[...y,l]))},registerDirUsage:U}}const nt=de("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),_=o.forwardRef(({className:e,variant:s,size:r,asChild:i=!1,...c},u)=>{const m=i?Le:"button";return t.jsx(m,{className:j(nt({variant:s,size:r,className:e})),ref:u,...c})});_.displayName="Button";const at=de("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function le({className:e,variant:s,...r}){return t.jsx("div",{className:j(at({variant:s}),e),...r})}const Y=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("rounded-xl border bg-card text-card-foreground shadow",e),...s}));Y.displayName="Card";const we=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("flex flex-col space-y-1.5 p-6",e),...s}));we.displayName="CardHeader";const Se=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("font-semibold leading-none tracking-tight",e),...s}));Se.displayName="CardTitle";const ye=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("text-sm text-muted-foreground",e),...s}));ye.displayName="CardDescription";const re=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("p-6 pt-0",e),...s}));re.displayName="CardContent";const it=o.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:j("flex items-center p-6 pt-0",e),...s}));it.displayName="CardFooter";function ct({onSettingsClick:e,toggleTheme:s,darkMode:r,connectionBadge:i,stepState:c,sessionId:u,status:m,configError:a,children:x}){const{messages:h}=z();return t.jsx(Y,{className:"border-border/50 bg-card/88 shadow-[0_14px_36px_-30px_rgba(15,23,42,0.14)] backdrop-blur-sm",children:t.jsxs(re,{className:"space-y-6 p-6 sm:p-7",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:["Term",t.jsx("span",{className:"text-muted-foreground",children:"Speak"})]}),t.jsx("p",{className:"max-w-2xl text-base leading-relaxed text-muted-foreground sm:text-lg",children:h.toolbar.subtitle})]}),t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsxs(le,{variant:i.variant,className:"rounded-full border border-border/30 px-4 py-1.5 text-sm font-medium shadow-none",children:[t.jsx("span",{className:j("mr-2 inline-block h-2 w-2 rounded-full",u?"bg-green-500 animate-pulse":m==="connected"?"bg-blue-500":"bg-muted-foreground animate-pulse")}),i.label]}),t.jsxs(_,{variant:"ghost",size:"sm",className:"h-10 gap-2 rounded-full px-4 text-base text-muted-foreground",onClick:e,children:[t.jsx(Fe,{className:"h-4.5 w-4.5"}),h.toolbar.settings]}),t.jsx(_,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full",onClick:s,title:r?h.toolbar.lightMode:h.toolbar.darkMode,children:r?t.jsx(Te,{className:"h-4.5 w-4.5"}):t.jsx(De,{className:"h-4.5 w-4.5"})})]})]}),t.jsx("div",{className:"flex flex-wrap gap-2.5",children:c.map(l=>t.jsxs(le,{variant:"secondary",className:j("rounded-full px-3.5 py-1.5 text-sm font-medium sm:text-base",l.done?"border border-primary/10 bg-primary/6 text-foreground":"border border-border/35 bg-background/40 text-muted-foreground"),children:[l.done&&t.jsx("span",{className:"mr-1",children:"✓"}),l.label]},l.label))}),t.jsx("div",{className:"rounded-2xl border border-border/45 bg-background/52 p-5 shadow-[inset_0_1px_0_rgba(255,255,255,0.12)] sm:p-6",children:x}),a&&t.jsx("p",{className:"rounded-xl border border-destructive/40 bg-destructive/8 px-4 py-3 text-base leading-relaxed text-destructive-foreground",children:h.toolbar.serverUnavailable})]})})}const K=Ve,W=Oe,O=o.forwardRef(({className:e,children:s,...r},i)=>t.jsxs(ue,{ref:i,className:j("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[s,t.jsx(He,{asChild:!0,children:t.jsx(me,{className:"h-4 w-4 opacity-50"})})]}));O.displayName=ue.displayName;const je=o.forwardRef(({className:e,...s},r)=>t.jsx(fe,{ref:r,className:j("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(_e,{className:"h-4 w-4"})}));je.displayName=fe.displayName;const Ne=o.forwardRef(({className:e,...s},r)=>t.jsx(pe,{ref:r,className:j("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(me,{className:"h-4 w-4"})}));Ne.displayName=pe.displayName;const $=o.forwardRef(({className:e,children:s,position:r="popper",...i},c)=>t.jsx(Ae,{children:t.jsxs(ge,{ref:c,className:j("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...i,children:[t.jsx(je,{}),t.jsx(Me,{className:j("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),t.jsx(Ne,{})]})}));$.displayName=ge.displayName;const lt=o.forwardRef(({className:e,...s},r)=>t.jsx(he,{ref:r,className:j("px-2 py-1.5 text-sm font-semibold",e),...s}));lt.displayName=he.displayName;const H=o.forwardRef(({className:e,children:s,...r},i)=>t.jsxs(xe,{ref:i,className:j("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[t.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(ze,{children:t.jsx(Be,{className:"h-4 w-4"})})}),t.jsx(Ue,{children:s})]}));H.displayName=xe.displayName;const dt=o.forwardRef(({className:e,...s},r)=>t.jsx(ve,{ref:r,className:j("-mx-1 my-1 h-px bg-muted",e),...s}));dt.displayName=ve.displayName;function ut({providers:e,provider:s,setProvider:r,cwd:i,hasFolder:c,openPicker:u,canStartSession:m,sessionId:a,startSession:x,stopSession:h,status:l,onSettingsClick:d,speechLang:n,setSpeechLang:g,uiLanguage:f,setUiLanguage:p,fontSize:w,setFontSize:P,isListening:C}){const{messages:v}=z(),D=c?i.split("/").filter(Boolean).at(-1)??(i==="/"?"/":i):v.controls.noFolder;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.35fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.assistant}),e.length>0?t.jsxs(t.Fragment,{children:[t.jsxs(K,{value:s,onValueChange:r,disabled:!!a,children:[t.jsx(O,{className:"h-12 w-full rounded-xl bg-background/80 text-base",children:t.jsx(W,{})}),t.jsx($,{children:e.map(k=>t.jsx(H,{value:k.id,children:k.label},k.id))})]}),t.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:v.controls.assistantReadyHint})]}):t.jsxs(t.Fragment,{children:[t.jsx(_,{variant:"outline",className:"h-12 w-full justify-start rounded-xl px-4 text-base",onClick:d,children:v.controls.configureAssistants}),t.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:v.controls.configureAssistantsHint})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.folder}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex min-h-14 items-start gap-3.5 rounded-xl border border-input bg-background/80 px-4 py-3 shadow-sm",title:i||v.controls.noFolder,children:[t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-accent/55 text-muted-foreground",children:t.jsx($e,{className:"h-4 w-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-base font-medium text-foreground",children:D}),t.jsx("div",{className:"mt-1 truncate text-sm text-muted-foreground",children:c?i:v.controls.noFolderSelected})]})]}),t.jsx(_,{variant:"outline",size:"sm",className:"h-12 rounded-xl px-4 text-base",onClick:u,disabled:!!a,children:v.controls.chooseFolder}),t.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:v.controls.chooseFolderHint})]})]})]}),t.jsxs("div",{className:"grid gap-5 md:grid-cols-2 2xl:grid-cols-3",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.interfaceLanguage}),t.jsxs(K,{value:f,onValueChange:k=>p(k),disabled:C,children:[t.jsx(O,{className:"h-12 w-full rounded-xl bg-background/80 text-base",children:t.jsx(W,{})}),t.jsxs($,{children:[t.jsx(H,{value:"en",children:v.controls.english}),t.jsx(H,{value:"pt-BR",children:v.controls.portuguese})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.dictationLanguage}),t.jsxs(K,{value:n,onValueChange:k=>g(k),disabled:C,children:[t.jsx(O,{className:"h-12 w-full rounded-xl bg-background/80 text-base",children:t.jsx(W,{})}),t.jsxs($,{children:[t.jsx(H,{value:"pt-BR",children:v.controls.portuguese}),t.jsx(H,{value:"en-US",children:v.controls.english})]})]})]}),t.jsxs("div",{className:"space-y-3 md:col-span-2 2xl:col-span-1",children:[t.jsx("label",{className:"text-base font-medium text-foreground",children:v.controls.fontSize}),t.jsxs(K,{value:w,onValueChange:k=>P(k),children:[t.jsx(O,{className:"h-12 w-full rounded-xl bg-background/80 text-base",children:t.jsx(W,{})}),t.jsxs($,{children:[t.jsx(H,{value:"sm",children:v.controls.fontSmall}),t.jsx(H,{value:"md",children:v.controls.fontMedium}),t.jsx(H,{value:"lg",children:v.controls.fontLarge})]})]})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-3 pt-2",children:[t.jsx(_,{className:"h-12 rounded-xl px-6 text-base",onClick:x,disabled:!m,children:l!=="connected"?v.controls.waitingConnection:v.controls.startSession}),t.jsx(_,{variant:"destructive",className:"h-12 rounded-xl px-6 text-base",onClick:h,disabled:!a,children:v.controls.endSession})]}),!a&&t.jsx("p",{className:"text-base leading-relaxed text-muted-foreground",children:e.length===0?v.controls.startHintNeedsAssistant:c?v.controls.startHintReady:v.controls.startHintNeedsFolder})]})}const Ce=o.forwardRef(({className:e,...s},r)=>t.jsx("textarea",{className:j("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...s}));Ce.displayName="Textarea";function mt({sessionId:e,promptDraft:s,setPromptDraft:r,sendPrompt:i,navigateHistory:c,setPromptHistoryIndex:u,promptTextareaRef:m,isListening:a,toggleVoice:x,speechSupported:h,pushToTalkLabel:l}){const{messages:d}=z();return e?t.jsx(Y,{className:j("border-border/45 bg-card/84 shadow-[0_12px_30px_-28px_rgba(15,23,42,0.12)]",a&&"border-destructive/35 shadow-[0_0_14px_rgba(239,68,68,0.06)]"),children:t.jsxs(re,{className:"grid grid-cols-[auto_1fr_auto] items-start gap-4 p-5 sm:p-6",children:[t.jsx(_,{variant:a?"destructive":"outline",size:"sm",onClick:x,disabled:!h,className:j("h-12 rounded-xl px-5 text-base",a&&"voice-pulse"),children:a?d.prompt.stopDictation:d.prompt.dictatePrompt}),t.jsx(Ce,{ref:m,value:s,onChange:n=>{r(n.target.value),u(null)},onKeyDown:n=>{if(n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),i()),n.key==="ArrowUp"){const g=n.currentTarget;g.selectionStart===0&&g.selectionEnd===0&&(n.preventDefault(),c("older"))}if(n.key==="ArrowDown"){const g=n.currentTarget;g.selectionStart===g.value.length&&g.selectionEnd===g.value.length&&(n.preventDefault(),c("newer"))}},placeholder:d.prompt.placeholder,rows:1,className:"min-h-[48px] resize-none rounded-xl bg-background/72 px-4 py-3 text-base leading-relaxed"}),t.jsx(_,{className:"h-12 rounded-xl px-6 text-base",onClick:i,disabled:!s.trim(),children:d.prompt.send}),t.jsxs("p",{className:"col-span-full pt-2 text-base leading-relaxed text-muted-foreground",children:[d.prompt.shortcuts," · ",d.prompt.pushToTalkHint(l)]})]})}):t.jsx(Y,{className:"border-border/45 bg-card/84 shadow-[0_12px_30px_-28px_rgba(15,23,42,0.12)]",children:t.jsxs(we,{className:"p-5 sm:p-6",children:[t.jsx(Se,{className:"text-xl sm:text-2xl",children:d.prompt.quickFlowTitle}),t.jsx(ye,{className:"max-w-3xl pt-1 text-base leading-relaxed sm:text-lg",children:d.prompt.quickFlowDescription})]})})}const ft=o.lazy(()=>G(()=>import("./DirectoryPickerDialog-D7IDk0pz.js"),__vite__mapDeps([3,1,4,5,0,2])).then(e=>({default:e.DirectoryPickerDialog}))),pt=o.lazy(()=>G(()=>import("./SettingsDialog-uQLxj7UI.js"),__vite__mapDeps([6,1,5,4,0,2])).then(e=>({default:e.SettingsDialog})));function gt({prefs:e}){var U;const{messages:s}=z(),[r,i]=o.useState([]),[c,u]=o.useState(!1),[m,a]=o.useState(!1),x=o.useRef(!1),h=o.useRef(null),l=o.useMemo(()=>typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),[]),d=l?"Cmd+Shift+Space":"Ctrl+Shift+Space",n=et({onSessionStarted:b=>{var I,L;const S=g.terminalRef.current;S&&(S.writeln(`\r
|
|
3
|
-
\x1B[32m●\x1B[0m ${s.app.sessionStartedTerminal}: \x1B[1m${b.provider}\x1B[0m @ \x1B[36m${b.cwd}\x1B[0m`),T.success(s.app.sessionStartedToast),(I=h.current)==null||I.scrollIntoView({behavior:"smooth",block:"start"}),(L=h.current)==null||L.focus({preventScroll:!0}),n.sendWs({type:"resize",sessionId:b.sessionId,cols:S.cols,rows:S.rows}))},onOutput:b=>{var S;(S=g.terminalRef.current)==null||S.write(b.data)},onSessionExit:b=>{const S=g.terminalRef.current;S&&(S.writeln(`\r
|
|
4
|
-
\x1B[2m[${s.terminal.processClosed} | exit=${b.exitCode}]\x1B[0m`),S.writeln(`\x1B[2m${s.app.sessionClosedTerminal}\x1B[0m`),T.success(s.app.sessionClosedToast))},onError:b=>{var S;(S=g.terminalRef.current)==null||S.writeln(`\r
|
|
5
|
-
\x1B[31m[${s.app.errorLabel}]\x1B[0m ${b.message}`),T.error(b.message)}}),g=tt({sendWs:n.sendWs,sessionIdRef:n.sessionIdRef,sessionId:n.sessionId,fontSize:e.fontSize==="lg"?16:e.fontSize==="sm"?14:15}),f=rt({sendWs:n.sendWs,sessionId:n.sessionId}),p=st({speechLang:e.speechLang,onTranscript:b=>f.setPromptDraft(b)}),w=ot({cwd:e.cwd,setCwd:e.setCwd,homeDir:e.homeDir}),P=e.cwd.trim().length>0,C=e.provider!==""&&r.some(b=>b.id===e.provider),v=n.status==="connected"&&!n.sessionId&&P&&C,D=o.useMemo(()=>n.sessionId?{label:s.connection.active,variant:"default"}:n.status==="connected"?{label:s.connection.ready,variant:"secondary"}:{label:s.connection.connecting,variant:"outline"},[s.connection.active,s.connection.connecting,s.connection.ready,n.sessionId,n.status]),k=o.useMemo(()=>[{label:s.steps.assistant,done:C},{label:s.steps.folder,done:P},{label:s.steps.session,done:!!n.sessionId}],[P,C,s.steps.assistant,s.steps.folder,s.steps.session,n.sessionId]),A=((U=r.find(b=>b.id===e.provider))==null?void 0:U.label)??e.provider,B=o.useCallback(async()=>{try{const b=await fetch("/api/info");if(!b.ok){u(!0);return}const S=await b.json();e.setHomeDir(S.home),i(S.providers),u(!1);const I=S.providers.map(L=>L.id);e.setProvider(L=>L&&I.includes(L)?L:S.defaultProvider||I[0]||""),S.providers.length===0&&a(!0)}catch{u(!0)}},[e.setCwd,e.setHomeDir,e.setProvider]);o.useEffect(()=>{B()},[B]);const Q=()=>{p.isListening||(f.setPromptDraft(""),f.setPromptHistoryIndex(null)),p.toggleVoice()};o.useEffect(()=>{const b=N=>{const V=N;if(!V)return!1;const te=V.tagName;return V.isContentEditable||te==="INPUT"||te==="SELECT"},S=N=>{!p.speechSupported||!n.sessionId||N.repeat||x.current||!(N.code==="Space"&&N.shiftKey&&(l?N.metaKey:N.ctrlKey))||b(N.target)||(N.preventDefault(),x.current=!0,f.setPromptDraft(""),f.setPromptHistoryIndex(null),p.startVoice())},I=()=>{var N;x.current&&(x.current=!1,p.stopVoice(),(N=f.promptTextareaRef.current)==null||N.focus())},L=N=>{(N.code==="Space"||N.key==="Shift"||N.code.startsWith("Shift")||!l&&(N.key==="Control"||N.code.startsWith("Control"))||l&&(N.key==="Meta"||N.code.startsWith("Meta")))&&I()};return window.addEventListener("keydown",S),window.addEventListener("keyup",L),window.addEventListener("blur",I),()=>{window.removeEventListener("keydown",S),window.removeEventListener("keyup",L),window.removeEventListener("blur",I)}},[l,f,p,n.sessionId]);const X=()=>{var b;f.sendPrompt(),p.dictatedFinalRef.current="",(b=g.terminalRef.current)==null||b.focus()},Z=()=>{const b=e.cwd.trim();b&&w.registerDirUsage(b,1),n.sendWs({type:"start_session",provider:e.provider,cwd:b||void 0})},ee=()=>{n.sessionId&&n.sendWs({type:"stop_session",sessionId:n.sessionId})};return t.jsxs("main",{className:j("mx-auto grid min-h-screen max-w-6xl grid-rows-[auto_auto_auto_1fr] gap-4 p-4 sm:gap-5 sm:p-6"),children:[m&&t.jsx(o.Suspense,{fallback:null,children:t.jsx(pt,{open:m,onOpenChange:a,onSaved:B})}),t.jsx(ct,{onSettingsClick:()=>a(!0),toggleTheme:e.toggleTheme,darkMode:e.darkMode,connectionBadge:D,stepState:k,sessionId:n.sessionId,status:n.status,configError:c,children:t.jsx(ut,{providers:r,provider:e.provider,setProvider:e.setProvider,cwd:e.cwd,hasFolder:P,openPicker:w.openPicker,canStartSession:v,sessionId:n.sessionId,startSession:Z,stopSession:ee,status:n.status,onSettingsClick:()=>a(!0),speechLang:e.speechLang,setSpeechLang:e.setSpeechLang,uiLanguage:e.uiLanguage,setUiLanguage:e.setUiLanguage,fontSize:e.fontSize,setFontSize:e.setFontSize,isListening:p.isListening})}),w.pickerOpen&&t.jsx(o.Suspense,{fallback:null,children:t.jsx(ft,{...w})}),t.jsx(mt,{sessionId:n.sessionId,promptDraft:f.promptDraft,setPromptDraft:f.setPromptDraft,sendPrompt:X,navigateHistory:f.navigateHistory,setPromptHistoryIndex:f.setPromptHistoryIndex,promptTextareaRef:f.promptTextareaRef,isListening:p.isListening,toggleVoice:Q,speechSupported:p.speechSupported,pushToTalkLabel:d}),!p.speechSupported&&t.jsx("p",{className:"rounded-xl border border-yellow-500/30 bg-yellow-500/10 px-4 py-3 text-base leading-relaxed text-yellow-500",children:s.app.speechUnsupported}),t.jsxs("section",{ref:h,tabIndex:-1,className:j("overflow-hidden rounded-xl border border-slate-800/80 bg-[#11161b] p-2 transition-colors focus:outline-none","min-h-[58vh]",n.sessionId&&"border-primary/30"),children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 border-b border-slate-700/60 px-2 py-2.5",children:[t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-red-500/70"}),t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-yellow-500/70"}),t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-green-500/70"})]}),t.jsx("span",{className:"flex-1 text-center font-mono text-sm text-slate-400",children:n.sessionId?`${A} - ${e.cwd}`:s.app.terminalIdleTitle})]}),t.jsx("div",{className:"h-[calc(100%-34px)] overflow-hidden",ref:g.containerRef})]})]})}function ht(){const e=Ze();return t.jsx(Ye,{language:e.uiLanguage,children:t.jsx(gt,{prefs:e})})}const xt=({...e})=>t.jsx(qe,{theme:"dark",className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e});ke.createRoot(document.getElementById("root")).render(t.jsxs(Pe.StrictMode,{children:[t.jsx(ht,{}),t.jsx(xt,{position:"bottom-right"})]}));export{_ as B,K as S,Ct as a,O as b,j as c,W as d,$ as e,H as f,yt as p,Nt as s,jt as t,z as u};
|