@thevinci/web 1.2.1 → 1.3.0

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 (25) hide show
  1. package/dist/assets/{GitView-p2ahAsFg.js → GitView-CRSR4Udh.js} +1 -1
  2. package/dist/assets/{HtmlEditor-CHu9gPrY.js → HtmlEditor-Cdmqf-2N.js} +1 -1
  3. package/dist/assets/{JsonTreeView-DNPUiy8M.js → JsonTreeView-BHfF9Efv.js} +1 -1
  4. package/dist/assets/{MarkdownRendererImpl-BtNl6Se-.js → MarkdownRendererImpl--9MJLbha.js} +1 -1
  5. package/dist/assets/{MultiRunWindow-520sOCac.js → MultiRunWindow-BgvoIqrW.js} +1 -1
  6. package/dist/assets/{OnboardingScreen-DoVP7Zm9.js → OnboardingScreen-D0MEhln5.js} +1 -1
  7. package/dist/assets/{SettingsWindow-B86Yerqr.js → SettingsWindow-Z-EFYu7z.js} +1 -1
  8. package/dist/assets/{TerminalView-D3pqxDPY.js → TerminalView-Ck9CASld.js} +1 -1
  9. package/dist/assets/{ToolOutputDialog-B40CkAsQ.js → ToolOutputDialog-nYirsIiU.js} +1 -1
  10. package/dist/assets/{es-B_p_C6PU.js → es-BFs9z5Pk.js} +1 -1
  11. package/dist/assets/{index-DbxIdVC4.js → index-BW75F1_U.js} +1 -1
  12. package/dist/assets/{ko-BslW5iXu.js → ko-DfXnAsXe.js} +1 -1
  13. package/dist/assets/{main-0lfSGrYL.js → main-C0ZrxisB.js} +35 -35
  14. package/dist/assets/{main-DvKMcqtE.js → main-DZyYGTEK.js} +2 -2
  15. package/dist/assets/{miniChat-DsZ_1ciq.js → miniChat-BYeO3Yg4.js} +2 -2
  16. package/dist/assets/{modelPrefsAutoSave-Cn7yX5JT.js → modelPrefsAutoSave-BUSppnWi.js} +60 -60
  17. package/dist/assets/{pl-BgO82JHA.js → pl-Cks13LmZ.js} +1 -1
  18. package/dist/assets/{pt-BR-QJ9vjGtl.js → pt-BR-ChRbcRLR.js} +1 -1
  19. package/dist/assets/{renderElectronMiniChatApp-BQK3OCIO.js → renderElectronMiniChatApp-BilFShcX.js} +2 -2
  20. package/dist/assets/{uk-DmQyBDIS.js → uk-DOLQ485O.js} +1 -1
  21. package/dist/assets/{zh-CN-P6ISeynY.js → zh-CN-DYWE2Jha.js} +1 -1
  22. package/dist/index.html +2 -2
  23. package/dist/mini-chat.html +2 -2
  24. package/package.json +2 -1
  25. package/server/lib/fs/routes.js +62 -0
