@openchamber/web 1.11.3 → 1.11.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.
Files changed (40) hide show
  1. package/dist/assets/{JsonTreeView-4KDa8lGo.js → JsonTreeView-YQcDxcEK.js} +1 -1
  2. package/dist/assets/MarkdownRendererImpl-h6uFn35l.js +6 -0
  3. package/dist/assets/{MultiRunWindow-BBmUkZot.js → MultiRunWindow-BXZBRXf8.js} +1 -1
  4. package/dist/assets/{OnboardingScreen-CmfCd-NF.js → OnboardingScreen-AGACaSpL.js} +2 -2
  5. package/dist/assets/{SettingsWindow-Cju1ws5b.js → SettingsWindow-DbIrbkwH.js} +1 -1
  6. package/dist/assets/TerminalView-ClACTVsY.js +1 -0
  7. package/dist/assets/{ToolOutputDialog-v9jBbw8P.js → ToolOutputDialog-C9M1QAxc.js} +1 -1
  8. package/dist/assets/{es-jann2TW8.js → es-nmO_Sy-z.js} +4 -4
  9. package/dist/assets/index-BWxr-Sly.css +1 -0
  10. package/dist/assets/{ko-BI4PbFHS.js → ko-DgzWO49N.js} +4 -4
  11. package/dist/assets/{main-d-4uuoz4.js → main-BG6I-VaN.js} +2 -2
  12. package/dist/assets/main-DLomPR7m.js +227 -0
  13. package/dist/assets/miniChat-ata1oHqJ.js +2 -0
  14. package/dist/assets/{modelPrefsAutoSave-bm-G98P3.js → modelPrefsAutoSave-D4IOtl1d.js} +97 -98
  15. package/dist/assets/{pl-eehxx-j8.js → pl-CdOdV9f8.js} +3 -3
  16. package/dist/assets/{pt-BR-D34YtT2a.js → pt-BR-gg2QcqbT.js} +5 -5
  17. package/dist/assets/renderElectronMiniChatApp-F0L1QF1k.js +2 -0
  18. package/dist/assets/{uk-Ce5zhj4w.js → uk-CrnDWkt0.js} +4 -4
  19. package/dist/assets/{vendor-.bun-CJSRTa27.js → vendor-.bun-BIr1wmDP.js} +2 -10
  20. package/dist/assets/{zh-CN-DOs9jvCa.js → zh-CN-CWGQwc9R.js} +5 -5
  21. package/dist/index.html +4 -4
  22. package/dist/mini-chat.html +4 -4
  23. package/package.json +1 -1
  24. package/server/lib/opencode/DOCUMENTATION.md +4 -0
  25. package/server/lib/opencode/config-entity-routes.js +115 -0
  26. package/server/lib/opencode/core-routes.js +1 -0
  27. package/server/lib/opencode/core-routes.test.js +17 -1
  28. package/server/lib/opencode/feature-routes-runtime.js +12 -0
  29. package/server/lib/opencode/index.js +9 -0
  30. package/server/lib/opencode/routes.js +14 -1
  31. package/server/lib/opencode/snippets.js +233 -0
  32. package/server/lib/opencode/snippets.test.js +68 -0
  33. package/server/lib/scheduled-tasks/runtime.js +4 -3
  34. package/dist/assets/MarkdownRendererImpl-ShCeV10r.js +0 -6
  35. package/dist/assets/TerminalView-K9P6-TDg.js +0 -1
  36. package/dist/assets/index-BG2LvnTV.css +0 -1
  37. package/dist/assets/main-BCXofLIN.js +0 -225
  38. package/dist/assets/miniChat-DCx1bzpk.js +0 -2
  39. package/dist/assets/renderElectronMiniChatApp-exfEAtnm.js +0 -2
  40. /package/dist/assets/{index-CQjRYgmJ.js → index-Dc1XJWqt.js} +0 -0
