Files
mission-control-v2/frontend/dist/assets/IdeenView-CK4Z-iQS.js
T
2026-08-07 11:05:59 +02:00

36 lines
37 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{c as R,j as e,e as S,a3 as ve,u as Se,b as De,r as d,g as z,a7 as Ke,$ as T,L as D,X as Q,a8 as xe,I,a4 as he,C as Ce,T as ze,a5 as Ee,a9 as ge,q as Le,R as fe}from"./index-QPm6yWLB.js";import{S as Ae,H as X}from"./SectionLabel-BkcHvYQE.js";import{C as ee}from"./code-xml-D-FeXxuA.js";import{L as Pe}from"./layers-YHWsVV8J.js";import{C as U}from"./chevron-down-DUjbeeIY.js";import{R as We}from"./rotate-ccw-DyH-0aBE.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 $e=R("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
* @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 Re=R("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
* @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 Be=R("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
* @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 Y=R("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/**
* @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=R("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
* @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=R("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);function Te({text:r,className:c}){const k=(r||"").split(`
`),s=[];let m=[],p=null;const h=g=>{m.length&&(s.push(e.jsx("ul",{className:"mb-3 ml-4 list-disc space-y-1",children:m},g)),m=[])};return k.forEach((g,o)=>{const i=`l${o}`;if(p!==null){g.trimEnd()==="```"?(s.push(e.jsx("pre",{className:"mb-3 overflow-x-auto rounded-xl border border-border/50 bg-background/50 p-3 font-mono text-[11px] leading-relaxed text-foreground/85",children:p.join(`
`)},i)),p=null):p.push(g);return}if(g.trimStart().startsWith("```")){h(i),p=[];return}const j=g.trimEnd();if(!j.trim()){h(i);return}const w=j.match(/^(#{1,4})\s+(.*)$/);if(w){h(i);const N=w[1].length,u=N===1?"text-base font-bold mt-1 mb-2":N===2?"text-sm font-bold mt-4 mb-1.5":"text-xs font-bold mt-3 mb-1 uppercase tracking-wide text-muted-foreground";s.push(e.jsx("p",{className:S(u,"font-space text-foreground"),children:_(w[2],i)},i));return}const y=j.match(/^\s*[-*•]\s+(.*)$/);if(y){m.push(e.jsx("li",{className:"text-xs leading-relaxed text-foreground/85",children:_(y[1],i)},i));return}const l=j.match(/^\s*\d+\.\s+(.*)$/);if(l){m.push(e.jsx("li",{className:"text-xs leading-relaxed text-foreground/85",children:_(l[1],i)},i));return}h(i),s.push(e.jsx("p",{className:"mb-2 text-xs leading-relaxed text-foreground/85",children:_(j,i)},i))}),h("end"),p!==null&&s.push(e.jsx("pre",{className:"mb-3 overflow-x-auto rounded-xl border border-border/50 bg-background/50 p-3 font-mono text-[11px]",children:p.join(`
`)},"code-end")),e.jsx("div",{className:S("max-w-3xl",c),children:s})}function _(r,c){return r.split(/(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`)/g).map((s,m)=>{const p=`${c}-${m}`;return/^\*\*[^*]+\*\*$/.test(s)?e.jsx("b",{className:"font-semibold text-foreground",children:s.slice(2,-2)},p):/^\*[^*]+\*$/.test(s)?e.jsx("i",{children:s.slice(1,-1)},p):/^`[^`]+`$/.test(s)?e.jsx("code",{className:"rounded bg-background/50 px-1 font-mono text-[11px] text-foreground/90",children:s.slice(1,-1)},p):e.jsx("span",{children:s},p)})}const Ie={triage:{label:"wird ausgearbeitet …",cls:"text-violet-300 border-violet-500/40 bg-violet-500/10",spin:!0},todo:{label:"wartet",cls:"text-muted-foreground border-border/60 bg-background/30"},scheduled:{label:"geplant",cls:"text-muted-foreground border-border/60 bg-background/30"},ready:{label:"gleich dran",cls:"text-sky-300/80 border-sky-500/30 bg-sky-500/5"},running:{label:"in Arbeit …",cls:"text-sky-300 border-sky-500/40 bg-sky-500/10",spin:!0},review:{label:"im Review",cls:"text-amber-300 border-amber-500/40 bg-amber-500/10"},blocked:{label:"hängt — braucht dich",cls:"text-red-300 border-red-500/40 bg-red-500/10"},done:{label:"fertig ✓",cls:"text-emerald-300 border-emerald-500/40 bg-emerald-500/10"}},Ve={box:{label:"BOX",icon:X,cls:"border-border/60 bg-background/40 text-muted-foreground",title:"Box-Welt: die Werkstatt baut das selbst. Das Ergebnis kommt als Patch-Vorschlag zurück — nichts geht ohne deinen Klick live."},idee:{label:"IDEE",icon:T,cls:"border-sky-500/40 bg-sky-500/10 text-sky-300",title:"Nur durchdacht: die Box hat die Produkt-Idee mit voller Denk-Kaskade zu einem Konzept ausgearbeitet. Kein Gerüst, kein Bau — du liest es und entscheidest, ob ein Projekt draus wird."},projekt:{label:"IDE",icon:ee,cls:"border-violet-500/40 bg-violet-500/10 text-violet-300",title:"IDE-Welt: die Box bereitet nur vor (Konzept + Repo + Doku, kein Code). Gebaut wird von dir in Zed."}},Ze={needs_input:"Die Box hat eine Frage:",capability:"Die Box kam hier nicht weiter:",transient:"Die Aufgabe hakt:"},be="mc_ideen_quote";function ke(){try{const r=JSON.parse(localStorage.getItem(be)||"{}");return{gesendet:Number(r.gesendet)||0,geaendert:Number(r.geaendert)||0}}catch{return{gesendet:0,geaendert:0}}}function pe(r){try{const c=ke();c[r]+=1,localStorage.setItem(be,JSON.stringify(c))}catch{}}function qe(){var ie,le;const{data:r,isLoading:c}=ve(),k=Se(),{showAlert:s,showConfirm:m,dialogElement:p}=De(),[h,g]=d.useState(""),[o,i]=d.useState("denken"),[j,w]=d.useState("schlank"),[y,l]=d.useState(!1),[N,u]=d.useState(!1),A=o!=="box",V=o==="repo",[K,je]=d.useState("lxc"),[G,te]=d.useState(!1),[v,E]=d.useState({}),[B,Ne]=d.useState(null),[H,we]=d.useState(null),[J,re]=d.useState({}),P=(r==null?void 0:r.items)??[],W=()=>k.invalidateQueries({queryKey:Le.ideen});d.useEffect(()=>{const t=h.trim();if(t.length<12){u(!1);return}let n=!1;const x=setTimeout(async()=>{try{const f=await z("/api/ideen/einordnen",{method:"POST",body:JSON.stringify({text:t})});if(n||!(f!=null&&f.ok))return;i(f.nur_denken?"denken":f.wer==="zed"?"repo":"box"),f.tiefe&&w(f.tiefe),u(!0)}catch{}},700);return()=>{n=!0,clearTimeout(x)}},[h]);const se=B!==null&&(((ie=r==null?void 0:r.items.find(t=>t.id===B))==null?void 0:ie.status)==="triage"||((le=r==null?void 0:r.items.find(t=>t.id===B))==null?void 0:le.status)==="running"),O=Ke(B??"",se);async function ne(){const t=h.trim();if(!(t.length<3||G)){te(!0);try{const n=t.length>160?t.slice(0,157)+"…":t;await z("/api/ideen",{method:"POST",body:JSON.stringify({titel:n,notiz:t.length>160?t:"",welt:A?"ide":"box",tiefe:V?j==="gruendlich"?"gruendlich":"simpel":"",ziel:V?K:"",art:o==="denken"?"idee":"projekt"})}),pe("gesendet"),g(""),u(!1),l(!1),W()}catch(n){s("Das hat nicht geklappt",String((n==null?void 0:n.message)||n))}finally{te(!1)}}}function ae(t,n,x){m(`${n} fertige Karte${n===1?"":"n"} wegräumen?`,`${x} verschwindet aus der Liste. Gelöscht wird nichts — die Karten wandern ins Archiv der Queue und bleiben dort lesbar. Laufende, hängende und wartende Karten bleiben unberührt.`,async()=>{var b;const f="arch:"+(t||"*");E(a=>({...a,[f]:!0}));try{const a=await z("/api/ideen/archivieren-alle",{method:"POST",body:JSON.stringify({projekt:t})});(b=a.fehlgeschlagen)!=null&&b.length&&s("Teilweise erledigt",`${a.archiviert} weggeräumt, ${a.fehlgeschlagen.length} nicht: `+a.fehlgeschlagen.map(L=>L.titel).join(", ")),W()}catch(a){s("Das hat nicht geklappt",String((a==null?void 0:a.message)||a))}finally{E(a=>({...a,[f]:!1}))}})}async function ye(t){E(n=>({...n,[t]:!0}));try{await z("/api/ideen/archivieren",{method:"POST",body:JSON.stringify({id:t})}),W()}catch(n){s("Das hat nicht geklappt",String((n==null?void 0:n.message)||n))}finally{E(n=>({...n,[t]:!1}))}}async function Z(t,n,x,f){E(b=>({...b,[t+n]:!0}));try{await z(x,{method:"POST",body:JSON.stringify(f)}),W()}catch(b){s("Das hat nicht geklappt",String((b==null?void 0:b.message)||b))}finally{E(b=>({...b,[t+n]:!1}))}}async function oe(t){const n=(J[t]||"").trim();if(!(n.length<1||v["ans:"+t])){E(x=>({...x,["ans:"+t]:!0}));try{await z("/api/ideen/antwort",{method:"POST",body:JSON.stringify({id:t,antwort:n})}),re(x=>({...x,[t]:""})),W()}catch(x){s("Das hat nicht geklappt",String((x==null?void 0:x.message)||x))}finally{E(x=>({...x,["ans:"+t]:!1}))}}}const q=t=>{var ce,ue;const n=Ie[t.status]??{label:t.status,cls:"text-muted-foreground border-border/60 bg-background/30"},x=B===t.id,f=t.status==="triage"||t.status==="running"||t.status==="done",b=t.status==="blocked",a=!!v["ans:"+t.id],L=t.status==="running"&&(t.puls_alter??0)>600,de=t.status==="todo"||t.status==="ready"||t.status==="scheduled";return e.jsxs("li",{className:S("flex flex-col gap-2 rounded-xl border bg-background/30 px-3 py-2",b?"border-red-500/30":L?"border-amber-500/40":"border-border/40"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:S("flex shrink-0 items-center gap-1.5 rounded-lg border px-2 py-0.5 text-[10px] font-bold",n.cls),children:[n.spin&&e.jsx(D,{className:"h-3 w-3 animate-spin"}),n.label]}),L&&e.jsxs("span",{className:"flex shrink-0 items-center gap-1 rounded-lg border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-bold text-amber-300",title:"Der Worker lebt, gibt aber kein Lebenszeichen mehr — vermutlich wartet er auf etwas, das nie kommt. „Neuer Versuch“ startet die Karte frisch.",children:[e.jsx(ze,{className:"h-3 w-3"})," ",Math.round((t.puls_alter??0)/60)," min ohne Regung"]}),(t.prio??0)!==0&&e.jsxs("span",{className:"shrink-0 rounded bg-background/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",title:"Priorität — höher kommt zuerst dran (bei gleicher Prio: Erstellzeit)",children:["P",t.prio]}),(()=>{const C=Ve[t.art||(t.welt==="ide"?"projekt":"box")];if(!C)return null;const M=C.icon;return e.jsxs("span",{className:S("flex shrink-0 items-center gap-1 rounded-lg border px-2 py-0.5 text-[10px] font-bold",C.cls),title:C.title,children:[e.jsx(M,{className:"h-3 w-3"})," ",C.label]})})(),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",title:t.titel,children:t.titel}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx(he,{className:"h-3 w-3"}),Ee(t.erstellt)]}),de&&e.jsxs("span",{className:"flex shrink-0 items-center",children:[e.jsx("button",{disabled:!!v["pr:"+t.id],onClick:()=>Z("pr:",t.id,"/api/ideen/prio",{id:t.id,richtung:"hoch"}),title:"Vorziehen (Prio +1)",className:"rounded-md p-1 text-muted-foreground/60 transition-colors hover:text-foreground cursor-pointer disabled:opacity-50",children:e.jsx(Re,{className:"h-3.5 w-3.5"})}),e.jsx("button",{disabled:!!v["pr:"+t.id],onClick:()=>Z("pr:",t.id,"/api/ideen/prio",{id:t.id,richtung:"runter"}),title:"Zurückstellen (Prio 1)",className:"rounded-md p-1 text-muted-foreground/60 transition-colors hover:text-foreground cursor-pointer disabled:opacity-50",children:e.jsx($e,{className:"h-3.5 w-3.5"})})]}),(t.status==="running"||b)&&e.jsx("button",{disabled:!!v["rt:"+t.id],onClick:()=>m("Neuer Versuch?",t.status==="running"?`Der laufende Worker von '${t.titel.slice(0,60)}' wird beendet (samt gestarteter Test-Prozesse) und die Karte frisch gestartet. Bisheriger Zwischenstand im Workspace bleibt liegen.`:`Die Karte '${t.titel.slice(0,60)}' wird entsperrt und läuft weiter, sobald ein Platz frei ist.`,()=>Z("rt:",t.id,"/api/ideen/retry",{id:t.id})),title:"Neuer Versuch — Karte frisch starten",className:S("shrink-0 rounded-md p-1 transition-colors cursor-pointer disabled:opacity-50",L?"text-amber-300 hover:text-amber-200":"text-muted-foreground/60 hover:text-foreground"),children:v["rt:"+t.id]?e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(We,{className:"h-3.5 w-3.5"})}),(t.status==="running"||de||t.status==="triage")&&e.jsx("button",{disabled:!!v["st:"+t.id],onClick:()=>m("Karte stoppen?",`'${t.titel.slice(0,60)}' wird angehalten${t.status==="running"?" und der laufende Worker beendet":""}. Sie bleibt als gestoppt im Board und kann jederzeit per „Neuer Versuch“ weiterlaufen.`,()=>Z("st:",t.id,"/api/ideen/stopp",{id:t.id})),title:"Stoppen — Karte anhalten",className:"shrink-0 rounded-md p-1 text-muted-foreground/60 transition-colors hover:text-red-300 cursor-pointer disabled:opacity-50",children:v["st:"+t.id]?e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Oe,{className:"h-3.5 w-3.5"})}),(t.status==="done"||b)&&e.jsx("button",{disabled:!!v[t.id],onClick:()=>ye(t.id),title:b?"Aufgeben und aus der Liste räumen (wandert ins Kanban-Archiv)":"Aus der Liste räumen (wandert ins Kanban-Archiv)",className:"shrink-0 rounded-md p-1 text-muted-foreground/60 transition-colors hover:text-foreground cursor-pointer disabled:opacity-50",children:v[t.id]?e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Q,{className:"h-3.5 w-3.5"})}),t.welt==="ide"&&(t.status==="running"||t.status==="done")&&e.jsxs("button",{onClick:()=>we(H===t.id?null:t.id),title:"Konzept ansehen (das ausgearbeitete KONZEPT.md)",className:S("flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-[10px] font-bold transition-colors cursor-pointer",H===t.id?"text-violet-300":"text-violet-300/70 hover:text-violet-200"),children:[e.jsx(ge,{className:"h-3.5 w-3.5"})," Konzept"]}),f&&e.jsx("button",{onClick:()=>Ne(x?null:t.id),title:t.status==="done"?"Ergebnis anzeigen":"Worker-Log anzeigen",className:"shrink-0 rounded-md p-1 text-muted-foreground/60 transition-colors hover:text-foreground cursor-pointer",children:x?e.jsx(U,{className:"h-3.5 w-3.5"}):e.jsx(I,{className:"h-3.5 w-3.5"})})]}),H===t.id&&e.jsx(Fe,{id:t.id,istIdee:t.art==="idee"&&t.status==="done",onWeiter:W}),t.status==="running"&&t.notiz&&e.jsxs("p",{className:"-mt-1 ml-1 text-[11px] italic leading-relaxed text-sky-200/80",title:"Jüngste Zwischenmeldung des Workers (Heartbeat)",children:["„",t.notiz,"“"]}),(t.status==="todo"||t.status==="scheduled"||t.status==="ready")&&(((ce=t.wartet_auf)==null?void 0:ce.length)??0)>0&&e.jsxs("p",{className:"-mt-1 ml-1 text-[10px] text-muted-foreground/70",children:["→ wartet auf: ",t.wartet_auf.join(" · ")]}),b&&e.jsxs("div",{className:"space-y-2 border-t border-red-500/20 pt-2",children:[e.jsxs("p",{className:"flex items-start gap-1.5 text-[11px] leading-relaxed text-red-200/90",children:[e.jsx(xe,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-red-300"}),e.jsxs("span",{children:[e.jsx("b",{children:Ze[t.frage_kind||""]??"Die Aufgabe hängt und wartet auf dich:"})," ",t.frage?e.jsx("span",{className:"text-foreground/90",children:t.frage}):e.jsx("span",{className:"text-muted-foreground italic",children:"kein genauer Grund hinterlegt — antworte einfach mit einer Entscheidung, dann läuft sie weiter."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:J[t.id]||"",onChange:C=>re(M=>({...M,[t.id]:C.target.value})),onKeyDown:C=>{C.key==="Enter"&&oe(t.id)},placeholder:"Deine Antwort — die Box macht damit weiter",maxLength:2e3,className:"h-8 min-w-0 flex-1 rounded-lg border border-border/60 bg-background/60 px-2.5 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-red-400/50 focus:outline-none"}),e.jsxs("button",{onClick:()=>oe(t.id),disabled:a||(J[t.id]||"").trim().length<1,className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-emerald-500/40 bg-emerald-500/10 px-3 text-[10px] font-bold uppercase tracking-wide text-emerald-300 transition-all hover:bg-emerald-500/20 cursor-pointer disabled:opacity-50",children:[a?e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(me,{className:"h-3.5 w-3.5"})," Antworten & weiter"]})]})]}),x&&f&&t.status!=="done"&&e.jsx("div",{className:"ml-2 -mt-1",children:e.jsx("div",{className:"rounded-lg border border-border/50 bg-background/50 p-2",children:se&&O.isLoading?e.jsx("p",{className:"text-[10px] text-muted-foreground animate-pulse",children:"Log wird geladen …"}):O.error?e.jsx("p",{className:"text-[10px] text-red-400",children:"Log nicht ladbar"}):(ue=O.data)!=null&&ue.available&&O.data.lines.length>0?e.jsx("pre",{className:"max-h-64 overflow-auto font-mono text-[10px] leading-relaxed text-foreground/80 whitespace-pre-wrap",children:O.data.lines.join(`
`)}):e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Kein Log verfügbar"})})}),x&&t.status==="done"&&e.jsx(He,{id:t.id})]},t.id)};return r&&!r.available?null:e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Ae,{icon:T,children:(()=>{if(!r)return"Ideen-Queue";const t=x=>P.filter(f=>x.includes(f.status)).length,n=[t(["blocked"])>0?`${t(["blocked"])} braucht dich`:"",t(["running","triage","review"])>0?`${t(["running","triage","review"])} in Arbeit`:"",t(["todo","scheduled","ready"])>0?`${t(["todo","scheduled","ready"])} wartet`:"",t(["done"])>0?`${t(["done"])} fertig`:""].filter(Boolean);return n.length?n.join(" · "):"noch nichts in der Queue"})()}),(()=>{const t=P.filter(n=>n.status==="done").length;return t===0?null:e.jsxs("button",{disabled:!!v["arch:*"],onClick:()=>ae("",t,`Alle ${t} fertigen Karten`),title:"Räumt ALLE fertigen Karten weg — auch die in abgeschlossenen Projekt-Ketten. Laufende, hängende und wartende bleiben unberührt.",className:"flex shrink-0 items-center gap-1.5 rounded-lg border border-border/60 px-2.5 py-1 text-[11px] font-semibold text-muted-foreground transition-all hover:border-primary/40 hover:text-foreground disabled:opacity-50 cursor-pointer",children:[v["arch:*"]?e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Q,{className:"h-3.5 w-3.5"}),t," fertige wegräumen"]})})()]}),e.jsxs("div",{className:"mc-card p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:h,onChange:t=>{g(t.target.value),u(!1)},onKeyDown:t=>{t.key==="Enter"&&ne()},placeholder:"Was soll entstehen?",className:"h-10 min-w-0 flex-1 rounded-lg border border-border/60 bg-background/50 px-3 text-sm text-foreground placeholder:text-muted-foreground/50 focus:border-primary/50 focus:outline-none"}),e.jsxs("button",{onClick:ne,disabled:G||h.trim().length<3,className:"flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-primary/40 bg-primary/10 px-4 text-xs font-semibold text-primary transition-all hover:bg-primary/20 disabled:opacity-40 cursor-pointer",children:[G?e.jsx(D,{className:"h-4 w-4 animate-spin"}):e.jsx(me,{className:"h-4 w-4"}),"Los"]})]}),y?e.jsxs("div",{className:"space-y-3 rounded-xl border border-border/40 bg-background/20 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[11px] text-muted-foreground/70",children:"Wer baut das?"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(F,{aktiv:o!=="box",onWahl:()=>i(o==="box"?"denken":o),k:{id:"zed",icon:ee,titel:"Ich, in Zed",text:"Du bekommst Konzept und Repo — den Code schreibst du selbst."}}),e.jsx(F,{aktiv:o==="box",onWahl:()=>i("box"),k:{id:"box",icon:X,titel:"Die Box, allein",text:"Für dein Heimlabor. Das Ergebnis kommt als Patch-Vorschlag ins Auftragsbuch."}})]})]}),o!=="box"&&e.jsxs("div",{className:"border-l-2 border-primary/40 pl-3",children:[e.jsx("p",{className:"mb-1.5 text-[11px] text-muted-foreground/70",children:"Und wie startest du?"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(F,{aktiv:o==="denken",onWahl:()=>i("denken"),k:{id:"denken",icon:T,titel:"Erst durchdenken",text:"Konzept zuerst — auf dein Ja wird ein Repo daraus."}}),e.jsx(F,{aktiv:o==="repo",onWahl:()=>i("repo"),k:{id:"repo",icon:Y,titel:"Direkt ein Repo",text:"Konzept und Gitea-Repo in einem Zug."}})]}),o==="repo"?e.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"Wie gründlich?"}),e.jsx("div",{className:"flex rounded-lg border border-border/60 p-0.5",children:[["schlank","schlank"],["gruendlich","gründlich"]].map(([t,n])=>e.jsx("button",{onClick:()=>w(t),className:S("rounded px-2.5 py-1 text-[10px] font-bold uppercase tracking-wide transition-all cursor-pointer",j===t?"bg-primary/15 text-primary":"text-muted-foreground/60 hover:text-foreground"),children:n},t))}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"Läuft als"}),e.jsx("div",{className:"flex rounded-lg border border-border/40 p-0.5",children:[["lxc","LXC"],["docker","Docker"]].map(([t,n])=>e.jsx("button",{onClick:()=>je(t),title:t==="lxc"?"Dienst in einem eigenen Proxmox-LXC (systemd, kein Docker). Wird vom Backup-Server mitgesichert.":"Natives Docker: Dockerfile + compose, portabel und pipeline-tauglich.",className:S("rounded px-2 py-0.5 text-[10px] font-semibold transition-all cursor-pointer",K===t?"bg-foreground/10 text-foreground":"text-muted-foreground/50 hover:text-foreground/80"),children:n},t))})]})]}):e.jsxs("p",{className:"mt-2 flex items-start gap-1.5 text-[10px] leading-relaxed text-muted-foreground/60",children:[e.jsx(xe,{className:"mt-px h-3 w-3 shrink-0"}),'Wie gründlich und wo es läuft, fragt die Box erst beim „gefällt mir" — dann weißt du mehr.']})]}),(()=>{const t=ke();return t.gesendet<3?null:e.jsxs("p",{className:"border-t border-border/30 pt-2 text-[10px] text-muted-foreground/50",children:["Du hast ",t.geaendert," von ",t.gesendet," Vorschlägen geändert. Wird das die Regel, bauen wir hier einen richtigen Schritt-für-Schritt-Assistenten."]})})()]}):e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-xl border border-border/40 bg-background/20 px-3 py-2.5 text-xs",children:[o==="box"?e.jsx(X,{className:"h-4 w-4 shrink-0 text-primary"}):o==="repo"?e.jsx(Y,{className:"h-4 w-4 shrink-0 text-primary"}):e.jsx(T,{className:"h-4 w-4 shrink-0 text-primary"}),!N&&e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wider text-muted-foreground/50",children:"Voreingestellt"}),e.jsx("span",{className:"text-muted-foreground",children:o==="box"?"Ich baue das selbst und lege dir das Ergebnis als Vorschlag hin.":o==="repo"?"Du baust selbst — ich lege dir Konzept und Repo an.":"Du baust selbst — ich arbeite erst ein Konzept aus."}),N&&e.jsx("span",{className:"shrink-0 rounded border border-primary/40 bg-primary/10 px-1.5 py-0.5 text-[10px] font-bold text-primary",children:"gelesen"}),e.jsx("button",{onClick:()=>{l(!0),pe("geaendert")},className:"ml-auto shrink-0 text-[11px] text-muted-foreground/60 underline underline-offset-2 transition-colors hover:text-foreground cursor-pointer",children:"anders"})]}),c&&e.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"})," Queue wird geladen …"]}),(r==null?void 0:r.fehler)&&e.jsx("p",{className:"text-xs text-amber-300",children:"Queue gerade nicht lesbar — neuer Versuch läuft."}),P.length>0&&e.jsxs("div",{className:"space-y-3",children:[((r==null?void 0:r.projekte)??[]).map(t=>e.jsx(_e,{projekt:t,karten:P.filter(n=>n.projekt===t.key),zeile:q,onArchivAlle:ae,raeumt:!!v["arch:"+t.key]},t.key)),(()=>{const t=new Set(((r==null?void 0:r.projekte)??[]).map(a=>a.key)),n=P.filter(a=>!a.projekt||!t.has(a.projekt));if(n.length===0)return null;const x=n.filter(a=>$[a.status]!==void 0).sort((a,L)=>$[a.status]-$[L.status]||(a.erstellt??0)-(L.erstellt??0)),f=n.filter(a=>["todo","scheduled"].includes(a.status)),b=n.filter(a=>a.status==="done");return e.jsxs("div",{className:"space-y-2",children:[x.length>0&&e.jsx("ul",{className:"space-y-1.5",children:x.map(a=>q(a))}),f.length>0&&e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 py-1 text-[11px] text-muted-foreground/70 hover:text-foreground",children:[e.jsx(I,{className:"h-3 w-3 transition-transform group-open:rotate-90"}),e.jsx(he,{className:"h-3 w-3"})," Wartet (",f.length,")"]}),e.jsx("ul",{className:"mt-1.5 space-y-1.5",children:f.map(a=>q(a))})]}),b.length>0&&e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 py-1 text-[11px] text-muted-foreground/70 hover:text-foreground",children:[e.jsx(I,{className:"h-3 w-3 transition-transform group-open:rotate-90"}),e.jsx(Ce,{className:"h-3 w-3 text-emerald-400/70"})," Fertig (",b.length,")"]}),e.jsx("ul",{className:"mt-1.5 space-y-1.5",children:b.map(a=>q(a))})]})]})})()]}),(r==null?void 0:r.available)&&!c&&P.length===0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Noch nichts hier. Zum Beispiel:"}),["Ein kleines Werkzeug, das meine Fotos nach Aufnahmedatum in Ordner sortiert","Rippy soll die Untertitel-Spur automatisch auswählen statt zu fragen","Lohnt sich ein Dashboard für die Stromzähler, oder reicht Home Assistant?"].map(t=>e.jsxs("button",{onClick:()=>g(t),className:"flex w-full items-center gap-2 rounded-lg border border-border/40 bg-background/20 px-3 py-2 text-left text-xs text-muted-foreground transition-all hover:border-primary/40 hover:text-foreground cursor-pointer",children:[e.jsx(T,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/50"}),t]},t))]})]}),p]})}function F({k:r,aktiv:c,onWahl:k}){return e.jsxs("button",{onClick:k,className:S("rounded-xl border p-3 text-left transition-all cursor-pointer",c?"border-primary/60 bg-primary/5":"border-border/50 hover:border-border"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r.icon,{className:S("h-4 w-4 shrink-0",c?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:r.titel})]}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:r.text})]})}const $={blocked:0,running:1,review:2,ready:3,triage:4};function _e({projekt:r,karten:c,zeile:k,onArchivAlle:s,raeumt:m}){const[p,h]=d.useState(!1),[g,o]=d.useState(!1),i=c.filter(l=>$[l.status]!==void 0).sort((l,N)=>$[l.status]-$[N.status]||(l.erstellt??0)-(N.erstellt??0)),j=c.filter(l=>l.status==="todo"||l.status==="scheduled").sort((l,N)=>{var u,A;return((u=l.wartet_auf)!=null&&u.length?1:0)-((A=N.wartet_auf)!=null&&A.length?1:0)||(l.erstellt??0)-(N.erstellt??0)}),w=c.filter(l=>l.status==="done").sort((l,N)=>(N.fertig??0)-(l.fertig??0)),y=r.gesamt>0?Math.round(r.fertig/r.gesamt*100):0;return e.jsxs("div",{className:"space-y-2 rounded-xl border border-border/50 bg-background/20 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"h-4 w-4 shrink-0 text-primary/70"}),e.jsx("p",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-foreground",title:r.titel,children:r.titel}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[r.fertig," von ",r.gesamt," fertig"]})]}),e.jsx("div",{className:"h-1 overflow-hidden rounded-full bg-background/60",title:`${y}%`,children:e.jsx("div",{className:"h-1 rounded-full bg-primary/70 transition-all",style:{width:`${y}%`}})}),i.length>0&&e.jsx("ul",{className:"space-y-1.5",children:i.map(l=>k(l))}),j.length>0&&e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>h(l=>!l),className:"flex items-center gap-1.5 text-[11px] font-semibold text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[p?e.jsx(U,{className:"h-3.5 w-3.5"}):e.jsx(I,{className:"h-3.5 w-3.5"}),j.length," Karte",j.length===1?"":"n"," in der Kette — laufen automatisch der Reihe nach"]}),p&&e.jsx("ul",{className:"mt-1.5 space-y-1.5",children:j.map(l=>k(l))})]}),w.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>o(l=>!l),className:"flex items-center gap-1.5 text-[11px] font-semibold text-emerald-300/70 hover:text-emerald-300 transition-colors cursor-pointer",children:[g?e.jsx(U,{className:"h-3.5 w-3.5"}):e.jsx(I,{className:"h-3.5 w-3.5"}),w.length," fertig"]}),s&&e.jsxs("button",{disabled:m,onClick:()=>s(r.key,w.length,`${r.titel}"`),title:"Räumt die fertigen Karten dieser Kette weg (Archiv, nichts wird gelöscht).",className:"flex items-center gap-1 text-[11px] text-muted-foreground/60 transition-colors hover:text-foreground disabled:opacity-50 cursor-pointer",children:[m?e.jsx(D,{className:"h-3 w-3 animate-spin"}):e.jsx(Q,{className:"h-3 w-3"}),"wegräumen"]})]}),g&&e.jsx("ul",{className:"mt-1.5 space-y-1.5",children:w.map(l=>k(l))})]})]})}function Fe({id:r,istIdee:c,onWeiter:k}){const[s,m]=d.useState(null),[p,h]=d.useState(!1),[g,o]=d.useState(0);return d.useEffect(()=>{let i=!1;return m(null),h(!1),z(`/api/ideen/${r}/konzept`).then(j=>{i||m(j)}).catch(()=>{i||h(!0)}),()=>{i=!0}},[r,g]),e.jsx("div",{className:"ml-2 -mt-1",children:e.jsxs("div",{className:"rounded-lg border border-violet-500/25 bg-violet-500/[0.04] p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wide text-violet-300",children:[e.jsx(ge,{className:"h-3 w-3"})," Konzept"]}),(s==null?void 0:s.repo)&&e.jsxs("a",{href:`https://git.tobisniceshomelab.ddnsfree.com/${s.repo}`,className:"flex items-center gap-1 text-[10px] text-violet-300/70 hover:text-violet-200",children:[e.jsx(Y,{className:"h-3 w-3"})," ",s.repo]}),!(s!=null&&s.repo)&&(s==null?void 0:s.quelle)==="datei"&&e.jsx("span",{className:"truncate font-mono text-[10px] text-muted-foreground/70",title:"Der Worker hat kein Repo angelegt — das Konzept liegt als Datei auf der Box.",children:s.pfad}),e.jsx("button",{onClick:()=>o(i=>i+1),title:"Neu laden",className:"ml-auto rounded p-0.5 text-muted-foreground/50 hover:text-foreground cursor-pointer",children:e.jsx(fe,{className:"h-3 w-3"})})]}),p?e.jsx("p",{className:"text-[11px] text-red-400",children:"Konzept nicht ladbar — später nochmal versuchen."}):s===null?e.jsx("p",{className:"text-[10px] text-muted-foreground animate-pulse",children:"Konzept wird geladen …"}):s.konzept?e.jsx("div",{className:"max-h-[28rem] overflow-y-auto pr-1",children:e.jsx(Te,{text:s.konzept})}):e.jsx("p",{className:"text-[11px] text-muted-foreground italic",children:s.error||"Noch kein Konzept — das Projekt wird gerade vorbereitet."}),c&&(s==null?void 0:s.konzept)&&e.jsx(Ge,{id:r,onFertig:k})]})})}function Ge({id:r,onFertig:c}){const[k,s]=d.useState("lxc"),[m,p]=d.useState("simpel"),[h,g]=d.useState(!1),[o,i]=d.useState(null),[j,w]=d.useState(""),[y,l]=d.useState(""),N=async(u,A,V)=>{g(!0),w("");try{const K=await z(u,{method:"POST",body:JSON.stringify(A)});i({id:K.id,art:V}),c==null||c()}catch(K){w(String((K==null?void 0:K.message)||K))}finally{g(!1)}};return o?e.jsx("p",{className:"mt-3 border-t border-violet-500/20 pt-2 text-[11px] text-emerald-300",children:o.art==="projekt"?e.jsxs(e.Fragment,{children:["Projekt-Karte ",e.jsx("span",{className:"font-mono",children:o.id})," ist angelegt — die Box bereitet das Repo vor (Konzept übernimmt sie, sie denkt es nicht neu). Danach öffnest du es in Zed."]}):e.jsxs(e.Fragment,{children:["Überarbeitung ",e.jsx("span",{className:"font-mono",children:o.id}),' läuft — die Box arbeitet deine Rückmeldung ein und schreibt die neue Fassung an dieselbe Stelle. Danach hier wieder „Konzept" öffnen.']})}):e.jsxs("div",{className:"mt-3 space-y-3 border-t border-violet-500/20 pt-2.5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[e.jsx("b",{className:"text-sky-300/90",children:"Passt etwas nicht?"})," Schreib hin, was anders werden soll — die Box arbeitet es ein und lässt den Rest stehen. Beliebig oft wiederholbar."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:y,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&y.trim().length>=3&&!h&&N("/api/ideen/nachschaerfen",{id:r,hinweis:y},"runde")},placeholder:"z. B. „Punkt 3: kein WebSocket, das ist mir zu fragil — nimm Polling“",maxLength:2e3,className:"h-8 min-w-0 flex-1 rounded-lg border border-border/60 bg-background/60 px-2.5 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-sky-400/50 focus:outline-none"}),e.jsxs("button",{onClick:()=>N("/api/ideen/nachschaerfen",{id:r,hinweis:y},"runde"),disabled:h||y.trim().length<3,className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-sky-500/40 bg-sky-500/10 px-3 text-[10px] font-bold uppercase tracking-wide text-sky-300 transition-all hover:bg-sky-500/20 cursor-pointer disabled:opacity-50",children:[h?e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(fe,{className:"h-3.5 w-3.5"}),"Nachschärfen"]})]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[e.jsx("b",{className:"text-violet-300/90",children:"Passt es so?"})," Dann macht die Box daraus ein startklares Repo — Konzept wird übernommen (nicht neu gedacht), dazu Roadmap, AGENTS.md & Co. Gebaut wird danach von dir in Zed."]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"Ziel"}),e.jsx("div",{className:"flex rounded-lg border border-border/40 p-0.5",children:["lxc","docker"].map(u=>e.jsx("button",{onClick:()=>s(u),title:u==="lxc"?"Dienst in einem eigenen Proxmox-LXC (systemd, kein Docker) — wird automatisch mitgesichert.":"Natives Docker: Dockerfile + compose, portabel und pipeline-tauglich.",className:S("rounded px-2 py-0.5 text-[10px] font-semibold transition-all cursor-pointer",k===u?"bg-foreground/10 text-foreground":"text-muted-foreground/50 hover:text-foreground/80"),children:u==="lxc"?"LXC":"Docker"},u))}),e.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"Aufwand"}),e.jsx("div",{className:"flex rounded-lg border border-border/40 p-0.5",children:["simpel","gruendlich"].map(u=>e.jsx("button",{onClick:()=>p(u),title:u==="simpel"?"Konzept ist schon gehärtet — nur kurz auf die Bau-Sicht nachschärfen (empfohlen).":"Nochmal volle Kaskade über die Bau-Sicht: mehrere Rollen, Härtetests. Dauert entsprechend.",className:S("rounded px-2 py-0.5 text-[10px] font-semibold transition-all cursor-pointer",m===u?"bg-foreground/10 text-foreground":"text-muted-foreground/50 hover:text-foreground/80"),children:u==="simpel"?"schlank":"gründlich"},u))}),e.jsxs("button",{onClick:()=>N("/api/ideen/weiterfuehren",{id:r,ziel:k,tiefe:m},"projekt"),disabled:h,className:"ml-auto flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-violet-500/40 bg-violet-500/10 px-3 text-[10px] font-bold uppercase tracking-wide text-violet-300 transition-all hover:bg-violet-500/20 cursor-pointer disabled:opacity-50",children:[h?e.jsx(D,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ee,{className:"h-3.5 w-3.5"}),"Gefällt mir — Projekt daraus machen"]})]}),j&&e.jsx("p",{className:"text-[11px] text-red-400",children:j})]})}function He({id:r}){const[c,k]=d.useState(null),[s,m]=d.useState(!1),[p,h]=d.useState(0);d.useEffect(()=>{let o=!1;return m(!1),k(null),z(`/api/ideen/${r}/ergebnis`).then(i=>{o||k(i)}).catch(()=>{o||m(!0)}),()=>{o=!0}},[r,p]);const g=c?c.summary||c.result:"";return e.jsx("div",{className:"ml-2 -mt-1",children:e.jsxs("div",{className:"rounded-lg border border-emerald-500/25 bg-emerald-500/5 p-2.5",children:[e.jsxs("p",{className:"mb-1 flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wide text-emerald-300",children:[e.jsx(Be,{className:"h-3 w-3"})," Ergebnis des Workers"]}),s?e.jsx("button",{type:"button",onClick:()=>h(o=>o+1),className:"text-[10px] text-red-400 underline decoration-dotted underline-offset-2 hover:text-red-300",children:"Ergebnis nicht ladbar — nochmal versuchen"}):c===null?e.jsx("p",{className:"text-[10px] text-muted-foreground animate-pulse",children:"Wird geladen …"}):g?e.jsx("p",{className:"max-h-64 overflow-y-auto whitespace-pre-wrap text-xs leading-relaxed text-foreground/85",children:g}):e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Der Worker hat keine Abschluss-Zusammenfassung hinterlassen (ältere Karte oder Protokollverstoß)."})]})})}function et(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text font-space text-2xl font-bold tracking-tight text-transparent",children:"Ideen"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Schreib hin, was entstehen soll. Die Box liest mit und schlägt vor, wie es weitergeht — ändern kannst du das immer."})]}),e.jsx(qe,{})]})}export{et as IdeenView};