blade-code 0.8.3 → 0.9.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 (84) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/chunk-0abtfzm6.js +1 -0
  3. package/dist/chunk-0zkhjsbv.js +1 -0
  4. package/dist/{chunk-6msfa7jh.js → chunk-119fhp5q.js} +1 -1
  5. package/dist/{chunk-fma9cbq5.js → chunk-1rpgvk3r.js} +1 -1
  6. package/dist/{chunk-7bqkkjxf.js → chunk-1v2n922p.js} +1 -1
  7. package/dist/{chunk-eyypmc9m.js → chunk-2fbwmdvg.js} +2 -2
  8. package/dist/chunk-3qgj2y5r.js +1 -0
  9. package/dist/{chunk-sva5bdgz.js → chunk-45bme7n9.js} +2 -2
  10. package/dist/{chunk-zj3q4btp.js → chunk-5jq01mg6.js} +2 -2
  11. package/dist/{chunk-5sccs44n.js → chunk-5nye3k5w.js} +1 -1
  12. package/dist/chunk-7pevqbfd.js +2 -0
  13. package/dist/chunk-8dqvnx7n.js +2 -0
  14. package/dist/chunk-8edsvxf3.js +1 -0
  15. package/dist/{chunk-hqtskyc1.js → chunk-8vemqfe4.js} +2 -2
  16. package/dist/{chunk-d7nrqg5b.js → chunk-8vtznxpq.js} +2 -2
  17. package/dist/chunk-936ft6kq.js +2 -0
  18. package/dist/{chunk-jc7k8pfn.js → chunk-9ax02vtg.js} +2 -2
  19. package/dist/chunk-9qknesxs.js +6 -0
  20. package/dist/chunk-acegy4td.js +3 -0
  21. package/dist/chunk-aewrn5xp.js +1 -0
  22. package/dist/{chunk-mqqajem9.js → chunk-aq7wf2zt.js} +2 -2
  23. package/dist/{chunk-5yt80bn2.js → chunk-ax7bx0j8.js} +1 -1
  24. package/dist/chunk-b10vr4xj.js +2 -0
  25. package/dist/{chunk-vxpdjtqc.js → chunk-bc6wbcrs.js} +1 -1
  26. package/dist/chunk-bfgm5k3e.js +1566 -0
  27. package/dist/chunk-cf3fhs7j.js +1 -0
  28. package/dist/chunk-d7y2mf7c.js +4 -0
  29. package/dist/chunk-e1586s4t.js +1 -0
  30. package/dist/chunk-enk621t7.js +98 -0
  31. package/dist/chunk-fpr6d8zc.js +2 -0
  32. package/dist/{chunk-nbpjzzrg.js → chunk-gagt42k2.js} +1 -1
  33. package/dist/chunk-gdm1xzvp.js +2 -0
  34. package/dist/chunk-gm62cfjw.js +1 -0
  35. package/dist/chunk-h3bjmkvz.js +1 -0
  36. package/dist/{chunk-qvtahmff.js → chunk-j8en7x02.js} +1 -1
  37. package/dist/{chunk-2c69g6t9.js → chunk-jyr9417h.js} +2 -2
  38. package/dist/chunk-mcnfbhpr.js +6 -0
  39. package/dist/{chunk-wcf80p9y.js → chunk-mns8e65q.js} +1 -1
  40. package/dist/chunk-mpkr3s6b.js +3 -0
  41. package/dist/chunk-n9tgxfvw.js +615 -0
  42. package/dist/{chunk-be7qz4cv.js → chunk-ppyg431d.js} +1 -1
  43. package/dist/chunk-qxhrzws6.js +1 -0
  44. package/dist/{chunk-mvww9cmc.js → chunk-r6h7eja3.js} +1 -1
  45. package/dist/chunk-r8pjwjt6.js +1 -0
  46. package/dist/{chunk-97qxd4yb.js → chunk-rmfk5f9m.js} +2 -2
  47. package/dist/chunk-rrg9bw8r.js +25 -0
  48. package/dist/chunk-w3me85va.js +2 -0
  49. package/dist/{chunk-b922cq7k.js → chunk-wtxwny0p.js} +3 -3
  50. package/dist/{chunk-crbh6x86.js → chunk-x40fkg4z.js} +2 -2
  51. package/dist/{chunk-1m63zddw.js → chunk-x548f12z.js} +1 -1
  52. package/dist/{chunk-bqhghfmt.js → chunk-xtfzjb72.js} +1 -1
  53. package/dist/{chunk-ar5564sf.js → chunk-z0qxaky4.js} +1 -1
  54. package/dist/web/assets/{FilePreview-B5g8yi8d.js → FilePreview-DpovIbME.js} +1 -1
  55. package/dist/web/assets/{MarkdownRenderer-qBCxzEb_.js → MarkdownRenderer-73wC_SGk.js} +1 -1
  56. package/dist/web/assets/{McpModal-C7y2Fsqc.js → McpModal-CIpxuyTG.js} +1 -1
  57. package/dist/web/assets/{SettingsModal-Dmc7Dw_E.js → SettingsModal-BBa1libe.js} +1 -1
  58. package/dist/web/assets/{SettingsStore-BfoB9tNV.js → SettingsStore-C8YBWQPS.js} +1 -1
  59. package/dist/web/assets/{SkillsModal-CqFAIfj5.js → SkillsModal-DArZ-nCX.js} +1 -1
  60. package/dist/web/assets/{TerminalPanel-EHh8-9b9.js → TerminalPanel-BX7C7qiD.js} +1 -1
  61. package/dist/web/assets/index-DIWzaS2_.js +16 -0
  62. package/dist/web/index.html +1 -1
  63. package/package.json +2 -1
  64. package/dist/chunk-23h9grdr.js +0 -1
  65. package/dist/chunk-6spmzx13.js +0 -6
  66. package/dist/chunk-724djh7r.js +0 -1
  67. package/dist/chunk-804j7say.js +0 -1
  68. package/dist/chunk-8yk5w2ks.js +0 -1
  69. package/dist/chunk-9cr3jexy.js +0 -2
  70. package/dist/chunk-ghf5tgjr.js +0 -1
  71. package/dist/chunk-kf43f8sy.js +0 -1577
  72. package/dist/chunk-kjc2aqww.js +0 -2
  73. package/dist/chunk-kjddt9xy.js +0 -1
  74. package/dist/chunk-m0ded6ky.js +0 -615
  75. package/dist/chunk-msr67f6q.js +0 -3
  76. package/dist/chunk-ncvr73ev.js +0 -1
  77. package/dist/chunk-qwn46cd6.js +0 -2
  78. package/dist/chunk-t9cqscfq.js +0 -2
  79. package/dist/chunk-tzr992v4.js +0 -1
  80. package/dist/chunk-x8xfx9nv.js +0 -1
  81. package/dist/chunk-yewg510f.js +0 -24
  82. package/dist/chunk-zjks0ncc.js +0 -6
  83. package/dist/chunk-zsyff0ky.js +0 -3
  84. package/dist/web/assets/index-B-BRpW1c.js +0 -16
