Fuenfte Etappe. Der Ereignisstrom war bisher ein reiner Anstoss-Bus, und die
Messwerte holte sich das Frontend im 3-Sekunden-Takt selbst — zwei Dauer-Anfragen,
unabhaengig davon, ob sich etwas geaendert hatte (Befund B-12).
## Backend: /api/stream
routers/events.py bedient jetzt zwei Endpunkte aus EINEM Sammler:
/api/stream `invalidate` (bei Aenderung) + `metrik` (jede Sekunde)
/api/events nur `invalidate` — bleibt EINE Fassung lang stehen, weil ein
Browser-Tab nach einem Deploy noch das vorige Buendel halten kann
und dieses nur /api/events kennt
Dazu services/system.py → metrik_punkt(): ein bewusst LEICHTER Messpunkt.
`system_status()` waere hier falsch — es ruft `psutil.cpu_percent(interval=0.1)`
und blockiert damit den Event-Loop 100 ms je Aufruf (bei 1-s-Takt 10 % der Zeit),
plus den Versions-Check, den niemand sekuendlich braucht. Gemessen: 0,2 ms je
Punkt mit `interval=None`.
Token stehen als GESAMTZAEHLER im Ereignis, nicht als Rate. So bleibt der Server
zustandslos und ein verpasster Punkt verfaelscht nichts — der Klient rechnet die
Rate aus zwei Punkten.
Neu im Fingerabdruck: Jobs (Zustand + Fortschritt). Damit ist auch der 3-s-Poller
der System-Schublade nur noch Sicherheitsnetz.
## Was bewusst FEHLT
Kein `agent`-Thema fuer Lucys Denkschritte. MC2 kann Hermes' interne Schritte nicht
sehen, ohne dessen Quellcode zu patchen — per AGENTS.md verboten. Eine leere Leitung
zu bauen waere eine Zusage, die keiner einloest. Das betrifft die Agent-Matrix aus
§4.4 der Spezifikation; sie braucht zuerst eine Datenquelle.
## Frontend
lib/events.ts hoert auf /api/stream und schreibt `metrik` direkt in den
Metrik-Speicher. Der bleibt bewusst ein useSyncExternalStore AUSSERHALB von React
(nicht der Zustand-Store aus P3): Bei einem Wert pro Sekunde wuerde ein Store-Update
jede abonnierende Komponente neu rendern.
## Gedrosselt statt abgeschaltet — eine Korrektur am eigenen Entwurf
Der erste Wurf schaltete beide Poller bei stehendem Strom komplett ab (`false`).
Das waere falsch gewesen: Beide Antworten tragen mehr als Messwerte —
/api/system/status die Versions-Hashes fuer den Schienen-Fuss, /api/system/token-stats
die Gesamtsumme und die Cloud-Ersparnis, fuer die das Backend die Tarife aufloest
(die Preis-Logik ist dort die einzige Wahrheit; sie im Klienten nachzubauen waere
eine zweite). Beides waere eingefroren.
Jetzt 3 s → 60 s bei stehendem Strom: ein Zwanzigstel der Last, und die Randdaten
bleiben frisch. Die MESSWERTE selbst kommen aus dem Strom — useSystemHistory legt
den letzten Messpunkt ueber die Query-Antwort, damit Legende, Temperatur und
Betriebszeit nicht zwischen zwei Minuten-Abfragen stehen bleiben.
## Verifiziert
Server: 12 `metrik`-Ereignisse in den ersten 4 kB des Stroms (1/s)
Server-Log ueber die ganze Prozesslaufzeit: /api/system/status 3 Anfragen,
/api/system/token-stats 3 Anfragen — vorher waere das eine je 3 Sekunden gewesen
Browser: Statusleiste zaehlt live weiter (Speicher 14,6 → 12,9 GB, CPU 3 → 2 %,
Betriebszeit 1:22 → 1:23) bei NULL fetch-Aufrufen im 49-s-Fenster
Cockpit: beide Diagramme rendern (2 Container, 5 Flaechen)
/api/events antwortet weiterhin (Alt-Tab im Log)
Einschraenkung, ehrlich: Die Browser-Pane war waehrend der Messung verborgen, und
TanStack Query pausiert Intervalle in Hintergrund-Tabs. Die Null im Klienten ist
daher KEIN sauberer Beleg fuer die Drosselung — der Server-Log ist es. Nebenbefund:
Der Strom laeuft auch im Hintergrund-Tab weiter, die Poller nicht.
37/37 Tests gruen (4 neue fuer pushMetrik: Ratenbildung, Zaehler-Ruecksprung,
letzter Messpunkt; MAX_POINTS ist jetzt exportiert, damit der Deckel-Test nicht
wieder gegen eine veraltete Kopie prueft) · ESLint 0 Fehler · Einstieg 118 582 B
gzip / Budget 125 000.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
53 lines
39 KiB
JavaScript
53 lines
39 KiB
JavaScript
import{c as w,j as e,b as c,r as l,T as W,L as ae,E as ve,n as b,O as le,V as oe,X as de,J as Se,u as Ce,k as _e,x as ze,ar as Fe,af as Le,al as Ue,U as P,t as Ae,y as q,q as N}from"./index-Cx7RCLVH.js";import{R as F}from"./refresh-cw-C02wnoZb.js";import{F as Pe}from"./file-text-DCWu7Fnn.js";import{S as Be}from"./search-CPzoxwoE.js";import{S as ce}from"./shield-BEuf-cEX.js";import{A as ne}from"./arrow-right-CBVuzArl.js";import{C as De}from"./clock-DF_nrSqC.js";import{E as Re}from"./external-link-CgE4twbA.js";import{P as $e}from"./power-wqc9-u1c.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 Oe=w("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
|
||
* @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=w("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
|
||
* @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 Te=w("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);/**
|
||
* @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 Me=w("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["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 He=w("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/**
|
||
* @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 qe=w("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
|
||
* @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 ie=w("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/**
|
||
* @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 me=w("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
||
* @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 xe=w("Shuffle",[["path",{d:"M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22",key:"1wmou1"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 6h1.9c1.5 0 2.9.9 3.6 2.2",key:"10bdb2"}],["path",{d:"M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8",key:"vgxac0"}],["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}]]);/**
|
||
* @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 We=w("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);function B({icon:n,iconClass:d,name:i,status:m,available:s,busy:u,actionLabel:f,onAction:r}){return e.jsxs("div",{className:c("flex items-center gap-3 rounded-lg border px-3 py-2",s?"border-amber-500/30 bg-amber-500/5":"border-border/50 bg-background/20"),children:[e.jsx(n,{className:c("h-4 w-4 shrink-0",d)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs text-foreground truncate",children:i}),e.jsx("div",{className:c("text-[10px] truncate",s?"text-amber-400/90":"text-muted-foreground"),children:m})]}),e.jsx("button",{onClick:r,disabled:!s||u,className:c("text-[11px] font-semibold rounded-lg px-2.5 py-1 transition-colors shrink-0",s?"bg-primary text-primary-foreground hover:opacity-90 cursor-pointer":"border border-border/50 text-muted-foreground/40 cursor-default"),children:u?"…":f})]})}function Ge({label:n,ok:d,system:i,busy:m,onRestart:s,onLogs:u}){return e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-border/50 bg-background/20 px-3 py-2",children:[e.jsx("span",{className:c("w-1.5 h-1.5 rounded-full shrink-0",d===!0?"bg-emerald-500":d===!1?"bg-red-500":"bg-muted-foreground/40")}),e.jsxs("span",{className:"flex-1 text-xs text-foreground truncate",children:[n,i&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:" (root)"})]}),e.jsx("button",{onClick:s,disabled:m,title:"Neu starten",className:"text-muted-foreground hover:text-primary transition-colors disabled:opacity-50",children:e.jsx(F,{className:c("h-3.5 w-3.5",m&&"animate-spin")})}),e.jsx("button",{onClick:u,title:"Logs ansehen",className:"text-muted-foreground hover:text-primary transition-colors",children:e.jsx(Pe,{className:"h-3.5 w-3.5"})})]})}const Je=/\b(error|fehler|fail(ed|ure)?|fatal|critical|crit|panic|traceback|exception|denied|refused|unable|emerg|alert|oom|killed)\b/i,Ke=/\b(warn(ing)?|deprecat\w*|retry(ing)?|timeout|timed out|degraded|missing|not found|nicht gefunden)\b/i;function Ve(n){return Je.test(n)?"error":Ke.test(n)?"warn":"info"}const Ze={error:"text-red-400",warn:"text-amber-300",info:"text-cyan-300/80"};function Qe({service:n,text:d,loading:i,logStatus:m,onRefresh:s,onOpenSettings:u}){const[f,r]=l.useState(!1),[j,y]=l.useState(""),o=l.useRef(null),h=l.useMemo(()=>d?d.split(`
|
||
`).map(p=>({t:p,level:Ve(p)})):[],[d]),S=l.useMemo(()=>h.filter(p=>p.level!=="info").length,[h]),C=j.trim().toLowerCase(),g=h.filter(p=>(!f||p.level!=="info")&&(!C||p.t.toLowerCase().includes(C))),k=m==="password_required"||m==="incorrect_password";return e.jsxs("div",{className:"flex-1 flex flex-col min-h-[300px] border border-border/60 bg-black/50 rounded-xl overflow-hidden shadow-inner",children:[e.jsxs("div",{className:"flex h-10 items-center justify-between gap-2 px-3 border-b border-border/40 bg-black/30 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-mono text-muted-foreground shrink-0",children:[e.jsx(We,{className:"h-3 w-3 text-primary"}),e.jsx("span",{className:"hidden sm:inline",children:"stdout/stderr —"})," ",n]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Be,{className:"pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{value:j,onChange:p=>y(p.target.value),placeholder:"filtern…",className:"h-7 w-24 sm:w-36 rounded-md border border-border/50 bg-background/40 pl-6 pr-2 text-[10px] text-foreground outline-none focus:border-primary/50"})]}),e.jsxs("button",{onClick:()=>r(p=>!p),title:"Nur Fehler und Warnungen zeigen",className:c("flex h-7 items-center gap-1 rounded-md border px-2 text-[10px] font-semibold transition-colors",f?"border-amber-500/50 bg-amber-500/15 text-amber-300":"border-border/50 bg-background/20 text-muted-foreground hover:text-foreground"),children:[e.jsx(W,{className:"h-3 w-3"}),"Nur Probleme",S>0?` (${S})`:""]}),e.jsx("button",{onClick:s,disabled:i,title:"Neu laden",className:"flex h-7 w-7 items-center justify-center rounded-md border border-border/50 bg-background/20 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e.jsx(F,{className:c("h-3 w-3",i&&"animate-spin")})})]})]}),e.jsx("div",{ref:o,className:"flex-1 overflow-y-auto p-3 text-[10px] font-mono leading-relaxed scrollbar-thin select-text",children:k?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center space-y-3 p-6 text-center",children:[e.jsx(W,{className:"h-8 w-8 text-amber-400 animate-pulse animate-duration-1000"}),e.jsx("div",{className:"text-xs font-semibold text-amber-300",children:m==="incorrect_password"?"Falsches Sudo-Passwort hinterlegt.":"Sudo-Passwort für systemd-Dienste erforderlich."}),e.jsxs("p",{className:"max-w-xs text-[10px] leading-normal text-muted-foreground",children:["Für das Auslesen der systemd-Logs von ",n," werden Root-Rechte benötigt. Hinterlege dein Passwort in den Einstellungen."]}),e.jsx("button",{onClick:u,className:"mt-2 rounded-md bg-primary px-3 py-1.5 text-[10px] font-semibold text-primary-foreground transition-colors hover:bg-primary/95",children:"Sudo-Passwort eintragen"})]}):i&&!d?e.jsx("span",{className:"text-muted-foreground",children:"Lade Logs…"}):h.length===0?e.jsx("span",{className:"text-muted-foreground",children:"Keine Logeinträge vorhanden."}):g.length===0?e.jsx("span",{className:"text-muted-foreground",children:f?"Keine Fehler oder Warnungen — der Dienst läuft sauber. ✓":"Kein Treffer für den Filter."}):g.map((p,R)=>e.jsx("div",{className:c("whitespace-pre-wrap",Ze[p.level]),children:p.t||" "},R))})]})}function Xe({open:n,showAlert:d}){const[i,m]=l.useState(null),[s,u]=l.useState(""),[f,r]=l.useState(!1),[j,y]=l.useState(!1),[o,h]=l.useState(!1);async function S(){y(!0);try{m(await b("/api/maintenance/geheimnisse"))}catch(g){d("Nicht erreichbar",`Der Geheimnis-Zustand konnte nicht geladen werden: ${(g==null?void 0:g.message)||g}`)}finally{y(!1)}}l.useEffect(()=>{n&&(u(""),r(!1),S())},[n]);async function C(g){h(!0);try{const k=await b("/api/maintenance/geheimnisse",{method:"POST",body:JSON.stringify({schluessel:"hf_token",wert:g})});m(k),u(""),d(g?"Gespeichert":"Gelöscht",g?"Der Token liegt jetzt auf der Box — der Browser behält ihn nicht.":"Der Token wurde von der Box entfernt.")}catch(k){d("Fehlgeschlagen",(k==null?void 0:k.message)||String(k))}finally{h(!1)}}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Zugangsdaten & Schlüssel"}),e.jsx("p",{className:"text-[10px] leading-normal text-muted-foreground",children:"Geheimnisse liegen auf der Box (Datei mit Rechten 0600), nicht im Browser. Diese Seite zeigt nur, ob etwas gesetzt ist — den Wert bekommt sie nie zurück."})]}),e.jsxs("div",{className:"mc-card-sm space-y-1.5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold",children:[e.jsx(me,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),"Box-Sudo-Passwort — nicht mehr nötig"]}),e.jsxs("p",{className:"text-[10px] leading-normal text-muted-foreground",children:["Systemdienste, OS-Update und Neustart laufen passwortlos (",e.jsx("code",{className:"font-mono text-primary",children:"NOPASSWD"})," in",e.jsx("code",{className:"font-mono",children:" /etc/sudoers"}),"). Das frühere Feld hat nie etwas bewirkt und lag dabei im Browser-Speicher — es ist am 28.08.2026 ersatzlos entfallen. Verlangt ",e.jsx("code",{className:"font-mono",children:"sudo"})," auf der Box je doch ein Passwort, sagt die Wartung das im Klartext; das ist dann dort zu lösen."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:"hf-token",className:"flex items-center gap-1.5 text-xs font-semibold",children:[e.jsx(qe,{className:"h-4 w-4 text-violet-400","aria-hidden":"true"}),"HuggingFace-Token"]}),e.jsx("div",{className:"flex items-center gap-2 text-[11px]",children:j?e.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(ae,{className:"h-3 w-3 animate-spin","aria-hidden":"true"})," Zustand wird geladen …"]}):i!=null&&i.hf_token_gesetzt?e.jsxs("span",{className:"flex items-center gap-1.5 font-semibold text-emerald-400",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500","aria-hidden":"true"}),"Gesetzt",i.hf_token_aus_env?" (aus der Dienst-Umgebung)":""]}):e.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/50","aria-hidden":"true"}),"Nicht gesetzt"]})}),(i==null?void 0:i.hf_token_aus_env)&&e.jsxs("p",{className:"text-[9px] leading-normal text-amber-400/90",children:["Der Token kommt aus der Umgebung des Dienstes und hat Vorrang. Hier gespeicherte Werte bleiben wirkungslos, solange ",e.jsx("code",{className:"font-mono",children:"HF_TOKEN"})," gesetzt ist."]}),i&&!i.schreibbar&&e.jsx("p",{className:"text-[9px] leading-normal text-amber-400/90",children:"Die Ablage ist nicht beschreibbar — auf einem Entwicklungsrechner ohne den Modell-Ordner der Box ist das normal. Speichern würde hier ins Leere laufen."}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"hf-token",type:f?"text":"password",value:s,onChange:g=>u(g.target.value),autoComplete:"off",spellCheck:!1,placeholder:i!=null&&i.hf_token_gesetzt?"Neuen Token eingeben, um zu ersetzen":"hf_…",className:"h-10 w-full rounded-lg border border-border/60 bg-background/40 pl-3 pr-10 text-xs text-foreground outline-none transition-colors focus:border-primary"}),e.jsx("button",{type:"button",onClick:()=>r(!f),"aria-label":f?"Token verbergen":"Token anzeigen",className:"absolute inset-y-0 right-0 flex items-center pr-3 text-muted-foreground transition-colors hover:text-foreground",children:f?e.jsx(Me,{className:"h-4 w-4","aria-hidden":"true"}):e.jsx(ve,{className:"h-4 w-4","aria-hidden":"true"})})]}),e.jsxs("p",{className:"text-[9px] leading-normal text-muted-foreground",children:["Nötig für Modelle mit Zugangsschranke. Wird beim Download als",e.jsx("code",{className:"font-mono",children:" HF_TOKEN"})," an den Job gereicht und verlässt die Box nicht."]})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsxs("button",{onClick:()=>C(s.trim()),disabled:o||!s.trim(),className:"flex h-9 flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-lg bg-primary text-xs font-semibold text-primary-foreground shadow shadow-primary/10 transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-40",children:[o&&e.jsx(ae,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Auf der Box speichern"]}),e.jsx("button",{onClick:()=>C(null),disabled:o||!(i!=null&&i.hf_token_gesetzt),className:"flex h-9 cursor-pointer items-center justify-center rounded-lg border border-border/60 bg-background/20 px-4 text-xs font-semibold text-muted-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-40",children:"Löschen"})]})]})}function Ie({detail:n,maintenanceJob:d,onClose:i,onApply:m}){var j,y;const s=n.data,u={os:{icon:ce,cls:"text-cyan-400",title:"OS-Pakete (apt)"},engine:{icon:oe,cls:"text-violet-400",title:"Inferenz-Engine (llama.cpp)"},swap:{icon:xe,cls:"text-fuchsia-400",title:"Router (llama-swap)"},hermes:{icon:le,cls:"text-amber-400",title:"Hermes-Agent"}}[n.kind],f=u.icon,r=s?n.kind==="os"?(s.count??0)===0:n.kind==="hermes"?(s.behind??0)===0:s.installed_build!=null&&s.latest_build!=null&&s.latest_build<=s.installed_build:!0;return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative w-full max-w-lg max-h-[80vh] flex flex-col rounded-2xl border border-border/60 bg-card shadow-2xl font-sans text-foreground",children:[e.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-border/40 px-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{className:c("h-4.5 w-4.5",u.cls)}),e.jsx("h3",{className:"text-sm font-semibold",children:u.title})]}),e.jsx("button",{onClick:i,className:"flex h-7 w-7 items-center justify-center rounded-lg border border-border/40 text-muted-foreground hover:bg-accent transition-colors",children:e.jsx(de,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-5 text-xs space-y-3 scrollbar-thin",children:n.loading?e.jsxs("div",{className:"flex h-24 items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(F,{className:"h-4 w-4 animate-spin"})," Details werden geladen…"]}):s!=null&&s.error?e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/5 p-3 text-red-400",children:s.error}):e.jsxs(e.Fragment,{children:[(s==null?void 0:s.action_needed)!=null&&e.jsxs("div",{className:c("flex items-start gap-2 rounded-lg border p-3",s.action_needed?"border-amber-500/40 bg-amber-500/10":"border-emerald-500/40 bg-emerald-500/10"),children:[s.action_needed?e.jsx(W,{className:"h-4 w-4 text-amber-400 shrink-0 mt-0.5"}):e.jsx(Se,{className:"h-4 w-4 text-emerald-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:c("text-xs font-semibold",s.action_needed?"text-amber-300":"text-emerald-300"),children:["Musst du etwas tun? ",s.action_needed?"Ja":"Nein — die Box regelt das (Fangnetz)"]}),s.action_needed&&s.action_text&&e.jsx("div",{className:"mt-0.5 text-[11px] text-foreground/90",children:s.action_text})]})]}),(s==null?void 0:s.summary)&&e.jsxs("div",{className:"rounded-lg border border-primary/25 bg-primary/5 p-3 space-y-1",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-primary",children:"Was dieses Update bedeutet (Zusammenfassung der Box)"}),e.jsx("pre",{className:"whitespace-pre-wrap text-[11px] leading-relaxed text-foreground/90 font-sans",children:s.summary})]}),n.kind==="os"?e.jsxs(e.Fragment,{children:[((s==null?void 0:s.count)??0)===0?e.jsx("div",{className:"text-muted-foreground",children:"Keine Pakete zu aktualisieren — System ist aktuell."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-muted-foreground",children:[s.count," Paket(e) werden aktualisiert:"]}),e.jsx("div",{className:"space-y-1",children:s.packages.map(o=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border/40 bg-background/30 px-2.5 py-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-[11px] truncate",children:[e.jsx(ie,{className:"h-3 w-3 text-cyan-400 shrink-0"}),o.name]}),e.jsxs("span",{className:"flex items-center gap-1 font-mono text-[10px] text-muted-foreground shrink-0",children:[e.jsx("span",{children:o.current}),e.jsx(ne,{className:"h-3 w-3"}),e.jsx("span",{className:"text-emerald-400",children:o.candidate})]})]},o.name))})]}),(((j=s==null?void 0:s.held_back)==null?void 0:j.length)??0)>0&&e.jsxs("div",{className:"space-y-1.5 rounded-lg border border-border/40 bg-background/20 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-semibold text-muted-foreground",children:[e.jsx(De,{className:"h-3.5 w-3.5"})," Vom Hersteller zurückgestellt — kein Handeln nötig"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground leading-normal",children:"Diese Pakete gäbe es bereits, Ubuntu spielt sie aber gestaffelt aus (Phasen-Rollout) bzw. hält sie kurz zurück. Sie kommen bei einem der nächsten automatischen Läufe von selbst — das ist kein Fehler und nichts hängt fest."}),e.jsx("div",{className:"space-y-1",children:s.held_back.map(o=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border/30 bg-background/30 px-2.5 py-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-[11px] truncate",children:[e.jsx(ie,{className:"h-3 w-3 text-muted-foreground shrink-0"}),o.name]}),e.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0",children:o.reason==="phasing"?"Phasen-Rollout":"vorerst zurückgehalten"})]},o.name))})]})]}):n.kind==="engine"||n.kind==="swap"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 font-mono text-[11px]",children:[e.jsxs("span",{className:"rounded-md border border-border/40 bg-background/30 px-2 py-1",children:["Build ",(s==null?void 0:s.installed_build)??"?"]}),e.jsx(ne,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/5 px-2 py-1 text-emerald-400",children:["Build ",(s==null?void 0:s.latest_build)??"?"]})]}),((s==null?void 0:s.name)||(s==null?void 0:s.latest_tag))&&e.jsxs("div",{className:"text-muted-foreground",children:["Release: ",e.jsx("span",{className:"text-foreground",children:s==null?void 0:s.name}),s!=null&&s.latest_tag?` (${s.latest_tag})`:""]}),(s==null?void 0:s.url)&&e.jsxs("a",{href:s.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-primary hover:underline",children:["Original-Release-Notes auf GitHub ",e.jsx(Re,{className:"h-3 w-3"})]}),(s==null?void 0:s.body)&&e.jsxs("details",{className:"group",children:[e.jsx("summary",{className:"cursor-pointer text-[10px] text-muted-foreground hover:text-foreground",children:"Original-Notizen (englisch) anzeigen"}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap rounded-lg border border-border/40 bg-background/30 p-3 text-[10px] leading-relaxed text-muted-foreground max-h-60 overflow-y-auto scrollbar-thin",children:s.body})]})]}):(((y=s==null?void 0:s.commits)==null?void 0:y.length)??0)===0?e.jsx("div",{className:"text-muted-foreground",children:"Keine neuen Commits — Hermes-Agent ist bereits aktuell."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-muted-foreground",children:[s.behind," neue Commit(s) auf ",e.jsxs("span",{className:"font-mono text-foreground",children:["origin/",s.branch]}),":"]}),e.jsx("div",{className:"space-y-1",children:s.commits.map(o=>e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-border/40 bg-background/30 px-2.5 py-1.5",children:[e.jsx(He,{className:"h-3.5 w-3.5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] truncate",children:o.subject}),e.jsxs("div",{className:"font-mono text-[9px] text-muted-foreground",children:[o.hash," · ",o.when]})]})]},o.hash))})]}),n.kind!=="os"&&!r&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-border/40 bg-background/20 p-2.5",children:[e.jsx(me,{className:"h-3.5 w-3.5 text-emerald-400 shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground leading-normal",children:["Vor dem Update sichert die Box automatisch den alten Stand. Danach prüft sie den ganzen Stack per echter Anfrage — läuft etwas nicht, rollt sie von selbst zurück",n.kind==="hermes"?" und startet den Gateway neu":"","."]})]})]})}),e.jsxs("div",{className:"flex gap-3 border-t border-border/40 p-4 shrink-0",children:[e.jsx("button",{onClick:i,className:"h-9 flex-1 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold text-muted-foreground hover:bg-accent transition-colors cursor-pointer",children:"Schließen"}),e.jsx("button",{onClick:m,disabled:n.loading||r||!!d,title:d?`Update läuft bereits: ${d.label}`:void 0,className:"h-9 flex-1 rounded-lg bg-primary text-xs font-semibold text-primary-foreground hover:opacity-90 transition-all cursor-pointer disabled:opacity-40 disabled:cursor-default",children:d?"Update läuft…":"Jetzt aktualisieren"})]})]})]})}function ot({open:n,onClose:d,defaultTab:i="maintenance"}){var se,re;const m=Ce(),{showAlert:s,showConfirm:u,dialogElement:f}=_e(),{data:r}=ze(),{data:j}=Fe(),y=Le(3e3,n).data??[],{data:o}=Ue(void 0,n),[h,S]=l.useState("llama-swap"),[C,g]=l.useState(""),[k,p]=l.useState(!1),[R,G]=l.useState(null),[$,J]=l.useState({}),[_,v]=l.useState("maintenance"),[K,V]=l.useState(!1),[Z,O]=l.useState(""),[Q,X]=l.useState(!1),[ue,I]=l.useState(!1),[L,U]=l.useState(null),E=(j==null?void 0:j.services)??[],z=()=>P(m,N.jobs);function he(t){return t?new Date(t*1e3).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"Nie"}l.useEffect(()=>{n&&i&&v(i)},[n,i]),l.useEffect(()=>{n&&P(m,N.updates,N.services,N.jobs,N.zeitmaschine)},[n]);function T(t){p(!0),G(null),b(`/api/maintenance/logs?service=${t}&lines=150`).then(a=>{a.ok?g(a.text):(g(`Fehler beim Laden der Logs: ${a.err||"Unbekannter Fehler"}`),(a.status==="incorrect_password"||a.status==="password_required")&&G(a.status))}).catch(a=>g(`Fehler: ${a.message}`)).finally(()=>p(!1))}l.useEffect(()=>{!n||_!=="logs"||T(h)},[n,_,h]);function M(t){return(t==null?void 0:t.status)==="busy"?(s("Update läuft bereits",`Es läuft gerade „${t.running}". Bitte warte, bis es fertig ist.`),z(),!0):!1}function Y(t){return(t==null?void 0:t.status)==="password_required"||(t==null?void 0:t.status)==="incorrect_password"?(s("Box-Passwort nötig",(t.status==="incorrect_password"?"Das gespeicherte Box-Passwort stimmt nicht. ":"Für dieses Update braucht die Box dein Passwort. ")+"Bitte oben im Reiter „Einstellungen“ setzen bzw. korrigieren."),!0):t&&t.ok===!1?(s("Update fehlgeschlagen",t.err||"Unbekannter Fehler."),!0):!1}async function ge(t){const a={os:"os-update",engine:"engine-update",swap:"swap-update"}[t];try{const x=await b(`/api/maintenance/${a}`,{method:"POST"});if(M(x)||Y(x))return;z(),v("maintenance")}catch(x){s("Fehler",`Update konnte nicht starten: ${x.message}`)}}async function pe(){I(!0);try{const t=await b("/api/maintenance/hermes-update",{method:"POST"});if(M(t))return;z()}catch(t){s("Fehler",`Hermes-Update fehlgeschlagen: ${t.message}`)}finally{I(!1)}}async function D(t){U({kind:t,loading:!0,data:null});try{const a=await b(`/api/maintenance/update-details?kind=${t}`);U({kind:t,loading:!1,data:a})}catch(a){U({kind:t,loading:!1,data:{kind:t,error:a.message}})}}function fe(){const t=L==null?void 0:L.kind;U(null),t==="os"||t==="engine"||t==="swap"?ge(t):t==="hermes"&&pe()}function be(){var a;const t=[r!=null&&r.engine?"Engine":null,r!=null&&r.swap?"Router":null,(a=r==null?void 0:r.components)!=null&&a.some(x=>x.update===!0)?"Hermes-Agent":null,r!=null&&r.os?`OS (${r.os} Pakete)`:null].filter(Boolean);u("Alle Updates einspielen?",`Nacheinander in einem Job: ${t.join(" → ")}. Jeder Schritt sichert und prüft sich selbst; schlägt einer fehl, stoppt der Rest. (OS braucht das Box-Passwort aus den Einstellungen — fehlt es, wird OS übersprungen.)`,async()=>{try{const x=await b("/api/maintenance/update-all",{method:"POST"});if(M(x)||Y(x))return;if((x==null?void 0:x.status)==="nothing"){s("Nichts zu tun","Es stehen keine Updates aus.");return}z(),v("maintenance")}catch(x){s("Fehler",`„Alle aktualisieren" konnte nicht starten: ${x.message}`)}})}async function ye(){V(!0);try{await b("/api/maintenance/check-updates",{method:"POST"}),P(m,N.jobs,N.updates),v("maintenance")}catch(t){s("Fehler",`Fehler bei der Update-Suche: ${t.message}`)}finally{V(!1)}}async function je(t,a){try{await b("/api/models/install",{method:"POST",body:JSON.stringify({repo:t,role:a})}),s("Gestartet",`Modell-Upgrade für '${a}' (${t}) gestartet.`),z(),v("maintenance")}catch(x){s("Fehler",`Fehler beim Starten des Modell-Upgrades: ${x.message}`)}}async function Ne(){u("Reboot bestätigen","Bist du sicher, dass du das gesamte Host-System neu starten willst?",async()=>{try{await b("/api/maintenance/reboot",{method:"POST"}),s("Reboot","Reboot ausgelöst. System startet neu...",()=>d())}catch(t){s("Fehler",`Fehler beim Reboot: ${t.message}`)}})}async function ke(){X(!0),O("Snapshot wird erzeugt...");try{const t=await b("/api/system/backup",{method:"POST"});O(t.ok?`Snapshot erzeugt: ${t.snapshot} (${t.files.length} Komponenten)`:"Backup fehlgeschlagen."),P(m,N.zeitmaschine)}catch(t){O(`Fehler: ${t.message}`)}finally{X(!1)}}async function ee(t){J(a=>({...a,[t]:!0}));try{const a=await b("/api/maintenance/restart",{method:"POST",body:JSON.stringify({service:t})});a.ok?(s("Dienst neu gestartet",`Dienst ${t} wurde erfolgreich neu gestartet.`,()=>{_==="logs"&&h===t&&T(t)}),P(m,N.services,N.health,N.models)):s("Fehler",`Fehler beim Neustart: ${a.err||"Unbekannter Fehler"}`)}catch(a){s("Fehler",`Fehler beim Neustart: ${a.message}`)}finally{J(a=>({...a,[t]:!1}))}}async function we(t){try{await b(`/api/jobs/${t}/cancel`,{method:"POST"}),z()}catch(a){s("Fehler",`Fehler beim Abbrechen: ${a.message}`)}}const A=y.find(t=>(t.state==="running"||t.state==="queued")&&t.group==="maintenance"),te=(r?(r.os>0?1:0)+(r.engine?1:0)+(r.swap?1:0):0)+(((se=r==null?void 0:r.components)==null?void 0:se.filter(t=>t.update===!0).length)??0),H=(o==null?void 0:o.backups)??[];return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:c("fixed inset-0 bg-black/60 backdrop-blur-sm z-50 transition-opacity duration-300",n?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"),onClick:d}),e.jsxs("div",{className:c("fixed inset-y-0 right-0 w-full sm:w-[640px] bg-card/85 backdrop-blur-xl border-l border-border/60 shadow-2xl z-50 flex flex-col transform transition-transform duration-300 ease-in-out font-sans text-foreground",n?"translate-x-0":"translate-x-full"),children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center justify-between border-b border-border/40 px-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"h-4.5 w-4.5 text-primary"}),e.jsx("h2",{className:"text-sm font-semibold tracking-wide uppercase font-space",children:"OS-Zentrale & Pflege"})]}),e.jsx("button",{onClick:d,"aria-label":"System-Schublade schließen",className:"flex h-8 w-8 items-center justify-center rounded-lg border border-border/40 text-muted-foreground hover:bg-accent transition-colors cursor-pointer",children:e.jsx(de,{className:"h-4 w-4","aria-hidden":"true"})})]}),e.jsx("div",{className:"flex border-b border-border/40 px-6",children:["maintenance","logs","settings"].map(t=>e.jsx("button",{onClick:()=>v(t),className:c("flex-1 py-3 text-xs font-semibold uppercase tracking-wider border-b-2 text-center transition-all",_===t?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"),children:t==="maintenance"?"System-Wartung":t==="logs"?"System-Logs":"Einstellungen"},t))}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[_==="maintenance"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Updates"}),e.jsxs("div",{className:"flex items-center gap-3",children:[te>0&&e.jsxs("button",{onClick:be,disabled:!!A,className:"flex items-center gap-1 rounded-md border border-primary/40 bg-primary/10 px-2 py-1 text-[10px] font-bold text-primary transition-colors hover:bg-primary/20 disabled:opacity-50",children:[e.jsx(Te,{className:"h-3 w-3"})," Alle aktualisieren (",te,")"]}),e.jsxs("button",{onClick:ye,disabled:K||!!A,className:"flex items-center gap-1 text-[10px] font-semibold text-primary hover:text-primary/80 transition-colors disabled:opacity-50",children:[e.jsx(F,{className:c("h-3 w-3",K&&"animate-spin")})," Nach Updates suchen"]})]})]}),(r==null?void 0:r.last_check)&&e.jsxs("div",{className:"text-[9px] text-muted-foreground -mt-1",children:["Zuletzt gesucht: ",he(r.last_check)]}),A&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300",children:[e.jsx(F,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}),e.jsxs("span",{children:["Update läuft: ",e.jsx("span",{className:"font-semibold",children:A.label})," — bitte warten. Weitere Updates sind solange gesperrt."]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{icon:ce,iconClass:"text-cyan-400",name:"OS-Pakete (apt)",available:!!(r!=null&&r.os),status:r!=null&&r.os?`${r.os} verfügbar`:"aktuell",actionLabel:"Anzeigen",onAction:()=>D("os")}),e.jsx(B,{icon:oe,iconClass:"text-violet-400",name:"Inferenz-Engine (llama.cpp)",available:!!(r!=null&&r.engine),status:r!=null&&r.engine?"Update verfügbar":"aktuell",actionLabel:"Anzeigen",onAction:()=>D("engine")}),e.jsx(B,{icon:xe,iconClass:"text-fuchsia-400",name:"Router (llama-swap)",available:!!(r!=null&&r.swap),status:r!=null&&r.swap?"Update verfügbar":"aktuell",actionLabel:"Anzeigen",onAction:()=>D("swap")}),(()=>{var a;const t=(a=r==null?void 0:r.components)==null?void 0:a.find(x=>x.key==="hermes_agent");return e.jsx(B,{icon:le,iconClass:"text-amber-400",name:"Hermes-Agent",available:(t==null?void 0:t.update)===!0,busy:ue,status:(t==null?void 0:t.update)===!0?`Update: ${t.latest}`:(t==null?void 0:t.reachable)===!1?"offline":"aktuell",actionLabel:"Anzeigen",onAction:()=>D("hermes")})})(),(re=r==null?void 0:r.model_list)==null?void 0:re.map(t=>e.jsx(B,{icon:Oe,iconClass:"text-emerald-400",name:`Modell · ${t.role}`,available:!0,status:t.title,actionLabel:"Upgrade",onAction:()=>je(t.repo,t.role)},t.role))]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Dienste"}),e.jsxs("div",{className:"space-y-1.5",children:[E.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border/50 p-4 text-center text-xs text-muted-foreground",children:"Dienste-Liste wird geladen …"}),E.map(t=>e.jsx(Ge,{label:t.name,system:t.scope==="system",ok:t.ok,busy:$[t.unit],onRestart:()=>ee(t.unit),onLogs:()=>{S(t.unit),v("logs")}},t.unit))]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Backup"}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-background/20 px-3 py-2.5 flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs text-foreground truncate",children:H[0]?`Letztes: ${H[0].snapshot}`:"Noch kein Backup"}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[H.length," Snapshots · Wiederherstellen: Chronik → Zeitmaschine"]})]}),e.jsxs("button",{onClick:ke,disabled:Q,className:"flex items-center gap-1.5 text-[11px] font-semibold rounded-lg px-2.5 py-1 bg-primary text-primary-foreground hover:opacity-90 transition-all cursor-pointer disabled:opacity-50 shrink-0",children:[e.jsx(Ee,{className:c("h-3.5 w-3.5",Q&&"animate-pulse")})," Snapshot"]})]}),Z&&e.jsx("div",{className:"text-[10px] font-mono text-primary bg-primary/5 p-2 rounded-lg border border-primary/20 break-all leading-normal",children:Z})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-red-400/80",children:"Gefahrenzone"}),e.jsxs("button",{onClick:Ne,className:"flex w-full items-center gap-3 p-3 rounded-lg border border-red-500/20 bg-red-500/5 hover:bg-red-500/10 text-red-400 transition-all text-left text-xs font-semibold",children:[e.jsx($e,{className:"h-4.5 w-4.5"}),e.jsxs("div",{children:[e.jsx("div",{children:"Host-System neu starten"}),e.jsx("div",{className:"text-[10px] text-red-400/80 font-normal",children:"Startet die ganze Box neu"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Hintergrund-Aufgaben"}),e.jsxs("span",{className:"text-[10px] font-mono bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:[y.filter(t=>t.state==="running"||t.state==="queued").length," Aktiv"]})]}),e.jsx("div",{className:"space-y-3",children:y.length===0?e.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border/60 rounded-xl p-6 text-center",children:"Aktuell keine aktiven Hintergrund-Jobs."}):y.map(t=>{const a=t.state==="running"||t.state==="queued";return e.jsxs("div",{className:c("p-3 rounded-xl border transition-all duration-300",a?"border-primary/40 bg-primary/5 shadow-md shadow-primary/5":"border-border/40 bg-background/20 opacity-80"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-xs font-semibold flex items-center gap-1.5",children:[a&&e.jsxs("span",{className:"flex h-2 w-2 relative",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]}),t.label]}),e.jsxs("div",{className:"text-[10px] font-mono text-muted-foreground uppercase flex items-center gap-2",children:[e.jsxs("span",{children:["ID: ",t.id]}),e.jsx("span",{children:"•"}),e.jsx("span",{className:c(t.state==="done"&&"text-emerald-400",t.state==="failed"&&"text-red-400",t.state==="running"&&"text-primary",t.state==="queued"&&"text-amber-400",t.state==="canceled"&&"text-muted-foreground"),children:t.state})]})]}),a&&e.jsx("button",{onClick:()=>we(t.id),className:"text-[10px] font-semibold text-red-400 hover:text-red-300 border border-red-500/20 bg-red-500/5 hover:bg-red-500/10 px-2 py-0.5 rounded transition-colors",children:"Abbrechen"})]}),t.state==="running"&&e.jsxs("div",{className:"mt-3 space-y-1",children:[e.jsx("div",{className:"w-full h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all duration-500",style:{width:`${t.progress??0}%`}})}),e.jsxs("div",{className:"flex justify-between items-center text-[9px] font-mono text-muted-foreground",children:[e.jsxs("span",{children:[t.progress??0,"%"]}),t.done_bytes!=null&&t.total_bytes!=null&&e.jsxs("span",{children:[q(t.done_bytes)," / ",q(t.total_bytes),t.rate_bps!=null&&` (${q(t.rate_bps)}/s)`]}),t.eta_s!=null&&e.jsxs("span",{children:["ETA: ",t.eta_s,"s"]})]})]})]},t.id)})})]})]}),_==="logs"&&e.jsxs("div",{className:"flex flex-col h-full space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("select",{value:h,onChange:t=>S(t.target.value),className:"flex-1 h-9 px-3 text-xs bg-background/40 border border-border/60 rounded-lg outline-none text-foreground font-semibold",children:E.map(t=>e.jsxs("option",{value:t.unit,children:[t.name," (",t.scope==="system"?"systemd-root":"user",")"]},t.unit))}),e.jsxs("button",{onClick:()=>ee(h),disabled:$[h],className:"flex h-9 px-3 items-center gap-1.5 text-xs font-semibold rounded-lg border border-border/60 bg-background/20 hover:border-primary/50 transition-colors disabled:opacity-50",title:"Dienst neu starten",children:[e.jsx(F,{className:c("h-3.5 w-3.5",$[h]&&"animate-spin")}),"Restart"]})]}),e.jsx(Qe,{service:h,text:C,loading:k,logStatus:R,onRefresh:()=>T(h),onOpenSettings:()=>v("settings")})]}),_==="settings"&&e.jsx(Xe,{open:n,showAlert:s})]})]}),L&&e.jsx(Ie,{detail:L,maintenanceJob:A,onClose:()=>U(null),onApply:fe}),f]})}export{ot as SystemDrawer};
|