@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 +1 @@
1
- import{R as s,j as e}from"./vendor-.bun-CJSRTa27.js";import{u as j,at as u,I as x,eU as b}from"./modelPrefsAutoSave-bm-G98P3.js";const N=s.memo(function({jsonString:t,className:l,maxHeight:i="100%",initiallyExpandedDepth:m=2}){const{t:r}=j(),n=s.useRef(null),[c,o]=s.useState(null),d=s.useMemo(()=>{try{const a=t.trim();if(!a)return o(r("jsonTreeView.error.emptyJson")),null;const f=JSON.parse(a);return o(null),f}catch(a){return o(a instanceof Error?a.message:r("jsonTreeView.error.invalidJson")),null}},[t,r]),p=s.useCallback(()=>{n.current?.expandAll()},[]),v=s.useCallback(()=>{n.current?.collapseAll()},[]);return c?e.jsx("div",{className:l,children:e.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4",children:[e.jsx("div",{className:"mb-1 font-medium text-[var(--surface-foreground)]",children:r("jsonTreeView.error.invalidJsonTitle")}),e.jsx("div",{className:"font-mono text-xs text-[var(--surface-mutedForeground)]",children:c})]})}):d===null?null:e.jsxs("div",{className:l,children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1",children:[e.jsxs(u,{variant:"ghost",size:"xs",onClick:p,className:"gap-1 text-xs text-muted-foreground",children:[e.jsx(x,{name:"arrow-down-s",className:"h-3 w-3"}),r("jsonTreeView.actions.expandAll")]}),e.jsxs(u,{variant:"ghost",size:"xs",onClick:v,className:"gap-1 text-xs text-muted-foreground",children:[e.jsx(x,{name:"arrow-up-s",className:"h-3 w-3"}),r("jsonTreeView.actions.collapseAll")]})]}),e.jsx("div",{className:"bg-[var(--syntax-base-background)] py-1",style:{maxHeight:i,overflow:"auto"},children:e.jsx(b,{ref:n,data:d,maxHeight:i,initiallyExpandedDepth:m})})]})});export{N as J};
1
+ import{R as s,j as e}from"./vendor-.bun-BIr1wmDP.js";import{u as j,as as u,I as x,eT as b}from"./modelPrefsAutoSave-D4IOtl1d.js";const T=s.memo(function({jsonString:t,className:l,maxHeight:i="100%",initiallyExpandedDepth:m=2}){const{t:r}=j(),n=s.useRef(null),[c,o]=s.useState(null),d=s.useMemo(()=>{try{const a=t.trim();if(!a)return o(r("jsonTreeView.error.emptyJson")),null;const f=JSON.parse(a);return o(null),f}catch(a){return o(a instanceof Error?a.message:r("jsonTreeView.error.invalidJson")),null}},[t,r]),p=s.useCallback(()=>{n.current?.expandAll()},[]),v=s.useCallback(()=>{n.current?.collapseAll()},[]);return c?e.jsx("div",{className:l,children:e.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4",children:[e.jsx("div",{className:"mb-1 font-medium text-[var(--surface-foreground)]",children:r("jsonTreeView.error.invalidJsonTitle")}),e.jsx("div",{className:"font-mono text-xs text-[var(--surface-mutedForeground)]",children:c})]})}):d===null?null:e.jsxs("div",{className:l,children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1",children:[e.jsxs(u,{variant:"ghost",size:"xs",onClick:p,className:"gap-1 text-xs text-muted-foreground",children:[e.jsx(x,{name:"arrow-down-s",className:"h-3 w-3"}),r("jsonTreeView.actions.expandAll")]}),e.jsxs(u,{variant:"ghost",size:"xs",onClick:v,className:"gap-1 text-xs text-muted-foreground",children:[e.jsx(x,{name:"arrow-up-s",className:"h-3 w-3"}),r("jsonTreeView.actions.collapseAll")]})]}),e.jsx("div",{className:"bg-[var(--syntax-base-background)] py-1",style:{maxHeight:i,overflow:"auto"},children:e.jsx(b,{ref:n,data:d,maxHeight:i,initiallyExpandedDepth:m})})]})});export{T as J};
@@ -0,0 +1,6 @@
1
+ import{R as j,c as V,bx as Ue,by as Ve,j as a,bz as qe,bA as Ze,bB as Ke,bC as Ge,bD as Xe,bE as Ye,am as Qe}from"./vendor-.bun-BIr1wmDP.js";import{M as Se,bh as Re,a as be,u as le,bN as Te,c as F,b2 as Je,b4 as ye,eP as et,eQ as Le,O as tt,i as ge,eR as rt,I as U,eS as nt,b as we,v as ae,w as _e}from"./modelPrefsAutoSave-D4IOtl1d.js";import"./index-Dc1XJWqt.js";const ve=()=>{const t=V.c(4),e=Je();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=ye(!1),t[0]=r):r=t[0];const s=r;let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=ye(!0),t[1]=n):n=t[1];const o=n;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:s),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},Me=t=>{const e=V.c(4),{containerRef:r,enabled:s}=t;let n,o;e[0]!==r||e[1]!==s?(n=()=>{if(s===!1)return;const i=r.current;if(!i)return;const l=Wt;return i.addEventListener("click",l),()=>{i.removeEventListener("click",l)}},o=[r,s],e[0]=r,e[1]=s,e[2]=n,e[3]=o):(n=e[2],o=e[3]),j.useEffect(n,o)},ot=t=>{const e=V.c(5),{href:r}=t,[s,n]=j.useState(!1);let o;e[0]!==r?(o=nt(r),e[0]=r,e[1]=o):o=e[1];const i=o;if(!i||s)return null;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>n(!0),e[2]=l):l=e[2];let c;return e[3]!==i?(c=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:i,alt:"","aria-hidden":"true",loading:"lazy",decoding:"async",className:"size-3.5 rounded-sm",onError:l})}),e[3]=i,e[4]=c):c=e[4],c},Ae=t=>{const e=[],r=[],s=t.querySelector("thead");s&&s.querySelectorAll("th").forEach(i=>e.push(i.innerText.trim()));const n=t.querySelector("tbody");return n&&n.querySelectorAll("tr").forEach(i=>{const l=i.querySelectorAll("td"),c=[];l.forEach(d=>c.push(d.innerText.trim())),r.push(c)}),{headers:e,rows:r}},Fe=({headers:t,rows:e})=>{const r=n=>n.includes(",")||n.includes('"')||n.includes(`
2
+ `)?`"${n.replace(/"/g,'""')}"`:n,s=[];return t.length>0&&s.push(t.map(r).join(",")),e.forEach(n=>s.push(n.map(r).join(","))),s.join(`
3
+ `)},st=({headers:t,rows:e})=>{const r=n=>n.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),s=[];return t.length>0&&s.push(t.map(r).join(" ")),e.forEach(n=>s.push(n.map(r).join(" "))),s.join(`
4
+ `)},at=({headers:t,rows:e})=>{if(t.length===0)return"";const r=n=>n.replace(/\\/g,"\\\\").replace(/\|/g,"\\|"),s=[];return s.push(`| ${t.map(r).join(" | ")} |`),s.push(`| ${t.map(()=>"---").join(" | ")} |`),e.forEach(n=>{const o=t.map((i,l)=>r(n[l]||""));s.push(`| ${o.join(" | ")} |`)}),s.join(`
5
+ `)},it=(t,e,r)=>{const s=new Blob([e],{type:r}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)},lt=t=>{const e=V.c(20),{tableRef:r}=t,{t:s}=le(),[n,o]=j.useState(!1),[i,l]=j.useState(!1),c=j.useRef(null);let d,m;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const T=w=>{c.current&&!c.current.contains(w.target)&&l(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},m=[],e[0]=d,e[1]=m):(d=e[0],m=e[1]),j.useEffect(d,m);let g;e[2]!==r?(g=async T=>{const w=r.current?.querySelector("table");if(!w)return;const y=Ae(w),f=T==="csv"?Fe(y):st(y);try{await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([f],{type:"text/plain"}),"text/html":new Blob([w.outerHTML],{type:"text/html"})})]),o(!0),l(!1),setTimeout(()=>o(!1),2e3)}catch(C){const S=C;if((await ae(f)).ok){o(!0),l(!1),setTimeout(()=>o(!1),2e3);return}console.error("Failed to copy table:",S)}},e[2]=r,e[3]=g):g=e[3];const h=g;let p;e[4]!==i?(p=()=>l(!i),e[4]=i,e[5]=p):p=e[5];let k;e[6]!==s?(k=s("markdownRenderer.table.actions.copyTitle"),e[6]=s,e[7]=k):k=e[7];let v;e[8]!==n?(v=n?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[8]=n,e[9]=v):v=e[9];let x;e[10]!==p||e[11]!==k||e[12]!==v?(x=a.jsx("button",{onClick:p,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:k,children:v}),e[10]=p,e[11]=k,e[12]=v,e[13]=x):x=e[13];let u;e[14]!==h||e[15]!==i?(u=i&&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:()=>h("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:()=>h("tsv"),children:"TSV"})]}),e[14]=h,e[15]=i,e[16]=u):u=e[16];let M;return e[17]!==x||e[18]!==u?(M=a.jsxs("div",{className:"relative",ref:c,children:[x,u]}),e[17]=x,e[18]=u,e[19]=M):M=e[19],M},ct=t=>{const e=V.c(19),{tableRef:r}=t,{t:s}=le(),[n,o]=j.useState(!1),i=j.useRef(null);let l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const u=M=>{i.current&&!i.current.contains(M.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),j.useEffect(l,c);let d;e[2]!==s||e[3]!==r?(d=u=>{const M=r.current?.querySelector("table");if(!M)return;const T=Ae(M),w=u==="csv"?Fe(T):at(T);it(u==="csv"?"table.csv":"table.md",w,u==="csv"?"text/csv":"text/markdown"),o(!1),_e.success(s("markdownRenderer.table.toast.downloadedAsFormat",{format:u.toUpperCase()}))},e[2]=s,e[3]=r,e[4]=d):d=e[4];const m=d;let g;e[5]!==n?(g=()=>o(!n),e[5]=n,e[6]=g):g=e[6];let h;e[7]!==s?(h=s("markdownRenderer.table.actions.downloadTitle"),e[7]=s,e[8]=h):h=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 k;e[10]!==g||e[11]!==h?(k=a.jsx("button",{onClick:g,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:h,children:p}),e[10]=g,e[11]=h,e[12]=k):k=e[12];let v;e[13]!==m||e[14]!==n?(v=n&&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]=n,e[15]=v):v=e[15];let x;return e[16]!==k||e[17]!==v?(x=a.jsxs("div",{className:"relative",ref:i,children:[k,v]}),e[16]=k,e[17]=v,e[18]=x):x=e[18],x},dt=t=>{const e=V.c(14),{children:r,className:s}=t,n=j.useRef(null),{isMobile:o,isTablet:i}=we(),c=o||i?"opacity-100":"opacity-0 group-hover:opacity-100";let d;e[0]!==c?(d=F("flex items-center justify-end gap-1 transition-opacity",c),e[0]=c,e[1]=d):d=e[1];let m,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(lt,{tableRef:n}),g=a.jsx(ct,{tableRef:n}),e[2]=m,e[3]=g):(m=e[2],g=e[3]);let h;e[4]!==d?(h=a.jsxs("div",{className:d,children:[m,g]}),e[4]=d,e[5]=h):h=e[5];let p;e[6]!==s?(p=F("w-full border-collapse text-sm",s),e[6]=s,e[7]=p):p=e[7];let k;e[8]!==r||e[9]!==p?(k=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:r})}),e[8]=r,e[9]=p,e[10]=k):k=e[10];let v;return e[11]!==h||e[12]!==k?(v=a.jsxs("div",{className:"group my-4 flex flex-col space-y-2","data-markdown":"table-wrapper",ref:n,children:[h,k]}),e[11]=h,e[12]=k,e[13]=v):v=e[13],v},mt=t=>{const e=V.c(83),{source:r,mode:s}=t,{t:n}=le(),o=ve(),{isMobile:i,isTablet:l}=we(),[c,d]=j.useState(!1),[m,g]=j.useState(!1);let h;e:{if(s!=="svg"){h="";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]!==r?(b=Xe(r,{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]=r,e[7]=b):b=e[7],h=b}catch{h=""}}const p=h;let k;e:{if(s!=="ascii"){k="";break e}try{let b;e[8]!==r?(b=Ye(r),e[8]=r,e[9]=b):b=e[9],k=b}catch{k=""}}const v=k,x=i||l?"opacity-100":"opacity-0 group-hover:opacity-100";let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=async b=>{if(!b)return;(await ae(b)).ok&&(d(!0),setTimeout(()=>d(!1),2e3))},e[10]=u):u=e[10];const M=u;let T;e[11]!==r?(T=async()=>{if(!r)return;(await ae(r)).ok&&(d(!0),setTimeout(()=>d(!1),2e3))},e[11]=r,e[12]=T):T=e[12];const w=T;let y;e[13]!==p||e[14]!==n?(y=()=>{if(p)try{const b=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),E=URL.createObjectURL(b),N=document.createElement("a");N.href=E,N.download=`diagram-${Date.now()}.svg`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(E),g(!0),setTimeout(()=>g(!1),2e3)}catch{_e.error(n("markdownRenderer.mermaid.toast.downloadFailed"))}},e[13]=p,e[14]=n,e[15]=y):y=e[15];const f=y;if(s==="ascii"){const b=v||r;let E;e[16]!==b?(E=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("pre",{"data-markdown":"mermaid-ascii",children:b})}),e[16]=b,e[17]=E):E=e[17];let N;e[18]!==x?(N=F("absolute top-1 right-2 transition-opacity",x),e[18]=x,e[19]=N):N=e[19];let R;e[20]!==b?(R=()=>M(b),e[20]=b,e[21]=R):R=e[21];let L;e[22]!==n?(L=n("markdownRenderer.mermaid.actions.copyTitle"),e[22]=n,e[23]=L):L=e[23];let _;e[24]!==c?(_=c?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[24]=c,e[25]=_):_=e[25];let O;e[26]!==_||e[27]!==R||e[28]!==L?(O=a.jsx("button",{onClick:R,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:L,children:_}),e[26]=_,e[27]=R,e[28]=L,e[29]=O):O=e[29];let H;e[30]!==O||e[31]!==N?(H=a.jsx("div",{className:N,children:O}),e[30]=O,e[31]=N,e[32]=H):H=e[32];let Z;return e[33]!==H||e[34]!==E?(Z=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[E,H]}),e[33]=H,e[34]=E,e[35]=Z):Z=e[35],Z}if(!p){let b;e[36]!==r?(b=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("pre",{"data-markdown":"mermaid-ascii",children:r})}),e[36]=r,e[37]=b):b=e[37];let E;e[38]!==x?(E=F("absolute top-1 right-2 transition-opacity",x),e[38]=x,e[39]=E):E=e[39];let N;e[40]!==r?(N=()=>M(r),e[40]=r,e[41]=N):N=e[41];let R;e[42]!==n?(R=n("markdownRenderer.mermaid.actions.copyTitle"),e[42]=n,e[43]=R):R=e[43];let L;e[44]!==c?(L=c?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[44]=c,e[45]=L):L=e[45];let _;e[46]!==L||e[47]!==N||e[48]!==R?(_=a.jsx("button",{onClick:N,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:R,children:L}),e[46]=L,e[47]=N,e[48]=R,e[49]=_):_=e[49];let O;e[50]!==_||e[51]!==E?(O=a.jsx("div",{className:E,children:_}),e[50]=_,e[51]=E,e[52]=O):O=e[52];let H;return e[53]!==O||e[54]!==b?(H=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[b,O]}),e[53]=O,e[54]=b,e[55]=H):H=e[55],H}let C;e[56]!==p?(C=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("div",{"data-markdown":"mermaid",dangerouslySetInnerHTML:{__html:p}})}),e[56]=p,e[57]=C):C=e[57];let S;e[58]!==x?(S=F("absolute top-1 right-2 flex items-center gap-1 transition-opacity",x),e[58]=x,e[59]=S):S=e[59];let B;e[60]!==n?(B=n("markdownRenderer.mermaid.actions.copySourceTitle"),e[60]=n,e[61]=B):B=e[61];let A;e[62]!==c?(A=c?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[62]=c,e[63]=A):A=e[63];let $;e[64]!==w||e[65]!==B||e[66]!==A?($=a.jsx("button",{onClick:w,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:B,children:A}),e[64]=w,e[65]=B,e[66]=A,e[67]=$):$=e[67];let z;e[68]!==n?(z=n("markdownRenderer.mermaid.actions.downloadSvgTitle"),e[68]=n,e[69]=z):z=e[69];let P;e[70]!==m?(P=m?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"download",className:"size-3.5"}),e[70]=m,e[71]=P):P=e[71];let D;e[72]!==f||e[73]!==z||e[74]!==P?(D=a.jsx("button",{onClick:f,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:z,children:P}),e[72]=f,e[73]=z,e[74]=P,e[75]=D):D=e[75];let I;e[76]!==$||e[77]!==D||e[78]!==S?(I=a.jsxs("div",{className:S,children:[$,D]}),e[76]=$,e[77]=D,e[78]=S,e[79]=I):I=e[79];let W;return e[80]!==I||e[81]!==C?(W=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[C,I]}),e[80]=I,e[81]=C,e[82]=W):W=e[82],W},Ie=t=>{if(!t.includes("mermaid"))return[];const e=[],r=/(?:^|\r?\n)(`{3,}|~{3,})mermaid[^\n\r]*\r?\n([\s\S]*?)\r?\n\1(?=\r?\n|$)/gi;let s=r.exec(t);for(;s;){const n=(s[2]??"").replace(/\s+$/,"");e.push(n),s=r.exec(t)}return e},ut=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},ft=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),ht=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const r=e[1];if(!r)return!1;const s=r[0],n=r.length,o=t.trimEnd().split(`
6
+ `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${s}{${n},}[\\t ]*$`).test(o)},Ne=t=>Ve(t,{linkMode:"text-only"}),pt=t=>{let e=2166136261;for(let r=0;r<t.length;r+=1)e^=t.charCodeAt(r),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)},ne=(t,e,r,s)=>{const n=e.length>400?`${e.slice(0,200)}${e.slice(-200)}`:e;return`${t}:${r}:${s}:${e.length}:${pt(n)}`},bt=(t,e,r)=>{if(!e)return[{key:ne(r,t,0,"full"),raw:t,src:t,mode:"full"}];const s=Ne(t);if(ft(t))return[{key:ne(r,t,0,"live"),raw:t,src:s,mode:"live"}];const n=Ue.lexer(t),o=[];let i=0;for(let l=0;l<n.length;l+=1){const c=n[l];if(c.type==="space")continue;const d=c.raw??"",m=l===n.length-1||n.slice(l+1).every(p=>p.type==="space"),g=m?"live":"full",h=m&&c.type==="code"&&ht(d)?d:Ne(d);o.push({key:ne(r,d,i,g),raw:d,src:h,mode:g}),i+=1}return o.length===0?[{key:ne(r,t,0,"live"),raw:t,src:s,mode:"live"}]:o},$e=(t,e,r)=>{const s=j.useRef([]);return j.useMemo(()=>{const n=bt(t,e,r),o=s.current,i=n.map((c,d)=>{const m=o[d];return m&&m.key===c.key&&m.src===c.src?m:c});return i.length===o.length&&i.every((c,d)=>c===o[d])?o:(s.current=i,i)},[r,e,t])},pe=t=>typeof t=="string"?t:Array.isArray(t)?t.map(e=>pe(e)).join(""):j.isValidElement(t)?pe(t.props.children):"",gt=t=>t?.match(/language-([\w-]+)/)?.[1]?.toLowerCase()??"text",wt=t=>{let e=t;for(let r=0;r<3;r+=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},vt=(t,e)=>!["json","jsonc","json5"].includes(e)||!/&(quot|#34|amp;quot|lt|gt|amp|apos|#39);/.test(t)?t:wt(t),xt=300,kt=1200,yt=200,oe={margin:0,background:"transparent",padding:0,fontSize:"var(--text-code)",lineHeight:"var(--markdown-code-block-line-height)"},Nt=(t,e)=>{let r=1;for(let s=0;s<t.length;s+=1)if(t.charCodeAt(s)===10&&(r+=1,r>e))return!0;return!1},Et=()=>ge()?yt:kt,Ct=(t,e,r)=>{if(!(typeof window>"u"))try{const s=new Blob([t],{type:r}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}catch{}},jt=t=>{const e=V.c(52),{code:r,language:s,syntaxTheme:n}=t,[o,i]=j.useState(!1),[l,c]=j.useState(!0),[d,m]=j.useState("code"),g=j.useRef(r),h=j.useRef(null),{isMobile:p,isTablet:k}=we();let v;e[0]!==r?(v=Nt(r,Et()),e[0]=r,e[1]=v):v=e[1];const x=v,u=s==="html"||s==="htm";let M,T;e[2]!==u||e[3]!==d?(M=()=>{!u&&d!=="code"&&m("code")},T=[u,d],e[2]=u,e[3]=d,e[4]=M,e[5]=T):(M=e[4],T=e[5]),j.useEffect(M,T);let w,y;e[6]!==r?(w=()=>{if(g.current!==r)return g.current=r,h.current&&clearTimeout(h.current),c(!1),h.current=setTimeout(()=>{c(!0),h.current=null},xt),()=>{h.current&&(clearTimeout(h.current),h.current=null)}},y=[r],e[6]=r,e[7]=w,e[8]=y):(w=e[7],y=e[8]),j.useEffect(w,y);let f;e[9]!==r?(f=async()=>{(await ae(r)).ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))},e[9]=r,e[10]=f):f=e[10];const C=f;let S;e[11]!==u||e[12]!==r?(S=()=>{if(!u)return;const H=Date.now().toString(36);Ct(r,`preview-${H}.html`,"text/html;charset=utf-8")},e[11]=u,e[12]=r,e[13]=S):S=e[13];const B=S;let A;e[14]!==s?(A=a.jsx("span",{className:"font-mono text-[13px] text-muted-foreground",children:s}),e[14]=s,e[15]=A):A=e[15];const $=p||k?"opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100";let z;e[16]!==$?(z=F("flex items-center gap-1 transition-opacity",$),e[16]=$,e[17]=z):z=e[17];let P;e[18]!==u||e[19]!==d?(P=u?a.jsx("button",{type:"button",onClick:()=>m(Ut),className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:d==="preview"?"Show code":"Preview","aria-pressed":d==="preview","aria-label":d==="preview"?"Show code":"Preview HTML",children:d==="preview"?a.jsx(U,{name:"code",className:"size-3.5"}):a.jsx(U,{name:"eye",className:"size-3.5"})}):null,e[18]=u,e[19]=d,e[20]=P):P=e[20];let D;e[21]!==u||e[22]!==B?(D=u?a.jsx("button",{type:"button",onClick:B,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[21]=u,e[22]=B,e[23]=D):D=e[23];let I;e[24]!==C?(I=()=>{C()},e[24]=C,e[25]=I):I=e[25];const W=o?"Copied":"Copy code",b=o?"Copied":"Copy code";let E;e[26]!==o?(E=o?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[26]=o,e[27]=E):E=e[27];let N;e[28]!==I||e[29]!==W||e[30]!==b||e[31]!==E?(N=a.jsx("button",{type:"button",onClick:I,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:W,"aria-label":b,children:E}),e[28]=I,e[29]=W,e[30]=b,e[31]=E,e[32]=N):N=e[32];let R;e[33]!==z||e[34]!==P||e[35]!==D||e[36]!==N?(R=a.jsxs("div",{className:z,children:[P,D,N]}),e[33]=z,e[34]=P,e[35]=D,e[36]=N,e[37]=R):R=e[37];let L;e[38]!==R||e[39]!==A?(L=a.jsxs("div",{className:"flex items-center justify-between border-b border-border/70 px-3 py-1.5",children:[A,R]}),e[38]=R,e[39]=A,e[40]=L):L=e[40];let _;e[41]!==u||e[42]!==r||e[43]!==l||e[44]!==s||e[45]!==x||e[46]!==n||e[47]!==d?(_=u&&d==="preview"?a.jsx("div",{className:"h-[320px] md:h-[420px] bg-background",children:a.jsx("iframe",{srcDoc:r,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:l&&!x?a.jsx(Qe,{language:s,style:n,customStyle:oe,codeTagProps:{style:oe},PreTag:"pre",children:r}):a.jsx("pre",{style:oe,children:a.jsx("code",{style:oe,children:r})})}),e[41]=u,e[42]=r,e[43]=l,e[44]=s,e[45]=x,e[46]=n,e[47]=d,e[48]=_):_=e[48];let O;return e[49]!==L||e[50]!==_?(O=a.jsxs("div",{"data-component":"markdown-code",className:"my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]",children:[L,_]}),e[49]=L,e[50]=_,e[51]=O):O=e[51],O},Pe=({syntaxTheme:t,onPreviewLoopback:e,previewLabel:r,previewTitle:s})=>({table({children:n,...o}){return a.jsx(dt,{className:o.className,children:n})},h1({children:n,...o}){return a.jsx("h1",{...o,className:F("typography-markdown-h1 mt-4 mb-2 text-[var(--markdown-heading1,var(--primary))] font-semibold",o.className),children:n})},h2({children:n,...o}){return a.jsx("h2",{...o,className:F("typography-markdown-h2 mt-3.5 mb-1.5 text-[var(--markdown-heading2,var(--primary))] font-semibold",o.className),children:n})},h3({children:n,...o}){return a.jsx("h3",{...o,className:F("typography-markdown-h3 mt-3 mb-1 text-[var(--markdown-heading3,var(--primary))] font-semibold",o.className),children:n})},h4({children:n,...o}){return a.jsx("h4",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},h5({children:n,...o}){return a.jsx("h5",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},h6({children:n,...o}){return a.jsx("h6",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},p({children:n,...o}){return a.jsx("p",{...o,className:F("typography-markdown-body my-2 text-foreground/90",o.className),children:n})},thead({children:n,...o}){return a.jsx("thead",{...o,className:F("[&_tr]:border-b [&_tr]:border-border/80",o.className),children:n})},tbody({children:n,...o}){return a.jsx("tbody",{...o,className:F("[&_tr:last-child]:border-0",o.className),children:n})},tr({children:n,...o}){return a.jsx("tr",{...o,className:F("border-b border-border/60",o.className),children:n})},th({children:n,...o}){return a.jsx("th",{...o,className:F("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:n})},td({children:n,...o}){return a.jsx("td",{...o,className:F("border-r border-border/60 px-4 py-2.5 align-middle text-foreground/90 last:border-r-0",o.className),children:n})},ul({children:n,...o}){return a.jsx("ul",{...o,className:F("typography-markdown-body my-2",o.className),children:n})},ol({children:n,...o}){return a.jsx("ol",{...o,className:F("typography-markdown-body my-2",o.className),children:n})},li({children:n,...o}){return a.jsx("li",{...o,className:F("typography-markdown-body my-0.5 text-foreground/90",o.className),children:n})},blockquote({children:n,...o}){return a.jsx("blockquote",{...o,className:F("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:n})},pre({children:n,...o}){const i=j.Children.only(n),l=i.props.className,c=gt(l),d=vt(pe(i.props.children).replace(/\n$/,""),c);return c==="mermaid"?a.jsx(mt,{source:d,mode:be.getState().mermaidRenderingMode}):a.jsx(jt,{code:d,language:c,syntaxTheme:t,...o})},code({className:n,children:o,...i}){return a.jsx("code",{...i,className:F("rounded bg-[var(--surface-elevated)] px-1 py-0.5 font-mono text-[0.95em]",n),"data-markdown":"inline-code",children:o})},a({href:n,children:o,...i}){const l=n??"",c=Le(l),d=e?rt(l):!1;return a.jsxs(a.Fragment,{children:[a.jsxs("a",{...i,href:n,target:c?"_blank":void 0,rel:c?"noopener noreferrer":void 0,children:[c?a.jsx(ot,{href:l}):null,o]}),d&&e?a.jsxs("button",{type:"button",onClick:m=>{m.preventDefault(),m.stopPropagation(),e(l)},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??r??"Open preview pane",title:s??r??"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:r??"Preview"})]}):null]})}}),xe=j.memo(t=>{const e=V.c(5),{block:r,components:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[Ze,Ke],e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=[[Ge,{throwOnError:!1,errorColor:"var(--destructive)"}]],e[1]=o):o=e[1];let i;return e[2]!==r.src||e[3]!==s?(i=a.jsx(qe,{remarkPlugins:n,rehypePlugins:o,components:s,children:r.src}),e[2]=r.src,e[3]=s,e[4]=i):i=e[4],i},(t,e)=>t.block===e.block&&t.components===e.components);xe.displayName="MarkdownBlockView";const me='[data-markdown="mermaid-block"]',Ee='[data-openchamber-file-link="true"]',St=4,Rt=1e3,Tt=200,Lt=200,_t=40,G=new Map;let se=0;const Ce=[],Mt=()=>ge()?Tt:Rt,At=()=>ge()?_t:Lt,Ft=/^[A-Za-z]:[\\/]/,It=/^\\\\[^\\]+\\[^\\]+/,De=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),je=Array.from(De).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),K=t=>{const e=(t||"").trim();if(!e)return"";const r=e.replace(/\\/g,"/"),s=r.startsWith("//");let n=r.replace(/\/+/g,"/");s&&!n.startsWith("//")&&(n=`/${n}`);const o=n==="/",i=/^[A-Za-z]:\/$/.test(n);return!o&&!i&&(n=n.replace(/\/+$/,"")),n},ze=t=>t.startsWith("/")||Ft.test(t)||It.test(t)||t.startsWith("//"),$t=(t,e)=>{const r=K(e);if(!r)return K(t);if(ze(r))return r;const s=K(t);if(!s)return r;const n=/^[A-Za-z]:/.test(s),o=n?s.slice(0,2):"",l=(n?s.slice(2):s).split("/").filter(Boolean),c=r.split("/").filter(Boolean);for(const d of c)if(d!=="."){if(d===".."){l.length>0&&l.pop();continue}l.push(d)}return n?`${o}/${l.join("/")}`:`/${l.join("/")}`},ie=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):""},ue=t=>{let e=ie(t);if(!e)return"";const r=e.indexOf(";");r>=0&&(e=e.slice(0,r)),e=e.replace(/#.*$/,"");const s=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);s&&(e=s[1]??e);const n=je.length>0?e.match(new RegExp(`^(.*(?:/|^)(${je})):.*$`,"i")):null;return n&&(e=n[1]??e),ie(e)},Oe=t=>{const e=ie(t);if(!e)return null;const r=e.indexOf(";"),s=r>=0?ie(e.slice(0,r)):e;if(!s)return null;const n=s.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(n){const l=ue(n[1]??""),c=Number.parseInt(n[2]??"",10),d=n[3]?Number.parseInt(n[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const o=s.match(/^(.*):(\d+)(?::(\d+))?$/);if(o){const l=ue(o[1]??""),c=Number.parseInt(o[2]??"",10),d=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const i=ue(s);return i?{path:i}:null},Pt=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},Be=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=K(t),r=e.split("/").filter(Boolean).pop()??e;if(!r||r==="."||r==="..")return!1;const s=r.toLowerCase();return De.has(s)||s.startsWith(".")&&s.length>1?!0:Pt(e)},Dt=t=>{const e=Oe(t);return e?Be(e.path):!1},fe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&Dt(e))return e}return(t.textContent||"").trim()},he=(t,e)=>{const r=Oe(t);if(!r||!Be(r.path))return null;const s=ze(r.path)?K(r.path):$t(e,r.path);return s?{...r,resolvedPath:s}:null},zt=t=>{const e=K(t);if(!e)return Promise.resolve(!1);const r=G.get(e);if(r)return G.delete(e),G.set(e,r),r;const s=new Promise(o=>{const i=()=>{se+=1,fetch(`/api/fs/stat?path=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store"}).then(l=>o(l.ok)).catch(()=>o(!1)).finally(()=>{se=Math.max(0,se-1),Ce.shift()?.()})};if(se<St){i();return}Ce.push(i)}),n=Mt();for(;G.size>=n;){const o=G.keys().next().value;if(typeof o!="string")break;G.delete(o)}return G.set(e,s),s},Ot=(t,e)=>{const r=K(t);if(r)return r;const s=K(e);return s.replace(/\/[^/]*$/,"")||s},He=t=>{const e=V.c(7),{containerRef:r,effectiveDirectory:s,editor:n,preferRuntimeEditor:o,enabled:i}=t,l=j.useRef(null);let c,d;e[0]!==r||e[1]!==n||e[2]!==s||e[3]!==i||e[4]!==o?(c=()=>{const m=r.current;if(!m)return;let g=!1;const h=At(),p=Vt,k=()=>{const w=m.querySelectorAll(Ee);for(const y of Array.from(w))p(y)};if(!i){k();return}const v=()=>{const w=m.querySelectorAll('[data-markdown="inline-code"], a');let y=0;for(const f of Array.from(w)){const C=fe(f),S=he(C,s);p(f),S&&(y>=h||(y=y+1,zt(S.resolvedPath).then(B=>{if(g||!B||!m.contains(f))return;const A=fe(f),$=he(A,s);!$||$.resolvedPath!==S.resolvedPath||(f.setAttribute("data-openchamber-file-link","true"),f.setAttribute("data-openchamber-file-ref",A),f.setAttribute("data-openchamber-file-path",$.resolvedPath),f.setAttribute("title","Open file"),f.tagName.toLowerCase()!=="a"&&(f.setAttribute("role","button"),f.setAttribute("tabindex","0")))})))}},x=w=>{const y=w.getAttribute("data-openchamber-file-ref")||fe(w),f=he(y,s);if(!f)return;const C=Ot(s,f.resolvedPath);if(o&&n){n.openFile(f.resolvedPath,Number.isFinite(f.line??Number.NaN)?Math.max(1,Math.trunc(f.line)):void 0,Number.isFinite(f.column??Number.NaN)?Math.max(1,Math.trunc(f.column)):void 0);return}const S=be.getState();Number.isFinite(f.line??Number.NaN)?S.openContextFileAtLine(C,f.resolvedPath,Math.max(1,Math.trunc(f.line)),Number.isFinite(f.column??Number.NaN)?Math.max(1,Math.trunc(f.column)):1):S.openContextFile(C,f.resolvedPath)},u=w=>{const y=w.target;if(!(y instanceof Element))return;const f=y.closest(Ee);f instanceof HTMLElement&&(w.preventDefault(),w.stopPropagation(),x(f))},M=w=>{if(w.key!=="Enter"&&w.key!==" ")return;const y=w.target;!(y instanceof HTMLElement)||y.getAttribute("data-openchamber-file-link")!=="true"||(w.preventDefault(),w.stopPropagation(),x(y))};v();const T=new MutationObserver(()=>{if(l.current!==null&&typeof window<"u"&&window.clearTimeout(l.current),typeof window>"u"){v();return}l.current=window.setTimeout(()=>{l.current=null,v()},120)});return T.observe(m,{childList:!0,subtree:!0}),m.addEventListener("click",u),m.addEventListener("keydown",M),()=>{g=!0,l.current!==null&&typeof window<"u"&&window.clearTimeout(l.current),l.current=null,T.disconnect(),m.removeEventListener("click",u),m.removeEventListener("keydown",M)}},d=[r,n,s,o,i],e[0]=r,e[1]=n,e[2]=s,e[3]=i,e[4]=o,e[5]=c,e[6]=d):(c=e[5],d=e[6]),j.useEffect(c,d)},We=t=>{const e=V.c(6),{containerRef:r,mermaidBlocks:s,onShowPopup:n,allowWheelZoom:o}=t;let i,l;e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==n?(i=()=>{const c=r.current;if(!c)return;const d=g=>{if(!n)return;const h=g.target;if(!(h instanceof Element)||h.closest('button, a, [role="button"]'))return;const p=h.closest(me);if(!p)return;const v=Array.from(c.querySelectorAll(me)).indexOf(p);if(v<0)return;const x=s[v];if(!x||x.trim().length===0)return;const u=`Diagram ${v+1}`;n({open:!0,title:u,content:"",metadata:{tool:"mermaid-preview",filename:u},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(x)}`,source:x,filename:u}})},m=g=>{if(o)return;const h=g.target;!(h instanceof Element)||!h.closest(me)||g.stopPropagation()};return c.addEventListener("click",d),c.addEventListener("wheel",m,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",d),c.removeEventListener("wheel",m,!0)}},l=[o,r,s,n],e[0]=o,e[1]=r,e[2]=s,e[3]=n,e[4]=i,e[5]=l):(i=e[4],l=e[5]),j.useEffect(i,l)},Bt=t=>{const e=V.c(42),{content:r,part:s,messageId:n,isAnimated:o,skipFadeIn:i,className:l,isStreaming:c,disableStreamAnimation:d,variant:m,onShowPopup:g,enableFileReferences:h}=t,p=o===void 0?!0:o,k=i===void 0?!1:i,v=c===void 0?!1:c,x=d===void 0?!1:d,u=m===void 0?"assistant":m,M=h===void 0?!0:h,T=ve(),{editor:w,runtime:y}=Se(),f=j.useRef(null),C=Re()??"";let S;e[0]!==r?(S=Ie(r),e[0]=r,e[1]=S):S=e[1];const B=S;let A;e[2]!==B||e[3]!==g?(A={containerRef:f,mermaidBlocks:B,onShowPopup:g},e[2]=B,e[3]=g,e[4]=A):A=e[4],We(A);const $=M&&!v;let z;e[5]!==w||e[6]!==C||e[7]!==y.isVSCode||e[8]!==$?(z={containerRef:f,effectiveDirectory:C,editor:w,preferRuntimeEditor:y.isVSCode,enabled:$},e[5]=w,e[6]=C,e[7]=y.isVSCode,e[8]=$,e[9]=z):z=e[9],He(z);let P;e[10]===Symbol.for("react.memo_cache_sentinel")?(P={containerRef:f},e[10]=P):P=e[10],Me(P);const D=be(qt),{t:I}=le();let W;e[11]!==C||e[12]!==D?(W=q=>{C&&D(C,q)},e[11]=C,e[12]=D,e[13]=W):W=e[13];const b=W;let E;e[14]!==I?(E=I("terminalView.preview.open"),e[14]=I,e[15]=E):E=e[15];const N=E;let R;e[16]!==I?(R=I("terminalView.preview.openTitle"),e[16]=I,e[17]=R):R=e[17];const L=R;let _;e[18]!==T?(_=Te(T),e[18]=T,e[19]=_):_=e[19];const O=_,H=C?b:void 0;let Z;e[20]!==N||e[21]!==L||e[22]!==O||e[23]!==H?(Z=Pe({syntaxTheme:O,onPreviewLoopback:H,previewLabel:N,previewTitle:L}),e[20]=N,e[21]=L,e[22]=O,e[23]=H,e[24]=Z):Z=e[24];const J=Z,ee=`markdown-${s?.id?`part-${s.id}`:`message-${n}`}`,ce=$e(r,v&&!x,ee),de=u==="tool"?"markdown-content markdown-tool":u==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed";let X;e[25]!==l?(X=F("break-words w-full min-w-0",l),e[25]=l,e[26]=X):X=e[26];let Y;if(e[27]!==ce||e[28]!==J){let q;e[30]!==J?(q=ke=>a.jsx(xe,{block:ke,components:J},ke.key),e[30]=J,e[31]=q):q=e[31],Y=ce.map(q),e[27]=ce,e[28]=J,e[29]=Y}else Y=e[29];let Q;e[32]!==de||e[33]!==Y?(Q=a.jsx("div",{className:de,children:Y}),e[32]=de,e[33]=Y,e[34]=Q):Q=e[34];let te;e[35]!==X||e[36]!==Q?(te=a.jsx("div",{className:X,ref:f,children:Q}),e[35]=X,e[36]=Q,e[37]=te):te=e[37];const re=te;if(p){let q;return e[38]!==ee||e[39]!==re||e[40]!==k?(q=a.jsx(et,{skipAnimation:k,children:re},ee),e[38]=ee,e[39]=re,e[40]=k,e[41]=q):q=e[41],q}return re},Xt=j.memo(Bt,(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),Ht=t=>{const e=V.c(33),{content:r,className:s,variant:n,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:l,allowMermaidWheelZoom:c,enableFileReferences:d}=t,m=n===void 0?"assistant":n,g=i===void 0?!1:i,h=c===void 0?!1:c,p=d===void 0?!0:d,{editor:k,runtime:v}=Se();let x;e[0]!==r||e[1]!==g?(x=g?ut(r):r,e[0]=r,e[1]=g,e[2]=x):x=e[2];const u=x,M=ve(),T=j.useRef(null),w=Re()??"";let y;e[3]!==u?(y=Ie(u),e[3]=u,e[4]=y):y=e[4];const f=y;let C;e[5]!==h||e[6]!==f||e[7]!==l?(C={containerRef:T,mermaidBlocks:f,onShowPopup:l,allowWheelZoom:h},e[5]=h,e[6]=f,e[7]=l,e[8]=C):C=e[8],We(C);let S;e[9]!==k||e[10]!==w||e[11]!==p||e[12]!==v.isVSCode?(S={containerRef:T,effectiveDirectory:w,editor:k,preferRuntimeEditor:v.isVSCode,enabled:p},e[9]=k,e[10]=w,e[11]=p,e[12]=v.isVSCode,e[13]=S):S=e[13],He(S);const B=!o;let A;e[14]!==B?(A={containerRef:T,enabled:B},e[14]=B,e[15]=A):A=e[15],Me(A);let $;e[16]!==M?($=Te(M),e[16]=M,e[17]=$):$=e[17];const z=$;let P;e[18]!==z?(P=Pe({syntaxTheme:z}),e[18]=z,e[19]=P):P=e[19];const D=P,I=$e(u,!1,`simple:${m}`),W=m==="tool"?"markdown-content markdown-tool":m==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed";let b;e[20]!==s?(b=F("break-words w-full min-w-0",s),e[20]=s,e[21]=b):b=e[21];let E;if(e[22]!==I||e[23]!==D){let L;e[25]!==D?(L=_=>a.jsx(xe,{block:_,components:D},_.key),e[25]=D,e[26]=L):L=e[26],E=I.map(L),e[22]=I,e[23]=D,e[24]=E}else E=e[24];let N;e[27]!==W||e[28]!==E?(N=a.jsx("div",{className:W,children:E}),e[27]=W,e[28]=E,e[29]=N):N=e[29];let R;return e[30]!==b||e[31]!==N?(R=a.jsx("div",{className:b,ref:T,children:N}),e[30]=b,e[31]=N,e[32]=R):R=e[32],R},Yt=j.memo(Ht,(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 Wt(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 r=e.closest("a[href]");if(!(r instanceof HTMLAnchorElement)||r.getAttribute("data-openchamber-file-link")==="true")return;const s=r.getAttribute("href")??"";Le(s)&&(t.preventDefault(),t.stopPropagation(),tt(s))}function Ut(t){return t==="preview"?"code":"preview"}function Vt(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 qt(t){return t.openContextPreview}export{Xt as MarkdownRenderer,Yt as SimpleMarkdownRenderer};
@@ -1 +1 @@
1
- import{c as _,R as k,j as n,aW as D,aY as C,b0 as I,a$ as M,aZ as S}from"./vendor-.bun-CJSRTa27.js";import{u as z,c as w,I as O}from"./modelPrefsAutoSave-bm-G98P3.js";import{M as P}from"./main-BCXofLIN.js";import"./index-CQjRYgmJ.js";import"./JsonTreeView-4KDa8lGo.js";const F=R=>{const e=_.c(33),{open:b,onOpenChange:t,initialPrompt:v}=R,a=k.useId(),{t:i}=z(),N=W;let o;e[0]!==t?(o=j=>{!j&&N()||t(j)},e[0]=t,e[1]=o):o=e[1];let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(D,{className:w("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=x):x=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=w("relative pointer-events-auto","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=g):g=e[3];let s;e[4]!==t?(s=()=>t(!1),e[4]=t,e[5]=s):s=e[5];let l;e[6]!==i?(l=i("multiRun.window.actions.closeAria"),e[6]=i,e[7]=l):l=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(O,{name:"close",className:"h-5 w-5"}),e[8]=h):h=e[8];let r;e[9]!==s||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:s,"aria-label":l,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:h})}),e[9]=s,e[10]=l,e[11]=r):r=e[11];let c;e[12]!==i?(c=i("multiRun.window.description"),e[12]=i,e[13]=c):c=e[13];let d;e[14]!==a||e[15]!==c?(d=n.jsx(C,{id:a,className:"sr-only",children:c}),e[14]=a,e[15]=c,e[16]=d):d=e[16];let u,f;e[17]!==t?(u=()=>t(!1),f=()=>t(!1),e[17]=t,e[18]=u,e[19]=f):(u=e[18],f=e[19]);let m;e[20]!==v||e[21]!==u||e[22]!==f?(m=n.jsx(P,{initialPrompt:v,onCreated:u,onCancel:f,isWindowed:!0}),e[20]=v,e[21]=u,e[22]=f,e[23]=m):m=e[23];let p;e[24]!==a||e[25]!==m||e[26]!==r||e[27]!==d?(p=n.jsxs(I,{children:[x,n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:n.jsxs(M,{"aria-describedby":a,className:g,children:[r,d,m]})})]}),e[24]=a,e[25]=m,e[26]=r,e[27]=d,e[28]=p):p=e[28];let y;return e[29]!==b||e[30]!==o||e[31]!==p?(y=n.jsx(S,{open:b,onOpenChange:o,children:p}),e[29]=b,e[30]=o,e[31]=p,e[32]=y):y=e[32],y};function W(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{F as MultiRunWindow};
1
+ import{c as _,R as k,j as n,aW as D,aY as C,b0 as I,a$ as M,aZ as S}from"./vendor-.bun-BIr1wmDP.js";import{u as z,c as w,I as O}from"./modelPrefsAutoSave-D4IOtl1d.js";import{M as P}from"./main-DLomPR7m.js";import"./index-Dc1XJWqt.js";import"./JsonTreeView-YQcDxcEK.js";const F=R=>{const e=_.c(33),{open:b,onOpenChange:t,initialPrompt:v}=R,a=k.useId(),{t:i}=z(),N=W;let o;e[0]!==t?(o=j=>{!j&&N()||t(j)},e[0]=t,e[1]=o):o=e[1];let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(D,{className:w("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=x):x=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=w("relative pointer-events-auto","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=g):g=e[3];let s;e[4]!==t?(s=()=>t(!1),e[4]=t,e[5]=s):s=e[5];let l;e[6]!==i?(l=i("multiRun.window.actions.closeAria"),e[6]=i,e[7]=l):l=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(O,{name:"close",className:"h-5 w-5"}),e[8]=h):h=e[8];let r;e[9]!==s||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:s,"aria-label":l,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:h})}),e[9]=s,e[10]=l,e[11]=r):r=e[11];let c;e[12]!==i?(c=i("multiRun.window.description"),e[12]=i,e[13]=c):c=e[13];let d;e[14]!==a||e[15]!==c?(d=n.jsx(C,{id:a,className:"sr-only",children:c}),e[14]=a,e[15]=c,e[16]=d):d=e[16];let u,f;e[17]!==t?(u=()=>t(!1),f=()=>t(!1),e[17]=t,e[18]=u,e[19]=f):(u=e[18],f=e[19]);let m;e[20]!==v||e[21]!==u||e[22]!==f?(m=n.jsx(P,{initialPrompt:v,onCreated:u,onCancel:f,isWindowed:!0}),e[20]=v,e[21]=u,e[22]=f,e[23]=m):m=e[23];let p;e[24]!==a||e[25]!==m||e[26]!==r||e[27]!==d?(p=n.jsxs(I,{children:[x,n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:n.jsxs(M,{"aria-describedby":a,className:g,children:[r,d,m]})})]}),e[24]=a,e[25]=m,e[26]=r,e[27]=d,e[28]=p):p=e[28];let y;return e[29]!==b||e[30]!==o||e[31]!==p?(y=n.jsx(S,{open:b,onOpenChange:o,children:p}),e[29]=b,e[30]=o,e[31]=p,e[32]=y):y=e[32],y};function W(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{F as MultiRunWindow};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-CJSRTa27.js","assets/vendor--V65Sl9C2.css"])))=>i.map(i=>d[i]);
2
- import{r as O,j as t,R as s,c as $,_ as le}from"./vendor-.bun-CJSRTa27.js";import{u as z,eL as ie,eM as Q,a1 as X,eN as q,m as L,at as T,al as H,N as oe,ab as ce,d as ne,cT as W,v as se,c as G,I,a3 as Y}from"./modelPrefsAutoSave-bm-G98P3.js";import"./index-CQjRYgmJ.js";function de(l){switch(l){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function V(l){return l==="wrong-service"||l==="unreachable"}function ae({onBack:l,showBackButton:e=!0,initialUrl:c="",initialLabel:a="",isRecoveryMode:o=!1,onConnect:x,onSwitchToLocal:i}){const{t:n}=z(),[m,k]=O.useState(c),[g,_]=O.useState(a),[N,p]=O.useState("idle"),[h,w]=O.useState(null),[R,S]=O.useState(""),b=ie(m),f=O.useCallback(u=>{k(u.target.value),p("idle"),w(null),S("")},[]),j=O.useCallback(u=>{_(u.target.value)},[]),v=O.useCallback(async()=>{if(b){p("testing"),w(null),S("");try{const u=await Q(b);w(u),p(u.status==="ok"?"success":"error")}catch(u){S(u instanceof Error?u.message:n("onboarding.remoteConnection.errors.connectionTestFailed")),p("error")}}},[b,n]),C=O.useCallback(async()=>{if(b){p("testing"),w(null),S("");try{const u=await Q(b);if(w(u),V(u.status)){p("error");return}const r=await X(),y=g.trim()||b,K=r.hosts.find(M=>M.url===b),P=K?K.id:`host-${Date.now().toString(16)}`,J={id:P,label:y,url:b},re=K?r.hosts.map(M=>M.id===P?J:M):[...r.hosts,J];await q({hosts:re,defaultHostId:P,initialHostChoiceCompleted:!0}),x?.(),L()&&await window.__TAURI__?.core?.invoke?.("desktop_restart")}catch(u){S(u instanceof Error?u.message:n("onboarding.remoteConnection.errors.failedToSaveConnection")),p("error")}}},[b,g,x,n]),U=N==="testing",D=b!==null&&!U,A=b!==null&&!U&&!V(h?.status??null),E=de(h?.status??null),F=h?.status==="ok",B=h?.status==="auth",d=V(h?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(T,{variant:"ghost",onClick:l,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:n(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:n("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:n("onboarding.remoteConnection.field.serverAddress")}),t.jsx(H,{id:"remote-url",type:"url",value:m,onChange:f,placeholder:n("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:U})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:n("onboarding.remoteConnection.field.nameOptional")}),t.jsx(H,{id:"remote-label",type:"text",value:g,onChange:j,placeholder:n("onboarding.remoteConnection.field.namePlaceholder"),disabled:U})]})]}),h&&F&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:n("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:h.latencyMs})}),h&&B&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:n("onboarding.remoteConnection.status.authWarning")}),h&&d&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:n("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:E?n(E):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:h.status==="unreachable"?n("onboarding.remoteConnection.status.suggestionsUnreachable"):n("onboarding.remoteConnection.status.suggestionsWrongService")})]}),R&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:R}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(T,{variant:"outline",onClick:v,disabled:!D,children:n(U?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(T,{onClick:C,disabled:!A,children:n("onboarding.remoteConnection.actions.connectAndRestart")})]}),d&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:n("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(T,{variant:"outline",size:"sm",onClick:l,className:"flex-1",children:n("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(T,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:n("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const ue="curl -fsSL https://opencode.ai/install | bash",me="https://opencode.ai/docs",pe="https://opencode.ai/docs/windows-wsl",Z=2500;function he(l){const e=$.c(5),{onCopy:c,copyTitle:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[1]=x):x=e[1];let i;return e[2]!==a||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:a,"aria-label":a,children:x})]}),e[2]=a,e[3]=c,e[4]=i):i=e[4],i}function fe({onCliAvailable:l}){const{t:e}=z(),[c,a]=s.useState(!1),[o,x]=s.useState(!1),[i,n]=s.useState(!1),[m,k]=s.useState(!1),[g,_]=s.useState(""),[N,p]=s.useState("unknown"),[h,w]=s.useState("local"),[R,S]=s.useState(!1),[b,f]=s.useState(!1);s.useEffect(()=>{x(oe())},[]),s.useEffect(()=>{if(typeof navigator>"u"){p("unknown");return}const r=navigator.userAgent||"";/Windows/i.test(r)?p("windows"):/Macintosh|Mac OS X/i.test(r)?p("macos"):/Linux/i.test(r)?p("linux"):p("unknown")},[]),s.useEffect(()=>{let r=!1;return(async()=>{try{const y=await fetch("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!y.ok)return;const K=await y.json().catch(()=>null);if(!K||r)return;const P=typeof K.opencodeBinary=="string"?K.opencodeBinary.trim():"";P&&_(P)}catch{}})(),()=>{r=!0}},[]);const j=s.useCallback(async r=>{const y=r.target;y.closest(".app-region-no-drag")||y.closest("button, a, input, select, textarea, code, summary, details")||r.button===0&&o&&await ce()},[o]),v=s.useCallback(async()=>{try{const r=await fetch("/health");if(!r.ok)return!1;const y=await r.json();return y.openCodeRunning===!0||y.isOpenCodeReady===!0}catch{return!1}},[]),C=s.useCallback(async r=>{if(!L())return;const y=await X();await q({...y,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[]),U=s.useCallback(async()=>{L()&&await C("local"),l?.()},[l,C]);s.useEffect(()=>{if(h!=="local")return;let r=!1,y=null;const K=async()=>{if(!r){try{const P=await v();if(r)return;if(P){await U();return}}catch{}r||(y=setTimeout(K,Z))}};return y=setTimeout(K,Z),()=>{r=!0,y&&clearTimeout(y)}},[h,v,U]);const D=s.useCallback(async()=>{k(!0);try{await v()&&await U()}finally{k(!1)}},[v,U]),A=s.useCallback(async()=>{if(typeof window>"u"||!o||!L())return;const r=window.__TAURI__;if(r?.dialog?.open)try{const y=await r.dialog.open({title:e("onboarding.localSetup.dialog.selectOpencodeBinary"),multiple:!1,directory:!1});typeof y=="string"&&y.trim().length>0&&_(y.trim())}catch{}},[o,e]),E=s.useCallback(async()=>{n(!0);try{if(await ne({opencodeBinary:g.trim()}),L()){await C("local"),await W();return}await fetch("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>n(!1),1e3)}},[g,C]),F=s.useCallback(async()=>{const r=await se(ue);r.ok?(a(!0),setTimeout(()=>a(!1),2e3)):console.error("Failed to copy:",r.error)},[]),B=N==="windows"?pe:me,d=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",u=!o||!L()||h==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:j,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&L()&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:G("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",h==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>w("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:G("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",h==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>w("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&L()&&h==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ae,{onBack:()=>w("local"),showBackButton:!1,onSwitchToLocal:()=>w("local")})}):null,u&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsxs("li",{children:[e("onboarding.localSetup.windows.stepInstallWsl")," ",t.jsx("code",{className:"text-foreground/80",children:"wsl --install"})," ",e("onboarding.localSetup.windows.stepInstallWslSuffix")]}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(I,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(he,{onCopy:F,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:B,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(I,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:D,disabled:m,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(m?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:R,onToggle:r=>S(r.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(I,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(H,{value:g,onChange:r=>_(r.target.value),placeholder:d,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(T,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o||!L(),children:e("onboarding.localSetup.actions.browse")}),t.jsx(T,{type:"button",size:"sm",onClick:E,disabled:i||!g.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:b,onToggle:r=>f(r.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(I,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.windows.hintInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})]}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const xe="curl -fsSL https://opencode.ai/install | bash",ge="https://opencode.ai/docs",be="https://opencode.ai/docs/windows-wsl";function ye(l){const e=$.c(5),{onCopy:c,copyTitle:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[1]=x):x=e[1];let i;return e[2]!==a||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:a,children:x})]}),e[2]=a,e[3]=c,e[4]=i):i=e[4],i}const ve=3e4;function we({onBack:l,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:a}){const{t:o}=z(),[x,i]=s.useState(!1),[n,m]=s.useState(!1),[k,g]=s.useState(!1),[_,N]=s.useState(!1),[p,h]=s.useState(!1),[w,R]=s.useState(null),[S,b]=s.useState(""),[f,j]=s.useState("unknown");s.useEffect(()=>{const d=setTimeout(()=>m(!0),ve);return()=>clearTimeout(d)},[]),s.useEffect(()=>{g(oe())},[]),s.useEffect(()=>{if(typeof navigator>"u"){j("unknown");return}const d=navigator.userAgent||"";if(/Windows/i.test(d)){j("windows");return}if(/Macintosh|Mac OS X/i.test(d)){j("macos");return}if(/Linux/i.test(d)){j("linux");return}j("unknown")},[]),s.useEffect(()=>{let d=!1;return(async()=>{try{const u=await fetch("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!u.ok)return;const r=await u.json().catch(()=>null);if(!r||d)return;const y=typeof r.opencodeBinary=="string"?r.opencodeBinary.trim():"";y&&b(y)}catch{}})(),()=>{d=!0}},[]);const v=s.useCallback(async d=>{if(!d.target.closest("button, a, input, select, textarea, code")&&d.button===0&&k&&L())try{const{getCurrentWindow:u}=await le(async()=>{const{getCurrentWindow:y}=await import("./vendor-.bun-CJSRTa27.js").then(K=>K.bK);return{getCurrentWindow:y}},__vite__mapDeps([0,1]));await u().startDragging()}catch(u){console.error("Failed to start window dragging:",u)}},[k]),C=s.useCallback(async()=>{try{const d=await fetch("/health");if(!d.ok)return!1;const u=await d.json();return u.openCodeRunning===!0||u.isOpenCodeReady===!0}catch{return!1}},[]),U=s.useCallback(async()=>{if(typeof window>"u"||!k||!L())return;const d=window.__TAURI__;if(d?.dialog?.open)try{const u=await d.dialog.open({title:o("onboarding.localSetup.dialog.selectOpencodeBinary"),multiple:!1,directory:!1});typeof u=="string"&&u.trim().length>0&&b(u.trim())}catch{}},[k,o]),D=s.useCallback(async()=>{N(!0);try{if(await ne({opencodeBinary:S.trim()}),L()){await W();return}await fetch("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[S]),A=s.useCallback(async()=>{const d=await se(xe);d.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",d.error)},[]),E=s.useCallback(async()=>{h(!0),R(null);try{await C()?e?.():R(o("onboarding.localSetup.errors.cliNotReady"))}catch(d){R(d instanceof Error?d.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{h(!1)}},[C,e,o]),F=f==="windows"?be:ge,B=f==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":f==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:v,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(T,{variant:"ghost",onClick:l,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),f==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsxs("li",{children:[o("onboarding.localSetup.windows.stepInstallWsl")," ",t.jsx("code",{className:"text-foreground/80",children:"wsl --install"})," ",o("onboarding.localSetup.windows.stepInstallWslSuffix")]}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:x?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(I,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ye,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:F,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[o(f==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(I,{name:"external-link",className:"h-3 w-3"})]}),w&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:w}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(T,{type:"button",onClick:E,disabled:p,className:"w-full max-w-xs",size:"lg",children:o(p?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(H,{value:S,onChange:d=>b(d.target.value),placeholder:B,disabled:_,className:"flex-1 font-mono text-xs"}),t.jsx(T,{type:"button",variant:"secondary",onClick:U,disabled:_||!k||!L(),children:o("onboarding.localSetup.actions.browse")}),t.jsx(T,{type:"button",onClick:D,disabled:_,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&a&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(T,{variant:"link",onClick:a,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),n&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:f==="windows"?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintInstallInWsl")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function ee(l,e){if(l?.trim())return Y(l.trim());if(e)return Y(e)}function je(l,e,c){switch(l){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const a=ee(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${a||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:a?{host:a}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const a=ee(e,c);return{title:"Incompatible Server",description:`The server at "${a||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:a?{host:a}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const a=l;throw new Error(`Unknown recovery variant: ${a}`)}}}function ke(l){switch(l){case"local":return t.jsx(I,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(I,{name:"server",className:"h-8 w-8"})}}function Ce({variant:l,hostLabel:e,hostUrl:c,onRetry:a,onUseLocal:o,onUseRemote:x,isRetrying:i=!1}){const{t:n}=z(),m=je(l,e,c),k=m.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",g=s.useMemo(()=>{if(m.descriptionParams?.host)return m.descriptionParams;if(l==="remote-unreachable")return{host:n("onboarding.desktopRecovery.placeholders.remoteServer")};if(l==="remote-wrong-service")return{host:n("onboarding.desktopRecovery.placeholders.unknownServer")}},[m.descriptionParams,n,l]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:ke(m.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:n(m.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:n(m.descriptionKey,g)})]}),c&&(l==="remote-unreachable"||l==="remote-wrong-service")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:n("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:Y(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[m.showRetry&&a&&t.jsxs(T,{onClick:a,disabled:i,className:"w-full",children:[t.jsx(I,{name:"refresh",className:G("h-4 w-4",i&&"animate-spin")}),n(i?"onboarding.desktopRecovery.actions.retrying":k)]}),t.jsxs("div",{className:"flex gap-2",children:[m.showUseLocal&&o&&t.jsxs(T,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(I,{name:"macbook",className:"h-4 w-4"}),n(m.useLocalLabelKey)]}),m.showUseRemote&&x&&t.jsxs(T,{variant:"outline",onClick:x,disabled:i,className:"flex-1",children:[t.jsx(I,{name:"server",className:"h-4 w-4"}),n(m.useRemoteLabelKey)]})]})]})]})})}function te(l,e){if(e==="use-remote")return{kind:"remote-form"};switch(l){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=l;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Se(l){const e=$.c(27),{variant:c,hostUrl:a,hostLabel:o,onRetry:x,onChooseRemote:i,showRemoteForm:n,onCloseRemoteForm:m,onSwitchToLocalFromRemote:k,onEnterLocalSetup:g,isRetrying:_}=l,N=n===void 0?!1:n,p=_===void 0?!1:_,h=Ne;let w;e[0]!==x?(w=async()=>{if(L()){await W();return}await fetch("/api/config/reload",{method:"POST"}),x?.()},e[0]=x,e[1]=w):w=e[1];const R=w;let S;e[2]!==g||e[3]!==c?(S=async()=>{if(te(c,"use-local").kind==="local-setup"){g?.();return}if(await h("local"),L()){await W();return}window.location.reload()},e[2]=g,e[3]=c,e[4]=S):S=e[4];const b=S;let f;e[5]!==i||e[6]!==c?(f=()=>{te(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=f):f=e[7];const j=f;if(N){const C=c==="remote-wrong-service"?"":a||"",U=c==="remote-wrong-service"?"":o||"";let D;e[8]!==i||e[9]!==m?(D=m||(()=>i?.()),e[8]=i,e[9]=m,e[10]=D):D=e[10];let A;e[11]!==g||e[12]!==k?(A=k||(()=>{h("local").then(()=>{L()?W():g?.()})}),e[11]=g,e[12]=k,e[13]=A):A=e[13];let E;return e[14]!==U||e[15]!==C||e[16]!==D||e[17]!==A?(E=t.jsx(ae,{onBack:D,initialUrl:C,initialLabel:U,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=U,e[15]=C,e[16]=D,e[17]=A,e[18]=E):E=e[18],E}let v;return e[19]!==R||e[20]!==b||e[21]!==j||e[22]!==o||e[23]!==a||e[24]!==p||e[25]!==c?(v=t.jsx(Ce,{variant:c,hostLabel:o,hostUrl:a,onRetry:R,onUseLocal:b,onUseRemote:j,isRetrying:p}),e[19]=R,e[20]=b,e[21]=j,e[22]=o,e[23]=a,e[24]=p,e[25]=c,e[26]=v):v=e[26],v}async function Ne(l){if(!L())return;const e=await X();await q({...e,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ue(l){const e=$.c(26),{onBack:c,onCliAvailable:a,mode:o,recoveryVariant:x,recoveryHostUrl:i,recoveryHostLabel:n,onEnterLocalSetup:m}=l,k=o===void 0?"first-launch":o,g=x===void 0?"missing-default-host":x,[_,N]=s.useState(!1),[p,h]=s.useState(!1);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{h(!1),N(!1)},e[0]=w):w=e[0];let R;e[1]!==k||e[2]!==n||e[3]!==i||e[4]!==g?(R=[k,g,i,n],e[1]=k,e[2]=n,e[3]=i,e[4]=g,e[5]=R):R=e[5],s.useEffect(w,R);const S=p?"local-setup":k;if(S==="recovery"){let f,j;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>N(!1),j=()=>{N(!1),h(!0)},e[6]=f,e[7]=j):(f=e[6],j=e[7]);let v;e[8]!==m?(v=()=>{h(!0),m?.()},e[8]=m,e[9]=v):v=e[9];let C;return e[10]!==n||e[11]!==i||e[12]!==g||e[13]!==_||e[14]!==v?(C=t.jsx(Se,{variant:g,hostUrl:i,hostLabel:n,showRemoteForm:_,onCloseRemoteForm:f,onSwitchToLocalFromRemote:j,onEnterLocalSetup:v}),e[10]=n,e[11]=i,e[12]=g,e[13]=_,e[14]=v,e[15]=C):C=e[15],C}if(S==="local-setup"){let f;e[16]!==c||e[17]!==p?(f=()=>{p?h(!1):c?.()},e[16]=c,e[17]=p,e[18]=f):f=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=()=>N(!0),e[19]=j):j=e[19];let v;return e[20]!==a||e[21]!==p||e[22]!==f?(v=t.jsx(we,{onBack:f,onCliAvailable:a,isFromRecovery:p,onSwitchToRemote:j}),e[20]=a,e[21]=p,e[22]=f,e[23]=v):v=e[23],v}let b;return e[24]!==a?(b=t.jsx(fe,{onCliAvailable:a}),e[24]=a,e[25]=b):b=e[25],b}export{Ue as OnboardingScreen};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-BIr1wmDP.js","assets/vendor--V65Sl9C2.css"])))=>i.map(i=>d[i]);
2
+ import{r as O,j as t,R as s,c as $,_ as le}from"./vendor-.bun-BIr1wmDP.js";import{u as z,eK as ie,eL as Q,a1 as X,eM as J,m as L,as as T,aI as H,N as oe,ab as ce,d as ne,cV as W,v as se,c as G,I,a3 as Y}from"./modelPrefsAutoSave-D4IOtl1d.js";import"./index-Dc1XJWqt.js";function de(l){switch(l){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function V(l){return l==="wrong-service"||l==="unreachable"}function ae({onBack:l,showBackButton:e=!0,initialUrl:c="",initialLabel:a="",isRecoveryMode:o=!1,onConnect:x,onSwitchToLocal:i}){const{t:n}=z(),[m,k]=O.useState(c),[g,_]=O.useState(a),[N,p]=O.useState("idle"),[h,w]=O.useState(null),[R,S]=O.useState(""),b=ie(m),f=O.useCallback(u=>{k(u.target.value),p("idle"),w(null),S("")},[]),j=O.useCallback(u=>{_(u.target.value)},[]),v=O.useCallback(async()=>{if(b){p("testing"),w(null),S("");try{const u=await Q(b);w(u),p(u.status==="ok"?"success":"error")}catch(u){S(u instanceof Error?u.message:n("onboarding.remoteConnection.errors.connectionTestFailed")),p("error")}}},[b,n]),C=O.useCallback(async()=>{if(b){p("testing"),w(null),S("");try{const u=await Q(b);if(w(u),V(u.status)){p("error");return}const r=await X(),y=g.trim()||b,K=r.hosts.find(M=>M.url===b),P=K?K.id:`host-${Date.now().toString(16)}`,q={id:P,label:y,url:b},re=K?r.hosts.map(M=>M.id===P?q:M):[...r.hosts,q];await J({hosts:re,defaultHostId:P,initialHostChoiceCompleted:!0}),x?.(),L()&&await window.__TAURI__?.core?.invoke?.("desktop_restart")}catch(u){S(u instanceof Error?u.message:n("onboarding.remoteConnection.errors.failedToSaveConnection")),p("error")}}},[b,g,x,n]),U=N==="testing",D=b!==null&&!U,A=b!==null&&!U&&!V(h?.status??null),E=de(h?.status??null),F=h?.status==="ok",B=h?.status==="auth",d=V(h?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(T,{variant:"ghost",onClick:l,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:n(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:n("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:n("onboarding.remoteConnection.field.serverAddress")}),t.jsx(H,{id:"remote-url",type:"url",value:m,onChange:f,placeholder:n("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:U})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:n("onboarding.remoteConnection.field.nameOptional")}),t.jsx(H,{id:"remote-label",type:"text",value:g,onChange:j,placeholder:n("onboarding.remoteConnection.field.namePlaceholder"),disabled:U})]})]}),h&&F&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:n("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:h.latencyMs})}),h&&B&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:n("onboarding.remoteConnection.status.authWarning")}),h&&d&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:n("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:E?n(E):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:h.status==="unreachable"?n("onboarding.remoteConnection.status.suggestionsUnreachable"):n("onboarding.remoteConnection.status.suggestionsWrongService")})]}),R&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:R}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(T,{variant:"outline",onClick:v,disabled:!D,children:n(U?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(T,{onClick:C,disabled:!A,children:n("onboarding.remoteConnection.actions.connectAndRestart")})]}),d&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:n("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(T,{variant:"outline",size:"sm",onClick:l,className:"flex-1",children:n("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(T,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:n("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const ue="curl -fsSL https://opencode.ai/install | bash",me="https://opencode.ai/docs",pe="https://opencode.ai/docs/windows-wsl",Z=2500;function he(l){const e=$.c(5),{onCopy:c,copyTitle:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[1]=x):x=e[1];let i;return e[2]!==a||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:a,"aria-label":a,children:x})]}),e[2]=a,e[3]=c,e[4]=i):i=e[4],i}function fe({onCliAvailable:l}){const{t:e}=z(),[c,a]=s.useState(!1),[o,x]=s.useState(!1),[i,n]=s.useState(!1),[m,k]=s.useState(!1),[g,_]=s.useState(""),[N,p]=s.useState("unknown"),[h,w]=s.useState("local"),[R,S]=s.useState(!1),[b,f]=s.useState(!1);s.useEffect(()=>{x(oe())},[]),s.useEffect(()=>{if(typeof navigator>"u"){p("unknown");return}const r=navigator.userAgent||"";/Windows/i.test(r)?p("windows"):/Macintosh|Mac OS X/i.test(r)?p("macos"):/Linux/i.test(r)?p("linux"):p("unknown")},[]),s.useEffect(()=>{let r=!1;return(async()=>{try{const y=await fetch("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!y.ok)return;const K=await y.json().catch(()=>null);if(!K||r)return;const P=typeof K.opencodeBinary=="string"?K.opencodeBinary.trim():"";P&&_(P)}catch{}})(),()=>{r=!0}},[]);const j=s.useCallback(async r=>{const y=r.target;y.closest(".app-region-no-drag")||y.closest("button, a, input, select, textarea, code, summary, details")||r.button===0&&o&&await ce()},[o]),v=s.useCallback(async()=>{try{const r=await fetch("/health");if(!r.ok)return!1;const y=await r.json();return y.openCodeRunning===!0||y.isOpenCodeReady===!0}catch{return!1}},[]),C=s.useCallback(async r=>{if(!L())return;const y=await X();await J({...y,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[]),U=s.useCallback(async()=>{L()&&await C("local"),l?.()},[l,C]);s.useEffect(()=>{if(h!=="local")return;let r=!1,y=null;const K=async()=>{if(!r){try{const P=await v();if(r)return;if(P){await U();return}}catch{}r||(y=setTimeout(K,Z))}};return y=setTimeout(K,Z),()=>{r=!0,y&&clearTimeout(y)}},[h,v,U]);const D=s.useCallback(async()=>{k(!0);try{await v()&&await U()}finally{k(!1)}},[v,U]),A=s.useCallback(async()=>{if(typeof window>"u"||!o||!L())return;const r=window.__TAURI__;if(r?.dialog?.open)try{const y=await r.dialog.open({title:e("onboarding.localSetup.dialog.selectOpencodeBinary"),multiple:!1,directory:!1});typeof y=="string"&&y.trim().length>0&&_(y.trim())}catch{}},[o,e]),E=s.useCallback(async()=>{n(!0);try{if(await ne({opencodeBinary:g.trim()}),L()){await C("local"),await W();return}await fetch("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>n(!1),1e3)}},[g,C]),F=s.useCallback(async()=>{const r=await se(ue);r.ok?(a(!0),setTimeout(()=>a(!1),2e3)):console.error("Failed to copy:",r.error)},[]),B=N==="windows"?pe:me,d=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",u=!o||!L()||h==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:j,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&L()&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:G("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",h==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>w("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:G("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",h==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>w("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&L()&&h==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ae,{onBack:()=>w("local"),showBackButton:!1,onSwitchToLocal:()=>w("local")})}):null,u&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsxs("li",{children:[e("onboarding.localSetup.windows.stepInstallWsl")," ",t.jsx("code",{className:"text-foreground/80",children:"wsl --install"})," ",e("onboarding.localSetup.windows.stepInstallWslSuffix")]}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(I,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(he,{onCopy:F,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:B,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(I,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:D,disabled:m,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(m?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:R,onToggle:r=>S(r.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(I,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(H,{value:g,onChange:r=>_(r.target.value),placeholder:d,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(T,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o||!L(),children:e("onboarding.localSetup.actions.browse")}),t.jsx(T,{type:"button",size:"sm",onClick:E,disabled:i||!g.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:b,onToggle:r=>f(r.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(I,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.windows.hintInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})]}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const xe="curl -fsSL https://opencode.ai/install | bash",ge="https://opencode.ai/docs",be="https://opencode.ai/docs/windows-wsl";function ye(l){const e=$.c(5),{onCopy:c,copyTitle:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[1]=x):x=e[1];let i;return e[2]!==a||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:a,children:x})]}),e[2]=a,e[3]=c,e[4]=i):i=e[4],i}const ve=3e4;function we({onBack:l,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:a}){const{t:o}=z(),[x,i]=s.useState(!1),[n,m]=s.useState(!1),[k,g]=s.useState(!1),[_,N]=s.useState(!1),[p,h]=s.useState(!1),[w,R]=s.useState(null),[S,b]=s.useState(""),[f,j]=s.useState("unknown");s.useEffect(()=>{const d=setTimeout(()=>m(!0),ve);return()=>clearTimeout(d)},[]),s.useEffect(()=>{g(oe())},[]),s.useEffect(()=>{if(typeof navigator>"u"){j("unknown");return}const d=navigator.userAgent||"";if(/Windows/i.test(d)){j("windows");return}if(/Macintosh|Mac OS X/i.test(d)){j("macos");return}if(/Linux/i.test(d)){j("linux");return}j("unknown")},[]),s.useEffect(()=>{let d=!1;return(async()=>{try{const u=await fetch("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!u.ok)return;const r=await u.json().catch(()=>null);if(!r||d)return;const y=typeof r.opencodeBinary=="string"?r.opencodeBinary.trim():"";y&&b(y)}catch{}})(),()=>{d=!0}},[]);const v=s.useCallback(async d=>{if(!d.target.closest("button, a, input, select, textarea, code")&&d.button===0&&k&&L())try{const{getCurrentWindow:u}=await le(async()=>{const{getCurrentWindow:y}=await import("./vendor-.bun-BIr1wmDP.js").then(K=>K.bJ);return{getCurrentWindow:y}},__vite__mapDeps([0,1]));await u().startDragging()}catch(u){console.error("Failed to start window dragging:",u)}},[k]),C=s.useCallback(async()=>{try{const d=await fetch("/health");if(!d.ok)return!1;const u=await d.json();return u.openCodeRunning===!0||u.isOpenCodeReady===!0}catch{return!1}},[]),U=s.useCallback(async()=>{if(typeof window>"u"||!k||!L())return;const d=window.__TAURI__;if(d?.dialog?.open)try{const u=await d.dialog.open({title:o("onboarding.localSetup.dialog.selectOpencodeBinary"),multiple:!1,directory:!1});typeof u=="string"&&u.trim().length>0&&b(u.trim())}catch{}},[k,o]),D=s.useCallback(async()=>{N(!0);try{if(await ne({opencodeBinary:S.trim()}),L()){await W();return}await fetch("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[S]),A=s.useCallback(async()=>{const d=await se(xe);d.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",d.error)},[]),E=s.useCallback(async()=>{h(!0),R(null);try{await C()?e?.():R(o("onboarding.localSetup.errors.cliNotReady"))}catch(d){R(d instanceof Error?d.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{h(!1)}},[C,e,o]),F=f==="windows"?be:ge,B=f==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":f==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:v,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(T,{variant:"ghost",onClick:l,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),f==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsxs("li",{children:[o("onboarding.localSetup.windows.stepInstallWsl")," ",t.jsx("code",{className:"text-foreground/80",children:"wsl --install"})," ",o("onboarding.localSetup.windows.stepInstallWslSuffix")]}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:x?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(I,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ye,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:F,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[o(f==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(I,{name:"external-link",className:"h-3 w-3"})]}),w&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:w}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(T,{type:"button",onClick:E,disabled:p,className:"w-full max-w-xs",size:"lg",children:o(p?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(H,{value:S,onChange:d=>b(d.target.value),placeholder:B,disabled:_,className:"flex-1 font-mono text-xs"}),t.jsx(T,{type:"button",variant:"secondary",onClick:U,disabled:_||!k||!L(),children:o("onboarding.localSetup.actions.browse")}),t.jsx(T,{type:"button",onClick:D,disabled:_,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&a&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(T,{variant:"link",onClick:a,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),n&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:f==="windows"?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintInstallInWsl")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function ee(l,e){if(l?.trim())return Y(l.trim());if(e)return Y(e)}function je(l,e,c){switch(l){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const a=ee(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${a||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:a?{host:a}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const a=ee(e,c);return{title:"Incompatible Server",description:`The server at "${a||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:a?{host:a}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const a=l;throw new Error(`Unknown recovery variant: ${a}`)}}}function ke(l){switch(l){case"local":return t.jsx(I,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(I,{name:"server",className:"h-8 w-8"})}}function Ce({variant:l,hostLabel:e,hostUrl:c,onRetry:a,onUseLocal:o,onUseRemote:x,isRetrying:i=!1}){const{t:n}=z(),m=je(l,e,c),k=m.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",g=s.useMemo(()=>{if(m.descriptionParams?.host)return m.descriptionParams;if(l==="remote-unreachable")return{host:n("onboarding.desktopRecovery.placeholders.remoteServer")};if(l==="remote-wrong-service")return{host:n("onboarding.desktopRecovery.placeholders.unknownServer")}},[m.descriptionParams,n,l]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:ke(m.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:n(m.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:n(m.descriptionKey,g)})]}),c&&(l==="remote-unreachable"||l==="remote-wrong-service")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:n("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:Y(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[m.showRetry&&a&&t.jsxs(T,{onClick:a,disabled:i,className:"w-full",children:[t.jsx(I,{name:"refresh",className:G("h-4 w-4",i&&"animate-spin")}),n(i?"onboarding.desktopRecovery.actions.retrying":k)]}),t.jsxs("div",{className:"flex gap-2",children:[m.showUseLocal&&o&&t.jsxs(T,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(I,{name:"macbook",className:"h-4 w-4"}),n(m.useLocalLabelKey)]}),m.showUseRemote&&x&&t.jsxs(T,{variant:"outline",onClick:x,disabled:i,className:"flex-1",children:[t.jsx(I,{name:"server",className:"h-4 w-4"}),n(m.useRemoteLabelKey)]})]})]})]})})}function te(l,e){if(e==="use-remote")return{kind:"remote-form"};switch(l){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=l;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Se(l){const e=$.c(27),{variant:c,hostUrl:a,hostLabel:o,onRetry:x,onChooseRemote:i,showRemoteForm:n,onCloseRemoteForm:m,onSwitchToLocalFromRemote:k,onEnterLocalSetup:g,isRetrying:_}=l,N=n===void 0?!1:n,p=_===void 0?!1:_,h=Ne;let w;e[0]!==x?(w=async()=>{if(L()){await W();return}await fetch("/api/config/reload",{method:"POST"}),x?.()},e[0]=x,e[1]=w):w=e[1];const R=w;let S;e[2]!==g||e[3]!==c?(S=async()=>{if(te(c,"use-local").kind==="local-setup"){g?.();return}if(await h("local"),L()){await W();return}window.location.reload()},e[2]=g,e[3]=c,e[4]=S):S=e[4];const b=S;let f;e[5]!==i||e[6]!==c?(f=()=>{te(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=f):f=e[7];const j=f;if(N){const C=c==="remote-wrong-service"?"":a||"",U=c==="remote-wrong-service"?"":o||"";let D;e[8]!==i||e[9]!==m?(D=m||(()=>i?.()),e[8]=i,e[9]=m,e[10]=D):D=e[10];let A;e[11]!==g||e[12]!==k?(A=k||(()=>{h("local").then(()=>{L()?W():g?.()})}),e[11]=g,e[12]=k,e[13]=A):A=e[13];let E;return e[14]!==U||e[15]!==C||e[16]!==D||e[17]!==A?(E=t.jsx(ae,{onBack:D,initialUrl:C,initialLabel:U,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=U,e[15]=C,e[16]=D,e[17]=A,e[18]=E):E=e[18],E}let v;return e[19]!==R||e[20]!==b||e[21]!==j||e[22]!==o||e[23]!==a||e[24]!==p||e[25]!==c?(v=t.jsx(Ce,{variant:c,hostLabel:o,hostUrl:a,onRetry:R,onUseLocal:b,onUseRemote:j,isRetrying:p}),e[19]=R,e[20]=b,e[21]=j,e[22]=o,e[23]=a,e[24]=p,e[25]=c,e[26]=v):v=e[26],v}async function Ne(l){if(!L())return;const e=await X();await J({...e,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ue(l){const e=$.c(26),{onBack:c,onCliAvailable:a,mode:o,recoveryVariant:x,recoveryHostUrl:i,recoveryHostLabel:n,onEnterLocalSetup:m}=l,k=o===void 0?"first-launch":o,g=x===void 0?"missing-default-host":x,[_,N]=s.useState(!1),[p,h]=s.useState(!1);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{h(!1),N(!1)},e[0]=w):w=e[0];let R;e[1]!==k||e[2]!==n||e[3]!==i||e[4]!==g?(R=[k,g,i,n],e[1]=k,e[2]=n,e[3]=i,e[4]=g,e[5]=R):R=e[5],s.useEffect(w,R);const S=p?"local-setup":k;if(S==="recovery"){let f,j;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>N(!1),j=()=>{N(!1),h(!0)},e[6]=f,e[7]=j):(f=e[6],j=e[7]);let v;e[8]!==m?(v=()=>{h(!0),m?.()},e[8]=m,e[9]=v):v=e[9];let C;return e[10]!==n||e[11]!==i||e[12]!==g||e[13]!==_||e[14]!==v?(C=t.jsx(Se,{variant:g,hostUrl:i,hostLabel:n,showRemoteForm:_,onCloseRemoteForm:f,onSwitchToLocalFromRemote:j,onEnterLocalSetup:v}),e[10]=n,e[11]=i,e[12]=g,e[13]=_,e[14]=v,e[15]=C):C=e[15],C}if(S==="local-setup"){let f;e[16]!==c||e[17]!==p?(f=()=>{p?h(!1):c?.()},e[16]=c,e[17]=p,e[18]=f):f=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=()=>N(!0),e[19]=j):j=e[19];let v;return e[20]!==a||e[21]!==p||e[22]!==f?(v=t.jsx(we,{onBack:f,onCliAvailable:a,isFromRecovery:p,onSwitchToRemote:j}),e[20]=a,e[21]=p,e[22]=f,e[23]=v):v=e[23],v}let b;return e[24]!==a?(b=t.jsx(fe,{onCliAvailable:a}),e[24]=a,e[25]=b):b=e[25],b}export{Ue as OnboardingScreen};
@@ -1 +1 @@
1
- import{c as h,R as b,j as t,aW as w,aY as j,b0 as v,a$ as D,aZ as k}from"./vendor-.bun-CJSRTa27.js";import{u as R,c as g}from"./modelPrefsAutoSave-bm-G98P3.js";import{a as S}from"./main-BCXofLIN.js";import"./index-CQjRYgmJ.js";import"./JsonTreeView-4KDa8lGo.js";const z=x=>{const e=h.c(19),{open:m,onOpenChange:a}=x,{t:u}=R(),n=b.useId(),y=_;let s;e[0]!==a?(s=f=>{!f&&y()||a(f)},e[0]=a,e[1]=s):s=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(w,{className:g("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=g("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=d):d=e[3];let o;e[4]!==u?(o=u("settings.window.description"),e[4]=u,e[5]=o):o=e[5];let i;e[6]!==n||e[7]!==o?(i=t.jsx(j,{id:n,className:"sr-only",children:o}),e[6]=n,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==a?(l=t.jsx(S,{onClose:()=>a(!1),isWindowed:!0}),e[9]=a,e[10]=l):l=e[10];let r;e[11]!==n||e[12]!==i||e[13]!==l?(r=t.jsxs(v,{children:[c,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(D,{"aria-describedby":n,className:d,children:[i,l]})})]}),e[11]=n,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==s||e[17]!==r?(p=t.jsx(k,{open:m,onOpenChange:s,children:r}),e[15]=m,e[16]=s,e[17]=r,e[18]=p):p=e[18],p};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{z as SettingsWindow};
1
+ import{c as h,R as b,j as t,aW as w,aY as j,b0 as v,a$ as D,aZ as k}from"./vendor-.bun-BIr1wmDP.js";import{u as R,c as g}from"./modelPrefsAutoSave-D4IOtl1d.js";import{a as S}from"./main-DLomPR7m.js";import"./index-Dc1XJWqt.js";import"./JsonTreeView-YQcDxcEK.js";const z=x=>{const e=h.c(19),{open:m,onOpenChange:a}=x,{t:u}=R(),n=b.useId(),y=_;let s;e[0]!==a?(s=f=>{!f&&y()||a(f)},e[0]=a,e[1]=s):s=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(w,{className:g("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=g("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=d):d=e[3];let o;e[4]!==u?(o=u("settings.window.description"),e[4]=u,e[5]=o):o=e[5];let i;e[6]!==n||e[7]!==o?(i=t.jsx(j,{id:n,className:"sr-only",children:o}),e[6]=n,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==a?(l=t.jsx(S,{onClose:()=>a(!1),isWindowed:!0}),e[9]=a,e[10]=l):l=e[10];let r;e[11]!==n||e[12]!==i||e[13]!==l?(r=t.jsxs(v,{children:[c,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(D,{"aria-describedby":n,className:d,children:[i,l]})})]}),e[11]=n,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==s||e[17]!==r?(p=t.jsx(k,{open:m,onOpenChange:s,children:r}),e[15]=m,e[16]=s,e[17]=r,e[18]=p):p=e[18],p};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{z as SettingsWindow};
@@ -0,0 +1 @@
1
+ import{R as n,j as c,x as yt,bu as ht,bv as bt,bw as gt}from"./vendor-.bun-BIr1wmDP.js";import{u as dt,v as xt,b0 as vt,c as Xe,M as Tt,bI as kt,eN as Ct,a as Se,b as Et,V as ft,bh as Rt,I as oe,eO as Ze,cx as ct,as as Q}from"./modelPrefsAutoSave-D4IOtl1d.js";import{u as Z,P as At,S as St}from"./main-DLomPR7m.js";import{a4 as It}from"./index-Dc1XJWqt.js";import"./JsonTreeView-YQcDxcEK.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,J,we=!1){const Me=`${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:Me,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:J,disableStdin:we}}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 J of p){const Ie=window.getComputedStyle(J).overflowY;if(!(Ie!=="auto"&&Ie!=="scroll")){if(J.scrollHeight-J.clientHeight>2)return J;m||(m=J)}}return m}const pt=n.forwardRef(({sessionKey:f,chunks:p,onInput:m,onResize:J,theme:we,fontFamily:Ie,fontSize:Me,className:Be,enableTouchScroll:R,autoFocus:Je=!0,isVisible:De=!0},ge)=>{const{t:W}=dt(),V=n.useRef(null),Ne=n.useRef(null),M=n.useRef(null),Ue=n.useRef(null),F=n.useRef(m),He=n.useRef(J),v=n.useRef(null),xe=n.useRef(""),ee=n.useRef(null),Pe=n.useRef(!1),Ve=n.useRef(null),ye=n.useRef(!0),te=n.useRef(null),X=n.useRef(null),ve=n.useRef(0),ne=n.useRef(null),ze=n.useRef(null),ae=n.useRef(!1),C=n.useRef(!1),A=n.useRef(null),he=n.useRef(null),je=n.useRef(null),L=n.useRef(""),Fe=n.useRef(null),Te=n.useRef(!R),_e=n.useRef(De),[,et]=n.useReducer(e=>e+1,0),[qe,z]=n.useReducer(e=>e+1,0);F.current=m,He.current=J;const at=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),h=!!R;n.useEffect(()=>{if(!R){Te.current=!0,_e.current=De;return}!_e.current&&De&&(Te.current=!1),_e.current=De},[R,De]);const ke=n.useCallback(()=>{if(!h)return;const e=V.current,o=ne.current;if(!e)return;const i=[];e.getAttribute("contenteditable")==="true"&&i.push(e),i.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),i.forEach(s=>{s.setAttribute("data-terminal-disabled-contenteditable","true"),s.setAttribute("contenteditable","false"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.setProperty("caret-color","transparent"),s.style.color="transparent",s.style.setProperty("-webkit-text-fill-color","transparent"),s.style.background="transparent",s.style.outline="none",s.style.boxShadow="none",s.style.textShadow="none",s.style.setProperty("user-select","none"),s.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(s=>{s.style.setProperty("caret-color","transparent"),s.style.color="transparent",s.style.setProperty("-webkit-text-fill-color","transparent"),s.style.background="transparent",s.style.border="0",s.style.outline="none",s.style.boxShadow="none",s.style.textShadow="none",s.style.fontSize="0",s.style.lineHeight="0",s!==o&&s.getAttribute("data-terminal-disabled-input")!=="true"&&(s.setAttribute("data-terminal-disabled-input","true"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.disabled=!0,s.style.position="absolute",s.style.opacity="0",s.style.width="0px",s.style.height="0px",s.style.pointerEvents="none",s.style.zIndex="-1")})},[h]),S=n.useCallback(e=>{if(Fe.current===e)return;const o=M.current;if(o)try{if(typeof o.setOption=="function"){o.setOption("cursorBlink",e),Fe.current=e;return}o.options&&(o.options.cursorBlink=e,Fe.current=e)}catch{}},[]),D=h&&at,E=n.useCallback((e,o)=>{const i=D?ze.current:ne.current,d=V.current;if(!i||!d)return;const s=d.getBoundingClientRect(),k=typeof window<"u"?window.innerWidth:s.width,I=typeof window<"u"?window.innerHeight:s.height,N=s.left+s.width/2,Y=s.top+s.height-12,l=typeof e=="number"?e:N,B=typeof o=="number"?o:Y,T=8,U=Math.max(T,Math.min(k-T,l)),be=Math.max(T,Math.min(I-T,B));i.style.left=`${U}px`,i.style.top=`${be}px`,i.style.bottom="",(i instanceof HTMLTextAreaElement||i instanceof HTMLInputElement)&&(i.disabled=!1,i.readOnly=!1,i.removeAttribute("disabled"),i.removeAttribute("readonly"));try{i.focus({preventScroll:!0})}catch{try{i.focus()}catch{}}},[D]),Ce=n.useCallback(()=>{if(h){E(),S(!0);return}M.current?.focus(),S(!0)},[E,S,h]),ce=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),q=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),le=n.useCallback(e=>{if(typeof window>"u"||D)return;je.current!==null&&(window.clearTimeout(je.current),je.current=null);let o=0;const i=3,d=()=>{je.current=window.setTimeout(()=>{je.current=null;const s=ce(e);if(!s){if(o+=1,o<i){d();return}return}const k=L.current;L.current=s;const I=s.startsWith(k)?s.slice(k.length):s;I&&F.current(I.replace(/\r\n|\r|\n/g,"\r")),q(e),L.current=""},o===0?0:24)};d()},[q,ce,D]);n.useEffect(()=>{const e=V.current;if(!h||!e||R)return;const o=i=>{const d=i.target;if(d&&d.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(d)){try{d.blur()}catch{}E()}};return e.addEventListener("focusin",o,!0),()=>{e.removeEventListener("focusin",o,!0)}},[R,h,E]);const Le=n.useCallback(()=>{const e=M.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 i=V.current;if(!i)return"";const d=e.anchorNode,s=e.focusNode;return d&&!i.contains(d)||s&&!i.contains(s)?"":o},[]),fe=n.useCallback(async()=>{if(typeof document>"u")return;const e=Le()||ue();e.trim()&&await xt(e)},[ue,Le]),$=n.useCallback(()=>Le().trim()?!0:!!ue().trim(),[ue,Le]);n.useEffect(()=>{if(typeof window>"u")return;const e=o=>{$()&&(o.preventDefault(),fe())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[fe,$]);const re=n.useCallback(()=>{xe.current="",ee.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(ee.current),ee.current=null,Pe.current=!1,Ve.current=null},[]),G=n.useCallback(()=>{const e=Ue.current,o=M.current,i=V.current;if(!e||!o||!i)return;const d=i.getBoundingClientRect();if(!(d.width<24||d.height<24))try{e.fit();const s={cols:o.cols,rows:o.rows},k=v.current;(!k||k.cols!==s.cols||k.rows!==s.rows)&&(v.current=s,He.current(s.cols,s.rows))}catch{}},[]),Ee=n.useCallback(()=>{if(Pe.current)return;const e=M.current;if(!e){re();return}if(!xe.current)return;const o=xe.current;xe.current="",Pe.current=!0,e.write(o,()=>{Pe.current=!1,xe.current&&(typeof window<"u"?ee.current=window.requestAnimationFrame(()=>{ee.current=null,Ee()}):Ee())})},[re]),Ke=n.useCallback(()=>{ee.current===null&&(typeof window<"u"?ee.current=window.requestAnimationFrame(()=>{ee.current=null,Ee()}):Ee())},[Ee]),$e=n.useCallback(e=>{e&&(xe.current+=e,Ke())},[Ke]),se=n.useCallback(()=>{if(te.current?.(),te.current=null,X.current!==null&&typeof window<"u"&&(window.clearTimeout(X.current),X.current=null),!R){ve.current=0;return}const e=V.current;if(!e)return;const o=M.current;if(!o)return;ve.current=0;const i=2.2,d=2.8,s=25,k=.25,I=8,N=.05,Y=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},B=()=>typeof performance<"u"?performance.now():Date.now(),T=Math.max(12,Math.round(Me*1.35));let U=0;const be=r=>{if(!r)return!1;const w=o.getViewportY(),b=U+r,g=Math.trunc(b/T);return U=b-g*T,g!==0&&o.scrollLines(g),o.getViewportY()!==w},O=()=>{l.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(l.rafId),l.rafId=null},y={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const r=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),w=6,b=x=>{if(x.pointerType==="touch"){O(),r.pointerId=x.pointerId,r.startX=x.clientX,r.startY=x.clientY,r.moved=!1,r.lastY=x.clientY,r.lastTime=B(),r.velocity=0;try{e.setPointerCapture(x.pointerId)}catch{}}},g=x=>{if(x.pointerType!=="touch"||r.pointerId!==x.pointerId)return;if(r.startX!==null&&r.startY!==null&&!r.moved){const mt=x.clientX-r.startX,wt=x.clientY-r.startY;Math.hypot(mt,wt)>=w&&(r.moved=!0)}if(r.lastY===null){r.lastY=x.clientY,r.lastTime=B();return}const pe=r.lastY,me=r.lastTime??B(),j=B();r.lastY=x.clientY,r.lastTime=j;const ie=pe-x.clientY;if(Math.abs(ie)<1)return;const Oe=Math.max(j-me,8),Qe=i+Math.min(d,Math.abs(ie)/s),ot=ie*Qe,st=ot/Oe;r.velocity=r.velocity*(1-k)+st*k,r.velocity>I?r.velocity=I:r.velocity<-I&&(r.velocity=-I),r.moved&&(x.cancelable&&x.preventDefault(),x.stopPropagation()),be(ot)},H=x=>{if(x.pointerType!=="touch"||r.pointerId!==x.pointerId)return;const pe=!r.moved;r.pointerId=null,r.startX=null,r.startY=null,r.moved=!1,r.lastY=null,r.lastTime=null;try{e.releasePointerCapture(x.pointerId)}catch{}if(pe){h?E(x.clientX,x.clientY):R&&!Te.current&&(Te.current=!0,M.current?.focus());return}if(typeof window>"u")return;if(Math.abs(r.velocity)<N){r.velocity=0;return}let me=B();const j=()=>{const ie=B(),Oe=Math.max(ie-me,8);me=ie;const Qe=be(r.velocity*Oe)??!1,ot=Math.sign(r.velocity),st=Math.max(0,Math.abs(r.velocity)-Y*Oe);if(r.velocity=st*ot,!Qe||st<=N){O(),r.velocity=0;return}r.rafId=window.requestAnimationFrame(j)};r.rafId=window.requestAnimationFrame(j)};e.addEventListener("pointerdown",b,y),e.addEventListener("pointermove",g,y),e.addEventListener("pointerup",H,y),e.addEventListener("pointercancel",H,y);const _=e.style.touchAction;e.style.touchAction="manipulation",te.current=()=>{O(),X.current!==null&&typeof window<"u"&&(window.clearTimeout(X.current),X.current=null),ve.current=0,e.removeEventListener("pointerdown",b,y),e.removeEventListener("pointermove",g,y),e.removeEventListener("pointerup",H,y),e.removeEventListener("pointercancel",H,y),e.style.touchAction=_};return}const Re=6,Ae=r=>{r.touches.length===1&&(O(),l.lastY=r.touches[0].clientY,l.lastTime=B(),l.velocity=0,l.startX=r.touches[0].clientX,l.startY=r.touches[0].clientY,l.didMove=!1)},t=r=>{if(r.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,O();return}const w=r.touches[0].clientX,b=r.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){const Oe=w-l.startX,Qe=b-l.startY;Math.hypot(Oe,Qe)>=Re&&(l.didMove=!0)}if(l.lastY===null){l.lastY=b,l.lastTime=B();return}const g=l.lastY,H=l.lastTime??B(),_=B();l.lastY=b,l.lastTime=_;const x=g-b;if(Math.abs(x)<1)return;const pe=Math.max(_-H,8),me=i+Math.min(d,Math.abs(x)/s),j=x*me,ie=j/pe;l.velocity=l.velocity*(1-k)+ie*k,l.velocity>I?l.velocity=I:l.velocity<-I&&(l.velocity=-I),l.didMove&&(r.preventDefault(),r.stopPropagation()),be(j)},u=r=>{const w=!l.didMove;l.lastY=null,l.lastTime=null;const b=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,w){const _=r.changedTouches?.[0];h?E(_?.clientX,_?.clientY):R&&!Te.current&&(Te.current=!0,M.current?.focus());return}if(typeof window>"u")return;if(Math.abs(b)<N){l.velocity=0;return}let g=B();const H=()=>{const _=B(),x=Math.max(_-g,8);g=_;const pe=be(l.velocity*x)??!1,me=Math.sign(l.velocity),j=Math.max(0,Math.abs(l.velocity)-Y*x);if(l.velocity=j*me,!pe||j<=N){O(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(H)};l.rafId=window.requestAnimationFrame(H)};e.addEventListener("touchstart",Ae,y),e.addEventListener("touchmove",t,y),e.addEventListener("touchend",u,y),e.addEventListener("touchcancel",u,y);const a=e.style.touchAction;e.style.touchAction="manipulation",te.current=()=>{O(),X.current!==null&&typeof window<"u"&&(window.clearTimeout(X.current),X.current=null),ve.current=0,e.removeEventListener("touchstart",Ae,y),e.removeEventListener("touchmove",t,y),e.removeEventListener("touchend",u,y),e.removeEventListener("touchcancel",u,y),e.style.touchAction=a}},[R,h,E,Me]);n.useEffect(()=>{let e=!1,o=null,i=null,d=null,s=[],k=null,I=null;const N=V.current;if(!N)return;if(N.tabIndex=h?-1:0,h){const O=N.focus.bind(N),y=N;y.focus=((...P)=>{E()}),I=()=>{y.focus=O}}const Y=()=>{S(!0)},l=()=>{S(!1)},B=O=>{const y=O.target;if(y&&N.contains(y)){if(h&&y instanceof HTMLElement){window.setTimeout(()=>{y.blur(),E()},0),S(!1);return}if(R&&!Te.current&&y instanceof HTMLElement){window.setTimeout(()=>{y.blur()},0),S(!1);return}S(!0);return}S(!1)},T=()=>{S(!1)};let U=null;return(async()=>{try{const O=await Dt();if(e)return;const y=Bt(Ie,Me,we,O,!1),P=new ht(y);ye.current=!0,h&&(P.focus=()=>{});const Re=P;if(typeof Re.scrollToBottom=="function"){const a=Re.scrollToBottom.bind(Re);Re.scrollToBottom=()=>{ye.current&&a()},k=()=>{Re.scrollToBottom=a}}const Ae=new bt;o=P,M.current=P,Ue.current=Ae,P.loadAddon(Ae),P.open(N),z(),Fe.current=!1,U=P.textarea??N.querySelector("textarea"),U&&(U.addEventListener("focus",Y),U.addEventListener("blur",l)),ke(),typeof MutationObserver<"u"&&(d=new MutationObserver(()=>{ke()}),d.observe(N,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const t=Nt(N);t?(t.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),Ne.current=t,et()):Ne.current=null,G();const u=Ae;typeof u.observeResize=="function"&&u.observeResize(),se(),s=[P.onData(a=>{F.current(a)}),P.onScroll(a=>{if(typeof a=="number"&&Number.isFinite(a)){const r=typeof P.hasSelection=="function"&&P.hasSelection();ye.current=!r&&a<=.5}}),P.onSelectionChange(()=>{if(typeof P.hasSelection=="function"&&P.hasSelection()){ye.current=!1;return}const r=typeof P.getViewportY=="function"?P.getViewportY():0;ye.current=r<=.5})],i=new ResizeObserver(()=>{G()}),i.observe(N),typeof window<"u"&&window.setTimeout(()=>{G()},0)}catch{}})(),document.addEventListener("focusin",B,!0),window.addEventListener("blur",T),()=>{e=!0,te.current?.(),te.current=null,document.removeEventListener("focusin",B,!0),window.removeEventListener("blur",T),s.forEach(O=>O.dispose()),k?.(),k=null,U&&(U.removeEventListener("focus",Y),U.removeEventListener("blur",l)),i?.disconnect(),d?.disconnect(),I?.(),o?.dispose(),M.current=null,Ue.current=null,Ne.current=null,v.current=null,Fe.current=null,re()}},[ke,R,G,E,Ie,Me,se,we,re,S,h]),n.useEffect(()=>{const e=M.current;e&&(e.reset(),re(),v.current=null,G())},[f,qe,G,re]),n.useEffect(()=>{!Je||!M.current||Ce()},[Je,Ce,f,qe]),n.useEffect(()=>(se(),()=>{te.current?.(),te.current=null}),[se,f]),n.useEffect(()=>{const e=M.current;if(!e)return;if(p.length===0){Ve.current!==null&&(e.reset(),re(),G());return}const o=Ve.current;let i;if(o===null)i=p;else{const d=p.findIndex(s=>s.id===o);i=d>=0?p.slice(d+1):p}i.length>0&&$e(i.map(d=>d.data).join("")),Ve.current=p[p.length-1].id},[p,qe,$e,G,re]),n.useImperativeHandle(ge,()=>({focus:()=>{Ce()},clear:()=>{const e=M.current;e&&(e.reset(),re(),G())},fit:()=>{G()}}),[Ce,G,re]);const de=n.useCallback(e=>{if(!h)return;const o=V.current,i=e.relatedTarget,d=i?.tagName,s=d==="INPUT"||d==="TEXTAREA"||i?.isContentEditable,k=i?.getAttribute("data-terminal-hidden-input")==="true",I=!!(i&&o?.contains(i))},[h]),tt=n.useCallback(e=>{const o=e.nativeEvent,i=o?.inputType??"",d=typeof o?.data=="string"?o.data:"";if(he.current=typeof performance<"u"?performance.now():Date.now(),i==="insertCompositionText"){ae.current=!0;return}if(!i&&d){if(ae.current)return;e.preventDefault(),F.current(d),A.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},C.current=!0;return}if(i==="insertText"&&d){if(ae.current)return;e.preventDefault(),F.current(d),A.current={type:i,at:typeof performance<"u"?performance.now():Date.now()},C.current=!0;return}if(i==="insertLineBreak"){if(ae.current)return;e.preventDefault(),F.current("\r"),A.current={type:i,at:typeof performance<"u"?performance.now():Date.now()},C.current=!0;return}if(i==="deleteContentBackward"){if(ae.current)return;e.preventDefault(),F.current(""),A.current={type:i,at:typeof performance<"u"?performance.now():Date.now()},C.current=!0}},[]),Ye=n.useCallback(e=>{const o=e.currentTarget;if(he.current=typeof performance<"u"?performance.now():Date.now(),ae.current)return;if(C.current){const s=A.current,k=typeof performance<"u"?performance.now():Date.now();if(s&&k-s.at<50){C.current=!1,q(o);return}C.current=!1}const i=ce(o);if(!i)return;L.current=i;const d=i.replace(/\r\n|\r|\n/g,"\r");F.current(d),q(o),L.current=""},[q,ce]),nt=n.useCallback(e=>{e.stopPropagation();const o=e.key.toLowerCase(),i=e.metaKey&&!e.ctrlKey&&!e.altKey&&o==="c",d=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&o==="c";if((i||d)&&$()){e.preventDefault(),fe();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const T=e.key.toUpperCase();if(T>="A"&&T<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),F.current(String.fromCharCode(T.charCodeAt(0)-64)),q(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),F.current("\x1B"+e.key),q(e.currentTarget);return}const k={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(k){e.preventDefault(),F.current(k),q(e.currentTarget);return}const I=e.currentTarget;if(e.nativeEvent?.isComposing)return;const Y=A.current,l=typeof performance<"u"?performance.now():Date.now(),B=!!(Y&&l-Y.at<50);if(e.key==="Enter"){if(B&&Y?.type==="insertLineBreak")return;e.preventDefault(),F.current("\r"),q(I);return}if(e.key==="Backspace"){if(e.preventDefault(),B&&Y?.type==="deleteContentBackward")return;ce(I)||F.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const T=he.current;T&&l-T<50||(e.preventDefault(),F.current(e.key),C.current=!0,A.current={type:"keydown-text",at:l})}le(I)},[q,fe,$,ce,le]),rt=n.useCallback(e=>{e.stopPropagation();const o=e.currentTarget;e.nativeEvent?.isComposing||le(o)},[le]),Ge=n.useCallback(e=>{const o=e.currentTarget;ae.current=!1;const i=e.data||ce(o);if(he.current=typeof performance<"u"?performance.now():Date.now(),!i)return;const d=i.replace(/\r\n|\r|\n/g,"\r");F.current(d),q(o),A.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},C.current=!0},[q,ce]),K=n.useCallback(e=>{e.stopPropagation();const o=e.clipboardData?.getData("text")??"";if(!o)return;e.preventDefault();const d=M.current?.hasBracketedPaste?.()?`\x1B[200~${o}\x1B[201~`:o;F.current(d)},[]),We={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 c.jsxs("div",{ref:V,className:Xe("relative h-full w-full terminal-viewport-container",Be),"data-hidden-input-overlay-active":h?"true":void 0,style:{backgroundColor:we.background},onTouchStart:e=>{if(!(!h||R)&&!$()){const o=e.touches?.[0];E(o?.clientX,o?.clientY)}},onClick:e=>{if(!R)if(h){if($())return;E(e.clientX,e.clientY)}else M.current?.focus()},onMouseUp:()=>{!R&&$()&&fe()},onTouchEnd:()=>{!R&&$()&&fe()},children:[h&&typeof document<"u"?yt.createPortal(c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ze,type:"text",inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":W("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...We,display:D?"block":"none"},onBlur:de,onBeforeInput:tt,onCompositionStart:()=>{ae.current=!0},onInput:Ye,onKeyDown:nt,onKeyUp:rt,onCompositionEnd:Ge,onPaste:K}),c.jsx("textarea",{ref:ne,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":W("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...We,display:D?"none":"block"},onBlur:de,onBeforeInput:tt,onCompositionStart:()=>{ae.current=!0},onInput:Ye,onKeyDown:nt,onKeyUp:rt,onCompositionEnd:Ge,onPaste:K})]}),document.body):null,Ne.current&&!R?c.jsx(vt,{containerRef:Ne,disableHorizontal:!0,className:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero"}):null]})});pt.displayName="TerminalViewport";const Pt={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},Vt={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 Pt[f]??null},Ht=()=>{const{t:f}=dt(),{terminal:p,runtime:m}=Tt(),{currentTheme:J}=kt(),{monoFont:we}=Ct(),Ie=Se(t=>t.terminalFontSize),Me=Se(t=>t.bottomTerminalHeight),Be=Se(t=>t.isBottomTerminalExpanded),{isMobile:R,isTablet:Je,hasTouchOnlyPointer:De}=Et(),ge=R||Je,W=(ge||De)&&m.platform==="web",V=m.platform!=="vscode",Ne=Se(t=>t.showTerminalQuickKeysOnDesktop),M=ge||Ne,Ue=ft(t=>t.currentSessionId),F=ft(t=>t.newSessionDraft),He=Ue!==null||F?.open===!0,v=Rt()??null,xe=Z(t=>t.sessions),ee=Z(t=>t.hasHydrated),Pe=Z(t=>t.ensureDirectory),Ve=Z(t=>t.createTab),ye=Z(t=>t.setActiveTab),te=Z(t=>t.closeTab),X=Z(t=>t.setTabSessionId),ve=Z(t=>t.setTabLifecycle),ne=Z(t=>t.setConnecting),ze=Z(t=>t.appendToBuffer),ae=Se(t=>t.openContextPreview),C=n.useMemo(()=>{if(v)return xe.get(v)},[xe,v]),A=n.useMemo(()=>C?V?C.activeTabId??C.tabs[0]?.id??null:C.tabs[0]?.id??null:null,[C,V]),he=n.useMemo(()=>{if(C)return A?C.tabs.find(t=>t.id===A)??C.tabs[0]:C.tabs[0]},[C,A]),je=n.useMemo(()=>(C?.tabs??[]).map(t=>({icon:(()=>{const u=t.iconKey?At[t.iconKey]??"terminal":"terminal";return c.jsx(oe,{name:u,className:"h-4 w-4"})})(),id:t.id,label:t.label,title:t.label,closeLabel:f("terminalView.tabs.closeTabTitle")})),[C?.tabs,f]),L=he?.terminalSessionId??null,Fe=he?.lifecycle??"idle",Te=he?.bufferChunks??[],_e=he?.isConnecting??!1,et=he?.previewUrl??null,[qe,z]=n.useState(null),[at,h]=n.useState(!1),[ke,S]=n.useState(!1),[D,E]=n.useState(null),[Ce,ce]=n.useState(!1),q=n.useRef(null),le=n.useRef(null),Le=n.useRef(A),ue=n.useRef(L),fe=n.useRef(v),$=n.useRef(null),re=n.useRef(null),G=n.useRef(!1),Ee=n.useRef(null),Ke=n.useRef(new Set),$e=n.useRef(!1),se=n.useCallback(()=>{W||typeof document<"u"&&!document.hasFocus()||$.current?.focus()},[W]),de=n.useCallback(()=>{W||$.current?.focus()},[W]);n.useEffect(()=>{if(!ee||$e.current)return;$e.current=!0;const t=new Set;for(const[,u]of Z.getState().sessions.entries())for(const a of u.tabs)a.terminalSessionId&&t.add(a.terminalSessionId);Ke.current=t},[ee]);const tt=Se(t=>t.activeMainTab),Ye=Se(t=>t.isBottomTerminalOpen),nt=Se(t=>t.setBottomTerminalOpen),rt=Se(t=>t.setBottomTerminalExpanded),Ge=tt==="terminal",K=Ge||Ye,[We,e]=n.useState(K);n.useEffect(()=>{!K||m.platform==="vscode"||It()},[K,m.platform]),n.useEffect(()=>{K&&e(!0)},[K]),n.useEffect(()=>{G.current=K},[K]),n.useEffect(()=>{ue.current=L},[L]),n.useEffect(()=>{Le.current=A},[A]),n.useEffect(()=>{fe.current=v},[v]),n.useEffect(()=>{!M&&D!==null&&E(null)},[M,D,E]),n.useEffect(()=>{!L&&D!==null&&E(null)},[L,D,E]);const o=n.useCallback(()=>{q.current?.(),q.current=null,le.current=null,S(!1)},[]);n.useEffect(()=>()=>{o(),ue.current=null},[o]);const i=n.useCallback((t,u,a,r=ut)=>{if(le.current===a)return;o(),le.current=a;const w=p.connect(a,{onEvent:b=>{if(le.current===a)switch(b.type){case"connected":{ne(t,u,!1),z(null),h(!1),S(!1),se(),Ee.current===a&&(Ee.current=null,p.sendInput(a,"\r").catch(()=>{}));break}case"reconnecting":{z(null),h(!1),S(!0);break}case"data":{b.data&&ze(t,u,b.data);break}case"exit":{const g=typeof b.exitCode=="number"?b.exitCode:null,H=typeof b.signal=="number"?b.signal:null,x=!!Z.getState().getDirectoryState(t)?.tabs.find(pe=>pe.id===u)?.label?.startsWith("Action:");ze(t,u,f("terminalView.stream.processExitedMessage",{exitCodeSegment:g!==null?f("terminalView.stream.processExitedWithCode",{exitCode:g}):"",signalSegment:H!==null?f("terminalView.stream.processExitedWithSignal",{signal:H}):""})),ve(t,u,"exited"),X(t,u,null),ne(t,u,!1),z(x?null:f("terminalView.error.sessionEnded")),h(!1),S(!1),o();break}}},onError:(b,g)=>{if(le.current===a){if(!g){z(null),h(!1);return}S(!1),z(f("terminalView.error.connectionFailed",{message:b.message})),h(!0),ne(t,u,!1),ve(t,u,"exited"),X(t,u,null),o()}}},r);q.current=()=>{w.close(),le.current=null}},[ze,o,se,ne,ve,X,f,p]);n.useEffect(()=>{let t=!1;if(!ee||!We)return;if(!v){z(f(He?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),o();return}return(async()=>{const a=v;if(!fe.current||fe.current!==a)return;Pe(a);const r=Z.getState().getDirectoryState(a);if(!r||r.tabs.length===0)return;const w=V?r.activeTabId??r.tabs[0]?.id??null:r.tabs[0]?.id??null;if(!w)return;const b=r.tabs.find(j=>j.id===w)??r.tabs[0];let g=b?.terminalSessionId??null;const H=b?.lifecycle??"idle",_=!!b?.label?.startsWith("Action:"),x=(b?.bufferLength??0)>0||(b?.bufferChunks?.length??0)>0,pe=!!g&&Ke.current.has(g)&&(b?.bufferLength??0)===0&&(b?.bufferChunks?.length??0)===0,me=!!g&&Ke.current.has(g);if(!g){if(H==="exited"){ne(a,w,!1);return}if(_&&x){ne(a,w,!1);return}z(null),h(!1),S(!1),ne(a,w,!0);try{const j=re.current,ie=await p.createSession({cwd:a,cols:j?.cols,rows:j?.rows});if(!(!t&&fe.current===a&&Le.current===w)){try{await p.close(ie.sessionId)}catch{}return}X(a,w,ie.sessionId),g=ie.sessionId}catch(j){t||(z(j instanceof Error?j.message:f("terminalView.error.startSessionFailed")),h(!0),S(!1),ne(a,w,!1));return}}!g||t||(ue.current=g,me&&Ke.current.delete(g),pe&&(Ee.current=g),i(a,w,g,me?Vt:ut))})(),()=>{t=!0,ue.current=null,o()}},[He,v,L,Fe,A,We,V,ee,Pe,ne,ve,X,i,o,f,p]),n.useEffect(()=>{if(!K||W)return;if(typeof window>"u"){se();return}const t=window.requestAnimationFrame(()=>{se()});return()=>{window.cancelAnimationFrame(t)}},[A,se,K,W]);const d=n.useCallback(async()=>{if(!v||Ce)return;const t=Z.getState().getDirectoryState(v),u=V?A??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(u){ce(!0),z(null),h(!1),S(!1),o();try{await te(v,u)}catch(a){z(a instanceof Error?a.message:f("terminalView.error.restartFailed")),h(!0),S(!1)}finally{ce(!1)}}},[A,te,o,v,V,Ce,f]),s=n.useCallback(async()=>{await d()},[d]),k=n.useCallback(()=>{if(!v)return;const t=Ve(v);ye(v,t),z(null),h(!1),S(!1),o()},[Ve,o,v,ye]),I=n.useCallback(t=>{v&&(ye(v,t),z(null),h(!1),S(!1),o())},[o,v,ye]),N=n.useCallback(t=>{v&&(t===A&&o(),z(null),h(!1),S(!1),te(v,t))},[A,te,o,v]),Y=n.useCallback(t=>{if(!t||ke)return;let u=t,a=!1;if(D&&t.length>0){const w=t[0];if(w.length===1&&/[a-zA-Z]/.test(w)){const b=w.toUpperCase();(D==="ctrl"||D==="cmd")&&(u=String.fromCharCode(b.charCodeAt(0)&31),a=!0)}a||(a=!0)}const r=ue.current;r&&(p.sendInput(r,u).catch(w=>{ke||z(w instanceof Error?w.message:f("terminalView.error.sendInputFailed"))}),a&&(E(null),de()))},[D,de,ke,E,f,p]),l=n.useCallback((t,u)=>{if(re.current={cols:t,rows:u},!G.current)return;const a=ue.current;a&&p.resize({sessionId:a,cols:t,rows:u}).catch(()=>{})},[p]),B=n.useCallback(t=>{E(u=>u===t?null:t),de()},[de,E]),T=n.useCallback(t=>{const u=jt(t,D);u&&(Y(u),E(null),de())},[D,de,Y,E]);n.useEffect(()=>{if(!M||!D||!L)return;const t=u=>{if(u.repeat)return;const a=u.key;if(!a||a==="Control"||a==="Meta"||a==="Alt"||a==="Shift")return;const r=a.length===1?a.toLowerCase():a,w=u.code??"",b=w.startsWith("Key")&&w.length===4?w.slice(3).toUpperCase():null,g=a.length===1&&/[a-zA-Z]/.test(a)?a.toUpperCase():b,H={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(r in H){u.preventDefault(),u.stopPropagation(),T(H[r]);return}if(D==="ctrl"&&g&&g.length===1&&g>="A"&&g<="Z"){const _=String.fromCharCode(g.charCodeAt(0)&31);u.preventDefault(),u.stopPropagation(),Y(_),E(null),de()}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[D,T,Y,de,M,E,L]);const U=n.useMemo(()=>{const t=Ze[ct].stack;if(typeof window>"u")return(Ze[we]??Ze[ct]).stack;const a=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return a&&a.trim().length>0?a.trim():(Ze[we]??Ze[ct]).stack??t},[we]),be=n.useMemo(()=>Mt(J),[J]),O=n.useMemo(()=>`${v??"no-dir"}::${A??"no-tab"}::${L??"no-terminal"}`,[v,A,L]);if(n.useEffect(()=>{if(!K||W)return;const t=$.current;if(!t)return;const u=()=>{t.fit()};if(typeof window<"u"){const a=window.requestAnimationFrame(()=>{u(),se()}),r=[220,400].map(w=>window.setTimeout(u,w));return()=>{window.cancelAnimationFrame(a),r.forEach(w=>window.clearTimeout(w))}}u()},[se,K,W,O,L]),n.useEffect(()=>{if(W||!K||!Ye)return;const t=$.current;if(!t)return;const u=()=>{t.fit()};if(typeof window<"u"){const a=window.requestAnimationFrame(()=>{u()}),r=[0,80,180,320].map(w=>window.setTimeout(u,w));return()=>{window.cancelAnimationFrame(a),r.forEach(w=>window.clearTimeout(w))}}u()},[Me,Be,Ye,K,W]),!He)return c.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(!v)return c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[c.jsx("p",{children:f("terminalView.empty.noWorkingDirectoryForSession")}),c.jsx("button",{onClick:d,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 y=!L||_e||Ce||ke,P=We,Re=!ge&&Ye&&!Ge,Ae=c.jsxs(c.Fragment,{children:[c.jsx(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>T("esc"),disabled:y,children:f("terminalView.quickKeys.escape")}),c.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>T("tab"),disabled:y,children:[c.jsx(oe,{name:"arrow-right",className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.tabAria")})]}),c.jsxs(Q,{type:"button",size:"sm",variant:"chip","aria-pressed":D==="ctrl",className:"h-6 w-9 p-0",onClick:()=>B("ctrl"),disabled:y,children:[c.jsx("span",{className:"text-xs font-medium",children:f("terminalView.quickKeys.controlLabel")}),c.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.controlModifierAria")})]}),c.jsxs(Q,{type:"button",size:"sm",variant:"chip","aria-pressed":D==="cmd",className:"h-6 w-9 p-0",onClick:()=>B("cmd"),disabled:y,children:[c.jsx(oe,{name:"command"}),c.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.commandModifierAria")})]}),c.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>T("arrow-up"),disabled:y,children:[c.jsx(oe,{name:"arrow-up"}),c.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowUpAria")})]}),c.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>T("arrow-left"),disabled:y,children:[c.jsx(oe,{name:"arrow-left"}),c.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowLeftAria")})]}),c.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>T("arrow-down"),disabled:y,children:[c.jsx(oe,{name:"arrow-down"}),c.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowDownAria")})]}),c.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>T("arrow-right"),disabled:y,children:[c.jsx(oe,{name:"arrow-right"}),c.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowRightAria")})]}),c.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>T("enter"),disabled:y,children:[c.jsx(oe,{name:"arrow-go-back"}),c.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.enterAria")})]})]});return c.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[c.jsxs("div",{className:Xe("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",ge?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[V&&C?c.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[c.jsx("div",{className:Xe("min-w-0 flex-1",ge?"h-8":"h-7"),children:c.jsx(St,{items:je,activeId:A,onSelect:I,onClose:N,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),c.jsx(Q,{type:"button",size:"xs",variant:"ghost",className:Xe("shrink-0",ge?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:k,title:f("terminalView.tabs.newTabTitle"),children:c.jsx(oe,{name:"add",className:`${ge?"h-[18px] w-[18px]":"h-4 w-4"}`})}),c.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[et?c.jsxs(Q,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{v&&ae(v,et)},title:f("terminalView.preview.openTitle"),children:[c.jsx(oe,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"whitespace-nowrap",children:f("terminalView.preview.open")})]}):null,Re?c.jsxs(c.Fragment,{children:[c.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:()=>rt(!Be),className:Xe("shrink-0 p-0",R?"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?c.jsx(oe,{name:"fullscreen-exit",className:"h-4 w-4"}):c.jsx(oe,{name:"fullscreen",className:"h-4 w-4"})}),c.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:()=>nt(!1),className:Xe("shrink-0 p-0",R?"h-8 w-8":"h-7 w-7"),title:f("terminalView.bottomDock.closeTitle"),"aria-label":f("terminalView.bottomDock.closeAria"),children:c.jsx(oe,{name:"close",className:"h-4 w-4"})})]}):null]})]}):null,!R&&M&&V&&C?c.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:Ae}):null,M&&(R||!V||!C)?c.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:Ae}):null]}),c.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:be.background},children:[c.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:P?c.jsx(pt,{ref:t=>{$.current=t},sessionKey:O,chunks:Te,onInput:Y,onResize:l,theme:be,fontFamily:U,fontSize:Ie,enableTouchScroll:W,autoFocus:!W&&K,isVisible:K}):null}),!ke&&qe&&c.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:[c.jsx("span",{children:qe}),at&&R&&c.jsx(Q,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:s,disabled:Ce,title:f("terminalView.actions.hardRestartTitle"),type:"button",children:f("terminalView.actions.hardRestart")})]})]})]})};export{Ht as TerminalView};
@@ -1,4 +1,4 @@
1
- import{R as v,c as he,j as i,x as Ke,bG as Le,am as Ie,ak as He,bm as Ye,s as Fe}from"./vendor-.bun-CJSRTa27.js";import{u as Me,c as pe,I as D,bF as Xe,eV as Te,b6 as Ve,eW as Qe,eX as et,eY as tt,eZ as nt,e_ as it,be as We,e$ as st,f0 as ot,b1 as rt,b3 as Ee,f1 as at,b4 as Ce,au as lt,av as ct}from"./modelPrefsAutoSave-bm-G98P3.js";import{J as dt}from"./JsonTreeView-4KDa8lGo.js";import"./index-CQjRYgmJ.js";const ut=80,ft=20,mt=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),ht=n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${mt(e)}:${String(t)};`).join(""),pt=n=>n.split(",").map(e=>e.trim()).filter(Boolean).flatMap(e=>e.startsWith(".token")?[`.oc-virtualized-prism ${e}`]:e.startsWith("token.")?[`.oc-virtualized-prism .${e}`]:/^[a-z0-9_-]+$/i.test(e)?[`.oc-virtualized-prism .token.${e}`]:e.includes("token")?[`.oc-virtualized-prism ${e}`]:[]),gt=n=>{const e=[];return Object.entries(n).forEach(([t,a])=>{const l=pt(t);if(l.length===0)return;const o=ht(a);o&&e.push(`${l.join(",")}{${o}}`)}),e.join(`
1
+ import{R as v,c as he,j as i,w as Ke,bF as Le,am as Ie,ak as He,bl as Ye,x as Fe}from"./vendor-.bun-BIr1wmDP.js";import{u as Me,c as pe,I as D,bG as Xe,eU as Te,b7 as Ve,eV as Qe,eW as et,eX as tt,eY as nt,eZ as it,bf as We,e_ as st,e$ as ot,b2 as rt,b4 as Ee,f0 as at,b5 as Ce,at as lt,au as ct}from"./modelPrefsAutoSave-D4IOtl1d.js";import{J as dt}from"./JsonTreeView-YQcDxcEK.js";import"./index-Dc1XJWqt.js";const ut=80,ft=20,mt=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),ht=n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${mt(e)}:${String(t)};`).join(""),pt=n=>n.split(",").map(e=>e.trim()).filter(Boolean).flatMap(e=>e.startsWith(".token")?[`.oc-virtualized-prism ${e}`]:e.startsWith("token.")?[`.oc-virtualized-prism .${e}`]:/^[a-z0-9_-]+$/i.test(e)?[`.oc-virtualized-prism .token.${e}`]:e.includes("token")?[`.oc-virtualized-prism ${e}`]:[]),gt=n=>{const e=[];return Object.entries(n).forEach(([t,a])=>{const l=pt(t);if(l.length===0)return;const o=ht(a);o&&e.push(`${l.join(",")}{${o}}`)}),e.join(`
2
2
  `)},xt={text:"plain",plaintext:"plain",shell:"bash",sh:"bash",zsh:"bash",patch:"diff",dockerfile:"docker",js:"javascript",ts:"typescript"},wt=n=>{const e=n.toLowerCase();return xt[e]??e},bt=5e3,ye=new Map,yt=(n,e)=>{const t=wt(e),a=`${t}
3
3
  ${n}`,l=ye.get(a);if(l!==void 0)return l;const o=Le.languages[t]??Le.languages.text;if(!o){const r=Ae(n);return ye.set(a,r),r}try{const r=Le.highlight(n,o,t);if(ye.size>=bt){const s=ye.keys().next().value;typeof s=="string"&&ye.delete(s)}return ye.set(a,r),r}catch{const r=Ae(n);return ye.set(a,r),r}};function Ae(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const Ue=v.memo(n=>{const e=he.c(26),{lines:t,language:a,syntaxTheme:l,maxHeight:o,showLineNumbers:r,lineStyles:s}=n,c=o===void 0?"60vh":o,d=r===void 0?!0:r;let f;e[0]!==l?(f=gt(l),e[0]=l,e[1]=f):f=e[1];const g=f;if(!(t.length>ut)){let b;e[2]!==c?(b={maxHeight:c,overflow:"auto"},e[2]=c,e[3]=b):b=e[3];let w;e[4]!==g?(w=g?i.jsx("style",{children:g}):null,e[4]=g,e[5]=w):w=e[5];let y;if(e[6]!==a||e[7]!==s||e[8]!==t||e[9]!==d){let x;e[11]!==a||e[12]!==s||e[13]!==d?(x=(_,k)=>i.jsx(De,{line:_,language:a,showLineNumbers:d,style:s?.(_)},k),e[11]=a,e[12]=s,e[13]=d,e[14]=x):x=e[14],y=t.map(x),e[6]=a,e[7]=s,e[8]=t,e[9]=d,e[10]=y}else y=e[10];let P;return e[15]!==b||e[16]!==w||e[17]!==y?(P=i.jsxs("div",{className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:b,children:[w,y]}),e[15]=b,e[16]=w,e[17]=y,e[18]=P):P=e[18],P}let R;return e[19]!==a||e[20]!==s||e[21]!==t||e[22]!==c||e[23]!==g||e[24]!==d?(R=i.jsx(Ge,{lines:t,language:a,prismThemeCss:g,maxHeight:c,showLineNumbers:d,lineStyles:s}),e[19]=a,e[20]=s,e[21]=t,e[22]=c,e[23]=g,e[24]=d,e[25]=R):R=e[25],R});Ue.displayName="VirtualizedCodeBlock";const Ge=v.memo(({lines:n,language:e,prismThemeCss:t,maxHeight:a,showLineNumbers:l,lineStyles:o})=>{const r=v.useRef(null),s=Ke({count:n.length,getScrollElement:()=>r.current,estimateSize:()=>ft,overscan:20});return i.jsxs("div",{ref:r,className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:{maxHeight:a,overflow:"auto"},children:[t?i.jsx("style",{children:t}):null,i.jsx("div",{style:{height:`${s.getTotalSize()}px`,width:"100%",position:"relative"},children:s.getVirtualItems().map(c=>{const d=n[c.index];return i.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${c.size}px`,transform:`translateY(${c.start}px)`},children:i.jsx(De,{line:d,language:e,showLineNumbers:l,style:o?.(d)})},c.index)})})]})});Ge.displayName="VirtualizedRows";const De=v.memo(n=>{const e=he.c(15),{line:t,language:a,showLineNumbers:l,style:o}=n;let r;e[0]!==a||e[1]!==t.text?(r=yt(t.text,a),e[0]=a,e[1]=t.text,e[2]=r):r=e[2];const s=r;let c;e[3]!==t.isInfo||e[4]!==t.lineNumber||e[5]!==l?(c=l&&i.jsx("span",{className:"w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5",style:{color:"var(--tools-edit-line-number)",borderColor:"var(--tools-border)"},children:!t.isInfo&&t.lineNumber!=null?t.lineNumber:""}),e[3]=t.isInfo,e[4]=t.lineNumber,e[5]=l,e[6]=c):c=e[6];let d;e[7]!==s||e[8]!==t.isInfo||e[9]!==t.text?(d=i.jsx("div",{className:"flex-1 min-w-0",children:t.isInfo?i.jsx("div",{className:"whitespace-pre-wrap break-words text-muted-foreground/70 italic",children:t.text}):i.jsx("div",{className:"whitespace-pre",dangerouslySetInnerHTML:{__html:s}})}),e[7]=s,e[8]=t.isInfo,e[9]=t.text,e[10]=d):d=e[10];let f;return e[11]!==o||e[12]!==c||e[13]!==d?(f=i.jsxs("div",{className:"typography-code font-mono flex w-full min-w-0",style:o,children:[c,d]}),e[11]=o,e[12]=c,e[13]=d,e[14]=f):f=e[14],f});De.displayName="VirtualizedCodeBlock.Row";const jt=n=>{const e="h-3.5 w-3.5 flex-shrink-0",t=n.toLowerCase();return t==="reasoning"?i.jsx(D,{name:"brain-ai-3",className:e}):t==="image-preview"?i.jsx(D,{name:"file-image",className:e}):t==="mermaid-preview"?i.jsx(D,{name:"file-list-2",className:e}):t==="edit"||t==="multiedit"||t==="apply_patch"||t==="str_replace"||t==="str_replace_based_edit_tool"?i.jsx(D,{name:"pencil-ai",className:e}):t==="write"||t==="create"||t==="file_write"?i.jsx(D,{name:"file-pdf",className:e}):t==="read"||t==="view"||t==="file_read"||t==="cat"?i.jsx(D,{name:"file-pdf",className:e}):t==="bash"||t==="shell"||t==="cmd"||t==="terminal"?i.jsx(D,{name:"terminal-box",className:e}):t==="list"||t==="ls"||t==="dir"||t==="list_files"?i.jsx(D,{name:"folder-6",className:e}):t==="search"||t==="grep"||t==="find"||t==="ripgrep"?i.jsx(D,{name:"search",className:e}):t==="glob"?i.jsx(D,{name:"file-search",className:e}):t==="fetch"||t==="curl"||t==="wget"||t==="webfetch"?i.jsx(D,{name:"global",className:e}):t==="web-search"||t==="websearch"||t==="search_web"||t==="google"||t==="bing"||t==="duckduckgo"?i.jsx(D,{name:"search",className:e}):t==="todowrite"||t==="todoread"?i.jsx(D,{name:"list-check-3",className:e}):t==="plan_enter"?i.jsx(D,{name:"file-list-2",className:e}):t==="plan_exit"?i.jsx(D,{name:"task",className:e}):t.startsWith("git")?i.jsx(D,{name:"git-branch",className:e}):i.jsx(D,{name:"tools",className:e})},Oe=150,vt=40,Nt=120,Tt=3,Re={style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},St={download:!1,copy:!1,fullscreen:!1,panZoom:!0},_t=`
4
4
  [data-diff-header],