import{c as _,r as m,u as He,j as e,a as Ke,b as Be,P as X,d as te,e as Qe,f as ee,g as ie,q as k,s as L,h as G,i as H,t as C,S as A,B as R,k as j,I as je,L as ge}from"./index-Db2le9MZ.js";import{C as f,a as p,b as N,c as b,d as w,e as S}from"./card-Brywvsf7.js";import{L as E,I as ne}from"./label-Cr1rg8V6.js";import{S as se,R as M}from"./switch-CStZrAxp.js";import{c as ve,R as Ue,I as We}from"./index-bf0tLRhp.js";import{u as Ze,C as fe}from"./index-DzPJ0_Ig.js";import{S as a}from"./skeleton-CpqLFdPV.js";import{C as pe}from"./circle-x-DEK1Rhk5.js";/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Je=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]],F=_("Brain",Je);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ye=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Xe=_("Globe",Ye);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const es=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Ne=_("Plug",es);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ss=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],be=_("Save",ss);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const as=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],I=_("Server",as);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rs=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],z=_("SquareTerminal",rs);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ts=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],D=_("TriangleAlert",ts);var ae="Tabs",[ls,Xs]=Ke(ae,[ve]),we=ve(),[ns,ce]=ls(ae),ye=m.forwardRef((s,r)=>{const{__scopeTabs:t,value:i,onValueChange:n,defaultValue:o,orientation:c="horizontal",dir:x,activationMode:h="automatic",...g}=s,u=Ze(x),[l,v]=He({prop:i,onChange:n,defaultProp:o??"",caller:ae});return e.jsx(ns,{scope:t,baseId:Be(),value:l,onValueChange:v,orientation:c,dir:u,activationMode:h,children:e.jsx(X.div,{dir:u,"data-orientation":c,...g,ref:r})})});ye.displayName=ae;var Ce="TabsList",Se=m.forwardRef((s,r)=>{const{__scopeTabs:t,loop:i=!0,...n}=s,o=ce(Ce,t),c=we(t);return e.jsx(Ue,{asChild:!0,...c,orientation:o.orientation,dir:o.dir,loop:i,children:e.jsx(X.div,{role:"tablist","aria-orientation":o.orientation,...n,ref:r})})});Se.displayName=Ce;var ke="TabsTrigger",Pe=m.forwardRef((s,r)=>{const{__scopeTabs:t,value:i,disabled:n=!1,...o}=s,c=ce(ke,t),x=we(t),h=Ae(c.baseId,i),g=Te(c.baseId,i),u=i===c.value;return e.jsx(We,{asChild:!0,...x,focusable:!n,active:u,children:e.jsx(X.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":g,"data-state":u?"active":"inactive","data-disabled":n?"":void 0,disabled:n,id:h,...o,ref:r,onMouseDown:te(s.onMouseDown,l=>{!n&&l.button===0&&l.ctrlKey===!1?c.onValueChange(i):l.preventDefault()}),onKeyDown:te(s.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&c.onValueChange(i)}),onFocus:te(s.onFocus,()=>{const l=c.activationMode!=="manual";!u&&!n&&l&&c.onValueChange(i)})})})});Pe.displayName=ke;var Me="TabsContent",Le=m.forwardRef((s,r)=>{const{__scopeTabs:t,value:i,forceMount:n,children:o,...c}=s,x=ce(Me,t),h=Ae(x.baseId,i),g=Te(x.baseId,i),u=i===x.value,l=m.useRef(u);return m.useEffect(()=>{const v=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame(v)},[]),e.jsx(Qe,{present:n||u,children:({present:v})=>e.jsx(X.div,{"data-state":u?"active":"inactive","data-orientation":x.orientation,role:"tabpanel","aria-labelledby":h,hidden:!v,id:g,tabIndex:0,...c,ref:r,style:{...s.style,animationDuration:l.current?"0s":void 0},children:v&&o})})});Le.displayName=Me;function Ae(s,r){return`${s}-trigger-${r}`}function Te(s,r){return`${s}-content-${r}`}var is=ye,cs=Se,os=Pe,ds=Le;function Ee({className:s,...r}){return e.jsx(is,{"data-slot":"tabs",className:ee("flex flex-col gap-2",s),...r})}function Re({className:s,...r}){return e.jsx(cs,{"data-slot":"tabs-list",className:ee("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",s),...r})}function O({className:s,...r}){return e.jsx(os,{"data-slot":"tabs-trigger",className:ee("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),...r})}function q({className:s,...r}){return e.jsx(ds,{"data-slot":"tabs-content",className:ee("flex-1 outline-none",s),...r})}function $(s){return ie({queryKey:k.config.value(s),queryFn:async()=>await L.config.get(s),enabled:!!s})}function xs(s){const r=G(),{data:t,isLoading:i,error:n,refetch:o}=ie({queryKey:k.server.logs(),queryFn:()=>L.server.getLogs(s),refetchInterval:5e3}),c=H({mutationFn:x=>L.server.clearLogs({type:x}),onSuccess:()=>{r.invalidateQueries({queryKey:k.server.all})}});return{logs:t,isLoading:i,error:n,refetch:o,clearLogs:c.mutate,isClearingLogs:c.isPending}}function ms(s={}){const r=G();return H({mutationFn:async({key:t,value:i})=>L.config.set(t,i),onSuccess:(t,i)=>{r.invalidateQueries({queryKey:k.config.value(i.key)}),r.invalidateQueries({queryKey:k.config.all}),(s.invalidateServerLogs||i.key.startsWith("server."))&&r.invalidateQueries({queryKey:k.server.all})}})}function hs(){const s=G();return H({mutationFn:async()=>L.server.restart(),onSuccess:()=>{s.invalidateQueries({queryKey:k.server.all}),C.success("Server restarted",{description:"Server has been restarted with the new configuration"})},onError:r=>{C.error("Failed to restart server",{description:r instanceof Error?r.message:"Unknown error occurred"})}})}function us(s="all"){const r=G(),{data:t,isLoading:i,error:n,refetch:o}=ie({queryKey:k.server.mcpLogs(s),queryFn:()=>L.server.getMCPLogs({type:s}),staleTime:5e3}),c=H({mutationFn:x=>L.server.clearMCPLogs({type:x}),onSuccess:()=>{r.invalidateQueries({queryKey:k.server.all})}});return{logs:t,isLoading:i,error:n,refetch:o,clearLogs:c.mutate,isClearingLogs:c.isPending}}function js(){const s=G();return H({mutationFn:async()=>L.server.restartMCP(),onSuccess:()=>{s.invalidateQueries({queryKey:k.server.all}),C.success("MCP Server restarted",{description:"MCP Server has been restarted with the new configuration"})},onError:r=>{console.error("Failed to restart MCP server:",r),C.error("Error restarting MCP server",{description:"Could not restart the MCP server"})}})}const ue=3001,Y=4241,gs=5173;function vs(){return e.jsx("div",{className:"min-h-full bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-6",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"inline-flex items-center justify-center p-4 bg-gradient-to-r from-blue-500 to-purple-600 rounded-2xl text-white shadow-lg",children:e.jsx(I,{className:"h-8 w-8"})}),e.jsx("h1",{className:"text-4xl font-bold bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent",children:"Settings"}),e.jsx("p",{className:"text-lg text-gray-600 max-w-2xl mx-auto",children:"Configure your server and application settings for optimal performance."})]}),e.jsxs(Ee,{defaultValue:"server",className:"w-full",children:[e.jsxs(Re,{className:"grid w-full grid-cols-3 bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg",children:[e.jsxs(O,{value:"server",className:"flex items-center gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-blue-500 data-[state=active]:to-purple-600 data-[state=active]:text-white",children:[e.jsx(I,{className:"h-4 w-4"}),"API Server"]}),e.jsxs(O,{value:"mcpServer",className:"flex items-center gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-blue-500 data-[state=active]:to-purple-600 data-[state=active]:text-white",children:[e.jsx(F,{className:"h-4 w-4"}),"MCP Server"]}),e.jsxs(O,{value:"general",className:"flex items-center gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-blue-500 data-[state=active]:to-purple-600 data-[state=active]:text-white",disabled:!0,children:[e.jsx(Ne,{className:"h-4 w-4"}),"General"]})]}),e.jsxs(q,{value:"server",className:"mt-6",children:[e.jsx(fs,{}),e.jsx(Ns,{}),e.jsx(ys,{})]}),e.jsxs(q,{value:"mcpServer",className:"mt-6",children:[e.jsx(ps,{}),e.jsx(bs,{}),e.jsx(ws,{}),e.jsx(Cs,{})]}),e.jsx(q,{value:"general",children:e.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"General settings will be available in a future update"})})]})]})})}function fs(){return e.jsxs(f,{className:"bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg",children:[e.jsx(p,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-gradient-to-r from-blue-500 to-cyan-500 rounded-lg text-white",children:e.jsx(I,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx(N,{className:"text-xl font-semibold",children:"Server Configuration"}),e.jsx(b,{className:"mt-1 text-gray-600",children:"Configure the built-in API server for receiving logs"})]})]}),e.jsx(a,{className:"h-6 w-16"})]})}),e.jsxs(w,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a,{className:"h-4 w-24"}),e.jsx(a,{className:"h-3 w-40"})]}),e.jsx(a,{className:"h-6 w-11 rounded-full"})]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{className:"h-4 w-20"}),e.jsx(a,{className:"h-10 w-full"}),e.jsx(a,{className:"h-3 w-64"})]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a,{className:"h-4 w-24"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-10 flex-1"}),e.jsx(a,{className:"h-10 w-16"})]}),e.jsx(a,{className:"h-3 w-72"}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[e.jsx(a,{className:"h-6 w-32"}),e.jsx(a,{className:"h-6 w-28"})]})]})]}),e.jsxs(S,{className:"flex justify-end gap-3 pt-2",children:[e.jsx(a,{className:"h-10 w-32"}),e.jsx(a,{className:"h-10 w-28"})]})]})}function ps(){return e.jsxs(f,{className:"bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg",children:[e.jsx(p,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-gradient-to-r from-purple-500 to-pink-500 rounded-lg text-white",children:e.jsx(F,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx(N,{className:"text-xl font-semibold",children:"MCP Server Configuration"}),e.jsx(b,{className:"mt-1 text-gray-600",children:"Configure the Model Context Protocol server for AI agent access"})]})]}),e.jsx(a,{className:"h-6 w-16"})]})}),e.jsxs(w,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a,{className:"h-4 w-32"}),e.jsx(a,{className:"h-3 w-48"})]}),e.jsx(a,{className:"h-6 w-11 rounded-full"})]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{className:"h-4 w-28"}),e.jsx(a,{className:"h-10 w-full"}),e.jsx(a,{className:"h-3 w-64"})]})]}),e.jsxs(S,{className:"flex justify-end gap-3 pt-2",children:[e.jsx(a,{className:"h-10 w-32"}),e.jsx(a,{className:"h-10 w-28"})]})]})}function Ns(){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(a,{className:"h-5 w-5"}),"API Endpoints"]}),e.jsx(b,{children:"The server exposes these endpoints when enabled"})]}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[1,2,3].map(s=>e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx(a,{className:"h-4 w-20 mb-2"}),e.jsx(a,{className:"h-3 w-48"})]},s))})})})]})}function bs(){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(a,{className:"h-5 w-5"}),"MCP Endpoint"]}),e.jsx(b,{children:"The MCP server exposes this endpoint when enabled"})]}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx(a,{className:"h-4 w-24 mb-2"}),e.jsx(a,{className:"h-3 w-40"})]})})})]})}function ws(){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5"}),"Available MCP Tools"]}),e.jsx(b,{children:"Tools accessible to AI agents via the MCP protocol"})]}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:e.jsx(a,{className:"h-16 w-full"})})})})]})}function ys(){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(a,{className:"h-5 w-5"}),"Server Logs"]}),e.jsx(b,{children:"View server stdout and stderr logs"})]}),e.jsxs(w,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a,{className:"h-8 w-24"}),e.jsx(a,{className:"h-8 w-20"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a,{className:"h-4 w-20"}),e.jsx(a,{className:"h-6 w-11 rounded-full"}),e.jsx(a,{className:"h-8 w-8"}),e.jsx(a,{className:"h-8 w-8"})]})]}),e.jsx("div",{className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm h-96 overflow-y-auto",children:e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(s=>e.jsx(a,{className:"h-4 w-full bg-gray-800"},s))})})]}),e.jsxs(S,{className:"flex justify-between",children:[e.jsx(a,{className:"h-3 w-32"}),e.jsx(a,{className:"h-8 w-24"})]})]})}function Cs(){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(a,{className:"h-5 w-5"}),"MCP Server Logs"]}),e.jsx(b,{children:"View MCP server stdout and stderr logs"})]}),e.jsxs(w,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a,{className:"h-8 w-24"}),e.jsx(a,{className:"h-8 w-20"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a,{className:"h-4 w-20"}),e.jsx(a,{className:"h-6 w-11 rounded-full"}),e.jsx(a,{className:"h-8 w-8"}),e.jsx(a,{className:"h-8 w-8"})]})]}),e.jsx("div",{className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm h-96 overflow-y-auto",children:e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(s=>e.jsx(a,{className:"h-4 w-full bg-gray-800"},s))})})]}),e.jsxs(S,{className:"flex justify-between",children:[e.jsx(a,{className:"h-3 w-32"}),e.jsx(a,{className:"h-8 w-24"})]})]})}function Ie({title:s,description:r,icon:t,iconGradient:i,showCorsSection:n=!1,showRestartNotification:o=!1}){return e.jsxs(f,{className:"bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg",children:[e.jsx(p,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 ${i} rounded-lg text-white`,children:e.jsx(t,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx(N,{className:"text-xl font-semibold",children:s}),e.jsx(b,{className:"mt-1 text-gray-600",children:r})]})]}),e.jsx(a,{className:"h-6 w-16"})," "]})}),e.jsxs(w,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a,{className:"h-4 w-24"})," ",e.jsx(a,{className:"h-3 w-40"})," "]}),e.jsx(a,{className:"h-6 w-11 rounded-full"})," "]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{className:"h-4 w-20"})," ",e.jsx(a,{className:"h-10 w-full"})," ",e.jsx(a,{className:"h-3 w-64"})," "]}),n&&e.jsxs(e.Fragment,{children:[e.jsx(A,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a,{className:"h-4 w-24"})," ",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{className:"h-10 flex-1"})," ",e.jsx(a,{className:"h-10 w-16"})," "]}),e.jsx(a,{className:"h-3 w-72"})," ",e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[e.jsx(a,{className:"h-6 w-32"})," ",e.jsx(a,{className:"h-6 w-28"})," ",e.jsx(a,{className:"h-6 w-36"})," "]})]})]}),o&&e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900 rounded-md p-4 mt-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(a,{className:"h-5 w-5 mt-0.5"})," ",e.jsxs("div",{className:"ml-3 space-y-2",children:[e.jsx(a,{className:"h-4 w-48"})," ",e.jsx(a,{className:"h-3 w-80"})," "]})]})})]}),e.jsxs(S,{className:"flex justify-end gap-3 pt-2",children:[e.jsx(a,{className:"h-10 w-32"})," ",e.jsx(a,{className:"h-10 w-28"})," "]})]})}function Ss(){return e.jsx(Ie,{title:"Server Configuration",description:"Configure the built-in API server for receiving logs",icon:I,iconGradient:"bg-gradient-to-r from-blue-500 to-cyan-500",showCorsSection:!0,showRestartNotification:!0})}function ks(){return e.jsx(Ie,{title:"MCP Server Configuration",description:"Configure the Model Context Protocol server for AI agent access",icon:F,iconGradient:"bg-gradient-to-r from-purple-500 to-pink-500",showCorsSection:!1,showRestartNotification:!0})}function _e({title:s="Server Logs",description:r="View server stdout and stderr logs"}){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(z,{className:"h-5 w-5"}),s]}),e.jsx(b,{children:r})]}),e.jsxs(w,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a,{className:"h-8 w-28"})," ",e.jsx(a,{className:"h-8 w-20"})," "]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a,{className:"h-4 w-20"})," ",e.jsx(a,{className:"h-6 w-11 rounded-full"})," ",e.jsx(a,{className:"h-8 w-8"})," ",e.jsx(a,{className:"h-8 w-8"})," "]})]}),e.jsx("div",{className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm h-96 overflow-y-auto",children:e.jsx("div",{className:"space-y-2",children:Array.from({length:8},(t,i)=>e.jsx(a,{className:"h-4 bg-gray-800",style:{width:`${Math.random()*40+60}%`}},i))})})]}),e.jsxs(S,{className:"flex justify-between",children:[e.jsx(a,{className:"h-3 w-36"})," ",e.jsx(a,{className:"h-8 w-28"})," "]})]})}function Ps(){return e.jsx(_e,{title:"MCP Server Logs",description:"View MCP server stdout and stderr logs"})}const Ms="http://example.com";function Ls({serverConfig:s,setServerConfig:r,corsInput:t,setCorsInput:i,isLoading:n,isRestarting:o,setIsRestarting:c,onSave:x,onRestart:h,onAddCorsOrigin:g,onRemoveCorsOrigin:u,isSaving:l,isRestartingServer:v}){return e.jsxs(f,{className:"bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg",children:[e.jsx(p,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-gradient-to-r from-blue-500 to-cyan-500 rounded-lg text-white",children:e.jsx(I,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx(N,{className:"text-xl font-semibold",children:"Server Configuration"}),e.jsx(b,{className:"mt-1 text-gray-600",children:"Configure the built-in API server for receiving logs"})]})]}),e.jsx(R,{variant:s.enabled?"default":"outline",className:"mt-1",children:s.enabled?"Enabled":"Disabled"})]})}),e.jsxs(w,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(E,{htmlFor:"server-enabled",children:"Server Status"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Enable or disable the API server"})]}),e.jsx(se,{id:"server-enabled",checked:s.enabled,onCheckedChange:d=>r({...s,enabled:d}),disabled:n||l})]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{htmlFor:"server-port",children:"Server Port"}),e.jsx(ne,{id:"server-port",type:"number",min:"1000",max:"65535",value:s.port,onChange:d=>r({...s,port:parseInt(d.target.value,10)}),disabled:n||!s.enabled||l}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["The port number the server will listen on (default: ",gs,")"]})]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(E,{children:"CORS Origins"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{placeholder:Ms,value:t,onChange:d=>i(d.target.value),disabled:n||!s.enabled||l}),e.jsx(j,{variant:"outline",onClick:g,disabled:n||!s.enabled||!t||l,children:"Add"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Specify allowed origins for Cross-Origin Resource Sharing"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:s.corsOrigins.map(d=>e.jsxs(R,{variant:"secondary",className:"pl-2 flex items-center gap-1",children:[e.jsx(Xe,{className:"h-3 w-3 mr-1"}),d,e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>u(d),className:"h-4 w-4 p-0 ml-1 text-muted-foreground hover:text-foreground",disabled:n||!s.enabled||l,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-3 w-3",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},d))})]}),o&&e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900 rounded-md p-4 mt-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(je,{className:"h-5 w-5 text-amber-500 mt-0.5"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800 dark:text-amber-300",children:"Server Restart Required"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700 dark:text-amber-400",children:e.jsx("p",{children:"You'll need to restart the server for the configuration changes to take effect."})})]})]})})]}),e.jsxs(S,{className:"flex justify-end gap-3 pt-2",children:[e.jsxs(j,{variant:"outline",onClick:()=>c(!1),disabled:n||!o||l,children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Restart Later"]}),o&&e.jsxs(j,{variant:"default",onClick:h,disabled:n||v||l,children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Restart Now"]}),e.jsxs(j,{onClick:x,disabled:n||l||v,children:[e.jsx(be,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})}function As({mcpServerConfig:s,setMCPServerConfig:r,isLoading:t,isMCPRestarting:i,setIsMCPRestarting:n,onSave:o,onRestart:c,isSaving:x,isRestartingServer:h}){return e.jsxs(f,{className:"bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg",children:[e.jsx(p,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-gradient-to-r from-purple-500 to-pink-500 rounded-lg text-white",children:e.jsx(F,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx(N,{className:"text-xl font-semibold",children:"MCP Server Configuration"}),e.jsx(b,{className:"mt-1 text-gray-600",children:"Configure the Model Context Protocol server for AI agent access"})]})]}),e.jsx(R,{variant:s.enabled?"default":"outline",className:"mt-1",children:s.enabled?"Enabled":"Disabled"})]})}),e.jsxs(w,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(E,{htmlFor:"mcp-server-enabled",children:"MCP Server Status"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Enable or disable the MCP server for LLM agents"})]}),e.jsx(se,{id:"mcp-server-enabled",checked:s.enabled,onCheckedChange:g=>r({...s,enabled:g}),disabled:t||x})]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{htmlFor:"mcp-server-port",children:"MCP Server Port"}),e.jsx(ne,{id:"mcp-server-port",type:"number",min:"1000",max:"65535",value:s.port,onChange:g=>r({...s,port:parseInt(g.target.value,10)||Y}),disabled:t||!s.enabled||x}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["The port number the MCP server will listen on (default: ",Y,")"]})]}),i&&e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900 rounded-md p-4 mt-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(je,{className:"h-5 w-5 text-amber-500 mt-0.5"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800 dark:text-amber-300",children:"MCP Server Restart Required"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700 dark:text-amber-400",children:e.jsx("p",{children:"You'll need to restart the MCP server for the configuration changes to take effect."})})]})]})})]}),e.jsxs(S,{className:"flex justify-end gap-3 pt-2",children:[e.jsxs(j,{variant:"outline",onClick:()=>n(!1),disabled:t||!i||x,children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Restart Later"]}),i&&e.jsxs(j,{variant:"default",onClick:c,disabled:t||h||x,children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Restart Now"]}),e.jsxs(j,{onClick:o,disabled:t||x||h,children:[e.jsx(be,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})}const le="localhost",Ts="/api",Es="/ui",Rs="/doc";function Is({port:s}){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(ge,{className:"h-5 w-5"}),"API Endpoints"]}),e.jsx(b,{children:"The server exposes these endpoints when enabled"})]}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("h3",{className:"font-medium",children:"API Root"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["http://",le,":",s,Ts]})]}),e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("h3",{className:"font-medium",children:"Swagger UI"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["http://",le,":",s,Es]})]}),e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("h3",{className:"font-medium",children:"API Documentation"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["http://",le,":",s,Rs]})]})]})})})]})}const _s="localhost",Fs="/mcp";function Os({port:s}){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(ge,{className:"h-5 w-5"}),"MCP Endpoint"]}),e.jsx(b,{children:"The MCP server exposes this endpoint when enabled"})]}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsx("h3",{className:"font-medium",children:"MCP Endpoint"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["http://",_s,":",s,Fs]})]})})})]})}function qs(){return e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5"}),"Available MCP Tools"]}),e.jsx(b,{children:"Tools accessible to AI agents via the MCP protocol"})]}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:"MCP tools will be available in a future update"})})})]})}function Vs({enabledError:s,portError:r,corsError:t,mcpEnabledError:i,mcpPortError:n}){return e.jsx("div",{className:"min-h-full bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-6",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsxs(f,{className:"border-red-200 bg-red-50",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2 text-red-700",children:[e.jsx(D,{className:"h-5 w-5"}),"Configuration Error"]}),e.jsx(b,{className:"text-red-600",children:"Failed to load application settings"})]}),e.jsx(w,{children:e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx("p",{className:"text-sm text-red-600",children:"• Failed to load server enabled status"}),r&&e.jsx("p",{className:"text-sm text-red-600",children:"• Failed to load server port configuration"}),t&&e.jsx("p",{className:"text-sm text-red-600",children:"• Failed to load CORS configuration"}),i&&e.jsx("p",{className:"text-sm text-red-600",children:"• Failed to load MCP server enabled status"}),n&&e.jsx("p",{className:"text-sm text-red-600",children:"• Failed to load MCP server port configuration"})]})}),e.jsx(S,{children:e.jsxs(j,{onClick:()=>window.location.reload(),variant:"outline",children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Reload Page"]})})]})})})}function $s(){return e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"inline-flex items-center justify-center p-4 bg-gradient-to-r from-blue-500 to-purple-600 rounded-2xl text-white shadow-lg",children:e.jsx(I,{className:"h-8 w-8"})}),e.jsx("h1",{className:"text-4xl font-bold bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent",children:"Settings"}),e.jsx("p",{className:"text-lg text-gray-600 max-w-2xl mx-auto",children:"Configure your server and application settings for optimal performance."})]})}function zs(){const[s,r]=m.useState("stdout"),[t,i]=m.useState(!1),n=m.useRef(null),{logs:o,isLoading:c,error:x,refetch:h,clearLogs:g,isClearingLogs:u}=xs({type:"all"}),l=m.useMemo(()=>o?Array.isArray(o)?{stdout:o,stderr:[]}:o:{stdout:[],stderr:[]},[o]);m.useEffect(()=>{if(!t)return;const d=setInterval(()=>{h()},5e3);return()=>clearInterval(d)},[t,h]),m.useEffect(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[l]);const v=d=>{g(d),C.success(`${d==="all"?"All":d==="stdout"?"Standard output":"Error"} logs cleared`)};return c&&!o?e.jsx(_e,{}):x?e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(z,{className:"h-5 w-5"}),"Server Logs"]}),e.jsx(b,{children:"View server stdout and stderr logs"})]}),e.jsx(w,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(D,{className:"h-12 w-12 text-red-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Error loading server logs"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"Failed to fetch server logs. Please try again."}),e.jsxs(j,{onClick:()=>h(),variant:"outline",children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Retry"]})]})})]}):e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(z,{className:"h-5 w-5"}),"Server Logs"]}),e.jsx(b,{children:"View server stdout and stderr logs"})]}),e.jsxs(w,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(j,{variant:s==="stdout"?"default":"outline",size:"sm",onClick:()=>r("stdout"),className:"gap-1",children:[e.jsx(fe,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Standard Output"}),e.jsx("span",{className:"inline sm:hidden",children:"Stdout"}),e.jsx(R,{variant:"secondary",className:"ml-1",children:l.stdout.length})]}),e.jsxs(j,{variant:s==="stderr"?"default":"outline",size:"sm",onClick:()=>r("stderr"),className:"gap-1",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Standard Error"}),e.jsx("span",{className:"inline sm:hidden",children:"Stderr"}),e.jsx(R,{variant:"secondary",className:"ml-1",children:l.stderr.length})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(E,{htmlFor:"auto-refresh",className:"text-sm",children:"Auto-refresh"}),e.jsx(se,{id:"auto-refresh",checked:t,onCheckedChange:i})]}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>h(),disabled:c||u,children:e.jsx(M,{className:`h-4 w-4 ${c?"animate-spin":""}`})}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>v(s),disabled:c||u,children:e.jsx(pe,{className:"h-4 w-4"})})]})]}),e.jsx("div",{ref:n,className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm h-96 overflow-y-auto whitespace-pre-wrap",children:c?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"animate-pulse",children:"Loading logs..."})}):s==="stdout"?l.stdout.length>0?l.stdout.map((d,y)=>e.jsx("div",{className:"mb-1",children:d},y)):e.jsx("div",{className:"text-gray-500 italic",children:"No standard output logs available"}):l.stderr.length>0?l.stderr.map((d,y)=>e.jsx("div",{className:"text-red-400 mb-1",children:d},y)):e.jsx("div",{className:"text-gray-500 italic",children:"No error logs available"})})]}),e.jsxs(S,{className:"flex justify-between",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:c?"Loading logs...":`Showing ${s==="stdout"?l.stdout.length:l.stderr.length} log entries`}),e.jsx(j,{variant:"destructive",size:"sm",onClick:()=>v("all"),disabled:c||u,children:"Clear All Logs"})]})]})}function Ds(){const[s,r]=m.useState("stdout"),[t,i]=m.useState(!1),n=m.useRef(null),{logs:o,isLoading:c,error:x,refetch:h,clearLogs:g,isClearingLogs:u}=us("all"),l=m.useMemo(()=>o?Array.isArray(o)?{stdout:o,stderr:[]}:o:{stdout:[],stderr:[]},[o]);m.useEffect(()=>{if(!t)return;const d=setInterval(()=>{h()},5e3);return()=>clearInterval(d)},[t,h]),m.useEffect(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[l]);const v=d=>{g(d),C.success(`${d==="all"?"All":d==="stdout"?"Standard output":"Error"} logs cleared`)};return c&&!o?e.jsx(Ps,{}):x?e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(z,{className:"h-5 w-5"}),"MCP Server Logs"]}),e.jsx(b,{children:"View MCP server stdout and stderr logs"})]}),e.jsx(w,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(D,{className:"h-12 w-12 text-red-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Error loading MCP server logs"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"Failed to fetch MCP server logs. Please try again."}),e.jsxs(j,{onClick:()=>h(),variant:"outline",children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Retry"]})]})})]}):e.jsxs(f,{className:"border shadow-sm mt-6",children:[e.jsxs(p,{children:[e.jsxs(N,{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(z,{className:"h-5 w-5"}),"MCP Server Logs"]}),e.jsx(b,{children:"View MCP server stdout and stderr logs"})]}),e.jsxs(w,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(j,{variant:s==="stdout"?"default":"outline",size:"sm",onClick:()=>r("stdout"),className:"gap-1",children:[e.jsx(fe,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Standard Output"}),e.jsx("span",{className:"inline sm:hidden",children:"Stdout"}),e.jsx(R,{variant:"secondary",className:"ml-1",children:l.stdout.length})]}),e.jsxs(j,{variant:s==="stderr"?"default":"outline",size:"sm",onClick:()=>r("stderr"),className:"gap-1",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Standard Error"}),e.jsx("span",{className:"inline sm:hidden",children:"Stderr"}),e.jsx(R,{variant:"secondary",className:"ml-1",children:l.stderr.length})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(E,{htmlFor:"mcp-auto-refresh",className:"text-sm",children:"Auto-refresh"}),e.jsx(se,{id:"mcp-auto-refresh",checked:t,onCheckedChange:i})]}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>h(),disabled:c||u,children:e.jsx(M,{className:`h-4 w-4 ${c?"animate-spin":""}`})}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>v(s),disabled:c||u,children:e.jsx(pe,{className:"h-4 w-4"})})]})]}),e.jsx("div",{ref:n,className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm h-96 overflow-y-auto whitespace-pre-wrap",children:c?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"animate-pulse",children:"Loading logs..."})}):s==="stdout"?l.stdout.length>0?l.stdout.map((d,y)=>e.jsx("div",{className:"mb-1",children:d},y)):e.jsx("div",{className:"text-gray-500 italic",children:"No standard output logs available"}):l.stderr.length>0?l.stderr.map((d,y)=>e.jsx("div",{className:"text-red-400 mb-1",children:d},y)):e.jsx("div",{className:"text-gray-500 italic",children:"No error logs available"})})]}),e.jsxs(S,{className:"flex justify-between",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:c?"Loading logs...":`Showing ${s==="stdout"?l.stdout.length:l.stderr.length} log entries`}),e.jsx(j,{variant:"destructive",size:"sm",onClick:()=>v("all"),disabled:c||u,children:"Clear All Logs"})]})]})}function Gs(){const[s,r]=m.useState(!0),[t,i]=m.useState({enabled:!0,port:ue,corsOrigins:[]}),[n,o]=m.useState(""),[c,x]=m.useState(!1),{data:h,isLoading:g,error:u}=$("server.enabled"),{data:l,isLoading:v,error:d}=$("server.port"),{data:y,isLoading:K,error:oe}=$("server.corsOrigins"),T=ms({invalidateServerLogs:!0}),B=hs();m.useEffect(()=>{B.isSuccess&&x(!1)},[B.isSuccess]),m.useEffect(()=>{if(!(g||v||K))try{r(!0),console.log("cors config",y),i({enabled:h!=null&&h.value?h.value==="true":!0,port:l!=null&&l.value?parseInt(l.value,10):ue,corsOrigins:y!=null&&y.value?JSON.parse(y.value):[]})}catch(P){console.error("Failed to parse server configuration:",P),C.error("Error loading settings",{description:"Could not load server configuration"})}finally{r(!1)}},[h,l,y,g,v,K]);const Fe=async()=>{try{r(!0),await T.mutateAsync({key:"server.enabled",value:t.enabled.toString()}),await T.mutateAsync({key:"server.port",value:t.port.toString()}),await T.mutateAsync({key:"server.corsOrigins",value:JSON.stringify(t.corsOrigins)}),C.success("Settings saved",{description:"Server configuration has been updated"}),x(!0)}catch(P){console.error("Failed to save server configuration:",P),C.error("Error saving settings",{description:"Could not save server configuration"})}finally{r(!1)}},Oe=()=>{B.mutate()},qe=()=>{n&&!t.corsOrigins.includes(n)&&(i({...t,corsOrigins:[...t.corsOrigins,n]}),o(""))},Ve=P=>{i({...t,corsOrigins:t.corsOrigins.filter(Ge=>Ge!==P)})},[Q,de]=m.useState({enabled:!1,port:Y}),[$e,re]=m.useState(!1),{data:U,isLoading:W,error:xe}=$("mcpServer.enabled"),{data:V,isLoading:Z,error:me}=$("mcpServer.port"),J=js();m.useEffect(()=>{J.isSuccess&&re(!1)},[J.isSuccess]),m.useEffect(()=>{if(!(W||Z))try{de({enabled:(U==null?void 0:U.value)==="true",port:V!=null&&V.value?parseInt(V.value,10):Y})}catch(P){console.error("Failed to parse MCP server configuration:",P),C.error("Error loading MCP settings",{description:"Could not load MCP server configuration"})}},[U,V,W,Z]);const ze=async()=>{try{r(!0),await T.mutateAsync({key:"mcpServer.enabled",value:Q.enabled.toString()}),await T.mutateAsync({key:"mcpServer.port",value:Q.port.toString()}),C.success("MCP Settings saved",{description:"MCP Server configuration has been updated"}),re(!0)}catch(P){console.error("Failed to save MCP server configuration:",P),C.error("Error saving MCP settings",{description:"Could not save MCP server configuration"})}finally{r(!1)}},De=()=>{J.mutate()},he=u||d||oe||xe||me;return(g||v||K||W||Z)&&!he?e.jsx(vs,{}):he?e.jsx(Vs,{enabledError:u,portError:d,corsError:oe,mcpEnabledError:xe,mcpPortError:me}):e.jsx("div",{className:"min-h-full bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-6",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-8",children:[e.jsx($s,{}),e.jsxs(Ee,{defaultValue:"server",className:"w-full",children:[e.jsxs(Re,{className:"grid w-full grid-cols-3 bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg",children:[e.jsxs(O,{value:"server",className:"flex items-center gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-blue-500 data-[state=active]:to-purple-600 data-[state=active]:text-white",children:[e.jsx(I,{className:"h-4 w-4"}),"API Server"]}),e.jsxs(O,{value:"mcpServer",className:"flex items-center gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-blue-500 data-[state=active]:to-purple-600 data-[state=active]:text-white",children:[e.jsx(F,{className:"h-4 w-4"}),"MCP Server"]}),e.jsxs(O,{value:"general",className:"flex items-center gap-2 data-[state=active]:bg-gradient-to-r data-[state=active]:from-blue-500 data-[state=active]:to-purple-600 data-[state=active]:text-white",disabled:!0,children:[e.jsx(Ne,{className:"h-4 w-4"}),"General"]})]}),e.jsxs(q,{value:"server",className:"mt-6",children:[g||v||K?e.jsx(Ss,{}):e.jsx(Ls,{serverConfig:t,setServerConfig:i,corsInput:n,setCorsInput:o,isLoading:s,isRestarting:c,setIsRestarting:x,onSave:Fe,onRestart:Oe,onAddCorsOrigin:qe,onRemoveCorsOrigin:Ve,isSaving:T.isPending,isRestartingServer:B.isPending}),e.jsx(Is,{port:t.port}),e.jsx(zs,{})]}),e.jsxs(q,{value:"mcpServer",className:"mt-6",children:[W||Z?e.jsx(ks,{}):e.jsx(As,{mcpServerConfig:Q,setMCPServerConfig:de,isLoading:s,isMCPRestarting:$e,setIsMCPRestarting:re,onSave:ze,onRestart:De,isSaving:T.isPending,isRestartingServer:J.isPending}),e.jsx(Os,{port:Q.port}),e.jsx(qs,{}),e.jsx(Ds,{})]}),e.jsx(q,{value:"general",children:e.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"General settings will be available in a future update"})})]})]})})}const ea=Gs;export{ea as component};