@@ -1,4 +1,4 @@
1
- import{c as wt,R as i,r as tt,j as t,ap as Na,al as Ca}from"./vendor-.bun-DgrCmzWD.js";import{eE as ye,u as st,N as ht,a as xt,au as Ct,aq as Es,G as v,I as C,H as Pr,J as Tr,R as ee,K as zr,eF as ka,eG as Sa,V as Vt,U as Rt,O as At,P as It,aQ as Wt,Q as xs,T as Ge,n as Ue,p as We,eH as Va,c as _e,eI as Ra,eJ as Aa,eK as Ia,aM as Da,aD as ws,c_ as ir,eL as Ea,S as Ps,b as Fr,aZ as Pa,eM as Ta,al as Mr,bv as Qs,bw as er,bx as tr,by as sr,bz as ps,C as Br,a2 as pr,Z as _r,ax as za,eN as Fa,aC as Is,bi as xr,am as Ma,E as Ba,eO as _a,aF as $a,b0 as Oa,aJ as La,a6 as Ha,eP as Ga,cP as Ua,eQ as Wa,eR as qa,b1 as Ka,eS as Ja,a$ as St,cT as Ya,aN as Xa,b2 as Za,eT as Qa,eU as en,eV as qs}from"./modelPrefsAutoSave-Cn7yX5JT.js";import{C as or,a as lr,b as cr,c as dr,d as Ts,e as zs,P as tn,f as $r,g as rr,h as ar,u as Ht,i as sn,j as rn,k as an,l as nn,G as on}from"./main-0lfSGrYL.js";import"./index-DbxIdVC4.js";import"./JsonTreeView-DNPUiy8M.js";const nr=r=>{if(!r)return"";const e=r.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ln=r=>{const e=nr(r);if(!e)return null;const c=e.indexOf("/.git/worktrees/");return c>0&&e.slice(0,c)||null};function cn(r,e,s){const c=wt.c(5),[h,g]=i.useState();let m,a;return c[0]!==s||c[1]!==r||c[2]!==e?(m=()=>{if(e){g(void 0);return}if(!r){g(void 0);return}g(void 0);let u=!1;return(async()=>{const[N,R]=await Promise.all([ye("git rev-parse --absolute-git-dir",r),ye("git rev-parse --show-toplevel",r)]);if(u||!N.success||!R.success)return;const b=nr((N.stdout||"").trim()),P=ln(b);if(!P)return;const I=nr((R.stdout||"").trim());if(!I||I===P)return;const y=s||"",T=I.split("/").filter(Boolean).pop()||I;g({source:"sdk",path:I,projectDirectory:P,branch:y,label:y||T,name:T,worktreeRoot:I,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!0}},a=[r,e,s],c[0]=s,c[1]=r,c[2]=e,c[3]=m,c[4]=a):(m=c[3],a=c[4]),i.useEffect(m,a),e??h}const at=r=>{const e=r.trim();return e?`'${e.replace(/'/g,"'\\''")}'`:"''"},ns=r=>(r||"").split(/\r?\n/).map(e=>e.trim()).filter(Boolean),Dt=r=>!!r.success,Bs=r=>(r.stdout||"").trim(),Ut=r=>(r.stderr||"").trim();async function dn(r){const s=((await ye("git worktree list --porcelain",r)).stdout||"").split(/\r?\n/),c=[];let h=null;for(const g of s){if(g.startsWith("worktree ")){h&&c.push(h),h={path:g.slice(9).trim(),branchRef:null};continue}h&&g.startsWith("branch ")&&(h.branchRef=g.slice(7).trim())}return h&&c.push(h),c.filter(g=>!!g.path)}async function un(r){const e=`refs/heads/${r.targetBranch}`,s=new Set(r.excludePaths),h=(await dn(r.repoRoot)).filter(m=>m.branchRef===e).map(m=>m.path).filter(m=>m&&!s.has(m)),g=[];for(const m of h){const a=await ye("git status --porcelain",m);Bs(a)||g.push(m)}return g}async function Or(r,e){for(const s of e)await ye("git reset --hard",s).catch(()=>{})}async function mn(r,e){const s=e.trim();if(!s||s==="HEAD")return"HEAD";const c=await ye(`git show-ref --verify --quiet ${at(`refs/heads/${s}`)}`,r);if(Dt(c))return s;if(s.startsWith("remotes/")){const m=s.slice(8).split("/"),a=m[0]||"origin",u=m.slice(1).join("/");if(u)return await ye(`git branch --track ${at(u)} ${at(`${a}/${u}`)}`,r),u}const h=await ye(`git show-ref --verify --quiet ${at(`refs/remotes/origin/${s}`)}`,r);return Dt(h)&&await ye(`git branch --track ${at(s)} ${at(`origin/${s}`)}`,r),s}async function gs(r){const e=r.repoRoot,s=r.sourceBranch.trim(),c=r.targetBranch.trim();if(!s||!c)return{repoRoot:e,sourceBranch:s,targetBranch:c,commits:[]};const h=await mn(e,c),g=await ye(`git cherry ${at(h)} ${at(s)}`,e),m=ns(g.stdout),a=new Set;for(const b of m){const P=b.match(/^\+\s+([0-9a-f]{7,40})\b/i);P&&a.add(P[1])}const u=await ye(`git rev-list --reverse ${at(`${h}..${s}`)}`,e),R=ns(u.stdout).filter(b=>a.has(b));return{repoRoot:e,sourceBranch:s,targetBranch:h,commits:R}}async function hn(r,e){const s=await ye('mkdir -p "$HOME/.config/vinci/tmp"',r);if(!Dt(s))throw new Error(Ut(s)||"Failed to create temp directory parent");const c=await ye('mktemp -d "$HOME/.config/vinci/tmp/vinci-integrate-XXXXXX"',r),h=Bs(c);if(!h)throw new Error(Ut(c)||"Failed to create temp directory");const g=await ye(`git worktree add --force ${at(h)} ${at(e)}`,r);if(!Dt(g))throw new Error(Ut(g)||"Failed to create temp worktree");return h}async function Fs(r,e){await ye(`git worktree remove --force ${at(e)}`,r).catch(()=>{}),await ye("git worktree prune",r).catch(()=>{})}async function fn(r){const e=await ye("git rev-parse --abbrev-ref --symbolic-full-name @{u}",r),s=Bs(e);if(!s)return;await ye("git fetch",r);const c=await ye(`git merge --ff-only ${at(s)}`,r);if(!Dt(c))throw new Error(Ut(c)||"Fast-forward failed")}async function Ms(r){const e=await ye("git status --porcelain",r),s=await ye("git diff --name-only --diff-filter=U",r),c=await ye("git diff",r),h=await ye("git show --no-patch --pretty=fuller CHERRY_PICK_HEAD",r),g=await ye("git show CHERRY_PICK_HEAD",r);return{statusPorcelain:e.stdout||"",unmergedFiles:ns(s.stdout),diff:c.stdout||c.stderr||"",currentPatchMeta:h.stdout||h.stderr||"",currentPatch:g.stdout||g.stderr||""}}async function gn(r){return Ms(r)}async function pn(r){const e=await ye("git rev-parse --verify --quiet CHERRY_PICK_HEAD",r);return Dt(e)}async function xn(r){if(r.commits.length===0)return{kind:"noop",reason:"No commits to move"};const e=await hn(r.repoRoot,r.targetBranch);let s=[];try{await fn(e);const c=await ye("git status --porcelain",e);if(Bs(c))throw new Error("Target branch has local changes; abort integration and retry");const h=await un({repoRoot:r.repoRoot,targetBranch:r.targetBranch,excludePaths:[e]}).catch(()=>[]);for(s=[...r.commits];s.length>0;){const g=s[0],m=await ye(`git cherry-pick ${at(g)}`,e);if(Dt(m)){s.shift();continue}const a=await ye("git diff --name-only --diff-filter=U",e);if(ns(a.stdout).length>0){const N=await Ms(e);return{kind:"conflict",state:{repoRoot:r.repoRoot,tempWorktreePath:e,sourceBranch:r.sourceBranch,targetBranch:r.targetBranch,cleanTargetWorktrees:h,remainingCommits:s,currentCommit:g},details:N}}throw new Error(Ut(m)||"Cherry-pick failed")}return await Fs(r.repoRoot,e),await Or(r.repoRoot,h).catch(()=>{}),{kind:"success",moved:r.commits.length}}catch(c){throw await Fs(r.repoRoot,e).catch(()=>{}),c}}async function wn(r){await ye("git cherry-pick --abort",r.tempWorktreePath).catch(()=>{}),await Fs(r.repoRoot,r.tempWorktreePath)}async function yn(r){const e=await ye("git cherry-pick --continue",r.tempWorktreePath);if(!Dt(e)){const g=await ye("git diff --name-only --diff-filter=U",r.tempWorktreePath);if(ns(g.stdout).length>0){const a=await Ms(r.tempWorktreePath);return{kind:"conflict",state:r,details:a}}throw new Error(Ut(e)||"Cherry-pick continue failed")}const s=r.tempWorktreePath,c=[...r.remainingCommits];c.length>0&&c[0]===r.currentCommit&&c.shift();const h=[...c];for(;h.length>0;){const g=h[0],m=await ye(`git cherry-pick ${at(g)}`,s);if(Dt(m)){h.shift();continue}const a=await ye("git diff --name-only --diff-filter=U",s);if(ns(a.stdout).length>0){const N=await Ms(s);return{kind:"conflict",state:{repoRoot:r.repoRoot,tempWorktreePath:s,sourceBranch:r.sourceBranch,targetBranch:r.targetBranch,cleanTargetWorktrees:r.cleanTargetWorktrees,remainingCommits:h,currentCommit:g},details:N}}throw new Error(Ut(m)||"Cherry-pick failed")}return await Fs(r.repoRoot,r.tempWorktreePath),await Or(r.repoRoot,r.cleanTargetWorktrees).catch(()=>{}),{kind:"success",moved:r.remainingCommits.length}}const bn=({repoRoot:r,sourceBranch:e,worktreeMetadata:s,localBranches:c,defaultTargetBranch:h,refreshKey:g,onRefresh:m})=>{const{t:a}=st(),u=ht(x=>x.currentSessionId),N=xt(x=>x.setActiveMainTab),[R,b]=tt.useState(!1),P=tt.useRef(null),[I,y]=tt.useState(h);tt.useEffect(()=>{y(h)},[h]),tt.useEffect(()=>{if(R){const x=setTimeout(()=>{P.current?.focus()},0);return()=>clearTimeout(x)}},[R]);const T=!!(r&&e&&I&&I!=="HEAD"&&e!==I),[j,f]=tt.useState({kind:"idle"}),[G,V]=tt.useState(!1),[q,K]=tt.useState([]),w=tt.useMemo(()=>u?`vinci.integrate.conflict:${u}`:null,[u]);tt.useEffect(()=>{if(!w||typeof window>"u")return;const x=window.localStorage.getItem(w);if(!x)return;let F=!1;try{const _=JSON.parse(x);if(!_?.tempWorktreePath||_.repoRoot!==r){window.localStorage.removeItem(w);return}(async()=>{const ce=await pn(_.tempWorktreePath).catch(()=>!1);if(F)return;if(!ce){window.localStorage.removeItem(w);return}const ae=await gn(_.tempWorktreePath).catch(()=>null);F||ae&&f({kind:"conflict",state:_,details:ae})})()}catch{window.localStorage.removeItem(w)}return()=>{F=!0}},[w,r]),tt.useEffect(()=>{if(!T){f({kind:"idle"});return}let x=!1;return f({kind:"loading"}),(async()=>{try{const F=await gs({repoRoot:r,sourceBranch:e,targetBranch:I});if(x)return;if(f({kind:"ready",plan:F}),F.commits.length>0){const ae=F.commits.slice(-50).reverse().map(we=>JSON.stringify(we)).join(" "),ue=((await ye(`git show -s --format=%H%x09%h%x09%s ${ae}`,r)).stdout||"").split(/\r?\n/).filter(Boolean),le=[];for(const we of ue){const[L,E,ne]=we.split(" ");!L||!E||le.push({sha:L,short:E,subject:ne||""})}x||(K(le),V(!1))}else x||(K([]),V(!1))}catch{x||f({kind:"idle"})}})(),()=>{x=!0}},[T,r,e,I,g]);const Y=tt.useCallback(x=>{u&&ht.getState().setWorktreeMetadata(u,{...s,createdFromBranch:x})},[u,s]),X=ht(x=>x.openNewSessionDraft),S=tt.useCallback(async x=>{const F=await Ct("git.integrate.cherrypick.resolve.visible",{current_commit:x.state.currentCommit,target_branch:x.state.targetBranch}),_=await Ct("git.integrate.cherrypick.resolve.instructions",{repo_root:x.state.repoRoot,temp_worktree_path:x.state.tempWorktreePath,source_branch:x.state.sourceBranch,target_branch:x.state.targetBranch,current_commit:x.state.currentCommit}),ce=`Cherry-pick conflict context (JSON)
1
+ import{c as wt,R as i,r as tt,j as t,ap as Na,al as Ca}from"./vendor-.bun-DgrCmzWD.js";import{eE as ye,u as st,N as ht,a as xt,au as Ct,aq as Es,G as v,I as C,H as Pr,J as Tr,R as ee,K as zr,eF as ka,eG as Sa,V as Vt,U as Rt,O as At,P as It,aQ as Wt,Q as xs,T as Ge,n as Ue,p as We,eH as Va,c as _e,eI as Ra,eJ as Aa,eK as Ia,aM as Da,aD as ws,c_ as ir,eL as Ea,S as Ps,b as Fr,aZ as Pa,eM as Ta,al as Mr,bv as Qs,bw as er,bx as tr,by as sr,bz as ps,C as Br,a2 as pr,Z as _r,ax as za,eN as Fa,aC as Is,bi as xr,am as Ma,E as Ba,eO as _a,aF as $a,b0 as Oa,aJ as La,a6 as Ha,eP as Ga,cP as Ua,eQ as Wa,eR as qa,b1 as Ka,eS as Ja,a$ as St,cT as Ya,aN as Xa,b2 as Za,eT as Qa,eU as en,eV as qs}from"./modelPrefsAutoSave-BUSppnWi.js";import{C as or,a as lr,b as cr,c as dr,d as Ts,e as zs,P as tn,f as $r,g as rr,h as ar,u as Ht,i as sn,j as rn,k as an,l as nn,G as on}from"./main-C0ZrxisB.js";import"./index-BW75F1_U.js";import"./JsonTreeView-BHfF9Efv.js";const nr=r=>{if(!r)return"";const e=r.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ln=r=>{const e=nr(r);if(!e)return null;const c=e.indexOf("/.git/worktrees/");return c>0&&e.slice(0,c)||null};function cn(r,e,s){const c=wt.c(5),[h,g]=i.useState();let m,a;return c[0]!==s||c[1]!==r||c[2]!==e?(m=()=>{if(e){g(void 0);return}if(!r){g(void 0);return}g(void 0);let u=!1;return(async()=>{const[N,R]=await Promise.all([ye("git rev-parse --absolute-git-dir",r),ye("git rev-parse --show-toplevel",r)]);if(u||!N.success||!R.success)return;const b=nr((N.stdout||"").trim()),P=ln(b);if(!P)return;const I=nr((R.stdout||"").trim());if(!I||I===P)return;const y=s||"",T=I.split("/").filter(Boolean).pop()||I;g({source:"sdk",path:I,projectDirectory:P,branch:y,label:y||T,name:T,worktreeRoot:I,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!0}},a=[r,e,s],c[0]=s,c[1]=r,c[2]=e,c[3]=m,c[4]=a):(m=c[3],a=c[4]),i.useEffect(m,a),e??h}const at=r=>{const e=r.trim();return e?`'${e.replace(/'/g,"'\\''")}'`:"''"},ns=r=>(r||"").split(/\r?\n/).map(e=>e.trim()).filter(Boolean),Dt=r=>!!r.success,Bs=r=>(r.stdout||"").trim(),Ut=r=>(r.stderr||"").trim();async function dn(r){const s=((await ye("git worktree list --porcelain",r)).stdout||"").split(/\r?\n/),c=[];let h=null;for(const g of s){if(g.startsWith("worktree ")){h&&c.push(h),h={path:g.slice(9).trim(),branchRef:null};continue}h&&g.startsWith("branch ")&&(h.branchRef=g.slice(7).trim())}return h&&c.push(h),c.filter(g=>!!g.path)}async function un(r){const e=`refs/heads/${r.targetBranch}`,s=new Set(r.excludePaths),h=(await dn(r.repoRoot)).filter(m=>m.branchRef===e).map(m=>m.path).filter(m=>m&&!s.has(m)),g=[];for(const m of h){const a=await ye("git status --porcelain",m);Bs(a)||g.push(m)}return g}async function Or(r,e){for(const s of e)await ye("git reset --hard",s).catch(()=>{})}async function mn(r,e){const s=e.trim();if(!s||s==="HEAD")return"HEAD";const c=await ye(`git show-ref --verify --quiet ${at(`refs/heads/${s}`)}`,r);if(Dt(c))return s;if(s.startsWith("remotes/")){const m=s.slice(8).split("/"),a=m[0]||"origin",u=m.slice(1).join("/");if(u)return await ye(`git branch --track ${at(u)} ${at(`${a}/${u}`)}`,r),u}const h=await ye(`git show-ref --verify --quiet ${at(`refs/remotes/origin/${s}`)}`,r);return Dt(h)&&await ye(`git branch --track ${at(s)} ${at(`origin/${s}`)}`,r),s}async function gs(r){const e=r.repoRoot,s=r.sourceBranch.trim(),c=r.targetBranch.trim();if(!s||!c)return{repoRoot:e,sourceBranch:s,targetBranch:c,commits:[]};const h=await mn(e,c),g=await ye(`git cherry ${at(h)} ${at(s)}`,e),m=ns(g.stdout),a=new Set;for(const b of m){const P=b.match(/^\+\s+([0-9a-f]{7,40})\b/i);P&&a.add(P[1])}const u=await ye(`git rev-list --reverse ${at(`${h}..${s}`)}`,e),R=ns(u.stdout).filter(b=>a.has(b));return{repoRoot:e,sourceBranch:s,targetBranch:h,commits:R}}async function hn(r,e){const s=await ye('mkdir -p "$HOME/.config/vinci/tmp"',r);if(!Dt(s))throw new Error(Ut(s)||"Failed to create temp directory parent");const c=await ye('mktemp -d "$HOME/.config/vinci/tmp/vinci-integrate-XXXXXX"',r),h=Bs(c);if(!h)throw new Error(Ut(c)||"Failed to create temp directory");const g=await ye(`git worktree add --force ${at(h)} ${at(e)}`,r);if(!Dt(g))throw new Error(Ut(g)||"Failed to create temp worktree");return h}async function Fs(r,e){await ye(`git worktree remove --force ${at(e)}`,r).catch(()=>{}),await ye("git worktree prune",r).catch(()=>{})}async function fn(r){const e=await ye("git rev-parse --abbrev-ref --symbolic-full-name @{u}",r),s=Bs(e);if(!s)return;await ye("git fetch",r);const c=await ye(`git merge --ff-only ${at(s)}`,r);if(!Dt(c))throw new Error(Ut(c)||"Fast-forward failed")}async function Ms(r){const e=await ye("git status --porcelain",r),s=await ye("git diff --name-only --diff-filter=U",r),c=await ye("git diff",r),h=await ye("git show --no-patch --pretty=fuller CHERRY_PICK_HEAD",r),g=await ye("git show CHERRY_PICK_HEAD",r);return{statusPorcelain:e.stdout||"",unmergedFiles:ns(s.stdout),diff:c.stdout||c.stderr||"",currentPatchMeta:h.stdout||h.stderr||"",currentPatch:g.stdout||g.stderr||""}}async function gn(r){return Ms(r)}async function pn(r){const e=await ye("git rev-parse --verify --quiet CHERRY_PICK_HEAD",r);return Dt(e)}async function xn(r){if(r.commits.length===0)return{kind:"noop",reason:"No commits to move"};const e=await hn(r.repoRoot,r.targetBranch);let s=[];try{await fn(e);const c=await ye("git status --porcelain",e);if(Bs(c))throw new Error("Target branch has local changes; abort integration and retry");const h=await un({repoRoot:r.repoRoot,targetBranch:r.targetBranch,excludePaths:[e]}).catch(()=>[]);for(s=[...r.commits];s.length>0;){const g=s[0],m=await ye(`git cherry-pick ${at(g)}`,e);if(Dt(m)){s.shift();continue}const a=await ye("git diff --name-only --diff-filter=U",e);if(ns(a.stdout).length>0){const N=await Ms(e);return{kind:"conflict",state:{repoRoot:r.repoRoot,tempWorktreePath:e,sourceBranch:r.sourceBranch,targetBranch:r.targetBranch,cleanTargetWorktrees:h,remainingCommits:s,currentCommit:g},details:N}}throw new Error(Ut(m)||"Cherry-pick failed")}return await Fs(r.repoRoot,e),await Or(r.repoRoot,h).catch(()=>{}),{kind:"success",moved:r.commits.length}}catch(c){throw await Fs(r.repoRoot,e).catch(()=>{}),c}}async function wn(r){await ye("git cherry-pick --abort",r.tempWorktreePath).catch(()=>{}),await Fs(r.repoRoot,r.tempWorktreePath)}async function yn(r){const e=await ye("git cherry-pick --continue",r.tempWorktreePath);if(!Dt(e)){const g=await ye("git diff --name-only --diff-filter=U",r.tempWorktreePath);if(ns(g.stdout).length>0){const a=await Ms(r.tempWorktreePath);return{kind:"conflict",state:r,details:a}}throw new Error(Ut(e)||"Cherry-pick continue failed")}const s=r.tempWorktreePath,c=[...r.remainingCommits];c.length>0&&c[0]===r.currentCommit&&c.shift();const h=[...c];for(;h.length>0;){const g=h[0],m=await ye(`git cherry-pick ${at(g)}`,s);if(Dt(m)){h.shift();continue}const a=await ye("git diff --name-only --diff-filter=U",s);if(ns(a.stdout).length>0){const N=await Ms(s);return{kind:"conflict",state:{repoRoot:r.repoRoot,tempWorktreePath:s,sourceBranch:r.sourceBranch,targetBranch:r.targetBranch,cleanTargetWorktrees:r.cleanTargetWorktrees,remainingCommits:h,currentCommit:g},details:N}}throw new Error(Ut(m)||"Cherry-pick failed")}return await Fs(r.repoRoot,r.tempWorktreePath),await Or(r.repoRoot,r.cleanTargetWorktrees).catch(()=>{}),{kind:"success",moved:r.remainingCommits.length}}const bn=({repoRoot:r,sourceBranch:e,worktreeMetadata:s,localBranches:c,defaultTargetBranch:h,refreshKey:g,onRefresh:m})=>{const{t:a}=st(),u=ht(x=>x.currentSessionId),N=xt(x=>x.setActiveMainTab),[R,b]=tt.useState(!1),P=tt.useRef(null),[I,y]=tt.useState(h);tt.useEffect(()=>{y(h)},[h]),tt.useEffect(()=>{if(R){const x=setTimeout(()=>{P.current?.focus()},0);return()=>clearTimeout(x)}},[R]);const T=!!(r&&e&&I&&I!=="HEAD"&&e!==I),[j,f]=tt.useState({kind:"idle"}),[G,V]=tt.useState(!1),[q,K]=tt.useState([]),w=tt.useMemo(()=>u?`vinci.integrate.conflict:${u}`:null,[u]);tt.useEffect(()=>{if(!w||typeof window>"u")return;const x=window.localStorage.getItem(w);if(!x)return;let F=!1;try{const _=JSON.parse(x);if(!_?.tempWorktreePath||_.repoRoot!==r){window.localStorage.removeItem(w);return}(async()=>{const ce=await pn(_.tempWorktreePath).catch(()=>!1);if(F)return;if(!ce){window.localStorage.removeItem(w);return}const ae=await gn(_.tempWorktreePath).catch(()=>null);F||ae&&f({kind:"conflict",state:_,details:ae})})()}catch{window.localStorage.removeItem(w)}return()=>{F=!0}},[w,r]),tt.useEffect(()=>{if(!T){f({kind:"idle"});return}let x=!1;return f({kind:"loading"}),(async()=>{try{const F=await gs({repoRoot:r,sourceBranch:e,targetBranch:I});if(x)return;if(f({kind:"ready",plan:F}),F.commits.length>0){const ae=F.commits.slice(-50).reverse().map(we=>JSON.stringify(we)).join(" "),ue=((await ye(`git show -s --format=%H%x09%h%x09%s ${ae}`,r)).stdout||"").split(/\r?\n/).filter(Boolean),le=[];for(const we of ue){const[L,E,ne]=we.split(" ");!L||!E||le.push({sha:L,short:E,subject:ne||""})}x||(K(le),V(!1))}else x||(K([]),V(!1))}catch{x||f({kind:"idle"})}})(),()=>{x=!0}},[T,r,e,I,g]);const Y=tt.useCallback(x=>{u&&ht.getState().setWorktreeMetadata(u,{...s,createdFromBranch:x})},[u,s]),X=ht(x=>x.openNewSessionDraft),S=tt.useCallback(async x=>{const F=await Ct("git.integrate.cherrypick.resolve.visible",{current_commit:x.state.currentCommit,target_branch:x.state.targetBranch}),_=await Ct("git.integrate.cherrypick.resolve.instructions",{repo_root:x.state.repoRoot,temp_worktree_path:x.state.tempWorktreePath,source_branch:x.state.sourceBranch,target_branch:x.state.targetBranch,current_commit:x.state.currentCommit}),ce=`Cherry-pick conflict context (JSON)
2
2
  ${JSON.stringify({repoRoot:x.state.repoRoot,tempWorktreePath:x.state.tempWorktreePath,sourceBranch:x.state.sourceBranch,targetBranch:x.state.targetBranch,currentCommit:x.state.currentCommit,remainingCommits:x.state.remainingCommits,statusPorcelain:x.details.statusPorcelain,unmergedFiles:x.details.unmergedFiles,currentPatchMeta:x.details.currentPatchMeta,currentPatch:x.details.currentPatch,diff:x.details.diff},null,2)}`;return{visibleText:F,instructionsText:_,payloadText:ce}},[]),A=Es(x=>x.setPendingInputText),z=Es(x=>x.setPendingSyntheticParts),re=tt.useCallback(async(x,F)=>{const _=await S(x);if(F){X({directoryOverride:x.state.tempWorktreePath,initialPrompt:_.visibleText,syntheticParts:[{text:_.instructionsText,synthetic:!0},{text:_.payloadText,synthetic:!0}]}),N("chat");return}if(!u){v.error(a("gitView.integrate.noActiveSession"),{description:a("gitView.integrate.noActiveSessionDescription")});return}A(_.visibleText,"replace"),z([{text:_.instructionsText,synthetic:!0},{text:_.payloadText,synthetic:!0}]),N("chat")},[u,N,S,X,A,z,a]),O=tt.useCallback(async()=>{if(j.kind==="ready"){if(j.plan.commits.length===0){v.message(a("gitView.integrate.noCommitsToMoveToast"));return}f({kind:"running",plan:j.plan});try{const x=await xn(j.plan);if(x.kind==="success"){v.success(a("gitView.integrate.commitsMovedToast"),{description:x.moved===1?a("gitView.integrate.commitsMovedDescriptionSingle",{count:x.moved,branch:j.plan.targetBranch}):a("gitView.integrate.commitsMovedDescriptionPlural",{count:x.moved,branch:j.plan.targetBranch})});const F=await gs(j.plan);f({kind:"ready",plan:F}),m?.();return}x.kind==="conflict"&&(v.error(a("gitView.integrate.cherryPickConflictToast"),{description:a("gitView.integrate.cherryPickConflictDescription")}),f({kind:"conflict",state:x.state,details:x.details}),w&&typeof window<"u"&&window.localStorage.setItem(w,JSON.stringify(x.state)))}catch(x){const F=x instanceof Error?x.message:String(x);v.error(a("gitView.integrate.failedToMoveToast"),{description:F});const _=await gs({repoRoot:r,sourceBranch:e,targetBranch:I}).catch(()=>null);f(_?{kind:"ready",plan:_}:{kind:"idle"})}}},[j,m,r,e,I,w,a]),Q=tt.useCallback(async()=>{if(j.kind==="conflict")try{await wn(j.state),v.message(a("gitView.integrate.cherryPickAbortedToast")),w&&typeof window<"u"&&window.localStorage.removeItem(w)}finally{const x=await gs({repoRoot:r,sourceBranch:e,targetBranch:I}).catch(()=>null);f(x?{kind:"ready",plan:x}:{kind:"idle"})}},[j,r,e,I,w,a]),te=tt.useCallback(async()=>{if(j.kind==="conflict")try{const x=await yn(j.state);if(x.kind==="success"){v.success(a("gitView.integrate.cherryPickFinishedToast"));const F=await gs({repoRoot:r,sourceBranch:e,targetBranch:I}).catch(()=>null);f(F?{kind:"ready",plan:F}:{kind:"idle"}),w&&typeof window<"u"&&window.localStorage.removeItem(w),m?.();return}x.kind==="conflict"&&(f({kind:"conflict",state:x.state,details:x.details}),w&&typeof window<"u"&&window.localStorage.setItem(w,JSON.stringify(x.state)))}catch(x){const F=x instanceof Error?x.message:String(x);v.error(a("gitView.integrate.cherryPickContinueFailedToast"),{description:F})}},[j,r,e,I,m,w,a]);return!r||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[t.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(C,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.integrate.title")}),j.kind==="ready"&&j.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:a("gitView.integrate.toMoveCount",{count:j.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:j.kind==="loading"||j.kind==="running"?t.jsx(C,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null})]}),t.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",I]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Pr,{open:R,onOpenChange:b,children:[t.jsx(Tr,{asChild:!0,children:t.jsxs(ee,{variant:"outline",size:"sm",className:"gap-1.5",children:[a("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:I}),t.jsx(C,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(zr,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(or,{className:"h-full min-h-0",children:[t.jsx(lr,{ref:P,placeholder:a("gitView.branch.searchPlaceholder"),onKeyDown:x=>x.stopPropagation()}),t.jsxs(cr,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(dr,{children:a("gitView.branch.empty")}),t.jsx(Ts,{heading:a("gitView.branch.localBranches"),children:c.map(x=>t.jsx(zs,{value:x,onSelect:()=>{y(x),Y(x),b(!1)},children:x},x))})]})]})})]}),j.kind==="ready"?t.jsx(ee,{size:"sm",onClick:()=>{O()},disabled:!T||j.plan.commits.length===0,children:a("gitView.integrate.move")}):j.kind==="loading"?t.jsx(ee,{size:"sm",variant:"outline",disabled:!0,children:a("gitView.integrate.checking")}):j.kind==="running"?t.jsx(ee,{size:"sm",variant:"outline",disabled:!0,children:a("gitView.integrate.moving")}):null]}),j.kind==="ready"&&j.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.integrate.noCommitsToMove")}),j.kind==="ready"&&j.plan.commits.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"typography-meta text-foreground",children:[a("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",j.plan.commits.length,")"]})]}),q.length>0&&j.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>V(x=>!x),className:"typography-micro text-muted-foreground hover:text-foreground",children:a(G?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(G?q:q.slice(0,5)).map(x=>t.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"font-mono text-xs text-muted-foreground flex-shrink-0",children:x.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:x.subject||x.sha})]},x.sha)),q.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.integrate.previewUnavailable")}),j.plan.commits.length>q.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:a("gitView.integrate.showingFirstCommits",{count:q.length})})]})]}),j.kind==="conflict"&&t.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 p-3 space-y-2",children:[t.jsx("div",{className:"typography-meta text-foreground",children:a("gitView.integrate.conflictsInFiles",{count:j.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[a("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:j.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[j.details.unmergedFiles.slice(0,6).map(x=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:x},x)),j.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:a("gitView.integrate.moreFiles",{count:j.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(ee,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{Q()},children:a("gitView.operation.abort")}),t.jsxs(ee,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!u,onClick:()=>{re({state:j.state,details:j.details},!1)},children:[t.jsx(C,{name:"sparkling",className:"size-3.5"}),a("gitView.integrate.currentSession")]}),t.jsxs(ee,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{re({state:j.state,details:j.details},!0)},children:[t.jsx(C,{name:"sparkling",className:"size-3.5"}),a("gitView.integrate.newSession")]}),t.jsx(ee,{size:"sm",className:"typography-meta",onClick:()=>{te()},children:a("gitView.operation.continue")})]})]})]})]})},jn=({open:r,onOpenChange:e,directory:s,hasUncommittedChanges:c,uncommittedFileCount:h,onChanged:g})=>{const{t:m}=st(),[a,u]=i.useState([]),[N,R]=i.useState(!1),[b,P]=i.useState(""),[I,y]=i.useState(""),[T,j]=i.useState(null),[f,G]=i.useState({}),V=i.useCallback(async()=>{if(s){R(!0);try{const S=await ka(s);u(S.stashes),G({})}catch(S){v.error(S instanceof Error?S.message:m("gitView.stashes.toast.loadFailed"))}finally{R(!1)}}},[s,m]);i.useEffect(()=>{r&&V()},[V,r]),i.useEffect(()=>{if(!r||!s||a.length===0)return;let S=!1;const A=a.map(z=>z.ref);return Sa(s,A).then(z=>{S||G(z.counts)}).catch(()=>{}),()=>{S=!0}},[s,r,a]);const q=i.useMemo(()=>{const S=b.trim().toLowerCase();return S?a.filter(A=>`${A.ref} ${A.message} ${A.relativeTime}`.toLowerCase().includes(S)):a},[b,a]),K=i.useCallback(async()=>{await V(),await g?.()},[V,g]),w=async()=>{if(!(!s||T)){j("create");try{(await Va(s,{message:I.trim()||void 0})).created?(v.success(m("gitView.stashes.toast.created")),y("")):v.info(m("gitView.stashes.toast.noChanges")),await K()}catch(S){v.error(S instanceof Error?S.message:m("gitView.stashes.toast.createFailed"))}finally{j(null)}}},Y=async(S,A)=>{if(!(!s||T)&&!(A==="drop"&&!window.confirm(m("gitView.stashes.confirm.drop",{ref:S.ref})))){j(`${A}:${S.ref}`);try{A==="apply"&&await Ra(s,{ref:S.ref}),A==="pop"&&await Aa(s,{ref:S.ref}),A==="drop"&&await Ia(s,{ref:S.ref});const z=A==="apply"?"gitView.stashes.toast.applySuccess":A==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";v.success(m(z)),await K()}catch(z){const re=A==="apply"?"gitView.stashes.toast.applyFailed":A==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";v.error(z instanceof Error?z.message:m(re)),await K()}finally{j(null)}}},X=T!==null;return t.jsx(Vt,{open:r,onOpenChange:e,children:t.jsxs(Rt,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(At,{children:[t.jsxs(It,{className:"flex items-center gap-2",children:[t.jsx(C,{name:"archive-stack",className:"h-5 w-5"}),m("gitView.stashes.title")]}),t.jsx(Wt,{children:m("gitView.stashes.description")})]}),t.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(xs,{value:I,onChange:S=>y(S.target.value),placeholder:m("gitView.stashes.messagePlaceholder"),disabled:X||!c,className:"flex-1"}),t.jsxs(ee,{onClick:w,disabled:!c||X||!s,children:[T==="create"?t.jsx(C,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(C,{name:"inbox-archive",className:"size-4"}),m("gitView.stashes.actions.stashCurrentWithCount",{count:h})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:m("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(C,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(xs,{value:b,onChange:S=>P(S.target.value),placeholder:m("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:N?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(C,{name:"loader-4",className:"size-5 animate-spin"})}):q.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:m(b?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):q.map((S,A)=>t.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[t.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[t.jsx("p",{className:"typography-small truncate text-foreground",children:S.message||m("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(Ge,{children:[t.jsx(Ue,{asChild:!0,children:t.jsx("span",{children:A===0&&!b.trim()?m("gitView.stashes.latestLabel"):m("gitView.stashes.itemNumber",{number:A+1})})}),t.jsx(We,{sideOffset:6,children:S.ref})]})," · ",S.relativeTime," · ",typeof f[S.ref]=="number"?m("gitView.stashes.fileCount",{count:f[S.ref]}):m("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Ks,{label:m("gitView.stashes.actions.apply"),loading:T===`apply:${S.ref}`,onClick:()=>Y(S,"apply"),disabled:X,children:t.jsx(C,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Ks,{label:m("gitView.stashes.actions.pop"),loading:T===`pop:${S.ref}`,onClick:()=>Y(S,"pop"),disabled:X,children:t.jsx(C,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Ks,{label:m("gitView.stashes.actions.drop"),loading:T===`drop:${S.ref}`,onClick:()=>Y(S,"drop"),disabled:X,destructive:!0,children:t.jsx(C,{name:"delete-bin",className:"size-4"})})]})]},S.ref))})]})})},Ks=r=>{const e=wt.c(17),{label:s,loading:c,disabled:h,destructive:g,onClick:m,children:a}=r,u=c||void 0,N=g?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let R;e[0]!==N?(R=_e("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",N),e[0]=N,e[1]=R):R=e[1];let b;e[2]!==a||e[3]!==c?(b=c?t.jsx(C,{name:"loader-4",className:"size-4 animate-spin"}):a,e[2]=a,e[3]=c,e[4]=b):b=e[4];let P;e[5]!==h||e[6]!==s||e[7]!==m||e[8]!==u||e[9]!==R||e[10]!==b?(P=t.jsx(Ue,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":s,"aria-busy":u,className:R,onClick:m,disabled:h,children:b})}),e[5]=h,e[6]=s,e[7]=m,e[8]=u,e[9]=R,e[10]=b,e[11]=P):P=e[11];let I;e[12]!==s?(I=t.jsx(We,{sideOffset:6,children:s}),e[12]=s,e[13]=I):I=e[13];let y;return e[14]!==P||e[15]!==I?(y=t.jsxs(Ge,{children:[P,I]}),e[14]=P,e[15]=I,e[16]=y):y=e[16],y},Lr={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},vn=Lr.M;function Nn(r){const e=r.index?.trim(),s=r.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"}function Cn(r){const e=Nn(r);return Lr[e]??vn}const wr=i.memo(function(e){const s=wt.c(71),{file:c,checked:h,onToggle:g,onViewDiff:m,onRevert:a,isReverting:u,stats:N,rowPaddingClassName:R,indentPx:b}=e,P=b===void 0?0:b;let I;s[0]!==c?(I=Cn(c),s[0]=c,s[1]=I):I=s[1];const y=I,{t:T}=st(),j=y.description,f=N?.insertions??0,G=N?.deletions??0;let V;s[2]!==g||s[3]!==m?(V=E=>{E.key===" "?(E.preventDefault(),g()):E.key==="Enter"&&(E.preventDefault(),m())},s[2]=g,s[3]=m,s[4]=V):V=s[4];const q=V;let K;s[5]!==a?(K=E=>{E.preventDefault(),E.stopPropagation(),a()},s[5]=a,s[6]=K):K=s[6];const w=K,Y=`group flex items-center gap-2 py-1.5 hover:bg-sidebar/40 cursor-pointer ${R??"px-3"}`;let X;s[7]!==P?(X=P>0?{paddingLeft:`${P}px`}:void 0,s[7]=P,s[8]=X):X=s[8];let S;s[9]!==g?(S=()=>g(),s[9]=g,s[10]=S):S=s[10];let A;s[11]!==c.path||s[12]!==T?(A=T("gitView.changes.selectFileAria",{path:c.path}),s[11]=c.path,s[12]=T,s[13]=A):A=s[13];let z;s[14]!==h||s[15]!==S||s[16]!==A?(z=t.jsx("div",{className:"flex size-5 shrink-0 items-center justify-center",onClick:kn,children:t.jsx(ws,{size:"sm",checked:h,onChange:S,ariaLabel:A})}),s[14]=h,s[15]=S,s[16]=A,s[17]=z):z=s[17];let re;s[18]!==y.color?(re={color:y.color},s[18]=y.color,s[19]=re):re=s[19];let O;s[20]!==y.code||s[21]!==j||s[22]!==re?(O=t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:re,title:j,"aria-label":j,children:y.code}),s[20]=y.code,s[21]=j,s[22]=re,s[23]=O):O=s[23];let Q;s[24]!==c.path?(Q=t.jsx(Da,{filePath:c.path,className:"h-3.5 w-3.5 shrink-0"}),s[24]=c.path,s[25]=Q):Q=s[25];let te;if(s[26]!==c.path){e:{const E=c.path.lastIndexOf("/");if(E===-1){let ge;s[28]===Symbol.for("react.memo_cache_sentinel")?(ge={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},s[28]=ge):ge=s[28],te=t.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ge,title:c.path,children:c.path});break e}const ne=c.path.slice(0,E),B=c.path.slice(E);let me;s[29]===Symbol.for("react.memo_cache_sentinel")?(me={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},s[29]=me):me=s[29];let W;s[30]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx("span",{className:"text-muted-foreground",children:"/"}),s[30]=W):W=s[30];const Ae=t.jsx("span",{className:"text-foreground",children:B.slice(1)});let Ce;s[31]!==Ae?(Ce=t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[W,Ae]}),s[31]=Ae,s[32]=Ce):Ce=s[32],te=t.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:c.path,children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:me,children:ne}),Ce]})}s[26]=c.path,s[27]=te}else te=s[27];let se;s[33]===Symbol.for("react.memo_cache_sentinel")?(se={color:"var(--status-success)"},s[33]=se):se=s[33];let ie;s[34]!==f?(ie=t.jsxs("span",{style:se,children:["+",f]}),s[34]=f,s[35]=ie):ie=s[35];let Z,x;s[36]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),x={color:"var(--status-error)"},s[36]=Z,s[37]=x):(Z=s[36],x=s[37]);let F;s[38]!==G?(F=t.jsxs("span",{style:x,children:["-",G]}),s[38]=G,s[39]=F):F=s[39];let _;s[40]!==ie||s[41]!==F?(_=t.jsxs("span",{className:"shrink-0 typography-micro",children:[ie,Z,F]}),s[40]=ie,s[41]=F,s[42]=_):_=s[42];let ce;s[43]!==c.path||s[44]!==T?(ce=T("gitView.changes.revertFileAria",{path:c.path}),s[43]=c.path,s[44]=T,s[45]=ce):ce=s[45];let ae;s[46]!==u?(ae=u?t.jsx(C,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(C,{name:"arrow-go-back",className:"size-3.5"}),s[46]=u,s[47]=ae):ae=s[47];let oe;s[48]!==w||s[49]!==u||s[50]!==ce||s[51]!==ae?(oe=t.jsx(Ue,{asChild:!0,children:t.jsx("button",{type:"button",onClick:w,disabled:u,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":ce,children:ae})}),s[48]=w,s[49]=u,s[50]=ce,s[51]=ae,s[52]=oe):oe=s[52];let ue;s[53]!==T?(ue=T("gitView.changes.revertFileTooltip"),s[53]=T,s[54]=ue):ue=s[54];let le;s[55]!==ue?(le=t.jsx(We,{sideOffset:8,children:ue}),s[55]=ue,s[56]=le):le=s[56];let we;s[57]!==oe||s[58]!==le?(we=t.jsxs(Ge,{children:[oe,le]}),s[57]=oe,s[58]=le,s[59]=we):we=s[59];let L;return s[60]!==q||s[61]!==m||s[62]!==O||s[63]!==Q||s[64]!==te||s[65]!==_||s[66]!==we||s[67]!==Y||s[68]!==X||s[69]!==z?(L=t.jsxs("div",{className:Y,role:"button",tabIndex:0,onClick:m,onKeyDown:q,style:X,children:[z,O,Q,te,_,we]}),s[60]=q,s[61]=m,s[62]=O,s[63]=Q,s[64]=te,s[65]=_,s[66]=we,s[67]=Y,s[68]=X,s[69]=z,s[70]=L):L=s[70],L});function kn(r){r.stopPropagation()}const Sn=1e3,Vn=34,yr=14,Hr=r=>r.replace(/\\/g,"/").replace(/^\/+/,"").trim(),br=(r,e)=>({id:`dir:${r}`,path:r,name:e,children:new Map,directFiles:[],files:[]}),Rn=r=>{const e=br("","");for(const s of r){const c=Hr(s.path);if(!c)continue;const g=c.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(s),g.length>0){let a="";for(const u of g){a=a?`${a}/${u}`:u;const N=m.children.get(u);if(N){N.files.push(s),m=N;continue}const R=br(a,u);R.files.push(s),m.children.set(u,R),m=R}}m.directFiles.push(s)}return e},An=(r,e)=>{const s=[],c=(h,g)=>{const m=Array.from(h.children.values()).sort((u,N)=>u.path.localeCompare(N.path));for(const u of m)s.push({key:u.id,kind:"directory",depth:g,directory:u}),e.has(u.path)&&c(u,g+1);const a=[...h.directFiles].sort((u,N)=>u.path.localeCompare(N.path));for(const u of a)s.push({key:`file:${Hr(u.path)}`,kind:"file",depth:g,file:u})};return c(r,0),s},jr=(r,e)=>{if(r.files.length===0)return"none";let s=0;for(const c of r.files)e.has(c.path)&&(s+=1);return s===0?"none":s===r.files.length?"all":"partial"},In=({changeEntries:r,selectedPaths:e,diffStats:s,revertingPaths:c,onToggleFile:h,onSelectAll:g,onClearSelection:m,onRevertAll:a,onViewDiff:u,onRevertFile:N,isRevertingAll:R=!1,maxListHeightClassName:b,onVisiblePathsChange:P,onOpenStashes:I})=>{const{t:y}=st(),T=i.useRef(null),f=xt(L=>L.gitChangesViewMode)==="tree",G=e.size,V=r.length,[q,K]=i.useState(!1),w=i.useMemo(()=>Rn(r),[r]),[Y,X]=i.useState(new Set),S=i.useMemo(()=>Array.from(w.children.values()).map(L=>L.path),[w]);i.useEffect(()=>{f&&X(L=>{const E=new Set,ne=new Set(S);return L.forEach(B=>{if(B.includes("/")){E.add(B);return}ne.has(B)&&E.add(B)}),S.forEach(B=>E.add(B)),E})},[f,S]);const A=i.useMemo(()=>An(w,Y),[Y,w]),z=i.useMemo(()=>f?A:r,[r,f,A]),re=z.length,O=re>=Sn,Q=G>0,te=V>0&&G===V,se=Q&&!te,ie=Na({count:re,getScrollElement:()=>T.current,estimateSize:()=>Vn,overscan:10,enabled:O});i.useEffect(()=>{if(!O)return;const L=T.current;if(!L)return;const E=new ResizeObserver(()=>{ie.measure()});return E.observe(L),()=>E.disconnect()},[O,ie]);const Z=ie.getTotalSize(),x=i.useMemo(()=>O&&Z>=0?ie.getVirtualItems():[],[O,ie,Z]);i.useEffect(()=>{if(!P)return;if(re===0){P([]);return}const L=E=>{if(!f)return E.path;const ne=E;return ne.kind==="file"?ne.file.path:null};if(!O){P(z.slice(0,Math.min(30,re)).map(E=>L(E)).filter(E=>!!E));return}P(x.map(E=>z[E.index]).map(E=>E?L(E):null).filter(E=>!!E))},[f,P,re,z,O,x]);const F="flex flex-col flex-1 min-h-0",_="flex items-center justify-between gap-2 px-0 py-3 border-b border-border/40",ce=`flex-1 min-h-0 pr-0 ${b??""}`.trim(),ae="pl-0 pr-2",oe=i.useCallback(L=>{X(E=>{const ne=new Set(E);return ne.has(L)?ne.delete(L):ne.add(L),ne})},[]),ue=i.useCallback(L=>{const ne=jr(L,e)!=="all";for(const B of L.files){const me=e.has(B.path);(ne&&!me||!ne&&me)&&h(B.path)}},[h,e]),le=i.useCallback(L=>{if(!f){const W=L;return t.jsx(wr,{file:W,checked:e.has(W.path),stats:s?.[W.path],onToggle:()=>h(W.path),onViewDiff:()=>u(W.path),onRevert:()=>N(W.path),isReverting:c.has(W.path)||R,rowPaddingClassName:ae})}const E=L;if(E.kind==="file"){const W=E.file;return t.jsx(wr,{file:W,checked:e.has(W.path),stats:s?.[W.path],onToggle:()=>h(W.path),onViewDiff:()=>u(W.path),onRevert:()=>N(W.path),isReverting:c.has(W.path)||R,rowPaddingClassName:ae,indentPx:E.depth*yr})}const ne=E.directory,B=Y.has(ne.path),me=jr(ne,e);return t.jsxs("div",{className:_e("group flex items-center gap-2 py-1.5 hover:bg-sidebar/40",ae),style:{paddingLeft:`${E.depth*yr}px`},children:[t.jsx("div",{className:"flex size-5 shrink-0 items-center justify-center",children:t.jsx(ws,{size:"sm",checked:me==="all",indeterminate:me==="partial",onChange:()=>ue(ne),ariaLabel:y("gitView.changes.toggleDirectorySelectionAria",{path:ne.path})})}),t.jsxs("button",{type:"button",onClick:()=>oe(ne.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":B?y("gitView.changes.collapseDirectoryAria",{path:ne.path}):y("gitView.changes.expandDirectoryAria",{path:ne.path}),children:[B?t.jsx(C,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):t.jsx(C,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:ne.path,children:ne.name}),t.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:ne.files.length})]})]})},[s,Y,R,f,N,h,u,c,ae,e,y,oe,ue]),we=i.useCallback(async()=>{!a||R||r.length===0||(await a(r.map(L=>L.path)),K(!1))},[r,R,a]);return t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:F,children:[t.jsxs("header",{className:_,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:y("gitView.changes.title")}),V>0?t.jsxs("div",{className:_e("inline-flex h-6 items-center gap-1 rounded px-1.5",R&&"cursor-not-allowed opacity-50"),children:[t.jsx(ws,{size:"sm",checked:Q,indeterminate:se,disabled:R,onChange:()=>te?m():g(),ariaLabel:y(te?"gitView.changes.clearSelectionAria":"gitView.changes.selectAllAria")}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[G,"/",V]})]}):null,I?t.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-1.5",onClick:I,"aria-label":y("gitView.stashes.title"),title:y("gitView.stashes.title"),children:t.jsx(C,{name:"archive-stack",className:"size-4"})}):null]}),t.jsx("div",{className:"flex items-center gap-2 pr-1",children:V>0&&a?t.jsx(ee,{variant:"destructive",size:"xs",onClick:()=>K(!0),disabled:R,children:y("gitView.changes.revertAll")}):null})]}),t.jsxs("div",{className:_e("relative flex flex-col min-h-0 w-full overflow-hidden",ce),children:[t.jsx(ir,{ref:T,className:"overlay-scrollbar-target overlay-scrollbar-container flex-1 min-h-0 w-full overflow-y-auto overflow-x-hidden",children:O?t.jsx("div",{className:"relative w-full",style:{height:`${ie.getTotalSize()}px`},children:x.map(L=>{const E=z[L.index];if(!E)return null;const ne=f?E.key:`file:${E.path}`;return t.jsx("div",{ref:ie.measureElement,"data-index":L.index,className:_e("absolute left-0 top-0 w-full",L.index>0&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),style:{transform:`translateY(${L.start}px)`},children:le(E)},ne)})}):t.jsx("div",{role:"list","aria-label":y("gitView.changes.changedFilesAria"),children:z.map((L,E)=>t.jsx("div",{className:_e("relative",E>0&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:le(L)},f?L.key:`file:${L.path}`))})}),t.jsx(Ea,{containerRef:T,disableHorizontal:!0})]})]}),t.jsx(Vt,{open:q,onOpenChange:L=>{R||K(L)},children:t.jsxs(Rt,{className:"max-w-md",children:[t.jsxs(At,{children:[t.jsx(It,{children:y("gitView.changes.revertAllDialogTitle")}),t.jsx(Wt,{children:V===1?y("gitView.changes.revertAllDescriptionSingle",{count:V}):y("gitView.changes.revertAllDescriptionPlural",{count:V})})]}),t.jsxs(Ps,{children:[t.jsx(ee,{variant:"outline",size:"sm",onClick:()=>K(!1),disabled:R,children:y("gitView.common.cancel")}),t.jsx(ee,{variant:"destructive",size:"sm",onClick:()=>{we()},disabled:R,children:y(R?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})})]})},Js=38,Ds=200,Dn=r=>{const e=wt.c(20),{value:s,onChange:c,placeholder:h,disabled:g,hasTouchInput:m,isMobile:a}=r,u=g===void 0?!1:g,N=m===void 0?!1:m,R=a===void 0?!1:a,{t:b}=st(),P=i.useRef(null),I=xt(En);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{const S=P.current;if(!S)return;const A=document.activeElement===S,z=()=>{S.style.height=`${Js}px`;const O=S.scrollHeight,Q=Math.min(Math.max(O,Js),Ds);S.style.height=`${Q}px`,S.style.overflowY=O>Ds?"auto":"hidden",O>Ds&&!A&&(S.scrollTop=S.scrollHeight)};z();const re=window.requestAnimationFrame(z);return()=>{window.cancelAnimationFrame(re)}},e[0]=y):y=e[0];let T;e[1]!==s?(T=[s],e[1]=s,e[2]=T):T=e[2],i.useLayoutEffect(y,T);let j;e[3]!==c?(j=S=>c(S.target.value),e[3]=c,e[4]=j):j=e[4];let f;e[5]!==h||e[6]!==b?(f=h??b("gitView.commit.messagePlaceholder"),e[5]=h,e[6]=b,e[7]=f):f=e[7];const G=N?"on":"off",V=N?"sentences":"off",q=R||I,K=u&&"opacity-50";let w;e[8]!==K?(w=_e("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",K),e[8]=K,e[9]=w):w=e[9];let Y;e[10]===Symbol.for("react.memo_cache_sentinel")?(Y={minHeight:Js,maxHeight:Ds},e[10]=Y):Y=e[10];let X;return e[11]!==u||e[12]!==q||e[13]!==w||e[14]!==j||e[15]!==f||e[16]!==G||e[17]!==V||e[18]!==s?(X=t.jsx("textarea",{ref:P,value:s,onChange:j,placeholder:f,rows:1,disabled:u,autoCorrect:G,autoCapitalize:V,spellCheck:q,className:w,style:Y}),e[11]=u,e[12]=q,e[13]=w,e[14]=j,e[15]=f,e[16]=G,e[17]=V,e[18]=s,e[19]=X):X=e[19],X};function En(r){return r.inputSpellcheckEnabled}const Pn=r=>{const e=wt.c(30),{highlights:s,onInsert:c}=r,{t:h}=st();if(s.length===0)return null;let g;e[0]!==s||e[1]!==c?(g=()=>{c(s)},e[0]=s,e[1]=c,e[2]=g):g=e[2];const m=g;let a;e[3]!==h?(a=h("gitView.commit.aiHighlights.title"),e[3]=h,e[4]=a):a=e[4];let u;e[5]!==a?(u=t.jsx("p",{className:"typography-micro text-muted-foreground",children:a}),e[5]=a,e[6]=u):u=e[6];let N;e[7]!==h?(N=h("gitView.commit.aiHighlights.insertAria"),e[7]=h,e[8]=N):N=e[8];let R;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(C,{name:"arrow-down",className:"size-4"}),e[9]=R):R=e[9];let b;e[10]!==m||e[11]!==N?(b=t.jsx(Ue,{asChild:!0,children:t.jsx(ee,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":N,children:R})}),e[10]=m,e[11]=N,e[12]=b):b=e[12];let P;e[13]!==h?(P=h("gitView.commit.aiHighlights.insertTooltip"),e[13]=h,e[14]=P):P=e[14];let I;e[15]!==P?(I=t.jsx(We,{sideOffset:8,children:P}),e[15]=P,e[16]=I):I=e[16];let y;e[17]!==b||e[18]!==I?(y=t.jsxs(Ge,{children:[b,I]}),e[17]=b,e[18]=I,e[19]=y):y=e[19];let T;e[20]!==u||e[21]!==y?(T=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u,y]}),e[20]=u,e[21]=y,e[22]=T):T=e[22];let j;e[23]!==s?(j=s.map(Tn),e[23]=s,e[24]=j):j=e[24];let f;e[25]!==j?(f=t.jsx("ul",{className:"space-y-1",children:j}),e[25]=j,e[26]=f):f=e[26];let G;return e[27]!==T||e[28]!==f?(G=t.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[T,f]}),e[27]=T,e[28]=f,e[29]=G):G=e[29],G};function Tn(r,e){return t.jsx("li",{className:"typography-meta text-foreground",children:r},`${r}-${e}`)}const zn=r=>{const e=wt.c(72),{selectedCount:s,commitMessage:c,onCommitMessageChange:h,generatedHighlights:g,onInsertHighlights:m,onGenerateMessage:a,isGeneratingMessage:u,onCommit:N,onCommitAndPush:R,commitAction:b,gitmojiEnabled:P,onOpenGitmojiPicker:I}=r,{t:y}=st(),T=s>0;let j;e[0]!==b||e[1]!==c||e[2]!==T?(j=c.trim()&&T&&b===null,e[0]=b,e[1]=c,e[2]=T,e[3]=j):j=e[3];const f=j,{isMobile:G,hasTouchInput:V}=Fr();let q;e[4]!==y?(q=y("gitView.commit.title"),e[4]=y,e[5]=q):q=e[5];let K;e[6]!==q?(K=t.jsx("div",{className:"flex w-full items-center justify-between px-0 pt-2 pb-1",children:t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:q})}),e[6]=q,e[7]=K):K=e[7];let w;e[8]!==T||e[9]!==y?(w=T?null:t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.commit.selectFilesHint")}),e[8]=T,e[9]=y,e[10]=w):w=e[10];let Y;e[11]!==g||e[12]!==m?(Y=t.jsx(Pn,{highlights:g,onInsert:m}),e[11]=g,e[12]=m,e[13]=Y):Y=e[13];let X;e[14]!==y?(X=y("gitView.commit.messagePlaceholder"),e[14]=y,e[15]=X):X=e[15];const S=b!==null;let A;e[16]!==c||e[17]!==V||e[18]!==G||e[19]!==h||e[20]!==X||e[21]!==S?(A=t.jsx(Dn,{value:c,onChange:h,placeholder:X,disabled:S,hasTouchInput:V,isMobile:G}),e[16]=c,e[17]=V,e[18]=G,e[19]=h,e[20]=X,e[21]=S,e[22]=A):A=e[22];let z;e[23]!==P||e[24]!==I||e[25]!==y?(z=P&&t.jsxs(ee,{variant:"outline",size:"sm",onClick:I,className:"w-fit",type:"button",children:[t.jsx(C,{name:"emotion-happy",className:"size-4"}),y("gitView.commit.addGitmoji")]}),e[23]=P,e[24]=I,e[25]=y,e[26]=z):z=e[26];const re=u||b!==null||s===0;let O;e[27]!==y?(O=y("gitView.commit.generateAria"),e[27]=y,e[28]=O):O=e[28];let Q;e[29]!==u?(Q=u?t.jsx(C,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(C,{name:"ai-generate-2",className:"size-4 text-primary"}),e[29]=u,e[30]=Q):Q=e[30];let te;e[31]!==y?(te=y("gitView.commit.generate"),e[31]=y,e[32]=te):te=e[32];let se;e[33]!==te?(se=t.jsx("span",{className:"commit-actions__label",children:te}),e[33]=te,e[34]=se):se=e[34];let ie;e[35]!==a||e[36]!==re||e[37]!==O||e[38]!==Q||e[39]!==se?(ie=t.jsxs(ee,{variant:"outline",size:"sm",onClick:a,disabled:re,type:"button","aria-label":O,className:"commit-actions__btn",children:[Q,se]}),e[35]=a,e[36]=re,e[37]=O,e[38]=Q,e[39]=se,e[40]=ie):ie=e[40];let Z;e[41]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx("div",{className:"flex-1"}),e[41]=Z):Z=e[41];const x=!f||u;let F;e[42]!==y?(F=y("gitView.commit.commitAria"),e[42]=y,e[43]=F):F=e[43];let _;e[44]!==b||e[45]!==y?(_=b==="commit"?t.jsxs(t.Fragment,{children:[t.jsx(C,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"commit-actions__label",children:y("gitView.commit.committing")})]}):t.jsxs(t.Fragment,{children:[t.jsx(C,{name:"git-commit",className:"size-4"}),t.jsx("span",{className:"commit-actions__label",children:y("gitView.commit.commit")})]}),e[44]=b,e[45]=y,e[46]=_):_=e[46];let ce;e[47]!==N||e[48]!==x||e[49]!==F||e[50]!==_?(ce=t.jsx(ee,{size:"sm",variant:"outline",onClick:N,disabled:x,className:"commit-actions__btn whitespace-nowrap","aria-label":F,children:_}),e[47]=N,e[48]=x,e[49]=F,e[50]=_,e[51]=ce):ce=e[51];let ae;e[52]!==f||e[53]!==b||e[54]!==u||e[55]!==G||e[56]!==R||e[57]!==y?(ae=G?t.jsxs(Ge,{children:[t.jsx(Ue,{asChild:!0,children:t.jsx(ee,{variant:"default",size:"sm",onClick:()=>R(),disabled:!f||u,className:"h-7 w-7 p-0","aria-label":y("gitView.commit.pushAria"),children:b==="commitAndPush"?t.jsx(C,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(C,{name:"arrow-up",className:"size-3.5"})})}),t.jsx(We,{side:"top",children:t.jsx("p",{children:y("gitView.commit.push")})})]}):t.jsx(ee,{size:"sm",variant:"default",onClick:()=>R(),disabled:!f||u,className:"commit-actions__btn","aria-label":y("gitView.commit.pushAria"),children:b==="commitAndPush"?t.jsxs(t.Fragment,{children:[t.jsx(C,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"commit-actions__label",children:y("gitView.commit.pushing")})]}):t.jsxs(t.Fragment,{children:[t.jsx(C,{name:"arrow-up",className:"size-3.5"}),t.jsx("span",{className:"commit-actions__label",children:y("gitView.commit.push")})]})}),e[52]=f,e[53]=b,e[54]=u,e[55]=G,e[56]=R,e[57]=y,e[58]=ae):ae=e[58];let oe;e[59]!==ie||e[60]!==ce||e[61]!==ae?(oe=t.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[ie,Z,ce,ae]}),e[59]=ie,e[60]=ce,e[61]=ae,e[62]=oe):oe=e[62];let ue;e[63]!==oe||e[64]!==w||e[65]!==Y||e[66]!==A||e[67]!==z?(ue=t.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[w,Y,A,z,oe]}),e[63]=oe,e[64]=w,e[65]=Y,e[66]=A,e[67]=z,e[68]=ue):ue=e[68];let le;return e[69]!==ue||e[70]!==K?(le=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[K,ue]}),e[69]=ue,e[70]=K,e[71]=le):le=e[71],le},Fn=r=>{const e=wt.c(16),{onOpenStashes:s}=r,{t:c}=st();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(C,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=h):h=e[0];let g;e[1]!==c?(g=c("gitView.empty.cleanTitle"),e[1]=c,e[2]=g):g=e[2];let m;e[3]!==g?(m=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:g}),e[3]=g,e[4]=m):m=e[4];let a;e[5]!==c?(a=c("gitView.empty.cleanDescription"),e[5]=c,e[6]=a):a=e[6];let u;e[7]!==a?(u=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:a}),e[7]=a,e[8]=u):u=e[8];let N;e[9]!==s||e[10]!==c?(N=s?t.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:s,className:"gap-1.5",children:[t.jsx(C,{name:"archive-stack",className:"size-4"}),c("gitView.stashes.title")]}):null,e[9]=s,e[10]=c,e[11]=N):N=e[11];let R;return e[12]!==m||e[13]!==u||e[14]!==N?(R=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[h,m,u,N]}),e[12]=m,e[13]=u,e[14]=N,e[15]=R):R=e[15],R},vr=15e3,Nr=500,Cr=12,kr=8*1024*1024,Sr=r=>typeof r=="string"?0:(r.original?.length??0)+(r.modified?.length??0),Vr=r=>{if(r.size<=Cr){let h=0;for(const g of r.values())h+=Sr(g);if(h<=kr)return r}const e=Array.from(r.entries()).reverse(),s=new Map;let c=0;for(const[h,g]of e){if(s.size>=Cr)continue;const m=Sr(g);c+m>kr&&s.size>0||(s.set(h,g),c+=m)}return new Map(Array.from(s.entries()).reverse())};function Rr(r){const e=new Date(r);return Number.isNaN(e.getTime())?r:e.toLocaleString(void 0,{hour12:!1,year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Mn(r){switch(r){case"A":return"text-[var(--status-success)]";case"D":return"text-[var(--status-error)]";case"M":return"text-[var(--status-warning)]";case"R":return"text-[var(--status-info)]";default:return"text-muted-foreground"}}const Bn=i.memo(r=>{const e=wt.c(71),{entry:s,isExpanded:c,onToggle:h,files:g,isLoadingFiles:m,onCopyHash:a,directory:u}=r,{t:N}=st();let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R=new Set,e[0]=R):R=e[0];const[b,P]=i.useState(R);let I;e[1]===Symbol.for("react.memo_cache_sentinel")?(I=new Map,e[1]=I):I=e[1];const[y,T]=i.useState(I);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=new Set,e[2]=j):j=e[2];const[f,G]=i.useState(j);let V;e[3]!==u||e[4]!==s.hash?(V=async B=>{const me=B.path;if(!u){T(W=>new Map(W).set(me,"error"));return}T(W=>Vr(new Map(W).set(me,"loading")));try{const W=Ta(u,s.hash,B.path,!1),Ae=new Promise(_n),Ce=await Promise.race([W,Ae]);T(ge=>Vr(new Map(ge).set(me,Ce)))}catch{T(W=>new Map(W).set(me,"error"))}},e[3]=u,e[4]=s.hash,e[5]=V):V=e[5];const q=V;let K;e[6]!==y||e[7]!==f||e[8]!==q||e[9]!==b?(K=async B=>{const me=B.path;if(B.changeType==="R"||B.isBinary){P(ge=>{const be=new Set(ge);return be.has(me)?be.delete(me):be.add(me),be});return}const W=y.get(me);if(b.has(me)&&W&&W!=="error"){P(ge=>{const be=new Set(ge);return be.delete(me),be});return}P(ge=>{const be=new Set(ge);return be.add(me),be}),!(W&&W!=="error"||B.insertions+B.deletions>Nr&&!f.has(me))&&await q(B)},e[6]=y,e[7]=f,e[8]=q,e[9]=b,e[10]=K):K=e[10];const w=K,Y=c?"bg-sidebar/90":"hover:bg-sidebar/40";let X;e[11]!==Y?(X=_e("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",Y),e[11]=Y,e[12]=X):X=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),e[13]=S):S=e[13];let A;e[14]!==s.message?(A=t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:s.message}),e[14]=s.message,e[15]=A):A=e[15];let z;e[16]!==s.author_name?(z=t.jsx("span",{className:"truncate min-w-[3ch]",title:s.author_name,children:s.author_name}),e[16]=s.author_name,e[17]=z):z=e[17];let re;e[18]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsx("span",{className:"shrink-0",children:"·"}),e[18]=re):re=e[18];let O;e[19]!==s.date?(O=Rr(s.date),e[19]=s.date,e[20]=O):O=e[20];let Q;e[21]!==s.date?(Q=Rr(s.date),e[21]=s.date,e[22]=Q):Q=e[22];let te;e[23]!==O||e[24]!==Q?(te=t.jsx("span",{className:"truncate min-w-0",title:O,children:Q}),e[23]=O,e[24]=Q,e[25]=te):te=e[25];let se;e[26]!==z||e[27]!==te?(se=t.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[z,re,te]}),e[26]=z,e[27]=te,e[28]=se):se=e[28];let ie;e[29]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsx("span",{className:"shrink-0",children:"·"}),e[29]=ie):ie=e[29];let Z;e[30]!==s.hash?(Z=s.hash.slice(0,8),e[30]=s.hash,e[31]=Z):Z=e[31];let x;e[32]!==Z?(x=t.jsx("code",{className:"shrink-0 font-mono",children:Z}),e[32]=Z,e[33]=x):x=e[33];let F;e[34]!==s.hash||e[35]!==a?(F=B=>{B.stopPropagation(),a(s.hash)},e[34]=s.hash,e[35]=a,e[36]=F):F=e[36];let _;e[37]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx(C,{name:"file-copy",className:"size-3"}),e[37]=_):_=e[37];let ce;e[38]!==F?(ce=t.jsx(Ue,{asChild:!0,children:t.jsx(ee,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:F,children:_})}),e[38]=F,e[39]=ce):ce=e[39];let ae;e[40]!==N?(ae=N("gitView.history.copySha"),e[40]=N,e[41]=ae):ae=e[41];let oe;e[42]!==ae?(oe=t.jsx(We,{sideOffset:8,children:ae}),e[42]=ae,e[43]=oe):oe=e[43];let ue;e[44]!==ce||e[45]!==oe?(ue=t.jsxs(Ge,{children:[ce,oe]}),e[44]=ce,e[45]=oe,e[46]=ue):ue=e[46];let le;e[47]!==se||e[48]!==x||e[49]!==ue?(le=t.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[se,ie,x,ue]}),e[47]=se,e[48]=x,e[49]=ue,e[50]=le):le=e[50];let we;e[51]!==le||e[52]!==A?(we=t.jsxs("div",{className:"min-w-0 flex-1",children:[A,le]}),e[51]=le,e[52]=A,e[53]=we):we=e[53];let L;e[54]!==h||e[55]!==we||e[56]!==X?(L=t.jsxs("button",{type:"button",onClick:h,className:X,children:[S,we]}),e[54]=h,e[55]=we,e[56]=X,e[57]=L):L=e[57];let E;e[58]!==y||e[59]!==g||e[60]!==f||e[61]!==c||e[62]!==m||e[63]!==q||e[64]!==b||e[65]!==N||e[66]!==w?(E=c&&t.jsx("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:m?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(C,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:N("gitView.history.loadingFiles")})]}):g.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:N("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:g.map(B=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>w(B),className:_e("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",b.has(B.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:_e("font-semibold w-3 text-center shrink-0",Mn(B.changeType)),children:B.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:B.path,children:B.path}),!B.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",B.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",B.deletions]})]}),B.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:N("gitView.history.binary")}),t.jsx(C,{name:b.has(B.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),b.has(B.path)&&t.jsx("div",{className:"max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:B.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:N("gitView.history.renamedNoDiff")}):B.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:N("gitView.history.binaryNoDiff")}):(()=>{const me=B.insertions+B.deletions;if(!f.has(B.path)&&me>Nr)return t.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:N("gitView.history.largeDiffTitle",{count:me})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:N("gitView.history.largeDiffDescription")}),t.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{G(Ae=>new Set(Ae).add(B.path)),q(B)},children:N("gitView.history.renderDiffAnyway")})]});const W=y.get(B.path);return W==="loading"||W===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:N("gitView.history.loadingDiff")}):W==="error"?t.jsx("button",{type:"button",onClick:()=>w(B),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:N("gitView.history.diffError")}):t.jsx(tn,{original:W.original,modified:W.modified,language:Pa(B.path)||"",fileName:B.path,renderSideBySide:!1,layout:"inline"})})()})]},B.path))})}),e[58]=y,e[59]=g,e[60]=f,e[61]=c,e[62]=m,e[63]=q,e[64]=b,e[65]=N,e[66]=w,e[67]=E):E=e[67];let ne;return e[68]!==L||e[69]!==E?(ne=t.jsxs("li",{children:[L,E]}),e[68]=L,e[69]=E,e[70]=ne):ne=e[70],ne});function _n(r,e){setTimeout(()=>e(new Error(`Timed out after ${vr}ms`)),vr)}const $n=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],On=r=>{const e=wt.c(56),{log:s,isLogLoading:c,logMaxCount:h,onLogMaxCountChange:g,expandedCommitHashes:m,onToggleCommit:a,commitFilesMap:u,loadingCommitHashes:N,onCopyHash:R,directory:b,showHeader:P,contentMaxHeightClassName:I,branchDivider:y}=r,T=P===void 0?!0:P,j=I===void 0?"max-h-[50vh]":I,f=y===void 0?null:y,{t:G}=st(),[V,q]=i.useState(!0);if(!s)return null;const K=f!==null&&f.insertBeforeIndex>0&&f.insertBeforeIndex<s.all.length,w=f!==null&&f.insertBeforeIndex===s.all.length,Y=K||w;let X;e[0]!==f||e[1]!==K||e[2]!==w||e[3]!==s.all?(X=K?s.all.slice(0,f.insertBeforeIndex):w?s.all:[],e[0]=f,e[1]=K,e[2]=w,e[3]=s.all,e[4]=X):X=e[4];const S=X;let A;if(e[5]!==f||e[6]!==u||e[7]!==j||e[8]!==b||e[9]!==m||e[10]!==K||e[11]!==Y||e[12]!==N||e[13]!==s.all||e[14]!==R||e[15]!==a||e[16]!==G||e[17]!==S){const F=K?s.all.slice(f.insertBeforeIndex):[];let _;e[19]!==f?.direction?(_=f?.direction==="down"?t.jsx(C,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(C,{name:"arrow-up",className:"size-3.5"}),e[19]=f?.direction,e[20]=_):_=e[20];const ce=_;let ae;e[21]!==u||e[22]!==b||e[23]!==m||e[24]!==N||e[25]!==R||e[26]!==a?(ae=ue=>t.jsx("ul",{className:"divide-y divide-border/60",children:ue.map(le=>t.jsx(Bn,{entry:le,isExpanded:m.has(le.hash),onToggle:()=>a(le.hash),files:u.get(le.hash)??[],isLoadingFiles:N.has(le.hash),onCopyHash:R,directory:b},le.hash))}),e[21]=u,e[22]=b,e[23]=m,e[24]=N,e[25]=R,e[26]=a,e[27]=ae):ae=e[27];const oe=ae;A=t.jsx(Mr,{outerClassName:`min-h-0 ${j}`,className:"h-full w-full",children:s.all.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:G("gitView.history.noCommits")})}):Y&&f?t.jsxs("div",{className:"flex flex-col gap-0",children:[S.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:oe(S)}):null,t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"h-px flex-1 bg-border/60"}),t.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[t.jsx("span",{className:"truncate",title:f.branchName,children:f.branchName}),ce]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),F.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:oe(F)}):null]}):oe(s.all)}),e[5]=f,e[6]=u,e[7]=j,e[8]=b,e[9]=m,e[10]=K,e[11]=Y,e[12]=N,e[13]=s.all,e[14]=R,e[15]=a,e[16]=G,e[17]=S,e[18]=A}else A=e[18];const z=A;if(!T){if(Y){let _;return e[28]!==z?(_=t.jsx("section",{className:"h-full min-h-0",children:z}),e[28]=z,e[29]=_):_=e[29],_}let F;return e[30]!==z?(F=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:z}),e[30]=z,e[31]=F):F=e[31],F}let re;e[32]!==G?(re=G("gitView.history.title"),e[32]=G,e[33]=re):re=e[33];let O;e[34]!==re?(O=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:re}),e[34]=re,e[35]=O):O=e[35];let Q;e[36]!==c||e[37]!==V||e[38]!==h||e[39]!==g||e[40]!==G?(Q=V&&t.jsx("div",{onClick:Ln,onPointerDown:Hn,children:t.jsxs(Qs,{value:String(h),onValueChange:F=>g(Number(F)),disabled:c,children:[t.jsx(er,{size:"sm",className:"data-[size=sm]:h-auto h-7 min-h-7 w-auto justify-between px-2 py-0",disabled:c,children:t.jsx(tr,{placeholder:G("gitView.history.commitsPlaceholder")})}),t.jsx(sr,{children:$n.map(F=>t.jsx(ps,{value:String(F.value),children:G(F.labelKey)},F.value))})]})}),e[36]=c,e[37]=V,e[38]=h,e[39]=g,e[40]=G,e[41]=Q):Q=e[41];let te;e[42]!==V?(te=V?t.jsx(C,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(C,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[42]=V,e[43]=te):te=e[43];let se;e[44]!==Q||e[45]!==te?(se=t.jsxs("div",{className:"flex items-center gap-2",children:[Q,te]}),e[44]=Q,e[45]=te,e[46]=se):se=e[46];let ie;e[47]!==se||e[48]!==O?(ie=t.jsxs($r,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[O,se]}),e[47]=se,e[48]=O,e[49]=ie):ie=e[49];let Z;e[50]!==z?(Z=t.jsx(rr,{children:z}),e[50]=z,e[51]=Z):Z=e[51];let x;return e[52]!==V||e[53]!==ie||e[54]!==Z?(x=t.jsxs(ar,{open:V,onOpenChange:q,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[ie,Z]}),e[52]=V,e[53]=ie,e[54]=Z,e[55]=x):x=e[55],x};function Ln(r){return r.stopPropagation()}function Hn(r){return r.stopPropagation()}const Gn=r=>{switch(r){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},Un=r=>{const e=r?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const s=r?.checks?.state==="failure",c=typeof e.mergeableState=="string"?e.mergeableState:"",h=e.mergeable===!1||c==="blocked"||c==="dirty";return s||h?"blocked":"open"},Wn=[2e3,5e3],Ar=r=>r.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Ot=r=>{let e=r.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},qn=(r,e)=>{const s=Ot(r);if(!s||s.includes("->"))return"";if(e){const h=`${e}/`;return s.startsWith(h)?s.slice(h.length).trim():""}const c=s.indexOf("/");return c>0?s.slice(c+1).trim():s},Kn=(r,e)=>`${r}::${e}`,ur=r=>{const e=String(r||"").trim();if(!e)return"";const s=e.indexOf("/");return s<=0?"":e.slice(0,s).trim()},Ys=(r,e)=>{if(r.length===0)return null;const s=String(e.selectedRemoteName||"").trim();if(s){const g=r.find(m=>m.name===s);if(g)return g}const c=ur(e.trackingBranch);if(c){const g=c==="origin"?r.find(a=>a.name==="upstream"):null;if(g)return g;const m=r.find(a=>a.name===c);if(m)return m}const h=r.find(g=>g.name==="origin");return h||(r[0]??null)},Jn=r=>r.startsWith("pr-"),Yn=(r,e)=>{const s=ur(e),c=new Map(r.map(m=>[m.name,m])),h=[],g=m=>{m&&(h.some(a=>a.name===m.name)||h.push(m))};return s&&g(c.get(s)),g(c.get("upstream")),g(c.get("origin")),r.filter(m=>!Jn(m.name)).forEach(m=>g(m)),r.forEach(m=>g(m)),h},Xs=new Map,Zs=Ba;function Xn(r,e){const[s,c]=i.useState(null),[h,g]=i.useState([]),m=i.useRef(null);return i.useEffect(()=>{c(null),g([])},[r]),i.useEffect(()=>{if(!r||!e?.repoUpstream||m.current===r)return;m.current=r;let a=!1;return(async()=>{try{const u=await e.repoUpstream(r);if(a||!u?.isFork||!u.upstream||(c(u.upstream),!e.repoBranches))return;try{const N=await e.repoBranches(u.upstream.owner,u.upstream.repo);a||g(N)}catch{}}catch{}})(),()=>{a=!0}},[r,e]),{detectedUpstream:s,upstreamBranches:h}}const Zn=({directory:r,branch:e,baseBranch:s,trackingBranch:c,remotes:h=[],remoteBranches:g=[],onGeneratedDescription:m})=>{const{t:a}=st(),{github:u}=Br(),N=pr(o=>o.status),R=pr(o=>o.hasChecked),b=xt(o=>o.setSettingsDialogOpen),P=xt(o=>o.setSettingsPage),I=xt(o=>o.setActiveMainTab),y=ht(o=>o.currentSessionId),{isMobile:T,hasTouchInput:j}=Fr(),f=i.useCallback(()=>{P("github"),b(!0)},[b,P]),G=i.useMemo(()=>Kn(r,e),[r,e]),V=i.useMemo(()=>Xs.get(G)??null,[G]),q=Ht(o=>o.ensureEntry),K=Ht(o=>o.setParams),w=Ht(o=>o.startWatching),Y=Ht(o=>o.stopWatching),X=Ht(o=>o.refresh),S=Ht(o=>o.updateStatus),[A,z]=i.useState(()=>V?.title??Ar(e)),[re,O]=i.useState(()=>V?.body??""),[Q,te]=i.useState(()=>V?.draft??!1),[se,ie]=i.useState(()=>V?.additionalContext??""),[Z,x]=i.useState(()=>{const o=typeof V?.targetBaseBranch=="string"?Ot(V.targetBaseBranch):"";return o||Ot(s)}),[F,_]=i.useState("squash"),[ce,ae]=i.useState(!1),[oe,ue]=i.useState(!1),[le,we]=i.useState(!1),[L,E]=i.useState(!1),[ne,B]=i.useState(!1),[me,W]=i.useState(!1),[Ae,Ce]=i.useState(null),[ge,be]=i.useState(""),[Xe,qe]=i.useState(""),[Oe,Ze]=i.useState(!1),[Qe,Me]=i.useState(!1),[fe,Fe]=i.useState(()=>Ys(h,{selectedRemoteName:V?.selectedRemoteName,trackingBranch:c})),[ke,je]=i.useState(!1),{detectedUpstream:xe,upstreamBranches:Le}=Xn(r,u);i.useEffect(()=>{je(!1)},[r]);const He=h.some(o=>o.name==="upstream"),Ee=!!(r&&e&&s&&(e!==s||(He||xe!==null))),ve=i.useMemo(()=>sn(r,e),[r,e]),$e=Ht(o=>o.entries[ve]),Ke=$e?.isLoading??!1,Ve=$e?.status??null,he=$e?.error??null,Te=$e?.isInitialStatusResolved??!1,Re=i.useMemo(()=>{const o=ke?null:fe?.name?.trim()||null,k=new Set;for(const de of g){const H=qn(de,o);!H||H==="HEAD"||k.add(H)}if(ke)for(const de of Le)de&&de!=="HEAD"&&k.add(de);const M=Ot(s);M&&M!=="HEAD"&&k.add(M);const U=Ot(Z);return U&&U!=="HEAD"&&k.add(U),Array.from(k).sort((de,H)=>de.localeCompare(H))},[s,g,fe?.name,Z,Le,ke]);i.useEffect(()=>{if(h.length===0){fe&&Fe(null);return}(!fe||!h.some(o=>o.name===fe.name))&&Fe(Ys(h,{selectedRemoteName:V?.selectedRemoteName,trackingBranch:c}))},[V?.selectedRemoteName,h,fe,c]),i.useEffect(()=>{const o=Ot(s);if(!Z&&o){x(o);return}if(Re.length!==0&&!Re.includes(Z)){const k=Re.includes(o)?o:Re[0];k&&x(k)}},[Re,s,Z]);const[Ne,De]=i.useState(!1),[Je,nt]=i.useState(null),[ft,Lt]=i.useState(!1),[qt,is]=i.useState(new Set),[_s,os]=i.useState(!1),[Et,ys]=i.useState(null),[Kt,ls]=i.useState(!1),Jt=i.useRef(new Set),Pt=i.useRef(null),Yt=i.useRef(!1),bs=i.useRef(new Set),Xt=i.useRef([]);i.useEffect(()=>{xe&&!He&&je(!0)},[xe,He]),i.useEffect(()=>{ke&&xe?.defaultBranch&&x(xe.defaultBranch)},[ke,xe?.defaultBranch]);const $=Ve?.pr??null,Zt=$?`${r}#${$.number}`:null,$s=!!(Zt&&Ae===Zt);i.useEffect(()=>{if(!u?.prContext||!$||typeof $.body=="string"&&$.body.length>0)return;const o=`${r}#${$.number}`;if(Jt.current.has(o))return;Jt.current.add(o),Ce(o);let k=!1;return u.prContext(r,$.number,{includeDiff:!1,includeCheckDetails:!1}).then(M=>{if(k)return;const U=M?.pr;U&&S(ve,de=>!de?.pr||de.pr.number!==$.number?de:{...de,pr:{...de.pr,body:U.body||""}})}).catch(()=>{}).finally(()=>{k||Ce(M=>M===o?null:M)}),()=>{k=!0}},[r,u,$,ve,S]),i.useEffect(()=>{if(!$){W(!1),be(""),qe(""),Pt.current=null;return}const o=Pt.current!==null&&Pt.current!==$.number;o&&W(!1),(!me||o)&&(be($.title||""),qe($.body||"")),Pt.current=$.number},[me,$]);const cs=i.useCallback(async()=>{if(!u?.prContext){v.error(a("gitView.pr.toast.githubApiUnavailable"));return}if($){De(!0),is(new Set),Lt(!0);try{const o=await u.prContext(r,$.number,{includeDiff:!1,includeCheckDetails:!0});nt(o)}catch(o){const k=o instanceof Error?o.message:String(o);v.error(a("gitView.pr.toast.loadCheckDetailsFailed"),{description:k})}finally{Lt(!1)}}},[r,u,$,a]),js=i.useCallback(async()=>{if(!u?.prContext){v.error(a("gitView.pr.toast.githubApiUnavailable"));return}if($){os(!0),ls(!0);try{const o=await u.prContext(r,$.number,{includeDiff:!1,includeCheckDetails:!1});ys(o)}catch(o){const k=o instanceof Error?o.message:String(o);v.error(a("gitView.pr.toast.loadCommentsFailed"),{description:k})}finally{ls(!1)}}},[r,u,$,a]),Tt=i.useCallback(o=>{if(!o)return"";const k=Date.parse(o);return Number.isFinite(k)?new Date(k).toLocaleString():o},[]),ds=i.useMemo(()=>{const o=N?.user?.login;return typeof o=="string"?o.trim():""},[N]),Os=i.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),zt=i.useCallback(o=>{const k=ds.toLowerCase(),M=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return o.replace(M,(U,de,H)=>{const Be=`@${H}`,dt=H.toLowerCase();return`${de}[${Be}](https://github.com/${dt}${k&&dt===k?"?oc-self-mention=1":""})`})},[ds]),gt=i.useMemo(()=>{const o=(Et?.issueComments??[]).map(U=>({id:`issue-${U.id}`,body:U.body||"",authorName:U.author?.name||U.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:U.author?.login||null,avatarUrl:U.author?.avatarUrl||null,createdAt:U.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),k=(Et?.reviewComments??[]).map(U=>({id:`review-${U.id}`,body:U.body||"",authorName:U.author?.name||U.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:U.author?.login||null,avatarUrl:U.author?.avatarUrl||null,createdAt:U.createdAt,context:a("gitView.pr.comments.reviewContext"),path:U.path||null,line:U.line??null})),M=[...o,...k];return M.sort((U,de)=>{const H=U.createdAt?Date.parse(U.createdAt):0,Be=de.createdAt?Date.parse(de.createdAt):0,dt=Number.isFinite(H)?H:0,et=Number.isFinite(Be)?Be:0;return dt-et}),M},[Et,a]),yt=i.useCallback(()=>{if(!y)return v.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null;const{currentProviderId:o,currentModelId:k,currentAgentName:M,currentVariant:U}=_r.getState(),de=za.getState().lastUsedProvider,H=o||de?.providerID,Be=k||de?.modelID;return!H||!Be?(v.error(a("gitView.pr.toast.noModelSelected")),null):{sessionId:y,providerID:H,modelID:Be,currentAgentName:M??null,currentVariant:U??null}},[y,a]),ut=i.useCallback((o,k,M,U)=>{ht.getState().sendMessage(k,o.providerID,o.modelID,o.currentAgentName??void 0,void 0,void 0,[{text:M,synthetic:!0},{text:U,synthetic:!0}],o.currentVariant??void 0).catch(de=>{const H=de instanceof Error?de.message:String(de);v.error(a("gitView.pr.toast.sendMessageFailed"),{description:H})})},[a]),us=i.useCallback(o=>{const k=o.status||"unknown",M=o.conclusion??void 0,U=M?`${k} / ${M}`:k,de=o.app?.name||o.app?.slug;return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground truncate",children:o.name}),t.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:de?`${de} · ${U}`:U})]}),o.detailsUrl?t.jsx(ee,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:t.jsxs("a",{href:o.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(C,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),o.output?.title?t.jsx("div",{className:"typography-micro text-foreground",children:o.output.title}):null,o.output?.summary?t.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap",children:o.output.summary}):null,o.output?.text?t.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:o.output.text}):null,Array.isArray(o.annotations)&&o.annotations.length>0?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",o.annotations.length>20?` (showing 20/${o.annotations.length})`:""]}),t.jsx("div",{className:"space-y-1",children:o.annotations.slice(0,20).map((H,Be)=>t.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[t.jsxs("div",{className:"typography-micro text-[var(--status-error)]",children:[H.title||H.level||"Issue",H.path?` · ${H.path}`:"",typeof H.startLine=="number"?`:${H.startLine}`:"",typeof H.endLine=="number"&&H.endLine!==H.startLine?`-${H.endLine}`:""]}),t.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap mt-1",children:H.message}),H.rawDetails?t.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap mt-1",children:H.rawDetails}):null]},`${H.path||"file"}:${H.startLine||Be}:${Be}`))})]}):null,o.job?.steps&&o.job.steps.length>0?t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),t.jsx("div",{className:"space-y-1",children:o.job.steps.map((H,Be)=>{const dt=(H.conclusion||"").toLowerCase(),et=dt&&!["success","neutral","skipped"].includes(dt),pe=`${o.id??"run"}:${o.job?.jobId??"job"}:${H.number??Be}:${H.name}`,Se=qt.has(pe);return et?t.jsxs(ar,{open:Se,children:[t.jsxs("button",{type:"button",onClick:()=>{is(hs=>{const it=new Set(hs);return it.has(pe)?it.delete(pe):it.add(pe),it})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(et?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Se?t.jsx(C,{name:"arrow-down-s",className:"size-4"}):t.jsx(C,{name:"arrow-right-s",className:"size-4"}),t.jsx("span",{className:"truncate",children:H.name}),H.conclusion?t.jsx("span",{className:"ml-auto flex-shrink-0",children:H.conclusion}):null]}),t.jsx(rr,{children:t.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof H.number=="number"?t.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",H.number]}):null,H.status?t.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",H.status]}):null,H.conclusion?t.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",H.conclusion]}):null,H.startedAt?t.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",Tt(H.startedAt)]}):null,H.completedAt?t.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",Tt(H.completedAt)]}):null]})})]},pe):t.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[t.jsx("span",{className:"truncate",children:H.name}),H.conclusion?t.jsx("span",{className:"ml-auto flex-shrink-0",children:H.conclusion}):null]},pe)})})]}):null]})},[qt,Tt,a]),vs=i.useCallback(async()=>{if(I("chat"),!u?.prContext){v.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!r||!$)return;const o=yt();if(o)try{const k=await u.prContext(r,$.number,{includeDiff:!1,includeCheckDetails:!0}),U=(k.checkRuns??[]).filter(et=>{const pe=typeof et.conclusion=="string"?et.conclusion.toLowerCase():"";return pe?!["success","neutral","skipped"].includes(pe):!1});if(U.length===0){v.message(a("gitView.pr.toast.noFailedChecks"));return}const de=await Ct("github.pr.checks.review.visible"),H=await Ct("github.pr.checks.review.instructions"),Be=U.flatMap(et=>(Array.isArray(et.annotations)?et.annotations:[]).map(Se=>({run:et.name,level:Se.level,title:Se.title,path:Se.path,startLine:Se.startLine,endLine:Se.endLine,message:Se.message,rawDetails:Se.rawDetails}))),dt=`GitHub PR failed checks (JSON)
3
3
  ${JSON.stringify({repo:k.repo??null,pr:k.pr??null,failedChecks:U,failedAnnotations:Be},null,2)}`;ut(o,de,H,dt)}catch(k){const M=k instanceof Error?k.message:String(k);v.error(a("gitView.pr.toast.loadChecksFailed"),{description:M})}},[r,ut,u,$,yt,I,a]),Ns=i.useCallback(async()=>{if(I("chat"),!u?.prContext){v.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!r||!$)return;const o=yt();if(o)try{const k=await u.prContext(r,$.number,{includeDiff:!1,includeCheckDetails:!1}),M=k.issueComments??[],U=k.reviewComments??[];if(M.length+U.length===0){v.message(a("gitView.pr.toast.noPrComments"));return}const H=await Ct("github.pr.comments.review.visible"),Be=await Ct("github.pr.comments.review.instructions"),dt=`GitHub PR comments (JSON)
4
4
  ${JSON.stringify({repo:k.repo??null,pr:k.pr??null,issueComments:M,reviewComments:U},null,2)}`;ut(o,H,Be,dt)}catch(k){const M=k instanceof Error?k.message:String(k);v.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:M})}},[r,ut,u,$,yt,I,a]),Ls=i.useCallback(async o=>{os(!1),I("chat");const k=yt();if(!k)return;const M=await Ct("github.pr.comment.single.visible"),U=await Ct("github.pr.comment.single.instructions"),de=`GitHub PR comment (JSON)
@@ -1 +1 @@
1
- import{R as o,j as n,bG as E}from"./vendor-.bun-DgrCmzWD.js";import{C as w}from"./modelPrefsAutoSave-Cn7yX5JT.js";import"./index-DbxIdVC4.js";function l(){return typeof document>"u"?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function e(s){if(!(typeof document>"u"))return getComputedStyle(document.documentElement).getPropertyValue(s).trim()||void 0}function S(){return{default:{colors:{global:{background1:e("--surface-muted"),background2:e("--surface-background"),background3:e("--surface-elevated"),backgroundHover:e("--interactive-hover"),text:e("--surface-foreground"),border:e("--interactive-border"),focus:e("--interactive-focus-ring")},primary:{background1:e("--primary-base"),background2:e("--primary-muted"),background3:e("--surface-subtle"),backgroundHover:e("--primary-hover"),text:e("--primary-foreground")},component:{background1:e("--status-info"),background2:e("--status-info-background"),background3:e("--surface-muted"),backgroundHover:e("--status-info-border"),text:e("--status-info-foreground")},selector:{background1:e("--status-success"),background2:e("--status-success-background"),background3:e("--surface-muted"),backgroundHover:e("--status-success-border"),text:e("--status-success-foreground")},symbol:{background1:e("--primary-base"),background2:e("--primary-muted"),background3:e("--surface-muted"),backgroundHover:e("--primary-hover"),text:e("--primary-foreground")}}}}}const H=({content:s,absolutePath:m,onSave:f,onCancel:y})=>{const{files:a}=w(),[u,b]=o.useState(!1),[h,v]=o.useState(0),c=o.useRef(null);o.useEffect(()=>{let t=l();const i=()=>{const p=l();p!==t&&(t=p,v(C=>C+1))},r=new MutationObserver(i);r.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]});const d=setInterval(i,500);return()=>{r.disconnect(),clearInterval(d)}},[]);const g=o.useMemo(()=>({pages:[{name:"Page",component:s}]}),[s]),x=o.useCallback(async()=>{if(!(!c.current||!a?.writeFile)){b(!0);try{const r=(await c.current.runCommand("studio:projectFiles",{styles:"inline"}))?.find(d=>d.mimeType==="text/html");r?.content&&(await a.writeFile(m,r.content),f(r.content))}catch(t){console.error("Failed to save:",t)}finally{b(!1)}}},[m,a,f]),k=l(),j=S();return n.jsxs("div",{className:"flex flex-col h-full min-h-[400px]",children:[n.jsxs("div",{className:"flex items-center justify-end px-3 py-2 border-b border-border/30 gap-2",children:[n.jsx("button",{type:"button",onClick:y,disabled:u,className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors rounded-lg hover:bg-muted/50",children:"Cancel"}),n.jsx("button",{type:"button",onClick:x,disabled:u,className:"px-3 py-1.5 text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors rounded-lg disabled:opacity-50",children:u?"Saving...":"Save"})]}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(E,{options:{licenseKey:"LOCAL_LICENSE_KEY",theme:k,customTheme:j,project:{type:"web",default:g},layout:{default:{type:"column",style:{height:"100%"},children:[{type:"sidebarTop"},{type:"row",grow:!0,children:[{type:"canvas",grow:!0},{type:"sidebarRight"}]}]}},storage:{type:"self",onSave:async()=>{},onLoad:async()=>({project:g})}},onEditor:t=>{c.current=t}},h)})]})};export{H as default};
1
+ import{R as o,j as n,bG as E}from"./vendor-.bun-DgrCmzWD.js";import{C as w}from"./modelPrefsAutoSave-BUSppnWi.js";import"./index-BW75F1_U.js";function l(){return typeof document>"u"?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function e(s){if(!(typeof document>"u"))return getComputedStyle(document.documentElement).getPropertyValue(s).trim()||void 0}function S(){return{default:{colors:{global:{background1:e("--surface-muted"),background2:e("--surface-background"),background3:e("--surface-elevated"),backgroundHover:e("--interactive-hover"),text:e("--surface-foreground"),border:e("--interactive-border"),focus:e("--interactive-focus-ring")},primary:{background1:e("--primary-base"),background2:e("--primary-muted"),background3:e("--surface-subtle"),backgroundHover:e("--primary-hover"),text:e("--primary-foreground")},component:{background1:e("--status-info"),background2:e("--status-info-background"),background3:e("--surface-muted"),backgroundHover:e("--status-info-border"),text:e("--status-info-foreground")},selector:{background1:e("--status-success"),background2:e("--status-success-background"),background3:e("--surface-muted"),backgroundHover:e("--status-success-border"),text:e("--status-success-foreground")},symbol:{background1:e("--primary-base"),background2:e("--primary-muted"),background3:e("--surface-muted"),backgroundHover:e("--primary-hover"),text:e("--primary-foreground")}}}}}const H=({content:s,absolutePath:m,onSave:f,onCancel:y})=>{const{files:a}=w(),[u,b]=o.useState(!1),[h,v]=o.useState(0),c=o.useRef(null);o.useEffect(()=>{let t=l();const i=()=>{const p=l();p!==t&&(t=p,v(C=>C+1))},r=new MutationObserver(i);r.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]});const d=setInterval(i,500);return()=>{r.disconnect(),clearInterval(d)}},[]);const g=o.useMemo(()=>({pages:[{name:"Page",component:s}]}),[s]),x=o.useCallback(async()=>{if(!(!c.current||!a?.writeFile)){b(!0);try{const r=(await c.current.runCommand("studio:projectFiles",{styles:"inline"}))?.find(d=>d.mimeType==="text/html");r?.content&&(await a.writeFile(m,r.content),f(r.content))}catch(t){console.error("Failed to save:",t)}finally{b(!1)}}},[m,a,f]),k=l(),j=S();return n.jsxs("div",{className:"flex flex-col h-full min-h-[400px]",children:[n.jsxs("div",{className:"flex items-center justify-end px-3 py-2 border-b border-border/30 gap-2",children:[n.jsx("button",{type:"button",onClick:y,disabled:u,className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors rounded-lg hover:bg-muted/50",children:"Cancel"}),n.jsx("button",{type:"button",onClick:x,disabled:u,className:"px-3 py-1.5 text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors rounded-lg disabled:opacity-50",children:u?"Saving...":"Save"})]}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(E,{options:{licenseKey:"LOCAL_LICENSE_KEY",theme:k,customTheme:j,project:{type:"web",default:g},layout:{default:{type:"column",style:{height:"100%"},children:[{type:"sidebarTop"},{type:"row",grow:!0,children:[{type:"canvas",grow:!0},{type:"sidebarRight"}]}]}},storage:{type:"self",onSave:async()=>{},onLoad:async()=>({project:g})}},onEditor:t=>{c.current=t}},h)})]})};export{H as default};
@@ -1 +1 @@
1
- import{R as s,j as e}from"./vendor-.bun-DgrCmzWD.js";import{u as j,R as u,I as x,f0 as b}from"./modelPrefsAutoSave-Cn7yX5JT.js";const N=s.memo(function({jsonString:t,className:l,maxHeight:i="100%",initiallyExpandedDepth:m=2}){const{t:r}=j(),a=s.useRef(null),[c,o]=s.useState(null),d=s.useMemo(()=>{try{const n=t.trim();if(!n)return o(r("jsonTreeView.error.emptyJson")),null;const f=JSON.parse(n);return o(null),f}catch(n){return o(n instanceof Error?n.message:r("jsonTreeView.error.invalidJson")),null}},[t,r]),p=s.useCallback(()=>{a.current?.expandAll()},[]),v=s.useCallback(()=>{a.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:a,data:d,maxHeight:i,initiallyExpandedDepth:m})})]})});export{N as J};
1
+ import{R as s,j as e}from"./vendor-.bun-DgrCmzWD.js";import{u as j,R as u,I as x,f0 as b}from"./modelPrefsAutoSave-BUSppnWi.js";const N=s.memo(function({jsonString:t,className:l,maxHeight:i="100%",initiallyExpandedDepth:m=2}){const{t:r}=j(),a=s.useRef(null),[c,o]=s.useState(null),d=s.useMemo(()=>{try{const n=t.trim();if(!n)return o(r("jsonTreeView.error.emptyJson")),null;const f=JSON.parse(n);return o(null),f}catch(n){return o(n instanceof Error?n.message:r("jsonTreeView.error.invalidJson")),null}},[t,r]),p=s.useCallback(()=>{a.current?.expandAll()},[]),v=s.useCallback(()=>{a.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:a,data:d,maxHeight:i,initiallyExpandedDepth:m})})]})});export{N as J};
@@ -1,4 +1,4 @@
1
- import{R as S,c as V,by as We,bz as Ue,j as a,bA as He,bB as Ve,bC as qe,bD as Ze,bE as Ke,bF as Ge,aj as Ye}from"./vendor-.bun-DgrCmzWD.js";import{C as Se,aF as Ce,a as pe,u as le,bl as Re,c as L,aS as Je,aU as xe,eY as Qe,eZ as Ee,E as Xe,e_ as et,I as U,e$ as tt,b as be,aN as se,G as Te}from"./modelPrefsAutoSave-Cn7yX5JT.js";import"./index-DbxIdVC4.js";const ge=()=>{const t=V.c(4),e=Je();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=xe(!1),t[0]=n):n=t[0];const s=n;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=xe(!0),t[1]=r):r=t[1];const o=r;let l;return t[2]!==e?.currentTheme?(l=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:s),t[2]=e?.currentTheme,t[3]=l):l=t[3],l},Me=t=>{const e=V.c(4),{containerRef:n,enabled:s}=t;let r,o;e[0]!==n||e[1]!==s?(r=()=>{if(s===!1)return;const l=n.current;if(!l)return;const d=Lt;return l.addEventListener("click",d),()=>{l.removeEventListener("click",d)}},o=[n,s],e[0]=n,e[1]=s,e[2]=r,e[3]=o):(r=e[2],o=e[3]),S.useEffect(r,o)},rt=t=>{const e=V.c(5),{href:n}=t,[s,r]=S.useState(!1);let o;e[0]!==n?(o=tt(n),e[0]=n,e[1]=o):o=e[1];const l=o;if(!l||s)return null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>r(!0),e[2]=d):d=e[2];let i;return e[3]!==l?(i=a.jsx("img",{src:l,alt:"","aria-hidden":"true",loading:"lazy",decoding:"async",className:"mr-1 inline-block size-4 rounded-sm align-[-0.1875em]",onError:d}),e[3]=l,e[4]=i):i=e[4],i},Ae=t=>{const e=[],n=[],s=t.querySelector("thead");s&&s.querySelectorAll("th").forEach(l=>e.push(l.innerText.trim()));const r=t.querySelector("tbody");return r&&r.querySelectorAll("tr").forEach(l=>{const d=l.querySelectorAll("td"),i=[];d.forEach(c=>i.push(c.innerText.trim())),n.push(i)}),{headers:e,rows:n}},Le=({headers:t,rows:e})=>{const n=r=>r.includes(",")||r.includes('"')||r.includes(`
1
+ import{R as S,c as V,by as We,bz as Ue,j as a,bA as He,bB as Ve,bC as qe,bD as Ze,bE as Ke,bF as Ge,aj as Ye}from"./vendor-.bun-DgrCmzWD.js";import{C as Se,aF as Ce,a as pe,u as le,bl as Re,c as L,aS as Je,aU as xe,eY as Qe,eZ as Ee,E as Xe,e_ as et,I as U,e$ as tt,b as be,aN as se,G as Te}from"./modelPrefsAutoSave-BUSppnWi.js";import"./index-BW75F1_U.js";const ge=()=>{const t=V.c(4),e=Je();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=xe(!1),t[0]=n):n=t[0];const s=n;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=xe(!0),t[1]=r):r=t[1];const o=r;let l;return t[2]!==e?.currentTheme?(l=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:s),t[2]=e?.currentTheme,t[3]=l):l=t[3],l},Me=t=>{const e=V.c(4),{containerRef:n,enabled:s}=t;let r,o;e[0]!==n||e[1]!==s?(r=()=>{if(s===!1)return;const l=n.current;if(!l)return;const d=Lt;return l.addEventListener("click",d),()=>{l.removeEventListener("click",d)}},o=[n,s],e[0]=n,e[1]=s,e[2]=r,e[3]=o):(r=e[2],o=e[3]),S.useEffect(r,o)},rt=t=>{const e=V.c(5),{href:n}=t,[s,r]=S.useState(!1);let o;e[0]!==n?(o=tt(n),e[0]=n,e[1]=o):o=e[1];const l=o;if(!l||s)return null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>r(!0),e[2]=d):d=e[2];let i;return e[3]!==l?(i=a.jsx("img",{src:l,alt:"","aria-hidden":"true",loading:"lazy",decoding:"async",className:"mr-1 inline-block size-4 rounded-sm align-[-0.1875em]",onError:d}),e[3]=l,e[4]=i):i=e[4],i},Ae=t=>{const e=[],n=[],s=t.querySelector("thead");s&&s.querySelectorAll("th").forEach(l=>e.push(l.innerText.trim()));const r=t.querySelector("tbody");return r&&r.querySelectorAll("tr").forEach(l=>{const d=l.querySelectorAll("td"),i=[];d.forEach(c=>i.push(c.innerText.trim())),n.push(i)}),{headers:e,rows:n}},Le=({headers:t,rows:e})=>{const n=r=>r.includes(",")||r.includes('"')||r.includes(`
2
2
  `)?`"${r.replace(/"/g,'""')}"`:r,s=[];return t.length>0&&s.push(t.map(n).join(",")),e.forEach(r=>s.push(r.map(n).join(","))),s.join(`
3
3
  `)},nt=({headers:t,rows:e})=>{const n=r=>r.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),s=[];return t.length>0&&s.push(t.map(n).join(" ")),e.forEach(r=>s.push(r.map(n).join(" "))),s.join(`
4
4
  `)},ot=({headers:t,rows:e})=>{if(t.length===0)return"";const n=r=>r.replace(/\\/g,"\\\\").replace(/\|/g,"\\|"),s=[];return s.push(`| ${t.map(n).join(" | ")} |`),s.push(`| ${t.map(()=>"---").join(" | ")} |`),e.forEach(r=>{const o=t.map((l,d)=>n(r[d]||""));s.push(`| ${o.join(" | ")} |`)}),s.join(`
@@ -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-DgrCmzWD.js";import{u as z,c as w,I as O}from"./modelPrefsAutoSave-Cn7yX5JT.js";import{M as P}from"./main-0lfSGrYL.js";import"./index-DbxIdVC4.js";import"./JsonTreeView-DNPUiy8M.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-DgrCmzWD.js";import{u as z,c as w,I as O}from"./modelPrefsAutoSave-BUSppnWi.js";import{M as P}from"./main-C0ZrxisB.js";import"./index-BW75F1_U.js";import"./JsonTreeView-BHfF9Efv.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
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-DgrCmzWD.js","assets/vendor--DaW60Aqe.css"])))=>i.map(i=>d[i]);
2
- import{r as O,j as t,R as s,c as $,_ as le}from"./vendor-.bun-DgrCmzWD.js";import{u as z,ez as ie,eA as J,eB as X,eC as Q,b5 as L,R as T,Q as H,D as oe,ac as ce,f as ne,cy as W,aN as se,c as G,I,eD as Y}from"./modelPrefsAutoSave-Cn7yX5JT.js";import"./index-DbxIdVC4.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,v]=O.useState(null),[R,S]=O.useState(""),b=ie(m),f=O.useCallback(u=>{k(u.target.value),p("idle"),v(null),S("")},[]),j=O.useCallback(u=>{_(u.target.value)},[]),w=O.useCallback(async()=>{if(b){p("testing"),v(null),S("");try{const u=await J(b);v(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"),v(null),S("");try{const u=await J(b);if(v(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 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),B=h?.status==="ok",F=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&&B&&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&&F&&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:w,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,v]=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]),w=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 w();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,w,U]);const D=s.useCallback(async()=>{k(!0);try{await w()&&await U()}finally{k(!1)}},[w,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]),B=s.useCallback(async()=>{const r=await se(ue);r.ok?(a(!0),setTimeout(()=>a(!1),2e3)):console.error("Failed to copy:",r.error)},[]),F=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:()=>v("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:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&L()&&h==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ae,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("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:B,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:F,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 we=3e4;function ve({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),[v,R]=s.useState(null),[S,b]=s.useState(""),[f,j]=s.useState("unknown");s.useEffect(()=>{const d=setTimeout(()=>m(!0),we);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 w=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-DgrCmzWD.js").then(K=>K.bL);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]),B=f==="windows"?be:ge,F=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:w,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:B,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"})]}),v&&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:v}),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:F,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 Vinci. Verify the address points to an Vinci 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 v;e[0]!==x?(v=async()=>{if(L()){await W();return}await fetch("/api/config/reload",{method:"POST"}),x?.()},e[0]=x,e[1]=v):v=e[1];const R=v;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 w;return e[19]!==R||e[20]!==b||e[21]!==j||e[22]!==o||e[23]!==a||e[24]!==p||e[25]!==c?(w=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]=w):w=e[26],w}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 v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{h(!1),N(!1)},e[0]=v):v=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(v,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 w;e[8]!==m?(w=()=>{h(!0),m?.()},e[8]=m,e[9]=w):w=e[9];let C;return e[10]!==n||e[11]!==i||e[12]!==g||e[13]!==_||e[14]!==w?(C=t.jsx(Se,{variant:g,hostUrl:i,hostLabel:n,showRemoteForm:_,onCloseRemoteForm:f,onSwitchToLocalFromRemote:j,onEnterLocalSetup:w}),e[10]=n,e[11]=i,e[12]=g,e[13]=_,e[14]=w,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 w;return e[20]!==a||e[21]!==p||e[22]!==f?(w=t.jsx(ve,{onBack:f,onCliAvailable:a,isFromRecovery:p,onSwitchToRemote:j}),e[20]=a,e[21]=p,e[22]=f,e[23]=w):w=e[23],w}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};
2
+ import{r as O,j as t,R as s,c as $,_ as le}from"./vendor-.bun-DgrCmzWD.js";import{u as z,ez as ie,eA as J,eB as X,eC as Q,b5 as L,R as T,Q as H,D as oe,ac as ce,f as ne,cy as W,aN as se,c as G,I,eD as Y}from"./modelPrefsAutoSave-BUSppnWi.js";import"./index-BW75F1_U.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,v]=O.useState(null),[R,S]=O.useState(""),b=ie(m),f=O.useCallback(u=>{k(u.target.value),p("idle"),v(null),S("")},[]),j=O.useCallback(u=>{_(u.target.value)},[]),w=O.useCallback(async()=>{if(b){p("testing"),v(null),S("");try{const u=await J(b);v(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"),v(null),S("");try{const u=await J(b);if(v(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 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),B=h?.status==="ok",F=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&&B&&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&&F&&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:w,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,v]=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]),w=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 w();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,w,U]);const D=s.useCallback(async()=>{k(!0);try{await w()&&await U()}finally{k(!1)}},[w,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]),B=s.useCallback(async()=>{const r=await se(ue);r.ok?(a(!0),setTimeout(()=>a(!1),2e3)):console.error("Failed to copy:",r.error)},[]),F=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:()=>v("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:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&L()&&h==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ae,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("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:B,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:F,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 we=3e4;function ve({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),[v,R]=s.useState(null),[S,b]=s.useState(""),[f,j]=s.useState("unknown");s.useEffect(()=>{const d=setTimeout(()=>m(!0),we);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 w=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-DgrCmzWD.js").then(K=>K.bL);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]),B=f==="windows"?be:ge,F=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:w,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:B,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"})]}),v&&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:v}),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:F,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 Vinci. Verify the address points to an Vinci 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 v;e[0]!==x?(v=async()=>{if(L()){await W();return}await fetch("/api/config/reload",{method:"POST"}),x?.()},e[0]=x,e[1]=v):v=e[1];const R=v;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 w;return e[19]!==R||e[20]!==b||e[21]!==j||e[22]!==o||e[23]!==a||e[24]!==p||e[25]!==c?(w=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]=w):w=e[26],w}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 v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{h(!1),N(!1)},e[0]=v):v=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(v,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 w;e[8]!==m?(w=()=>{h(!0),m?.()},e[8]=m,e[9]=w):w=e[9];let C;return e[10]!==n||e[11]!==i||e[12]!==g||e[13]!==_||e[14]!==w?(C=t.jsx(Se,{variant:g,hostUrl:i,hostLabel:n,showRemoteForm:_,onCloseRemoteForm:f,onSwitchToLocalFromRemote:j,onEnterLocalSetup:w}),e[10]=n,e[11]=i,e[12]=g,e[13]=_,e[14]=w,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 w;return e[20]!==a||e[21]!==p||e[22]!==f?(w=t.jsx(ve,{onBack:f,onCliAvailable:a,isFromRecovery:p,onSwitchToRemote:j}),e[20]=a,e[21]=p,e[22]=f,e[23]=w):w=e[23],w}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-DgrCmzWD.js";import{u as R,c as g}from"./modelPrefsAutoSave-Cn7yX5JT.js";import{o as S}from"./main-0lfSGrYL.js";import"./index-DbxIdVC4.js";import"./JsonTreeView-DNPUiy8M.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-DgrCmzWD.js";import{u as R,c as g}from"./modelPrefsAutoSave-BUSppnWi.js";import{o as S}from"./main-C0ZrxisB.js";import"./index-BW75F1_U.js";import"./JsonTreeView-BHfF9Efv.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};