84 lines
69 KiB
JavaScript
84 lines
69 KiB
JavaScript
import{c as E,u as he,a as qe,r as j,j as e,C as Y,L as Fe,b as k,d as Re,q as V,B as oe,e as Ie,E as ze,f as le,g as Be,h as Ae,i as Pe,k as Ge,l as ee,X as me,H as be,T as re,s as Oe,m as Te,n as q,o as U,p as He,S as ge,t as Qe,P as Ue,v as Ve,w as We,x as Ze,y as Je}from"./index-CewBeZjY.js";import{J as Xe}from"./JobsBar-C8WWQtK-.js";import{C as Ye}from"./code-xml-Lx72vTIt.js";import{R as et}from"./rotate-ccw-BIvkXC_w.js";import{C as ue,Z as de,L as tt,a as rt}from"./zap-DEJaO_AS.js";import{C as $e}from"./chevron-down-lw66P7XB.js";import{L as st}from"./layers-BJ9BGRJu.js";/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const nt=E("BrainCircuit",[["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:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["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:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const at=E("BrainCog",[["path",{d:"M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588 4 4 0 0 0 7.636 2.106 3.2 3.2 0 0 0 .164-.546c.028-.13.306-.13.335 0a3.2 3.2 0 0 0 .163.546 4 4 0 0 0 7.636-2.106 4 4 0 0 0 .556-6.588 4 4 0 0 0-2.526-5.77A3 3 0 1 0 12 5",key:"1kgmhc"}],["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"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m15.7 10.4-.9.4",key:"ayzo6p"}],["path",{d:"m9.2 13.2-.9.4",key:"1uzb3g"}],["path",{d:"m13.6 15.7-.4-.9",key:"11ifqf"}],["path",{d:"m10.8 9.2-.4-.9",key:"1pmk2v"}],["path",{d:"m15.7 13.5-.9-.4",key:"7ng02m"}],["path",{d:"m9.2 10.9-.9-.4",key:"1x66zd"}],["path",{d:"m10.5 15.7.4-.9",key:"3js94g"}],["path",{d:"m13.1 9.2.4-.9",key:"18n7mc"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const De=E("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ne=E("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ot=E("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const lt=E("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const dt=E("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const it=E("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ct=E("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const xt=E("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const mt=E("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ee=E("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ut=E("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const pt=E("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ht=E("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/**
|
||
* @license lucide-react v0.460.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const bt=E("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),gt=["fast","heavy","heavy_chars"],ft=["coder_lite","coder","coding_escalate_chars"];function yt(){const t=he(),{data:r,isLoading:h}=qe(),[a,c]=j.useState(null),[M,w]=j.useState(!1),[N,S]=j.useState(""),[b,z]=j.useState(0);if(j.useEffect(()=>{r!=null&&r.policy&&!a&&c({...r.policy})},[r,a]),h||!r||!a)return e.jsx("div",{className:"mc-card p-5 text-xs text-muted-foreground",children:"Lade Routing-Policy…"});const x=s=>r.fields.find(o=>o.key===s),g=Object.keys(a).some(s=>a[s]!==r.policy[s]),p=(s,o)=>{c(d=>d&&{...d,[s]:o}),S("")},i=s=>p(s,r.defaults[s]);async function L(){if(!a)return;const s={};for(const o of Object.keys(a))a[o]!==r.policy[o]&&(s[o]=a[o]);if(Object.keys(s).length!==0){w(!0),S("");try{const{policy:o}=await Re(s);c({...o}),t.invalidateQueries({queryKey:V.routingPolicy}),t.invalidateQueries({queryKey:V.routing}),z(Date.now()),setTimeout(()=>z(0),2e3)}catch(o){S(o.message||String(o))}finally{w(!1)}}}function A({k:s}){const o=x(s),d=a[s],G=a[s]===r.defaults[s];return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("label",{className:"text-[10px] font-semibold text-muted-foreground",children:o.label}),!G&&e.jsxs("button",{onClick:()=>i(s),className:"flex items-center gap-0.5 text-[9px] text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",title:`Auf Default zurücksetzen (${String(r.defaults[s])||"leer"})`,children:[e.jsx(et,{className:"h-2.5 w-2.5"})," Default"]})]}),o.type==="bool"?e.jsxs("button",{onClick:()=>p(s,!d),className:k("flex h-8 w-full items-center justify-between rounded-lg border px-3 text-[11px] font-semibold transition-all cursor-pointer",d?"border-emerald-500/40 bg-emerald-500/10 text-emerald-300":"border-border/40 bg-background/40 text-muted-foreground"),children:[e.jsx("span",{children:d?"An":"Aus"}),e.jsx("span",{className:k("h-3.5 w-3.5 rounded-full transition-colors",d?"bg-emerald-400":"bg-muted-foreground/40")})]}):o.type==="int"?e.jsx("input",{type:"number",value:d,min:o.min,max:o.max,"aria-label":o.label,onChange:B=>p(s,Number(B.target.value)),className:"h-8 w-full rounded-lg border border-border/40 bg-background/40 px-3 font-mono text-[11px] text-foreground outline-none focus:border-primary/50"}):e.jsx("input",{type:"text",value:d,"aria-label":o.label,spellCheck:!1,placeholder:s==="coder_lite"?"(leer = aus)":"",onChange:B=>p(s,B.target.value),className:"h-8 w-full rounded-lg border border-border/40 bg-background/40 px-3 font-mono text-[11px] text-foreground outline-none focus:border-primary/50"})]})}return e.jsxs("div",{className:"mc-card p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ut,{className:"h-4.5 w-4.5 text-primary"}),e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-foreground",children:"Lane-Routing & Policy"}),e.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-300 border border-emerald-500/20",children:"hot-reload"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[N&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-[280px] truncate",title:N,children:N}),b>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-emerald-400",children:[e.jsx(Y,{className:"h-3.5 w-3.5"})," gespeichert"]}),e.jsxs("button",{onClick:L,disabled:!g||M,className:k("h-8 px-4 rounded-lg text-[10px] font-bold uppercase tracking-wide transition-all flex items-center gap-1.5",g&&!M?"bg-primary text-primary-foreground hover:opacity-90 cursor-pointer shadow-md shadow-primary/10":"bg-background/40 text-muted-foreground/50 border border-border/40 cursor-not-allowed"),children:[M?e.jsx(Fe,{className:"h-3.5 w-3.5 animate-spin"}):null,"Speichern"]})]})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/70 leading-relaxed -mt-1",children:["Welches echte Modell hinter den virtuellen Lanes ",e.jsx("code",{className:"text-cyan-300",children:"chat"})," und"," ",e.jsx("code",{className:"text-cyan-300",children:"coding"})," steckt. Änderungen greifen sofort (kein Neustart). Die Keyword-Heuristiken bleiben im Code."]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-border/40 bg-background/25 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 pb-2",children:[e.jsx(it,{className:"h-4 w-4 text-teal-400"}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-foreground",children:"chat"}),e.jsx("span",{className:"text-[9px] text-muted-foreground/60 font-mono",children:"(= auto)"})]}),gt.map(s=>e.jsx(A,{k:s},s))]}),e.jsxs("div",{className:"rounded-xl border border-border/40 bg-background/25 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 pb-2",children:[e.jsx(Ye,{className:"h-4 w-4 text-indigo-400"}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-foreground",children:"coding"}),e.jsx("span",{className:"text-[9px] text-muted-foreground/60 font-mono",children:"(agentisch → immer Coder)"})]}),ft.map(s=>e.jsx(A,{k:s},s))]})]}),e.jsx("div",{className:"rounded-xl border border-border/40 bg-background/25 p-4",children:e.jsx("div",{className:"max-w-xs",children:e.jsx(A,{k:"fast_no_think"})})})]})}const fe=[{role:"hermes",label:"Lucys Hirn",short:"Hirn",icon:oe,desc:"Lucys Alltags-Verstand — denkt und redet mit dir. Immer bereit.",tone:"bg-indigo-500/15 text-indigo-400 border-indigo-500/25",protected:!0},{role:"embed",label:"Lucys Gedächtnis",short:"Gedächtnis",icon:Ie,desc:"Merkt sich Wichtiges und findet es später wieder.",tone:"bg-emerald-500/15 text-emerald-400 border-emerald-500/25",protected:!0},{role:"reranker",label:"Gedächtnis-Sortierer",short:"Sortierer",icon:dt,desc:"Ordnet gefundene Erinnerungen nach echter Relevanz — die Feinsortierung hinter dem Gedächtnis.",tone:"bg-lime-500/15 text-lime-400 border-lime-500/25"},{role:"vision",label:"Lucys Augen",short:"Augen",icon:ze,desc:"Sieht Bilder und Screenshots und beschreibt, was drauf ist.",tone:"bg-pink-500/15 text-pink-400 border-pink-500/25"},{role:"heavy",label:"Großes Hirn",short:"Groß",icon:at,desc:"Das schwere Geschütz — wird für besonders knifflige Fragen dazugeholt.",tone:"bg-amber-500/15 text-amber-400 border-amber-500/25"},{role:"coder-lite",label:"Programmierer (schnell)",short:"Code schnell",icon:ue,desc:"Schnelles Programmieren im Alltag.",tone:"bg-violet-500/15 text-violet-400 border-violet-500/25"},{role:"coder",label:"Programmierer",short:"Code",icon:ue,desc:"Baut und plant. Der Kopf der Coding-Mannschaft — er hält den Faden und verteilt Zuarbeit.",tone:"bg-fuchsia-500/15 text-fuchsia-400 border-fuchsia-500/25",protected:!0},{role:"scout",label:"Späher",short:"Späher",icon:ht,desc:"Schneller erster Blick und grobe Einschätzung.",tone:"bg-teal-500/15 text-teal-400 border-teal-500/25"},{role:"kritiker",label:"Kritiker",short:"Kritiker",icon:Ee,desc:"Liest dem Programmierer nach jeder Etappe gegen — bewusst aus einer FREMDEN Modellfamilie (Mistral statt Qwen), damit er andere blinde Flecken hat.",tone:"bg-cyan-500/15 text-cyan-400 border-cyan-500/25"}];fe.map(t=>t.role);const je=Object.fromEntries(fe.map(t=>[t.role,t])),ve=t=>({role:t||"?",label:t||"unbekannt",short:t||"?",icon:oe,desc:"Rolle ohne hinterlegten Klartext-Namen.",tone:"bg-slate-500/15 text-slate-300 border-slate-500/25"}),jt={fast:"hermes",coder_lite:"coder-lite"};function F(t){return t&&(je[t]||je[jt[t]])||ve(t)}function pe({role:t,dense:r=!1,className:h}){const a=F(t),c=a.icon;return e.jsxs("span",{className:k("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-semibold border tracking-wide",a.tone,h),title:`${a.desc} (${a.role})`,children:[e.jsx(c,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),r?a.short:a.label]})}function vt({fit:t}){const r={perfect:"bg-emerald-500/15 text-emerald-400 border border-emerald-500/20",marginal:"bg-amber-500/15 text-amber-400 border border-amber-500/20",too_tight:"bg-red-500/15 text-red-400 border border-red-500/20"}[t.level];return e.jsxs("span",{className:k("rounded px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider font-mono",r),children:[t.text," • ",t.req_gb," GB RAM"]})}function Ke(t){const r=t.toLowerCase();return r.includes("qwen")?{name:"Qwen",color:"bg-purple-500/20 text-purple-300 border-purple-500/30",initial:"Q"}:r.includes("gemma")?{name:"Gemma",color:"bg-blue-500/20 text-blue-300 border-blue-500/30",initial:"G"}:r.includes("llama")?{name:"Llama",color:"bg-red-500/20 text-red-300 border-red-500/30",initial:"🦙"}:r.includes("mistral")||r.includes("mixtral")?{name:"Mistral",color:"bg-orange-500/20 text-orange-300 border-orange-500/30",initial:"M"}:r.includes("deepseek")?{name:"DeepSeek",color:"bg-cyan-500/20 text-cyan-300 border-cyan-500/30",initial:"D"}:r.includes("hermes")||r.includes("nous")?{name:"Hermes",color:"bg-amber-500/20 text-amber-300 border-amber-500/30",initial:"H"}:r.includes("phi")?{name:"Phi",color:"bg-emerald-500/20 text-emerald-300 border-emerald-500/30",initial:"Φ"}:{name:"Other",color:"bg-slate-500/20 text-slate-300 border-slate-500/30",initial:"AI"}}function Nt(){var te,T,$;const t=he(),{data:r}=le(),{data:h}=Be(),{data:a}=Ae(),{data:c}=Pe(),{showAlert:M,dialogElement:w}=Ge(),[N,S]=j.useState(!1),[b,z]=j.useState(!1),x=(r==null?void 0:r.models)??[],g=(r==null?void 0:r.running)??[],p=(te=h==null?void 0:h.groups)==null?void 0:te.brains,i=(p==null?void 0:p.members)??[],L=u=>x.find(_=>_.name===u),A=u=>{var _;return((_=u.split("/").pop())==null?void 0:_.replace(/\.gguf$/i,""))||u},s=i.map(L).filter(Boolean),o=1024**3,d=c==null?void 0:c.budget,G=s.reduce((u,_)=>u+(_.size_bytes||0),0)/o,B=((T=a==null?void 0:a.gpu)==null?void 0:T.gtt_total)||(($=a==null?void 0:a.gpu)==null?void 0:$.vram_total)||0,C=(d==null?void 0:d.gtt_gb)||(B?B/o:0),v=(d==null?void 0:d.warm_projected_gb)??G,R=C>0?Math.min(100,v/C*100):0,K=x.filter(u=>!i.includes(u.name)&&!u.incomplete);async function I(u){z(!0);try{await Oe("brains",u,(p==null?void 0:p.swap)??!1,(p==null?void 0:p.persist)??!0),t.invalidateQueries({queryKey:V.groups}),t.invalidateQueries({queryKey:V.models}),t.invalidateQueries({queryKey:V.hermesBrain})}catch(_){M("Fehler",`Immer-bereit-Set konnte nicht geändert werden: ${(_==null?void 0:_.message)||_}`)}finally{z(!1)}}function O(u){const _=L(u);if(_&&F(_.role).protected){M("Geschützt",`„${F(_.role).label}" ist lebenswichtig und bleibt immer bereit.`);return}I(i.filter(H=>H!==u))}function W(u){S(!1),I([...i,u])}return p?e.jsxs("div",{className:"mc-card p-5 space-y-4",children:[e.jsx(Ne,{}),e.jsxs("div",{className:"space-y-1.5",children:[s.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Noch keine Modelle im Set."}),s.map(u=>{const _=g.includes(u.name),H=F(u.role).protected;return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border/30 bg-background/20 p-2.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:k("h-2 w-2 shrink-0 rounded-full ring-2 ring-black/40",_?"bg-emerald-500 animate-pulse":"bg-muted-foreground/40"),title:_?"Gerade warm (bereit)":"Reserviert — lädt bei Bedarf sofort"}),u.role&&e.jsx(pe,{role:u.role,dense:!0,className:"shrink-0"}),e.jsx("span",{className:"truncate font-mono text-xs font-semibold text-foreground",title:u.name,children:A(u.name)}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground/70",children:ee(u.size_bytes)})]}),H?e.jsx("span",{className:"shrink-0 text-[10px] font-semibold text-muted-foreground",title:"Lebenswichtig — bleibt immer im Set.",children:"🔒"}):e.jsx("button",{onClick:()=>O(u.name),disabled:b,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border/40 text-muted-foreground transition-colors hover:bg-red-500/5 hover:text-red-400 cursor-pointer disabled:opacity-50",title:"Aus dem Immer-bereit-Set nehmen (lädt dann nur noch bei Bedarf)",children:e.jsx(me,{className:"h-3.5 w-3.5"})})]},u.name)})]}),e.jsxs("button",{onClick:()=>S(!0),disabled:b||K.length===0,className:"flex h-8 w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-border/50 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground transition-colors hover:border-primary/40 hover:text-primary cursor-pointer disabled:opacity-50",children:[e.jsx(xt,{className:"h-3.5 w-3.5"})," Modell dauerhaft bereithalten"]}),e.jsxs("div",{className:"rounded-xl border border-border/30 bg-background/20 p-3",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between text-[11px]",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-semibold uppercase tracking-wider text-muted-foreground",title:"Modellgewichte + KV-Cache, berechnet aus den echten Architektur-Daten jedes Modells (Layer × KV-Köpfe × Kontext) und seiner KV-Quantisierung. So viel legt llama.cpp beim Laden wirklich für den eingestellten Kontext an — kein Aufschlag mehr.",children:[e.jsx(be,{className:"h-3.5 w-3.5"})," Reserviert fürs Set"]}),e.jsxs("span",{className:"font-mono font-bold text-foreground",children:[v.toFixed(1),C>0?` / ${C.toFixed(0)}`:""," GB"]})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full border border-border/30 bg-background/50",children:e.jsx("div",{className:k("h-full rounded-full transition-all duration-500",R>=85?"bg-red-500":R>=65?"bg-amber-500":"bg-teal-500"),style:{width:`${R}%`}})}),d&&!d.fits&&e.jsxs("p",{className:"mt-2 flex items-start gap-1.5 text-[11px] text-amber-400",children:[e.jsx(re,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{children:["Zusammen mit dem größten Gelegenheits-Modell (~",d.largest_ondemand_gb," GB) wird der Speicher knapp. Das Set bleibt dabei immer geladen — wird es wirklich eng, schlägt das Laden des großen Modells fehl (es wartet dann, statt das Set zu verdrängen)."]})]}),d&&d.fits&&e.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-emerald-400",children:[e.jsx(Y,{className:"h-3.5 w-3.5 shrink-0"})," Passt auch neben dem größten Gelegenheits-Modell — nichts wird verdrängt."]})]}),N&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",role:"dialog","aria-modal":"true","aria-label":"Modell zum Immer-bereit-Set hinzufügen",children:e.jsxs("div",{className:"w-full max-w-md space-y-3 rounded-2xl border border-border/80 bg-card p-6 shadow-2xl animate-in fade-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/20 pb-2",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-primary",children:"Dauerhaft bereithalten"}),e.jsx("button",{onClick:()=>S(!1),className:"rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground cursor-pointer",children:e.jsx(me,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Wähle ein Modell, das ohne Ladezeit bereitstehen soll:"}),e.jsx("div",{className:"max-h-60 space-y-1.5 overflow-y-auto pr-1",children:K.map(u=>e.jsxs("button",{onClick:()=>W(u.name),className:"flex w-full items-center justify-between gap-2 rounded-lg border border-border/30 bg-background/20 px-3 py-2.5 text-left transition-colors hover:bg-accent cursor-pointer",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.role&&e.jsx(pe,{role:u.role,dense:!0,className:"shrink-0"}),e.jsx("span",{className:"truncate font-mono text-xs font-semibold text-foreground",children:A(u.name)})]}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground/70",children:ee(u.size_bytes)})]},u.name))})]})}),w]}):e.jsxs("div",{className:"mc-card p-5",children:[e.jsx(Ne,{}),e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Es gibt noch kein Immer-bereit-Set. Es entsteht automatisch, sobald Lucys Hirn zugewiesen ist."}),w]})}function Ne(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"h-4.5 w-4.5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wide text-foreground",children:"Immer-bereit-Set"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Diese Modelle hält Lucy immer bereit — sie antworten ohne Ladezeit."})]})]})}function J({children:t,tone:r="muted"}){const h={muted:"bg-muted text-muted-foreground",primary:"bg-primary/15 text-primary",warn:"bg-amber-500/15 text-amber-500"};return e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[11px] font-medium ${h[r]}`,children:t})}function kt({caps:t}){return t?e.jsxs("span",{className:"inline-flex flex-wrap gap-1",children:[t.coder&&e.jsx(J,{children:"💻 Code"}),t.vision&&e.jsx(J,{children:"👁 Bild"}),t.reasoning&&e.jsx(J,{children:"🧠 Reason"}),t.moe&&e.jsxs(J,{tone:"primary",children:["🧩 MoE",t.active_b?`·${t.active_b}b`:""]}),t.tools==="yes"&&e.jsx(J,{tone:"primary",children:"🛠 Tools"}),t.tools==="likely"&&e.jsx(J,{tone:"warn",children:"🛠 Tools?"}),t.embedding&&e.jsx(J,{children:"🔢 Embed"})]}):null}function wt({model:t,onClose:r,onChanged:h}){var L,A;const{data:a,isLoading:c}=Te(t.gguf_path),[M,w]=j.useState(null),[N,S]=j.useState(""),b=a==null?void 0:a.target_vocab,z=(a==null?void 0:a.drafts)??[],x=z.filter(s=>s.compatible===!0),g=t.spec_draft_model;async function p(s){w(s??"__clear__"),S("");try{await q(`/api/models/${encodeURIComponent(t.name)}/draft`,{method:"POST",body:JSON.stringify({draft_path:s})}),h(),r()}catch(o){S(String((o==null?void 0:o.message)||o)),w(null)}}const i=s=>{var o;return s?`${s.pre??"?"} · ${((o=s.n_vocab)==null?void 0:o.toLocaleString())??"?"} Tokens`:"—"};return e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-border/80 bg-card p-6 shadow-2xl space-y-4 animate-in fade-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/20 pb-2",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2",children:[e.jsx(de,{className:"h-4 w-4"})," Speculative Draft"]}),e.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",children:e.jsx(me,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground leading-relaxed",children:['Beschleunigt die Token-Generierung mit einem kleinen "Draft"-Modell. Voraussetzung: der Draft muss den ',e.jsx("strong",{className:"text-foreground",children:"exakt gleichen Tokenizer (Vocab)"})," haben wie das Modell — sonst lehnt llama.cpp es ab."]}),e.jsxs("div",{className:"rounded-lg border border-border/40 bg-background/30 px-3 py-2 text-[11px] font-mono flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:(L=t.name.split("/").pop())==null?void 0:L.replace(/\.gguf$/i,"")}),e.jsxs("span",{className:"text-foreground",children:["Vocab: ",i(b)]})]}),t.spec_active&&g&&e.jsxs("div",{className:"rounded-lg border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-400 font-mono flex items-center gap-1.5 truncate",children:[e.jsx(Y,{className:"h-3.5 w-3.5 shrink-0"})," Aktiv: ",g]}),e.jsx("button",{onClick:()=>p(null),disabled:M!==null,className:"h-6 px-2.5 rounded border border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/10 text-amber-400 text-[9px] font-bold uppercase shrink-0 cursor-pointer disabled:opacity-50",children:"Deaktivieren"})]}),!(a!=null&&a.target_exists)&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] text-amber-400 flex items-center gap-2",children:[e.jsx(re,{className:"h-3.5 w-3.5 shrink-0"}),"Modell-GGUF noch nicht vorhanden — Spec-Draft ist nach dem Download konfigurierbar."]}),e.jsx("div",{className:"space-y-1.5 max-h-64 overflow-y-auto pr-1",children:c?e.jsx("div",{className:"text-xs text-muted-foreground py-6 text-center",children:"Prüfe Vocab-Kompatibilität…"}):z.length===0?e.jsxs("div",{className:"text-[11px] text-muted-foreground border border-dashed border-border/50 rounded-lg p-4 text-center",children:["Keine Draft-Modelle in ",e.jsx("code",{className:"font-mono",children:"/srv/models/drafts"}),". Lade ein kleines same-family-Modell (z.B. Qwen3-0.6B) und lege es dort ab."]}):z.map(s=>{var G,B;const o=s.filename===g,d=s.compatible===!0;return e.jsxs("div",{className:k("rounded-lg border px-3 py-2 flex items-center justify-between gap-2 text-left",d?"border-border/40 bg-background/20":"border-border/20 bg-background/10 opacity-60",o&&"border-primary/40 bg-primary/10"),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-[11px] font-mono font-semibold text-foreground truncate flex items-center gap-1.5",children:[s.filename,s.mtp&&e.jsx("span",{className:"shrink-0 rounded bg-indigo-500/15 px-1.5 py-0.5 text-[8px] font-bold uppercase tracking-wider text-indigo-400 border border-indigo-500/25",title:"MTP-Kopf (Multi-Token-Prediction) — by-construction vocab-identisch, höchste Akzeptanzrate",children:"MTP"})]}),e.jsxs("div",{className:"text-[9px] text-muted-foreground font-mono",children:[ee(s.size_bytes)," · Vocab: ",i(s.vocab)]})]}),d?o?e.jsxs("span",{className:"text-[9px] font-bold uppercase text-primary flex items-center gap-1 shrink-0",children:[e.jsx(Y,{className:"h-3.5 w-3.5"})," Aktiv"]}):e.jsx("button",{onClick:()=>p(s.path),disabled:M!==null,className:"h-7 px-3 rounded-lg border border-emerald-500/30 bg-emerald-500/5 hover:bg-emerald-500/15 text-emerald-400 text-[9px] font-bold uppercase shrink-0 cursor-pointer disabled:opacity-50",children:"Aktivieren"}):e.jsxs("span",{className:"text-[9px] font-bold uppercase text-amber-400/80 flex items-center gap-1 shrink-0",title:s.compatible===!1?`Inkompatibel: Tokenizer/Vocab weicht ab (Draft ${(G=s.vocab)==null?void 0:G.pre}/${(B=s.vocab)==null?void 0:B.n_vocab} ≠ Modell ${b==null?void 0:b.pre}/${b==null?void 0:b.n_vocab}).`:"Kompatibilität nicht prüfbar (Datei fehlt).",children:[e.jsx(re,{className:"h-3.5 w-3.5"})," ",s.compatible===!1?"Vocab ≠":"n/a"]})]},s.path)})}),!c&&(a==null?void 0:a.target_exists)&&z.length>0&&x.length===0&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] text-amber-400 leading-relaxed",children:["Kein vocab-kompatibler Draft verfügbar — Speculative Decoding ist für dieses Modell nicht möglich. Es braucht einen Draft mit identischem Tokenizer (pre=",e.jsx("span",{className:"font-mono",children:b==null?void 0:b.pre}),", n_vocab=",e.jsx("span",{className:"font-mono",children:(A=b==null?void 0:b.n_vocab)==null?void 0:A.toLocaleString()}),")."]}),N&&e.jsx("div",{className:"text-[10px] text-red-400 font-mono",children:N})]})})}const ke={hermes:{bar:"bg-indigo-500",dot:"bg-indigo-500",text:"text-indigo-400"},embed:{bar:"bg-emerald-500",dot:"bg-emerald-500",text:"text-emerald-400"},vision:{bar:"bg-pink-500",dot:"bg-pink-500",text:"text-pink-400"},heavy:{bar:"bg-amber-500",dot:"bg-amber-500",text:"text-amber-400"},"coder-lite":{bar:"bg-violet-500",dot:"bg-violet-500",text:"text-violet-400"},coder:{bar:"bg-fuchsia-500",dot:"bg-fuchsia-500",text:"text-fuchsia-400"},scout:{bar:"bg-teal-500",dot:"bg-teal-500",text:"text-teal-400"},kritiker:{bar:"bg-cyan-500",dot:"bg-cyan-500",text:"text-cyan-400"},reranker:{bar:"bg-lime-500",dot:"bg-lime-500",text:"text-lime-400"}},Mt={fast:"hermes",coder_lite:"coder-lite"},we={bar:"bg-slate-400",dot:"bg-slate-400",text:"text-slate-300"};function ae(t){return t&&(ke[t]||ke[Mt[t]])||we}const Me=1024**3,Se=t=>{var r;return((r=t.split("/").pop())==null?void 0:r.replace(/\.gguf$/i,""))??t};function St({running:t,capacityBytes:r,realUsedBytes:h,selected:a,onSelect:c}){const M=r>2*Me?r:124*Me,w=t.reduce((x,g)=>x+(g.size_bytes||0),0),N=Math.max(0,h-w),S=Math.max(0,M-Math.max(w,h)),b=S/M*100,z=N/M*100;return e.jsxs("div",{className:"mc-card p-5",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-end justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Modell-Speicher (GPU-Pool)"}),e.jsxs("div",{className:"font-space text-xl font-bold tracking-tight text-foreground",children:[U(M)," GB ",e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"gesamt"})]})]})]}),e.jsxs("div",{className:"text-right text-[11px] font-mono text-muted-foreground",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-bold text-foreground",children:[U(w)," GB"]})," Modell-Gewichte"]}),N>0&&e.jsxs("div",{children:[U(N)," GB KV-Cache & Betrieb"]}),e.jsxs("div",{className:"text-emerald-400",children:[U(S)," GB frei"]})]})]}),e.jsx("div",{className:"flex h-12 w-full overflow-hidden rounded-xl border border-border/40 bg-background/50 p-1",children:t.length===0?e.jsx("div",{className:"flex w-full items-center justify-center text-[11px] italic text-muted-foreground/60",children:"Kein Modell geladen — Auto-Swap holt bei Anfrage automatisch das passende."}):e.jsxs(e.Fragment,{children:[t.map(x=>{const g=(x.size_bytes||0)/M*100,p=ae(x.role),i=a===x.name;return e.jsxs("button",{onClick:()=>c==null?void 0:c(x.name),style:{width:`${g}%`},title:`${F(x.role).label} · ${Se(x.name)} · ${ee(x.size_bytes)}`,className:k("group flex h-full min-w-[2.5rem] shrink-0 flex-col justify-center gap-0.5 rounded-lg px-2 text-left text-white transition-all",p.bar,i?"ring-2 ring-white/70":"opacity-90 hover:opacity-100"),children:[e.jsx("span",{className:"truncate font-space text-[10px] font-bold leading-tight tracking-wide",children:F(x.role).short}),e.jsx("span",{className:"truncate font-mono text-[9px] leading-tight opacity-85",children:ee(x.size_bytes)})]},x.name)}),z>1.5&&e.jsx("div",{style:{width:`${z}%`},className:"flex h-full min-w-[2rem] items-center justify-center rounded-lg border border-dashed border-border/60 bg-background/40 text-[9px] font-mono text-muted-foreground/70",title:`${U(N)} GB KV-Cache & Betrieb (reale Belegung über den Modell-Gewichten)`,children:"KV"}),b>1.5&&e.jsx("div",{style:{width:`${b}%`},className:"flex h-full min-w-[2rem] items-center justify-center rounded-lg text-[9px] font-mono text-muted-foreground/50",title:`${U(S)} GB frei`,children:"frei"})]})}),t.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-x-4 gap-y-1.5",children:[t.map(x=>{const g=ae(x.role);return e.jsxs("button",{onClick:()=>c==null?void 0:c(x.name),className:"flex items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx("span",{className:k("h-2.5 w-2.5 rounded-sm",g.dot)}),e.jsx("span",{className:k("font-semibold",g.text),children:F(x.role).short}),e.jsx("span",{className:"font-mono text-muted-foreground/70",children:Se(x.name)})]},x.name)}),N>0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/60",title:"Reale Belegung über den Modell-Gewichten (Kontext-Speicher der laufenden Modelle)",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-sm border border-dashed border-border/60 bg-background/40"})," KV-Cache & Betrieb · ",U(N)," GB"]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/60",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-sm border border-border/50 bg-background/50"})," frei · ",U(S)," GB"]})]})]})}const Ce=1024**3,X=t=>{var r;return((r=t.split("/").pop())==null?void 0:r.replace(/\.gguf$/i,""))??t};function Ct(){var n,f,D,Q;const t=he(),{data:r,isLoading:h,error:a}=le(),{data:c}=Ae(),{data:M}=Be(),{showAlert:w,showConfirm:N,showPrompt:S,dialogElement:b}=Ge(),z=He(),x=(r==null?void 0:r.models)??[],g=(r==null?void 0:r.running)??[],p=l=>!!F(l).protected,i=(n=M==null?void 0:M.groups)==null?void 0:n.brains,L=(i==null?void 0:i.members)??[],A=l=>L.includes(l),[s,o]=j.useState(null),[d,G]=j.useState(""),[B,C]=j.useState("all"),[v,R]=j.useState(null),K=()=>{t.invalidateQueries({queryKey:V.models}),t.invalidateQueries({queryKey:V.routing}),t.invalidateQueries({queryKey:V.groups})},I=x.filter(l=>g.includes(l.name)),O=((f=c==null?void 0:c.gpu)==null?void 0:f.gtt_total)||((D=c==null?void 0:c.gpu)==null?void 0:D.vram_total)||0,W=((Q=c==null?void 0:c.gpu)==null?void 0:Q.gtt_used)||0,te=O>2*Ce?O:124*Ce,T=j.useMemo(()=>{const l=d.trim().toLowerCase();return x.filter(m=>B==="in_use"?!!m.role||g.includes(m.name):!0).filter(m=>l?m.name.toLowerCase().includes(l):!0).sort((m,y)=>{const P=g.includes(m.name)?0:1,Z=g.includes(y.name)?0:1;return P!==Z?P-Z:X(m.name).localeCompare(X(y.name))})},[x,g,B,d]),$=x.find(l=>l.name===s)??null;async function u(l){try{await q(`/api/models/${encodeURIComponent(l)}/load`,{method:"POST"}),K()}catch(m){w("Fehler",`Laden fehlgeschlagen: ${m.message||m}`)}}async function _(l){const m=L.some(y=>g.includes(y));if(i&&m&&!A(l)){const y=L.filter(P=>g.includes(P)).map(X).join(", ");N("Verdrängt das Hirn?",`„${X(l)}" ist nicht ko-resident. Beim Laden wirft es das warme Hirn (${y}) raus — Lucy verliert Hirn bzw. Augen.
|
||
|
||
Trotzdem exklusiv laden?`,()=>u(l));return}u(l)}async function H(l){const m=x.find(y=>y.name===l);if(m&&p(m.role)){w("Geschützt",`„${F(m.role).label}" ist lebenswichtig und bleibt geladen.`);return}try{await q(`/api/models/${encodeURIComponent(l)}/unload`,{method:"POST"}),K()}catch(y){w("Fehler",`Entladen fehlgeschlagen: ${y.message||y}`)}}async function ie(l,m){try{const y=await q(`/api/models/${encodeURIComponent(m)}/role`,{method:"POST",body:JSON.stringify({role:l||null})});K(),y!=null&&y.warning&&w("Rolle gesetzt — Hinweis",y.warning)}catch(y){w("Fehler",`Rolle zuweisen fehlgeschlagen: ${y.message||y}`)}}async function ce(l,m){let y=null;try{y=await q(`/api/models/${encodeURIComponent(l)}/ctx/auto`)}catch{}const P=y?`Optimal für dein Setup: ${(y.ctx/1024).toFixed(0)}k (${y.ctx}). »Auto« trägt diesen Wert ein.`:"Gib die gewünschte Kontextlänge in Tokens an:";S("Kontextlänge anpassen",P,String(m||32768),async Z=>{if(Z)try{await q(`/api/models/${encodeURIComponent(l)}/ctx`,{method:"POST",body:JSON.stringify({ctx:parseInt(Z,10)})}),K()}catch(ye){w("Fehler",`Kontext setzen fehlgeschlagen: ${ye.message||ye}`)}},void 0,y?{autoValue:String(y.ctx),autoLabel:`Auto (${(y.ctx/1024).toFixed(0)}k)`}:void 0)}async function xe(l){const m=x.find(y=>y.name===l);if(m&&p(m.role)){w("Geschützt",`„${F(m.role).label}" kann nicht gelöscht werden. Weise die Rolle zuerst einem anderen Modell zu.`);return}N("Modell löschen?",`„${X(l)}" und alle GGUF-Dateien unwiderruflich von der Box löschen?`,async()=>{try{await q(`/api/models/${encodeURIComponent(l)}`,{method:"DELETE"}),s===l&&o(null),K()}catch(y){w("Fehler",`Löschen fehlgeschlagen: ${y.message||y}`)}})}return h?e.jsx("div",{className:"py-16 text-center text-xs text-muted-foreground",children:"Werkbank wird geladen …"}):a?e.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400",children:["Gateway oder Engine nicht erreichbar (",String(a),")."]}):e.jsxs("div",{className:"space-y-5",children:[e.jsx(St,{running:I,capacityBytes:te,realUsedBytes:W,selected:s,onSelect:o}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.3fr)]",children:[e.jsxs("div",{className:"mc-card p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ge,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60"}),e.jsx("input",{value:d,onChange:l=>G(l.target.value),placeholder:"Modell suchen …",className:"h-8 w-full rounded-lg border border-border/40 bg-background/40 pl-8 pr-2 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-primary/50 focus:outline-none"})]}),e.jsx("div",{className:"flex rounded-lg border border-border/40 bg-background/30 p-0.5",children:["all","in_use"].map(l=>e.jsx("button",{onClick:()=>C(l),className:k("rounded-md px-2 py-1 text-[9px] font-bold uppercase transition-all cursor-pointer",B===l?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"),children:l==="all"?"Alle":"In Benutzung"},l))})]}),e.jsx("div",{className:"max-h-[60vh] space-y-1.5 overflow-y-auto scrollbar-thin pr-1",children:T.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-border/50 p-8 text-center text-xs text-muted-foreground",children:"Keine Modelle."}):T.map(l=>{const m=g.includes(l.name),y=s===l.name,P=Ke(l.name),Z=ae(l.role);return e.jsxs("button",{onClick:()=>o(l.name),className:k("flex w-full items-center gap-2.5 rounded-xl border p-2.5 text-left transition-all cursor-pointer",y?"border-primary/60 bg-primary/10":"border-border/40 bg-background/20 hover:border-primary/30 hover:bg-background/40"),children:[e.jsx("span",{className:k("flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border text-[10px] font-bold",P.color),children:P.initial}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-mono text-xs font-semibold text-foreground",children:X(l.name)}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[l.role&&e.jsx("span",{className:k("h-2 w-2 rounded-sm",Z.dot)}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l.role?F(l.role).short:"keine Rolle"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/50",children:["· ",ee(l.size_bytes)]})]})]}),m?e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[9px] font-bold uppercase text-emerald-400",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"}),"warm"]}):l.incomplete?e.jsx("span",{className:"shrink-0 text-[9px] font-bold uppercase text-amber-400",children:"⚠ fehlt"}):e.jsx("span",{className:"shrink-0 text-[9px] font-semibold uppercase text-muted-foreground/50",children:"bereit"})]},l.name)})})]}),e.jsx("div",{className:"mc-card p-5",children:$?e.jsx(_t,{m:$,warm:g.includes($.name),expert:z,protectedRole:p($.role),coresident:A($.name),onLoad:()=>_($.name),onUnload:()=>H($.name),onRole:l=>ie(l,$.name),onCtx:()=>ce($.name,$.ctx),onSpec:()=>R($),onDelete:()=>xe($.name)}):e.jsxs("div",{className:"flex h-full min-h-[16rem] flex-col items-center justify-center gap-2 text-center text-muted-foreground",children:[e.jsx(Qe,{className:"h-8 w-8 opacity-40"}),e.jsx("p",{className:"text-sm font-semibold",children:"Links ein Modell wählen"}),e.jsx("p",{className:"text-xs",children:"Dann verwaltest du es hier — laden, Rolle, Kontext, löschen."})]})})]}),v&&e.jsx(wt,{model:v,onClose:()=>R(null),onChanged:K}),b]})}function _t({m:t,warm:r,expert:h,protectedRole:a,coresident:c,onLoad:M,onUnload:w,onRole:N,onCtx:S,onSpec:b,onDelete:z}){const x=Ke(t.name),g=r&&a;return e.jsxs("div",{className:"flex h-full flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:k("flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border text-sm font-bold",x.color),children:x.initial}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"break-all font-mono text-sm font-bold text-foreground",children:X(t.name)}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[t.role?e.jsx(pe,{role:t.role}):e.jsx("span",{className:"rounded border border-dashed border-border/50 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"keine Rolle"}),a&&e.jsxs("span",{className:"rounded bg-background/40 px-1.5 py-0.5 text-[10px] text-muted-foreground",title:"Lebenswichtig — geschützt",children:[e.jsx(tt,{className:"mr-0.5 inline h-3 w-3"}),"geschützt"]}),c&&e.jsxs("span",{className:"rounded border border-fuchsia-500/30 bg-fuchsia-500/10 px-1.5 py-0.5 text-[10px] font-bold uppercase text-fuchsia-300",children:[e.jsx(oe,{className:"mr-0.5 inline h-3 w-3"}),"Ko-resident"]}),r&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] font-bold uppercase text-emerald-400",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"}),"warm"]})]})]})]}),e.jsxs("button",{onClick:r?w:M,disabled:t.incomplete&&!r||g,className:k("flex h-11 w-full items-center justify-center gap-2 rounded-xl border text-sm font-bold transition-all cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",r?"border-amber-500/40 bg-amber-500/10 text-amber-300 hover:bg-amber-500/20":"border-primary/40 bg-primary/10 text-primary hover:bg-primary/20"),title:g?`„${F(t.role).label}" bleibt geladen (geschützt).`:void 0,children:[r?e.jsx(mt,{className:"h-4 w-4"}):e.jsx(Ue,{className:"h-4 w-4"}),g?"🔒 bleibt geladen":r?"Entladen":"Ins Warm-Set laden"]}),e.jsxs("div",{className:"rounded-xl border border-border/30 bg-background/20 p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:[e.jsx("span",{children:"Rolle"}),a&&e.jsx("span",{className:"normal-case font-medium tracking-normal text-muted-foreground/70",children:"🔒 lebenswichtig — zum Tausch die Rolle woanders zuweisen"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(_e,{active:!t.role,onClick:()=>N(""),dot:"bg-slate-400",label:"keine",disabled:a}),fe.map(p=>e.jsx(_e,{active:t.role===p.role,onClick:()=>N(p.role),dot:ae(p.role).dot,label:p.short,disabled:a&&t.role!==p.role},p.role))]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsx(Lt,{icon:be,label:"Größe",value:ee(t.size_bytes)}),e.jsxs("button",{onClick:S,className:"group flex items-center gap-2 rounded-lg border border-border/30 bg-background/20 p-2.5 text-left transition-colors hover:border-primary/40 cursor-pointer",children:[e.jsx(ct,{className:"h-4 w-4 text-primary/80"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:"Kontext · ändern"}),e.jsx("div",{className:"font-semibold text-foreground",children:Ve(t.ctx)})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-border/30 bg-background/20 p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Beschleuniger"}),h&&e.jsxs("button",{onClick:b,className:k("flex h-6 items-center gap-1 rounded-lg border px-2 text-[9px] font-bold uppercase transition-colors cursor-pointer",t.spec_active?"border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10":t.spec_draft_model?"border-amber-500/30 text-amber-400 hover:bg-amber-500/10":"border-border/40 text-muted-foreground hover:bg-accent"),children:[e.jsx(de,{className:"h-3 w-3"})," Spec"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.spec_active&&e.jsx(se,{tone:"emerald",label:"Spec-Decoding aktiv"}),!t.spec_active&&t.spec_draft_model&&e.jsx(se,{tone:"amber",label:"Spec inaktiv"}),t.prompt_cache&&e.jsx(se,{tone:"cyan",label:"Prompt-Cache"}),t.parallel_slots>1&&e.jsx(se,{tone:"violet",label:`${t.parallel_slots} Slots`}),!t.spec_active&&!t.spec_draft_model&&!t.prompt_cache&&t.parallel_slots<=1&&e.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"keine aktiv"})]})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(kt,{caps:t.capabilities})}),e.jsxs("button",{onClick:z,disabled:a,className:k("mt-auto flex h-9 items-center justify-center gap-1.5 rounded-lg border text-xs font-semibold transition-colors",a?"cursor-not-allowed border-border/30 text-muted-foreground/40":"border-red-500/30 text-red-400 hover:bg-red-500/10 cursor-pointer"),children:[e.jsx(bt,{className:"h-3.5 w-3.5"})," ",a?"geschützt — nicht löschbar":"Modell löschen"]})]})}function _e({active:t,onClick:r,dot:h,label:a,disabled:c}){return e.jsxs("button",{onClick:r,disabled:c,title:c?"Gesperrt: dieses Modell hält eine lebenswichtige Rolle.":void 0,className:k("flex items-center gap-1.5 rounded-lg border px-2 py-1 text-[10px] font-semibold transition-all",c?"cursor-not-allowed opacity-40 border-border/40 bg-background/20 text-muted-foreground":t?"cursor-pointer border-primary/60 bg-primary/15 text-foreground":"cursor-pointer border-border/40 bg-background/20 text-muted-foreground hover:border-primary/30"),children:[e.jsx("span",{className:k("h-2 w-2 rounded-sm",h)}),a,t&&e.jsx(Y,{className:"h-3 w-3 text-primary"})]})}function Lt({icon:t,label:r,value:h}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/30 bg-background/20 p-2.5",children:[e.jsx(t,{className:"h-4 w-4 text-primary/80"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:r}),e.jsx("div",{className:"font-semibold text-foreground",children:h})]})]})}function se({tone:t,label:r}){const h={emerald:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",amber:"bg-amber-500/10 text-amber-400 border-amber-500/20",cyan:"bg-cyan-500/10 text-cyan-400 border-cyan-500/20",violet:"bg-violet-500/10 text-violet-400 border-violet-500/20"}[t];return e.jsx("span",{className:k("rounded border px-1.5 py-0.5 text-[10px] font-semibold",h),children:r})}const zt=[{key:"popular",label:"Beliebt",q:""},{key:"coder",label:"Coder",q:"coder"},{key:"vision",label:"Vision",q:"vision"},{key:"reasoning",label:"Reasoning",q:"reasoning"},{key:"small",label:"Klein (≤4B)",q:"3B"}],Bt=["fast","heavy","coder","vision","hermes","scout"],At=new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1});function Le(t){return At.format(t)}function Gt(){const{data:t}=le(),r=(t==null?void 0:t.models)??[],[h,a]=j.useState(""),[c,M]=j.useState([]),[w,N]=j.useState(!1),[S,b]=j.useState(""),[z,x]=j.useState("popular"),[g,p]=j.useState(""),[i,L]=j.useState(null),[A,s]=j.useState([]),[o,d]=j.useState("Q4_K_M"),[G,B]=j.useState(""),[C,v]=j.useState(null),[R,K]=j.useState(!1),[I,O]=j.useState({});async function W(n){N(!0),b("");try{const f=await q(`/api/hf/search?q=${encodeURIComponent(n)}`);M(f.results),f.results.length||b("Keine Ergebnisse.")}catch(f){b(`Suche fehlgeschlagen: ${f}`)}finally{N(!1)}}j.useEffect(()=>{W("")},[]);function te(n){x(n.key),a(""),W(n.q)}function T(){x(""),W(h)}async function $(n,f,D){K(!1);try{const Q=await q(`/api/fit?params_b=0&quant=${encodeURIComponent(f)}&ctx=8192&name=${encodeURIComponent(n)}&role=${encodeURIComponent(D)}`);v(Q)}catch{v(null)}}async function u(n){if(i===n){L(null);return}L(n),s([]),v(null),B(""),K(!1),b("Analysiere Repository…");try{const f=await q(`/api/hf/quants?repo=${encodeURIComponent(n)}`);s(f.quants);const D=f.quants.includes("Q4_K_M")?"Q4_K_M":f.quants[0]||"Q4_K_M";d(D),b(f.quants.length?"":"Keine GGUF-Dateien in diesem Repo gefunden."),f.quants.length&&$(f.repo,D,"")}catch(f){b(`Fehler: ${f}`)}}function _(){const n=g.trim();n&&(M(f=>f.some(D=>D.repo===n)?f:[{repo:n,downloads:0,likes:0},...f]),p(""),u(n))}const H=G?r.find(n=>(n.role||"").toLowerCase()===G):void 0;async function ie(n){if((C==null?void 0:C.fit.level)==="too_tight"&&!R){K(!0);return}O(f=>({...f,[n]:"Starte…"}));try{await q("/api/models/install",{method:"POST",body:JSON.stringify({repo:n,quant:o,role:G||void 0,jinja:!0})}),O(f=>({...f,[n]:"Download läuft"})),K(!1)}catch{O(D=>({...D,[n]:"Fehler"}))}}const ce=n=>{var D;const f=((D=n.split("/").pop())==null?void 0:D.toLowerCase().replace(/-gguf$/i,""))||"";return f.length>3&&r.some(Q=>Q.name.toLowerCase().includes(f))},xe=n=>n==="perfect"?"text-emerald-400 border-emerald-500/40 bg-emerald-500/10":n==="marginal"?"text-amber-400 border-amber-500/40 bg-amber-500/10":"text-red-400 border-red-500/40 bg-red-500/10";return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ge,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx("input",{value:h,onChange:n=>a(n.target.value),onKeyDown:n=>n.key==="Enter"&&T(),"aria-label":"HuggingFace durchsuchen",type:"search",spellCheck:!1,placeholder:"HuggingFace durchsuchen (z.B. Qwen Coder, Llama-3.1, gemma)…",className:"w-full h-10 pl-9 pr-3 rounded-xl border border-border/60 bg-background/40 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"})]}),e.jsx("button",{onClick:T,className:"h-10 px-5 rounded-xl bg-primary text-primary-foreground text-xs font-semibold hover:opacity-90 transition-all cursor-pointer",children:"Suchen"})]}),e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:zt.map(n=>e.jsxs("button",{onClick:()=>te(n),className:k("flex items-center gap-1.5 rounded-full px-3 py-1.5 text-[11px] font-semibold transition-all cursor-pointer border",z===n.key?"bg-primary/15 text-primary border-primary/30":"border-border/50 text-muted-foreground hover:text-foreground hover:border-border"),children:[n.key==="popular"&&e.jsx(ot,{className:"h-3 w-3"}),n.label]},n.key))}),w?e.jsx("div",{className:"text-xs text-muted-foreground py-10 text-center",children:"Lade GGUF-Modelle von HuggingFace…"}):e.jsxs("div",{className:"space-y-2",children:[c.map(n=>{const f=i===n.repo,D=ce(n.repo),Q=n.repo.includes("/")?n.repo.split("/")[0]:"—",l=n.repo.split("/").pop();return e.jsxs("div",{className:k("mc-card-sm",f?"border-primary/40 shadow-lg shadow-primary/5":"border-border/50 hover:border-primary/30"),children:[e.jsxs("button",{onClick:()=>u(n.repo),className:"w-full flex items-center gap-3 p-3.5 text-left cursor-pointer",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-bold font-mono text-foreground truncate max-w-[280px]",title:n.repo,children:l}),D&&e.jsxs("span",{className:"flex items-center gap-1 text-[8px] font-bold text-emerald-400 uppercase tracking-wider bg-emerald-500/10 border border-emerald-500/20 px-1.5 py-0.5 rounded",children:[e.jsx(Y,{className:"h-2.5 w-2.5"})," installiert"]})]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-3 mt-0.5 font-mono",children:[e.jsx("span",{children:Q}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ne,{className:"h-3 w-3"})," ",Le(n.downloads)]}),n.likes>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lt,{className:"h-3 w-3"})," ",Le(n.likes)]})]})]}),f?e.jsx(De,{className:"h-4 w-4 text-muted-foreground shrink-0"}):e.jsx($e,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),f&&e.jsx("div",{className:"border-t border-border/30 p-3.5 space-y-3",children:A.length===0?e.jsx("div",{className:"text-[11px] text-muted-foreground font-mono",children:S||"Lade Quants…"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"Quant"}),e.jsx("select",{value:o,onChange:m=>{d(m.target.value),$(n.repo,m.target.value,G)},"aria-label":"Quantisierung",className:"h-8 rounded-lg border border-border/60 bg-background/40 px-2 text-xs text-foreground font-semibold outline-none",children:A.map(m=>e.jsx("option",{value:m,className:"bg-popover text-foreground",children:m},m))}),e.jsx("label",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground ml-1",children:"Rolle"}),e.jsxs("select",{value:G,onChange:m=>{B(m.target.value),$(n.repo,o,m.target.value)},"aria-label":"Rolle",title:"Optional — bestimmt Auto-Konfiguration + setup-bewussten Kontext",className:"h-8 rounded-lg border border-border/60 bg-background/40 px-2 text-xs text-foreground font-semibold outline-none",children:[e.jsx("option",{value:"",className:"bg-popover text-foreground",children:"keine"}),Bt.map(m=>e.jsx("option",{value:m,className:"bg-popover text-foreground",children:m},m))]}),e.jsx("button",{onClick:()=>ie(n.repo),disabled:!!I[n.repo]&&I[n.repo]==="Download läuft",className:k("h-8 px-3.5 ml-auto rounded-lg text-xs font-semibold transition-all cursor-pointer flex items-center gap-1.5",R?"bg-red-500 text-white hover:opacity-90":"bg-primary text-primary-foreground hover:opacity-90"),children:I[n.repo]?I[n.repo]:R?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-3.5 w-3.5"})," OOM — trotzdem laden"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"h-3.5 w-3.5"})," Herunterladen"]})})]}),C&&e.jsxs("div",{className:k("flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border px-3 py-2 text-[11px] font-medium",xe(C.fit.level)),children:[e.jsx("span",{className:"font-bold uppercase tracking-wide",children:C.fit.text}),e.jsxs("span",{className:"font-mono opacity-90",children:["~",C.params_b,"B · ~",C.fit.req_gb," GB / ",C.sys_ram_gb," GB · ~",C.fit.tps," t/s"]}),C.fit.level!=="too_tight"?e.jsxs("span",{className:"font-mono opacity-80",children:["ctx → ",(C.assigned_ctx/1024).toFixed(0),"k"]}):e.jsx("span",{className:"opacity-90",children:"— passt nicht, würde beim Laden abstürzen (OOM)."})]}),H&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-400",children:[e.jsx(re,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Rolle ",e.jsxs("strong",{children:["„",G,'"']})," hält aktuell ",e.jsx("strong",{children:H.name.split("/").pop()})," — wird beim Download übernommen."]})]})]})})]},n.repo)}),!c.length&&!w&&e.jsx("div",{className:"text-xs text-muted-foreground py-10 text-center",children:S||"Keine Ergebnisse."})]}),e.jsxs("div",{className:"border-t border-border/30 pt-4 flex flex-col sm:flex-row gap-2 items-stretch sm:items-center",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground shrink-0",children:"Direkt:"}),e.jsx("input",{value:g,onChange:n=>p(n.target.value),onKeyDown:n=>n.key==="Enter"&&_(),"aria-label":"Repository oder URL direkt eingeben",spellCheck:!1,placeholder:"org/repo oder HF-URL (z.B. unsloth/Qwen2.5-Coder-7B-Instruct-GGUF)",className:"flex-1 h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground font-mono"}),e.jsx("button",{onClick:_,className:"h-9 px-4 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer whitespace-nowrap",children:"Laden"})]})]})}const $t={fast:{title:"Schnelles Alltags-Hirn",desc:"Schnelle MoE-Antworten für Chat, Zusammenfassungen und alltägliche Aufgaben.",icon:de},heavy:{title:"Schweres Reasoning",desc:"Große Modelle für komplexe Logik, Mathematik und tiefgründiges Planen.",icon:oe},coder:{title:"Coden & Entwicklung",desc:"Autovervollständigung, Refactoring und Codegenerierung direkt in deiner IDE.",icon:ue},vision:{title:"Bilder & Vision",desc:"Verarbeitet Bilder, Screenshots und visuelle Diagramme in multimodalen Chats.",icon:ze},hermes:{title:"Lucys Hirn (Agent)",desc:"Lucys dauer-warmes Agent-Hirn mit Tool-Calling — bleibt ko-resident, lädt nie kalt nach.",icon:nt},scout:{title:"Multimodal-Allrounder",desc:"Multimodaler Allrounder für schnelle Antworten, Übersetzungen und Alltag.",icon:rt},kritiker:{title:"Kritisches Prüf-Hirn",desc:"Schärfer Blick für Fehler, Schwachstellen und Sicherheitslücken — denkt skeptisch, bevor du deployst.",icon:Ee},reranker:{title:"Gedächtnis-Sortierer",desc:"Sortiert und gewichtet gespeicherte Fakten nach Relevanz — damit die richtige Info sofort da ist.",icon:ge}};function Dt(){const{data:t,isLoading:r,error:h}=We(),{data:a}=le(),{data:c}=Ze(),M=(a==null?void 0:a.models)??[],w=h?String(h):"",[N,S]=j.useState({}),[b,z]=j.useState({}),[x,g]=j.useState("recommended");async function p(i,L,A,s){S(o=>({...o,[i]:"Starte..."}));try{await q("/api/models/install",{method:"POST",body:JSON.stringify({repo:i,role:L,quant:A,jinja:s})}),S(o=>({...o,[i]:"Download läuft"}))}catch{S(d=>({...d,[i]:"Fehler"}))}}return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex mc-card-sm p-1 w-fit",children:[["recommended","Empfohlen"],["browse","Stöbern & Suchen"]].map(([i,L])=>e.jsx("button",{onClick:()=>g(i),className:k("rounded-lg px-4 py-1.5 text-xs font-semibold tracking-wide transition-all cursor-pointer",x===i?"bg-primary text-primary-foreground shadow-md shadow-primary/10":"text-muted-foreground hover:text-foreground"),children:L},i))}),x==="browse"?e.jsx(Gt,{}):r?e.jsx("div",{className:"text-xs text-muted-foreground py-12 text-center",children:"Analysiere Hardware und suche passende GGUF-Empfehlungen…"}):w||!t?e.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400",children:["Empfehlungsdienst temporär nicht erreichbar (",w,")."]}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-[10px] font-mono text-muted-foreground bg-background/25 border border-border/40 p-4 rounded-xl flex flex-col sm:flex-row sm:items-center justify-between gap-3 shadow-sm",children:[e.jsxs("div",{children:["Modell-Registry geladen für ",e.jsxs("span",{className:"text-foreground font-bold",children:[t.sys_ram_gb," GB"]})," System-RAM."]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pt,{className:"h-3.5 w-3.5 text-primary fill-primary/20"}),e.jsx("span",{children:"Empfehlungen sind automatisch auf deine Box-Hardware optimiert."})]})]}),e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:t.categories.map(i=>{const L=$t[i.role]||{title:i.title||i.role,desc:"Spezifisches Modell für diese Systemrolle.",icon:st},A=L.icon,s=M.find(v=>v.role===i.role||(v.aliases||[]).includes(i.role)),o=c==null?void 0:c.model_list.find(v=>v.role===i.role),d=i.models.find(v=>v.repo===i.recommended)||i.models[0];if(!d)return null;const G=N[d.repo],B=i.models.filter(v=>v.repo!==i.recommended),C=!!b[i.role];return e.jsxs("div",{className:k("mc-card p-5 flex flex-col justify-between gap-5",s?"border-border/60":"border-primary/20 shadow-primary/5"),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 border border-primary/20 flex items-center justify-center text-primary shadow-sm shrink-0",children:e.jsx(A,{className:"h-5.5 w-5.5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold tracking-tight text-foreground",children:L.title}),e.jsxs("span",{className:"text-[9px] font-mono text-muted-foreground uppercase bg-background/50 px-1.5 py-0.5 rounded border border-border/30 inline-block mt-0.5",children:["Rolle: ",i.role]})]})]}),s?e.jsxs("span",{className:"flex items-center gap-1.5 text-[9px] font-bold text-emerald-400 uppercase tracking-wider bg-emerald-500/10 border border-emerald-500/20 px-2.5 py-1 rounded-lg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Aktiviert"]}):e.jsx("span",{className:"text-[9px] font-bold text-primary/70 uppercase tracking-wider bg-primary/10 border border-primary/20 px-2.5 py-1 rounded-lg",children:"Frei"})]}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:L.desc}),e.jsx("div",{className:"p-3.5 rounded-xl bg-background/35 border border-border/30 space-y-2.5",children:s?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-muted-foreground/60",children:"Aktive GGUF-Belegung"}),e.jsx("div",{className:"text-xs font-mono font-bold text-foreground truncate",title:s.name,children:s.name.split("/").pop()}),e.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2",children:[e.jsxs("span",{children:["Größe: ",Je(s.size_bytes||0)]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Quant: ",s.quant||"GGUF"]})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-primary/80",children:"Empfohlenes Modell"}),e.jsx("div",{className:"text-xs font-mono font-bold text-foreground truncate",title:d.name,children:d.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{children:["Ersteller: ",d.author]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Quant: ",d.quant]})]}),e.jsx("div",{className:"flex items-center gap-1.5 pt-0.5",children:e.jsx(vt,{fit:d.fit})})]})}),e.jsx("div",{className:"pt-1",children:s?o?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[9px] font-semibold text-amber-400 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-ping shrink-0"}),e.jsxs("span",{children:["Bessere Version in der Registry: ",o.repo.split("/").pop()]})]}),e.jsxs("button",{onClick:()=>p(o.repo,i.role,o.repo===d.repo&&d.quant||"Q4_K_M",d.caps.tools!=="no"),disabled:!!N[o.repo],className:"h-8 w-full flex items-center justify-center gap-1.5 rounded-lg bg-amber-500 text-black text-xs font-bold hover:bg-amber-400 disabled:opacity-50 transition-all cursor-pointer shadow-md shadow-amber-500/10",children:[e.jsx(ne,{className:"h-3.5 w-3.5"}),N[o.repo]||"Auf neue Version aktualisieren"]})]}):e.jsxs("div",{className:"h-8 flex items-center justify-center gap-1.5 text-[10px] font-bold text-emerald-400 uppercase tracking-wide bg-emerald-500/5 border border-emerald-500/10 rounded-lg select-none",children:[e.jsx(Y,{className:"h-4 w-4"})," Auf neuestem Stand"]}):e.jsxs("button",{onClick:()=>p(d.repo,i.role,d.quant||"Q4_K_M",d.caps.tools!=="no"),disabled:!!G,className:k("h-8 w-full flex items-center justify-center gap-1.5 rounded-lg text-xs font-bold transition-all cursor-pointer border",G?"border-primary/40 bg-primary/5 text-primary":"bg-primary text-primary-foreground hover:opacity-90 shadow-md shadow-primary/10"),children:[e.jsx(ne,{className:"h-3.5 w-3.5"}),G||"Optimales Modell einsetzen"]})})]}),B.length>0&&e.jsxs("div",{className:"border-t border-border/20 pt-3",children:[e.jsxs("button",{onClick:()=>z(v=>({...v,[i.role]:!C})),className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/80 hover:text-foreground transition-colors cursor-pointer",children:[C?e.jsx(De,{className:"h-3 w-3"}):e.jsx($e,{className:"h-3 w-3"}),e.jsxs("span",{children:["Alternative Empfehlungen anzeigen (",B.length,")"]})]}),C&&e.jsx("div",{className:"mt-2.5 space-y-2 max-h-36 overflow-y-auto pr-1 scrollbar-thin",children:B.map(v=>e.jsxs("div",{className:"p-2 rounded-lg bg-background/25 border border-border/20 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-mono font-bold text-foreground truncate",title:v.name,children:v.name}),e.jsxs("div",{className:"text-[9px] text-muted-foreground flex items-center gap-1.5 mt-0.5",children:[e.jsxs("span",{children:["Quant: ",v.quant]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:v.fit.text})]})]}),e.jsx("button",{onClick:()=>p(v.repo,i.role,v.quant||"Q4_K_M",v.caps.tools!=="no"),disabled:!!N[v.repo],className:"h-6 px-2.5 rounded bg-background/40 hover:bg-background/80 border border-border/40 text-[9px] font-bold text-foreground transition-all cursor-pointer shrink-0 disabled:opacity-50",children:N[v.repo]||"Installieren"})]},v.repo))})]})]},i.role)})})]})]})}const Et=[{id:"werkbank",label:"Werkbank"},{id:"routing",label:"Routing & Warm-Set"},{id:"discover",label:"Modelle finden"}];function Tt(){const[t,r]=j.useState("werkbank");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between sm:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent",children:"Modell-Manager"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Modelle verwalten, das Lane-Routing einstellen und Neues von HuggingFace holen."})]}),e.jsx("div",{className:"flex mc-card-sm p-1 self-start",children:Et.map(h=>e.jsx("button",{onClick:()=>r(h.id),className:k("rounded-lg px-4 py-1.5 text-xs font-semibold tracking-wide uppercase transition-all cursor-pointer",t===h.id?"bg-primary text-primary-foreground shadow-md shadow-primary/10":"text-muted-foreground hover:text-foreground"),children:h.label},h.id))})]}),e.jsx(Xe,{}),e.jsxs("div",{className:"transition-all duration-300",children:[t==="werkbank"&&e.jsx(Ct,{}),t==="routing"&&e.jsxs("div",{className:"space-y-5",children:[e.jsx(yt,{}),e.jsx(Nt,{})]}),t==="discover"&&e.jsx(Dt,{})]})]})}export{Tt as ModelsView};
|