@@ -1,6 +0,0 @@
1
- import{R as S,c as V,by as We,bz as Ue,j as a,bA as He,bB as Ve,bC as qe,bD as Ze,bE as Ke,bF as Ge,am as Ye}from"./vendor-.bun-CJSRTa27.js";import{M as Se,bg as Ce,a as pe,u as le,bM as Re,c as L,b1 as Qe,b3 as xe,eQ as Je,eR as Ee,O as Xe,eS as et,I as U,eT as tt,b as be,v as se,w as Te}from"./modelPrefsAutoSave-bm-G98P3.js";import"./index-CQjRYgmJ.js";const ge=()=>{const t=V.c(4),e=Qe();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=xe(!1),t[0]=n):n=t[0];const s=n;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=xe(!0),t[1]=r):r=t[1];const o=r;let l;return t[2]!==e?.currentTheme?(l=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:s),t[2]=e?.currentTheme,t[3]=l):l=t[3],l},Me=t=>{const e=V.c(4),{containerRef:n,enabled:s}=t;let r,o;e[0]!==n||e[1]!==s?(r=()=>{if(s===!1)return;const l=n.current;if(!l)return;const d=Lt;return l.addEventListener("click",d),()=>{l.removeEventListener("click",d)}},o=[n,s],e[0]=n,e[1]=s,e[2]=r,e[3]=o):(r=e[2],o=e[3]),S.useEffect(r,o)},rt=t=>{const e=V.c(5),{href:n}=t,[s,r]=S.useState(!1);let o;e[0]!==n?(o=tt(n),e[0]=n,e[1]=o):o=e[1];const l=o;if(!l||s)return null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>r(!0),e[2]=d):d=e[2];let i;return e[3]!==l?(i=a.jsx("span",{className:"mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle",children:a.jsx("img",{src:l,alt:"","aria-hidden":"true",loading:"lazy",decoding:"async",className:"size-3.5 rounded-sm",onError:d})}),e[3]=l,e[4]=i):i=e[4],i},Ae=t=>{const e=[],n=[],s=t.querySelector("thead");s&&s.querySelectorAll("th").forEach(l=>e.push(l.innerText.trim()));const r=t.querySelector("tbody");return r&&r.querySelectorAll("tr").forEach(l=>{const d=l.querySelectorAll("td"),i=[];d.forEach(c=>i.push(c.innerText.trim())),n.push(i)}),{headers:e,rows:n}},Le=({headers:t,rows:e})=>{const n=r=>r.includes(",")||r.includes('"')||r.includes(`
2
- `)?`"${r.replace(/"/g,'""')}"`:r,s=[];return t.length>0&&s.push(t.map(n).join(",")),e.forEach(r=>s.push(r.map(n).join(","))),s.join(`
3
- `)},nt=({headers:t,rows:e})=>{const n=r=>r.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),s=[];return t.length>0&&s.push(t.map(n).join(" ")),e.forEach(r=>s.push(r.map(n).join(" "))),s.join(`
4
- `)},ot=({headers:t,rows:e})=>{if(t.length===0)return"";const n=r=>r.replace(/\\/g,"\\\\").replace(/\|/g,"\\|"),s=[];return s.push(`| ${t.map(n).join(" | ")} |`),s.push(`| ${t.map(()=>"---").join(" | ")} |`),e.forEach(r=>{const o=t.map((l,d)=>n(r[d]||""));s.push(`| ${o.join(" | ")} |`)}),s.join(`
5
- `)},st=(t,e,n)=>{const s=new Blob([e],{type:n}),r=URL.createObjectURL(s),o=document.createElement("a");o.href=r,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)},at=t=>{const e=V.c(20),{tableRef:n}=t,{t:s}=le(),[r,o]=S.useState(!1),[l,d]=S.useState(!1),i=S.useRef(null);let c,m;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{const h=g=>{i.current&&!i.current.contains(g.target)&&d(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},m=[],e[0]=c,e[1]=m):(c=e[0],m=e[1]),S.useEffect(c,m);let v;e[2]!==n?(v=async h=>{const g=n.current?.querySelector("table");if(!g)return;const T=Ae(g),A=h==="csv"?Le(T):nt(T);try{await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([A],{type:"text/plain"}),"text/html":new Blob([g.outerHTML],{type:"text/html"})})]),o(!0),d(!1),setTimeout(()=>o(!1),2e3)}catch(R){const E=R;if((await se(A)).ok){o(!0),d(!1),setTimeout(()=>o(!1),2e3);return}console.error("Failed to copy table:",E)}},e[2]=n,e[3]=v):v=e[3];const f=v;let p;e[4]!==l?(p=()=>d(!l),e[4]=l,e[5]=p):p=e[5];let x;e[6]!==s?(x=s("markdownRenderer.table.actions.copyTitle"),e[6]=s,e[7]=x):x=e[7];let u;e[8]!==r?(u=r?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[8]=r,e[9]=u):u=e[9];let w;e[10]!==p||e[11]!==x||e[12]!==u?(w=a.jsx("button",{onClick:p,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:x,children:u}),e[10]=p,e[11]=x,e[12]=u,e[13]=w):w=e[13];let k;e[14]!==f||e[15]!==l?(k=l&&a.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[100px] overflow-hidden rounded-md border border-border bg-background shadow-none",children:[a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>f("csv"),children:"CSV"}),a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>f("tsv"),children:"TSV"})]}),e[14]=f,e[15]=l,e[16]=k):k=e[16];let y;return e[17]!==w||e[18]!==k?(y=a.jsxs("div",{className:"relative",ref:i,children:[w,k]}),e[17]=w,e[18]=k,e[19]=y):y=e[19],y},lt=t=>{const e=V.c(19),{tableRef:n}=t,{t:s}=le(),[r,o]=S.useState(!1),l=S.useRef(null);let d,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const k=y=>{l.current&&!l.current.contains(y.target)&&o(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},i=[],e[0]=d,e[1]=i):(d=e[0],i=e[1]),S.useEffect(d,i);let c;e[2]!==s||e[3]!==n?(c=k=>{const y=n.current?.querySelector("table");if(!y)return;const h=Ae(y),g=k==="csv"?Le(h):ot(h);st(k==="csv"?"table.csv":"table.md",g,k==="csv"?"text/csv":"text/markdown"),o(!1),Te.success(s("markdownRenderer.table.toast.downloadedAsFormat",{format:k.toUpperCase()}))},e[2]=s,e[3]=n,e[4]=c):c=e[4];const m=c;let v;e[5]!==r?(v=()=>o(!r),e[5]=r,e[6]=v):v=e[6];let f;e[7]!==s?(f=s("markdownRenderer.table.actions.downloadTitle"),e[7]=s,e[8]=f):f=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(U,{name:"download",className:"size-3.5"}),e[9]=p):p=e[9];let x;e[10]!==v||e[11]!==f?(x=a.jsx("button",{onClick:v,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:f,children:p}),e[10]=v,e[11]=f,e[12]=x):x=e[12];let u;e[13]!==m||e[14]!==r?(u=r&&a.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[100px] overflow-hidden rounded-md border border-border bg-background shadow-none",children:[a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>m("csv"),children:"CSV"}),a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>m("markdown"),children:"Markdown"})]}),e[13]=m,e[14]=r,e[15]=u):u=e[15];let w;return e[16]!==x||e[17]!==u?(w=a.jsxs("div",{className:"relative",ref:l,children:[x,u]}),e[16]=x,e[17]=u,e[18]=w):w=e[18],w},it=t=>{const e=V.c(14),{children:n,className:s}=t,r=S.useRef(null),{isMobile:o,isTablet:l}=be(),i=o||l?"opacity-100":"opacity-0 group-hover:opacity-100";let c;e[0]!==i?(c=L("flex items-center justify-end gap-1 transition-opacity",i),e[0]=i,e[1]=c):c=e[1];let m,v;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(at,{tableRef:r}),v=a.jsx(lt,{tableRef:r}),e[2]=m,e[3]=v):(m=e[2],v=e[3]);let f;e[4]!==c?(f=a.jsxs("div",{className:c,children:[m,v]}),e[4]=c,e[5]=f):f=e[5];let p;e[6]!==s?(p=L("w-full border-collapse text-sm",s),e[6]=s,e[7]=p):p=e[7];let x;e[8]!==n||e[9]!==p?(x=a.jsx("div",{className:"overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]",children:a.jsx("table",{className:p,"data-markdown":"table",children:n})}),e[8]=n,e[9]=p,e[10]=x):x=e[10];let u;return e[11]!==f||e[12]!==x?(u=a.jsxs("div",{className:"group my-4 flex flex-col space-y-2","data-markdown":"table-wrapper",ref:r,children:[f,x]}),e[11]=f,e[12]=x,e[13]=u):u=e[13],u},ct=t=>{const e=V.c(83),{source:n,mode:s}=t,{t:r}=le(),o=ge(),{isMobile:l,isTablet:d}=be(),[i,c]=S.useState(!1),[m,v]=S.useState(!1);let f;e:{if(s!=="svg"){f="";break e}try{let b;e[0]!==o.colors.interactive.border||e[1]!==o.colors.primary.base||e[2]!==o.colors.surface.elevated||e[3]!==o.colors.surface.foreground||e[4]!==o.colors.surface.muted||e[5]!==o.colors.surface.mutedForeground||e[6]!==n?(b=Ke(n,{bg:o.colors.surface.elevated,fg:o.colors.surface.foreground,line:o.colors.interactive.border,accent:o.colors.primary.base,muted:o.colors.surface.mutedForeground,surface:o.colors.surface.muted,border:o.colors.interactive.border,transparent:!0,font:"IBM Plex Sans, sans-serif"}),e[0]=o.colors.interactive.border,e[1]=o.colors.primary.base,e[2]=o.colors.surface.elevated,e[3]=o.colors.surface.foreground,e[4]=o.colors.surface.muted,e[5]=o.colors.surface.mutedForeground,e[6]=n,e[7]=b):b=e[7],f=b}catch{f=""}}const p=f;let x;e:{if(s!=="ascii"){x="";break e}try{let b;e[8]!==n?(b=Ge(n),e[8]=n,e[9]=b):b=e[9],x=b}catch{x=""}}const u=x,w=l||d?"opacity-100":"opacity-0 group-hover:opacity-100";let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=async b=>{if(!b)return;(await se(b)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},e[10]=k):k=e[10];const y=k;let h;e[11]!==n?(h=async()=>{if(!n)return;(await se(n)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},e[11]=n,e[12]=h):h=e[12];const g=h;let T;e[13]!==p||e[14]!==r?(T=()=>{if(p)try{const b=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),j=URL.createObjectURL(b),N=document.createElement("a");N.href=j,N.download=`diagram-${Date.now()}.svg`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(j),v(!0),setTimeout(()=>v(!1),2e3)}catch{Te.error(r("markdownRenderer.mermaid.toast.downloadFailed"))}},e[13]=p,e[14]=r,e[15]=T):T=e[15];const A=T;if(s==="ascii"){const b=u||n;let j;e[16]!==b?(j=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("pre",{"data-markdown":"mermaid-ascii",children:b})}),e[16]=b,e[17]=j):j=e[17];let N;e[18]!==w?(N=L("absolute top-1 right-2 transition-opacity",w),e[18]=w,e[19]=N):N=e[19];let C;e[20]!==b?(C=()=>y(b),e[20]=b,e[21]=C):C=e[21];let M;e[22]!==r?(M=r("markdownRenderer.mermaid.actions.copyTitle"),e[22]=r,e[23]=M):M=e[23];let _;e[24]!==i?(_=i?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[24]=i,e[25]=_):_=e[25];let W;e[26]!==_||e[27]!==C||e[28]!==M?(W=a.jsx("button",{onClick:C,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:M,children:_}),e[26]=_,e[27]=C,e[28]=M,e[29]=W):W=e[29];let H;e[30]!==W||e[31]!==N?(H=a.jsx("div",{className:N,children:W}),e[30]=W,e[31]=N,e[32]=H):H=e[32];let Z;return e[33]!==H||e[34]!==j?(Z=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[j,H]}),e[33]=H,e[34]=j,e[35]=Z):Z=e[35],Z}if(!p){let b;e[36]!==n?(b=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("pre",{"data-markdown":"mermaid-ascii",children:n})}),e[36]=n,e[37]=b):b=e[37];let j;e[38]!==w?(j=L("absolute top-1 right-2 transition-opacity",w),e[38]=w,e[39]=j):j=e[39];let N;e[40]!==n?(N=()=>y(n),e[40]=n,e[41]=N):N=e[41];let C;e[42]!==r?(C=r("markdownRenderer.mermaid.actions.copyTitle"),e[42]=r,e[43]=C):C=e[43];let M;e[44]!==i?(M=i?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[44]=i,e[45]=M):M=e[45];let _;e[46]!==M||e[47]!==N||e[48]!==C?(_=a.jsx("button",{onClick:N,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:C,children:M}),e[46]=M,e[47]=N,e[48]=C,e[49]=_):_=e[49];let W;e[50]!==_||e[51]!==j?(W=a.jsx("div",{className:j,children:_}),e[50]=_,e[51]=j,e[52]=W):W=e[52];let H;return e[53]!==W||e[54]!==b?(H=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[b,W]}),e[53]=W,e[54]=b,e[55]=H):H=e[55],H}let R;e[56]!==p?(R=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("div",{"data-markdown":"mermaid",dangerouslySetInnerHTML:{__html:p}})}),e[56]=p,e[57]=R):R=e[57];let E;e[58]!==w?(E=L("absolute top-1 right-2 flex items-center gap-1 transition-opacity",w),e[58]=w,e[59]=E):E=e[59];let O;e[60]!==r?(O=r("markdownRenderer.mermaid.actions.copySourceTitle"),e[60]=r,e[61]=O):O=e[61];let F;e[62]!==i?(F=i?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[62]=i,e[63]=F):F=e[63];let P;e[64]!==g||e[65]!==O||e[66]!==F?(P=a.jsx("button",{onClick:g,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:O,children:F}),e[64]=g,e[65]=O,e[66]=F,e[67]=P):P=e[67];let I;e[68]!==r?(I=r("markdownRenderer.mermaid.actions.downloadSvgTitle"),e[68]=r,e[69]=I):I=e[69];let $;e[70]!==m?($=m?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"download",className:"size-3.5"}),e[70]=m,e[71]=$):$=e[71];let D;e[72]!==A||e[73]!==I||e[74]!==$?(D=a.jsx("button",{onClick:A,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:I,children:$}),e[72]=A,e[73]=I,e[74]=$,e[75]=D):D=e[75];let z;e[76]!==P||e[77]!==D||e[78]!==E?(z=a.jsxs("div",{className:E,children:[P,D]}),e[76]=P,e[77]=D,e[78]=E,e[79]=z):z=e[79];let B;return e[80]!==z||e[81]!==R?(B=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[R,z]}),e[80]=z,e[81]=R,e[82]=B):B=e[82],B},_e=t=>{if(!t.includes("mermaid"))return[];const e=[],n=/(?:^|\r?\n)(`{3,}|~{3,})mermaid[^\n\r]*\r?\n([\s\S]*?)\r?\n\1(?=\r?\n|$)/gi;let s=n.exec(t);for(;s;){const r=(s[2]??"").replace(/\s+$/,"");e.push(r),s=n.exec(t)}return e},dt=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},mt=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),ut=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const n=e[1];if(!n)return!1;const s=n[0],r=n.length,o=t.trimEnd().split(`
6
- `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${s}{${r},}[\\t ]*$`).test(o)},ke=t=>Ue(t,{linkMode:"text-only"}),ft=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)},re=(t,e,n,s)=>{const r=e.length>400?`${e.slice(0,200)}${e.slice(-200)}`:e;return`${t}:${n}:${s}:${e.length}:${ft(r)}`},ht=(t,e,n)=>{if(!e)return[{key:re(n,t,0,"full"),raw:t,src:t,mode:"full"}];const s=ke(t);if(mt(t))return[{key:re(n,t,0,"live"),raw:t,src:s,mode:"live"}];const r=We.lexer(t),o=[];let l=0;for(let d=0;d<r.length;d+=1){const i=r[d];if(i.type==="space")continue;const c=i.raw??"",m=d===r.length-1||r.slice(d+1).every(p=>p.type==="space"),v=m?"live":"full",f=m&&i.type==="code"&&ut(c)?c:ke(c);o.push({key:re(n,c,l,v),raw:c,src:f,mode:v}),l+=1}return o.length===0?[{key:re(n,t,0,"live"),raw:t,src:s,mode:"live"}]:o},Fe=(t,e,n)=>{const s=S.useRef([]);return S.useMemo(()=>{const r=ht(t,e,n),o=s.current,l=r.map((i,c)=>{const m=o[c];return m&&m.key===i.key&&m.src===i.src?m:i});return l.length===o.length&&l.every((i,c)=>i===o[c])?o:(s.current=l,l)},[n,e,t])},he=t=>typeof t=="string"?t:Array.isArray(t)?t.map(e=>he(e)).join(""):S.isValidElement(t)?he(t.props.children):"",pt=t=>t?.match(/language-([\w-]+)/)?.[1]?.toLowerCase()??"text",bt=t=>{let e=t;for(let n=0;n<3;n+=1){const s=e.replace(/&quot;/g,'"').replace(/&#34;/g,'"').replace(/&apos;/g,"'").replace(/&#39;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");if(s===e)return e;e=s}return e},gt=(t,e)=>!["json","jsonc","json5"].includes(e)||!/&(quot|#34|amp;quot|lt|gt|amp|apos|#39);/.test(t)?t:bt(t),vt=300,ne={margin:0,background:"transparent",padding:0,fontSize:"var(--text-code)",lineHeight:"var(--markdown-code-block-line-height)"},wt=(t,e,n)=>{if(!(typeof window>"u"))try{const s=new Blob([t],{type:n}),r=URL.createObjectURL(s),o=document.createElement("a");o.href=r,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}catch{}},xt=t=>{const e=V.c(49),{code:n,language:s,syntaxTheme:r}=t,[o,l]=S.useState(!1),[d,i]=S.useState(!0),[c,m]=S.useState("code"),v=S.useRef(n),f=S.useRef(null),{isMobile:p,isTablet:x}=be(),u=s==="html"||s==="htm";let w,k;e[0]!==u||e[1]!==c?(w=()=>{!u&&c!=="code"&&m("code")},k=[u,c],e[0]=u,e[1]=c,e[2]=w,e[3]=k):(w=e[2],k=e[3]),S.useEffect(w,k);let y,h;e[4]!==n?(y=()=>{if(v.current!==n)return v.current=n,f.current&&clearTimeout(f.current),i(!1),f.current=setTimeout(()=>{i(!0),f.current=null},vt),()=>{f.current&&(clearTimeout(f.current),f.current=null)}},h=[n],e[4]=n,e[5]=y,e[6]=h):(y=e[5],h=e[6]),S.useEffect(y,h);let g;e[7]!==n?(g=async()=>{(await se(n)).ok&&(l(!0),window.setTimeout(()=>l(!1),2e3))},e[7]=n,e[8]=g):g=e[8];const T=g;let A;e[9]!==u||e[10]!==n?(A=()=>{if(!u)return;const _=Date.now().toString(36);wt(n,`preview-${_}.html`,"text/html;charset=utf-8")},e[9]=u,e[10]=n,e[11]=A):A=e[11];const R=A;let E;e[12]!==s?(E=a.jsx("span",{className:"font-mono text-[13px] text-muted-foreground",children:s}),e[12]=s,e[13]=E):E=e[13];const O=p||x?"opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100";let F;e[14]!==O?(F=L("flex items-center gap-1 transition-opacity",O),e[14]=O,e[15]=F):F=e[15];let P;e[16]!==u||e[17]!==c?(P=u?a.jsx("button",{type:"button",onClick:()=>m(_t),className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:c==="preview"?"Show code":"Preview","aria-pressed":c==="preview","aria-label":c==="preview"?"Show code":"Preview HTML",children:c==="preview"?a.jsx(U,{name:"code",className:"size-3.5"}):a.jsx(U,{name:"eye",className:"size-3.5"})}):null,e[16]=u,e[17]=c,e[18]=P):P=e[18];let I;e[19]!==u||e[20]!==R?(I=u?a.jsx("button",{type:"button",onClick:R,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:"Download HTML","aria-label":"Download HTML",children:a.jsx(U,{name:"download",className:"size-3.5"})}):null,e[19]=u,e[20]=R,e[21]=I):I=e[21];let $;e[22]!==T?($=()=>{T()},e[22]=T,e[23]=$):$=e[23];const D=o?"Copied":"Copy code",z=o?"Copied":"Copy code";let B;e[24]!==o?(B=o?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[24]=o,e[25]=B):B=e[25];let b;e[26]!==$||e[27]!==D||e[28]!==z||e[29]!==B?(b=a.jsx("button",{type:"button",onClick:$,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:D,"aria-label":z,children:B}),e[26]=$,e[27]=D,e[28]=z,e[29]=B,e[30]=b):b=e[30];let j;e[31]!==P||e[32]!==I||e[33]!==b||e[34]!==F?(j=a.jsxs("div",{className:F,children:[P,I,b]}),e[31]=P,e[32]=I,e[33]=b,e[34]=F,e[35]=j):j=e[35];let N;e[36]!==j||e[37]!==E?(N=a.jsxs("div",{className:"flex items-center justify-between border-b border-border/70 px-3 py-1.5",children:[E,j]}),e[36]=j,e[37]=E,e[38]=N):N=e[38];let C;e[39]!==u||e[40]!==n||e[41]!==d||e[42]!==s||e[43]!==r||e[44]!==c?(C=u&&c==="preview"?a.jsx("div",{className:"h-[320px] md:h-[420px] bg-background",children:a.jsx("iframe",{srcDoc:n,title:"HTML preview",className:"h-full w-full border-0",sandbox:"allow-scripts allow-forms"})}):a.jsx("div",{className:"px-3 py-2.5",children:d?a.jsx(Ye,{language:s,style:r,customStyle:ne,codeTagProps:{style:ne},PreTag:"pre",children:n}):a.jsx("pre",{style:ne,children:a.jsx("code",{style:ne,children:n})})}),e[39]=u,e[40]=n,e[41]=d,e[42]=s,e[43]=r,e[44]=c,e[45]=C):C=e[45];let M;return e[46]!==N||e[47]!==C?(M=a.jsxs("div",{"data-component":"markdown-code",className:"my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]",children:[N,C]}),e[46]=N,e[47]=C,e[48]=M):M=e[48],M},$e=({syntaxTheme:t,onPreviewLoopback:e,previewLabel:n,previewTitle:s})=>({table({children:r,...o}){return a.jsx(it,{className:o.className,children:r})},h1({children:r,...o}){return a.jsx("h1",{...o,className:L("typography-markdown-h1 mt-4 mb-2 text-[var(--markdown-heading1,var(--primary))] font-semibold",o.className),children:r})},h2({children:r,...o}){return a.jsx("h2",{...o,className:L("typography-markdown-h2 mt-3.5 mb-1.5 text-[var(--markdown-heading2,var(--primary))] font-semibold",o.className),children:r})},h3({children:r,...o}){return a.jsx("h3",{...o,className:L("typography-markdown-h3 mt-3 mb-1 text-[var(--markdown-heading3,var(--primary))] font-semibold",o.className),children:r})},h4({children:r,...o}){return a.jsx("h4",{...o,className:L("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:r})},h5({children:r,...o}){return a.jsx("h5",{...o,className:L("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:r})},h6({children:r,...o}){return a.jsx("h6",{...o,className:L("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:r})},p({children:r,...o}){return a.jsx("p",{...o,className:L("typography-markdown-body my-2 text-foreground/90",o.className),children:r})},thead({children:r,...o}){return a.jsx("thead",{...o,className:L("[&_tr]:border-b [&_tr]:border-border/80",o.className),children:r})},tbody({children:r,...o}){return a.jsx("tbody",{...o,className:L("[&_tr:last-child]:border-0",o.className),children:r})},tr({children:r,...o}){return a.jsx("tr",{...o,className:L("border-b border-border/60",o.className),children:r})},th({children:r,...o}){return a.jsx("th",{...o,className:L("border-r border-border/60 px-4 py-2.5 text-left align-middle font-semibold text-foreground last:border-r-0",o.className),children:r})},td({children:r,...o}){return a.jsx("td",{...o,className:L("border-r border-border/60 px-4 py-2.5 align-middle text-foreground/90 last:border-r-0",o.className),children:r})},ul({children:r,...o}){return a.jsx("ul",{...o,className:L("typography-markdown-body my-2",o.className),children:r})},ol({children:r,...o}){return a.jsx("ol",{...o,className:L("typography-markdown-body my-2",o.className),children:r})},li({children:r,...o}){return a.jsx("li",{...o,className:L("typography-markdown-body my-0.5 text-foreground/90",o.className),children:r})},blockquote({children:r,...o}){return a.jsx("blockquote",{...o,className:L("my-3 border-l-2 border-[var(--markdown-blockquote-border,var(--border))] pl-4 typography-markdown-body text-[var(--markdown-blockquote,var(--muted-foreground))]",o.className),children:r})},pre({children:r,...o}){const l=S.Children.only(r),d=l.props.className,i=pt(d),c=gt(he(l.props.children).replace(/\n$/,""),i);return i==="mermaid"?a.jsx(ct,{source:c,mode:pe.getState().mermaidRenderingMode}):a.jsx(xt,{code:c,language:i,syntaxTheme:t,...o})},code({className:r,children:o,...l}){return a.jsx("code",{...l,className:L("rounded bg-[var(--surface-elevated)] px-1 py-0.5 font-mono text-[0.95em]",r),"data-markdown":"inline-code",children:o})},a({href:r,children:o,...l}){const d=r??"",i=Ee(d),c=e?et(d):!1;return a.jsxs(a.Fragment,{children:[a.jsxs("a",{...l,href:r,target:i?"_blank":void 0,rel:i?"noopener noreferrer":void 0,children:[i?a.jsx(rt,{href:d}):null,o]}),c&&e?a.jsxs("button",{type:"button",onClick:m=>{m.preventDefault(),m.stopPropagation(),e(d)},className:"ml-1 inline-flex h-5 items-center gap-0.5 rounded border border-[var(--border)] bg-[var(--surface-background)] px-1.5 align-middle text-[11px] leading-none text-[var(--muted-foreground)] transition-colors hover:bg-[var(--surface-hover)] hover:text-[var(--foreground)]","aria-label":s??n??"Open preview pane",title:s??n??"Open preview pane","data-loopback-preview-trigger":"true",children:[a.jsx(U,{name:"eye",className:"size-3","aria-hidden":"true"}),a.jsx("span",{className:"font-medium",children:n??"Preview"})]}):null]})}}),ve=S.memo(t=>{const e=V.c(5),{block:n,components:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[Ve,qe],e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=[[Ze,{throwOnError:!1,errorColor:"var(--destructive)"}]],e[1]=o):o=e[1];let l;return e[2]!==n.src||e[3]!==s?(l=a.jsx(He,{remarkPlugins:r,rehypePlugins:o,components:s,children:n.src}),e[2]=n.src,e[3]=s,e[4]=l):l=e[4],l},(t,e)=>t.block===e.block&&t.components===e.components);ve.displayName="MarkdownBlockView";const de='[data-markdown="mermaid-block"]',kt='[data-openchamber-file-link="true"]',yt=4,ye=new Map;let oe=0;const Ne=[],Nt=/^[A-Za-z]:[\\/]/,jt=/^\\\\[^\\]+\\[^\\]+/,Pe=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),je=Array.from(Pe).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),K=t=>{const e=(t||"").trim();if(!e)return"";const n=e.replace(/\\/g,"/"),s=n.startsWith("//");let r=n.replace(/\/+/g,"/");s&&!r.startsWith("//")&&(r=`/${r}`);const o=r==="/",l=/^[A-Za-z]:\/$/.test(r);return!o&&!l&&(r=r.replace(/\/+$/,"")),r},Ie=t=>t.startsWith("/")||Nt.test(t)||jt.test(t)||t.startsWith("//"),St=(t,e)=>{const n=K(e);if(!n)return K(t);if(Ie(n))return n;const s=K(t);if(!s)return n;const r=/^[A-Za-z]:/.test(s),o=r?s.slice(0,2):"",d=(r?s.slice(2):s).split("/").filter(Boolean),i=n.split("/").filter(Boolean);for(const c of i)if(c!=="."){if(c===".."){d.length>0&&d.pop();continue}d.push(c)}return r?`${o}/${d.join("/")}`:`/${d.join("/")}`},ae=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},me=t=>{let e=ae(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const s=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);s&&(e=s[1]??e);const r=je.length>0?e.match(new RegExp(`^(.*(?:/|^)(${je})):.*$`,"i")):null;return r&&(e=r[1]??e),ae(e)},ze=t=>{const e=ae(t);if(!e)return null;const n=e.indexOf(";"),s=n>=0?ae(e.slice(0,n)):e;if(!s)return null;const r=s.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(r){const d=me(r[1]??""),i=Number.parseInt(r[2]??"",10),c=r[3]?Number.parseInt(r[3],10):void 0;return!d||!Number.isFinite(i)?null:{path:d,line:i,column:Number.isFinite(c??Number.NaN)?c:void 0}}const o=s.match(/^(.*):(\d+)(?::(\d+))?$/);if(o){const d=me(o[1]??""),i=Number.parseInt(o[2]??"",10),c=o[3]?Number.parseInt(o[3],10):void 0;return!d||!Number.isFinite(i)?null:{path:d,line:i,column:Number.isFinite(c??Number.NaN)?c:void 0}}const l=me(s);return l?{path:l}:null},Ct=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},De=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=K(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const s=n.toLowerCase();return Pe.has(s)||s.startsWith(".")&&s.length>1?!0:Ct(e)},Rt=t=>{const e=ze(t);return e?De(e.path):!1},ue=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&Rt(e))return e}return(t.textContent||"").trim()},fe=(t,e)=>{const n=ze(t);if(!n||!De(n.path))return null;const s=Ie(n.path)?K(n.path):St(e,n.path);return s?{...n,resolvedPath:s}:null},Et=t=>{const e=K(t);if(!e)return Promise.resolve(!1);const n=ye.get(e);if(n)return n;const s=new Promise(r=>{const o=()=>{oe+=1,fetch(`/api/fs/stat?path=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store"}).then(l=>r(l.ok)).catch(()=>r(!1)).finally(()=>{oe=Math.max(0,oe-1),Ne.shift()?.()})};if(oe<yt){o();return}Ne.push(o)});return ye.set(e,s),s},Tt=(t,e)=>{const n=K(t);if(n)return n;const s=K(e);return s.replace(/\/[^/]*$/,"")||s},Be=t=>{const e=V.c(7),{containerRef:n,effectiveDirectory:s,editor:r,preferRuntimeEditor:o,enabled:l}=t,d=S.useRef(null);let i,c;e[0]!==n||e[1]!==r||e[2]!==s||e[3]!==l||e[4]!==o?(i=()=>{const m=n.current;if(!m)return;let v=!1;const f=Ft,p=()=>{const y=m.querySelectorAll('[data-markdown="inline-code"], a');for(const h of Array.from(y)){const g=ue(h),T=fe(g,s);f(h),!(!l||!T)&&Et(T.resolvedPath).then(A=>{if(v||!A||!m.contains(h))return;const R=ue(h),E=fe(R,s);!E||E.resolvedPath!==T.resolvedPath||(h.setAttribute("data-openchamber-file-link","true"),h.setAttribute("data-openchamber-file-ref",R),h.setAttribute("data-openchamber-file-path",E.resolvedPath),h.setAttribute("title","Open file"),h.tagName.toLowerCase()!=="a"&&(h.setAttribute("role","button"),h.setAttribute("tabindex","0")))})}},x=y=>{const h=y.getAttribute("data-openchamber-file-ref")||ue(y),g=fe(h,s);if(!g)return;const T=Tt(s,g.resolvedPath);if(o&&r){r.openFile(g.resolvedPath,Number.isFinite(g.line??Number.NaN)?Math.max(1,Math.trunc(g.line)):void 0,Number.isFinite(g.column??Number.NaN)?Math.max(1,Math.trunc(g.column)):void 0);return}const A=pe.getState();Number.isFinite(g.line??Number.NaN)?A.openContextFileAtLine(T,g.resolvedPath,Math.max(1,Math.trunc(g.line)),Number.isFinite(g.column??Number.NaN)?Math.max(1,Math.trunc(g.column)):1):A.openContextFile(T,g.resolvedPath)},u=y=>{const h=y.target;if(!(h instanceof Element))return;const g=h.closest(kt);g instanceof HTMLElement&&(y.preventDefault(),y.stopPropagation(),x(g))},w=y=>{if(y.key!=="Enter"&&y.key!==" ")return;const h=y.target;!(h instanceof HTMLElement)||h.getAttribute("data-openchamber-file-link")!=="true"||(y.preventDefault(),y.stopPropagation(),x(h))};p();const k=new MutationObserver(()=>{if(d.current!==null&&typeof window<"u"&&window.clearTimeout(d.current),typeof window>"u"){p();return}d.current=window.setTimeout(()=>{d.current=null,p()},120)});return k.observe(m,{childList:!0,subtree:!0}),m.addEventListener("click",u),m.addEventListener("keydown",w),()=>{v=!0,d.current!==null&&typeof window<"u"&&window.clearTimeout(d.current),d.current=null,k.disconnect(),m.removeEventListener("click",u),m.removeEventListener("keydown",w)}},c=[n,r,s,o,l],e[0]=n,e[1]=r,e[2]=s,e[3]=l,e[4]=o,e[5]=i,e[6]=c):(i=e[5],c=e[6]),S.useEffect(i,c)},Oe=t=>{const e=V.c(6),{containerRef:n,mermaidBlocks:s,onShowPopup:r,allowWheelZoom:o}=t;let l,d;e[0]!==o||e[1]!==n||e[2]!==s||e[3]!==r?(l=()=>{const i=n.current;if(!i)return;const c=v=>{if(!r)return;const f=v.target;if(!(f instanceof Element)||f.closest('button, a, [role="button"]'))return;const p=f.closest(de);if(!p)return;const u=Array.from(i.querySelectorAll(de)).indexOf(p);if(u<0)return;const w=s[u];if(!w||w.trim().length===0)return;const k=`Diagram ${u+1}`;r({open:!0,title:k,content:"",metadata:{tool:"mermaid-preview",filename:k},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(w)}`,source:w,filename:k}})},m=v=>{if(o)return;const f=v.target;!(f instanceof Element)||!f.closest(de)||v.stopPropagation()};return i.addEventListener("click",c),i.addEventListener("wheel",m,{capture:!0,passive:!0}),()=>{i.removeEventListener("click",c),i.removeEventListener("wheel",m,!0)}},d=[o,n,s,r],e[0]=o,e[1]=n,e[2]=s,e[3]=r,e[4]=l,e[5]=d):(l=e[4],d=e[5]),S.useEffect(l,d)},Mt=t=>{const e=V.c(42),{content:n,part:s,messageId:r,isAnimated:o,skipFadeIn:l,className:d,isStreaming:i,disableStreamAnimation:c,variant:m,onShowPopup:v,enableFileReferences:f}=t,p=o===void 0?!0:o,x=l===void 0?!1:l,u=i===void 0?!1:i,w=c===void 0?!1:c,k=m===void 0?"assistant":m,y=f===void 0?!0:f,h=ge(),{editor:g,runtime:T}=Se(),A=S.useRef(null),R=Ce()??"";let E;e[0]!==n?(E=_e(n),e[0]=n,e[1]=E):E=e[1];const O=E;let F;e[2]!==O||e[3]!==v?(F={containerRef:A,mermaidBlocks:O,onShowPopup:v},e[2]=O,e[3]=v,e[4]=F):F=e[4],Oe(F);const P=y&&!u;let I;e[5]!==g||e[6]!==R||e[7]!==T.isVSCode||e[8]!==P?(I={containerRef:A,effectiveDirectory:R,editor:g,preferRuntimeEditor:T.isVSCode,enabled:P},e[5]=g,e[6]=R,e[7]=T.isVSCode,e[8]=P,e[9]=I):I=e[9],Be(I);let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($={containerRef:A},e[10]=$):$=e[10],Me($);const D=pe($t),{t:z}=le();let B;e[11]!==R||e[12]!==D?(B=q=>{R&&D(R,q)},e[11]=R,e[12]=D,e[13]=B):B=e[13];const b=B;let j;e[14]!==z?(j=z("terminalView.preview.open"),e[14]=z,e[15]=j):j=e[15];const N=j;let C;e[16]!==z?(C=z("terminalView.preview.openTitle"),e[16]=z,e[17]=C):C=e[17];const M=C;let _;e[18]!==h?(_=Re(h),e[18]=h,e[19]=_):_=e[19];const W=_,H=R?b:void 0;let Z;e[20]!==N||e[21]!==M||e[22]!==W||e[23]!==H?(Z=$e({syntaxTheme:W,onPreviewLoopback:H,previewLabel:N,previewTitle:M}),e[20]=N,e[21]=M,e[22]=W,e[23]=H,e[24]=Z):Z=e[24];const J=Z,X=`markdown-${s?.id?`part-${s.id}`:`message-${r}`}`,ie=Fe(n,u&&!w,X),ce=k==="tool"?"markdown-content markdown-tool":k==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed";let G;e[25]!==d?(G=L("break-words w-full min-w-0",d),e[25]=d,e[26]=G):G=e[26];let Y;if(e[27]!==ie||e[28]!==J){let q;e[30]!==J?(q=we=>a.jsx(ve,{block:we,components:J},we.key),e[30]=J,e[31]=q):q=e[31],Y=ie.map(q),e[27]=ie,e[28]=J,e[29]=Y}else Y=e[29];let Q;e[32]!==ce||e[33]!==Y?(Q=a.jsx("div",{className:ce,children:Y}),e[32]=ce,e[33]=Y,e[34]=Q):Q=e[34];let ee;e[35]!==G||e[36]!==Q?(ee=a.jsx("div",{className:G,ref:A,children:Q}),e[35]=G,e[36]=Q,e[37]=ee):ee=e[37];const te=ee;if(p){let q;return e[38]!==X||e[39]!==te||e[40]!==x?(q=a.jsx(Je,{skipAnimation:x,children:te},X),e[38]=X,e[39]=te,e[40]=x,e[41]=q):q=e[41],q}return te},Dt=S.memo(Mt,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.part?.id===e.part?.id),At=t=>{const e=V.c(33),{content:n,className:s,variant:r,disableLinkSafety:o,stripFrontmatter:l,onShowPopup:d,allowMermaidWheelZoom:i,enableFileReferences:c}=t,m=r===void 0?"assistant":r,v=l===void 0?!1:l,f=i===void 0?!1:i,p=c===void 0?!0:c,{editor:x,runtime:u}=Se();let w;e[0]!==n||e[1]!==v?(w=v?dt(n):n,e[0]=n,e[1]=v,e[2]=w):w=e[2];const k=w,y=ge(),h=S.useRef(null),g=Ce()??"";let T;e[3]!==k?(T=_e(k),e[3]=k,e[4]=T):T=e[4];const A=T;let R;e[5]!==f||e[6]!==A||e[7]!==d?(R={containerRef:h,mermaidBlocks:A,onShowPopup:d,allowWheelZoom:f},e[5]=f,e[6]=A,e[7]=d,e[8]=R):R=e[8],Oe(R);let E;e[9]!==x||e[10]!==g||e[11]!==p||e[12]!==u.isVSCode?(E={containerRef:h,effectiveDirectory:g,editor:x,preferRuntimeEditor:u.isVSCode,enabled:p},e[9]=x,e[10]=g,e[11]=p,e[12]=u.isVSCode,e[13]=E):E=e[13],Be(E);const O=!o;let F;e[14]!==O?(F={containerRef:h,enabled:O},e[14]=O,e[15]=F):F=e[15],Me(F);let P;e[16]!==y?(P=Re(y),e[16]=y,e[17]=P):P=e[17];const I=P;let $;e[18]!==I?($=$e({syntaxTheme:I}),e[18]=I,e[19]=$):$=e[19];const D=$,z=Fe(k,!1,`simple:${m}`),B=m==="tool"?"markdown-content markdown-tool":m==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed";let b;e[20]!==s?(b=L("break-words w-full min-w-0",s),e[20]=s,e[21]=b):b=e[21];let j;if(e[22]!==z||e[23]!==D){let M;e[25]!==D?(M=_=>a.jsx(ve,{block:_,components:D},_.key),e[25]=D,e[26]=M):M=e[26],j=z.map(M),e[22]=z,e[23]=D,e[24]=j}else j=e[24];let N;e[27]!==B||e[28]!==j?(N=a.jsx("div",{className:B,children:j}),e[27]=B,e[28]=j,e[29]=N):N=e[29];let C;return e[30]!==b||e[31]!==N?(C=a.jsx("div",{className:b,ref:h,children:N}),e[30]=b,e[31]=N,e[32]=C):C=e[32],C},Bt=S.memo(At,(t,e)=>t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&t.allowMermaidWheelZoom===e.allowMermaidWheelZoom&&t.enableFileReferences===e.enableFileReferences);function Lt(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const n=e.closest("a[href]");if(!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true")return;const s=n.getAttribute("href")??"";Ee(s)&&(t.preventDefault(),t.stopPropagation(),Xe(s))}function _t(t){return t==="preview"?"code":"preview"}function Ft(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function $t(t){return t.openContextPreview}export{Dt as MarkdownRenderer,Bt as SimpleMarkdownRenderer};
@@ -1 +0,0 @@
1
- import{R as n,j as a,s as yt,bv as ht,bw as bt,bx as gt}from"./vendor-.bun-CJSRTa27.js";import{u as dt,v as xt,a$ as vt,c as Ue,M as Tt,bH as kt,eO as Ct,a as Ie,b as Et,V as ft,bg as Rt,I as ie,eP as et,cv as ct,at as Z}from"./modelPrefsAutoSave-bm-G98P3.js";import{u as J,P as At,S as St}from"./main-BCXofLIN.js";import{a4 as It}from"./index-CQjRYgmJ.js";import"./JsonTreeView-4KDa8lGo.js";function Mt(f){const{colors:p}=f,m=p.syntax.base;return{background:p.surface.background,foreground:m.foreground,cursor:p.interactive.cursor,cursorAccent:p.surface.background,selectionBackground:p.interactive.selection,selectionForeground:p.interactive.selectionForeground,selectionInactiveBackground:p.interactive.selection+"50",black:p.surface.muted,red:p.status.error,green:p.status.success,yellow:p.status.warning,blue:m.function,magenta:m.keyword,cyan:m.type,white:m.foreground,brightBlack:m.comment,brightRed:p.status.error,brightGreen:p.status.success,brightYellow:p.status.warning,brightBlue:m.function,brightMagenta:m.keyword,brightCyan:m.type,brightWhite:p.surface.elevatedForeground}}function Bt(f,p,m,ee,de=!1){const ye=`${f}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:p,lineHeight:1.15,fontFamily:ye,allowTransparency:!1,theme:{background:m.background,foreground:m.foreground,cursor:m.cursor,cursorAccent:m.cursorAccent,selectionBackground:m.selectionBackground,selectionForeground:m.selectionForeground,black:m.black,red:m.red,green:m.green,yellow:m.yellow,blue:m.blue,magenta:m.magenta,cyan:m.cyan,white:m.white,brightBlack:m.brightBlack,brightRed:m.brightRed,brightGreen:m.brightGreen,brightYellow:m.brightYellow,brightBlue:m.brightBlue,brightMagenta:m.brightMagenta,brightCyan:m.brightCyan,brightWhite:m.brightWhite},scrollback:1e4,ghostty:ee,disableStdin:de}}let lt=null;function Dt(){return lt||(lt=gt.load()),lt}function Nt(f){if(typeof window>"u")return null;const p=[f,...Array.from(f.querySelectorAll("*"))];let m=null;for(const ee of p){const Me=window.getComputedStyle(ee).overflowY;if(!(Me!=="auto"&&Me!=="scroll")){if(ee.scrollHeight-ee.clientHeight>2)return ee;m||(m=ee)}}return m}const pt=n.forwardRef(({sessionKey:f,chunks:p,onInput:m,onResize:ee,theme:de,fontFamily:Me,fontSize:ye,className:Be,enableTouchScroll:E,autoFocus:tt=!0,isVisible:je=!0},he)=>{const{t:F}=dt(),N=n.useRef(null),Fe=n.useRef(null),I=n.useRef(null),_e=n.useRef(null),P=n.useRef(m),ze=n.useRef(ee),h=n.useRef(null),be=n.useRef(""),te=n.useRef(null),Le=n.useRef(!1),Ke=n.useRef(null),pe=n.useRef(!0),ne=n.useRef(null),q=n.useRef(null),ge=n.useRef(0),re=n.useRef(null),qe=n.useRef(null),ce=n.useRef(!1),k=n.useRef(!1),R=n.useRef(null),me=n.useRef(null),Ye=n.useRef(null),j=n.useRef(""),Oe=n.useRef(null),xe=n.useRef(!E),$e=n.useRef(je),[,nt]=n.useReducer(e=>e+1,0),[We,O]=n.useReducer(e=>e+1,0);P.current=m,ze.current=ee;const at=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),y=!!E;n.useEffect(()=>{if(!E){xe.current=!0,$e.current=je;return}!$e.current&&je&&(xe.current=!1),$e.current=je},[E,je]);const ve=n.useCallback(()=>{if(!y)return;const e=N.current,o=re.current;if(!e)return;const s=[];e.getAttribute("contenteditable")==="true"&&s.push(e),s.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),s.forEach(r=>{r.setAttribute("data-terminal-disabled-contenteditable","true"),r.setAttribute("contenteditable","false"),r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.style.setProperty("caret-color","transparent"),r.style.color="transparent",r.style.setProperty("-webkit-text-fill-color","transparent"),r.style.background="transparent",r.style.outline="none",r.style.boxShadow="none",r.style.textShadow="none",r.style.setProperty("user-select","none"),r.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(r=>{r.style.setProperty("caret-color","transparent"),r.style.color="transparent",r.style.setProperty("-webkit-text-fill-color","transparent"),r.style.background="transparent",r.style.border="0",r.style.outline="none",r.style.boxShadow="none",r.style.textShadow="none",r.style.fontSize="0",r.style.lineHeight="0",r!==o&&r.getAttribute("data-terminal-disabled-input")!=="true"&&(r.setAttribute("data-terminal-disabled-input","true"),r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.disabled=!0,r.style.position="absolute",r.style.opacity="0",r.style.width="0px",r.style.height="0px",r.style.pointerEvents="none",r.style.zIndex="-1")})},[y]),A=n.useCallback(e=>{if(Oe.current===e)return;const o=I.current;if(o)try{if(typeof o.setOption=="function"){o.setOption("cursorBlink",e),Oe.current=e;return}o.options&&(o.options.cursorBlink=e,Oe.current=e)}catch{}},[]),M=y&&at,C=n.useCallback((e,o)=>{const s=M?qe.current:re.current,c=N.current;if(!s||!c)return;const r=c.getBoundingClientRect(),v=typeof window<"u"?window.innerWidth:r.width,S=typeof window<"u"?window.innerHeight:r.height,D=r.left+r.width/2,G=r.top+r.height-12,l=typeof e=="number"?e:D,T=typeof o=="number"?o:G,V=8,H=Math.max(V,Math.min(v-V,l)),K=Math.max(V,Math.min(S-V,T));s.style.left=`${H}px`,s.style.top=`${K}px`,s.style.bottom="",(s instanceof HTMLTextAreaElement||s instanceof HTMLInputElement)&&(s.disabled=!1,s.readOnly=!1,s.removeAttribute("disabled"),s.removeAttribute("readonly"));try{s.focus({preventScroll:!0})}catch{try{s.focus()}catch{}}},[M]),Te=n.useCallback(()=>{if(y){C(),A(!0);return}I.current?.focus(),A(!0)},[C,A,y]),le=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),W=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),He=n.useCallback(e=>{if(typeof window>"u"||M)return;Ye.current!==null&&(window.clearTimeout(Ye.current),Ye.current=null);let o=0;const s=3,c=()=>{Ye.current=window.setTimeout(()=>{Ye.current=null;const r=le(e);if(!r){if(o+=1,o<s){c();return}return}const v=j.current;j.current=r;const S=r.startsWith(v)?r.slice(v.length):r;S&&P.current(S.replace(/\r\n|\r|\n/g,"\r")),W(e),j.current=""},o===0?0:24)};c()},[W,le,M]);n.useEffect(()=>{const e=N.current;if(!y||!e||E)return;const o=s=>{const c=s.target;if(c&&c.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(c)){try{c.blur()}catch{}C()}};return e.addEventListener("focusin",o,!0),()=>{e.removeEventListener("focusin",o,!0)}},[E,y,C]);const De=n.useCallback(()=>{const e=I.current;if(!e||typeof e.getSelection!="function")return"";const o=e.getSelection();return typeof o=="string"?o:""},[]),ue=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const o=e.toString();if(!o.trim())return"";const s=N.current;if(!s)return"";const c=e.anchorNode,r=e.focusNode;return c&&!s.contains(c)||r&&!s.contains(r)?"":o},[]),ke=n.useCallback(async()=>{if(typeof document>"u")return;const e=De()||ue();e.trim()&&await xt(e)},[ue,De]),X=n.useCallback(()=>De().trim()?!0:!!ue().trim(),[ue,De]);n.useEffect(()=>{if(typeof window>"u")return;const e=o=>{X()&&(o.preventDefault(),ke())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ke,X]);const U=n.useCallback(()=>{be.current="",te.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(te.current),te.current=null,Le.current=!1,Ke.current=null},[]),L=n.useCallback(()=>{const e=_e.current,o=I.current,s=N.current;if(!e||!o||!s)return;const c=s.getBoundingClientRect();if(!(c.width<24||c.height<24))try{e.fit();const r={cols:o.cols,rows:o.rows},v=h.current;(!v||v.cols!==r.cols||v.rows!==r.rows)&&(h.current=r,ze.current(r.cols,r.rows))}catch{}},[]),Ne=n.useCallback(()=>{if(Le.current)return;const e=I.current;if(!e){U();return}if(!be.current)return;const o=be.current;be.current="",Le.current=!0,e.write(o,()=>{Le.current=!1,be.current&&(typeof window<"u"?te.current=window.requestAnimationFrame(()=>{te.current=null,Ne()}):Ne())})},[U]),Ge=n.useCallback(()=>{te.current===null&&(typeof window<"u"?te.current=window.requestAnimationFrame(()=>{te.current=null,Ne()}):Ne())},[Ne]),Xe=n.useCallback(e=>{e&&(be.current+=e,Ge())},[Ge]),Ce=n.useCallback(()=>{if(ne.current?.(),ne.current=null,q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),!E){ge.current=0;return}const e=N.current;if(!e)return;const o=I.current;if(!o)return;ge.current=0;const s=2.2,c=2.8,r=25,v=.25,S=8,D=.05,G=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},T=()=>typeof performance<"u"?performance.now():Date.now(),V=Math.max(12,Math.round(ye*1.35));let H=0;const K=t=>{if(!t)return!1;const u=o.getViewportY(),i=H+t,b=Math.trunc(i/V);return H=i-b*V,b!==0&&o.scrollLines(b),o.getViewportY()!==u},Y=()=>{l.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(l.rafId),l.rafId=null},x={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),u=6,i=d=>{if(d.pointerType==="touch"){Y(),t.pointerId=d.pointerId,t.startX=d.clientX,t.startY=d.clientY,t.moved=!1,t.lastY=d.clientY,t.lastTime=T(),t.velocity=0;try{e.setPointerCapture(d.pointerId)}catch{}}},b=d=>{if(d.pointerType!=="touch"||t.pointerId!==d.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){const mt=d.clientX-t.startX,wt=d.clientY-t.startY;Math.hypot(mt,wt)>=u&&(t.moved=!0)}if(t.lastY===null){t.lastY=d.clientY,t.lastTime=T();return}const _=t.lastY,oe=t.lastTime??T(),$=T();t.lastY=d.clientY,t.lastTime=$;const ae=_-d.clientY;if(Math.abs(ae)<1)return;const Se=Math.max($-oe,8),se=s+Math.min(c,Math.abs(ae)/r),Pe=ae*se,Je=Pe/Se;t.velocity=t.velocity*(1-v)+Je*v,t.velocity>S?t.velocity=S:t.velocity<-S&&(t.velocity=-S),t.moved&&(d.cancelable&&d.preventDefault(),d.stopPropagation()),K(Pe)},w=d=>{if(d.pointerType!=="touch"||t.pointerId!==d.pointerId)return;const _=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(d.pointerId)}catch{}if(_){y?C(d.clientX,d.clientY):E&&!xe.current&&(xe.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(t.velocity)<D){t.velocity=0;return}let oe=T();const $=()=>{const ae=T(),Se=Math.max(ae-oe,8);oe=ae;const se=K(t.velocity*Se)??!1,Pe=Math.sign(t.velocity),Je=Math.max(0,Math.abs(t.velocity)-G*Se);if(t.velocity=Je*Pe,!se||Je<=D){Y(),t.velocity=0;return}t.rafId=window.requestAnimationFrame($)};t.rafId=window.requestAnimationFrame($)};e.addEventListener("pointerdown",i,x),e.addEventListener("pointermove",b,x),e.addEventListener("pointerup",w,x),e.addEventListener("pointercancel",w,x);const g=e.style.touchAction;e.style.touchAction="manipulation",ne.current=()=>{Y(),q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),ge.current=0,e.removeEventListener("pointerdown",i,x),e.removeEventListener("pointermove",b,x),e.removeEventListener("pointerup",w,x),e.removeEventListener("pointercancel",w,x),e.style.touchAction=g};return}const Re=6,z=t=>{t.touches.length===1&&(Y(),l.lastY=t.touches[0].clientY,l.lastTime=T(),l.velocity=0,l.startX=t.touches[0].clientX,l.startY=t.touches[0].clientY,l.didMove=!1)},Ve=t=>{if(t.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,Y();return}const u=t.touches[0].clientX,i=t.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){const Se=u-l.startX,se=i-l.startY;Math.hypot(Se,se)>=Re&&(l.didMove=!0)}if(l.lastY===null){l.lastY=i,l.lastTime=T();return}const b=l.lastY,w=l.lastTime??T(),g=T();l.lastY=i,l.lastTime=g;const d=b-i;if(Math.abs(d)<1)return;const _=Math.max(g-w,8),oe=s+Math.min(c,Math.abs(d)/r),$=d*oe,ae=$/_;l.velocity=l.velocity*(1-v)+ae*v,l.velocity>S?l.velocity=S:l.velocity<-S&&(l.velocity=-S),l.didMove&&(t.preventDefault(),t.stopPropagation()),K($)},Ae=t=>{const u=!l.didMove;l.lastY=null,l.lastTime=null;const i=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,u){const g=t.changedTouches?.[0];y?C(g?.clientX,g?.clientY):E&&!xe.current&&(xe.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(i)<D){l.velocity=0;return}let b=T();const w=()=>{const g=T(),d=Math.max(g-b,8);b=g;const _=K(l.velocity*d)??!1,oe=Math.sign(l.velocity),$=Math.max(0,Math.abs(l.velocity)-G*d);if(l.velocity=$*oe,!_||$<=D){Y(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(w)};l.rafId=window.requestAnimationFrame(w)};e.addEventListener("touchstart",z,x),e.addEventListener("touchmove",Ve,x),e.addEventListener("touchend",Ae,x),e.addEventListener("touchcancel",Ae,x);const Q=e.style.touchAction;e.style.touchAction="manipulation",ne.current=()=>{Y(),q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),ge.current=0,e.removeEventListener("touchstart",z,x),e.removeEventListener("touchmove",Ve,x),e.removeEventListener("touchend",Ae,x),e.removeEventListener("touchcancel",Ae,x),e.style.touchAction=Q}},[E,y,C,ye]);n.useEffect(()=>{let e=!1,o=null,s=null,c=null,r=[],v=null,S=null;const D=N.current;if(!D)return;if(D.tabIndex=y?-1:0,y){const Y=D.focus.bind(D),x=D;x.focus=((...B)=>{C()}),S=()=>{x.focus=Y}}const G=()=>{A(!0)},l=()=>{A(!1)},T=Y=>{const x=Y.target;if(x&&D.contains(x)){if(y&&x instanceof HTMLElement){window.setTimeout(()=>{x.blur(),C()},0),A(!1);return}if(E&&!xe.current&&x instanceof HTMLElement){window.setTimeout(()=>{x.blur()},0),A(!1);return}A(!0);return}A(!1)},V=()=>{A(!1)};let H=null;return(async()=>{try{const Y=await Dt();if(e)return;const x=Bt(Me,ye,de,Y,!1),B=new ht(x);pe.current=!0,y&&(B.focus=()=>{});const Re=B;if(typeof Re.scrollToBottom=="function"){const Q=Re.scrollToBottom.bind(Re);Re.scrollToBottom=()=>{pe.current&&Q()},v=()=>{Re.scrollToBottom=Q}}const z=new bt;o=B,I.current=B,_e.current=z,B.loadAddon(z),B.open(D),O(),Oe.current=!1,H=B.textarea??D.querySelector("textarea"),H&&(H.addEventListener("focus",G),H.addEventListener("blur",l)),ve(),typeof MutationObserver<"u"&&(c=new MutationObserver(()=>{ve()}),c.observe(D,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const Ve=Nt(D);Ve?(Ve.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),Fe.current=Ve,nt()):Fe.current=null,L();const Ae=z;typeof Ae.observeResize=="function"&&Ae.observeResize(),Ce(),r=[B.onData(Q=>{P.current(Q)}),B.onScroll(Q=>{if(typeof Q=="number"&&Number.isFinite(Q)){const t=typeof B.hasSelection=="function"&&B.hasSelection();pe.current=!t&&Q<=.5}}),B.onSelectionChange(()=>{if(typeof B.hasSelection=="function"&&B.hasSelection()){pe.current=!1;return}const t=typeof B.getViewportY=="function"?B.getViewportY():0;pe.current=t<=.5})],s=new ResizeObserver(()=>{L()}),s.observe(D),typeof window<"u"&&window.setTimeout(()=>{L()},0)}catch{}})(),document.addEventListener("focusin",T,!0),window.addEventListener("blur",V),()=>{e=!0,ne.current?.(),ne.current=null,document.removeEventListener("focusin",T,!0),window.removeEventListener("blur",V),r.forEach(Y=>Y.dispose()),v?.(),v=null,H&&(H.removeEventListener("focus",G),H.removeEventListener("blur",l)),s?.disconnect(),c?.disconnect(),S?.(),o?.dispose(),I.current=null,_e.current=null,Fe.current=null,h.current=null,Oe.current=null,U()}},[ve,E,L,C,Me,ye,Ce,de,U,A,y]),n.useEffect(()=>{const e=I.current;e&&(e.reset(),U(),h.current=null,L())},[f,We,L,U]),n.useEffect(()=>{!tt||!I.current||Te()},[tt,Te,f,We]),n.useEffect(()=>(Ce(),()=>{ne.current?.(),ne.current=null}),[Ce,f]),n.useEffect(()=>{const e=I.current;if(!e)return;if(p.length===0){Ke.current!==null&&(e.reset(),U(),L());return}const o=Ke.current;let s;if(o===null)s=p;else{const c=p.findIndex(r=>r.id===o);s=c>=0?p.slice(c+1):p}s.length>0&&Xe(s.map(c=>c.data).join("")),Ke.current=p[p.length-1].id},[p,We,Xe,L,U]),n.useImperativeHandle(he,()=>({focus:()=>{Te()},clear:()=>{const e=I.current;e&&(e.reset(),U(),L())},fit:()=>{L()}}),[Te,L,U]);const Qe=n.useCallback(e=>{if(!y)return;const o=N.current,s=e.relatedTarget,c=s?.tagName,r=c==="INPUT"||c==="TEXTAREA"||s?.isContentEditable,v=s?.getAttribute("data-terminal-hidden-input")==="true",S=!!(s&&o?.contains(s))},[y]),we=n.useCallback(e=>{const o=e.nativeEvent,s=o?.inputType??"",c=typeof o?.data=="string"?o.data:"";if(me.current=typeof performance<"u"?performance.now():Date.now(),s==="insertCompositionText"){ce.current=!0;return}if(!s&&c){if(ce.current)return;e.preventDefault(),P.current(c),R.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="insertText"&&c){if(ce.current)return;e.preventDefault(),P.current(c),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="insertLineBreak"){if(ce.current)return;e.preventDefault(),P.current("\r"),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="deleteContentBackward"){if(ce.current)return;e.preventDefault(),P.current(""),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0}},[]),fe=n.useCallback(e=>{const o=e.currentTarget;if(me.current=typeof performance<"u"?performance.now():Date.now(),ce.current)return;if(k.current){const r=R.current,v=typeof performance<"u"?performance.now():Date.now();if(r&&v-r.at<50){k.current=!1,W(o);return}k.current=!1}const s=le(o);if(!s)return;j.current=s;const c=s.replace(/\r\n|\r|\n/g,"\r");P.current(c),W(o),j.current=""},[W,le]),rt=n.useCallback(e=>{e.stopPropagation();const o=e.key.toLowerCase(),s=e.metaKey&&!e.ctrlKey&&!e.altKey&&o==="c",c=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&o==="c";if((s||c)&&X()){e.preventDefault(),ke();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const V=e.key.toUpperCase();if(V>="A"&&V<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),P.current(String.fromCharCode(V.charCodeAt(0)-64)),W(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),P.current("\x1B"+e.key),W(e.currentTarget);return}const v={ArrowUp:"\x1B[A",ArrowDown:"\x1B[B",ArrowRight:"\x1B[C",ArrowLeft:"\x1B[D",Escape:"\x1B",Tab:" ",Delete:"\x1B[3~",Home:"\x1B[H",End:"\x1B[F"}[e.key];if(v){e.preventDefault(),P.current(v),W(e.currentTarget);return}const S=e.currentTarget;if(e.nativeEvent?.isComposing)return;const G=R.current,l=typeof performance<"u"?performance.now():Date.now(),T=!!(G&&l-G.at<50);if(e.key==="Enter"){if(T&&G?.type==="insertLineBreak")return;e.preventDefault(),P.current("\r"),W(S);return}if(e.key==="Backspace"){if(e.preventDefault(),T&&G?.type==="deleteContentBackward")return;le(S)||P.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const V=me.current;V&&l-V<50||(e.preventDefault(),P.current(e.key),k.current=!0,R.current={type:"keydown-text",at:l})}He(S)},[W,ke,X,le,He]),Ee=n.useCallback(e=>{e.stopPropagation();const o=e.currentTarget;e.nativeEvent?.isComposing||He(o)},[He]),ot=n.useCallback(e=>{const o=e.currentTarget;ce.current=!1;const s=e.data||le(o);if(me.current=typeof performance<"u"?performance.now():Date.now(),!s)return;const c=s.replace(/\r\n|\r|\n/g,"\r");P.current(c),W(o),R.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},k.current=!0},[W,le]),st=n.useCallback(e=>{e.stopPropagation();const o=e.clipboardData?.getData("text")??"";if(!o)return;e.preventDefault();const c=I.current?.hasBracketedPaste?.()?`\x1B[200~${o}\x1B[201~`:o;P.current(c)},[]),Ze={position:"fixed",left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:"transparent",color:"transparent",WebkitTextFillColor:"transparent",caretColor:"transparent",textShadow:"none",WebkitAppearance:"none",appearance:"none",resize:"none",overflow:"hidden",whiteSpace:"nowrap",border:"0",padding:0,margin:0,outline:"none",outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:"none",WebkitUserSelect:"none",userSelect:"none"};return a.jsxs("div",{ref:N,className:Ue("relative h-full w-full terminal-viewport-container",Be),"data-hidden-input-overlay-active":y?"true":void 0,style:{backgroundColor:de.background},onTouchStart:e=>{if(!(!y||E)&&!X()){const o=e.touches?.[0];C(o?.clientX,o?.clientY)}},onClick:e=>{if(!E)if(y){if(X())return;C(e.clientX,e.clientY)}else I.current?.focus()},onMouseUp:()=>{!E&&X()&&ke()},onTouchEnd:()=>{!E&&X()&&ke()},children:[y&&typeof document<"u"?yt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:qe,type:"text",inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":F("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Ze,display:M?"block":"none"},onBlur:Qe,onBeforeInput:we,onCompositionStart:()=>{ce.current=!0},onInput:fe,onKeyDown:rt,onKeyUp:Ee,onCompositionEnd:ot,onPaste:st}),a.jsx("textarea",{ref:re,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":F("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Ze,display:M?"none":"block"},onBlur:Qe,onBeforeInput:we,onCompositionStart:()=>{ce.current=!0},onInput:fe,onKeyDown:rt,onKeyUp:Ee,onCompositionEnd:ot,onPaste:st})]}),document.body):null,Fe.current&&!E?a.jsx(vt,{containerRef:Fe,disableHorizontal:!0,className:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero"}):null]})});pt.displayName="TerminalViewport";const Vt={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},it={ctrl:"5",cmd:"3"},ut={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},Pt={retry:{...ut.retry,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},jt=(f,p)=>{if(p)switch(f){case"arrow-up":return`\x1B[1;${it[p]}A`;case"arrow-down":return`\x1B[1;${it[p]}B`;case"arrow-right":return`\x1B[1;${it[p]}C`;case"arrow-left":return`\x1B[1;${it[p]}D`}return Vt[f]??null},Ht=()=>{const{t:f}=dt(),{terminal:p,runtime:m}=Tt(),{currentTheme:ee}=kt(),{monoFont:de}=Ct(),Me=Ie(t=>t.terminalFontSize),ye=Ie(t=>t.bottomTerminalHeight),Be=Ie(t=>t.isBottomTerminalExpanded),{isMobile:E,isTablet:tt,hasTouchOnlyPointer:je}=Et(),he=E||tt,F=(he||je)&&m.platform==="web",N=m.platform!=="vscode",Fe=Ie(t=>t.showTerminalQuickKeysOnDesktop),I=he||Fe,_e=ft(t=>t.currentSessionId),P=ft(t=>t.newSessionDraft),ze=_e!==null||P?.open===!0,h=Rt()??null,be=J(t=>t.sessions),te=J(t=>t.hasHydrated),Le=J(t=>t.ensureDirectory),Ke=J(t=>t.createTab),pe=J(t=>t.setActiveTab),ne=J(t=>t.closeTab),q=J(t=>t.setTabSessionId),ge=J(t=>t.setTabLifecycle),re=J(t=>t.setConnecting),qe=J(t=>t.appendToBuffer),ce=Ie(t=>t.openContextPreview),k=n.useMemo(()=>{if(h)return be.get(h)},[be,h]),R=n.useMemo(()=>k?N?k.activeTabId??k.tabs[0]?.id??null:k.tabs[0]?.id??null:null,[k,N]),me=n.useMemo(()=>{if(k)return R?k.tabs.find(t=>t.id===R)??k.tabs[0]:k.tabs[0]},[k,R]),Ye=n.useMemo(()=>(k?.tabs??[]).map(t=>({icon:(()=>{const u=t.iconKey?At[t.iconKey]??"terminal":"terminal";return a.jsx(ie,{name:u,className:"h-4 w-4"})})(),id:t.id,label:t.label,title:t.label,closeLabel:f("terminalView.tabs.closeTabTitle")})),[k?.tabs,f]),j=me?.terminalSessionId??null,Oe=me?.lifecycle??"idle",xe=me?.bufferChunks??[],$e=me?.isConnecting??!1,nt=me?.previewUrl??null,[We,O]=n.useState(null),[at,y]=n.useState(!1),[ve,A]=n.useState(!1),[M,C]=n.useState(null),[Te,le]=n.useState(!1),[W,He]=n.useState(0),De=n.useRef(null),ue=n.useRef(null),ke=n.useRef(R),X=n.useRef(j),U=n.useRef(h),L=n.useRef(null),Ne=n.useRef(null),Ge=n.useRef(!1),Xe=n.useRef(null),Ce=n.useRef(new Set),Qe=n.useRef(!1),we=n.useCallback(()=>{F||typeof document<"u"&&!document.hasFocus()||L.current?.focus()},[F]),fe=n.useCallback(()=>{F||L.current?.focus()},[F]);n.useEffect(()=>{if(!te||Qe.current)return;Qe.current=!0;const t=new Set;for(const[,u]of J.getState().sessions.entries())for(const i of u.tabs)i.terminalSessionId&&t.add(i.terminalSessionId);Ce.current=t},[te]);const rt=Ie(t=>t.activeMainTab),Ee=Ie(t=>t.isBottomTerminalOpen),ot=Ie(t=>t.setBottomTerminalOpen),st=Ie(t=>t.setBottomTerminalExpanded),Ze=rt==="terminal",e=Ze||Ee,[o,s]=n.useState(e);n.useEffect(()=>{!e||m.platform==="vscode"||It()},[e,m.platform]),n.useEffect(()=>{e&&s(!0)},[e]),n.useEffect(()=>{Ge.current=e},[e]),n.useEffect(()=>{X.current=j},[j]),n.useEffect(()=>{ke.current=R},[R]),n.useEffect(()=>{U.current=h},[h]),n.useEffect(()=>{!I&&M!==null&&C(null)},[I,M,C]),n.useEffect(()=>{!j&&M!==null&&C(null)},[j,M,C]);const c=n.useCallback(()=>{De.current?.(),De.current=null,ue.current=null,A(!1)},[]);n.useEffect(()=>()=>{c(),X.current=null},[c]);const r=n.useCallback((t,u,i,b=ut)=>{if(ue.current===i)return;c(),ue.current=i;const w=p.connect(i,{onEvent:g=>{if(ue.current===i)switch(g.type){case"connected":{re(t,u,!1),O(null),y(!1),A(!1),we(),Xe.current===i&&(Xe.current=null,p.sendInput(i,"\r").catch(()=>{}));break}case"reconnecting":{O(null),y(!1),A(!0);break}case"data":{g.data&&qe(t,u,g.data);break}case"exit":{const d=typeof g.exitCode=="number"?g.exitCode:null,_=typeof g.signal=="number"?g.signal:null,$=!!J.getState().getDirectoryState(t)?.tabs.find(ae=>ae.id===u)?.label?.startsWith("Action:");qe(t,u,f("terminalView.stream.processExitedMessage",{exitCodeSegment:d!==null?f("terminalView.stream.processExitedWithCode",{exitCode:d}):"",signalSegment:_!==null?f("terminalView.stream.processExitedWithSignal",{signal:_}):""})),ge(t,u,"exited"),q(t,u,null),re(t,u,!1),O($?null:f("terminalView.error.sessionEnded")),y(!1),A(!1),c();break}}},onError:(g,d)=>{if(ue.current===i){if(!d){O(null),y(!1);return}A(!1),O(f("terminalView.error.connectionFailed",{message:g.message})),y(!0),re(t,u,!1),ge(t,u,"exited"),q(t,u,null),c()}}},b);De.current=()=>{w.close(),ue.current=null}},[qe,c,we,re,ge,q,f,p]);n.useEffect(()=>{let t=!1;if(!te||!o)return;if(!h){O(f(ze?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),c();return}return(async()=>{const i=h;if(!U.current||U.current!==i)return;Le(i);const b=J.getState().getDirectoryState(i);if(!b||b.tabs.length===0)return;const w=N?b.activeTabId??b.tabs[0]?.id??null:b.tabs[0]?.id??null;if(!w)return;const g=b.tabs.find(se=>se.id===w)??b.tabs[0];let d=g?.terminalSessionId??null;const _=g?.lifecycle??"idle",oe=!!g?.label?.startsWith("Action:"),$=(g?.bufferLength??0)>0||(g?.bufferChunks?.length??0)>0,ae=!!d&&Ce.current.has(d)&&(g?.bufferLength??0)===0&&(g?.bufferChunks?.length??0)===0,Se=!!d&&Ce.current.has(d);if(!d){if(_==="exited"){re(i,w,!1);return}if(oe&&$){re(i,w,!1);return}O(null),y(!1),A(!1),re(i,w,!0);try{const se=Ne.current,Pe=await p.createSession({cwd:i,cols:se?.cols,rows:se?.rows});if(!(!t&&U.current===i&&ke.current===w)){try{await p.close(Pe.sessionId)}catch{}return}q(i,w,Pe.sessionId),d=Pe.sessionId}catch(se){t||(O(se instanceof Error?se.message:f("terminalView.error.startSessionFailed")),y(!0),A(!1),re(i,w,!1));return}}!d||t||(X.current=d,Se&&Ce.current.delete(d),ae&&(Xe.current=d),r(i,w,d,Se?Pt:ut))})(),()=>{t=!0,X.current=null,c()}},[ze,h,j,Oe,R,o,N,te,Le,re,ge,q,r,c,f,p]),n.useEffect(()=>{if(!e||F)return;if(typeof window>"u"){we();return}const t=window.requestAnimationFrame(()=>{we()});return()=>{window.cancelAnimationFrame(t)}},[R,we,e,F]);const v=n.useCallback(async()=>{if(!h||Te)return;const t=J.getState().getDirectoryState(h),u=N?R??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(u){le(!0),O(null),y(!1),A(!1),c();try{await ne(h,u)}catch(i){O(i instanceof Error?i.message:f("terminalView.error.restartFailed")),y(!0),A(!1)}finally{le(!1)}}},[R,ne,c,h,N,Te,f]),S=n.useCallback(async()=>{await v()},[v]),D=n.useCallback(()=>{if(!h)return;const t=Ke(h);pe(h,t),O(null),y(!1),A(!1),c()},[Ke,c,h,pe]),G=n.useCallback(t=>{h&&(pe(h,t),O(null),y(!1),A(!1),c())},[c,h,pe]),l=n.useCallback(t=>{h&&(t===R&&c(),O(null),y(!1),A(!1),ne(h,t))},[R,ne,c,h]),T=n.useCallback(t=>{if(!t||ve)return;let u=t,i=!1;if(M&&t.length>0){const w=t[0];if(w.length===1&&/[a-zA-Z]/.test(w)){const g=w.toUpperCase();(M==="ctrl"||M==="cmd")&&(u=String.fromCharCode(g.charCodeAt(0)&31),i=!0)}i||(i=!0)}const b=X.current;b&&(p.sendInput(b,u).catch(w=>{ve||O(w instanceof Error?w.message:f("terminalView.error.sendInputFailed"))}),i&&(C(null),fe()))},[M,fe,ve,C,f,p]),V=n.useCallback((t,u)=>{if(Ne.current={cols:t,rows:u},!Ge.current)return;const i=X.current;i&&p.resize({sessionId:i,cols:t,rows:u}).catch(()=>{})},[p]),H=n.useCallback(t=>{C(u=>u===t?null:t),fe()},[fe,C]),K=n.useCallback(t=>{const u=jt(t,M);u&&(T(u),C(null),fe())},[M,fe,T,C]);n.useEffect(()=>{if(!I||!M||!j)return;const t=u=>{if(u.repeat)return;const i=u.key;if(!i||i==="Control"||i==="Meta"||i==="Alt"||i==="Shift")return;const b=i.length===1?i.toLowerCase():i,w=u.code??"",g=w.startsWith("Key")&&w.length===4?w.slice(3).toUpperCase():null,d=i.length===1&&/[a-zA-Z]/.test(i)?i.toUpperCase():g,_={Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc",tab:"tab",enter:"enter",arrowup:"arrow-up",arrowdown:"arrow-down",arrowleft:"arrow-left",arrowright:"arrow-right",escape:"esc"};if(b in _){u.preventDefault(),u.stopPropagation(),K(_[b]);return}if(M==="ctrl"&&d&&d.length===1&&d>="A"&&d<="Z"){const oe=String.fromCharCode(d.charCodeAt(0)&31);u.preventDefault(),u.stopPropagation(),T(oe),C(null),fe()}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[M,K,T,fe,I,C,j]);const Y=n.useMemo(()=>{const t=et[ct].stack;if(typeof window>"u")return(et[de]??et[ct]).stack;const i=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return i&&i.trim().length>0?i.trim():(et[de]??et[ct]).stack??t},[de]),x=n.useMemo(()=>Mt(ee),[ee]),B=n.useMemo(()=>`${h??"no-dir"}::${R??"no-tab"}::${j??"no-terminal"}`,[h,R,j]),Re=n.useMemo(()=>`${B}::layout-${W}`,[B,W]);if(n.useEffect(()=>{if(F||!Ee||!e)return;if(typeof window>"u"){He(u=>u+1);return}const t=window.setTimeout(()=>{He(u=>u+1)},140);return()=>{window.clearTimeout(t)}},[ye,Be,Ee,e,F]),n.useEffect(()=>{if(!e||F)return;const t=L.current;if(!t)return;const u=()=>{t.fit()};if(typeof window<"u"){const i=window.requestAnimationFrame(()=>{u(),we()}),b=[220,400].map(w=>window.setTimeout(u,w));return()=>{window.cancelAnimationFrame(i),b.forEach(w=>window.clearTimeout(w))}}u()},[we,e,F,B,j]),n.useEffect(()=>{if(F||!e||!Ee)return;const t=L.current;if(!t)return;const u=()=>{t.fit()};if(typeof window<"u"){const i=window.requestAnimationFrame(()=>{u()}),b=[0,80,180,320].map(w=>window.setTimeout(u,w));return()=>{window.cancelAnimationFrame(i),b.forEach(w=>window.clearTimeout(w))}}u()},[ye,Be,Ee,e,F]),!ze)return a.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:f("terminalView.empty.selectSession")});if(!h)return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[a.jsx("p",{children:f("terminalView.empty.noWorkingDirectoryForSession")}),a.jsx("button",{onClick:v,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:f("terminalView.actions.retry")})]});const z=!j||$e||Te||ve,Ve=o,Ae=!he&&Ee&&!Ze,Q=a.jsxs(a.Fragment,{children:[a.jsx(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>K("esc"),disabled:z,children:f("terminalView.quickKeys.escape")}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("tab"),disabled:z,children:[a.jsx(ie,{name:"arrow-right",className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.tabAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"chip","aria-pressed":M==="ctrl",className:"h-6 w-9 p-0",onClick:()=>H("ctrl"),disabled:z,children:[a.jsx("span",{className:"text-xs font-medium",children:f("terminalView.quickKeys.controlLabel")}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.controlModifierAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"chip","aria-pressed":M==="cmd",className:"h-6 w-9 p-0",onClick:()=>H("cmd"),disabled:z,children:[a.jsx(ie,{name:"command"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.commandModifierAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-up"),disabled:z,children:[a.jsx(ie,{name:"arrow-up"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowUpAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-left"),disabled:z,children:[a.jsx(ie,{name:"arrow-left"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowLeftAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-down"),disabled:z,children:[a.jsx(ie,{name:"arrow-down"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowDownAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-right"),disabled:z,children:[a.jsx(ie,{name:"arrow-right"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowRightAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("enter"),disabled:z,children:[a.jsx(ie,{name:"arrow-go-back"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.enterAria")})]})]});return a.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[a.jsxs("div",{className:Ue("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",he?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[N&&k?a.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[a.jsx("div",{className:Ue("min-w-0 flex-1",he?"h-8":"h-7"),children:a.jsx(St,{items:Ye,activeId:R,onSelect:G,onClose:l,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),a.jsx(Z,{type:"button",size:"xs",variant:"ghost",className:Ue("shrink-0",he?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:D,title:f("terminalView.tabs.newTabTitle"),children:a.jsx(ie,{name:"add",className:`${he?"h-[18px] w-[18px]":"h-4 w-4"}`})}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[nt?a.jsxs(Z,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{h&&ce(h,nt)},title:f("terminalView.preview.openTitle"),children:[a.jsx(ie,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"whitespace-nowrap",children:f("terminalView.preview.open")})]}):null,Ae?a.jsxs(a.Fragment,{children:[a.jsx(Z,{type:"button",size:"xs",variant:"ghost",onClick:()=>st(!Be),className:Ue("shrink-0 p-0",E?"h-8 w-8":"h-7 w-7"),title:f(Be?"terminalView.bottomDock.restoreTitle":"terminalView.bottomDock.expandTitle"),"aria-label":f(Be?"terminalView.bottomDock.restoreAria":"terminalView.bottomDock.expandAria"),children:Be?a.jsx(ie,{name:"fullscreen-exit",className:"h-4 w-4"}):a.jsx(ie,{name:"fullscreen",className:"h-4 w-4"})}),a.jsx(Z,{type:"button",size:"xs",variant:"ghost",onClick:()=>ot(!1),className:Ue("shrink-0 p-0",E?"h-8 w-8":"h-7 w-7"),title:f("terminalView.bottomDock.closeTitle"),"aria-label":f("terminalView.bottomDock.closeAria"),children:a.jsx(ie,{name:"close",className:"h-4 w-4"})})]}):null]})]}):null,!E&&I&&N&&k?a.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:Q}):null,I&&(E||!N||!k)?a.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:Q}):null]}),a.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:x.background},children:[a.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:Ve?a.jsx(pt,{ref:t=>{L.current=t},sessionKey:Re,chunks:xe,onInput:T,onResize:V,theme:x,fontFamily:Y,fontSize:Me,enableTouchScroll:F,autoFocus:!F&&e,isVisible:e}):null}),!ve&&We&&a.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[a.jsx("span",{children:We}),at&&E&&a.jsx(Z,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:S,disabled:Te,title:f("terminalView.actions.hardRestartTitle"),type:"button",children:f("terminalView.actions.hardRestart")})]})]})]})};export{Ht as TerminalView};