@@ -1,4 +1,4 @@
1
- import{_ as ye}from"./vendor-markdown-b9iCqZWK.js";import{r as d,j as e}from"./vendor-react-FPIC4Czm.js";import{c as D,u as _e,e as _,s as z,f as Ie,B as qe,g as fe}from"./index-B-BRpW1c.js";import{n as Pe,L as ke,o as ve,p as Ee}from"./vendor-radix-DyP_DOwV.js";import{u as ze}from"./SettingsStore-BfoB9tNV.js";import{X as We,b as ue,d as xe,a as je,I as Ge,J as Oe}from"./vendor-icons-DBM55KTG.js";import"./vendor-monaco-w6PwaWGP.js";const Je=Pe,we=d.forwardRef(({className:t,...n},a)=>e.jsx(ke,{ref:a,className:D("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...n}));we.displayName=ke.displayName;const W=d.forwardRef(({className:t,...n},a)=>e.jsx(ve,{ref:a,className:D("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...n}));W.displayName=ve.displayName;const G=d.forwardRef(({className:t,...n},a)=>e.jsx(Ee,{ref:a,className:D("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n}));G.displayName=Ee.displayName;const Ve={"ayu-dark":{background:{primary:"#0f1419",secondary:"#14191f"},text:{primary:"#e6e1cf",secondary:"#bae67e",muted:"#5c6773"},border:{light:"#2d323b"},syntax:{comment:"#5c6773",string:"#bae67e",number:"#ffcc66",keyword:"#ff8f40",function:"#73d0ff",variable:"#e6e1cf",operator:"#f29e74",type:"#73d0ff",tag:"#ff8f40",attr:"#ffd580",default:"#e6e1cf"}},dracula:{background:{primary:"#282a36",secondary:"#44475a"},text:{primary:"#f8f8f2",secondary:"#f1fa8c",muted:"#6272a4"},border:{light:"#44475a"},syntax:{comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",keyword:"#ff79c6",function:"#50fa7b",variable:"#f8f8f2",operator:"#ff79c6",type:"#8be9fd",tag:"#ff79c6",attr:"#50fa7b",default:"#f8f8f2"}},monokai:{background:{primary:"#272822",secondary:"#3e3d32"},text:{primary:"#f8f8f2",secondary:"#e6db74",muted:"#75715e"},border:{light:"#3e3d32"},syntax:{comment:"#75715e",string:"#e6db74",number:"#ae81ff",keyword:"#f92672",function:"#a6e22e",variable:"#f8f8f2",operator:"#f92672",type:"#66d9ef",tag:"#f92672",attr:"#a6e22e",default:"#f8f8f2"}},nord:{background:{primary:"#2e3440",secondary:"#3b4252"},text:{primary:"#eceff4",secondary:"#d8dee9",muted:"#4c566a"},border:{light:"#434c5e"},syntax:{comment:"#616e88",string:"#a3be8c",number:"#b48ead",keyword:"#81a1c1",function:"#88c0d0",variable:"#d8dee9",operator:"#81a1c1",type:"#8fbcbb",tag:"#81a1c1",attr:"#8fbcbb",default:"#eceff4"}},"solarized-light":{background:{primary:"#fdf6e3",secondary:"#eee8d5"},text:{primary:"#586e75",secondary:"#657b83",muted:"#93a1a1"},border:{light:"#eee8d5"},syntax:{comment:"#93a1a1",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#657b83",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#657b83"}},"solarized-dark":{background:{primary:"#002b36",secondary:"#073642"},text:{primary:"#839496",secondary:"#93a1a1",muted:"#586e75"},border:{light:"#073642"},syntax:{comment:"#586e75",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#839496",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#839496"}},"tokyo-night":{background:{primary:"#1a1b26",secondary:"#292e42"},text:{primary:"#a9b1d6",secondary:"#c0caf5",muted:"#565f89"},border:{light:"#292e42"},syntax:{comment:"#565f89",string:"#9ece6a",number:"#ff9e64",keyword:"#bb9af7",function:"#7aa2f7",variable:"#c0caf5",operator:"#89ddff",type:"#7dcfff",tag:"#f7768e",attr:"#7aa2f7",default:"#a9b1d6"}},github:{background:{primary:"#ffffff",secondary:"#f6f8fa"},text:{primary:"#24292f",secondary:"#57606a",muted:"#6e7781"},border:{light:"#d0d7de"},syntax:{comment:"#6e7781",string:"#0a3069",number:"#0550ae",keyword:"#cf222e",function:"#8250df",variable:"#24292f",operator:"#cf222e",type:"#0550ae",tag:"#116329",attr:"#0550ae",default:"#24292f"}},gruvbox:{background:{primary:"#282828",secondary:"#3c3836"},text:{primary:"#ebdbb2",secondary:"#d5c4a1",muted:"#928374"},border:{light:"#3c3836"},syntax:{comment:"#928374",string:"#b8bb26",number:"#d3869b",keyword:"#fb4934",function:"#b8bb26",variable:"#ebdbb2",operator:"#fe8019",type:"#fabd2f",tag:"#fb4934",attr:"#fabd2f",default:"#ebdbb2"}},"one-dark":{background:{primary:"#282c34",secondary:"#21252b"},text:{primary:"#abb2bf",secondary:"#e5c07b",muted:"#5c6370"},border:{light:"#3e4451"},syntax:{comment:"#5c6370",string:"#98c379",number:"#d19a66",keyword:"#c678dd",function:"#61afef",variable:"#e06c75",operator:"#56b6c2",type:"#e5c07b",tag:"#e06c75",attr:"#d19a66",default:"#abb2bf"}},catppuccin:{background:{primary:"#1e1e2e",secondary:"#313244"},text:{primary:"#cdd6f4",secondary:"#f5e0dc",muted:"#6c7086"},border:{light:"#313244"},syntax:{comment:"#6c7086",string:"#a6e3a1",number:"#fab387",keyword:"#cba6f7",function:"#89b4fa",variable:"#f5e0dc",operator:"#89dceb",type:"#f9e2af",tag:"#f38ba8",attr:"#f9e2af",default:"#cdd6f4"}},"rose-pine":{background:{primary:"#191724",secondary:"#1f1d2e"},text:{primary:"#e0def4",secondary:"#908caa",muted:"#6e6a86"},border:{light:"#26233a"},syntax:{comment:"#6e6a86",string:"#f6c177",number:"#ebbcba",keyword:"#c4a7e7",function:"#9ccfd8",variable:"#e0def4",operator:"#31748f",type:"#eb6f92",tag:"#eb6f92",attr:"#c4a7e7",default:"#e0def4"}},kanagawa:{background:{primary:"#1f1f28",secondary:"#2a2a37"},text:{primary:"#dcd7ba",secondary:"#c8c093",muted:"#727169"},border:{light:"#2a2a37"},syntax:{comment:"#727169",string:"#98bb6c",number:"#d27e99",keyword:"#957fb8",function:"#7e9cd8",variable:"#dcd7ba",operator:"#c0a36e",type:"#7aa89f",tag:"#e46876",attr:"#ffa066",default:"#dcd7ba"}}};function He(t){const n=t.replace("#",""),a=parseInt(n.substring(0,2),16),s=parseInt(n.substring(2,4),16),o=parseInt(n.substring(4,6),16);return(.299*a+.587*s+.114*o)/255<.5}function Ke(t){return{base:He(t.background.primary)?"vs-dark":"vs",inherit:!0,rules:[{token:"",foreground:t.text.primary.replace("#",""),background:t.background.primary.replace("#","")},{token:"comment",foreground:t.syntax.comment.replace("#",""),fontStyle:"italic"},{token:"string",foreground:t.syntax.string.replace("#","")},{token:"number",foreground:t.syntax.number.replace("#","")},{token:"keyword",foreground:t.syntax.keyword.replace("#","")},{token:"type",foreground:t.syntax.type.replace("#","")},{token:"identifier",foreground:t.syntax.variable.replace("#","")},{token:"function",foreground:t.syntax.function.replace("#","")},{token:"variable",foreground:t.syntax.variable.replace("#","")},{token:"operator",foreground:t.syntax.operator.replace("#","")},{token:"delimiter",foreground:t.syntax.operator.replace("#","")},{token:"tag",foreground:t.syntax.tag.replace("#","")},{token:"attribute.name",foreground:t.syntax.attr.replace("#","")},{token:"attribute.value",foreground:t.syntax.string.replace("#","")}],colors:{"editor.background":t.background.primary,"editor.foreground":t.text.primary,"editor.lineHighlightBackground":t.background.secondary,"editor.selectionBackground":`${t.syntax.function}40`,"editorLineNumber.foreground":t.text.muted,"editorLineNumber.activeForeground":t.text.secondary,"editorCursor.foreground":t.text.primary,"editorIndentGuide.background":t.border.light,"editorWidget.background":t.background.secondary,"editorWidget.border":t.border.light,"scrollbarSlider.background":`${t.text.muted}40`,"scrollbarSlider.hoverBackground":`${t.text.muted}60`}}}const me=new Set;function pe(t,n){const a=n.toLowerCase().replace(/\s+/g,"-"),s=Ve[a];if(!s)return"vs-dark";if(!me.has(a)){const o=Ke(s);t.editor.defineTheme(a,o),me.add(a)}return a}d.lazy(async()=>({default:(await ye(()=>import("./vendor-react-FPIC4Czm.js").then(n=>n.i),[])).DiffEditor}));const Ue=d.lazy(async()=>({default:(await ye(()=>import("./vendor-react-FPIC4Czm.js").then(n=>n.i),[])).Editor}));function te(t,n){return t instanceof Error?t.message:n}function dt(){const{toggleFilePreview:t}=_e(),{messages:n,currentSessionRef:a,sessions:s}=_(),[o,f]=d.useState("diff"),[c,i]=d.useState([]),[p,b]=d.useState({}),[x,y]=d.useState(!1),[m,R]=d.useState(null),[w,N]=d.useState({}),[O,J]=d.useState({}),[E,ae]=d.useState(null),[Fe,V]=d.useState(""),[H,K]=d.useState(!1),[U,X]=d.useState(null),[re,M]=d.useState(!1),ne=d.useRef(a),T=d.useRef(0),I=d.useRef(0),q=d.useRef({}),Q=d.useRef(0),F=d.useRef(0),A=d.useRef({}),C=d.useRef({}),Y=d.useRef(null);d.useLayoutEffect(()=>{z(ne.current,a)||(T.current+=1),ne.current=a},[a]);const Z=(r,l)=>l===T.current&&z(_.getState().currentSessionRef,r),se=async(r,l="")=>{const g=l?`/suggestions/files/tree?path=${encodeURIComponent(l)}`:"/suggestions/files/tree",u=await fetch(g,{headers:fe(r)});if(!u.ok)throw new Error("Failed to load tree");return(await u.json()).map(h=>({...h,children:h.type==="dir"?[]:void 0}))};d.useEffect(()=>{const r=++I.current;return(async()=>{if(!a){i([]),y(!1),R(null);return}const g={...a},u=T.current,k=()=>r===I.current&&Z(g,u);if(k()){i([]),y(!0),R(null);try{const h=await se(g);k()&&i(h)}catch(h){k()&&R(te(h,"Failed to load tree"))}finally{k()&&y(!1)}}})(),()=>{I.current===r&&(I.current+=1)}},[a==null?void 0:a.projectPath,a==null?void 0:a.sessionId]),d.useEffect(()=>{Y.current=null,A.current={},C.current={},q.current={},Q.current+=1,ae(null),V(""),K(!1),X(null),M(!1),N({}),b({})},[a==null?void 0:a.projectPath,a==null?void 0:a.sessionId]);const v=d.useMemo(()=>s.find(r=>z({sessionId:r.sessionId,projectPath:r.projectPath},a)),[a,s]),Ce=d.useMemo(()=>Qe(n),[n]),[Se,oe]=d.useState(null),[Be,ee]=d.useState(!1),[ie,de]=d.useState(null),S=Se??Ce,ce=d.useMemo(()=>Me(n),[n]),[Le,De]=d.useState({});d.useEffect(()=>{const r=++F.current;if(oe(null),de(null),ee(!1),!a||(v==null?void 0:v.taskIsolation)!=="worktree"||!v.taskDiffStat||v.taskDiffStat.changedFiles===0)return;const l={...a};return ee(!0),Ie.getTaskDiff(l).then(g=>{r!==F.current||!z(_.getState().currentSessionRef,l)||oe(g.files.map(u=>({filePath:u.path,diff:{patch:u.patch},summary:u.binary?"binary":`+${u.additions} -${u.deletions}${u.truncated?" (truncated)":""}`})))}).catch(g=>{r===F.current&&de(te(g,"Failed to load task diff"))}).finally(()=>{r===F.current&&ee(!1)}),()=>{F.current===r&&(F.current+=1)}},[v==null?void 0:v.taskCompletedAt,v==null?void 0:v.taskDiffStat,v==null?void 0:v.taskIsolation,a]);const Re=r=>{De(l=>({...l,[r]:!l[r]}))},Te=async r=>{const l=_.getState().currentSessionRef;if(!l)return;const g=T.current,u=++Q.current,k=()=>u===Q.current&&Y.current===r&&Z(l,g);Y.current=r,ae(r),V(""),K(!0),X(null),M(!1);try{const h=await fetch(`/suggestions/files/content?path=${encodeURIComponent(r)}`,{headers:fe(l)});if(!h.ok)throw new Error("Failed to load file");const $=await h.json();k()&&(V($.content||""),M(!!$.truncated))}catch(h){k()&&X(te(h,"Failed to load file"))}finally{k()&&K(!1)}},Ae=async r=>{const l=(q.current[r]??0)+1;q.current[r]=l;const g=!A.current[r],u={...A.current,[r]:g};if(A.current=u,N(u),!g||C.current[r])return;const k=_.getState().currentSessionRef;if(!k)return;const h=T.current,$=()=>q.current[r]===l&&A.current[r]===!0&&Z(k,h);try{const P=await se(k,r);if($()){const le={...C.current,[r]:P};C.current=le,b(le)}}catch{if($()){const P={...C.current,[r]:[]};C.current=P,b(P)}}},$e=r=>{J(l=>({...l,[r]:!l[r]}))};return e.jsxs("div",{className:"w-[55%] min-w-[420px] max-w-[860px] border-l border-[#E5E7EB] dark:border-zinc-800 bg-white dark:bg-[#09090b] flex flex-col h-full shadow-xl shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 h-12 border-b border-[#E5E7EB] dark:border-zinc-800 shrink-0",children:[e.jsx("span",{className:"font-normal text-[13px] text-[#6B7280] dark:text-zinc-400 font-mono",children:"Preview"}),e.jsx(qe,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB]/60 dark:text-zinc-500 dark:hover:text-zinc-300 dark:hover:bg-zinc-800/50",children:e.jsx(We,{className:"w-4 h-4"})})]}),e.jsxs(Je,{value:o,onValueChange:r=>f(r),className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"px-4 py-3 border-b border-[#E5E7EB] dark:border-zinc-800",children:e.jsxs(we,{className:"bg-white dark:bg-[#111113] border border-[#E5E7EB] dark:border-[#27272a] h-9 p-1 rounded-md w-full justify-start",children:[e.jsx(W,{value:"diff",className:"text-[12px] font-mono px-3 text-[#6B7280] dark:text-[#a1a1aa] data-[state=active]:bg-[#E5E7EB] data-[state=active]:text-[#111827] dark:data-[state=active]:bg-[#27272a] dark:data-[state=active]:text-white",children:"Diff"}),e.jsx(W,{value:"files",className:"text-[12px] font-mono px-3 text-[#6B7280] dark:text-[#a1a1aa] data-[state=active]:bg-[#E5E7EB] data-[state=active]:text-[#111827] dark:data-[state=active]:bg-[#27272a] dark:data-[state=active]:text-white",children:"Files"}),e.jsx(W,{value:"logs",className:"text-[12px] font-mono px-3 text-[#6B7280] dark:text-[#a1a1aa] data-[state=active]:bg-[#E5E7EB] data-[state=active]:text-[#111827] dark:data-[state=active]:bg-[#27272a] dark:data-[state=active]:text-white",children:"Logs"})]})}),e.jsx(G,{value:"diff",className:"overflow-hidden flex-1 mt-0",children:e.jsx("div",{className:"overflow-y-auto px-4 py-4 space-y-3 h-full",children:Be&&S.length===0?e.jsx(j,{title:"Loading task diff…",subtitle:"Reading the durable worktree artifact."}):ie&&S.length===0?e.jsx(j,{title:"Failed to load task diff",subtitle:ie}):S.length===0?e.jsx(j,{title:"No patch yet",subtitle:"Run a tool that changes files to see diffs here."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-[12px] text-[#6B7280] dark:text-[#71717a] font-mono mb-2",children:[S.length," changed file",S.length>1?"s":""]}),S.map(r=>{var u;const l=((u=r.filePath)==null?void 0:u.split("/").pop())||"unknown",g=Le[r.filePath||""]!==!1;return e.jsxs("div",{className:"border border-[#E5E7EB] dark:border-[#27272a] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>Re(r.filePath||""),className:"w-full flex items-center gap-2 px-3 py-2 bg-[#F9FAFB] dark:bg-[#111113] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b] transition-colors",children:[g?e.jsx(ue,{className:"w-4 h-4 text-[#6B7280] dark:text-[#71717a]"}):e.jsx(xe,{className:"w-4 h-4 text-[#6B7280] dark:text-[#71717a]"}),e.jsx(je,{className:"w-4 h-4 text-[#6B7280] dark:text-[#71717a]"}),e.jsx("span",{className:"text-[13px] text-[#111827] dark:text-[#E5E5E5] font-mono flex-1 text-left truncate",children:l}),r.summary&&e.jsx("span",{className:"text-[11px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:r.summary})]}),g&&e.jsxs("div",{className:"border-t border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("div",{className:"px-3 py-1 text-[11px] text-[#9CA3AF] dark:text-[#52525b] font-mono truncate",children:r.filePath}),e.jsx(et,{diff:r.diff})]})]},r.filePath)})]})})}),e.jsx(G,{value:"files",className:"overflow-hidden flex-1 mt-0",children:e.jsxs("div",{className:"px-4 py-4 h-full",children:[x&&e.jsx(j,{title:"Loading files…",subtitle:"Fetching workspace tree."}),!x&&m&&e.jsx(j,{title:"Failed to load files",subtitle:m}),!x&&!m&&c.length===0&&e.jsx(j,{title:"No files yet",subtitle:"Start a session to load the workspace tree."}),!x&&!m&&c.length>0&&e.jsxs("div",{className:"h-full grid grid-cols-[220px_1fr] gap-4 min-h-0",children:[e.jsx("div",{className:"border border-[#E5E7EB] dark:border-[#27272a] rounded-lg p-2 overflow-y-auto min-h-0",children:c.map(r=>e.jsx(Ne,{node:r,depth:0,expandedDirs:w,childrenCache:p,toggleDir:Ae,selectedPath:E,onSelectFile:Te},r.path))}),e.jsxs("div",{className:"border border-[#E5E7EB] dark:border-[#27272a] rounded-lg overflow-hidden flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-2 bg-[#F9FAFB] dark:bg-[#111113] border-b border-[#E5E7EB] dark:border-[#27272a] text-[12px] text-[#6B7280] dark:text-[#71717a] font-mono flex items-center justify-between",children:[e.jsx("span",{children:E||"Select a file to preview"}),E&&e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#a1a1aa] font-mono",children:H?"Loading…":re?"Truncated":"Ready"})]}),re&&!H&&e.jsx("div",{className:"px-3 py-2 bg-[#FEF3C7] dark:bg-[#111113] border-b border-[#E5E7EB] dark:border-[#27272a] text-[11px] text-[#b45309] dark:text-[#facc15] font-mono",children:"Preview truncated to 200k characters."}),e.jsxs("div",{className:"flex-1 min-h-0",children:[!E&&e.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[#6B7280] dark:text-[#71717a] font-mono",children:"Pick a file from the tree to preview."}),E&&U&&e.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[#DC2626] dark:text-[#fca5a5] font-mono",children:U}),E&&!U&&e.jsx("div",{className:"h-full",children:H?e.jsx(he,{}):e.jsx(d.Suspense,{fallback:e.jsx(he,{}),children:e.jsx(Ye,{content:Fe,filename:E})})})]})]})]})]})}),e.jsx(G,{value:"logs",className:"overflow-hidden flex-1 mt-0",children:e.jsx("div",{className:"overflow-y-auto px-4 py-4 space-y-3 h-full",children:ce.length===0?e.jsx(j,{title:"No logs yet",subtitle:"Tool runs will appear here."}):ce.map(r=>{var h;const l=O[r.id],g=(r.content||"").split(`
1
+ import{_ as ye}from"./vendor-markdown-b9iCqZWK.js";import{r as d,j as e}from"./vendor-react-FPIC4Czm.js";import{c as D,u as _e,e as _,s as z,f as Ie,B as qe,g as fe}from"./index-DIWzaS2_.js";import{n as Pe,L as ke,o as ve,p as Ee}from"./vendor-radix-DyP_DOwV.js";import{u as ze}from"./SettingsStore-C8YBWQPS.js";import{X as We,b as ue,d as xe,a as je,I as Ge,J as Oe}from"./vendor-icons-DBM55KTG.js";import"./vendor-monaco-w6PwaWGP.js";const Je=Pe,we=d.forwardRef(({className:t,...n},a)=>e.jsx(ke,{ref:a,className:D("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...n}));we.displayName=ke.displayName;const W=d.forwardRef(({className:t,...n},a)=>e.jsx(ve,{ref:a,className:D("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...n}));W.displayName=ve.displayName;const G=d.forwardRef(({className:t,...n},a)=>e.jsx(Ee,{ref:a,className:D("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n}));G.displayName=Ee.displayName;const Ve={"ayu-dark":{background:{primary:"#0f1419",secondary:"#14191f"},text:{primary:"#e6e1cf",secondary:"#bae67e",muted:"#5c6773"},border:{light:"#2d323b"},syntax:{comment:"#5c6773",string:"#bae67e",number:"#ffcc66",keyword:"#ff8f40",function:"#73d0ff",variable:"#e6e1cf",operator:"#f29e74",type:"#73d0ff",tag:"#ff8f40",attr:"#ffd580",default:"#e6e1cf"}},dracula:{background:{primary:"#282a36",secondary:"#44475a"},text:{primary:"#f8f8f2",secondary:"#f1fa8c",muted:"#6272a4"},border:{light:"#44475a"},syntax:{comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",keyword:"#ff79c6",function:"#50fa7b",variable:"#f8f8f2",operator:"#ff79c6",type:"#8be9fd",tag:"#ff79c6",attr:"#50fa7b",default:"#f8f8f2"}},monokai:{background:{primary:"#272822",secondary:"#3e3d32"},text:{primary:"#f8f8f2",secondary:"#e6db74",muted:"#75715e"},border:{light:"#3e3d32"},syntax:{comment:"#75715e",string:"#e6db74",number:"#ae81ff",keyword:"#f92672",function:"#a6e22e",variable:"#f8f8f2",operator:"#f92672",type:"#66d9ef",tag:"#f92672",attr:"#a6e22e",default:"#f8f8f2"}},nord:{background:{primary:"#2e3440",secondary:"#3b4252"},text:{primary:"#eceff4",secondary:"#d8dee9",muted:"#4c566a"},border:{light:"#434c5e"},syntax:{comment:"#616e88",string:"#a3be8c",number:"#b48ead",keyword:"#81a1c1",function:"#88c0d0",variable:"#d8dee9",operator:"#81a1c1",type:"#8fbcbb",tag:"#81a1c1",attr:"#8fbcbb",default:"#eceff4"}},"solarized-light":{background:{primary:"#fdf6e3",secondary:"#eee8d5"},text:{primary:"#586e75",secondary:"#657b83",muted:"#93a1a1"},border:{light:"#eee8d5"},syntax:{comment:"#93a1a1",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#657b83",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#657b83"}},"solarized-dark":{background:{primary:"#002b36",secondary:"#073642"},text:{primary:"#839496",secondary:"#93a1a1",muted:"#586e75"},border:{light:"#073642"},syntax:{comment:"#586e75",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#839496",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#839496"}},"tokyo-night":{background:{primary:"#1a1b26",secondary:"#292e42"},text:{primary:"#a9b1d6",secondary:"#c0caf5",muted:"#565f89"},border:{light:"#292e42"},syntax:{comment:"#565f89",string:"#9ece6a",number:"#ff9e64",keyword:"#bb9af7",function:"#7aa2f7",variable:"#c0caf5",operator:"#89ddff",type:"#7dcfff",tag:"#f7768e",attr:"#7aa2f7",default:"#a9b1d6"}},github:{background:{primary:"#ffffff",secondary:"#f6f8fa"},text:{primary:"#24292f",secondary:"#57606a",muted:"#6e7781"},border:{light:"#d0d7de"},syntax:{comment:"#6e7781",string:"#0a3069",number:"#0550ae",keyword:"#cf222e",function:"#8250df",variable:"#24292f",operator:"#cf222e",type:"#0550ae",tag:"#116329",attr:"#0550ae",default:"#24292f"}},gruvbox:{background:{primary:"#282828",secondary:"#3c3836"},text:{primary:"#ebdbb2",secondary:"#d5c4a1",muted:"#928374"},border:{light:"#3c3836"},syntax:{comment:"#928374",string:"#b8bb26",number:"#d3869b",keyword:"#fb4934",function:"#b8bb26",variable:"#ebdbb2",operator:"#fe8019",type:"#fabd2f",tag:"#fb4934",attr:"#fabd2f",default:"#ebdbb2"}},"one-dark":{background:{primary:"#282c34",secondary:"#21252b"},text:{primary:"#abb2bf",secondary:"#e5c07b",muted:"#5c6370"},border:{light:"#3e4451"},syntax:{comment:"#5c6370",string:"#98c379",number:"#d19a66",keyword:"#c678dd",function:"#61afef",variable:"#e06c75",operator:"#56b6c2",type:"#e5c07b",tag:"#e06c75",attr:"#d19a66",default:"#abb2bf"}},catppuccin:{background:{primary:"#1e1e2e",secondary:"#313244"},text:{primary:"#cdd6f4",secondary:"#f5e0dc",muted:"#6c7086"},border:{light:"#313244"},syntax:{comment:"#6c7086",string:"#a6e3a1",number:"#fab387",keyword:"#cba6f7",function:"#89b4fa",variable:"#f5e0dc",operator:"#89dceb",type:"#f9e2af",tag:"#f38ba8",attr:"#f9e2af",default:"#cdd6f4"}},"rose-pine":{background:{primary:"#191724",secondary:"#1f1d2e"},text:{primary:"#e0def4",secondary:"#908caa",muted:"#6e6a86"},border:{light:"#26233a"},syntax:{comment:"#6e6a86",string:"#f6c177",number:"#ebbcba",keyword:"#c4a7e7",function:"#9ccfd8",variable:"#e0def4",operator:"#31748f",type:"#eb6f92",tag:"#eb6f92",attr:"#c4a7e7",default:"#e0def4"}},kanagawa:{background:{primary:"#1f1f28",secondary:"#2a2a37"},text:{primary:"#dcd7ba",secondary:"#c8c093",muted:"#727169"},border:{light:"#2a2a37"},syntax:{comment:"#727169",string:"#98bb6c",number:"#d27e99",keyword:"#957fb8",function:"#7e9cd8",variable:"#dcd7ba",operator:"#c0a36e",type:"#7aa89f",tag:"#e46876",attr:"#ffa066",default:"#dcd7ba"}}};function He(t){const n=t.replace("#",""),a=parseInt(n.substring(0,2),16),s=parseInt(n.substring(2,4),16),o=parseInt(n.substring(4,6),16);return(.299*a+.587*s+.114*o)/255<.5}function Ke(t){return{base:He(t.background.primary)?"vs-dark":"vs",inherit:!0,rules:[{token:"",foreground:t.text.primary.replace("#",""),background:t.background.primary.replace("#","")},{token:"comment",foreground:t.syntax.comment.replace("#",""),fontStyle:"italic"},{token:"string",foreground:t.syntax.string.replace("#","")},{token:"number",foreground:t.syntax.number.replace("#","")},{token:"keyword",foreground:t.syntax.keyword.replace("#","")},{token:"type",foreground:t.syntax.type.replace("#","")},{token:"identifier",foreground:t.syntax.variable.replace("#","")},{token:"function",foreground:t.syntax.function.replace("#","")},{token:"variable",foreground:t.syntax.variable.replace("#","")},{token:"operator",foreground:t.syntax.operator.replace("#","")},{token:"delimiter",foreground:t.syntax.operator.replace("#","")},{token:"tag",foreground:t.syntax.tag.replace("#","")},{token:"attribute.name",foreground:t.syntax.attr.replace("#","")},{token:"attribute.value",foreground:t.syntax.string.replace("#","")}],colors:{"editor.background":t.background.primary,"editor.foreground":t.text.primary,"editor.lineHighlightBackground":t.background.secondary,"editor.selectionBackground":`${t.syntax.function}40`,"editorLineNumber.foreground":t.text.muted,"editorLineNumber.activeForeground":t.text.secondary,"editorCursor.foreground":t.text.primary,"editorIndentGuide.background":t.border.light,"editorWidget.background":t.background.secondary,"editorWidget.border":t.border.light,"scrollbarSlider.background":`${t.text.muted}40`,"scrollbarSlider.hoverBackground":`${t.text.muted}60`}}}const me=new Set;function pe(t,n){const a=n.toLowerCase().replace(/\s+/g,"-"),s=Ve[a];if(!s)return"vs-dark";if(!me.has(a)){const o=Ke(s);t.editor.defineTheme(a,o),me.add(a)}return a}d.lazy(async()=>({default:(await ye(()=>import("./vendor-react-FPIC4Czm.js").then(n=>n.i),[])).DiffEditor}));const Ue=d.lazy(async()=>({default:(await ye(()=>import("./vendor-react-FPIC4Czm.js").then(n=>n.i),[])).Editor}));function te(t,n){return t instanceof Error?t.message:n}function dt(){const{toggleFilePreview:t}=_e(),{messages:n,currentSessionRef:a,sessions:s}=_(),[o,f]=d.useState("diff"),[c,i]=d.useState([]),[p,b]=d.useState({}),[x,y]=d.useState(!1),[m,R]=d.useState(null),[w,N]=d.useState({}),[O,J]=d.useState({}),[E,ae]=d.useState(null),[Fe,V]=d.useState(""),[H,K]=d.useState(!1),[U,X]=d.useState(null),[re,M]=d.useState(!1),ne=d.useRef(a),T=d.useRef(0),I=d.useRef(0),q=d.useRef({}),Q=d.useRef(0),F=d.useRef(0),A=d.useRef({}),C=d.useRef({}),Y=d.useRef(null);d.useLayoutEffect(()=>{z(ne.current,a)||(T.current+=1),ne.current=a},[a]);const Z=(r,l)=>l===T.current&&z(_.getState().currentSessionRef,r),se=async(r,l="")=>{const g=l?`/suggestions/files/tree?path=${encodeURIComponent(l)}`:"/suggestions/files/tree",u=await fetch(g,{headers:fe(r)});if(!u.ok)throw new Error("Failed to load tree");return(await u.json()).map(h=>({...h,children:h.type==="dir"?[]:void 0}))};d.useEffect(()=>{const r=++I.current;return(async()=>{if(!a){i([]),y(!1),R(null);return}const g={...a},u=T.current,k=()=>r===I.current&&Z(g,u);if(k()){i([]),y(!0),R(null);try{const h=await se(g);k()&&i(h)}catch(h){k()&&R(te(h,"Failed to load tree"))}finally{k()&&y(!1)}}})(),()=>{I.current===r&&(I.current+=1)}},[a==null?void 0:a.projectPath,a==null?void 0:a.sessionId]),d.useEffect(()=>{Y.current=null,A.current={},C.current={},q.current={},Q.current+=1,ae(null),V(""),K(!1),X(null),M(!1),N({}),b({})},[a==null?void 0:a.projectPath,a==null?void 0:a.sessionId]);const v=d.useMemo(()=>s.find(r=>z({sessionId:r.sessionId,projectPath:r.projectPath},a)),[a,s]),Ce=d.useMemo(()=>Qe(n),[n]),[Se,oe]=d.useState(null),[Be,ee]=d.useState(!1),[ie,de]=d.useState(null),S=Se??Ce,ce=d.useMemo(()=>Me(n),[n]),[Le,De]=d.useState({});d.useEffect(()=>{const r=++F.current;if(oe(null),de(null),ee(!1),!a||(v==null?void 0:v.taskIsolation)!=="worktree"||!v.taskDiffStat||v.taskDiffStat.changedFiles===0)return;const l={...a};return ee(!0),Ie.getTaskDiff(l).then(g=>{r!==F.current||!z(_.getState().currentSessionRef,l)||oe(g.files.map(u=>({filePath:u.path,diff:{patch:u.patch},summary:u.binary?"binary":`+${u.additions} -${u.deletions}${u.truncated?" (truncated)":""}`})))}).catch(g=>{r===F.current&&de(te(g,"Failed to load task diff"))}).finally(()=>{r===F.current&&ee(!1)}),()=>{F.current===r&&(F.current+=1)}},[v==null?void 0:v.taskCompletedAt,v==null?void 0:v.taskDiffStat,v==null?void 0:v.taskIsolation,a]);const Re=r=>{De(l=>({...l,[r]:!l[r]}))},Te=async r=>{const l=_.getState().currentSessionRef;if(!l)return;const g=T.current,u=++Q.current,k=()=>u===Q.current&&Y.current===r&&Z(l,g);Y.current=r,ae(r),V(""),K(!0),X(null),M(!1);try{const h=await fetch(`/suggestions/files/content?path=${encodeURIComponent(r)}`,{headers:fe(l)});if(!h.ok)throw new Error("Failed to load file");const $=await h.json();k()&&(V($.content||""),M(!!$.truncated))}catch(h){k()&&X(te(h,"Failed to load file"))}finally{k()&&K(!1)}},Ae=async r=>{const l=(q.current[r]??0)+1;q.current[r]=l;const g=!A.current[r],u={...A.current,[r]:g};if(A.current=u,N(u),!g||C.current[r])return;const k=_.getState().currentSessionRef;if(!k)return;const h=T.current,$=()=>q.current[r]===l&&A.current[r]===!0&&Z(k,h);try{const P=await se(k,r);if($()){const le={...C.current,[r]:P};C.current=le,b(le)}}catch{if($()){const P={...C.current,[r]:[]};C.current=P,b(P)}}},$e=r=>{J(l=>({...l,[r]:!l[r]}))};return e.jsxs("div",{className:"w-[55%] min-w-[420px] max-w-[860px] border-l border-[#E5E7EB] dark:border-zinc-800 bg-white dark:bg-[#09090b] flex flex-col h-full shadow-xl shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 h-12 border-b border-[#E5E7EB] dark:border-zinc-800 shrink-0",children:[e.jsx("span",{className:"font-normal text-[13px] text-[#6B7280] dark:text-zinc-400 font-mono",children:"Preview"}),e.jsx(qe,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB]/60 dark:text-zinc-500 dark:hover:text-zinc-300 dark:hover:bg-zinc-800/50",children:e.jsx(We,{className:"w-4 h-4"})})]}),e.jsxs(Je,{value:o,onValueChange:r=>f(r),className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"px-4 py-3 border-b border-[#E5E7EB] dark:border-zinc-800",children:e.jsxs(we,{className:"bg-white dark:bg-[#111113] border border-[#E5E7EB] dark:border-[#27272a] h-9 p-1 rounded-md w-full justify-start",children:[e.jsx(W,{value:"diff",className:"text-[12px] font-mono px-3 text-[#6B7280] dark:text-[#a1a1aa] data-[state=active]:bg-[#E5E7EB] data-[state=active]:text-[#111827] dark:data-[state=active]:bg-[#27272a] dark:data-[state=active]:text-white",children:"Diff"}),e.jsx(W,{value:"files",className:"text-[12px] font-mono px-3 text-[#6B7280] dark:text-[#a1a1aa] data-[state=active]:bg-[#E5E7EB] data-[state=active]:text-[#111827] dark:data-[state=active]:bg-[#27272a] dark:data-[state=active]:text-white",children:"Files"}),e.jsx(W,{value:"logs",className:"text-[12px] font-mono px-3 text-[#6B7280] dark:text-[#a1a1aa] data-[state=active]:bg-[#E5E7EB] data-[state=active]:text-[#111827] dark:data-[state=active]:bg-[#27272a] dark:data-[state=active]:text-white",children:"Logs"})]})}),e.jsx(G,{value:"diff",className:"overflow-hidden flex-1 mt-0",children:e.jsx("div",{className:"overflow-y-auto px-4 py-4 space-y-3 h-full",children:Be&&S.length===0?e.jsx(j,{title:"Loading task diff…",subtitle:"Reading the durable worktree artifact."}):ie&&S.length===0?e.jsx(j,{title:"Failed to load task diff",subtitle:ie}):S.length===0?e.jsx(j,{title:"No patch yet",subtitle:"Run a tool that changes files to see diffs here."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-[12px] text-[#6B7280] dark:text-[#71717a] font-mono mb-2",children:[S.length," changed file",S.length>1?"s":""]}),S.map(r=>{var u;const l=((u=r.filePath)==null?void 0:u.split("/").pop())||"unknown",g=Le[r.filePath||""]!==!1;return e.jsxs("div",{className:"border border-[#E5E7EB] dark:border-[#27272a] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>Re(r.filePath||""),className:"w-full flex items-center gap-2 px-3 py-2 bg-[#F9FAFB] dark:bg-[#111113] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b] transition-colors",children:[g?e.jsx(ue,{className:"w-4 h-4 text-[#6B7280] dark:text-[#71717a]"}):e.jsx(xe,{className:"w-4 h-4 text-[#6B7280] dark:text-[#71717a]"}),e.jsx(je,{className:"w-4 h-4 text-[#6B7280] dark:text-[#71717a]"}),e.jsx("span",{className:"text-[13px] text-[#111827] dark:text-[#E5E5E5] font-mono flex-1 text-left truncate",children:l}),r.summary&&e.jsx("span",{className:"text-[11px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:r.summary})]}),g&&e.jsxs("div",{className:"border-t border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("div",{className:"px-3 py-1 text-[11px] text-[#9CA3AF] dark:text-[#52525b] font-mono truncate",children:r.filePath}),e.jsx(et,{diff:r.diff})]})]},r.filePath)})]})})}),e.jsx(G,{value:"files",className:"overflow-hidden flex-1 mt-0",children:e.jsxs("div",{className:"px-4 py-4 h-full",children:[x&&e.jsx(j,{title:"Loading files…",subtitle:"Fetching workspace tree."}),!x&&m&&e.jsx(j,{title:"Failed to load files",subtitle:m}),!x&&!m&&c.length===0&&e.jsx(j,{title:"No files yet",subtitle:"Start a session to load the workspace tree."}),!x&&!m&&c.length>0&&e.jsxs("div",{className:"h-full grid grid-cols-[220px_1fr] gap-4 min-h-0",children:[e.jsx("div",{className:"border border-[#E5E7EB] dark:border-[#27272a] rounded-lg p-2 overflow-y-auto min-h-0",children:c.map(r=>e.jsx(Ne,{node:r,depth:0,expandedDirs:w,childrenCache:p,toggleDir:Ae,selectedPath:E,onSelectFile:Te},r.path))}),e.jsxs("div",{className:"border border-[#E5E7EB] dark:border-[#27272a] rounded-lg overflow-hidden flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-2 bg-[#F9FAFB] dark:bg-[#111113] border-b border-[#E5E7EB] dark:border-[#27272a] text-[12px] text-[#6B7280] dark:text-[#71717a] font-mono flex items-center justify-between",children:[e.jsx("span",{children:E||"Select a file to preview"}),E&&e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#a1a1aa] font-mono",children:H?"Loading…":re?"Truncated":"Ready"})]}),re&&!H&&e.jsx("div",{className:"px-3 py-2 bg-[#FEF3C7] dark:bg-[#111113] border-b border-[#E5E7EB] dark:border-[#27272a] text-[11px] text-[#b45309] dark:text-[#facc15] font-mono",children:"Preview truncated to 200k characters."}),e.jsxs("div",{className:"flex-1 min-h-0",children:[!E&&e.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[#6B7280] dark:text-[#71717a] font-mono",children:"Pick a file from the tree to preview."}),E&&U&&e.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[#DC2626] dark:text-[#fca5a5] font-mono",children:U}),E&&!U&&e.jsx("div",{className:"h-full",children:H?e.jsx(he,{}):e.jsx(d.Suspense,{fallback:e.jsx(he,{}),children:e.jsx(Ye,{content:Fe,filename:E})})})]})]})]})]})}),e.jsx(G,{value:"logs",className:"overflow-hidden flex-1 mt-0",children:e.jsx("div",{className:"overflow-y-auto px-4 py-4 space-y-3 h-full",children:ce.length===0?e.jsx(j,{title:"No logs yet",subtitle:"Tool runs will appear here."}):ce.map(r=>{var h;const l=O[r.id],g=(r.content||"").split(`
2
2
  `),u=g.length>10||(((h=r.content)==null?void 0:h.length)||0)>800,k=l||!u?g:g.slice(0,8);return e.jsxs("div",{className:"border border-[#E5E7EB] dark:border-[#27272a] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-[#F9FAFB] dark:bg-[#111113] border-b border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono",children:r.title}),r.subtitle&&e.jsx("div",{className:"text-[11px] text-[#6B7280] dark:text-[#71717a] font-mono",children:r.subtitle})]}),e.jsx(Xe,{status:r.status})]}),r.content&&e.jsxs("div",{className:"px-3 py-3 space-y-2",children:[e.jsxs("pre",{className:"text-[12px] text-[#374151] dark:text-[#d4d4d8] bg-[#F3F4F6] dark:bg-[#09090b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md p-3 overflow-x-auto whitespace-pre-wrap font-mono",children:[k.join(`
3
3
  `),!l&&u&&`
4
4
  …`]}),u&&e.jsxs("button",{onClick:()=>$e(r.id),className:"flex items-center gap-1 text-[12px] text-[#6B7280] dark:text-[#a1a1aa] font-mono hover:text-[#111827] dark:hover:text-[#E5E5E5] transition-colors",children:[l?e.jsx(ue,{className:"w-3 h-3"}):e.jsx(xe,{className:"w-3 h-3"}),l?"Collapse":"Expand"]})]})]},r.id)})})})]})]})}function j({title:t,subtitle:n}){return e.jsxs("div",{className:"border border-dashed border-[#E5E7EB] dark:border-[#27272a] rounded-lg p-6 text-center",children:[e.jsx("div",{className:"text-[13px] text-[#111827] dark:text-[#E5E5E5] font-mono",children:t}),e.jsx("div",{className:"text-[12px] text-[#6B7280] dark:text-[#71717a] font-mono mt-1",children:n})]})}function Xe({status:t}){const n=t==="success"?"Success":t==="error"?"Failed":"Running",a=t==="success"?"bg-[#22C55E] text-white":t==="error"?"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]":"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]";return e.jsx("span",{className:D("text-[11px] px-2 py-0.5 rounded-full font-mono",a),children:n})}function Ne({node:t,depth:n,expandedDirs:a,childrenCache:s,toggleDir:o,onSelectFile:f,selectedPath:c}){const i=t.type==="dir",p=a[t.path],b=!i&&c===t.path,x=s[t.path]||[];return e.jsxs("div",{children:[e.jsx("button",{onClick:()=>{i?o(t.path):f(t.path)},className:D("flex items-center gap-2 w-full text-left text-[12px] font-mono px-2 py-1 rounded-md transition-colors",b?"bg-[#16A34A]/10 text-[#111827] dark:bg-[#22C55E]/10 dark:text-[#E5E5E5]":"hover:bg-[#F3F4F6] text-[#6B7280] dark:hover:bg-[#111113] dark:text-[#a1a1aa]",i&&"cursor-pointer",b&&"border border-[#16A34A]/30 dark:border-[#22C55E]/30"),style:{paddingLeft:n*14+8},children:i?e.jsxs(e.Fragment,{children:[p?e.jsx(Ge,{className:"h-3.5 w-3.5 shrink-0 text-[#111827] dark:text-[#E5E5E5]"}):e.jsx(Oe,{className:"h-3.5 w-3.5 shrink-0 text-[#6B7280] dark:text-[#a1a1aa]"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:t.name})]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"h-3.5 w-3.5 shrink-0 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:t.name})]})}),i&&p&&e.jsx("div",{children:x.map(y=>e.jsx(Ne,{node:y,depth:n+1,expandedDirs:a,childrenCache:s,toggleDir:o,onSelectFile:f,selectedPath:c},y.path))})]})}function Me(t){return t.flatMap(n=>{var o,f,c;const a=[];if((o=n.agentContent)!=null&&o.toolCalls)for(const i of n.agentContent.toolCalls){const p=ge(i.arguments),b=i.output,x=b?(f=L(b))!=null&&f.diff?be(b):b:void 0;a.push({id:`${n.id}-${i.toolCallId}`,title:i.toolName||"Tool",subtitle:i.summary,status:i.status==="success"?"success":i.status==="error"?"error":"running",content:x||(p?`Arguments:
@@ -1 +1 @@
1
- import{M as p,r as h,_ as j}from"./vendor-markdown-b9iCqZWK.js";import{r as o,j as r}from"./vendor-react-FPIC4Czm.js";import{c as b}from"./index-B-BRpW1c.js";import{a as f}from"./SettingsStore-BfoB9tNV.js";import{k as g,Q as N}from"./vendor-icons-DBM55KTG.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-DyP_DOwV.js";const v=[h],y=o.lazy(()=>j(()=>import("./CodeBlockHighlighter-D8_cOYpG.js"),[]).then(t=>({default:t.CodeBlockHighlighter}))),R=o.memo(function({content:s,className:a,syntaxHighlight:d=!0}){const i=f(),E=o.useMemo(()=>({code({className:e,children:n,...x}){const c=/language-(\w+)/.exec(e||""),k=!c,m=c?c[1]:"",l=String(n).replace(/\n$/,"");return k?r.jsx("code",{className:b("bg-[#F3F4F6] dark:bg-[#27272a] px-1.5 py-0.5 rounded text-[#111827] dark:text-[#E5E5E5] font-mono text-[13px]",e),...x,children:n}):d?r.jsxs("div",{className:"relative my-4 rounded-lg overflow-hidden border border-[#E5E7EB] dark:border-[#27272a] bg-[#F9FAFB] dark:bg-[#1e1e1e]",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#F3F4F6] dark:bg-[#27272a] border-b border-[#E5E7EB] dark:border-[#27272a]",children:[r.jsx("span",{className:"text-xs text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:m||"text"}),r.jsx(F,{content:l})]}),r.jsx(o.Suspense,{fallback:r.jsx(u,{className:e,code:l,props:x}),children:r.jsx(y,{code:l,language:m,isDark:i})})]}):r.jsx(u,{className:e,code:l,props:x})},p({children:e}){return r.jsx("p",{className:"mb-4 leading-relaxed last:mb-0",children:e})},ul({children:e}){return r.jsx("ul",{className:"pl-4 mb-4 space-y-1 list-disc last:mb-0",children:e})},ol({children:e}){return r.jsx("ol",{className:"pl-4 mb-4 space-y-1 list-decimal last:mb-0",children:e})},li({children:e}){return r.jsx("li",{className:"leading-relaxed",children:e})},h1({children:e}){return r.jsx("h1",{className:"text-2xl font-bold mb-4 mt-6 text-[#111827] dark:text-[#E5E5E5]",children:e})},h2({children:e}){return r.jsx("h2",{className:"text-xl font-bold mb-3 mt-5 text-[#111827] dark:text-[#E5E5E5]",children:e})},h3({children:e}){return r.jsx("h3",{className:"text-lg font-bold mb-2 mt-4 text-[#111827] dark:text-[#E5E5E5]",children:e})},blockquote({children:e}){return r.jsx("blockquote",{className:"border-l-2 border-[#22C55E] pl-4 italic text-[#6B7280] dark:text-[#a1a1aa] mb-4",children:e})},a({href:e,children:n}){return r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-[#22C55E] hover:underline transition-colors",children:n})},table({children:e}){return r.jsx("div",{className:"overflow-x-auto mb-4 border border-[#E5E7EB] dark:border-[#27272a] rounded-lg",children:r.jsx("table",{className:"w-full text-sm text-left",children:e})})},thead({children:e}){return r.jsx("thead",{className:"bg-[#F3F4F6] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]",children:e})},tbody({children:e}){return r.jsx("tbody",{className:"divide-y divide-[#E5E7EB] dark:divide-[#27272a]",children:e})},tr({children:e}){return r.jsx("tr",{className:"hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]/50 transition-colors",children:e})},th({children:e}){return r.jsx("th",{className:"px-4 py-3 font-medium whitespace-nowrap",children:e})},td({children:e}){return r.jsx("td",{className:"px-4 py-3 text-[#374151] dark:text-[#d4d4d8]",children:e})},hr(){return r.jsx("hr",{className:"my-6 border-[#E5E7EB] dark:border-[#27272a]"})}}),[i,d]);return r.jsx("div",{className:b("text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono break-words min-w-0 w-full",a),children:r.jsx(p,{remarkPlugins:v,components:E,children:s})})});function u({className:t,code:s,props:a}){return r.jsx("pre",{className:"my-4 overflow-x-auto rounded-lg border border-[#E5E7EB] dark:border-[#27272a] bg-[#F9FAFB] dark:bg-[#1e1e1e] p-4 text-[13px] leading-normal",children:r.jsx("code",{className:t,...a,children:s})})}function F({content:t}){const[s,a]=o.useState(!1),d=async()=>{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2e3)};return r.jsx("button",{onClick:d,className:"p-1 hover:bg-[#E5E7EB] dark:hover:bg-[#3f3f46] rounded-md transition-colors text-[#9CA3AF] dark:text-[#a1a1aa] hover:text-[#111827] dark:hover:text-[#E5E5E5]",title:"Copy code",children:s?r.jsx(g,{className:"h-3.5 w-3.5 text-[#22C55E]"}):r.jsx(N,{className:"h-3.5 w-3.5"})})}export{R as MarkdownRenderer};
1
+ import{M as p,r as h,_ as j}from"./vendor-markdown-b9iCqZWK.js";import{r as o,j as r}from"./vendor-react-FPIC4Czm.js";import{c as b}from"./index-DIWzaS2_.js";import{a as f}from"./SettingsStore-C8YBWQPS.js";import{k as g,Q as N}from"./vendor-icons-DBM55KTG.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-DyP_DOwV.js";const v=[h],y=o.lazy(()=>j(()=>import("./CodeBlockHighlighter-D8_cOYpG.js"),[]).then(t=>({default:t.CodeBlockHighlighter}))),R=o.memo(function({content:s,className:a,syntaxHighlight:d=!0}){const i=f(),E=o.useMemo(()=>({code({className:e,children:n,...x}){const c=/language-(\w+)/.exec(e||""),k=!c,m=c?c[1]:"",l=String(n).replace(/\n$/,"");return k?r.jsx("code",{className:b("bg-[#F3F4F6] dark:bg-[#27272a] px-1.5 py-0.5 rounded text-[#111827] dark:text-[#E5E5E5] font-mono text-[13px]",e),...x,children:n}):d?r.jsxs("div",{className:"relative my-4 rounded-lg overflow-hidden border border-[#E5E7EB] dark:border-[#27272a] bg-[#F9FAFB] dark:bg-[#1e1e1e]",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#F3F4F6] dark:bg-[#27272a] border-b border-[#E5E7EB] dark:border-[#27272a]",children:[r.jsx("span",{className:"text-xs text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:m||"text"}),r.jsx(F,{content:l})]}),r.jsx(o.Suspense,{fallback:r.jsx(u,{className:e,code:l,props:x}),children:r.jsx(y,{code:l,language:m,isDark:i})})]}):r.jsx(u,{className:e,code:l,props:x})},p({children:e}){return r.jsx("p",{className:"mb-4 leading-relaxed last:mb-0",children:e})},ul({children:e}){return r.jsx("ul",{className:"pl-4 mb-4 space-y-1 list-disc last:mb-0",children:e})},ol({children:e}){return r.jsx("ol",{className:"pl-4 mb-4 space-y-1 list-decimal last:mb-0",children:e})},li({children:e}){return r.jsx("li",{className:"leading-relaxed",children:e})},h1({children:e}){return r.jsx("h1",{className:"text-2xl font-bold mb-4 mt-6 text-[#111827] dark:text-[#E5E5E5]",children:e})},h2({children:e}){return r.jsx("h2",{className:"text-xl font-bold mb-3 mt-5 text-[#111827] dark:text-[#E5E5E5]",children:e})},h3({children:e}){return r.jsx("h3",{className:"text-lg font-bold mb-2 mt-4 text-[#111827] dark:text-[#E5E5E5]",children:e})},blockquote({children:e}){return r.jsx("blockquote",{className:"border-l-2 border-[#22C55E] pl-4 italic text-[#6B7280] dark:text-[#a1a1aa] mb-4",children:e})},a({href:e,children:n}){return r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-[#22C55E] hover:underline transition-colors",children:n})},table({children:e}){return r.jsx("div",{className:"overflow-x-auto mb-4 border border-[#E5E7EB] dark:border-[#27272a] rounded-lg",children:r.jsx("table",{className:"w-full text-sm text-left",children:e})})},thead({children:e}){return r.jsx("thead",{className:"bg-[#F3F4F6] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]",children:e})},tbody({children:e}){return r.jsx("tbody",{className:"divide-y divide-[#E5E7EB] dark:divide-[#27272a]",children:e})},tr({children:e}){return r.jsx("tr",{className:"hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]/50 transition-colors",children:e})},th({children:e}){return r.jsx("th",{className:"px-4 py-3 font-medium whitespace-nowrap",children:e})},td({children:e}){return r.jsx("td",{className:"px-4 py-3 text-[#374151] dark:text-[#d4d4d8]",children:e})},hr(){return r.jsx("hr",{className:"my-6 border-[#E5E7EB] dark:border-[#27272a]"})}}),[i,d]);return r.jsx("div",{className:b("text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono break-words min-w-0 w-full",a),children:r.jsx(p,{remarkPlugins:v,components:E,children:s})})});function u({className:t,code:s,props:a}){return r.jsx("pre",{className:"my-4 overflow-x-auto rounded-lg border border-[#E5E7EB] dark:border-[#27272a] bg-[#F9FAFB] dark:bg-[#1e1e1e] p-4 text-[13px] leading-normal",children:r.jsx("code",{className:t,...a,children:s})})}function F({content:t}){const[s,a]=o.useState(!1),d=async()=>{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2e3)};return r.jsx("button",{onClick:d,className:"p-1 hover:bg-[#E5E7EB] dark:hover:bg-[#3f3f46] rounded-md transition-colors text-[#9CA3AF] dark:text-[#a1a1aa] hover:text-[#111827] dark:hover:text-[#E5E5E5]",title:"Copy code",children:s?r.jsx(g,{className:"h-3.5 w-3.5 text-[#22C55E]"}):r.jsx(N,{className:"h-3.5 w-3.5"})})}export{R as MarkdownRenderer};
@@ -1,4 +1,4 @@
1
- import{r as o,j as e}from"./vendor-react-FPIC4Czm.js";import{u as ge,D as V,a as ee,b as te,c as A}from"./index-B-BRpW1c.js";import{_ as T,q as w,r as se,s as oe,t as W}from"./vendor-radix-DyP_DOwV.js";import{i as ve,a as Ee,d as le,u as pe,b as be,c as je,e as O,f as G,g as ke}from"./useRequest-B4kP-cmG.js";import{K as Ne,q as Ce,X as ae,y as ye,L as ce,N as de,k as we,O as Ae}from"./vendor-icons-DBM55KTG.js";import"./vendor-markdown-b9iCqZWK.js";import"./vendor-monaco-w6PwaWGP.js";function q(a,n){if(ve){if(!a)return n;var r;return Ee(a)?r=a():"current"in a?r=a.current:r=a,r}}var Se=function(a){var n=function(r,c,d){var l=o.useRef(!1),s=o.useRef([]),m=o.useRef([]),h=o.useRef(void 0);a(function(){var i,k=Array.isArray(d)?d:[d],v=k.map(function(N){return q(N)});if(!l.current){l.current=!0,s.current=v,m.current=c,h.current=r();return}(v.length!==s.current.length||!le(s.current,v)||!le(m.current,c))&&((i=h.current)===null||i===void 0||i.call(h),s.current=v,m.current=c,h.current=r())}),pe(function(){var i;(i=h.current)===null||i===void 0||i.call(h),l.current=!1})};return n},Fe=Se(o.useEffect);function Be(){var a=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,n=typeof self=="object"&&self&&self.Object===Object&&self;return a||n}Be()||(global.Date=Date);function Me(a,n){var r,c=be(a),d=(r=n==null?void 0:n.wait)!==null&&r!==void 0?r:1e3,l=o.useMemo(function(){return je(function(){for(var s=[],m=0;m<arguments.length;m++)s[m]=arguments[m];return c.current.apply(c,T([],w(s),!1))},d,n)},[]);return pe(function(){l.cancel()}),{run:l,cancel:l.cancel,flush:l.flush}}function De(a,n,r){r===void 0&&(r={});var c=r.enable,d=c===void 0?!0:c,l=be(n);Fe(function(){if(d){var s=q(r.target,window);if(s!=null&&s.addEventListener){var m=function(i){return l.current(i)},h=Array.isArray(a)?a:[a];return h.forEach(function(i){s.addEventListener(i,m,{capture:r.capture,once:r.once,passive:r.passive})}),function(){h.forEach(function(i){s.removeEventListener(i,m,{capture:r.capture})})}}}},[a,r.capture,r.once,r.passive,d],r.target)}var Te=function(a){return a===document||a===document.documentElement||a===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):a.scrollTop},ie=function(a){return a.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},_e=function(a){return a.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},Ie=function(a,n){n===void 0&&(n={});var r=n.target,c=n.isNoMore,d=n.threshold,l=d===void 0?100:d,s=n.direction,m=s===void 0?"bottom":s,h=n.reloadDeps,i=h===void 0?[]:h,k=n.manual,v=n.onBefore,N=n.onSuccess,S=n.onError,p=n.onFinally,_=w(o.useState(),2),C=_[0],F=_[1],R=w(o.useState(!1),2),P=R[0],g=R[1],B=m==="top",y=o.useRef(void 0),E=o.useRef(0),L=o.useMemo(function(){return c?c(C):!1},[C]),M=O(function(x){return se(void 0,void 0,void 0,function(){var f;return oe(this,function(t){switch(t.label){case 0:return[4,a(x)];case 1:return f=t.sent(),[2,{currentData:f,lastData:x}]}})})},{manual:k,onFinally:function(x,f,t){g(!1),p==null||p(f==null?void 0:f.currentData,t)},onBefore:function(){return v==null?void 0:v()},onSuccess:function(x){var f,t,j;x.lastData?F(W(W({},x.currentData),{list:B?T(T([],w(x.currentData.list),!1),w((t=x.lastData.list)!==null&&t!==void 0?t:[]),!1):T(T([],w((j=x.lastData.list)!==null&&j!==void 0?j:[]),!1),w(x.currentData.list),!1)})):F(W(W({},x.currentData),{list:T([],w((f=x.currentData.list)!==null&&f!==void 0?f:[]),!1)})),setTimeout(function(){if(B){var b=q(r);if(b=b===document?document.documentElement:b,b){var z=ie(b);b.scrollTo(0,z-E.current)}}else J()}),N==null||N(x.currentData)},onError:function(x){return S==null?void 0:S(x)}}),$=M.loading,Y=M.error,H=M.run,Q=M.runAsync,K=M.cancel,I=G(function(){L||(g(!0),H(C))}),u=function(x){return se(void 0,void 0,void 0,function(){var f;return oe(this,function(t){switch(t.label){case 0:return[4,Q(x)];case 1:return f=t.sent(),[2,f.currentData]}})})},D=G(function(){return L?Promise.reject():(g(!0),u(C))}),U=function(){return g(!1),H()},X=function(){return g(!1),u()},J=function(){var x=q(r);if(x){var f=x===document?document.documentElement:x,t=Te(f),j=ie(f),b=_e(f);B?(y.current!==void 0&&y.current>t&&t<=l&&I(),y.current=t,E.current=j-t):j-t<=b+l&&I()}};return De("scroll",function(){$||P||J()},{target:r}),ke(function(){H()},T([],w(i),!1)),{data:C,loading:!P&&$,error:Y,loadingMore:P,noMore:L,loadMore:I,loadMoreAsync:D,reload:G(U),reloadAsync:G(X),mutate:F,cancel:K}};const xe={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},me={connected:"Connected",connecting:"Connecting...",offline:"Offline",error:"Error"},ue=20,Oe=async()=>{const a=await fetch("/mcp");if(!a.ok)throw new Error("Failed to fetch servers");return a.json()},Re="mcp server @modelcontextprotocol",Pe=3,Le=async(a,n)=>{const r=a&&a.length>=Pe?a:Re,c=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(r)}&size=${ue}&from=${n}`,d=await fetch(c);if(!d.ok)throw new Error("Failed to fetch packages");const l=await d.json();return{list:l.objects.map(s=>s.package),total:l.total,hasMore:n+ue<l.total}};function Ke(){const{isMcpOpen:a,toggleMcp:n}=ge(),[r,c]=o.useState("installed"),[d,l]=o.useState(!1),[s,m]=o.useState(null),[h,i]=o.useState({}),[k,v]=o.useState(""),[N,S]=o.useState(""),[p,_]=o.useState(null),[C,F]=o.useState(null),R=o.useRef(null),{run:P}=Me(t=>{S(t)},{wait:500}),{data:g=[],loading:B,run:y}=O(Oe,{refreshDeps:[a],ready:a,onSuccess:t=>{t.length>0&&!s&&m(t[0].id)}}),{data:E,loading:L,loadingMore:M,noMore:$,reload:Y}=Ie(async t=>{var b;const j=((b=t==null?void 0:t.list)==null?void 0:b.length)??0;return Le(N,j)},{target:R,isNoMore:t=>!(t!=null&&t.hasMore),reloadDeps:[N],manual:!a||r!=="catalog"}),{runAsync:H}=O(async t=>{await fetch(`/mcp/${encodeURIComponent(t)}/connect`,{method:"POST"})},{manual:!0,onSuccess:y}),{runAsync:Q}=O(async t=>{await fetch(`/mcp/${encodeURIComponent(t)}/disconnect`,{method:"POST"})},{manual:!0,onSuccess:y}),{runAsync:K}=O(async t=>{await fetch(`/mcp/${encodeURIComponent(t)}`,{method:"DELETE"})},{manual:!0,onSuccess:y}),{runAsync:I}=O(async t=>{await fetch("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,config:t})})},{manual:!0,onSuccess:()=>{y(),l(!1),F(null),_(null)},onError:()=>{_(null)}}),u=o.useMemo(()=>g.find(t=>t.id===s)??g[0],[g,s]),D=u?h[u.id]??{read:!0,write:!1,shell:!1}:{read:!0,write:!1,shell:!1},U=t=>{u&&i(j=>({...j,[u.id]:{...D,[t]:!D[t]}}))},X=o.useMemo(()=>new Set(g.map(t=>t.name.toLowerCase())),[g]),J=t=>{F(t)},x=t=>t.startsWith("@modelcontextprotocol/"),f=t=>x(t.name)?"Official":"Community";return e.jsxs(e.Fragment,{children:[e.jsx(V,{open:a,onOpenChange:n,children:e.jsxs(ee,{className:"sm:max-w-[900px] h-[680px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(te,{className:"sr-only",children:"MCP"}),e.jsx("div",{className:"flex flex-1 min-h-0",children:e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-5 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:y,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:B,children:e.jsx(Ne,{className:A("h-4 w-4",B&&"animate-spin")})}),e.jsxs("button",{onClick:()=>l(!0),className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Add server"]}),e.jsx("button",{onClick:n,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(ae,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[e.jsxs(fe,{active:r==="installed",onClick:()=>c("installed"),children:["Installed (",g.length,")"]}),e.jsx(fe,{active:r==="catalog",onClick:()=>{c("catalog"),E||Y()},children:"Catalog"})]}),r==="installed"?e.jsxs("div",{className:"flex gap-5 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-[220px] flex flex-col gap-3 min-h-0 overflow-hidden",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Servers"}),e.jsx("div",{className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 text-[12px] text-[#9CA3AF] dark:text-[#71717a] font-mono shrink-0",children:"Search servers..."}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[g.length===0&&!B&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No MCP servers configured"}),g.map(t=>e.jsxs("button",{onClick:()=>m(t.id),className:A("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",t.id===s?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:A("text-[11px] font-mono font-semibold",xe[t.status]),children:me[t.status]})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.endpoint})]},t.id))]})]}),u?e.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-y-auto pr-2 min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:u.name}),e.jsx("span",{className:A("text-xs font-mono font-semibold",xe[u.status]),children:me[u.status]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:u.description}),u.error&&e.jsxs("p",{className:"text-[12px] font-mono text-[#ef4444]",children:["Error: ",u.error]}),e.jsxs("div",{className:"flex items-center gap-2",children:[u.status==="connected"?e.jsx("button",{onClick:()=>Q(u.name),className:"h-7 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Disconnect"}):e.jsx("button",{onClick:()=>H(u.name),className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Connect"}),e.jsx("button",{onClick:()=>K(u.name),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:"Delete"})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Permissions"}),e.jsx(Z,{label:"File read",enabled:D.read,onToggle:()=>U("read")}),e.jsx(Z,{label:"File write",enabled:D.write,onToggle:()=>U("write")}),e.jsx(Z,{label:"Shell exec",enabled:D.shell,onToggle:()=>U("shell")}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Tools (",u.tools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No tools available"}):u.tools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a server to view details"})})]}):e.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-h-0",children:[e.jsx("div",{className:"flex items-center gap-3 shrink-0",children:e.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[e.jsx(ye,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("input",{type:"text",value:k,onChange:t=>{v(t.target.value),P(t.target.value)},placeholder:"Search MCP servers on npm (min 3 chars)...",className:"flex-1 bg-transparent text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none"})]})}),e.jsxs("div",{ref:R,className:"flex-1 overflow-y-auto min-h-0",children:[L&&!E?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ce,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):e.jsx("div",{className:"grid grid-cols-2 gap-3 pb-4",children:E==null?void 0:E.list.map(t=>{var ne,re;const j=X.has(t.name.toLowerCase().replace(/\s+/g,"-")),b=p===t.name,z=f(t);return e.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:t.name}),e.jsx("span",{className:A("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",z==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:z})]}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2",children:t.description||"No description"}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsxs("span",{children:["v",t.version]}),((ne=t.publisher)==null?void 0:ne.username)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["by ",t.publisher.username]})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-auto pt-2",children:[e.jsxs("a",{href:((re=t.links)==null?void 0:re.npm)||`https://www.npmjs.com/package/${t.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5] flex items-center gap-1",children:[e.jsx(de,{className:"h-3 w-3"}),"npm"]}),j?e.jsxs("span",{className:"text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1",children:[e.jsx(we,{className:"h-3 w-3"}),"Installed"]}):e.jsxs("button",{onClick:()=>J(t),disabled:b,className:"h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50",children:[e.jsx(Ae,{className:A("h-3 w-3",b&&"animate-pulse")}),b?"Installing...":"Install"]})]})]},t.name)})}),M&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ce,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),$&&E&&E.list.length>0&&e.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No more packages"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[(E==null?void 0:E.total)??0," packages found"]}),e.jsxs("a",{href:"https://glama.ai/mcp/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-mono text-[#3b82f6] hover:underline flex items-center gap-1",children:["Browse more on Glama",e.jsx(de,{className:"h-3 w-3"})]})]})]})]})})]})}),e.jsx(Ue,{open:d,onOpenChange:l,onAdd:I}),C&&e.jsx($e,{pkg:C,onClose:()=>F(null),onInstall:t=>{_(C.name),I(t)}})]})}function fe({active:a,children:n,onClick:r}){return e.jsx("button",{onClick:r,className:A("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",a?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:n})}function Z({label:a,enabled:n,onToggle:r}){return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a}),e.jsx(He,{enabled:n,onChange:r})]})}function He({enabled:a,onChange:n}){return e.jsx("button",{onClick:n,className:A("w-9 h-5 rounded-full px-0.5 flex items-center transition-colors",a?"bg-[#16A34A] dark:bg-[#22C55E] justify-end":"bg-[#E5E7EB] dark:bg-[#27272a] justify-start"),children:e.jsx("span",{className:"h-4 w-4 rounded-full bg-white"})})}function Ue({open:a,onOpenChange:n,onAdd:r}){const[c,d]=o.useState("form"),[l,s]=o.useState(""),[m,h]=o.useState(""),[i,k]=o.useState(""),[v,N]=o.useState(`{
1
+ import{r as o,j as e}from"./vendor-react-FPIC4Czm.js";import{u as ge,D as V,a as ee,b as te,c as A}from"./index-DIWzaS2_.js";import{_ as T,q as w,r as se,s as oe,t as W}from"./vendor-radix-DyP_DOwV.js";import{i as ve,a as Ee,d as le,u as pe,b as be,c as je,e as O,f as G,g as ke}from"./useRequest-B4kP-cmG.js";import{K as Ne,q as Ce,X as ae,y as ye,L as ce,N as de,k as we,O as Ae}from"./vendor-icons-DBM55KTG.js";import"./vendor-markdown-b9iCqZWK.js";import"./vendor-monaco-w6PwaWGP.js";function q(a,n){if(ve){if(!a)return n;var r;return Ee(a)?r=a():"current"in a?r=a.current:r=a,r}}var Se=function(a){var n=function(r,c,d){var l=o.useRef(!1),s=o.useRef([]),m=o.useRef([]),h=o.useRef(void 0);a(function(){var i,k=Array.isArray(d)?d:[d],v=k.map(function(N){return q(N)});if(!l.current){l.current=!0,s.current=v,m.current=c,h.current=r();return}(v.length!==s.current.length||!le(s.current,v)||!le(m.current,c))&&((i=h.current)===null||i===void 0||i.call(h),s.current=v,m.current=c,h.current=r())}),pe(function(){var i;(i=h.current)===null||i===void 0||i.call(h),l.current=!1})};return n},Fe=Se(o.useEffect);function Be(){var a=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,n=typeof self=="object"&&self&&self.Object===Object&&self;return a||n}Be()||(global.Date=Date);function Me(a,n){var r,c=be(a),d=(r=n==null?void 0:n.wait)!==null&&r!==void 0?r:1e3,l=o.useMemo(function(){return je(function(){for(var s=[],m=0;m<arguments.length;m++)s[m]=arguments[m];return c.current.apply(c,T([],w(s),!1))},d,n)},[]);return pe(function(){l.cancel()}),{run:l,cancel:l.cancel,flush:l.flush}}function De(a,n,r){r===void 0&&(r={});var c=r.enable,d=c===void 0?!0:c,l=be(n);Fe(function(){if(d){var s=q(r.target,window);if(s!=null&&s.addEventListener){var m=function(i){return l.current(i)},h=Array.isArray(a)?a:[a];return h.forEach(function(i){s.addEventListener(i,m,{capture:r.capture,once:r.once,passive:r.passive})}),function(){h.forEach(function(i){s.removeEventListener(i,m,{capture:r.capture})})}}}},[a,r.capture,r.once,r.passive,d],r.target)}var Te=function(a){return a===document||a===document.documentElement||a===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):a.scrollTop},ie=function(a){return a.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},_e=function(a){return a.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},Ie=function(a,n){n===void 0&&(n={});var r=n.target,c=n.isNoMore,d=n.threshold,l=d===void 0?100:d,s=n.direction,m=s===void 0?"bottom":s,h=n.reloadDeps,i=h===void 0?[]:h,k=n.manual,v=n.onBefore,N=n.onSuccess,S=n.onError,p=n.onFinally,_=w(o.useState(),2),C=_[0],F=_[1],R=w(o.useState(!1),2),P=R[0],g=R[1],B=m==="top",y=o.useRef(void 0),E=o.useRef(0),L=o.useMemo(function(){return c?c(C):!1},[C]),M=O(function(x){return se(void 0,void 0,void 0,function(){var f;return oe(this,function(t){switch(t.label){case 0:return[4,a(x)];case 1:return f=t.sent(),[2,{currentData:f,lastData:x}]}})})},{manual:k,onFinally:function(x,f,t){g(!1),p==null||p(f==null?void 0:f.currentData,t)},onBefore:function(){return v==null?void 0:v()},onSuccess:function(x){var f,t,j;x.lastData?F(W(W({},x.currentData),{list:B?T(T([],w(x.currentData.list),!1),w((t=x.lastData.list)!==null&&t!==void 0?t:[]),!1):T(T([],w((j=x.lastData.list)!==null&&j!==void 0?j:[]),!1),w(x.currentData.list),!1)})):F(W(W({},x.currentData),{list:T([],w((f=x.currentData.list)!==null&&f!==void 0?f:[]),!1)})),setTimeout(function(){if(B){var b=q(r);if(b=b===document?document.documentElement:b,b){var z=ie(b);b.scrollTo(0,z-E.current)}}else J()}),N==null||N(x.currentData)},onError:function(x){return S==null?void 0:S(x)}}),$=M.loading,Y=M.error,H=M.run,Q=M.runAsync,K=M.cancel,I=G(function(){L||(g(!0),H(C))}),u=function(x){return se(void 0,void 0,void 0,function(){var f;return oe(this,function(t){switch(t.label){case 0:return[4,Q(x)];case 1:return f=t.sent(),[2,f.currentData]}})})},D=G(function(){return L?Promise.reject():(g(!0),u(C))}),U=function(){return g(!1),H()},X=function(){return g(!1),u()},J=function(){var x=q(r);if(x){var f=x===document?document.documentElement:x,t=Te(f),j=ie(f),b=_e(f);B?(y.current!==void 0&&y.current>t&&t<=l&&I(),y.current=t,E.current=j-t):j-t<=b+l&&I()}};return De("scroll",function(){$||P||J()},{target:r}),ke(function(){H()},T([],w(i),!1)),{data:C,loading:!P&&$,error:Y,loadingMore:P,noMore:L,loadMore:I,loadMoreAsync:D,reload:G(U),reloadAsync:G(X),mutate:F,cancel:K}};const xe={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},me={connected:"Connected",connecting:"Connecting...",offline:"Offline",error:"Error"},ue=20,Oe=async()=>{const a=await fetch("/mcp");if(!a.ok)throw new Error("Failed to fetch servers");return a.json()},Re="mcp server @modelcontextprotocol",Pe=3,Le=async(a,n)=>{const r=a&&a.length>=Pe?a:Re,c=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(r)}&size=${ue}&from=${n}`,d=await fetch(c);if(!d.ok)throw new Error("Failed to fetch packages");const l=await d.json();return{list:l.objects.map(s=>s.package),total:l.total,hasMore:n+ue<l.total}};function Ke(){const{isMcpOpen:a,toggleMcp:n}=ge(),[r,c]=o.useState("installed"),[d,l]=o.useState(!1),[s,m]=o.useState(null),[h,i]=o.useState({}),[k,v]=o.useState(""),[N,S]=o.useState(""),[p,_]=o.useState(null),[C,F]=o.useState(null),R=o.useRef(null),{run:P}=Me(t=>{S(t)},{wait:500}),{data:g=[],loading:B,run:y}=O(Oe,{refreshDeps:[a],ready:a,onSuccess:t=>{t.length>0&&!s&&m(t[0].id)}}),{data:E,loading:L,loadingMore:M,noMore:$,reload:Y}=Ie(async t=>{var b;const j=((b=t==null?void 0:t.list)==null?void 0:b.length)??0;return Le(N,j)},{target:R,isNoMore:t=>!(t!=null&&t.hasMore),reloadDeps:[N],manual:!a||r!=="catalog"}),{runAsync:H}=O(async t=>{await fetch(`/mcp/${encodeURIComponent(t)}/connect`,{method:"POST"})},{manual:!0,onSuccess:y}),{runAsync:Q}=O(async t=>{await fetch(`/mcp/${encodeURIComponent(t)}/disconnect`,{method:"POST"})},{manual:!0,onSuccess:y}),{runAsync:K}=O(async t=>{await fetch(`/mcp/${encodeURIComponent(t)}`,{method:"DELETE"})},{manual:!0,onSuccess:y}),{runAsync:I}=O(async t=>{await fetch("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,config:t})})},{manual:!0,onSuccess:()=>{y(),l(!1),F(null),_(null)},onError:()=>{_(null)}}),u=o.useMemo(()=>g.find(t=>t.id===s)??g[0],[g,s]),D=u?h[u.id]??{read:!0,write:!1,shell:!1}:{read:!0,write:!1,shell:!1},U=t=>{u&&i(j=>({...j,[u.id]:{...D,[t]:!D[t]}}))},X=o.useMemo(()=>new Set(g.map(t=>t.name.toLowerCase())),[g]),J=t=>{F(t)},x=t=>t.startsWith("@modelcontextprotocol/"),f=t=>x(t.name)?"Official":"Community";return e.jsxs(e.Fragment,{children:[e.jsx(V,{open:a,onOpenChange:n,children:e.jsxs(ee,{className:"sm:max-w-[900px] h-[680px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(te,{className:"sr-only",children:"MCP"}),e.jsx("div",{className:"flex flex-1 min-h-0",children:e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-5 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:y,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:B,children:e.jsx(Ne,{className:A("h-4 w-4",B&&"animate-spin")})}),e.jsxs("button",{onClick:()=>l(!0),className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Add server"]}),e.jsx("button",{onClick:n,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(ae,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[e.jsxs(fe,{active:r==="installed",onClick:()=>c("installed"),children:["Installed (",g.length,")"]}),e.jsx(fe,{active:r==="catalog",onClick:()=>{c("catalog"),E||Y()},children:"Catalog"})]}),r==="installed"?e.jsxs("div",{className:"flex gap-5 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-[220px] flex flex-col gap-3 min-h-0 overflow-hidden",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Servers"}),e.jsx("div",{className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 text-[12px] text-[#9CA3AF] dark:text-[#71717a] font-mono shrink-0",children:"Search servers..."}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[g.length===0&&!B&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No MCP servers configured"}),g.map(t=>e.jsxs("button",{onClick:()=>m(t.id),className:A("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",t.id===s?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:A("text-[11px] font-mono font-semibold",xe[t.status]),children:me[t.status]})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.endpoint})]},t.id))]})]}),u?e.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-y-auto pr-2 min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:u.name}),e.jsx("span",{className:A("text-xs font-mono font-semibold",xe[u.status]),children:me[u.status]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:u.description}),u.error&&e.jsxs("p",{className:"text-[12px] font-mono text-[#ef4444]",children:["Error: ",u.error]}),e.jsxs("div",{className:"flex items-center gap-2",children:[u.status==="connected"?e.jsx("button",{onClick:()=>Q(u.name),className:"h-7 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Disconnect"}):e.jsx("button",{onClick:()=>H(u.name),className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Connect"}),e.jsx("button",{onClick:()=>K(u.name),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:"Delete"})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Permissions"}),e.jsx(Z,{label:"File read",enabled:D.read,onToggle:()=>U("read")}),e.jsx(Z,{label:"File write",enabled:D.write,onToggle:()=>U("write")}),e.jsx(Z,{label:"Shell exec",enabled:D.shell,onToggle:()=>U("shell")}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Tools (",u.tools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No tools available"}):u.tools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a server to view details"})})]}):e.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-h-0",children:[e.jsx("div",{className:"flex items-center gap-3 shrink-0",children:e.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[e.jsx(ye,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("input",{type:"text",value:k,onChange:t=>{v(t.target.value),P(t.target.value)},placeholder:"Search MCP servers on npm (min 3 chars)...",className:"flex-1 bg-transparent text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none"})]})}),e.jsxs("div",{ref:R,className:"flex-1 overflow-y-auto min-h-0",children:[L&&!E?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ce,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):e.jsx("div",{className:"grid grid-cols-2 gap-3 pb-4",children:E==null?void 0:E.list.map(t=>{var ne,re;const j=X.has(t.name.toLowerCase().replace(/\s+/g,"-")),b=p===t.name,z=f(t);return e.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:t.name}),e.jsx("span",{className:A("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",z==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:z})]}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2",children:t.description||"No description"}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsxs("span",{children:["v",t.version]}),((ne=t.publisher)==null?void 0:ne.username)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["by ",t.publisher.username]})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-auto pt-2",children:[e.jsxs("a",{href:((re=t.links)==null?void 0:re.npm)||`https://www.npmjs.com/package/${t.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5] flex items-center gap-1",children:[e.jsx(de,{className:"h-3 w-3"}),"npm"]}),j?e.jsxs("span",{className:"text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1",children:[e.jsx(we,{className:"h-3 w-3"}),"Installed"]}):e.jsxs("button",{onClick:()=>J(t),disabled:b,className:"h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50",children:[e.jsx(Ae,{className:A("h-3 w-3",b&&"animate-pulse")}),b?"Installing...":"Install"]})]})]},t.name)})}),M&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ce,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),$&&E&&E.list.length>0&&e.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No more packages"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[(E==null?void 0:E.total)??0," packages found"]}),e.jsxs("a",{href:"https://glama.ai/mcp/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-mono text-[#3b82f6] hover:underline flex items-center gap-1",children:["Browse more on Glama",e.jsx(de,{className:"h-3 w-3"})]})]})]})]})})]})}),e.jsx(Ue,{open:d,onOpenChange:l,onAdd:I}),C&&e.jsx($e,{pkg:C,onClose:()=>F(null),onInstall:t=>{_(C.name),I(t)}})]})}function fe({active:a,children:n,onClick:r}){return e.jsx("button",{onClick:r,className:A("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",a?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:n})}function Z({label:a,enabled:n,onToggle:r}){return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a}),e.jsx(He,{enabled:n,onChange:r})]})}function He({enabled:a,onChange:n}){return e.jsx("button",{onClick:n,className:A("w-9 h-5 rounded-full px-0.5 flex items-center transition-colors",a?"bg-[#16A34A] dark:bg-[#22C55E] justify-end":"bg-[#E5E7EB] dark:bg-[#27272a] justify-start"),children:e.jsx("span",{className:"h-4 w-4 rounded-full bg-white"})})}function Ue({open:a,onOpenChange:n,onAdd:r}){const[c,d]=o.useState("form"),[l,s]=o.useState(""),[m,h]=o.useState(""),[i,k]=o.useState(""),[v,N]=o.useState(`{
2
2
  "name": "my-server",
3
3
  "command": "npx",
4
4
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
@@ -1 +1 @@
1
- import{r as l,j as e}from"./vendor-react-FPIC4Czm.js";import{D as O,a as M,b as T,c as u,u as _,d as H}from"./index-B-BRpW1c.js";import{u as J}from"./SettingsStore-BfoB9tNV.js";import{X as P,E as Q,D as W,b as L,f as q,i as V}from"./vendor-icons-DBM55KTG.js";import"./vendor-markdown-b9iCqZWK.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-DyP_DOwV.js";function X({open:a,onOpenChange:r,onSave:j}){const[f,v]=l.useState([]),[h,n]=l.useState([]),[s,c]=l.useState(),[i,m]=l.useState(),[k,w]=l.useState(""),[b,C]=l.useState(""),[F,E]=l.useState(!1),[S,N]=l.useState(!1),[y,B]=l.useState(!1);l.useEffect(()=>{a&&(n([]),c(void 0),m(void 0),w(""),C(""),E(!1),N(!1),B(!1),fetch("/providers").then(o=>o.json()).then(v))},[a]),l.useEffect(()=>{s&&fetch(`/providers/${s.id}/models`).then(o=>o.json()).then(n)},[s]);const A=()=>{!s||!i||!s.configured&&!b||(j({provider:s.id,model:i.id,displayName:k||i.name,apiKey:b||void 0}),r(!1))};return e.jsx(O,{open:a,onOpenChange:r,children:e.jsxs(M,{className:"sm:max-w-[480px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl [&>button]:hidden","aria-describedby":void 0,children:[e.jsx(T,{className:"sr-only",children:"Add Model"}),e.jsxs("div",{className:"flex flex-col gap-6 p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"font-mono text-base font-semibold",children:"Add Model"}),e.jsx("button",{type:"button",onClick:()=>r(!1),children:e.jsx(P,{className:"w-4 h-4"})})]}),e.jsx($,{label:"Provider",value:(s==null?void 0:s.name)??"Select provider",open:F,setOpen:E,options:f.map(o=>({id:o.id,label:`${o.name} (${o.modelCount})${o.configured?" · configured":""}`,selected:(s==null?void 0:s.id)===o.id,select:()=>{c(o),m(void 0),E(!1)}}))}),e.jsx($,{label:"Model",value:(i==null?void 0:i.name)??"Select model",open:S,setOpen:N,options:h.map(o=>({id:o.id,label:`${o.name} · ${Math.round(o.contextWindow/1e3)}K${o.reasoning?" · reasoning":""}${o.input.includes("image")?" · vision":""}`,selected:(i==null?void 0:i.id)===o.id,select:()=>{m(o),w(o.name),N(!1)}}))}),e.jsx(Y,{label:"Display name",value:k,onChange:w,placeholder:(i==null?void 0:i.name)??"Optional alias"}),(s==null?void 0:s.supportsApiKey)&&!s.configured&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-zinc-500 font-mono",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:y?"text":"password",value:b,onChange:o=>C(o.target.value),className:"pr-10 field",placeholder:"Stored separately in auth.json"}),e.jsx("button",{type:"button",onClick:()=>B(!y),className:"absolute right-3 top-1/2 -translate-y-1/2",children:y?e.jsx(Q,{className:"w-4 h-4"}):e.jsx(W,{className:"w-4 h-4"})})]})]}),s&&!s.configured&&!s.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:"This provider requires OAuth or ambient credentials. Configure it externally before selecting the model."}),e.jsx("button",{type:"button",disabled:!s||!i||!s.configured&&(!s.supportsApiKey||b.trim().length===0),onClick:A,className:"px-4 py-2 font-mono text-sm font-semibold text-white bg-green-600 rounded-md disabled:opacity-50",children:"Save Model"})]})]})})}function $(a){return e.jsxs("div",{className:"flex relative flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-zinc-500 font-mono",children:a.label}),e.jsxs("button",{type:"button",onClick:()=>a.setOpen(!a.open),className:"flex justify-between field",children:[a.value,e.jsx(L,{className:"w-4 h-4"})]}),a.open&&e.jsx("div",{className:"overflow-y-auto absolute right-0 left-0 top-full z-50 max-h-64 bg-white rounded-md border dark:bg-zinc-900",children:a.options.map(r=>e.jsx("button",{type:"button",onClick:r.select,className:u("w-full text-left px-3 py-2 text-sm font-mono",r.selected&&"bg-zinc-100 dark:bg-zinc-800"),children:r.label},r.id))})]})}function Y(a){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-zinc-500 font-mono",children:a.label}),e.jsx("input",{value:a.value,onChange:r=>a.onChange(r.target.value),placeholder:a.placeholder,className:"field"})]})}function Z(a){const[r,j]=l.useState(""),[f,v]=l.useState(""),[h,n]=l.useState("");l.useEffect(()=>{var c,i,m;j(((c=a.model)==null?void 0:c.displayName)??""),v(((m=(i=a.model)==null?void 0:i.overrides)==null?void 0:m.baseUrl)??"")},[a.model]);const s=async()=>{if(a.model){if(h.trim()&&!(await fetch(`/providers/${a.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:h.trim()})})).ok)throw new Error("Failed to update provider credential");a.onSave(a.model.id,{displayName:r||void 0,overrides:f?{...a.model.overrides,baseUrl:f}:void 0}),a.onOpenChange(!1)}};return e.jsx(O,{open:a.open,onOpenChange:a.onOpenChange,children:e.jsxs(M,{className:"sm:max-w-[480px] p-6 bg-white dark:bg-[#09090b]","aria-describedby":void 0,children:[e.jsx(T,{className:"sr-only",children:"Edit Model"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("h2",{className:"font-semibold font-mono",children:"Edit Model Overrides"}),e.jsx("button",{type:"button",onClick:()=>a.onOpenChange(!1),children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsx("label",{className:"font-mono text-sm",children:"Display name"}),e.jsx("input",{value:r,onChange:c=>j(c.target.value),className:"field"}),e.jsx("label",{className:"font-mono text-sm",children:"Replace provider API key"}),e.jsx("input",{type:"password",value:h,onChange:c=>n(c.target.value),placeholder:"Leave empty to keep current credential",className:"field"}),e.jsx("label",{className:"font-mono text-sm",children:"Base URL override"}),e.jsx("input",{value:f,onChange:c=>v(c.target.value),placeholder:"Leave empty to use default endpoint",className:"field"}),e.jsx("button",{type:"button",onClick:()=>void s(),className:"px-4 py-2 rounded-md text-white bg-green-600",children:"Save"})]})})}const ee={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}};function ie(){var z;const{isSettingsOpen:a,toggleSettings:r,isSidebarOpen:j,setSidebarOpen:f}=_(),{configuredModels:v,loadModels:h}=H(),n=J(),[s,c]=l.useState("general"),[i,m]=l.useState(!1),[k,w]=l.useState(null),[b,C]=l.useState(null),[F,E]=l.useState(""),[S,N]=l.useState("all"),y=[{value:"general",label:"General"},{value:"models",label:"Models"},{value:"shortcuts",label:"Shortcuts"}],A=l.useMemo(()=>[{action:"Open command palette",combo:["Ctrl","K"],scope:"Global"},{action:"New chat",combo:["Ctrl","N"],scope:"Chat"},{action:"Focus input",combo:["Ctrl","L"],scope:"Chat"},{action:"Toggle sidebar",combo:["Ctrl","B"],scope:"Layout"},{action:"Search history",combo:["Ctrl","H"],scope:"History"}],[]).filter(t=>{const d=t.action.toLowerCase().includes(F.toLowerCase()),x=S==="all"||t.scope.toLowerCase()===S;return d&&x}),o=v.reduce((t,d)=>{const x=d.provider||"unknown";return t[x]||(t[x]=[]),t[x].push(d),t},{});l.useEffect(()=>{a&&(h(),n.loadSettings())},[a,h,n.loadSettings]);const R=async t=>{try{if(!(await fetch("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,displayName:t.displayName,model:t.model,apiKey:t.apiKey})})).ok)throw new Error("Failed to save model");await h()}catch(d){console.error("Failed to save model:",d)}},U=async t=>{try{if(!(await fetch(`/models/${t}`,{method:"DELETE"})).ok)throw new Error("Failed to delete model");await h()}catch(d){console.error("Failed to delete model:",d)}},G=async(t,d)=>{try{if(!(await fetch(`/models/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).ok)throw new Error("Failed to update model");await h()}catch(x){console.error("Failed to update model:",x)}},I=t=>{w(k===t?null:t)};return e.jsxs(e.Fragment,{children:[e.jsx(O,{open:a,onOpenChange:r,children:e.jsxs(M,{className:"sm:max-w-[800px] h-[600px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Settings"}),e.jsxs("div",{className:"flex h-full",children:[e.jsx("div",{className:"w-[200px] h-full bg-[#F3F4F6] dark:bg-[#18181b] p-6 flex flex-col gap-2",children:y.map(t=>e.jsx("button",{onClick:()=>c(t.value),className:u("w-full text-left px-3 py-2 rounded-md text-sm font-mono transition-colors",s===t.value?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] font-medium":"text-[#6B7280] hover:text-[#111827] hover:bg-[#E5E7EB]/60 dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a]/50"),children:t.label},t.value))}),e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-6 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:s==="general"?"Settings":(z=y.find(t=>t.value===s))==null?void 0:z.label}),e.jsx("button",{onClick:r,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(P,{className:"h-4 w-4"})})]}),s==="models"&&e.jsxs("div",{className:"flex flex-col gap-6 flex-1 min-h-0 overflow-hidden",children:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:"Configure API keys and model settings for different providers."}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[Object.entries(o).map(([t,d])=>{const x=ee[t]||{bg:"#71717a",label:"?"},K=k===t;return e.jsxs("div",{className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>I(t),className:"w-full p-4 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded flex items-center justify-center text-white text-xs font-bold",style:{backgroundColor:x.bg},children:x.label}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-left",children:[e.jsx("span",{className:"text-sm font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono capitalize",children:t.replace(/-/g," ")}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono",children:[d.length," model",d.length>1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:u("text-xs font-mono","text-[#16A34A]"),children:"● Connected"}),e.jsx(L,{className:u("h-4 w-4 text-[#9CA3AF] dark:text-[#71717a] transition-transform",K&&"rotate-180")})]})]}),K&&e.jsx("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:d.map(p=>{var D;return e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate",children:p.displayName||p.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[p.displayName&&`${p.model} · `,((D=p.overrides)==null?void 0:D.baseUrl)||"default endpoint"]})]}),e.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>C(p),className:"p-1.5 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(q,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>U(p.id),className:"p-1.5 text-[#9CA3AF] hover:text-red-500 hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-red-400 dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(V,{className:"h-3.5 w-3.5"})})]})]},p.id)})})]},t)}),Object.keys(o).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No models configured yet"})]})}),e.jsx("button",{onClick:()=>m(!0),className:"w-full py-3 rounded-md text-[#6B7280] dark:text-[#a1a1aa] text-[13px] font-mono hover:bg-[#F3F4F6] dark:bg-[#18181b] transition-colors shrink-0",children:"+ Add New Model"})]}),s==="general"&&e.jsxs("div",{className:"flex flex-col gap-6 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"General"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Response Language"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"AI will respond in this language"})]}),e.jsxs("select",{value:n.language,onChange:t=>n.updateSettings({language:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"en-US",children:"English (US)"}),e.jsx("option",{value:"zh-CN",children:"简体中文"}),e.jsx("option",{value:"zh-TW",children:"繁體中文"}),e.jsx("option",{value:"ja-JP",children:"日本語"}),e.jsx("option",{value:"ko-KR",children:"한국어"}),e.jsx("option",{value:"es-ES",children:"Español"}),e.jsx("option",{value:"fr-FR",children:"Français"}),e.jsx("option",{value:"de-DE",children:"Deutsch"}),e.jsx("option",{value:"pt-BR",children:"Português (BR)"}),e.jsx("option",{value:"ru-RU",children:"Русский"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Auto-save sessions"}),e.jsx(g,{enabled:n.autoSaveSessions,onChange:t=>n.updateSettings({autoSaveSessions:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Appearance"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Theme Preference"}),e.jsx("div",{className:"flex items-center gap-2 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md p-1",children:["dark","light","system"].map(t=>e.jsx("button",{onClick:()=>n.updateSettings({uiTheme:t}),className:u("px-3 py-1 rounded text-[12px] font-mono transition-colors",n.uiTheme===t?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t==="dark"?"Dark":t==="light"?"Light":"System"},t))})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Compact sidebar"}),e.jsx(g,{enabled:!j,onChange:t=>f(!t)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Code theme"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"Syntax highlighting colors"})]}),e.jsxs("select",{value:n.theme,onChange:t=>n.updateSettings({theme:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"dracula",children:"Dracula"}),e.jsx("option",{value:"monokai",children:"Monokai"}),e.jsx("option",{value:"nord",children:"Nord"}),e.jsx("option",{value:"tokyo-night",children:"Tokyo Night"}),e.jsx("option",{value:"one-dark",children:"One Dark"}),e.jsx("option",{value:"catppuccin",children:"Catppuccin"}),e.jsx("option",{value:"gruvbox",children:"Gruvbox"}),e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"solarized-light",children:"Solarized Light"}),e.jsx("option",{value:"solarized-dark",children:"Solarized Dark"}),e.jsx("option",{value:"ayu-dark",children:"Ayu Dark"}),e.jsx("option",{value:"rose-pine",children:"Rose Pine"}),e.jsx("option",{value:"kanagawa",children:"Kanagawa"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Notifications"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Build finished"}),e.jsx(g,{enabled:n.notifyBuild,onChange:t=>n.updateSettings({notifyBuild:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Errors only"}),e.jsx(g,{enabled:n.notifyErrors,onChange:t=>n.updateSettings({notifyErrors:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"System sounds"}),e.jsx(g,{enabled:n.notifySounds,onChange:t=>n.updateSettings({notifySounds:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Privacy"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Telemetry"}),e.jsx(g,{enabled:n.privacyTelemetry,onChange:t=>n.updateSettings({privacyTelemetry:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Crash reports"}),e.jsx(g,{enabled:n.privacyCrash,onChange:t=>n.updateSettings({privacyCrash:t})})]})]})]}),s==="shortcuts"&&e.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("input",{value:F,onChange:t=>E(t.target.value),placeholder:"Search actions...",className:"flex-1 h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono"}),e.jsxs("select",{value:S,onChange:t=>N(t.target.value),className:"h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono",children:[e.jsx("option",{value:"all",children:"All scopes"}),e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"chat",children:"Chat"}),e.jsx("option",{value:"layout",children:"Layout"}),e.jsx("option",{value:"history",children:"History"})]}),e.jsx("button",{onClick:()=>{E(""),N("all")},className:"h-9 px-3 rounded-md bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:"Reset"})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 bg-white dark:bg-[#0C0C0C] text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono font-semibold",children:[e.jsx("span",{children:"Action"}),e.jsx("span",{children:"Shortcut"}),e.jsx("span",{children:"Scope"})]}),A.map((t,d)=>e.jsxs("div",{className:u("grid grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",d%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:t.action}),e.jsx("div",{className:"flex items-center gap-1",children:t.combo.map(x=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:x},x))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:t.scope})]},`${t.action}-${t.scope}`)),A.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:"No shortcuts found."})]})]})]})]})]})}),e.jsx(X,{open:i,onOpenChange:m,onSave:R}),e.jsx(Z,{open:!!b,onOpenChange:t=>!t&&C(null),model:b,onSave:G})]})}function g({enabled:a,onChange:r}){return e.jsx("button",{onClick:()=>r(!a),className:u("w-10 h-5 rounded-full px-0.5 flex items-center transition-colors",a?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:u("h-4 w-4 rounded-full transition-transform",a?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{ie as SettingsModal};
1
+ import{r as l,j as e}from"./vendor-react-FPIC4Czm.js";import{D as O,a as M,b as T,c as u,u as _,d as H}from"./index-DIWzaS2_.js";import{u as J}from"./SettingsStore-C8YBWQPS.js";import{X as P,E as Q,D as W,b as L,f as q,i as V}from"./vendor-icons-DBM55KTG.js";import"./vendor-markdown-b9iCqZWK.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-DyP_DOwV.js";function X({open:a,onOpenChange:r,onSave:j}){const[f,v]=l.useState([]),[h,n]=l.useState([]),[s,c]=l.useState(),[i,m]=l.useState(),[k,w]=l.useState(""),[b,C]=l.useState(""),[F,E]=l.useState(!1),[S,N]=l.useState(!1),[y,B]=l.useState(!1);l.useEffect(()=>{a&&(n([]),c(void 0),m(void 0),w(""),C(""),E(!1),N(!1),B(!1),fetch("/providers").then(o=>o.json()).then(v))},[a]),l.useEffect(()=>{s&&fetch(`/providers/${s.id}/models`).then(o=>o.json()).then(n)},[s]);const A=()=>{!s||!i||!s.configured&&!b||(j({provider:s.id,model:i.id,displayName:k||i.name,apiKey:b||void 0}),r(!1))};return e.jsx(O,{open:a,onOpenChange:r,children:e.jsxs(M,{className:"sm:max-w-[480px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl [&>button]:hidden","aria-describedby":void 0,children:[e.jsx(T,{className:"sr-only",children:"Add Model"}),e.jsxs("div",{className:"flex flex-col gap-6 p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"font-mono text-base font-semibold",children:"Add Model"}),e.jsx("button",{type:"button",onClick:()=>r(!1),children:e.jsx(P,{className:"w-4 h-4"})})]}),e.jsx($,{label:"Provider",value:(s==null?void 0:s.name)??"Select provider",open:F,setOpen:E,options:f.map(o=>({id:o.id,label:`${o.name} (${o.modelCount})${o.configured?" · configured":""}`,selected:(s==null?void 0:s.id)===o.id,select:()=>{c(o),m(void 0),E(!1)}}))}),e.jsx($,{label:"Model",value:(i==null?void 0:i.name)??"Select model",open:S,setOpen:N,options:h.map(o=>({id:o.id,label:`${o.name} · ${Math.round(o.contextWindow/1e3)}K${o.reasoning?" · reasoning":""}${o.input.includes("image")?" · vision":""}`,selected:(i==null?void 0:i.id)===o.id,select:()=>{m(o),w(o.name),N(!1)}}))}),e.jsx(Y,{label:"Display name",value:k,onChange:w,placeholder:(i==null?void 0:i.name)??"Optional alias"}),(s==null?void 0:s.supportsApiKey)&&!s.configured&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-zinc-500 font-mono",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:y?"text":"password",value:b,onChange:o=>C(o.target.value),className:"pr-10 field",placeholder:"Stored separately in auth.json"}),e.jsx("button",{type:"button",onClick:()=>B(!y),className:"absolute right-3 top-1/2 -translate-y-1/2",children:y?e.jsx(Q,{className:"w-4 h-4"}):e.jsx(W,{className:"w-4 h-4"})})]})]}),s&&!s.configured&&!s.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:"This provider requires OAuth or ambient credentials. Configure it externally before selecting the model."}),e.jsx("button",{type:"button",disabled:!s||!i||!s.configured&&(!s.supportsApiKey||b.trim().length===0),onClick:A,className:"px-4 py-2 font-mono text-sm font-semibold text-white bg-green-600 rounded-md disabled:opacity-50",children:"Save Model"})]})]})})}function $(a){return e.jsxs("div",{className:"flex relative flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-zinc-500 font-mono",children:a.label}),e.jsxs("button",{type:"button",onClick:()=>a.setOpen(!a.open),className:"flex justify-between field",children:[a.value,e.jsx(L,{className:"w-4 h-4"})]}),a.open&&e.jsx("div",{className:"overflow-y-auto absolute right-0 left-0 top-full z-50 max-h-64 bg-white rounded-md border dark:bg-zinc-900",children:a.options.map(r=>e.jsx("button",{type:"button",onClick:r.select,className:u("w-full text-left px-3 py-2 text-sm font-mono",r.selected&&"bg-zinc-100 dark:bg-zinc-800"),children:r.label},r.id))})]})}function Y(a){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-zinc-500 font-mono",children:a.label}),e.jsx("input",{value:a.value,onChange:r=>a.onChange(r.target.value),placeholder:a.placeholder,className:"field"})]})}function Z(a){const[r,j]=l.useState(""),[f,v]=l.useState(""),[h,n]=l.useState("");l.useEffect(()=>{var c,i,m;j(((c=a.model)==null?void 0:c.displayName)??""),v(((m=(i=a.model)==null?void 0:i.overrides)==null?void 0:m.baseUrl)??"")},[a.model]);const s=async()=>{if(a.model){if(h.trim()&&!(await fetch(`/providers/${a.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:h.trim()})})).ok)throw new Error("Failed to update provider credential");a.onSave(a.model.id,{displayName:r||void 0,overrides:f?{...a.model.overrides,baseUrl:f}:void 0}),a.onOpenChange(!1)}};return e.jsx(O,{open:a.open,onOpenChange:a.onOpenChange,children:e.jsxs(M,{className:"sm:max-w-[480px] p-6 bg-white dark:bg-[#09090b]","aria-describedby":void 0,children:[e.jsx(T,{className:"sr-only",children:"Edit Model"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("h2",{className:"font-semibold font-mono",children:"Edit Model Overrides"}),e.jsx("button",{type:"button",onClick:()=>a.onOpenChange(!1),children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsx("label",{className:"font-mono text-sm",children:"Display name"}),e.jsx("input",{value:r,onChange:c=>j(c.target.value),className:"field"}),e.jsx("label",{className:"font-mono text-sm",children:"Replace provider API key"}),e.jsx("input",{type:"password",value:h,onChange:c=>n(c.target.value),placeholder:"Leave empty to keep current credential",className:"field"}),e.jsx("label",{className:"font-mono text-sm",children:"Base URL override"}),e.jsx("input",{value:f,onChange:c=>v(c.target.value),placeholder:"Leave empty to use default endpoint",className:"field"}),e.jsx("button",{type:"button",onClick:()=>void s(),className:"px-4 py-2 rounded-md text-white bg-green-600",children:"Save"})]})})}const ee={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}};function ie(){var z;const{isSettingsOpen:a,toggleSettings:r,isSidebarOpen:j,setSidebarOpen:f}=_(),{configuredModels:v,loadModels:h}=H(),n=J(),[s,c]=l.useState("general"),[i,m]=l.useState(!1),[k,w]=l.useState(null),[b,C]=l.useState(null),[F,E]=l.useState(""),[S,N]=l.useState("all"),y=[{value:"general",label:"General"},{value:"models",label:"Models"},{value:"shortcuts",label:"Shortcuts"}],A=l.useMemo(()=>[{action:"Open command palette",combo:["Ctrl","K"],scope:"Global"},{action:"New chat",combo:["Ctrl","N"],scope:"Chat"},{action:"Focus input",combo:["Ctrl","L"],scope:"Chat"},{action:"Toggle sidebar",combo:["Ctrl","B"],scope:"Layout"},{action:"Search history",combo:["Ctrl","H"],scope:"History"}],[]).filter(t=>{const d=t.action.toLowerCase().includes(F.toLowerCase()),x=S==="all"||t.scope.toLowerCase()===S;return d&&x}),o=v.reduce((t,d)=>{const x=d.provider||"unknown";return t[x]||(t[x]=[]),t[x].push(d),t},{});l.useEffect(()=>{a&&(h(),n.loadSettings())},[a,h,n.loadSettings]);const R=async t=>{try{if(!(await fetch("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,displayName:t.displayName,model:t.model,apiKey:t.apiKey})})).ok)throw new Error("Failed to save model");await h()}catch(d){console.error("Failed to save model:",d)}},U=async t=>{try{if(!(await fetch(`/models/${t}`,{method:"DELETE"})).ok)throw new Error("Failed to delete model");await h()}catch(d){console.error("Failed to delete model:",d)}},G=async(t,d)=>{try{if(!(await fetch(`/models/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).ok)throw new Error("Failed to update model");await h()}catch(x){console.error("Failed to update model:",x)}},I=t=>{w(k===t?null:t)};return e.jsxs(e.Fragment,{children:[e.jsx(O,{open:a,onOpenChange:r,children:e.jsxs(M,{className:"sm:max-w-[800px] h-[600px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Settings"}),e.jsxs("div",{className:"flex h-full",children:[e.jsx("div",{className:"w-[200px] h-full bg-[#F3F4F6] dark:bg-[#18181b] p-6 flex flex-col gap-2",children:y.map(t=>e.jsx("button",{onClick:()=>c(t.value),className:u("w-full text-left px-3 py-2 rounded-md text-sm font-mono transition-colors",s===t.value?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] font-medium":"text-[#6B7280] hover:text-[#111827] hover:bg-[#E5E7EB]/60 dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a]/50"),children:t.label},t.value))}),e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-6 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:s==="general"?"Settings":(z=y.find(t=>t.value===s))==null?void 0:z.label}),e.jsx("button",{onClick:r,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(P,{className:"h-4 w-4"})})]}),s==="models"&&e.jsxs("div",{className:"flex flex-col gap-6 flex-1 min-h-0 overflow-hidden",children:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:"Configure API keys and model settings for different providers."}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[Object.entries(o).map(([t,d])=>{const x=ee[t]||{bg:"#71717a",label:"?"},K=k===t;return e.jsxs("div",{className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>I(t),className:"w-full p-4 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded flex items-center justify-center text-white text-xs font-bold",style:{backgroundColor:x.bg},children:x.label}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-left",children:[e.jsx("span",{className:"text-sm font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono capitalize",children:t.replace(/-/g," ")}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono",children:[d.length," model",d.length>1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:u("text-xs font-mono","text-[#16A34A]"),children:"● Connected"}),e.jsx(L,{className:u("h-4 w-4 text-[#9CA3AF] dark:text-[#71717a] transition-transform",K&&"rotate-180")})]})]}),K&&e.jsx("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:d.map(p=>{var D;return e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate",children:p.displayName||p.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[p.displayName&&`${p.model} · `,((D=p.overrides)==null?void 0:D.baseUrl)||"default endpoint"]})]}),e.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>C(p),className:"p-1.5 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(q,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>U(p.id),className:"p-1.5 text-[#9CA3AF] hover:text-red-500 hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-red-400 dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(V,{className:"h-3.5 w-3.5"})})]})]},p.id)})})]},t)}),Object.keys(o).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No models configured yet"})]})}),e.jsx("button",{onClick:()=>m(!0),className:"w-full py-3 rounded-md text-[#6B7280] dark:text-[#a1a1aa] text-[13px] font-mono hover:bg-[#F3F4F6] dark:bg-[#18181b] transition-colors shrink-0",children:"+ Add New Model"})]}),s==="general"&&e.jsxs("div",{className:"flex flex-col gap-6 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"General"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Response Language"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"AI will respond in this language"})]}),e.jsxs("select",{value:n.language,onChange:t=>n.updateSettings({language:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"en-US",children:"English (US)"}),e.jsx("option",{value:"zh-CN",children:"简体中文"}),e.jsx("option",{value:"zh-TW",children:"繁體中文"}),e.jsx("option",{value:"ja-JP",children:"日本語"}),e.jsx("option",{value:"ko-KR",children:"한국어"}),e.jsx("option",{value:"es-ES",children:"Español"}),e.jsx("option",{value:"fr-FR",children:"Français"}),e.jsx("option",{value:"de-DE",children:"Deutsch"}),e.jsx("option",{value:"pt-BR",children:"Português (BR)"}),e.jsx("option",{value:"ru-RU",children:"Русский"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Auto-save sessions"}),e.jsx(g,{enabled:n.autoSaveSessions,onChange:t=>n.updateSettings({autoSaveSessions:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Appearance"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Theme Preference"}),e.jsx("div",{className:"flex items-center gap-2 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md p-1",children:["dark","light","system"].map(t=>e.jsx("button",{onClick:()=>n.updateSettings({uiTheme:t}),className:u("px-3 py-1 rounded text-[12px] font-mono transition-colors",n.uiTheme===t?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t==="dark"?"Dark":t==="light"?"Light":"System"},t))})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Compact sidebar"}),e.jsx(g,{enabled:!j,onChange:t=>f(!t)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Code theme"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"Syntax highlighting colors"})]}),e.jsxs("select",{value:n.theme,onChange:t=>n.updateSettings({theme:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"dracula",children:"Dracula"}),e.jsx("option",{value:"monokai",children:"Monokai"}),e.jsx("option",{value:"nord",children:"Nord"}),e.jsx("option",{value:"tokyo-night",children:"Tokyo Night"}),e.jsx("option",{value:"one-dark",children:"One Dark"}),e.jsx("option",{value:"catppuccin",children:"Catppuccin"}),e.jsx("option",{value:"gruvbox",children:"Gruvbox"}),e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"solarized-light",children:"Solarized Light"}),e.jsx("option",{value:"solarized-dark",children:"Solarized Dark"}),e.jsx("option",{value:"ayu-dark",children:"Ayu Dark"}),e.jsx("option",{value:"rose-pine",children:"Rose Pine"}),e.jsx("option",{value:"kanagawa",children:"Kanagawa"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Notifications"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Build finished"}),e.jsx(g,{enabled:n.notifyBuild,onChange:t=>n.updateSettings({notifyBuild:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Errors only"}),e.jsx(g,{enabled:n.notifyErrors,onChange:t=>n.updateSettings({notifyErrors:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"System sounds"}),e.jsx(g,{enabled:n.notifySounds,onChange:t=>n.updateSettings({notifySounds:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Privacy"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Telemetry"}),e.jsx(g,{enabled:n.privacyTelemetry,onChange:t=>n.updateSettings({privacyTelemetry:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Crash reports"}),e.jsx(g,{enabled:n.privacyCrash,onChange:t=>n.updateSettings({privacyCrash:t})})]})]})]}),s==="shortcuts"&&e.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("input",{value:F,onChange:t=>E(t.target.value),placeholder:"Search actions...",className:"flex-1 h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono"}),e.jsxs("select",{value:S,onChange:t=>N(t.target.value),className:"h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono",children:[e.jsx("option",{value:"all",children:"All scopes"}),e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"chat",children:"Chat"}),e.jsx("option",{value:"layout",children:"Layout"}),e.jsx("option",{value:"history",children:"History"})]}),e.jsx("button",{onClick:()=>{E(""),N("all")},className:"h-9 px-3 rounded-md bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:"Reset"})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 bg-white dark:bg-[#0C0C0C] text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono font-semibold",children:[e.jsx("span",{children:"Action"}),e.jsx("span",{children:"Shortcut"}),e.jsx("span",{children:"Scope"})]}),A.map((t,d)=>e.jsxs("div",{className:u("grid grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",d%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:t.action}),e.jsx("div",{className:"flex items-center gap-1",children:t.combo.map(x=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:x},x))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:t.scope})]},`${t.action}-${t.scope}`)),A.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:"No shortcuts found."})]})]})]})]})]})}),e.jsx(X,{open:i,onOpenChange:m,onSave:R}),e.jsx(Z,{open:!!b,onOpenChange:t=>!t&&C(null),model:b,onSave:G})]})}function g({enabled:a,onChange:r}){return e.jsx("button",{onClick:()=>r(!a),className:u("w-10 h-5 rounded-full px-0.5 flex items-center transition-colors",a?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:u("h-4 w-4 rounded-full transition-transform",a?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{ie as SettingsModal};
@@ -1 +1 @@
1
- import{h as n}from"./index-B-BRpW1c.js";const c=s=>s==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches:s==="dark",i=s=>{const t=document.documentElement;if(t.classList.remove("light","dark"),s==="system"){const r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";t.classList.add(r)}else t.classList.add(s)},o={language:"zh-CN",theme:"dracula",uiTheme:"system",autoSaveSessions:!0,notifyBuild:!0,notifyErrors:!1,notifySounds:!1,privacyTelemetry:!1,privacyCrash:!0},l=n((s,t)=>({...o,isLoading:!1,error:null,loadSettings:async()=>{s({isLoading:!0,error:null});try{const r=await fetch("/configs");if(!r.ok)throw new Error("Failed to load settings");const e=await r.json(),a=e.uiTheme??o.uiTheme;s({language:e.language??o.language,theme:e.theme??o.theme,uiTheme:a,autoSaveSessions:e.autoSaveSessions??o.autoSaveSessions,notifyBuild:e.notifyBuild??o.notifyBuild,notifyErrors:e.notifyErrors??o.notifyErrors,notifySounds:e.notifySounds??o.notifySounds,privacyTelemetry:e.privacyTelemetry??o.privacyTelemetry,privacyCrash:e.privacyCrash??o.privacyCrash,isLoading:!1}),i(a)}catch(r){s({error:r.message,isLoading:!1})}},updateSettings:async r=>{const e=t();s({...r,error:null}),r.uiTheme&&i(r.uiTheme);try{if(!(await fetch("/configs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:r,options:{scope:"global"}})})).ok)throw new Error("Failed to save settings")}catch(a){s({language:e.language,theme:e.theme,uiTheme:e.uiTheme,autoSaveSessions:e.autoSaveSessions,notifyBuild:e.notifyBuild,notifyErrors:e.notifyErrors,notifySounds:e.notifySounds,privacyTelemetry:e.privacyTelemetry,privacyCrash:e.privacyCrash,error:a.message}),r.uiTheme&&i(e.uiTheme)}}}));i(o.uiTheme);const u=()=>l(s=>c(s.uiTheme));export{u as a,l as u};
1
+ import{h as n}from"./index-DIWzaS2_.js";const c=s=>s==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches:s==="dark",i=s=>{const t=document.documentElement;if(t.classList.remove("light","dark"),s==="system"){const r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";t.classList.add(r)}else t.classList.add(s)},o={language:"zh-CN",theme:"dracula",uiTheme:"system",autoSaveSessions:!0,notifyBuild:!0,notifyErrors:!1,notifySounds:!1,privacyTelemetry:!1,privacyCrash:!0},l=n((s,t)=>({...o,isLoading:!1,error:null,loadSettings:async()=>{s({isLoading:!0,error:null});try{const r=await fetch("/configs");if(!r.ok)throw new Error("Failed to load settings");const e=await r.json(),a=e.uiTheme??o.uiTheme;s({language:e.language??o.language,theme:e.theme??o.theme,uiTheme:a,autoSaveSessions:e.autoSaveSessions??o.autoSaveSessions,notifyBuild:e.notifyBuild??o.notifyBuild,notifyErrors:e.notifyErrors??o.notifyErrors,notifySounds:e.notifySounds??o.notifySounds,privacyTelemetry:e.privacyTelemetry??o.privacyTelemetry,privacyCrash:e.privacyCrash??o.privacyCrash,isLoading:!1}),i(a)}catch(r){s({error:r.message,isLoading:!1})}},updateSettings:async r=>{const e=t();s({...r,error:null}),r.uiTheme&&i(r.uiTheme);try{if(!(await fetch("/configs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:r,options:{scope:"global"}})})).ok)throw new Error("Failed to save settings")}catch(a){s({language:e.language,theme:e.theme,uiTheme:e.uiTheme,autoSaveSessions:e.autoSaveSessions,notifyBuild:e.notifyBuild,notifyErrors:e.notifyErrors,notifySounds:e.notifySounds,privacyTelemetry:e.privacyTelemetry,privacyCrash:e.privacyCrash,error:a.message}),r.uiTheme&&i(e.uiTheme)}}}));i(o.uiTheme);const u=()=>l(s=>c(s.uiTheme));export{u as a,l as u};
@@ -1 +1 @@
1
- import{r as o,j as e}from"./vendor-react-FPIC4Czm.js";import{u as q,D as I,a as D,b as T,c as h}from"./index-B-BRpW1c.js";import{e as v}from"./useRequest-B4kP-cmG.js";import{q as M,K as z,X as L,i as H}from"./vendor-icons-DBM55KTG.js";import"./vendor-markdown-b9iCqZWK.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-DyP_DOwV.js";const J=async()=>{const a=await fetch("/skills");if(!a.ok)throw new Error("Failed to fetch skills");return a.json()},$=async()=>{const a=await fetch("/skills/catalog");if(!a.ok)throw new Error("Failed to fetch catalog");return a.json()};function te(){const{isSkillsOpen:a,toggleSkills:r}=q(),[d,c]=o.useState(null),[f,n]=o.useState(""),[p,u]=o.useState(!1),[C,i]=o.useState(!1),[F,x]=o.useState("confirm"),[w,m]=o.useState(null),[k,j]=o.useState(null),{data:b=[],loading:E,run:g}=v(J,{refreshDeps:[a],ready:a,onSuccess:t=>{t.length>0&&!d&&c(t[0].id)}}),{data:s=[]}=v($,{refreshDeps:[a],ready:a}),{runAsync:y}=v(async t=>{await fetch(`/skills/${encodeURIComponent(t)}`,{method:"DELETE"})},{manual:!0,onSuccess:g}),{runAsync:A,loading:S}=v(async(t,N)=>{if(!(await fetch(`/skills/${encodeURIComponent(t)}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:N})})).ok)throw new Error("Failed to toggle skill")},{manual:!0,onSuccess:g}),O=b.filter(t=>t.name.toLowerCase().includes(f.toLowerCase())),l=o.useMemo(()=>b.find(t=>t.id===d)??b[0],[b,d]),R=()=>{u(!0)},P=t=>{j(t),m(null),x("confirm"),i(!0)},U=async()=>{if(k){x("installing"),m(null);try{const t=await fetch("/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}),N=await t.json().catch(()=>({}));if(!t.ok||N.success===!1)throw new Error(N.error||"Failed to install skill");await g(),i(!1),u(!1)}catch(t){m(t instanceof Error?t.message:"Failed to install skill"),x("failed")}}};return e.jsxs(o.Fragment,{children:[e.jsx(I,{open:a,onOpenChange:r,children:e.jsxs(D,{className:"sm:max-w-[820px] h-[620px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Skills"}),e.jsx("div",{className:"flex h-full min-h-0",children:e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-5 min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:R,className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(M,{className:"h-3.5 w-3.5"}),"Install skill"]}),e.jsx("button",{onClick:g,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:E,children:e.jsx(z,{className:h("h-4 w-4",E&&"animate-spin")})}),e.jsx("button",{onClick:r,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex gap-5 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-[220px] flex flex-col gap-3 min-h-0 overflow-hidden",children:[e.jsx("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Installed"}),e.jsx("input",{value:f,onChange:t=>n(t.target.value),placeholder:"Search skills...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[O.length===0&&!E&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills installed"}),O.map(t=>e.jsxs("button",{onClick:()=>c(t.id),className:h("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors",t.id===d?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:h("text-[11px] font-mono font-semibold",t.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:t.enabled?"Enabled":"Disabled"})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.description||"No description"})]},t.id))]})]}),l?e.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-y-auto pr-2 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:l.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",l.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:l.description||"No description available"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>A(l.name,!l.enabled),disabled:S,className:h("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",l.enabled?"bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]":"bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]",S&&"opacity-60 cursor-not-allowed"),children:S?"Saving...":l.enabled?"Disable":"Enable"}),e.jsx("button",{disabled:!0,title:"Editing not supported yet",className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold opacity-60 cursor-not-allowed",children:"Edit"}),e.jsxs("button",{onClick:()=>y(l.name),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1",children:[e.jsx(H,{className:"h-3 w-3"}),"Uninstall"]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Provider"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:l.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Location"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:l.location})]})]}),l.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Capabilities"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.capabilities.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]}),l.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Allowed Tools (",l.allowedTools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.allowedTools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a skill to view details"})})]})]})})]})}),e.jsx(G,{open:p,catalog:s,installed:b.map(t=>t.name),onOpenChange:u,onInstall:P}),e.jsx(K,{open:C,status:F,error:w,onCancel:()=>i(!1),onConfirm:U,onRetry:()=>x("confirm")})]})}function B({active:a,children:r,onClick:d}){return e.jsx("button",{onClick:d,className:h("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",a?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:r})}function G({open:a,onOpenChange:r,onInstall:d,catalog:c,installed:f}){const[n,p]=o.useState("catalog"),[u,C]=o.useState(""),[i,F]=o.useState(null),[x,w]=o.useState(""),[m,k]=o.useState(""),j=c.filter(s=>s.name.toLowerCase().includes(u.toLowerCase())),b=()=>{if(n==="catalog"){if(!i)return;d({source:"catalog",name:i});return}if(n==="repo"){if(!x)return;d({source:"repo",url:x});return}m&&d({source:"local",path:m})},E=i?f.includes(i):!1,g=n==="catalog"&&(!i||E)||n==="repo"&&!x||n==="local"&&!m;return e.jsx(I,{open:a,onOpenChange:r,children:e.jsxs(D,{className:"sm:max-w-[540px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Install Skill"}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install Skill"}),e.jsx("button",{onClick:()=>r(!1),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(L,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(B,{active:n==="catalog",onClick:()=>p("catalog"),children:"Catalog"}),e.jsx(B,{active:n==="repo",onClick:()=>p("repo"),children:"Repo"}),e.jsx(B,{active:n==="local",onClick:()=>p("local"),children:"Local"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[n==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{value:u,onChange:s=>C(s.target.value),placeholder:"Search catalog...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsxs("div",{className:"flex flex-col gap-2 max-h-[240px] overflow-y-auto",children:[j.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills found"}),j.map(s=>{const y=f.includes(s.name),A=i===s.name;return e.jsxs("button",{onClick:()=>F(s.name),className:h("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",A?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:s.name}),e.jsx("span",{className:h("text-[10px] font-mono px-2 py-0.5 rounded",s.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:s.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:s.description}),e.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["by ",s.author]}),y&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:"Installed"})]},s.name)})]})]}),n==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"GitHub URL"}),e.jsx("input",{value:x,onChange:s=>w(s.target.value),placeholder:"https://github.com/org/skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsx("span",{className:"inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Private repo supported (backend support required)"})]}),n==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Local path"}),e.jsx("input",{value:m,onChange:s=>k(s.target.value),placeholder:"/Users/bytedance/skills/my-skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>r(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:b,disabled:g,className:h("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",g?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:"Install"})]})]})]})})}function K({open:a,status:r,error:d,onCancel:c,onConfirm:f,onRetry:n}){return e.jsx(I,{open:a,onOpenChange:p=>!p&&c(),children:e.jsxs(D,{className:"sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Install Status"}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[r==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Confirm Install"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Install selected skill?"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:f,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Install"})]})]}),r==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Installing"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Downloading and verifying…"}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:c,className:"self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Hide"})]}),r==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Install Failed"}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:d||"Installation failed."}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Check access and try again."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Close"}),e.jsx("button",{onClick:n,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Retry"})]})]})]})]})})}export{te as SkillsModal};
1
+ import{r as o,j as e}from"./vendor-react-FPIC4Czm.js";import{u as q,D as I,a as D,b as T,c as h}from"./index-DIWzaS2_.js";import{e as v}from"./useRequest-B4kP-cmG.js";import{q as M,K as z,X as L,i as H}from"./vendor-icons-DBM55KTG.js";import"./vendor-markdown-b9iCqZWK.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-DyP_DOwV.js";const J=async()=>{const a=await fetch("/skills");if(!a.ok)throw new Error("Failed to fetch skills");return a.json()},$=async()=>{const a=await fetch("/skills/catalog");if(!a.ok)throw new Error("Failed to fetch catalog");return a.json()};function te(){const{isSkillsOpen:a,toggleSkills:r}=q(),[d,c]=o.useState(null),[f,n]=o.useState(""),[p,u]=o.useState(!1),[C,i]=o.useState(!1),[F,x]=o.useState("confirm"),[w,m]=o.useState(null),[k,j]=o.useState(null),{data:b=[],loading:E,run:g}=v(J,{refreshDeps:[a],ready:a,onSuccess:t=>{t.length>0&&!d&&c(t[0].id)}}),{data:s=[]}=v($,{refreshDeps:[a],ready:a}),{runAsync:y}=v(async t=>{await fetch(`/skills/${encodeURIComponent(t)}`,{method:"DELETE"})},{manual:!0,onSuccess:g}),{runAsync:A,loading:S}=v(async(t,N)=>{if(!(await fetch(`/skills/${encodeURIComponent(t)}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:N})})).ok)throw new Error("Failed to toggle skill")},{manual:!0,onSuccess:g}),O=b.filter(t=>t.name.toLowerCase().includes(f.toLowerCase())),l=o.useMemo(()=>b.find(t=>t.id===d)??b[0],[b,d]),R=()=>{u(!0)},P=t=>{j(t),m(null),x("confirm"),i(!0)},U=async()=>{if(k){x("installing"),m(null);try{const t=await fetch("/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}),N=await t.json().catch(()=>({}));if(!t.ok||N.success===!1)throw new Error(N.error||"Failed to install skill");await g(),i(!1),u(!1)}catch(t){m(t instanceof Error?t.message:"Failed to install skill"),x("failed")}}};return e.jsxs(o.Fragment,{children:[e.jsx(I,{open:a,onOpenChange:r,children:e.jsxs(D,{className:"sm:max-w-[820px] h-[620px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Skills"}),e.jsx("div",{className:"flex h-full min-h-0",children:e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-5 min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:R,className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(M,{className:"h-3.5 w-3.5"}),"Install skill"]}),e.jsx("button",{onClick:g,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:E,children:e.jsx(z,{className:h("h-4 w-4",E&&"animate-spin")})}),e.jsx("button",{onClick:r,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex gap-5 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-[220px] flex flex-col gap-3 min-h-0 overflow-hidden",children:[e.jsx("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Installed"}),e.jsx("input",{value:f,onChange:t=>n(t.target.value),placeholder:"Search skills...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[O.length===0&&!E&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills installed"}),O.map(t=>e.jsxs("button",{onClick:()=>c(t.id),className:h("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors",t.id===d?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:h("text-[11px] font-mono font-semibold",t.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:t.enabled?"Enabled":"Disabled"})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.description||"No description"})]},t.id))]})]}),l?e.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-y-auto pr-2 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:l.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",l.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:l.description||"No description available"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>A(l.name,!l.enabled),disabled:S,className:h("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",l.enabled?"bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]":"bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]",S&&"opacity-60 cursor-not-allowed"),children:S?"Saving...":l.enabled?"Disable":"Enable"}),e.jsx("button",{disabled:!0,title:"Editing not supported yet",className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold opacity-60 cursor-not-allowed",children:"Edit"}),e.jsxs("button",{onClick:()=>y(l.name),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1",children:[e.jsx(H,{className:"h-3 w-3"}),"Uninstall"]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Provider"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:l.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Location"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:l.location})]})]}),l.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Capabilities"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.capabilities.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]}),l.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Allowed Tools (",l.allowedTools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.allowedTools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a skill to view details"})})]})]})})]})}),e.jsx(G,{open:p,catalog:s,installed:b.map(t=>t.name),onOpenChange:u,onInstall:P}),e.jsx(K,{open:C,status:F,error:w,onCancel:()=>i(!1),onConfirm:U,onRetry:()=>x("confirm")})]})}function B({active:a,children:r,onClick:d}){return e.jsx("button",{onClick:d,className:h("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",a?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:r})}function G({open:a,onOpenChange:r,onInstall:d,catalog:c,installed:f}){const[n,p]=o.useState("catalog"),[u,C]=o.useState(""),[i,F]=o.useState(null),[x,w]=o.useState(""),[m,k]=o.useState(""),j=c.filter(s=>s.name.toLowerCase().includes(u.toLowerCase())),b=()=>{if(n==="catalog"){if(!i)return;d({source:"catalog",name:i});return}if(n==="repo"){if(!x)return;d({source:"repo",url:x});return}m&&d({source:"local",path:m})},E=i?f.includes(i):!1,g=n==="catalog"&&(!i||E)||n==="repo"&&!x||n==="local"&&!m;return e.jsx(I,{open:a,onOpenChange:r,children:e.jsxs(D,{className:"sm:max-w-[540px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Install Skill"}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install Skill"}),e.jsx("button",{onClick:()=>r(!1),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(L,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(B,{active:n==="catalog",onClick:()=>p("catalog"),children:"Catalog"}),e.jsx(B,{active:n==="repo",onClick:()=>p("repo"),children:"Repo"}),e.jsx(B,{active:n==="local",onClick:()=>p("local"),children:"Local"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[n==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{value:u,onChange:s=>C(s.target.value),placeholder:"Search catalog...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsxs("div",{className:"flex flex-col gap-2 max-h-[240px] overflow-y-auto",children:[j.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills found"}),j.map(s=>{const y=f.includes(s.name),A=i===s.name;return e.jsxs("button",{onClick:()=>F(s.name),className:h("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",A?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:s.name}),e.jsx("span",{className:h("text-[10px] font-mono px-2 py-0.5 rounded",s.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:s.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:s.description}),e.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["by ",s.author]}),y&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:"Installed"})]},s.name)})]})]}),n==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"GitHub URL"}),e.jsx("input",{value:x,onChange:s=>w(s.target.value),placeholder:"https://github.com/org/skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsx("span",{className:"inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Private repo supported (backend support required)"})]}),n==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Local path"}),e.jsx("input",{value:m,onChange:s=>k(s.target.value),placeholder:"/Users/bytedance/skills/my-skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>r(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:b,disabled:g,className:h("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",g?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:"Install"})]})]})]})})}function K({open:a,status:r,error:d,onCancel:c,onConfirm:f,onRetry:n}){return e.jsx(I,{open:a,onOpenChange:p=>!p&&c(),children:e.jsxs(D,{className:"sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Install Status"}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[r==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Confirm Install"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Install selected skill?"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:f,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Install"})]})]}),r==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Installing"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Downloading and verifying…"}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:c,className:"self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Hide"})]}),r==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Install Failed"}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:d||"Installation failed."}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Check access and try again."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Close"}),e.jsx("button",{onClick:n,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Retry"})]})]})]})]})})}export{te as SkillsModal};
@@ -1 +1 @@
1
- import{r,j as t}from"./vendor-react-FPIC4Czm.js";import{u as B,c as m}from"./index-B-BRpW1c.js";import{a as z}from"./SettingsStore-BfoB9tNV.js";import{D as y,o as A,L as v}from"./vendor-xterm-DuYZoU4T.js";import{r as j,M as C,X as N}from"./vendor-icons-DBM55KTG.js";import"./vendor-markdown-b9iCqZWK.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-DyP_DOwV.js";const I=()=>{const{isTerminalOpen:s,toggleTerminal:x}=B(),[i,p]=r.useState(!1),[E,l]=r.useState(!1),d=z(),u=r.useRef(null),o=r.useRef(null),b=r.useRef(null),c=r.useRef(null),k=r.useCallback(()=>{var a;if(((a=c.current)==null?void 0:a.readyState)===WebSocket.OPEN)return;const n=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/terminal/ws`,e=new WebSocket(n);c.current=e,e.onopen=()=>{l(!0)},e.onmessage=h=>{var f;(f=o.current)==null||f.write(h.data)},e.onclose=()=>{l(!1)},e.onerror=()=>{l(!1)}},[]),g=r.useCallback(()=>{c.current&&(c.current.close(),c.current=null),l(!1)},[]),w=r.useCallback(n=>{var e;((e=c.current)==null?void 0:e.readyState)===WebSocket.OPEN&&c.current.send(n)},[]);return r.useEffect(()=>{if(!s||!u.current||o.current)return;const n={background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"},e=new y({cursorBlink:!0,cursorStyle:"bar",fontSize:14,fontFamily:"JetBrains Mono, Menlo, Monaco, Consolas, monospace",allowTransparency:!0,scrollback:1e4,theme:d?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:n}),a=new A,h=new v;return e.loadAddon(a),e.loadAddon(h),e.open(u.current),a.fit(),e.onData(f=>{w(f)}),o.current=e,b.current=a,k(),()=>{g(),e.dispose(),o.current=null,b.current=null}},[s,k,g,w]),r.useEffect(()=>{o.current&&(o.current.options.theme=d?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:{background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"})},[d]),r.useEffect(()=>{if(!s||i)return;const n=()=>{var a;(a=b.current)==null||a.fit()};window.addEventListener("resize",n);const e=setTimeout(n,100);return()=>{window.removeEventListener("resize",n),clearTimeout(e)}},[s,i]),s?t.jsxs("div",{className:m("fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-[#0a0a0a] border-t border-[#E5E7EB] dark:border-zinc-800 transition-all duration-200",i?"h-10":"h-72"),children:[t.jsxs("div",{className:"flex items-center justify-between h-10 px-3 border-b border-[#E5E7EB] dark:border-zinc-800 bg-[#F9FAFB] dark:bg-zinc-900/50",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(j,{className:"h-4 w-4 text-[#9CA3AF] dark:text-zinc-400"}),t.jsx("span",{className:"text-sm text-[#6B7280] dark:text-zinc-400",children:"Terminal"}),t.jsx("span",{className:m("w-2 h-2 rounded-full",E?"bg-green-500":"bg-zinc-600")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>p(!i),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:t.jsx(C,{className:"h-4 w-4"})}),t.jsx("button",{onClick:()=>{g(),x()},className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:t.jsx(N,{className:"h-4 w-4"})})]})]}),t.jsx("div",{ref:u,className:m("h-[calc(100%-40px)] p-2",i&&"hidden")})]}):null};export{I as TerminalPanel};
1
+ import{r,j as t}from"./vendor-react-FPIC4Czm.js";import{u as B,c as m}from"./index-DIWzaS2_.js";import{a as z}from"./SettingsStore-C8YBWQPS.js";import{D as y,o as A,L as v}from"./vendor-xterm-DuYZoU4T.js";import{r as j,M as C,X as N}from"./vendor-icons-DBM55KTG.js";import"./vendor-markdown-b9iCqZWK.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-DyP_DOwV.js";const I=()=>{const{isTerminalOpen:s,toggleTerminal:x}=B(),[i,p]=r.useState(!1),[E,l]=r.useState(!1),d=z(),u=r.useRef(null),o=r.useRef(null),b=r.useRef(null),c=r.useRef(null),k=r.useCallback(()=>{var a;if(((a=c.current)==null?void 0:a.readyState)===WebSocket.OPEN)return;const n=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/terminal/ws`,e=new WebSocket(n);c.current=e,e.onopen=()=>{l(!0)},e.onmessage=h=>{var f;(f=o.current)==null||f.write(h.data)},e.onclose=()=>{l(!1)},e.onerror=()=>{l(!1)}},[]),g=r.useCallback(()=>{c.current&&(c.current.close(),c.current=null),l(!1)},[]),w=r.useCallback(n=>{var e;((e=c.current)==null?void 0:e.readyState)===WebSocket.OPEN&&c.current.send(n)},[]);return r.useEffect(()=>{if(!s||!u.current||o.current)return;const n={background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"},e=new y({cursorBlink:!0,cursorStyle:"bar",fontSize:14,fontFamily:"JetBrains Mono, Menlo, Monaco, Consolas, monospace",allowTransparency:!0,scrollback:1e4,theme:d?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:n}),a=new A,h=new v;return e.loadAddon(a),e.loadAddon(h),e.open(u.current),a.fit(),e.onData(f=>{w(f)}),o.current=e,b.current=a,k(),()=>{g(),e.dispose(),o.current=null,b.current=null}},[s,k,g,w]),r.useEffect(()=>{o.current&&(o.current.options.theme=d?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:{background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"})},[d]),r.useEffect(()=>{if(!s||i)return;const n=()=>{var a;(a=b.current)==null||a.fit()};window.addEventListener("resize",n);const e=setTimeout(n,100);return()=>{window.removeEventListener("resize",n),clearTimeout(e)}},[s,i]),s?t.jsxs("div",{className:m("fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-[#0a0a0a] border-t border-[#E5E7EB] dark:border-zinc-800 transition-all duration-200",i?"h-10":"h-72"),children:[t.jsxs("div",{className:"flex items-center justify-between h-10 px-3 border-b border-[#E5E7EB] dark:border-zinc-800 bg-[#F9FAFB] dark:bg-zinc-900/50",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(j,{className:"h-4 w-4 text-[#9CA3AF] dark:text-zinc-400"}),t.jsx("span",{className:"text-sm text-[#6B7280] dark:text-zinc-400",children:"Terminal"}),t.jsx("span",{className:m("w-2 h-2 rounded-full",E?"bg-green-500":"bg-zinc-600")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>p(!i),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:t.jsx(C,{className:"h-4 w-4"})}),t.jsx("button",{onClick:()=>{g(),x()},className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:t.jsx(N,{className:"h-4 w-4"})})]})]}),t.jsx("div",{ref:u,className:m("h-[calc(100%-40px)] p-2",i&&"hidden")})]}):null};export{I as TerminalPanel};