kanbaii 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/404.html +1 -1
- package/dashboard/_next/static/chunks/184-15d72b1991c86ab9.js +1 -0
- package/dashboard/_next/static/chunks/23-4a72ba4a90f008a6.js +1 -0
- package/dashboard/_next/static/chunks/{193-e4d2dea3fdc64b33.js → 759-3d8fc7952548ec08.js} +1 -1
- package/dashboard/_next/static/chunks/app/layout-5b89132efd82b0a2.js +1 -0
- package/dashboard/_next/static/chunks/app/page-e96878de09e0c519.js +1 -0
- package/dashboard/_next/static/css/85ce8ef4f13f9778.css +1 -0
- package/dashboard/index.html +1 -1
- package/dashboard/index.txt +3 -3
- package/dist/server/engines/coordinator.js +7 -2
- package/dist/server/engines/workerPool.js +9 -0
- package/dist/server/routes/projects.js +16 -3
- package/dist/server/services/projectStore.d.ts +2 -1
- package/dist/server/services/projectStore.js +11 -3
- package/package.json +6 -3
- package/dashboard/_next/static/chunks/23-2e97e53d3c5bbe2d.js +0 -1
- package/dashboard/_next/static/chunks/947-6596e9d0905e814e.js +0 -1
- package/dashboard/_next/static/chunks/app/layout-80932402bd5ccddf.js +0 -1
- package/dashboard/_next/static/chunks/app/page-81876f16bd9d3ebe.js +0 -1
- package/dashboard/_next/static/css/2671f4087ec3bbc3.css +0 -1
- /package/dashboard/_next/static/{dwjREEZVmsUge1LeMuNBi → A8eY-I1syJkHlELnPcf1s}/_buildManifest.js +0 -0
- /package/dashboard/_next/static/{dwjREEZVmsUge1LeMuNBi → A8eY-I1syJkHlELnPcf1s}/_ssgManifest.js +0 -0
- /package/dashboard/_next/static/chunks/{117-93de0183f63af83e.js → 117-749dc8b5f56031ab.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{7972:function(e,t,a){Promise.resolve().then(a.bind(a,2039))},2039:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return tE}});var s=a(7437),n=a(4938),r=a(407),o=a(9449),l=a(9747),c=a(2265),i=a(5675),d=a(9397),x=a(2023),m=a(3415),u=a(223),p=a(15),b=a(9116),h=a(2489),f=a(1171);let g=[{key:"feature",icon:"✦",label:"Feature",desc:"New functionality",color:"#6366f1"},{key:"bug",icon:"●",label:"Bug",desc:"Fix a defect",color:"#ef4444"},{key:"refactor",icon:"◆",label:"Refactor",desc:"Improve existing code",color:"#f59e0b"}];function j(e){let{projectSlug:t,onClose:a}=e,n=(0,p.o)(e=>e.createWorkItem),r=(0,o.U)(e=>e.goToWorkItem),[l,i]=(0,c.useState)(""),[d,x]=(0,c.useState)("feature"),[m,u]=(0,c.useState)(!1),{overlayProps:b}=(0,f.N)(a),j=async e=>{if(e.preventDefault(),l.trim()){u(!0);try{let e=await n(t,{title:l.trim(),category:d});a(),r(t,e.slug)}catch(e){u(!1)}}};return(0,s.jsx)("div",{className:"glass-overlay",...b,children:(0,s.jsxs)("div",{className:"modal-box w-[520px] max-w-[92%] p-7",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-7",children:[(0,s.jsx)("span",{className:"text-h2 font-semibold tracking-tight text-text",children:"New Work Item"}),(0,s.jsx)("button",{className:"btn-icon",onClick:a,children:(0,s.jsx)(h.Z,{size:16})})]}),(0,s.jsxs)("form",{className:"flex flex-col gap-[22px]",onSubmit:j,children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Category"}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:g.map(e=>(0,s.jsxs)("button",{type:"button",className:"flex flex-col items-center gap-2 py-[22px] px-3 pb-[18px]\n bg-transparent border border-border rounded-md cursor-pointer\n transition-all duration-250 ease-out-expo text-center relative\n before:content-[''] before:absolute before:top-0 before:left-[20%] before:right-[20%] before:h-px\n before:bg-gradient-to-r before:from-transparent before:via-white/[0.03] before:to-transparent before:pointer-events-none\n hover:border-border-light hover:bg-surface-hover hover:-translate-y-0.5 hover:shadow-[0_8px_20px_rgba(0,0,0,0.2)]\n ".concat(d===e.key?"border-[1.5px]":""),style:{"--cat-color":e.color,borderColor:d===e.key?e.color:void 0,background:d===e.key?"".concat(e.color,"12"):void 0},onClick:()=>x(e.key),children:[(0,s.jsx)("span",{className:"text-[22px]",style:{color:e.color},children:e.icon}),(0,s.jsx)("span",{className:"text-body font-semibold text-text tracking-tight",children:e.label}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted leading-snug",children:e.desc})]},e.key))})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Title"}),(0,s.jsx)("input",{value:l,onChange:e=>i(e.target.value),placeholder:"feature"===d?"e.g. Auth System, Payment Integration...":"bug"===d?"e.g. Login fails on mobile, API timeout...":"e.g. Extract API utils, Normalize DB schema...",autoFocus:!0})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-1.5",children:[(0,s.jsx)("button",{type:"button",className:"btn-ghost",onClick:a,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"btn-primary",disabled:!l.trim()||m,children:m?"Creating...":"Create"})]})]})]})})}var v=a(8930);let N=[{key:"planning",label:"Planning"},{key:"active",label:"Active"},{key:"review",label:"Review"},{key:"done",label:"Done"}];function y(e){let{projectSlug:t,workItem:a,onClose:n}=e,{updateWorkItem:r,deleteWorkItem:o}=(0,p.o)(),[l,i]=(0,c.useState)(a.title),[d,x]=(0,c.useState)(a.status),[m,u]=(0,c.useState)(!1),[b,g]=(0,c.useState)(!1),{overlayProps:j}=(0,f.N)(n,{disabled:m}),y=async e=>{if(e.preventDefault(),l.trim()){u(!0);try{await r(t,a.slug,{...l.trim()!==a.title?{title:l.trim()}:{},...d!==a.status?{status:d}:{}}),n()}catch(e){u(!1)}}},w=async()=>{if(!b){g(!0);return}u(!0);try{await o(t,a.slug),n()}catch(e){u(!1)}};return(0,s.jsx)("div",{className:"glass-overlay",...j,children:(0,s.jsxs)("div",{className:"modal-box w-[520px] max-w-[92%] p-7",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-7",children:[(0,s.jsx)("span",{className:"text-h2 font-semibold tracking-tight text-text",children:"Edit Work Item"}),(0,s.jsx)("button",{className:"btn-icon",onClick:n,children:(0,s.jsx)(h.Z,{size:16})})]}),(0,s.jsxs)("form",{className:"flex flex-col gap-[22px]",onSubmit:y,children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Title"}),(0,s.jsx)("input",{value:l,onChange:e=>i(e.target.value),autoFocus:!0})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Status"}),(0,s.jsx)("div",{className:"grid grid-cols-4 gap-2",children:N.map(e=>(0,s.jsx)("button",{type:"button",className:"flex items-center justify-center py-2.5 px-2 bg-transparent\n border border-border rounded-md cursor-pointer transition-all duration-250 ease-out-expo\n text-xs font-medium text-text-secondary\n hover:border-border-light hover:bg-surface-hover\n ".concat(d===e.key?"border-[rgba(99,102,241,0.25)] bg-accent-muted text-accent":""),onClick:()=>x(e.key),children:e.label},e.key))})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Category"}),(0,s.jsx)("span",{className:"badge badge-".concat(a.category," self-start"),children:a.category})]}),(0,s.jsxs)("div",{className:"flex justify-between gap-2 pt-1.5",children:[(0,s.jsxs)("button",{type:"button",className:"btn-danger",onClick:w,disabled:m,children:[(0,s.jsx)(v.Z,{size:14}),b?"Confirm delete?":"Delete"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{type:"button",className:"btn-ghost",onClick:n,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"btn-primary",disabled:!l.trim()||m,children:m?"Saving...":"Save"})]})]})]})]})})}var w=a(257);let k={feature:{color:"#6366f1",icon:"✦",label:"FEAT"},bug:{color:"#ef4444",icon:"●",label:"BUG"},refactor:{color:"#f59e0b",icon:"◆",label:"REF"}},C=[{key:"planning",label:"Planning"},{key:"active",label:"Active"},{key:"review",label:"Review"},{key:"done",label:"Done"}];function S(e){let{wi:t,projectSlug:a,onClick:n,onEdit:r,index:o=0,columnKey:l,onReorder:d}=e,x=(0,c.useRef)(null),[p,b]=(0,c.useState)(!1),[h,f]=(0,c.useState)(null),[g,j]=(0,c.useState)(!1),v=k[t.category],N=function(e){let t=0,a=0;for(let s of Object.values(e.columns))t+=s.length,a+=s.filter(e=>e.completed).length;return{completed:a,total:t,percent:0===t?0:Math.round(a/t*100)}}(t);(0,c.useEffect)(()=>{let e=x.current;if(!e)return;let a=(0,m.En)({element:e,getInitialData:()=>({type:"work-item",wiId:t.id,wiSlug:t.slug,currentStatus:l,index:o}),onDragStart:()=>b(!0),onDrop:()=>b(!1)}),s=(0,m.wO)({element:e,getData:e=>{let{input:a,element:s}=e;return(0,u.X)({type:"work-item-card",wiId:t.id,wiSlug:t.slug,columnKey:l,index:o},{input:a,element:s,allowedEdges:["top","bottom"]})},canDrop:e=>{let{source:a}=e;return"work-item"===a.data.type&&a.data.wiId!==t.id},onDragEnter:e=>{let{self:t}=e;return f((0,u.A)(t.data))},onDrag:e=>{let{self:t}=e;return f((0,u.A)(t.data))},onDragLeave:()=>f(null),onDrop:e=>{let{source:t,self:a}=e;f(null);let s=(0,u.A)(a.data),n=t.data.currentStatus,r=t.data.index,c=o;"bottom"===s&&(c=o+1),n===l&&r<c&&c--,d(t.data.wiSlug,n,r,l,c)}});return()=>{a(),s()}},[t.id,t.slug,l,o,d]);let y=(0,c.useRef)(t.status);return(0,c.useEffect)(()=>{if(y.current!==t.status){j(!0);let e=setTimeout(()=>j(!1),600);return y.current=t.status,()=>clearTimeout(e)}},[t.status]),(0,s.jsxs)("div",{className:"relative",children:["top"===h&&(0,s.jsx)("div",{className:"absolute -top-[2px] left-1 right-1 h-[3px] rounded-full bg-accent z-10 shadow-[0_0_8px_rgba(99,102,241,0.4)]"}),(0,s.jsx)("div",{ref:x,className:["group/card flex bg-card border border-border rounded-md cursor-pointer shadow-card","transition-all duration-250 ease-out-expo overflow-hidden animate-stagger-in","relative","before:absolute before:left-0 before:top-0 before:bottom-0 before:w-[3px] before:rounded-l-md before:bg-[var(--cat-color)]","hover:-translate-y-[3px] hover:shadow-card-hover hover:border-border-light",p?"opacity-20 scale-95 rotate-[2deg] shadow-drag":"",g?"animate-post-move":""].join(" "),style:{"--cat-color":v.color,animationDelay:"".concat(60*o,"ms")},onClick:n,children:(0,s.jsxs)("div",{className:"flex-1 p-3 pl-3.5 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)("span",{className:"shrink-0 text-body drop-shadow-[0_0_4px_currentColor]",style:{color:v.color},children:v.icon}),(0,s.jsx)("span",{className:"flex-1 text-body font-medium text-text overflow-hidden text-ellipsis whitespace-nowrap tracking-[-0.01em]",children:t.title}),(0,s.jsx)("button",{className:"inline-flex items-center justify-center w-5 h-5 rounded-xs text-text-muted opacity-0 transition-all duration-150 ease-out-expo group-hover/card:opacity-100 hover:bg-surface-hover hover:text-accent",onClick:e=>{e.stopPropagation(),r()},title:"Edit",children:(0,s.jsx)(i.Z,{size:11})}),(0,s.jsx)("span",{className:"badge badge-".concat(t.category),children:v.label})]}),t.plan.content?(0,s.jsx)("div",{className:"text-[10.5px] text-text-muted leading-[1.5] line-clamp-2 mb-2.5",children:t.plan.content}):(0,s.jsx)("div",{className:"text-[10.5px] text-text-muted leading-[1.5] line-clamp-2 mb-2.5 italic opacity-40",children:"No plan yet"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)("div",{className:"flex-1 h-[3px] rounded-[3px] bg-[rgba(148,163,242,0.06)] overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-[3px] transition-[width] duration-[800ms] ease-out-expo",style:{width:"".concat(N.percent,"%"),background:v.color}})}),(0,s.jsxs)("span",{className:"text-data font-semibold text-text-secondary font-mono min-w-[28px] text-right",children:[N.percent,"%"]}),(0,s.jsxs)("span",{className:"text-xxs text-text-muted font-mono",children:[N.completed,"/",N.total]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-data text-text-muted font-mono",children:[t.linkedWorkItem&&(0,s.jsxs)("span",{className:"text-accent-dim",children:["→ ",t.linkedWorkItem]}),(0,s.jsx)("span",{className:"ml-auto",children:function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<60)return"".concat(t,"m ago");let a=Math.floor(t/60);return a<24?"".concat(a,"h ago"):"".concat(Math.floor(a/24),"d ago")}(t.updatedAt)})]})]})}),"bottom"===h&&(0,s.jsx)("div",{className:"absolute -bottom-[2px] left-1 right-1 h-[3px] rounded-full bg-accent z-10 shadow-[0_0_8px_rgba(99,102,241,0.4)]"})]})}function T(e){let{columnKey:t,label:a,items:n,projectSlug:r,onCardClick:o,onCardEdit:l,onDrop:i,onReorder:d}=e,x=(0,c.useRef)(null),[u,p]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{let e=x.current;if(e)return(0,m.wO)({element:e,getData:()=>({columnKey:t}),canDrop:e=>{let{source:a}=e;return"work-item"===a.data.type&&a.data.currentStatus!==t},onDragEnter:()=>p(!0),onDragLeave:()=>p(!1),onDrop:e=>{let{source:a}=e;p(!1),i(a.data.wiSlug,t)}})},[t,i]),(0,s.jsxs)("div",{className:"flex flex-col min-w-[220px] gap-1.5 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-1.5 py-2 mb-1",children:[(0,s.jsx)("span",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:a}),(0,s.jsx)("span",{className:"text-xxs text-text-muted bg-pill px-[7px] py-[2px] rounded-xs font-mono font-medium border border-[rgba(148,163,242,0.04)]",children:n.length})]}),(0,s.jsx)("div",{ref:x,className:["flex-1 overflow-y-auto flex flex-col gap-1.5 p-0.5 rounded-sm transition-all duration-300 ease-out-expo",u?"bg-[rgba(99,102,241,0.03)] outline-[1.5px] outline-dashed outline-[rgba(99,102,241,0.2)] -outline-offset-1 shadow-[inset_0_0_30px_rgba(99,102,241,0.03)]":""].join(" "),children:0===n.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-[72px] text-text-muted text-data border border-dashed border-[rgba(148,163,242,0.06)] rounded-md font-mono tracking-[0.02em] transition-all duration-250 ease-out-expo",children:u?"Drop here":"No items"}):n.map((e,a)=>(0,s.jsx)(S,{wi:e,projectSlug:r,onClick:()=>o(e),onEdit:()=>l(e),index:a,columnKey:t,onReorder:d},e.id))})]})}function _(e){let{projectSlug:t}=e,a=(0,o.U)(e=>e.goToWorkItem),n=(0,o.U)(e=>e.setView),{workItems:r,loading:i,fetchWorkItems:m}=(0,p.o)(),u=(0,l.i)(e=>e.projects.find(e=>e.slug===t)),[h,f]=(0,c.useState)(!1),[g,v]=(0,c.useState)(null);(0,c.useEffect)(()=>{m(t)},[t,m]);let N=(0,c.useMemo)(()=>{let e={planning:[],active:[],review:[],done:[]};for(let t of r)e[t.status]&&e[t.status].push(t);return e},[r]),S=(0,c.useMemo)(()=>{let e={feature:0,bug:0,refactor:0};for(let t of r)e[t.category]++;return e},[r]),_=(0,c.useCallback)(async(e,a)=>{try{await b.h.updateWorkItem(t,e,{status:a}),m(t)}catch(e){console.error("Failed to move work item:",e)}},[t,m]),z=(0,c.useCallback)(async(e,a,s,n,r)=>{try{a!==n&&await b.h.updateWorkItem(t,e,{status:n});let s=w.env.NEXT_PUBLIC_API_URL||"http://localhost:5555";await fetch("".concat(s,"/api/projects/").concat(t,"/work-items/").concat(e,"/reorder"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:r})}),m(t)}catch(e){console.error("Failed to reorder work item:",e)}},[t,m]);return i&&0===r.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted text-label font-mono tracking-[0.04em] animate-breathe",children:"Loading..."}):(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-[var(--space-lg,24px)] py-4 border-b border-border shrink-0 bg-gradient-to-b from-bg-subtle to-bg relative after:content-[''] after:absolute after:bottom-0 after:left-[5%] after:right-[5%] after:h-px after:bg-gradient-to-r after:from-transparent after:via-border-glow after:to-transparent",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-[3px]",children:[(0,s.jsx)("div",{className:"text-[18px] font-semibold tracking-[-0.03em] text-text",children:(null==u?void 0:u.title)||t}),(0,s.jsxs)("div",{className:"text-data text-text-muted flex gap-3 items-center font-mono",children:[S.feature>0&&(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"inline-block w-[5px] h-[5px] rounded-full mr-1 shadow-[0_0_6px_currentColor]",style:{background:k.feature.color}}),S.feature," feature",1!==S.feature?"s":""]}),S.bug>0&&(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"inline-block w-[5px] h-[5px] rounded-full mr-1 shadow-[0_0_6px_currentColor]",style:{background:k.bug.color}}),S.bug," bug",1!==S.bug?"s":""]}),S.refactor>0&&(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"inline-block w-[5px] h-[5px] rounded-full mr-1 shadow-[0_0_6px_currentColor]",style:{background:k.refactor.color}}),S.refactor," refactor",1!==S.refactor?"s":""]}),0===r.length&&(0,s.jsx)("span",{children:"No work items"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("button",{className:"btn-ghost",onClick:()=>f(!0),children:[(0,s.jsx)(d.Z,{size:16})," Quick"]}),(0,s.jsxs)("button",{className:"btn-primary",onClick:()=>n("planner"),children:[(0,s.jsx)(x.Z,{size:16})," Planner"]})]})]}),(0,s.jsx)("div",{className:"grid grid-cols-4 gap-2.5 p-5 px-[var(--space-lg,24px)] flex-1 overflow-x-auto overflow-y-hidden",children:C.map(e=>{let{key:n,label:r}=e;return(0,s.jsx)(T,{columnKey:n,label:r,items:N[n]||[],projectSlug:t,onCardClick:e=>a(t,e.slug),onCardEdit:e=>v(e),onDrop:_,onReorder:z},n)})}),h&&(0,s.jsx)(j,{projectSlug:t,onClose:()=>f(!1)}),g&&(0,s.jsx)(y,{projectSlug:t,workItem:g,onClose:()=>v(null)})]})}var z=a(4887),Z=a(3276),P=a(1239),E=a(875),A=a(3247),D=a(1094),R=a(9405);let I={CoderAgent:{bg:"rgba(59, 130, 246, 0.12)",text:"#3b82f6",border:"rgba(59, 130, 246, 0.25)"},TesterAgent:{bg:"rgba(34, 197, 94, 0.12)",text:"#22c55e",border:"rgba(34, 197, 94, 0.25)"},ReviewerAgent:{bg:"rgba(168, 85, 247, 0.12)",text:"#a855f7",border:"rgba(168, 85, 247, 0.25)"},DocAgent:{bg:"rgba(107, 114, 128, 0.12)",text:"#6b7280",border:"rgba(107, 114, 128, 0.25)"},SecurityAgent:{bg:"rgba(239, 68, 68, 0.12)",text:"#ef4444",border:"rgba(239, 68, 68, 0.25)"}};var O=a(8662),F=a(1723),L=a(9227),M=a(257);let U=["haiku","sonnet","opus"],W=["low","medium","high","urgent"],B=M.env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function q(e,t){let[a,s]=(0,c.useState)(!1),[n,r]=(0,c.useState)(!1),o=(0,c.useRef)(null),l=(0,c.useRef)([]),i=(0,R.E)(e=>e.addToast),d=(0,c.useCallback)(async()=>{if(a&&o.current){o.current.stop();return}try{let a=await navigator.mediaDevices.getUserMedia({audio:!0}),n=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",c=new MediaRecorder(a,{mimeType:n});l.current=[],c.ondataavailable=e=>{e.data.size>0&&l.current.push(e.data)},c.onstop=async()=>{a.getTracks().forEach(e=>e.stop()),s(!1),o.current=null;let c=new Blob(l.current,{type:n});if(c.size<100){i("Recording too short","error");return}r(!0),i("Transcribing with Whisper...","info");try{var d;let a=await c.arrayBuffer(),s=await fetch("".concat(B,"/api/voice/transcribe"),{method:"POST",headers:{"Content-Type":"application/octet-stream","X-Audio-Type":n.split(";")[0]},body:a}),r=await s.json();r.ok&&(null===(d=r.data)||void 0===d?void 0:d.text)?(e(r.data.text),i("".concat(t,': "').concat(r.data.text.slice(0,50),'..."'),"success")):i(r.error||"Transcription failed","error")}catch(e){i("Failed to transcribe","error")}r(!1)},o.current=c,c.start(),s(!0),i("Recording... click to stop","info")}catch(e){i("NotAllowedError"===e.name?"Microphone denied":"Mic error","error")}},[a,e,i,t]);return{listening:a,toggle:d,supported:!0,transcribing:n}}function J(e){let{listening:t,onClick:a,transcribing:n}=e;return(0,s.jsxs)("button",{type:"button",disabled:n,className:"inline-flex items-center gap-1 rounded-full transition-all duration-150 ml-1.5\n ".concat(n?"w-6 h-6 justify-center text-accent border border-accent/20 bg-accent-muted animate-spin-slow":t?"bg-danger-dim text-danger border border-danger/30 px-2 py-0.5":"w-6 h-6 justify-center text-text-muted hover:text-accent hover:bg-accent-muted border border-transparent"),onClick:a,title:n?"Transcribing...":t?"Stop recording":"Voice input",children:[(0,s.jsx)(O.Z,{size:11,className:t?"animate-breathe":""}),t&&(0,s.jsx)("span",{className:"text-[8px] font-mono font-semibold tracking-wide",children:"REC"}),n&&(0,s.jsx)("span",{className:"text-[8px] font-mono font-semibold tracking-wide",children:"..."})]})}let K=[{key:"backlog",label:"Backlog"},{key:"todo",label:"To Do"},{key:"in-progress",label:"In Progress"},{key:"review",label:"Review"},{key:"done",label:"Done"}],H={low:"#71717a",medium:"#6366f1",high:"#f59e0b",urgent:"#f43f5e"},X={haiku:"#22c55e",sonnet:"#6366f1",opus:"#a855f7"};function G(e){let{projectSlug:t,wiSlug:a,mode:n,task:r,defaultColumn:o,onSave:l,onDelete:i,onClose:d}=e,[x,m]=(0,c.useState)((null==r?void 0:r.title)||""),[u,p]=(0,c.useState)((null==r?void 0:r.description)||""),[g,j]=(0,c.useState)((null==r?void 0:r.model)||"sonnet"),[N,y]=(0,c.useState)((null==r?void 0:r.priority)||"medium"),[w,k]=(0,c.useState)(((null==r?void 0:r.tags)||[]).join(", ")),[C,S]=(0,c.useState)(o||"backlog"),[T,_]=(0,c.useState)(!1),[z,Z]=(0,c.useState)(!1),P=q((0,c.useCallback)(e=>m(t=>t?"".concat(t," ").concat(e):e),[]),"title"),E=q((0,c.useCallback)(e=>p(t=>t?"".concat(t," ").concat(e):e),[]),"description"),{overlayProps:A}=(0,f.N)(d,{disabled:T}),D=async e=>{if(e.preventDefault(),!x.trim())return;_(!0);let s=w.split(",").map(e=>e.trim()).filter(Boolean);try{"create"===n?await b.h.createTask(t,a,{title:x.trim(),description:u.trim(),model:g,priority:N,tags:s.length>0?s:void 0,column:C}):await b.h.updateTask(t,a,r.id,{title:x.trim(),description:u.trim(),model:g,priority:N,tags:s.length>0?s:void 0}),l()}catch(e){_(!1)}},R=async()=>{if(!z){Z(!0);return}_(!0);try{await b.h.deleteTask(t,a,r.id),i()}catch(e){_(!1)}};return(0,s.jsx)("div",{className:"glass-overlay",...A,children:(0,s.jsxs)("div",{className:"modal-box w-[540px] max-w-[92%] p-7 max-h-[88vh] overflow-y-auto overflow-x-hidden",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-7",children:[(0,s.jsx)("span",{className:"text-h2 font-semibold tracking-tight",children:"create"===n?"New Task":"Edit Task"}),(0,s.jsx)("button",{className:"btn-icon",onClick:d,children:(0,s.jsx)(h.Z,{size:16})})]}),(0,s.jsxs)("form",{className:"flex flex-col gap-5",onSubmit:D,children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center mb-2",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Title"}),(0,s.jsx)(J,{listening:P.listening,onClick:P.toggle,transcribing:P.transcribing})]}),(0,s.jsx)("input",{value:x,onChange:e=>m(e.target.value),placeholder:"What needs to be done...",autoFocus:!0})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center mb-2",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Description"}),(0,s.jsx)(J,{listening:E.listening,onClick:E.toggle,transcribing:E.transcribing})]}),(0,s.jsx)("textarea",{value:u,onChange:e=>p(e.target.value),placeholder:"Details, context, acceptance criteria...",rows:3})]}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col flex-1",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Model"}),(0,s.jsx)("div",{className:"flex gap-1 flex-wrap",children:U.map(e=>(0,s.jsx)("button",{type:"button",className:"py-[5px] px-[11px] text-[10px] font-medium rounded-full border\n cursor-pointer transition-all duration-150 ease-out-expo font-mono tracking-wide\n ".concat(g===e?"shadow-[0_0_8px_rgba(99,102,241,0.06)]":"border-border text-text-muted bg-transparent hover:border-border-light hover:text-text-secondary hover:bg-surface-hover"),style:g===e?{background:"".concat(X[e],"20"),color:X[e],borderColor:"".concat(X[e],"40")}:{},onClick:()=>j(e),children:e},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col flex-1",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Priority"}),(0,s.jsx)("div",{className:"flex gap-1 flex-wrap",children:W.map(e=>(0,s.jsx)("button",{type:"button",className:"py-[5px] px-[11px] text-[10px] font-medium rounded-full border\n cursor-pointer transition-all duration-150 ease-out-expo font-mono tracking-wide\n ".concat(N===e?"shadow-[0_0_8px_rgba(99,102,241,0.06)]":"border-border text-text-muted bg-transparent hover:border-border-light hover:text-text-secondary hover:bg-surface-hover"),style:N===e?{background:"".concat(H[e],"20"),color:H[e],borderColor:"".concat(H[e],"40")}:{},onClick:()=>y(e),children:e},e))})]})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Tags (comma separated)"}),(0,s.jsx)("input",{value:w,onChange:e=>k(e.target.value),placeholder:"backend, auth, api..."})]}),"create"===n&&(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Column"}),(0,s.jsx)("div",{className:"flex gap-1 flex-wrap",children:K.map(e=>(0,s.jsx)("button",{type:"button",className:"py-[5px] px-[11px] text-[10px] font-medium rounded-full border\n cursor-pointer transition-all duration-150 ease-out-expo font-mono tracking-wide\n ".concat(C===e.key?"border-[rgba(99,102,241,0.2)] text-accent bg-accent-muted shadow-[0_0_8px_rgba(99,102,241,0.06)]":"border-border text-text-muted bg-transparent hover:border-border-light hover:text-text-secondary hover:bg-surface-hover"),onClick:()=>S(e.key),children:e.label},e.key))})]}),"edit"===n&&r&&(0,s.jsx)(Q,{projectSlug:t,wiSlug:a,task:r}),"edit"===n&&(null==r?void 0:r.output)&&(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Output"}),(0,s.jsx)("div",{className:"bg-bg border border-border rounded-md py-3 px-3.5 font-mono text-[10px] leading-relaxed text-text-muted max-h-[200px] overflow-y-auto whitespace-pre-wrap break-all shadow-inset",children:r.output})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:["edit"===n&&(0,s.jsxs)("button",{type:"button",className:"btn-danger",onClick:R,disabled:T,children:[(0,s.jsx)(v.Z,{size:14}),z?"Confirm?":"Delete"]}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsx)("button",{type:"button",className:"btn-ghost",onClick:d,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"btn-primary",disabled:!x.trim()||T,children:T?"Saving...":"create"===n?"Create":"Save"})]})]})]})})}let V=M.env.NEXT_PUBLIC_API_URL||"http://localhost:5555",Y=["once","daily","weekly","biweekly","monthly"],$=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Q(e){let{projectSlug:t,wiSlug:a,task:n}=e,r=(0,R.E)(e=>e.addToast),[o,l]=(0,c.useState)(null),[i,d]=(0,c.useState)(!1),[x,m]=(0,c.useState)("daily"),[u,p]=(0,c.useState)("09:00"),[b,h]=(0,c.useState)(1),[f,g]=(0,c.useState)(1),[j,N]=(0,c.useState)(!1),y=(0,c.useCallback)(async()=>{try{let e=await fetch("".concat(V,"/api/scheduler/task/").concat(t,"/").concat(a,"/").concat(n.id)),s=await e.json();s.ok&&s.data&&l(s.data)}catch(e){}},[t,a,n.id]);(0,c.useEffect)(()=>{y()},[y]);let w=async()=>{N(!0);try{await fetch("".concat(V,"/api/scheduler/schedules"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t,workItemSlug:a,taskId:n.id,taskTitle:n.title,frequency:x,time:u,dayOfWeek:"weekly"===x||"biweekly"===x?b:void 0,dayOfMonth:"monthly"===x?f:void 0})}),r("Schedule saved","success"),d(!1),y()}catch(e){r("Failed","error")}N(!1)},k=async()=>{o&&(await fetch("".concat(V,"/api/scheduler/schedules/").concat(o.id),{method:"DELETE"}),l(null),r("Schedule removed","info"))},C=async()=>{o&&(await fetch("".concat(V,"/api/scheduler/schedules/").concat(o.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!o.enabled})}),y())},[S,T]=(0,c.useState)(!1),_=async()=>{if(o&&!S){T(!0);try{let e=await fetch("".concat(V,"/api/scheduler/schedules/").concat(o.id,"/run"),{method:"POST"}),t=await e.json();t.ok?r("Task execution started via Ralph","success"):r(t.error||"Failed to start","error")}catch(e){r("Failed to trigger","error")}setTimeout(()=>{T(!1),y()},2e3)}};return(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsxs)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:[(0,s.jsx)(F.Z,{size:11,className:"inline align-middle mr-1"}),"Schedule"]}),o&&!i?(0,s.jsxs)("div",{className:"p-3 px-3.5 border border-border rounded-sm bg-bg flex flex-col gap-2 shadow-inset",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 flex-wrap",children:[(0,s.jsx)("span",{className:"text-[10px] font-semibold text-accent py-0.5 px-2 rounded-xs bg-accent-muted font-mono uppercase tracking-wide border border-[rgba(99,102,241,0.1)]",children:o.frequency}),(0,s.jsx)("span",{className:"text-xs font-medium text-text font-mono",children:o.time}),o.nextRun&&(0,s.jsxs)("span",{className:"text-[10px] text-text-muted font-mono",children:["Next: ",new Date(o.nextRun).toLocaleString()]})]}),(0,s.jsxs)("div",{className:"flex gap-1",children:[(0,s.jsx)("button",{type:"button",className:"inline-flex items-center gap-[3px] text-xxs font-medium py-[3px] px-2 rounded-xs font-mono text-text-muted border border-border transition-all duration-120 ease-out-expo hover:text-accent hover:border-[rgba(99,102,241,0.2)] hover:bg-accent-muted",onClick:C,children:o.enabled?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(L.Z,{size:10})," Pause"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Z.Z,{size:10})," Enable"]})}),(0,s.jsx)("button",{type:"button",className:"inline-flex items-center gap-[3px] text-xxs font-medium py-[3px] px-2 rounded-xs font-mono text-text-muted border border-border transition-all duration-120 ease-out-expo hover:text-accent hover:border-[rgba(99,102,241,0.2)] hover:bg-accent-muted",onClick:_,disabled:S,children:S?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"inline-block w-2.5 h-2.5 border border-white/20 border-t-white rounded-full animate-spin"})," Running..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Z.Z,{size:10})," Run Now"]})}),(0,s.jsx)("button",{type:"button",className:"inline-flex items-center gap-[3px] text-xxs font-medium py-[3px] px-2 rounded-xs font-mono text-text-muted border border-border transition-all duration-120 ease-out-expo hover:text-accent hover:border-[rgba(99,102,241,0.2)] hover:bg-accent-muted",onClick:()=>{m(o.frequency),p(o.time),d(!0)},children:"Edit"}),(0,s.jsx)("button",{type:"button",className:"inline-flex items-center gap-[3px] text-xxs py-[3px] px-1.5 rounded-xs text-text-muted border border-border transition-all duration-120 ease-out-expo hover:text-danger hover:border-[rgba(248,113,113,0.2)] hover:bg-danger-dim",onClick:k,children:(0,s.jsx)(v.Z,{size:10})})]}),o.lastRun&&(0,s.jsxs)("div",{className:"text-xxs text-text-muted font-mono opacity-60",children:["Last: ",new Date(o.lastRun).toLocaleString()," (",o.lastStatus,") — ",o.runCount," runs"]})]}):i?(0,s.jsxs)("div",{className:"p-3 px-3.5 border border-border rounded-sm bg-bg flex flex-col gap-2.5",children:[(0,s.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:(0,s.jsx)("div",{className:"flex gap-1 flex-wrap",children:Y.map(e=>(0,s.jsx)("button",{type:"button",className:"py-[5px] px-[11px] text-[10px] font-medium rounded-full border\n cursor-pointer transition-all duration-150 ease-out-expo font-mono tracking-wide\n ".concat(x===e?"border-[rgba(99,102,241,0.2)] text-accent bg-accent-muted shadow-[0_0_8px_rgba(99,102,241,0.06)]":"border-border text-text-muted bg-transparent hover:border-border-light hover:text-text-secondary hover:bg-surface-hover"),onClick:()=>m(e),children:e},e))})}),(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("input",{type:"time",value:u,onChange:e=>p(e.target.value),className:"!w-[100px] !font-mono !text-xs"}),("weekly"===x||"biweekly"===x)&&(0,s.jsx)("div",{className:"flex gap-1 flex-wrap",children:$.map((e,t)=>(0,s.jsx)("button",{type:"button",className:"py-[5px] px-[11px] text-[10px] font-medium rounded-full border\n cursor-pointer transition-all duration-150 ease-out-expo font-mono tracking-wide\n ".concat(b===t?"border-[rgba(99,102,241,0.2)] text-accent bg-accent-muted shadow-[0_0_8px_rgba(99,102,241,0.06)]":"border-border text-text-muted bg-transparent hover:border-border-light hover:text-text-secondary hover:bg-surface-hover"),onClick:()=>h(t),children:e},e))}),"monthly"===x&&(0,s.jsx)("input",{type:"number",min:1,max:31,value:f,onChange:e=>g(Number(e.target.value)),className:"!w-[100px] !font-mono !text-xs",placeholder:"Day"})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,s.jsx)("button",{type:"button",className:"btn-ghost",onClick:()=>d(!1),children:"Cancel"}),(0,s.jsx)("button",{type:"button",className:"btn-primary",onClick:w,disabled:j,children:j?"Saving...":"Save Schedule"})]})]}):(0,s.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 text-label font-medium text-text-muted py-2 px-3 border border-dashed border-border rounded-sm w-full transition-all duration-150 ease-out-expo font-mono hover:border-accent hover:text-accent hover:bg-accent-muted",onClick:()=>d(!0),children:[(0,s.jsx)(F.Z,{size:12})," Add Schedule"]})]})}let ee=["low","medium","high","urgent"],et=["haiku","sonnet","opus"],ea={search:"",tags:[],priorities:[],models:[]};function es(e){return""!==e.search||e.tags.length>0||e.priorities.length>0||e.models.length>0}function en(e,t){if(t.search){var a,s;let n=t.search.toLowerCase();if(!((null===(a=e.title)||void 0===a?void 0:a.toLowerCase().includes(n))||(null===(s=e.description)||void 0===s?void 0:s.toLowerCase().includes(n))))return!1}if(t.tags.length>0){let a=e.tags||[];if(!t.tags.some(e=>a.includes(e)))return!1}return(!(t.priorities.length>0)||!!t.priorities.includes(e.priority))&&(!(t.models.length>0)||!!t.models.includes(e.model))}function er(e){let{filter:t,onChange:a,allTags:n,totalCount:r,filteredCount:o}=e,[l,i]=(0,c.useState)(!1),d=e=>{let s=t.tags.includes(e)?t.tags.filter(t=>t!==e):[...t.tags,e];a({...t,tags:s})},x=e=>{let s=t.priorities.includes(e)?t.priorities.filter(t=>t!==e):[...t.priorities,e];a({...t,priorities:s})},m=e=>{let s=t.models.includes(e)?t.models.filter(t=>t!==e):[...t.models,e];a({...t,models:s})},u=es(t);return(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 animate-filter-in flex-wrap",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-input border border-input-border rounded-sm px-2.5 py-1.5 flex-1 min-w-[180px] max-w-[260px]",children:[(0,s.jsx)(A.Z,{size:14,className:"text-text-muted flex-shrink-0"}),(0,s.jsx)("input",{className:"bg-transparent border-none outline-none text-xs text-text placeholder:text-text-muted p-0 w-full shadow-none",value:t.search,onChange:e=>a({...t,search:e.target.value}),placeholder:"Search tasks...",autoFocus:!0})]}),(0,s.jsx)("div",{className:"flex items-center gap-1",children:ee.map(e=>(0,s.jsx)("button",{className:"px-2.5 py-1 rounded-full text-xxs font-medium border capitalize transition-all duration-150 ease-out-expo\n ".concat(t.priorities.includes(e)?"bg-accent-muted border-accent/30 text-accent shadow-[0_0_8px_rgba(99,102,241,0.1)]":"bg-surface border-border text-text-secondary hover:border-border-light hover:text-text"),onClick:()=>x(e),children:e},e))}),(0,s.jsx)("div",{className:"flex items-center gap-1",children:et.map(e=>(0,s.jsx)("button",{className:"px-2.5 py-1 rounded-full text-xxs font-medium border capitalize transition-all duration-150 ease-out-expo\n ".concat(t.models.includes(e)?"bg-accent-muted border-accent/30 text-accent shadow-[0_0_8px_rgba(99,102,241,0.1)]":"bg-surface border-border text-text-secondary hover:border-border-light hover:text-text"),onClick:()=>m(e),children:e},e))}),n.length>0&&(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("button",{className:"px-2.5 py-1 rounded-full text-xxs font-medium border transition-all duration-150 ease-out-expo\n ".concat(t.tags.length>0?"bg-accent-muted border-accent/30 text-accent":"bg-surface border-border text-text-secondary hover:border-border-light"),onClick:()=>i(!l),children:["Tags ",t.tags.length>0&&"(".concat(t.tags.length,")")]}),l&&(0,s.jsx)("div",{className:"absolute top-full mt-1 left-0 min-w-[140px] bg-glass backdrop-blur-glass border border-glass-border rounded-md shadow-elevated z-50 py-1 animate-filter-in",children:n.map(e=>(0,s.jsxs)("button",{className:"w-full text-left px-3 py-1.5 text-xs transition-colors duration-100\n ".concat(t.tags.includes(e)?"text-accent bg-accent-muted":"text-text-secondary hover:bg-surface-hover hover:text-text"),onClick:()=>d(e),children:["#",e]},e))})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 ml-auto",children:u&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"text-data font-mono text-text-muted",children:[o,"/",r]}),(0,s.jsxs)("button",{className:"flex items-center gap-1 text-xxs text-text-muted hover:text-danger transition-colors duration-120",onClick:()=>a(ea),children:[(0,s.jsx)(h.Z,{size:12})," Clear"]})]})})]})}var eo=a(2569);let el=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555",ec={feature:{color:"#6366f1",icon:"✦",label:"FEAT"},bug:{color:"#ef4444",icon:"●",label:"BUG"},refactor:{color:"#f59e0b",icon:"◆",label:"REF"}},ei=[{key:"backlog",label:"Backlog"},{key:"todo",label:"To Do"},{key:"in-progress",label:"In Progress"},{key:"review",label:"Review"},{key:"done",label:"Done"}],ed={urgent:"#f43f5e",high:"#f59e0b",medium:"#6366f1",low:"#71717a"},ex={bg:"rgba(148, 163, 242, 0.1)",text:"#94a3f2",border:"rgba(148, 163, 242, 0.2)"};function em(e){let{agents:t,currentAgent:a,suggestedAgent:n,position:r,onSelect:o,onClose:l}=e,i=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&l()},t=e=>{"Escape"===e.key&&l()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l]),(0,z.createPortal)((0,s.jsxs)("div",{ref:i,className:"fixed z-[9999] min-w-[180px] py-1 rounded-md border border-glass-border shadow-elevated animate-filter-in",style:{top:r.top,left:r.left,background:"rgba(15, 15, 18, 0.95)",backdropFilter:"blur(20px)"},children:[n&&(0,s.jsxs)("button",{className:"w-full text-left px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover hover:text-text transition-colors duration-100 flex items-center gap-2",onClick:()=>o(null),children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:(I[n]||ex).text,opacity:.5}}),(0,s.jsx)("span",{className:"text-text-muted",children:"Auto"}),(0,s.jsx)("span",{className:"text-text-muted/50 ml-auto text-[10px]",children:n})]}),a&&(0,s.jsx)("button",{className:"w-full text-left px-3 py-1.5 text-xs text-danger/70 hover:bg-[rgba(248,113,113,0.06)] hover:text-danger transition-colors duration-100",onClick:()=>o(null),children:"Remove agent"}),(a||n)&&(0,s.jsx)("div",{className:"h-px my-1 bg-border/50"}),t.map(e=>{let t=I[e.name]||ex,n=a===e.name;return(0,s.jsxs)("button",{className:"w-full text-left px-3 py-1.5 text-xs transition-colors duration-100 flex items-center gap-2\n ".concat(n?"font-medium":"text-text-secondary hover:bg-surface-hover hover:text-text"),style:n?{background:t.bg,color:t.text}:void 0,onClick:()=>o(e.name),children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:t.text}}),(0,s.jsx)("span",{className:"truncate",children:e.name}),(0,s.jsx)("span",{className:"text-text-muted/40 text-[10px] ml-auto shrink-0",children:e.model})]},e.name)}),0===t.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-text-muted/50 italic",children:"Loading agents..."})]}),document.body)}function eu(e){var t,a;let{task:n,columnKey:r,projectSlug:o,wiSlug:l,onEdit:i,onToggle:d,onRunTask:x,onAgentChange:p,agents:b,suggestedAgent:h,index:f,onDropOnCard:g}=e,j=(0,c.useRef)(null),[v,N]=(0,c.useState)(!1),[y,w]=(0,c.useState)(null),[k,C]=(0,c.useState)(!1),[S,T]=(0,c.useState)({top:0,left:0});(0,c.useEffect)(()=>{let e=j.current;if(!e)return;let t=(0,m.En)({element:e,getInitialData:()=>({type:"task",taskId:n.id,fromColumn:r,fromIndex:f}),onDragStart:()=>N(!0),onDrop:()=>N(!1)}),a=(0,m.wO)({element:e,getData:e=>{let{input:t,element:a}=e;return(0,u.X)({type:"task-card",taskId:n.id,columnKey:r,index:f},{input:t,element:a,allowedEdges:["top","bottom"]})},canDrop:e=>{let{source:t}=e;return"task"===t.data.type&&t.data.taskId!==n.id},onDragEnter:e=>{let{self:t}=e;return w((0,u.A)(t.data))},onDrag:e=>{let{self:t}=e;return w((0,u.A)(t.data))},onDragLeave:()=>w(null),onDrop:e=>{let{source:t,self:a}=e;w(null);let s=t.data.taskId,n=t.data.fromColumn,o=t.data.fromIndex,l=(0,u.A)(a.data),c=f;"bottom"===l&&(c=f+1),n===r&&o<c&&c--,g(s,n,r,c)}});return()=>{t(),a()}},[n.id,r,f,g]);let _=ed[n.priority]||"transparent",z=n.priority||n.model||n.agent||(null===(t=n.tags)||void 0===t?void 0:t.length)||n.output;return(0,s.jsxs)("div",{ref:j,className:"\n group flex bg-card border border-border rounded-md cursor-pointer\n shadow-card overflow-hidden\n hover:-translate-y-[3px] hover:shadow-card-hover hover:border-border-light\n transition-all duration-200 ease-out-expo\n animate-stagger-in\n before:absolute before:left-0 before:top-0 before:bottom-0 before:w-[3px]\n before:rounded-l-[3px] before:bg-[var(--priority-color)]\n before:transition-[background] before:duration-300 before:ease-out-expo\n relative\n ".concat(n.completed?"opacity-40":"","\n ").concat(v?"opacity-20 scale-95 rotate-2 shadow-drag":"","\n "),style:{animationDelay:"".concat(60*f,"ms"),"--priority-color":n.priority?_:"var(--border)"},onClick:i,children:["top"===y&&(0,s.jsx)("div",{className:"absolute top-0 left-1 right-1 h-[2px] bg-accent rounded-full z-10 shadow-[0_0_6px_var(--accent-glow)]",style:{transform:"translateY(-1px)"}}),"bottom"===y&&(0,s.jsx)("div",{className:"absolute bottom-0 left-1 right-1 h-[2px] bg-accent rounded-full z-10 shadow-[0_0_6px_var(--accent-glow)]",style:{transform:"translateY(1px)"}}),(0,s.jsxs)("div",{className:"flex-1 pl-[15px] pr-3 py-2.5 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("span",{className:"\n w-[15px] h-[15px] rounded-full shrink-0 mt-0.5\n flex items-center justify-center cursor-pointer\n transition-all duration-150 ease-out-expo\n ".concat(n.completed?"bg-accent border-[1.5px] border-accent":"border-[1.5px] border-border-light hover:border-accent hover:bg-accent-muted","\n "),onClick:e=>{e.stopPropagation(),d()},children:n.completed&&(0,s.jsx)("span",{className:"text-white text-[8px] leading-none",children:"✓"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"\n flex-1 text-[12.5px] font-medium text-text\n overflow-hidden text-ellipsis whitespace-nowrap\n leading-[1.4] tracking-[-0.01em]\n ".concat(n.completed?"line-through !text-text-muted":"","\n "),children:n.title}),!n.completed&&(0,s.jsx)("button",{className:"w-[18px] h-[18px] rounded-full shrink-0 flex items-center justify-center text-text-muted opacity-0 group-hover:opacity-100 transition-all duration-150 ease-out-expo hover:text-success hover:bg-success-dim hover:shadow-[0_0_8px_rgba(52,211,153,0.2)]",onClick:e=>{e.stopPropagation(),x()},title:"Run this task with Ralph",children:(0,s.jsx)(Z.Z,{size:9,fill:"currentColor"})})]}),n.description&&(0,s.jsx)("span",{className:"text-[10.5px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap mt-1.5 leading-[1.3]",children:n.description})]})]}),z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"h-px my-2",style:{background:"linear-gradient(90deg, var(--border), transparent 80%)"}}),(0,s.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,s.jsx)("span",{className:"inline-flex items-center px-[7px] py-px rounded-xs text-xxs font-medium font-mono tracking-[0.02em] border text-accent bg-accent-muted border-[rgba(99,102,241,0.1)] uppercase",children:n.model}),n.priority&&(0,s.jsx)("span",{className:"inline-flex items-center px-[7px] py-px rounded-xs text-xxs font-semibold font-mono tracking-[0.02em] border bg-transparent uppercase",style:{color:_,borderColor:"".concat(_,"30")},children:n.priority}),(()=>{let e=n.agent||h,t=!!n.agent,a=e?I[e]||ex:null;return(0,s.jsxs)("button",{className:"inline-flex items-center gap-1 px-[7px] py-px rounded-xs text-xxs font-medium font-mono tracking-[0.02em] border transition-all duration-150 cursor-pointer hover:brightness-125\n ".concat(e?"":"border-border text-text-muted/40 hover:text-text-muted hover:border-border-light","\n ").concat("","\n ").concat(e&&!t?"border-dashed":"","\n "),style:e&&a?{color:a.text,background:a.bg,borderColor:a.border,opacity:t?1:.6}:void 0,onClick:e=>{e.stopPropagation();let t=e.target.getBoundingClientRect();T({top:t.bottom+4,left:t.left}),C(!k)},title:e?t?"Agent: ".concat(e):"Auto: ".concat(e):"Assign agent",children:[(0,s.jsx)(P.Z,{size:9}),e?(0,s.jsxs)(s.Fragment,{children:[!t&&(0,s.jsx)("span",{className:"text-[8px] opacity-60",children:"auto:"}),e]}):(0,s.jsx)("span",{children:"agent"})]})})(),k&&(0,s.jsx)(em,{agents:b,currentAgent:n.agent||null,suggestedAgent:h,position:S,onSelect:e=>{p(n.id,e),C(!1)},onClose:()=>C(!1)}),null===(a=n.tags)||void 0===a?void 0:a.map(e=>(0,s.jsx)("span",{className:"inline-flex items-center px-[7px] py-px rounded-xs text-xxs font-medium font-mono tracking-[0.02em] border border-border text-text-muted bg-pill",children:e},e)),n.output&&(0,s.jsx)("span",{className:"inline-flex items-center px-[7px] py-px rounded-xs text-[8px] font-semibold font-mono tracking-[0.04em] border text-success bg-success-dim border-[rgba(52,211,153,0.08)] uppercase",children:"output"})]})]})]})]})}function ep(e){let{columnKey:t,label:a,tasks:n,projectSlug:r,wiSlug:o,onDrop:l,onEditTask:i,onToggleTask:x,onRunTask:u,onAgentChange:p,agents:b,agentSuggestions:h,onAddTask:f}=e,g=(0,c.useRef)(null),[j,v]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{let e=g.current;if(e)return(0,m.wO)({element:e,getData:()=>({columnKey:t,type:"column"}),canDrop:e=>{let{source:t}=e;return"task"===t.data.type},onDragEnter:()=>v(!0),onDragLeave:()=>v(!1),onDrop:e=>{let{source:a,location:s}=e;v(!1),!s.current.dropTargets.some(e=>"task-card"===e.data.type)&&l(a.data.taskId,a.data.fromColumn,t,n.length)}})},[t,n.length,l]),(0,s.jsxs)("div",{className:"flex flex-col min-w-[200px] gap-1.5 overflow-hidden group",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-1.5 py-2 mb-1",children:[(0,s.jsx)("span",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:a}),(0,s.jsx)("span",{className:"text-xxs text-text-muted bg-pill px-1.5 py-0.5 rounded-xs font-mono font-medium",children:n.length}),(0,s.jsx)("button",{className:"ml-auto inline-flex items-center justify-center w-5 h-5 rounded-xs text-text-muted opacity-0 group-hover:opacity-100 hover:bg-surface-hover hover:text-text-secondary transition-all duration-150",onClick:f,title:"Add task",children:(0,s.jsx)(d.Z,{size:14})})]}),(0,s.jsx)("div",{ref:g,className:"\n flex-1 overflow-y-auto flex flex-col gap-1.5 p-0.5 rounded-sm\n transition-all duration-250 ease-out-expo\n ".concat(j?"bg-[rgba(99,102,241,0.04)] outline outline-[1.5px] outline-dashed outline-[rgba(99,102,241,0.2)] -outline-offset-1":"","\n "),children:0===n.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-14 text-text-muted text-data border border-dashed border-[rgba(148,163,242,0.06)] rounded-sm font-mono tracking-[0.02em]",children:j?"Drop here":"Empty"}):n.map((e,a)=>{var n;return(0,s.jsx)(eu,{task:e,columnKey:t,projectSlug:r,wiSlug:o,onEdit:()=>i(e),onToggle:()=>x(e.id,e.completed,t),onRunTask:()=>u(e.id),onAgentChange:p,agents:b,suggestedAgent:null!==(n=h[e.id])&&void 0!==n?n:null,index:a,onDropOnCard:l},e.id)})})]})}function eb(e){var t,a,x;let{projectSlug:m,wiSlug:u}=e,{goHome:h,goToProject:f}=(0,o.U)(),g=(0,l.i)(e=>e.projects),{workItems:j,fetchWorkItems:v}=(0,p.o)(),N=(0,R.E)(e=>e.addToast),y=(0,eo.q)(e=>e.ralph),[w,k]=(0,c.useState)(!1),[C,S]=(0,c.useState)(!1),[T,_]=(0,c.useState)(""),[z,P]=(0,c.useState)(null),[I,O]=(0,c.useState)(!1),[F,L]=(0,c.useState)(ea),[M,U]=(0,c.useState)(!1),[W,B]=(0,c.useState)([]),q="running"===y.status||"paused"===y.status,J=y.workItemSlug===u||y.projectSlug===m;(0,c.useEffect)(()=>{v(m)},[m,v]),(0,c.useEffect)(()=>{b.h.getAgents().then(B).catch(()=>{})},[]);let K=(0,c.useMemo)(()=>j.find(e=>e.slug===u||e.id===u),[j,u]),H=(0,c.useCallback)(async()=>{if(K)try{await fetch("".concat(el,"/api/ralph/start"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:m,workItemSlug:K.slug})}),U(!0),N("Ralph started","success")}catch(e){N("Failed to start","error")}},[K,m,N]),X=(0,c.useCallback)(async()=>{await fetch("".concat(el,"/api/ralph/stop"),{method:"POST"})},[]),V=(0,c.useCallback)(async e=>{var t;if(!K)return;let a=Object.values(K.columns).flat().find(t=>t.id===e);if(!a)return;let s=null===(t=Object.entries(K.columns).find(t=>{let[,a]=t;return a.some(t=>t.id===e)}))||void 0===t?void 0:t[0];if(s&&"todo"!==s)try{await b.h.moveTask(m,K.slug,e,{toColumn:"todo",toIndex:0}),await v(m)}catch(e){N("Failed to move task","error");return}try{let t=await fetch("".concat(el,"/api/ralph/start"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:m,workItemSlug:K.slug,taskIds:[e]})}),s=await t.json();s.ok?(U(!0),N("Running: ".concat(a.title),"success")):N(s.error||"Failed to start","error")}catch(e){N("Failed to start Ralph","error")}},[K,m,v,N]),Y=(0,c.useCallback)(async(e,t,a,s)=>{if(K)try{await b.h.moveTask(m,K.slug,e,{toColumn:a,toIndex:s}),v(m),N("Task moved","success")}catch(e){console.error("Failed to move task:",e),N("Failed to move task","error")}},[K,m,v,N]),$=(0,c.useCallback)(async(e,t,a)=>{if(K)try{if(t){let t=(K.columns.done||[]).find(t=>t.id===e),a=(null==t?void 0:t.previousColumn)||"backlog";await b.h.moveTask(m,K.slug,e,{toColumn:a,toIndex:0})}else await b.h.moveTask(m,K.slug,e,{toColumn:"done",toIndex:0});v(m)}catch(e){console.error("Failed to toggle task:",e),N("Failed to move task","error")}},[K,m,v,N]),Q=(0,c.useCallback)(async(e,t)=>{if(K)try{await b.h.updateTask(m,K.slug,e,{agent:t||""}),v(m)}catch(e){N("Failed to assign agent","error")}},[K,m,v,N]),ee=(0,c.useMemo)(()=>{let e={};if(!K||0===W.length)return e;for(let s of Object.values(K.columns))for(let n of s){var t,a;if(n.agent||!(null===(t=n.tags)||void 0===t?void 0:t.length))continue;let s=null,r=0;for(let e of W){let t=n.tags.filter(t=>(e.skills||[]).some(e=>e.toLowerCase()===t.toLowerCase())).length;if(0===t)continue;let o=t/((null===(a=e.skills)||void 0===a?void 0:a.length)||1);o>r&&(r=o,s=e.name)}s&&(e[n.id]=s)}return e},[K,W]),et=(0,c.useCallback)(()=>{P(null),v(m),N((null==z?void 0:z.mode)==="create"?"Task created":"Task updated","success")},[m,v,N,null==z?void 0:z.mode]),ed=(0,c.useCallback)(()=>{P(null),v(m),N("Task deleted","success")},[m,v,N]),ex=(0,c.useCallback)(()=>{K&&(_(K.plan.content||""),S(!0),k(!0))},[K]),em=(0,c.useCallback)(async()=>{if(K)try{await b.h.updateWorkItem(m,K.slug,{plan:{content:T,status:T.trim()?"approved":"empty"}}),v(m),S(!1),N("Plan updated","success")}catch(e){N("Failed to save plan","error")}},[K,m,T,v,N]),eu=(0,c.useMemo)(()=>{if(!K)return[];let e=new Set;for(let t of Object.values(K.columns))for(let a of t)(a.tags||[]).forEach(t=>e.add(t));return Array.from(e).sort()},[K]),{totalCount:eb,filteredCount:eh}=(0,c.useMemo)(()=>{if(!K)return{totalCount:0,filteredCount:0};let e=0,t=0,a=es(F);for(let s of Object.values(K.columns))for(let n of s)e++,(!a||en(n,F))&&t++;return{totalCount:e,filteredCount:a?t:e}},[K,F]);if(!K)return(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted text-body",children:"Loading..."});let ef=ec[K.category],eg=(()=>{let e=0,t=0;for(let a of Object.values(K.columns))e+=a.length,t+=a.filter(e=>e.completed).length;return{completed:t,total:e,percent:0===e?0:Math.round(t/e*100)}})();return(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-border shrink-0 bg-bg",children:[(0,s.jsxs)("nav",{className:"flex items-center gap-1 text-label text-text-muted",children:[(0,s.jsx)("button",{className:"inline-flex items-center gap-1 px-2 py-[5px] rounded-sm transition-all duration-150 hover:bg-surface-hover hover:text-text",onClick:h,children:(0,s.jsx)(n.Z,{size:14})}),(0,s.jsx)(r.Z,{size:10,className:"text-text-muted/50"}),(0,s.jsx)("button",{className:"px-2 py-[5px] rounded-sm transition-all duration-150 hover:bg-surface-hover hover:text-text font-medium truncate max-w-[160px]",onClick:()=>f(m),children:null!==(x=null===(t=g.find(e=>e.slug===m))||void 0===t?void 0:t.title)&&void 0!==x?x:m}),(0,s.jsx)(r.Z,{size:10,className:"text-text-muted/50"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-h2 shrink-0",style:{color:ef.color},children:ef.icon}),(0,s.jsx)("span",{className:"text-h2 font-semibold whitespace-nowrap overflow-hidden text-ellipsis tracking-[-0.02em]",children:K.title}),(0,s.jsx)("span",{className:"badge badge-".concat(K.category),children:ef.label})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,s.jsx)("div",{className:"w-[100px] h-[3px] rounded-[3px] bg-[rgba(148,163,242,0.06)] overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-[3px] transition-[width] duration-[800ms] ease-out-expo",style:{width:"".concat(eg.percent,"%"),background:ef.color}})}),(0,s.jsxs)("span",{className:"text-data text-text-muted whitespace-nowrap font-mono",children:[eg.completed,"/",eg.total]})]}),(0,s.jsxs)("button",{className:"\n inline-flex items-center gap-1 text-label font-medium text-text-muted\n px-2.5 py-[5px] rounded-sm border border-border\n transition-all duration-150 hover:bg-surface-hover hover:text-text-secondary\n ".concat(w?"[&_svg]:rotate-180":"","\n "),onClick:()=>{C||k(!w)},children:["Plan ",(0,s.jsx)(E.Z,{size:14,className:"transition-transform duration-250 ease-out-expo"})]}),(0,s.jsx)("button",{className:"btn-icon ".concat(I?"!text-accent !bg-accent-muted":""),onClick:()=>O(!I),title:"Filter (Ctrl+F)",children:(0,s.jsx)(A.Z,{size:16})}),(0,s.jsxs)("button",{className:"btn-primary",onClick:()=>P({mode:"create",column:"backlog"}),children:[(0,s.jsx)(d.Z,{size:16}),"Task"]}),q&&J?(0,s.jsxs)("button",{className:"inline-flex items-center gap-[5px] px-3.5 py-1.5 border border-[rgba(248,113,113,0.2)] text-danger text-label font-semibold rounded-sm transition-all duration-150 ease-out-expo hover:bg-danger-dim hover:shadow-[0_0_16px_rgba(248,113,113,0.08)]",onClick:X,children:[(0,s.jsx)(D.Z,{size:14})," Stop"]}):(0,s.jsxs)("button",{className:"inline-flex items-center gap-[5px] px-3.5 py-1.5 text-white text-label font-semibold rounded-sm transition-all duration-150 ease-out-expo tracking-[0.01em] relative overflow-hidden bg-gradient-to-br from-emerald-600 to-emerald-400 before:absolute before:inset-0 before:bg-gradient-to-b before:from-white/15 before:to-transparent before:pointer-events-none hover:enabled:shadow-[0_0_20px_rgba(52,211,153,0.25)] hover:enabled:-translate-y-px disabled:opacity-20 disabled:cursor-not-allowed disabled:saturate-50 disabled:transform-none disabled:shadow-none",onClick:H,disabled:!K.columns.todo||0===K.columns.todo.length,title:(null===(a=K.columns.todo)||void 0===a?void 0:a.length)?"Run ".concat(K.columns.todo.length," tasks"):"No tasks in To Do",children:[(0,s.jsx)(Z.Z,{size:14})," Run"]})]}),I&&(0,s.jsx)(er,{filter:F,onChange:L,allTags:eu,totalCount:eb,filteredCount:eh}),w&&(0,s.jsx)("div",{className:"border-b border-border bg-surface",children:C?(0,s.jsxs)("div",{className:"px-5 py-3.5 flex flex-col gap-2",children:[(0,s.jsx)("textarea",{className:"w-full min-h-[120px] resize-y",value:T,onChange:e=>_(e.target.value),rows:8,placeholder:"Write a plan for this work item...",autoFocus:!0}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("button",{className:"btn-ghost",onClick:()=>S(!1),children:"Cancel"}),(0,s.jsx)("button",{className:"btn-primary",onClick:em,children:"Save Plan"})]})]}):(0,s.jsxs)("div",{className:"relative max-h-[200px] overflow-y-auto",children:[(0,s.jsx)("div",{className:"px-5 py-3.5 text-body text-text-secondary leading-[1.7] whitespace-pre-wrap",children:K.plan.content||(0,s.jsx)("span",{className:"italic text-text-muted opacity-50",children:"No plan yet. Click edit to add one."})}),(0,s.jsxs)("button",{className:"absolute top-2 right-3 inline-flex items-center gap-1 text-data text-text-muted px-2 py-[3px] rounded-xs transition-all duration-150 hover:bg-surface-hover hover:text-accent",onClick:ex,children:[(0,s.jsx)(i.Z,{size:12})," Edit"]})]})}),(0,s.jsx)("div",{className:"grid grid-cols-5 gap-2.5 p-5 flex-1 overflow-x-auto overflow-y-hidden",children:ei.map(e=>{let{key:t,label:a}=e;return(0,s.jsx)(ep,{columnKey:t,label:a,tasks:(K.columns[t]||[]).filter(e=>!es(F)||en(e,F)),projectSlug:m,wiSlug:K.slug,onDrop:Y,onEditTask:e=>P({mode:"edit",task:e}),onToggleTask:(e,a)=>$(e,a,t),onRunTask:V,onAgentChange:Q,agents:W,agentSuggestions:ee,onAddTask:()=>P({mode:"create",column:t})},t)})}),(q||y.output.length>0)&&(0,s.jsxs)("div",{className:"border-t border-border bg-surface shrink-0",children:[(0,s.jsxs)("button",{className:"flex items-center justify-between w-full px-5 py-2 text-label font-medium text-text-secondary cursor-pointer transition-[background] duration-150 text-left hover:bg-surface-hover",onClick:()=>U(!M),children:[(0,s.jsxs)("span",{children:["Ralph ","idle"!==y.status&&(0,s.jsx)("span",{className:"inline-block w-[5px] h-[5px] rounded-full bg-success ml-[5px] animate-breathe shadow-[0_0_6px_rgba(52,211,153,0.4)]"}),y.currentTaskTitle&&" — ".concat(y.currentTaskTitle)]}),(0,s.jsxs)("span",{className:"text-data text-text-muted font-mono",children:[y.stats.completed,"/",y.stats.total," done"]})]}),M&&(0,s.jsx)("div",{className:"max-h-[180px] overflow-y-auto px-5 pb-2 font-mono text-data leading-[1.65] text-text-muted",children:0===y.output.length?(0,s.jsx)("div",{className:"text-text-muted italic p-2 font-mono text-data opacity-50",children:"Waiting for output..."}):y.output.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-all",children:e},t))})]}),z&&(0,s.jsx)(G,{projectSlug:m,wiSlug:K.slug,mode:z.mode,task:"edit"===z.mode?z.task:void 0,defaultColumn:"create"===z.mode?z.column:void 0,onSave:et,onDelete:ed,onClose:()=>P(null)})]})}var eh=a(4822);let ef=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function eg(e){var t;let{projectSlug:a,wiSlug:n}=e,r=(0,eo.q)(e=>e.ralph),o=(0,R.E)(e=>e.addToast),{workItems:l}=(0,p.o)(),i=l.find(e=>e.slug===n||e.id===n),d=(null==i?void 0:null===(t=i.columns.todo)||void 0===t?void 0:t.length)||0,x="running"===r.status||"paused"===r.status,m=r.workItemSlug===n||r.projectSlug===a,u=(0,c.useCallback)(async()=>{try{let e=await fetch("".concat(ef,"/api/ralph/start"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:a,workItemSlug:n})}),t=await e.json();t.ok?o("Ralph started","success"):o(t.error||"Failed to start Ralph","error")}catch(e){o("Failed to connect to server","error")}},[a,n,o]),b=(0,c.useCallback)(async()=>{await fetch("".concat(ef,"/api/ralph/stop"),{method:"POST"})},[]),h=(0,c.useCallback)(async()=>{await fetch("".concat(ef,"/api/ralph/pause"),{method:"POST"})},[]),f=(0,c.useCallback)(async()=>{await fetch("".concat(ef,"/api/ralph/resume"),{method:"POST"})},[]),g=r.stats.total>0?(r.stats.completed+r.stats.failed)/r.stats.total*100:0,j=(0,c.useRef)(null);return(0,c.useEffect)(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[r.output]),(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-border shrink-0 bg-gradient-to-b from-bg-subtle to-bg relative after:content-[''] after:absolute after:bottom-0 after:left-[5%] after:right-[5%] after:h-px after:bg-[linear-gradient(90deg,transparent,var(--border-glow),transparent)]",children:[(0,s.jsxs)("div",{className:"text-h2 font-semibold flex items-center gap-2",children:[(0,s.jsx)(eh.Z,{size:18}),"Ralph",x&&m&&(0,s.jsx)("span",{className:"w-[7px] h-[7px] rounded-full bg-success animate-breathe shadow-[0_0_8px_rgba(52,211,153,0.4)]"})]}),(0,s.jsx)("div",{className:"flex-1"}),x&&m?(0,s.jsxs)("div",{className:"flex gap-1.5",children:["paused"===r.status?(0,s.jsxs)("button",{className:"btn-primary",onClick:f,children:[(0,s.jsx)(Z.Z,{size:14})," Resume"]}):(0,s.jsxs)("button",{className:"btn-ghost",onClick:h,children:[(0,s.jsx)(L.Z,{size:14})," Pause"]}),(0,s.jsxs)("button",{className:"inline-flex items-center gap-[5px] px-3.5 py-1.5 border border-[rgba(248,113,113,0.2)] text-danger text-label font-semibold rounded-sm transition-all duration-150 ease-out-expo hover:bg-danger-dim",onClick:b,children:[(0,s.jsx)(D.Z,{size:14})," Stop"]})]}):(0,s.jsxs)("button",{className:"inline-flex items-center gap-[5px] px-4 py-1.5 text-white text-label font-semibold rounded-sm bg-gradient-to-br from-emerald-600 to-emerald-400 relative overflow-hidden before:absolute before:inset-0 before:bg-gradient-to-b before:from-white/15 before:to-transparent before:pointer-events-none transition-all duration-150 ease-out-expo hover:enabled:shadow-[0_0_20px_rgba(52,211,153,0.25)] hover:enabled:-translate-y-px disabled:opacity-20 disabled:cursor-not-allowed",onClick:u,disabled:0===d,children:[(0,s.jsx)(Z.Z,{size:14})," Run (",d," tasks)"]})]}),(0,s.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,s.jsxs)("div",{className:"w-[320px] shrink-0 border-r border-border p-5 overflow-y-auto bg-bg-subtle flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"p-4 bg-bg border border-border rounded-md shadow-inset",children:[(0,s.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono mb-3",children:"Progress"}),(0,s.jsx)("div",{className:"h-[4px] rounded-full bg-[rgba(148,163,242,0.06)] overflow-hidden mb-3",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-[width] duration-[800ms] ease-out-expo",style:{width:"".concat(g,"%"),background:"var(--accent-gradient)"}})}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-2 text-center",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-lg font-bold text-success font-mono",children:r.stats.completed}),(0,s.jsx)("div",{className:"text-xxs text-text-muted font-mono uppercase",children:"Done"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-lg font-bold text-danger font-mono",children:r.stats.failed}),(0,s.jsx)("div",{className:"text-xxs text-text-muted font-mono uppercase",children:"Failed"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-lg font-bold text-text font-mono",children:r.stats.total}),(0,s.jsx)("div",{className:"text-xxs text-text-muted font-mono uppercase",children:"Total"})]})]})]}),r.currentTaskTitle&&(0,s.jsxs)("div",{className:"p-3 bg-bg border border-border rounded-md",children:[(0,s.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono mb-2",children:"Current Task"}),(0,s.jsx)("div",{className:"text-body text-accent font-mono animate-breathe",children:r.currentTaskTitle})]}),(0,s.jsxs)("div",{className:"p-3 bg-bg border border-border rounded-md",children:[(0,s.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono mb-2",children:"Status"}),(0,s.jsx)("span",{className:"text-xxs font-semibold font-mono tracking-wide uppercase px-2 py-0.5 rounded-full\n ".concat("running"===r.status?"text-success bg-success-dim border border-[rgba(52,211,153,0.15)]":"paused"===r.status?"text-warning bg-warning-dim border border-[rgba(251,191,36,0.15)]":"text-text-muted bg-pill border border-border"),children:r.status})]})]}),(0,s.jsx)(ej,{output:r.output,isRunning:x&&m})]})]})}function ej(e){let{output:t,isRunning:a}=e,n=(0,c.useRef)(null);return(0,c.useEffect)(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[t]),(0,s.jsxs)("div",{className:"flex-1 flex flex-col p-5 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)("span",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Output"}),a&&(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-xxs text-success font-mono font-medium animate-breathe",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-success shadow-[0_0_6px_rgba(52,211,153,0.5)]"}),"streaming"]})]}),(0,s.jsxs)("div",{ref:n,className:"flex-1 overflow-y-auto bg-[var(--console-bg)] border border-border rounded-md p-3 px-4 font-mono text-[11px] leading-[1.7] text-text-muted shadow-[inset_0_2px_6px_rgba(0,0,0,0.1)]",children:[0===t.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 opacity-20",children:[(0,s.jsx)(eh.Z,{size:28}),(0,s.jsx)("span",{className:"text-label font-mono",children:a?"Connecting to Claude...":"Output will appear here"}),a&&(0,s.jsxs)("div",{className:"flex gap-1 mt-1",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-bounce",style:{animationDelay:"0ms"}}),(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-bounce",style:{animationDelay:"150ms"}}),(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-bounce",style:{animationDelay:"300ms"}})]})]}):t.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-all py-px ".concat(e.startsWith("⚡")?"text-accent font-semibold":e.startsWith(" →")?"text-text-muted opacity-60 text-[10px]":e.startsWith("ERROR")?"text-danger":""),children:e},t)),a&&t.length>0&&(0,s.jsx)("span",{className:"inline-block w-[6px] h-[14px] bg-accent animate-blink ml-0.5 -mb-0.5"})]})]})}var ev=a(5805),eN=a(2222),ey=a(8728),ew=a(4972),ek=a(2934),eC=a(9525),eS=a(221),eT=a(2735),e_=a(6034),ez=a(8866),eZ=a(2207),eP=a(7168);let eE=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function eA(){let e=(0,R.E)(e=>e.addToast),[t,a]=(0,c.useState)("mcp"),[n,r]=(0,c.useState)([]),[o,l]=(0,c.useState)([]),[i,x]=(0,c.useState)([]),[m,u]=(0,c.useState)([]),[p,b]=(0,c.useState)(!1),[h,f]=(0,c.useState)(null),[g,j]=(0,c.useState)(!1),[N,y]=(0,c.useState)(null),[w,k]=(0,c.useState)(!1),[C,S]=(0,c.useState)(null),T=(0,c.useCallback)(async()=>{let[e,t,a,s]=await Promise.all([fetch("".concat(eE,"/api/mcp/servers")).then(e=>e.json()).catch(()=>({data:[]})),fetch("".concat(eE,"/api/skills")).then(e=>e.json()).catch(()=>({data:[]})),fetch("".concat(eE,"/api/plugins")).then(e=>e.json()).catch(()=>({data:[]})),fetch("".concat(eE,"/api/mcp/presets")).then(e=>e.json()).catch(()=>({data:[]}))]);r(e.data||[]),l(t.data||[]),x(a.data||[]),u(s.data||[])},[]);(0,c.useEffect)(()=>{T()},[T]);let _=async t=>{await fetch("".concat(eE,"/api/mcp/servers/").concat(t),{method:"DELETE"}),e("".concat(t," removed"),"success"),T()},z=async(e,t)=>{await fetch("".concat(eE,"/api/mcp/servers/").concat(e,"/toggle"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t})}),T()},Z=async t=>{S(t);try{var a;let s=await fetch("".concat(eE,"/api/mcp/servers/").concat(t,"/test"),{method:"POST"}),n=await s.json();e((null===(a=n.data)||void 0===a?void 0:a.message)||(n.ok?"OK":"Failed"),n.ok?"success":"error")}catch(t){e("Test failed","error")}S(null)},E=async t=>{await fetch("".concat(eE,"/api/mcp/servers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),e("".concat(t.name," added"),"success"),T()},A=async(e,t)=>{await fetch("".concat(eE,"/api/skills/").concat(e,"/toggle"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t})}),T()},D=async t=>{await fetch("".concat(eE,"/api/skills/").concat(t),{method:"DELETE"}),e("".concat(t," removed"),"success"),T()},I=async(e,t)=>{await fetch("".concat(eE,"/api/plugins/toggle"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,enabled:t})}),T()},O=async()=>{await fetch("".concat(eE,"/api/plugins/rescan"),{method:"POST"}),e("Plugins rescanned","info"),T()};return(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsx)("div",{className:"flex gap-0 border-b border-border shrink-0",children:["mcp","skills","plugins"].map(e=>(0,s.jsxs)("button",{className:"px-4 py-2.5 text-data font-semibold font-mono tracking-[0.06em] border-b-2 transition-all duration-[180ms] ease-out-expo flex items-center gap-1.5 ".concat(t===e?"text-text border-b-accent":"text-text-muted border-b-transparent hover:text-text-secondary"),onClick:()=>a(e),children:[e.toUpperCase(),(0,s.jsx)("span",{className:"text-xxs bg-pill px-[5px] py-px rounded-xs border border-[rgba(148,163,242,0.04)]",children:"mcp"===e?n.length:"skills"===e?o.length:i.length})]},e))}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:["mcp"===t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("span",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"MCP Servers"}),(0,s.jsxs)("div",{className:"flex gap-1.5",children:[(0,s.jsxs)("button",{className:"inline-flex items-center gap-1 text-data font-medium text-accent px-2.5 py-1 rounded-xs border border-[rgba(99,102,241,0.12)] bg-accent-muted transition-all duration-150 ease-out-expo font-mono hover:shadow-[0_0_8px_var(--accent-glow)]",onClick:()=>k(!0),children:[(0,s.jsx)(eT.Z,{size:11})," Presets"]}),(0,s.jsxs)("button",{className:"inline-flex items-center gap-1 text-data font-medium text-accent px-2.5 py-1 rounded-xs border border-[rgba(99,102,241,0.12)] bg-accent-muted transition-all duration-150 ease-out-expo font-mono hover:shadow-[0_0_8px_var(--accent-glow)]",onClick:()=>{f(null),b(!0)},children:[(0,s.jsx)(d.Z,{size:11})," Add"]})]})]}),0===n.length?(0,s.jsx)("div",{className:"text-text-muted text-label text-center py-8 font-mono opacity-50",children:"No MCP servers configured"}):(0,s.jsx)("div",{className:"flex flex-col gap-1",children:n.map(e=>(0,s.jsxs)("div",{className:"group flex items-center gap-2.5 px-3 py-2.5 border border-border rounded-sm transition-all duration-200 ease-out-expo hover:border-border-light hover:bg-surface-hover",children:[(0,s.jsx)("button",{className:"shrink-0 text-text-muted transition-colors duration-150 ease-out-expo",onClick:()=>z(e.name,!e.enabled),children:e.enabled?(0,s.jsx)(e_.Z,{size:16,className:"text-success"}):(0,s.jsx)(ez.Z,{size:16})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-text block",children:e.name}),(0,s.jsxs)("span",{className:"text-data text-text-muted block mt-0.5 font-mono overflow-hidden text-ellipsis whitespace-nowrap",children:[e.command," ",(e.args||[]).join(" ")]})]}),(0,s.jsxs)("div",{className:"flex gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity duration-150 ease-out-expo",children:[(0,s.jsx)("button",{className:"text-text-muted p-1 rounded-xs transition-all duration-120 ease-out-expo hover:text-accent hover:bg-accent-muted",onClick:()=>Z(e.name),disabled:C===e.name,title:"Test connection",children:C===e.name?(0,s.jsx)("span",{className:"inline-block w-[11px] h-[11px] border-[1.5px] border-[rgba(99,102,241,0.2)] border-t-accent rounded-full animate-spin"}):(0,s.jsx)(P.Z,{size:11})}),(0,s.jsx)("button",{className:"text-text-muted p-1 rounded-xs transition-all duration-120 ease-out-expo hover:text-accent hover:bg-accent-muted",onClick:()=>{f(e),b(!0)},title:"Edit",children:(0,s.jsx)(eZ.Z,{size:11})}),(0,s.jsx)("button",{className:"text-text-muted p-1 rounded-xs transition-all duration-120 ease-out-expo hover:text-danger hover:bg-danger-dim",onClick:()=>_(e.name),title:"Remove",children:(0,s.jsx)(v.Z,{size:11})})]})]},e.name))})]}),"skills"===t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("span",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Skills"}),(0,s.jsxs)("button",{className:"inline-flex items-center gap-1 text-data font-medium text-accent px-2.5 py-1 rounded-xs border border-[rgba(99,102,241,0.12)] bg-accent-muted transition-all duration-150 ease-out-expo font-mono hover:shadow-[0_0_8px_var(--accent-glow)]",onClick:()=>{y(null),j(!0)},children:[(0,s.jsx)(d.Z,{size:11})," Add"]})]}),0===o.length?(0,s.jsx)("div",{className:"text-text-muted text-label text-center py-8 font-mono opacity-50",children:"No skills defined"}):(0,s.jsx)("div",{className:"flex flex-col gap-1",children:o.map(e=>(0,s.jsxs)("div",{className:"group flex items-center gap-2.5 px-3 py-2.5 border border-border rounded-sm transition-all duration-200 ease-out-expo hover:border-border-light hover:bg-surface-hover",children:[(0,s.jsx)("button",{className:"shrink-0 text-text-muted transition-colors duration-150 ease-out-expo",onClick:()=>A(e.name,!e.enabled),children:e.enabled?(0,s.jsx)(e_.Z,{size:16,className:"text-success"}):(0,s.jsx)(ez.Z,{size:16})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-text block",children:e.name}),(0,s.jsx)("span",{className:"text-data text-text-muted block mt-0.5 font-mono overflow-hidden text-ellipsis whitespace-nowrap",children:e.description}),e.promptTemplate&&(0,s.jsx)("span",{className:"text-xxs text-accent-dim block mt-[3px] font-mono opacity-60 overflow-hidden text-ellipsis whitespace-nowrap",children:e.promptTemplate.length>60?e.promptTemplate.slice(0,60)+"...":e.promptTemplate})]}),(0,s.jsxs)("div",{className:"flex gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity duration-150 ease-out-expo",children:[(0,s.jsx)("button",{className:"text-text-muted p-1 rounded-xs transition-all duration-120 ease-out-expo hover:text-accent hover:bg-accent-muted",onClick:()=>{y(e),j(!0)},title:"Edit",children:(0,s.jsx)(eZ.Z,{size:11})}),(0,s.jsx)("button",{className:"text-text-muted p-1 rounded-xs transition-all duration-120 ease-out-expo hover:text-danger hover:bg-danger-dim",onClick:()=>D(e.name),title:"Remove",children:(0,s.jsx)(v.Z,{size:11})})]})]},e.name))})]}),"plugins"===t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("span",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Plugins"}),(0,s.jsxs)("button",{className:"inline-flex items-center gap-1 text-data font-medium text-accent px-2.5 py-1 rounded-xs border border-[rgba(99,102,241,0.12)] bg-accent-muted transition-all duration-150 ease-out-expo font-mono hover:shadow-[0_0_8px_var(--accent-glow)]",onClick:O,children:[(0,s.jsx)(eP.Z,{size:11})," Rescan"]})]}),0===i.length?(0,s.jsx)("div",{className:"text-text-muted text-label text-center py-8 font-mono opacity-50",children:"No plugins found in data/.plugins/"}):(0,s.jsx)("div",{className:"flex flex-col gap-1",children:i.map(e=>(0,s.jsxs)("div",{className:"group flex items-center gap-2.5 px-3 py-2.5 border border-border rounded-sm transition-all duration-200 ease-out-expo hover:border-border-light hover:bg-surface-hover",children:[(0,s.jsx)("button",{className:"shrink-0 text-text-muted transition-colors duration-150 ease-out-expo",onClick:()=>I(e.name,!e.enabled),children:e.enabled?(0,s.jsx)(e_.Z,{size:16,className:"text-success"}):(0,s.jsx)(ez.Z,{size:16})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("span",{className:"text-xs font-medium text-text block",children:[e.name," ",(0,s.jsxs)("span",{className:"text-xxs text-text-muted font-mono",children:["v",e.version]})]}),(0,s.jsx)("span",{className:"text-data text-text-muted block mt-0.5 font-mono overflow-hidden text-ellipsis whitespace-nowrap",children:e.description||"No description"}),(0,s.jsx)("div",{className:"flex gap-1 flex-wrap mt-1",children:e.hooks.map(e=>(0,s.jsx)("span",{className:"text-[8px] text-accent-dim bg-accent-muted px-[5px] py-px rounded-xs font-mono border border-[rgba(99,102,241,0.06)]",children:e},e))})]})]},e.name))})]})]}),p&&(0,s.jsx)(eD,{server:h,onClose:()=>b(!1),onSaved:()=>{b(!1),T()}}),g&&(0,s.jsx)(eR,{skill:N,onClose:()=>j(!1),onSaved:()=>{j(!1),T()}}),w&&(0,s.jsx)(eI,{presets:m,installed:n.map(e=>e.name),onAdd:E,onClose:()=>k(!1)})]})}function eD(e){let{server:t,onClose:a,onSaved:n}=e,r=(0,R.E)(e=>e.addToast),[o,l]=(0,c.useState)((null==t?void 0:t.name)||""),[i,d]=(0,c.useState)((null==t?void 0:t.command)||""),[x,m]=(0,c.useState)(((null==t?void 0:t.args)||[]).join(" ")),[u,p]=(0,c.useState)((null==t?void 0:t.env)?Object.entries(t.env).map(e=>{let[t,a]=e;return"".concat(t,"=").concat(a)}).join("\n"):""),[b,g]=(0,c.useState)(!1),{overlayProps:j}=(0,f.N)(a),v=async e=>{if(e.preventDefault(),!o.trim()||!i.trim())return;g(!0);let a={};u.split("\n").filter(Boolean).forEach(e=>{let t=e.indexOf("=");t>0&&(a[e.slice(0,t).trim()]=e.slice(t+1).trim())});try{await fetch("".concat(eE,"/api/mcp/servers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o.trim(),command:i.trim(),args:x.trim()?x.trim().split(/\s+/):[],env:a,enabled:!0})}),r("".concat(o," ").concat(t?"updated":"added"),"success"),n()}catch(e){g(!1),r("Failed","error")}};return(0,s.jsx)("div",{className:"fixed inset-0 bg-overlay backdrop-blur-[16px] saturate-[180%] flex items-center justify-center z-[200] animate-overlay-in",...j,children:(0,s.jsxs)("div",{className:"bg-[var(--modal-bg,var(--surface-elevated))] border border-glass-border rounded-lg shadow-modal max-w-[520px] w-[92%] p-6 max-h-[85vh] overflow-y-auto animate-spring-pop relative before:content-[''] before:absolute before:top-0 before:left-[15%] before:right-[15%] before:h-px before:bg-gradient-to-r before:from-transparent before:via-[rgba(129,140,248,0.15)] before:to-transparent before:pointer-events-none",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-5",children:[(0,s.jsxs)("span",{className:"text-h2 font-semibold tracking-tight",children:[t?"Edit":"Add"," MCP Server"]}),(0,s.jsx)("button",{className:"btn-icon",onClick:a,children:(0,s.jsx)(h.Z,{size:16})})]}),(0,s.jsxs)("form",{className:"flex flex-col gap-3.5",onSubmit:v,children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Name"}),(0,s.jsx)("input",{value:o,onChange:e=>l(e.target.value),placeholder:"context7",disabled:!!t,className:"mt-1.5"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Command"}),(0,s.jsx)("input",{value:i,onChange:e=>d(e.target.value),placeholder:"npx",className:"mt-1.5"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Arguments (space-separated)"}),(0,s.jsx)("input",{value:x,onChange:e=>m(e.target.value),placeholder:"-y @upstash/context7-mcp@latest",className:"mt-1.5"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Environment Variables (KEY=value, one per line)"}),(0,s.jsx)("textarea",{value:u,onChange:e=>p(e.target.value),placeholder:"BRAVE_API_KEY=your-key",rows:3,className:"mt-1.5"})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,s.jsx)("button",{type:"button",className:"btn-ghost",onClick:a,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"btn-primary",disabled:!o.trim()||!i.trim()||b,children:b?"Saving...":t?"Update":"Add Server"})]})]})]})})}function eR(e){let{skill:t,onClose:a,onSaved:n}=e,r=(0,R.E)(e=>e.addToast),[o,l]=(0,c.useState)((null==t?void 0:t.name)||""),[i,d]=(0,c.useState)((null==t?void 0:t.description)||""),[x,m]=(0,c.useState)((null==t?void 0:t.promptTemplate)||""),[u,p]=(0,c.useState)(((null==t?void 0:t.tools)||[]).join(", ")),[b,g]=(0,c.useState)(!1),{overlayProps:j}=(0,f.N)(a),v=async e=>{if(e.preventDefault(),o.trim()&&i.trim()){g(!0);try{await fetch("".concat(eE,"/api/skills"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o.trim(),description:i.trim(),promptTemplate:x.trim(),tools:u.split(",").map(e=>e.trim()).filter(Boolean),enabled:!0})}),r("".concat(o," ").concat(t?"updated":"created"),"success"),n()}catch(e){g(!1),r("Failed","error")}}};return(0,s.jsx)("div",{className:"fixed inset-0 bg-overlay backdrop-blur-[16px] saturate-[180%] flex items-center justify-center z-[200] animate-overlay-in",...j,children:(0,s.jsxs)("div",{className:"bg-[var(--modal-bg,var(--surface-elevated))] border border-glass-border rounded-lg shadow-modal max-w-[520px] w-[92%] p-6 max-h-[85vh] overflow-y-auto animate-spring-pop relative before:content-[''] before:absolute before:top-0 before:left-[15%] before:right-[15%] before:h-px before:bg-gradient-to-r before:from-transparent before:via-[rgba(129,140,248,0.15)] before:to-transparent before:pointer-events-none",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-5",children:[(0,s.jsxs)("span",{className:"text-h2 font-semibold tracking-tight",children:[t?"Edit":"New"," Skill"]}),(0,s.jsx)("button",{className:"btn-icon",onClick:a,children:(0,s.jsx)(h.Z,{size:16})})]}),(0,s.jsxs)("form",{className:"flex flex-col gap-3.5",onSubmit:v,children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Name"}),(0,s.jsx)("input",{value:o,onChange:e=>l(e.target.value),placeholder:"code-review",disabled:!!t,className:"mt-1.5"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Description"}),(0,s.jsx)("input",{value:i,onChange:e=>d(e.target.value),placeholder:"Reviews code for quality and security...",className:"mt-1.5"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Prompt Template"}),(0,s.jsx)("textarea",{value:x,onChange:e=>m(e.target.value),placeholder:"You are a code reviewer. When reviewing code, focus on...",rows:6,className:"mt-1.5 !font-mono !text-label !leading-[1.6]"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono",children:"Required Tools (comma-separated)"}),(0,s.jsx)("input",{value:u,onChange:e=>p(e.target.value),placeholder:"bash, read, edit",className:"mt-1.5"})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,s.jsx)("button",{type:"button",className:"btn-ghost",onClick:a,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"btn-primary",disabled:!o.trim()||!i.trim()||b,children:b?"Saving...":t?"Update":"Create Skill"})]})]})]})})}function eI(e){let{presets:t,installed:a,onAdd:n,onClose:r}=e,{overlayProps:o}=(0,f.N)(r);return(0,s.jsx)("div",{className:"fixed inset-0 bg-overlay backdrop-blur-[16px] saturate-[180%] flex items-center justify-center z-[200] animate-overlay-in",...o,children:(0,s.jsxs)("div",{className:"bg-[var(--modal-bg,var(--surface-elevated))] border border-glass-border rounded-lg shadow-modal max-w-[520px] w-[92%] p-6 max-h-[85vh] overflow-y-auto animate-spring-pop relative before:content-[''] before:absolute before:top-0 before:left-[15%] before:right-[15%] before:h-px before:bg-gradient-to-r before:from-transparent before:via-[rgba(129,140,248,0.15)] before:to-transparent before:pointer-events-none",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-5",children:[(0,s.jsx)("span",{className:"text-h2 font-semibold tracking-tight",children:"MCP Presets"}),(0,s.jsx)("button",{className:"btn-icon",onClick:r,children:(0,s.jsx)(h.Z,{size:16})})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:t.map(e=>{let t=a.includes(e.name);return(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3.5 border border-border rounded-sm transition-all duration-200 ease-out-expo hover:border-border-light hover:bg-surface-hover",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-body font-semibold text-text block",children:e.name}),(0,s.jsxs)("span",{className:"text-data text-text-muted block mt-[3px] font-mono",children:[e.command," ",(e.args||[]).join(" ")]}),e.env&&Object.keys(e.env).length>0&&(0,s.jsxs)("span",{className:"text-xxs text-warning block mt-[3px] font-mono",children:["Requires: ",Object.keys(e.env).join(", ")]})]}),t?(0,s.jsx)("span",{className:"text-xxs text-success px-2 py-[3px] rounded-xs border border-[rgba(52,211,153,0.15)] bg-success-dim font-mono font-medium tracking-wide",children:"Installed"}):(0,s.jsxs)("button",{className:"inline-flex items-center gap-1 text-data font-medium text-accent px-2.5 py-1 rounded-xs border border-[rgba(99,102,241,0.12)] bg-accent-muted transition-all duration-150 ease-out-expo font-mono hover:shadow-[0_0_8px_var(--accent-glow)]",onClick:()=>{n(e),r()},children:[(0,s.jsx)(d.Z,{size:11})," Add"]})]},e.name)})})]})})}let eO=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function eF(e){let{projectSlug:t}=e,{workItems:a,fetchWorkItems:n}=(0,p.o)(),r=(0,eo.q)(e=>e.teams),o=(0,R.E)(e=>e.addToast),[l,i]=(0,c.useState)([]),[x,m]=(0,c.useState)(3),[u,b]=(0,c.useState)("sonnet"),[f,g]=(0,c.useState)(null),[j,N]=(0,c.useState)([]),[y,w]=(0,c.useState)(!1),[k,C]=(0,c.useState)(null),[S,T]=(0,c.useState)(null),_=(0,c.useRef)(null),z=(0,c.useRef)(null),E=(0,c.useRef)(null);(0,c.useEffect)(()=>{n(t)},[t,n]),(0,c.useEffect)(()=>{I()},[]),(0,c.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[r.coordinatorThinking]),(0,c.useEffect)(()=>{z.current&&(z.current.scrollTop=z.current.scrollHeight)},[r.logs]),(0,c.useEffect)(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[S,r.workerLogs]);let A=(0,c.useRef)(r.coordinatorStatus);(0,c.useEffect)(()=>{"completed"!==A.current&&"completed"===r.coordinatorStatus&&r.completionMessage&&o(r.completionMessage,"success"),A.current=r.coordinatorStatus},[r.coordinatorStatus,r.completionMessage,o]);let I=(0,c.useCallback)(async()=>{try{let e=await fetch("".concat(eO,"/api/agents")),t=await e.json();t.ok&&N(t.data)}catch(e){}},[]),O=a.filter(e=>{var t;return(null===(t=e.columns.todo)||void 0===t?void 0:t.length)>0}),F=e=>{i(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},L=l.reduce((e,t)=>{var s;let n=a.find(e=>e.slug===t);return e+((null==n?void 0:null===(s=n.columns.todo)||void 0===s?void 0:s.length)||0)},0),M=async()=>{if(0===l.length){o("Select work items first","error");return}try{await fetch("".concat(eO,"/api/teams/start"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t,workItemSlugs:l,maxWorkers:x,model:u})})}catch(e){o("Failed to start","error")}},U=async()=>{await fetch("".concat(eO,"/api/teams/stop"),{method:"POST"})},W=async e=>{await fetch("".concat(eO,"/api/agents/").concat(e),{method:"DELETE"}),I(),o("".concat(e," deleted"),"success"),(null==k?void 0:k.name)===e&&C(null)},B=r.workers.filter(e=>"running"===e.status),q=r.workers.filter(e=>"running"!==e.status),J=r.coordinatorThinking.length>0,K=r.coordinatorToolCalls.slice(-8),H="completed"===r.coordinatorStatus,X="thinking"===r.coordinatorStatus?"Thinking...":"calling-tool"===r.coordinatorStatus?"Calling tool...":"waiting"===r.coordinatorStatus?"Waiting...":H?"Completed":r.active?"Active":"Idle";return(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-border shrink-0 bg-gradient-to-b from-bg-subtle to-bg relative after:content-[''] after:absolute after:bottom-0 after:left-[5%] after:right-[5%] after:h-px after:bg-[linear-gradient(90deg,transparent,var(--border-glow),transparent)]",children:[(0,s.jsxs)("div",{className:"text-h2 font-semibold flex items-center gap-2",children:[(0,s.jsx)(ev.Z,{size:18}),"Teams",r.active&&(0,s.jsx)("span",{className:"w-[7px] h-[7px] rounded-full bg-success animate-breathe shadow-[0_0_8px_rgba(52,211,153,0.4)]"}),H&&(0,s.jsx)("span",{className:"w-[7px] h-[7px] rounded-full bg-success shadow-[0_0_8px_rgba(52,211,153,0.4)]"})]}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsxs)("button",{className:"btn-ghost ".concat("agents"===f?"!text-accent !border-accent/20 !bg-accent-muted":""),onClick:()=>g("agents"===f?null:"agents"),children:[(0,s.jsx)(eN.Z,{size:14})," Agents"]}),(0,s.jsxs)("button",{className:"btn-ghost ".concat("config"===f?"!text-accent !border-accent/20 !bg-accent-muted":""),onClick:()=>g("config"===f?null:"config"),children:[(0,s.jsx)(ey.Z,{size:14})," Config"]}),r.active?(0,s.jsxs)("button",{className:"inline-flex items-center gap-[5px] px-4 py-[7px] border border-[rgba(248,113,113,0.2)] text-danger text-xs font-semibold rounded-sm transition-all duration-150 ease-out-expo hover:bg-danger-dim",onClick:U,children:[(0,s.jsx)(D.Z,{size:14})," Stop"]}):(0,s.jsxs)("button",{className:"inline-flex items-center gap-1.5 px-[18px] py-[7px] bg-gradient-to-br from-emerald-600 to-emerald-400 text-white text-xs font-semibold rounded-sm transition-all duration-150 ease-out-expo relative overflow-hidden before:content-[''] before:absolute before:inset-0 before:bg-gradient-to-b before:from-white/15 before:to-transparent before:pointer-events-none hover:shadow-[0_0_24px_rgba(52,211,153,0.25)] hover:-translate-y-px disabled:opacity-25 disabled:cursor-not-allowed",onClick:M,disabled:0===l.length,children:[(0,s.jsx)(Z.Z,{size:14})," Start (",L," tasks)"]})]}),(0,s.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,s.jsxs)("div",{className:"w-56 shrink-0 border-r border-border overflow-y-auto bg-bg-subtle p-3 flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-[0.1em] font-mono mb-2",children:"Work Items"}),(0,s.jsx)("div",{className:"flex flex-col gap-px",children:0===O.length?(0,s.jsx)("div",{className:"text-text-muted text-data text-center py-6 font-mono opacity-40",children:"No tasks in To Do"}):O.map(e=>{var t;return(0,s.jsxs)("label",{className:"flex items-center gap-2 py-[6px] px-2 rounded-sm text-xs text-text-secondary cursor-pointer transition-all duration-150 hover:bg-surface-hover",children:[(0,s.jsx)("input",{type:"checkbox",checked:l.includes(e.slug),onChange:()=>F(e.slug),disabled:r.active,className:"accent-accent w-3.5 h-3.5"}),(0,s.jsx)("span",{className:"flex-1 truncate",children:e.title}),(0,s.jsx)("span",{className:"text-xxs text-text-muted bg-pill px-1 py-0.5 rounded-xs font-mono",children:(null===(t=e.columns.todo)||void 0===t?void 0:t.length)||0})]},e.slug)})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-[0.1em] font-mono mb-2",children:"Workers"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"range",min:1,max:10,value:x,onChange:e=>m(Number(e.target.value)),disabled:r.active,className:"flex-1 accent-accent h-[3px]"}),(0,s.jsx)("span",{className:"text-base font-bold text-accent min-w-[24px] text-center font-mono",children:x})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-[0.1em] font-mono mb-2",children:"Coordinator Model"}),(0,s.jsx)("div",{className:"flex gap-1",children:["haiku","sonnet","opus"].map(e=>(0,s.jsx)("button",{className:"flex-1 py-1.5 text-xxs font-semibold rounded-sm font-mono tracking-wide uppercase transition-all duration-150\n ".concat(u===e?"text-accent bg-accent-muted border border-accent/20":"text-text-muted border border-border hover:text-text-secondary hover:bg-surface-hover"),onClick:()=>b(e),disabled:r.active,children:e},e))})]}),r.metrics&&(0,s.jsxs)("div",{className:"p-3 bg-bg border border-border rounded-md shadow-inset",children:[(0,s.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-[0.1em] font-mono mb-2",children:"Metrics"}),(0,s.jsxs)("div",{className:"flex justify-between text-label text-text-secondary py-0.5 font-mono",children:[(0,s.jsx)("span",{children:"Active"}),(0,s.jsx)("span",{children:r.metrics.activeWorkers})]}),(0,s.jsxs)("div",{className:"flex justify-between text-label text-text-secondary py-0.5 font-mono",children:[(0,s.jsx)("span",{className:"text-success",children:"Done"}),(0,s.jsx)("span",{children:r.metrics.totalCompleted})]}),(0,s.jsxs)("div",{className:"flex justify-between text-label text-text-secondary py-0.5 font-mono",children:[(0,s.jsx)("span",{className:"text-danger",children:"Failed"}),(0,s.jsx)("span",{children:r.metrics.totalFailed})]}),(0,s.jsxs)("div",{className:"flex justify-between text-label text-text-secondary py-0.5 font-mono",children:[(0,s.jsx)("span",{children:"Total"}),(0,s.jsx)("span",{children:r.metrics.totalTasks})]}),(0,s.jsx)("div",{className:"h-[3px] rounded-full bg-[rgba(148,163,242,0.06)] overflow-hidden mt-2",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-[width] duration-[800ms] ease-out-expo",style:{width:"".concat(r.metrics.totalTasks>0?(r.metrics.totalCompleted+r.metrics.totalFailed)/r.metrics.totalTasks*100:0,"%"),background:"var(--accent-gradient)"}})})]})]}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex-[3] min-h-0 flex flex-col p-4 overflow-hidden border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(ew.Z,{size:14,className:r.active?"text-accent animate-breathe":H?"text-success":"text-text-muted"}),(0,s.jsx)("span",{className:"text-xs font-semibold text-text uppercase tracking-[0.08em] font-mono",children:"Coordinator"}),(r.active||H)&&(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-xxs font-mono font-medium ml-2 px-2 py-0.5 rounded-full border\n ".concat(H?"text-success bg-success-dim border-success/20":"thinking"===r.coordinatorStatus?"text-accent bg-accent-muted border-accent/20 animate-breathe":"calling-tool"===r.coordinatorStatus?"text-warning bg-warning-dim border-warning/20":"text-success bg-success-dim border-success/20 animate-breathe"),children:[H?(0,s.jsx)(ek.Z,{size:10,className:"text-success"}):(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full ".concat("thinking"===r.coordinatorStatus?"bg-accent":"calling-tool"===r.coordinatorStatus?"bg-warning":"bg-success")}),X]}),B.length>0&&(0,s.jsxs)("span",{className:"text-xxs text-success font-mono font-medium ml-auto",children:[B.length," worker",B.length>1?"s":""," active"]})]}),(0,s.jsx)("div",{ref:_,className:"flex-1 overflow-y-auto bg-[var(--console-bg)] border border-border rounded-md p-4 font-mono text-[11px] leading-[1.8] shadow-[inset_0_2px_6px_rgba(0,0,0,0.3)]",children:J||0!==r.logs.length?(0,s.jsxs)(s.Fragment,{children:[r.coordinatorThinking.map((e,t)=>(0,s.jsx)("div",{className:"text-text-secondary whitespace-pre-wrap break-words py-px",children:e},t)),K.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2 mb-1",children:K.map((e,t)=>{var a;return(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-sm text-[10px] font-mono border\n ".concat("assign_task"===e.tool?"text-success bg-success-dim border-success/20":"wait_for_completion"===e.tool?"text-accent bg-accent-muted border-accent/20":"check_workers"===e.tool?"text-info bg-[rgba(96,165,250,0.08)] border-info/20":"escalate_to_human"===e.tool?"text-warning bg-warning-dim border-warning/20":"text-text-muted bg-pill border-border"),children:[(0,s.jsx)(eC.Z,{size:9}),e.tool,(null===(a=e.input)||void 0===a?void 0:a.taskId)&&(0,s.jsxs)("span",{className:"opacity-60",children:["(",e.input.taskId.slice(0,12),")"]})]},t)})}),r.logs.length>0&&!J&&r.logs.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-all py-px ".concat(e.includes("✓")?"text-success":e.includes("✗")?"text-danger":e.startsWith("\uD83D\uDD27")?"text-warning":e.startsWith("⚡")?"text-accent font-semibold":e.startsWith("\uD83D\uDD14")?"text-warning font-semibold":e.includes("---")?"text-text-muted opacity-40 text-center":e.includes("Worker →")?"text-accent":"text-text-muted"),children:e},t)),r.active&&(0,s.jsx)("span",{className:"inline-block w-[6px] h-[14px] bg-accent animate-blink ml-0.5 mt-1"}),H&&r.completionMessage&&(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2 px-3 py-2.5 bg-success-dim border border-success/20 rounded-md animate-fade-in-up",children:[(0,s.jsx)(ek.Z,{size:14,className:"text-success shrink-0"}),(0,s.jsx)("span",{className:"text-xs font-medium text-success font-mono",children:r.completionMessage})]})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 opacity-20",children:[(0,s.jsx)(ew.Z,{size:28}),(0,s.jsx)("span",{className:"text-xs font-mono text-text-muted",children:r.active?"Coordinator is starting...":"Select work items and start Teams"}),r.active&&(0,s.jsxs)("div",{className:"flex gap-1",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-bounce",style:{animationDelay:"0ms"}}),(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-bounce",style:{animationDelay:"150ms"}}),(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-bounce",style:{animationDelay:"300ms"}})]})]})})]}),(0,s.jsxs)("div",{className:"".concat(S?"flex-[3]":"flex-[2]"," min-h-[120px] shrink-0 flex flex-col overflow-hidden p-4 transition-all duration-300 ease-out-expo"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2 shrink-0",children:[(0,s.jsx)(P.Z,{size:12,className:B.length>0?"text-accent animate-breathe":H?"text-success":"text-text-muted"}),(0,s.jsx)("span",{className:"text-xxs font-semibold text-text-muted uppercase tracking-[0.1em] font-mono",children:"Workers"}),B.length>0&&(0,s.jsxs)("span",{className:"text-xxs text-success font-mono font-medium ml-auto",children:[B.length," active"]}),q.length>0&&(0,s.jsxs)("span",{className:"text-xxs text-text-muted font-mono",children:[q.length," done"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-1.5 shrink-0",children:[Array.from({length:x}).map((e,t)=>{let a=B[t],n=a&&S===a.id;return(0,s.jsx)("div",{className:"bg-card border rounded-sm px-3 py-3 flex items-center gap-2 transition-all duration-300 ease-out-expo\n ".concat(a?"cursor-pointer hover:border-accent/40 hover:shadow-[0_0_16px_rgba(99,102,241,0.12)] ".concat(n?"border-accent/40 bg-[rgba(99,102,241,0.06)] shadow-[0_0_16px_rgba(99,102,241,0.12)] ring-1 ring-accent/20":"border-accent/20 bg-[rgba(99,102,241,0.03)] shadow-[0_0_12px_rgba(99,102,241,0.08)]"):"border-border opacity-30"),onClick:()=>a&&T(n?null:a.id),children:a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(P.Z,{size:11,className:"text-accent animate-breathe shrink-0"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{className:"text-xs font-medium text-text truncate leading-tight",children:a.taskTitle}),(0,s.jsx)("div",{className:"text-xxs text-text-muted font-mono",children:a.agentName||"Auto"})]}),(0,s.jsx)(eS.Z,{size:10,className:"shrink-0 transition-colors duration-150 ".concat(n?"text-accent":"text-text-muted/40")})]}):(0,s.jsxs)("span",{className:"text-data text-text-muted font-mono",children:["Slot ",t+1]})},t)}),q.map(e=>{var t,a;let n=S===e.id,o=((null===(t=r.workerLogs[e.id])||void 0===t?void 0:t.length)||0)>0;return(0,s.jsxs)("div",{className:"bg-card border rounded-sm px-3 py-3 flex items-center gap-2 transition-all duration-300 ease-out-expo\n ".concat(o?"cursor-pointer hover:border-border-light hover:bg-surface-hover":"","\n ").concat(n?"border-accent/30 bg-[rgba(99,102,241,0.04)] ring-1 ring-accent/15":"border-border"),onClick:()=>o&&T(n?null:e.id),children:[(0,s.jsx)("span",{className:"shrink-0 ".concat("failed"===e.status?"text-danger":"text-success"),children:"completed"===e.status?"✓":"✗"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{className:"text-xs text-text-secondary truncate leading-tight",children:(null===(a=e.taskTitle)||void 0===a?void 0:a.slice(0,30))||e.taskId}),(0,s.jsx)("div",{className:"text-xxs text-text-muted font-mono",children:e.agentName||"Auto"})]}),o&&(0,s.jsx)(eS.Z,{size:10,className:"shrink-0 transition-colors duration-150 ".concat(n?"text-accent":"text-text-muted/40")})]},e.id)})]}),S&&(()=>{let e=r.workers.find(e=>e.id===S),t=r.workerLogs[S]||[];return e?(0,s.jsxs)("div",{className:"flex-1 min-h-0 mt-2 flex flex-col animate-fade-in-up",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[rgba(99,102,241,0.04)] border border-accent/15 rounded-t-md shrink-0",children:[(0,s.jsx)(eS.Z,{size:12,className:"text-accent"}),(0,s.jsx)("span",{className:"text-xxs font-semibold text-text uppercase tracking-[0.08em] font-mono truncate",children:e.taskTitle}),(0,s.jsx)("span",{className:"text-xxs text-text-muted font-mono",children:e.agentName||"Auto"}),"running"===e.status&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xxs text-accent font-mono animate-breathe",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent"})," live"]}),"completed"===e.status&&(0,s.jsx)("span",{className:"text-xxs text-success font-mono",children:"done"}),"failed"===e.status&&(0,s.jsx)("span",{className:"text-xxs text-danger font-mono",children:"failed"}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsxs)("span",{className:"text-xxs text-text-muted font-mono",children:[t.length," lines"]}),(0,s.jsx)("button",{className:"btn-icon !p-0.5 !w-5 !h-5",onClick:e=>{e.stopPropagation(),T(null)},children:(0,s.jsx)(h.Z,{size:12})})]}),(0,s.jsxs)("div",{ref:E,className:"flex-1 overflow-y-auto bg-[var(--console-bg)] border border-t-0 border-accent/10 rounded-b-md p-3 font-mono text-[11px] leading-[1.7] shadow-[inset_0_2px_6px_rgba(0,0,0,0.3)]",children:[0===t.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-full opacity-20",children:(0,s.jsx)("span",{className:"text-xs text-text-muted font-mono",children:"Waiting for output..."})}):t.map((e,t)=>(0,s.jsx)("div",{className:"text-text-secondary whitespace-pre-wrap break-all py-px",children:e},t)),"running"===e.status&&(0,s.jsx)("span",{className:"inline-block w-[6px] h-[14px] bg-accent animate-blink ml-0.5 mt-1"})]})]}):null})()]})]}),"agents"===f&&(0,s.jsxs)("div",{className:"w-[320px] shrink-0 border-l border-border bg-bg-subtle overflow-y-auto flex flex-col animate-fade-in-up",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-border shrink-0",children:[(0,s.jsx)("span",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Agents"}),(0,s.jsxs)("button",{className:"btn-primary text-xxs",onClick:()=>w(!0),children:[(0,s.jsx)(d.Z,{size:12})," New"]})]}),(0,s.jsx)("div",{className:"flex flex-col p-2 gap-1 flex-1 overflow-y-auto",children:j.map(e=>(0,s.jsxs)("div",{className:"p-2.5 border rounded-sm cursor-pointer transition-all duration-200 ease-out-expo bg-card\n hover:border-border-light hover:bg-surface-hover\n ".concat((null==k?void 0:k.name)===e.name?"border-accent/25 bg-accent-muted":"border-border"),onClick:()=>C((null==k?void 0:k.name)===e.name?null:e),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-body font-semibold text-text",children:e.name}),(0,s.jsx)("span",{className:"text-xxs text-text-muted bg-pill font-mono px-1 py-0.5 rounded-xs ml-auto",children:e.model})]}),(0,s.jsx)("div",{className:"text-label text-text-muted mt-0.5 truncate",children:e.description}),(null==k?void 0:k.name)===e.name&&(0,s.jsxs)("div",{className:"mt-2 pt-2 border-t border-border animate-fade-in-up",children:[(0,s.jsx)("div",{className:"flex gap-1 flex-wrap mb-2",children:e.skills.map(e=>(0,s.jsx)("span",{className:"text-xxs text-text-muted bg-pill font-mono px-1 py-0.5 rounded-xs",children:e},e))}),e.instructions&&(0,s.jsx)("div",{className:"text-xxs text-text-muted font-mono leading-relaxed whitespace-pre-wrap bg-bg p-2 rounded-sm border border-border max-h-[100px] overflow-y-auto",children:e.instructions}),!e.builtIn&&(0,s.jsxs)("button",{className:"text-xxs text-danger mt-2 flex items-center gap-1 font-mono",onClick:()=>W(e.name),children:[(0,s.jsx)(v.Z,{size:10})," Delete"]})]})]},e.name))})]}),"config"===f&&(0,s.jsx)("div",{className:"w-[320px] shrink-0 border-l border-border bg-bg-subtle overflow-hidden animate-fade-in-up",children:(0,s.jsx)(eA,{})})]}),y&&(0,s.jsx)(eL,{onClose:()=>w(!1),onCreated:()=>{w(!1),I()}})]})}function eL(e){let{onClose:t,onCreated:a}=e,n=(0,R.E)(e=>e.addToast),[r,o]=(0,c.useState)(""),[l,i]=(0,c.useState)(""),[d,m]=(0,c.useState)("sonnet"),[u,p]=(0,c.useState)(""),[b,g]=(0,c.useState)(""),[j,v]=(0,c.useState)(!1),[N,y]=(0,c.useState)(""),[w,k]=(0,c.useState)(!1),{overlayProps:C}=(0,f.N)(t,{disabled:w||j}),S=async()=>{if(N.trim()){k(!0);try{var e;let t=await fetch("".concat(eO,"/api/generate/plan"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:"feature",prompt:'Design an AI agent profile. User request: "'.concat(N,'"\n\nOutput ONLY valid JSON (no markdown fences):\n{"name":"PascalCaseName","description":"One sentence","model":"sonnet","skills":["tag1","tag2"],"instructions":"Detailed instructions"}')})}),a=await t.json(),s=(null===(e=a.data)||void 0===e?void 0:e.plan)||"",r=s.match(/\{[\s\S]*\}/);if(r)try{let e=JSON.parse(r[0]);e.name&&o(e.name),e.description&&i(e.description),e.model&&m(e.model),e.skills&&p(Array.isArray(e.skills)?e.skills.join(", "):e.skills),e.instructions&&g(e.instructions),n("Agent forged — review and save","success")}catch(e){g(s),i(N),n("Forged (raw)","info")}else g(s),i(N),n("Forged","info")}catch(e){n("Forge failed","error")}k(!1)}},T=async e=>{if(e.preventDefault(),r.trim()&&l.trim()){v(!0);try{await fetch("".concat(eO,"/api/agents"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r.trim(),description:l.trim(),model:d,skills:u.split(",").map(e=>e.trim()).filter(Boolean),instructions:b.trim()})}),n("".concat(r," created"),"success"),a()}catch(e){v(!1),n("Failed","error")}}};return(0,s.jsx)("div",{className:"glass-overlay",...C,children:(0,s.jsxs)("div",{className:"modal-box max-w-[520px] w-[92%] p-7 max-h-[90vh] overflow-y-auto",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,s.jsx)("span",{className:"text-h2 font-semibold",children:"New Agent"}),(0,s.jsx)("button",{className:"btn-icon",onClick:t,disabled:w||j,children:(0,s.jsx)(h.Z,{size:16})})]}),(0,s.jsxs)("div",{className:"mb-5 p-3.5 bg-bg rounded-md border border-border shadow-inset",children:[(0,s.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono mb-2.5",children:"Forge with Claude"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{className:"flex-1",value:N,onChange:e=>y(e.target.value),placeholder:"e.g. An agent that deploys to AWS..."}),(0,s.jsx)("button",{className:"btn-primary",onClick:S,disabled:w||!N.trim(),children:w?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-white/20 border-t-white rounded-full animate-spin"})," Forging..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.Z,{size:12})," Forge"]})})]}),w&&(0,s.jsx)("div",{className:"text-data text-accent font-mono mt-2.5 animate-breathe",children:"Claude is designing your agent..."})]}),(0,s.jsxs)("form",{className:"flex flex-col gap-4",onSubmit:T,children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Name"}),(0,s.jsx)("input",{className:"mt-1.5 w-full",value:r,onChange:e=>o(e.target.value),placeholder:"MyAgent"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Description"}),(0,s.jsx)("input",{className:"mt-1.5 w-full",value:l,onChange:e=>i(e.target.value),placeholder:"What this agent does..."})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Skills"}),(0,s.jsx)("input",{className:"mt-1.5 w-full",value:u,onChange:e=>p(e.target.value),placeholder:"backend, api, testing..."})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Model"}),(0,s.jsx)("div",{className:"flex gap-1.5 mt-1.5",children:["haiku","sonnet","opus"].map(e=>(0,s.jsx)("button",{type:"button",className:"px-3 py-1.5 text-data font-medium rounded-full border font-mono tracking-wide cursor-pointer transition-all duration-150 ease-out-expo ".concat(d===e?"border-accent/20 text-accent bg-accent-muted":"border-border text-text-muted hover:border-border-light hover:text-text-secondary"),onClick:()=>m(e),children:e},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Instructions"}),(0,s.jsx)("textarea",{className:"mt-1.5 w-full",value:b,onChange:e=>g(e.target.value),placeholder:"Custom instructions...",rows:4})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,s.jsx)("button",{type:"button",className:"btn-ghost",onClick:t,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"btn-primary",disabled:!r.trim()||!l.trim()||j,children:j?"Creating...":"Create Agent"})]})]})]})})}var eM=a(3315),eU=a(9076),eW=a(6766);let eB=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555",eq=[{id:"sonnet",label:"Sonnet"},{id:"opus",label:"Opus"},{id:"haiku",label:"Haiku"}],eJ=[{cmd:"/help",desc:"Show available commands"},{cmd:"/status",desc:"Show server and project status"},{cmd:"/clear",desc:"Clear terminal output"},{cmd:"/model <name>",desc:"Switch Claude model"},{cmd:"/reset",desc:"Reset terminal session"},{cmd:"/tasks",desc:"List tasks in current work item"}];function eK(e){let{projectSlug:t}=e,n=(0,eo.q)(e=>e.terminal.status),r=(0,eo.q)(e=>e.setTerminalStatus),o=(0,eo.q)(e=>e.resetTerminal),l=(0,R.E)(e=>e.addToast),i=(0,c.useRef)(null),d=(0,c.useRef)(null),x=(0,c.useRef)(null),[m,u]=(0,c.useState)(!1),[p,b]=(0,c.useState)("sonnet"),[h,f]=(0,c.useState)(!1),[g,j]=(0,c.useState)(!1),[v,N]=(0,c.useState)(null),[y,w]=(0,c.useState)(0);(0,c.useEffect)(()=>{if(!v){w(0);return}let e=setInterval(()=>w(Date.now()-v),1e3);return()=>clearInterval(e)},[v]),(0,c.useEffect)(()=>{let e=null,s=!1,n=(async()=>{let{Terminal:n}=await a.e(30).then(a.bind(a,9540)),{FitAddon:o}=await a.e(561).then(a.bind(a,1561));if(await Promise.all([a.e(525),a.e(914)]).then(a.t.bind(a,3409,23)).catch(()=>{}),s||!i.current)return;let l=getComputedStyle(document.documentElement),c=l.getPropertyValue("--console-bg").trim()||"#06060a",m=l.getPropertyValue("--console-fg").trim()||"#e8e8f0",u=l.getPropertyValue("--console-cursor").trim()||"#6366f1";e=new n({theme:"light"===document.documentElement.getAttribute("data-theme")?{background:c,foreground:m,cursor:u,cursorAccent:c,selectionBackground:"rgba(79, 70, 229, 0.2)",black:"#1a1a2e",red:"#dc2626",green:"#059669",yellow:"#d97706",blue:"#4f46e5",magenta:"#9333ea",cyan:"#0891b2",white:"#1a1a2e",brightBlack:"#6e6e82",brightRed:"#ef4444",brightGreen:"#10b981",brightYellow:"#f59e0b",brightBlue:"#6366f1",brightMagenta:"#a855f7",brightCyan:"#06b6d4",brightWhite:"#0f0f18"}:{background:c,foreground:m,cursor:u,cursorAccent:c,selectionBackground:"rgba(99, 102, 241, 0.3)",black:"#06060a",red:"#f87171",green:"#34d399",yellow:"#fbbf24",blue:"#818cf8",magenta:"#c084fc",cyan:"#22d3ee",white:"#e8e8f0",brightBlack:"#5c5c6e",brightRed:"#fca5a5",brightGreen:"#6ee7b7",brightYellow:"#fde68a",brightBlue:"#a5b4fc",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#ffffff"},fontSize:13,fontFamily:"'JetBrains Mono', 'Consolas', 'SF Mono', monospace",cursorBlink:!0,scrollback:3e3});let p=new o;e.loadAddon(p),e.open(i.current),p.fit(),d.current=e,x.current=p,e.onData(e=>{fetch("".concat(eB,"/api/terminal/input"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t,data:e})}).catch(()=>{})});let b=new ResizeObserver(()=>{if(p&&!s){p.fit();let e=p.proposeDimensions();e&&fetch("".concat(eB,"/api/terminal/resize"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t,cols:e.cols,rows:e.rows})}).catch(()=>{})}});i.current&&b.observe(i.current);let h=(0,eW.h)(),f=a=>{a.projectSlug===t&&e&&!s&&e.write(a.text)},g=e=>{e.projectSlug===t&&(r("idle"),N(null))};return h.on("terminal:output",f),h.on("terminal:closed",g),()=>{s=!0,h.off("terminal:output",f),h.off("terminal:closed",g),b.disconnect(),e.dispose()}})();return()=>{s=!0,n.then(e=>null==e?void 0:e())}},[t,r]);let k=(0,c.useCallback)(async()=>{try{var e,a,s,n;let o=(null===(a=x.current)||void 0===a?void 0:null===(e=a.proposeDimensions())||void 0===e?void 0:e.cols)||120,l=(null===(n=x.current)||void 0===n?void 0:null===(s=n.proposeDimensions())||void 0===s?void 0:s.rows)||30;await fetch("".concat(eB,"/api/terminal/spawn"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t,model:p,cols:o,rows:l})}),u(!0),r("running"),N(Date.now())}catch(e){l("Failed to spawn terminal","error")}},[t,p,r,l]),C=async()=>{await fetch("".concat(eB,"/api/terminal/stop"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t})}),u(!1),r("idle"),N(null)},S=async()=>{await fetch("".concat(eB,"/api/terminal/reset"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t})}),o(),u(!1),N(null),d.current&&d.current.clear(),l("Terminal reset","info")},T=e=>{if(j(!1),"/clear"===e){d.current&&d.current.clear();return}if("/reset"===e){S();return}fetch("".concat(eB,"/api/terminal/input"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t,data:e+"\r"})}).catch(()=>{})};(0,c.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),j(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let _="running"===n;return(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-5 py-2.5 border-b border-border shrink-0 bg-bg-subtle relative after:content-[''] after:absolute after:bottom-0 after:left-[5%] after:right-[5%] after:h-px after:bg-gradient-to-r after:from-transparent after:via-border-glow after:to-transparent",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mr-2",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-[#ff5f57]"}),(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-[#febc2e]"}),(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-[#28c840]"})]}),(0,s.jsxs)("div",{className:"text-[14px] font-semibold tracking-tight flex items-center gap-2",children:[(0,s.jsx)(eS.Z,{size:16}),"Console",(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full ".concat(_?"bg-success animate-breathe shadow-[0_0_6px_rgba(52,211,153,0.4)]":"error"===n?"bg-danger":"bg-text-muted")})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 ml-3",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("button",{className:"inline-flex items-center gap-1 px-2.5 py-1 text-data font-medium text-text-secondary bg-pill border border-border rounded-xs font-mono tracking-wide transition-all duration-150 ease-out-expo cursor-pointer hover:border-border-light hover:text-text disabled:opacity-50 disabled:cursor-default",onClick:()=>f(e=>!e),disabled:_,children:[p," ",(0,s.jsx)(E.Z,{size:10})]}),h&&!_&&(0,s.jsx)("div",{className:"absolute top-[calc(100%+4px)] left-0 bg-surface-elevated border border-border-light rounded-sm p-1 shadow-[0_8px_24px_rgba(0,0,0,0.4)] z-20 min-w-[100px] animate-fade-in-up",children:eq.map(e=>(0,s.jsx)("button",{className:"block w-full px-2.5 py-1.5 text-label font-medium text-text-secondary rounded-xs font-mono text-left transition-all duration-120 ease-out-expo hover:bg-surface-hover hover:text-text ".concat(p===e.id?"text-accent bg-accent-muted":""),onClick:()=>{b(e.id),f(!1)},children:e.label},e.id))})]}),_&&v&&(0,s.jsxs)("div",{className:"flex items-center gap-1 text-data text-text-muted font-mono font-medium px-2 py-[3px] bg-pill rounded-xs border border-[rgba(148,163,242,0.04)]",children:[(0,s.jsx)(F.Z,{size:11}),function(e){let t=Math.floor(e/1e3);if(t<60)return"".concat(t,"s");let a=Math.floor(t/60);return a<60?"".concat(a,"m ").concat(t%60,"s"):"".concat(Math.floor(a/60),"h ").concat(a%60,"m")}(y)]})]}),(0,s.jsxs)("div",{className:"flex gap-1.5 ml-auto",children:[(0,s.jsx)("button",{className:"inline-flex items-center justify-center w-7 h-7 rounded-sm text-text-muted border border-border transition-all duration-150 ease-out-expo hover:text-accent hover:border-[rgba(99,102,241,0.2)] hover:bg-accent-muted",onClick:()=>j(e=>!e),title:"Command Palette (Ctrl+K)",children:(0,s.jsx)(eM.Z,{size:12})}),!_&&(0,s.jsx)("button",{className:"inline-flex items-center gap-1.5 px-4 py-1.5 bg-gradient-to-br from-emerald-600 to-emerald-400 text-white text-label font-semibold rounded-sm transition-all duration-150 ease-out-expo relative overflow-hidden font-mono tracking-wide before:content-[''] before:absolute before:inset-0 before:bg-gradient-to-b before:from-white/15 before:to-transparent before:pointer-events-none hover:shadow-[0_0_20px_rgba(52,211,153,0.25)] hover:-translate-y-px",onClick:k,children:"Start Claude"}),_&&(0,s.jsxs)("button",{className:"btn-ghost",onClick:C,children:[(0,s.jsx)(D.Z,{size:12})," Stop"]}),(0,s.jsxs)("button",{className:"btn-ghost",onClick:S,children:[(0,s.jsx)(eU.Z,{size:12})," Reset"]})]})]}),(0,s.jsxs)("div",{className:"flex-1 relative overflow-hidden bg-[var(--console-bg)]",children:[(0,s.jsx)("div",{ref:i,className:"w-full h-full px-3 py-2"}),g&&(0,s.jsx)("div",{className:"absolute inset-0 bg-[rgba(6,6,10,0.7)] backdrop-blur-sm flex items-start justify-center pt-[60px] z-10 animate-overlay-in",onClick:()=>j(!1),children:(0,s.jsxs)("div",{className:"bg-surface-elevated border border-border-light rounded-md shadow-[0_16px_48px_rgba(0,0,0,0.5),0_0_0_1px_rgba(99,102,241,0.05)] max-w-[400px] w-[90%] p-2 animate-fade-in-up",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-[0.08em] font-mono px-3 pt-2 pb-1.5",children:"Command Palette"}),eJ.map(e=>(0,s.jsxs)("button",{className:"flex items-center gap-3 px-3 py-2.5 w-full rounded-sm transition-all duration-120 ease-out-expo text-left hover:bg-surface-hover",onClick:()=>T(e.cmd),children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-accent font-mono min-w-[110px]",children:e.cmd}),(0,s.jsx)("span",{className:"text-label text-text-muted",children:e.desc})]},e.cmd)),(0,s.jsx)("div",{className:"text-xxs text-text-muted opacity-50 font-mono text-center py-2 tracking-wide",children:"Press Ctrl+K to toggle"})]})})]}),(0,s.jsxs)("div",{className:"flex justify-between px-3 py-1 text-data font-mono text-text-muted border-t border-border bg-bg-subtle shrink-0",children:[(0,s.jsx)("span",{children:_?"Connected":"Disconnected"}),(0,s.jsx)("span",{children:p})]})]})}var eH=a(8736),eX=a(4401),eG=a(2208),eV=a(3229);let eY=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555",e$=[{key:"documents",label:"Documents",icon:(0,s.jsx)(eH.Z,{size:13})},{key:"memory",label:"Memory",icon:(0,s.jsx)(ew.Z,{size:13})},{key:"logs",label:"Daily Logs",icon:(0,s.jsx)(eX.Z,{size:13})},{key:"health",label:"Health",icon:(0,s.jsx)(eG.Z,{size:13})}];function eQ(e){let{projectSlug:t}=e,a=(0,R.E)(e=>e.addToast),[n,o]=(0,c.useState)("documents"),[l,i]=(0,c.useState)([]),[x,m]=(0,c.useState)([]),[u,p]=(0,c.useState)([]),[b,h]=(0,c.useState)(null),[f,g]=(0,c.useState)(null),[j,N]=(0,c.useState)(null),[y,w]=(0,c.useState)(""),[k,C]=(0,c.useState)(!1),[S,T]=(0,c.useState)(""),_="".concat(eY,"/api/projects/").concat(t,"/soul"),z=(0,c.useCallback)(async()=>{let[e,t,a,s,n]=await Promise.all([fetch("".concat(_,"/documents")).then(e=>e.json()).catch(()=>({data:[]})),fetch("".concat(_,"/memory")).then(e=>e.json()).catch(()=>({data:[]})),fetch("".concat(_,"/logs")).then(e=>e.json()).catch(()=>({data:[]})),fetch("".concat(_,"/health")).then(e=>e.json()).catch(()=>({data:null})),fetch("".concat(_,"/config")).then(e=>e.json()).catch(()=>({data:null}))]);i(e.data||[]),m(t.data||[]),p(a.data||[]),h(s.data||null),g(n.data||null)},[_]);(0,c.useEffect)(()=>{z()},[z]);let Z=e=>{N(e),w(e.content)},P=async()=>{j&&(await fetch("".concat(_,"/documents/").concat(j.name),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:y})}),a("".concat(j.name," saved"),"success"),N(null),z())},E=async()=>{S.trim()&&(await fetch("".concat(_,"/memory"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:S.trim(),source:"manual"})}),T(""),a("Memory added","success"),z())},A=async e=>{await fetch("".concat(_,"/memory/").concat(e),{method:"DELETE"}),z()},D=async()=>{await fetch("".concat(_,"/memory/reset"),{method:"POST"}),C(!1),a("Memory reset","success"),z()},I=async()=>{f&&(await fetch("".concat(_,"/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({heartbeat:{...f.heartbeat,enabled:!f.heartbeat.enabled}})}),z())};return(0,s.jsxs)("div",{className:"flex flex-col h-full p-6 gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-h2 font-semibold text-text",children:[(0,s.jsx)(eG.Z,{size:18})," Soul"]}),(0,s.jsx)("div",{className:"flex-1"}),b&&(0,s.jsxs)("div",{className:"text-label font-semibold px-2 py-0.5 rounded-full font-mono\n ".concat(b.score>=80?"bg-success-dim text-success border border-success/20":b.score>=50?"bg-warning-dim text-warning border border-warning/20":"bg-danger-dim text-danger border border-danger/20"),children:[b.score,"/100"]})]}),(0,s.jsx)("div",{className:"flex gap-0.5 border-b border-border",children:e$.map(e=>(0,s.jsxs)("button",{className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-t-sm transition-all duration-150\n ".concat(n===e.key?"text-text border-b-2 border-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"),onClick:()=>o(e.key),children:[e.icon," ",e.label]},e.key))}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto",children:["documents"===n&&(0,s.jsx)("div",{className:"flex flex-col gap-2",children:j?(0,s.jsxs)("div",{className:"flex flex-col gap-3 h-full",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"text-sm font-semibold text-text flex-1",children:j.name}),(0,s.jsx)("button",{className:"btn-ghost",onClick:()=>N(null),children:"Cancel"}),(0,s.jsxs)("button",{className:"btn-primary",onClick:P,children:[(0,s.jsx)(eV.Z,{size:12})," Save"]})]}),(0,s.jsx)("textarea",{className:"flex-1 font-mono text-xs leading-relaxed min-h-[300px] resize-none",value:y,onChange:e=>w(e.target.value),spellCheck:!1})]}):l.map(e=>(0,s.jsxs)("button",{className:"flex flex-col gap-1.5 p-3.5 bg-card border border-border rounded-md text-left transition-all duration-200 ease-out-expo hover:border-border-light hover:-translate-y-px",onClick:()=>Z(e),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eH.Z,{size:14,className:"text-accent"}),(0,s.jsx)("span",{className:"text-body font-medium text-text flex-1",children:e.name}),(0,s.jsx)(r.Z,{size:12,className:"text-text-muted"})]}),(0,s.jsx)("div",{className:"text-xs text-text-secondary leading-relaxed",children:e.content?e.content.slice(0,120)+(e.content.length>120?"...":""):"Empty — click to edit"}),(0,s.jsxs)("div",{className:"text-data text-text-muted font-mono",children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]})]},e.name))}),"memory"===n&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-label font-semibold uppercase tracking-[0.06em] text-text-muted",children:["Memories (",x.length,")"]}),(0,s.jsxs)("button",{className:"flex items-center gap-1 text-label text-text-muted px-2 py-1 rounded-md transition-all duration-150 hover:text-danger hover:bg-danger-dim disabled:opacity-30 disabled:cursor-not-allowed",onClick:()=>C(!0),disabled:0===x.length,children:[(0,s.jsx)(eU.Z,{size:11})," Reset"]})]}),(0,s.jsxs)("div",{className:"flex gap-2 items-end",children:[(0,s.jsx)("textarea",{className:"flex-1 min-h-[60px]",value:S,onChange:e=>T(e.target.value),placeholder:"Add a memory entry...",rows:2}),(0,s.jsxs)("button",{className:"btn-primary",onClick:E,disabled:!S.trim(),children:[(0,s.jsx)(d.Z,{size:12})," Add"]})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:0===x.length?(0,s.jsx)("div",{className:"text-center py-10 px-5 text-text-muted text-body",children:"No memories yet. Add one above."}):x.map(e=>(0,s.jsxs)("div",{className:"p-2.5 bg-card border border-border rounded-sm",children:[(0,s.jsx)("div",{className:"text-xs text-text leading-relaxed",children:e.content}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1.5 text-data text-text-muted font-mono",children:[(0,s.jsx)("span",{className:"px-1.5 py-px bg-accent-muted text-accent rounded text-xxs",children:e.source}),(0,s.jsx)("span",{children:new Date(e.createdAt).toLocaleDateString()}),(0,s.jsx)("button",{className:"flex items-center p-0.5 text-text-muted rounded-xs transition-all duration-150 ml-auto hover:text-danger hover:bg-danger-dim",onClick:()=>A(e.id),children:(0,s.jsx)(v.Z,{size:10})})]})]},e.id))})]}),"logs"===n&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:0===u.length?(0,s.jsx)("div",{className:"text-center py-10 px-5 text-text-muted text-body",children:"No daily logs yet. Logs are created automatically during execution."}):u.map(e=>(0,s.jsxs)("div",{className:"p-3 bg-card border border-border rounded-sm",children:[(0,s.jsx)("div",{className:"text-label font-semibold text-text-muted font-mono mb-2",children:e.date}),(0,s.jsx)("div",{className:"flex flex-col gap-1",children:e.entries.map((e,t)=>(0,s.jsx)("div",{className:"text-xs text-text-secondary leading-relaxed pl-2 border-l-2 border-border",children:e},t))})]},e.date))}),"health"===n&&b&&(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,s.jsx)("div",{className:"w-20 h-20 rounded-full border-[3px] border-accent flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-2xl font-bold text-text",children:b.score})}),(0,s.jsx)("span",{className:"text-label font-medium text-text-muted uppercase tracking-[0.06em]",children:"Health Score"})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:[{label:"Execution Rate",value:b.executionRate.toFixed(1),unit:"tasks/day"},{label:"Success Rate",value:"".concat(b.successRate.toFixed(0),"%"),unit:"completion"},{label:"Stuck Tasks",value:String(b.stuckTasks),unit:"blocked"},{label:"Last Run",value:b.lastRun?new Date(b.lastRun).toLocaleDateString():"—",unit:b.lastRun?new Date(b.lastRun).toLocaleTimeString():"never"}].map(e=>(0,s.jsxs)("div",{className:"p-3 bg-card border border-border rounded-sm text-center",children:[(0,s.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-wide mb-1",children:e.label}),(0,s.jsx)("div",{className:"text-xl font-bold text-text font-mono",children:e.value}),(0,s.jsx)("div",{className:"text-data text-text-muted",children:e.unit})]},e.label))}),f&&(0,s.jsxs)("div",{className:"pt-4 border-t border-border",children:[(0,s.jsx)("div",{className:"text-label font-semibold uppercase tracking-[0.06em] text-text-muted mb-2",children:"Heartbeat"}),(0,s.jsxs)("div",{className:"flex items-center justify-between py-2 text-body text-text",children:[(0,s.jsx)("span",{children:"Auto health check"}),(0,s.jsx)("button",{className:"px-3 py-1 text-label font-semibold rounded-md border border-border bg-surface text-text-secondary transition-all duration-150 hover:border-accent hover:text-accent",onClick:I,children:f.heartbeat.enabled?"Enabled":"Disabled"})]}),f.heartbeat.enabled&&(0,s.jsxs)("div",{className:"text-label text-text-muted py-1",children:["Every ",f.heartbeat.intervalMinutes,"m using ",f.heartbeat.model]})]})]})]}),k&&(0,s.jsx)(e0,{onConfirm:D,onClose:()=>C(!1)})]})}function e0(e){let{onConfirm:t,onClose:a}=e,{overlayProps:n}=(0,f.N)(a);return(0,s.jsx)("div",{className:"glass-overlay",...n,children:(0,s.jsxs)("div",{className:"modal-box w-[400px] max-w-[90vw] p-5",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("span",{className:"text-h2 font-semibold text-text",children:"Reset Memory"}),(0,s.jsx)("button",{className:"btn-icon",onClick:a,children:(0,s.jsx)(h.Z,{size:16})})]}),(0,s.jsx)("p",{className:"text-body text-text-secondary leading-relaxed mb-4",children:"This will permanently delete all memory entries for this project. This cannot be undone."}),(0,s.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,s.jsx)("button",{className:"btn-ghost",onClick:a,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn-danger",onClick:t,children:[(0,s.jsx)(v.Z,{size:12})," Reset All"]})]})]})})}var e1=a(1817),e2=a(2718);function e5(e){let{msg:t}=e;if("system"===t.role)return(0,s.jsx)("div",{className:"flex justify-center animate-fade-in-up",children:(0,s.jsx)("span",{className:"text-xxs font-mono text-text-muted/40 bg-surface/50 px-3 py-1 rounded-full",children:t.content})});if("escalation"===t.role){var a;let e=!!t.respondedWith;return(0,s.jsx)("div",{className:"animate-fade-in-up",children:(0,s.jsxs)("div",{className:"rounded-lg border p-4 transition-all duration-300\n ".concat(e?"border-border/50 bg-surface/30":"border-accent/15 bg-accent/[0.04] shadow-[0_0_12px_rgba(99,102,241,0.06)]"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2.5",children:[!e&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-breathe"}),(0,s.jsx)("span",{className:"text-[9px] font-mono text-accent/70 uppercase tracking-widest",children:e?"Answered":"Claude needs your input"})]}),(0,s.jsx)("p",{className:"text-body text-text leading-relaxed mb-3",children:t.content}),t.options&&t.options.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.options.map(a=>(0,s.jsx)("span",{className:"px-3 py-1.5 rounded-md text-xs font-medium border transition-all duration-150\n ".concat(t.respondedWith===a?"border-accent/30 bg-accent/10 text-accent":e?"border-border/30 bg-transparent text-text-muted/40":"border-accent/20 bg-accent/[0.06] text-accent/80 cursor-pointer hover:bg-accent/10 hover:border-accent/30"),children:a},a))}),e&&t.respondedWith&&!(null===(a=t.options)||void 0===a?void 0:a.includes(t.respondedWith))&&(0,s.jsxs)("div",{className:"mt-2 text-xs text-accent/70 font-mono",children:["→ ",t.respondedWith]})]})})}let n="user"===t.role;return(0,s.jsxs)("div",{className:"flex gap-2.5 items-start animate-fade-in-up ".concat(""),children:[(0,s.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 text-[9px] font-semibold\n ".concat(n?"bg-accent/15 text-accent":"bg-accent/20 text-accent"),children:n?"U":(0,s.jsx)("div",{className:"w-2.5 h-2.5 bg-gradient-to-br from-indigo-400 to-indigo-600 rounded-sm"})}),(0,s.jsx)("div",{className:"rounded-lg border px-3.5 py-2.5 max-w-[85%] text-body leading-relaxed\n ".concat(n?"bg-surface/50 border-border/50 text-text":"bg-accent/[0.03] border-accent/10 text-text-secondary"),children:(0,s.jsx)("div",{className:"whitespace-pre-wrap",children:t.content})})]})}function e3(e){let{onRespondToEscalation:t}=e,a=(0,eo.q)(e=>e.planner.messages),n=(0,eo.q)(e=>e.planner.escalation),r=(0,c.useRef)(null);return(0,c.useEffect)(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[a]),(0,s.jsxs)("div",{ref:r,className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-3",children:[a.map(e=>(0,s.jsx)(e5,{msg:e},e.id)),n&&(0,s.jsx)("div",{className:"animate-fade-in-up",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1 ml-8",children:n.options.map(e=>(0,s.jsx)("button",{onClick:()=>t(e),className:"px-3 py-1.5 rounded-md text-xs font-medium border border-accent/20 bg-accent/[0.06] text-accent/80 cursor-pointer hover:bg-accent/10 hover:border-accent/30 transition-all duration-150 ease-out-expo",children:e},e))})})]})}var e4=a(4743);function e6(e){let{onRespondToEscalation:t}=e,a=(0,eo.q)(e=>e.planner.active),n=(0,eo.q)(e=>e.planner.escalation),[r,o]=(0,c.useState)(""),l=(0,c.useRef)(null),i=!!n;(0,c.useEffect)(()=>{var e;i&&(null===(e=l.current)||void 0===e||e.focus())},[i]);let d=()=>{let e=r.trim();e&&i&&(t(e),o(""))};return a?(0,s.jsxs)("div",{className:"px-4 py-3 border-t border-border/50 flex-shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-end gap-2 rounded-lg border px-3 py-2 transition-all duration-200\n ".concat(i?"border-accent/20 bg-surface/50 focus-within:border-accent/40 focus-within:shadow-[0_0_12px_rgba(99,102,241,0.06)]":"border-border/30 bg-bg/50"),children:[(0,s.jsx)("textarea",{ref:l,value:r,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),d())},disabled:!i,placeholder:i?"Type your response...":"Claude is working...",className:"flex-1 bg-transparent border-none text-body text-text resize-none max-h-[120px] min-h-[24px] placeholder:text-text-muted/40 focus:outline-none disabled:opacity-40",rows:1}),(0,s.jsx)("button",{onClick:d,disabled:!i||!r.trim(),className:"w-7 h-7 flex items-center justify-center rounded-md flex-shrink-0 bg-accent/10 text-accent transition-all duration-150 hover:enabled:bg-accent/20 disabled:opacity-20",children:(0,s.jsx)(e4.Z,{size:13})})]}),!i&&a&&(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-2 ml-1",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-breathe shadow-[0_0_6px_rgba(52,211,153,0.5)]"}),(0,s.jsx)("span",{className:"text-xxs font-mono text-emerald-400/60",children:"Analyzing and planning — will ask when input is needed..."})]})]}):null}a(257).env.NEXT_PUBLIC_API_URL;var e8=a(401),e9=a(2135);let e7={feature:"border-l-feature",bug:"border-l-bug",refactor:"border-l-refactor"},te={feature:"text-feature bg-feature/10",bug:"text-bug bg-bug/10",refactor:"text-refactor bg-refactor/10"},tt={identified:{text:"Discovered",style:"text-text-muted bg-surface"},planning:{text:"Planning...",style:"text-accent bg-accent-muted"},ready:{text:"Ready to approve",style:"text-accent bg-accent-muted font-semibold"}};function ta(e){let{item:t,onApprove:a,onDiscard:n}=e,[r,o]=(0,c.useState)(!1),l=!!t.approvedAs,i=tt[t.status]||tt.identified;return(0,s.jsxs)("div",{className:"rounded-md border border-l-2 transition-all duration-250 ease-out-expo animate-card-in\n ".concat(e7[t.category]||"border-l-accent","\n ").concat(l?"border-border/30 bg-surface/20 opacity-50":"border-border bg-card hover:bg-surface-hover"),children:[(0,s.jsxs)("button",{onClick:()=>!l&&o(!r),className:"w-full flex items-center gap-2 px-2.5 py-2 text-left",children:["planning"===t.status&&!l&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-breathe flex-shrink-0"}),"ready"===t.status&&!l&&(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-accent flex-shrink-0 shadow-[0_0_6px_var(--accent-glow)]"}),l&&(0,s.jsx)(e8.Z,{size:10,className:"text-accent flex-shrink-0"}),"identified"===t.status&&!l&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/30 flex-shrink-0"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"text-[11px] font-medium text-text truncate",children:t.title}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,s.jsx)("span",{className:"text-[8px] font-mono px-1 py-px rounded ".concat(te[t.category]||""),children:t.category}),t.tasks.length>0&&(0,s.jsxs)("span",{className:"text-[8px] font-mono text-text-muted",children:[t.tasks.length," tasks"]}),!l&&(0,s.jsx)("span",{className:"text-[7px] font-mono px-1 py-px rounded ".concat(i.style),children:i.text})]})]}),!l&&(r?(0,s.jsx)(e9.Z,{size:10,className:"text-text-muted flex-shrink-0"}):(0,s.jsx)(E.Z,{size:10,className:"text-text-muted flex-shrink-0"}))]}),r&&!l&&(0,s.jsxs)("div",{className:"px-2.5 pb-2.5 border-t border-border/50 pt-2 flex flex-col gap-2",children:[t.plan&&(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[8px] font-mono text-text-muted uppercase tracking-wider mb-1",children:"Plan"}),(0,s.jsx)("div",{className:"text-[10px] text-text-secondary leading-relaxed max-h-[100px] overflow-y-auto whitespace-pre-wrap bg-bg/50 rounded p-2 border border-border/30",children:t.plan})]}),t.tasks.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[8px] font-mono text-text-muted uppercase tracking-wider mb-1",children:"Tasks"}),(0,s.jsx)("div",{className:"flex flex-col gap-0.5",children:t.tasks.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",children:[(0,s.jsx)("span",{className:"text-accent/50",children:"◈"}),(0,s.jsx)("span",{className:"text-text-secondary truncate",children:e.title})]},t))})]}),"ready"===t.status&&(0,s.jsxs)("div",{className:"flex gap-1.5 mt-1",children:[(0,s.jsxs)("button",{onClick:e=>{e.stopPropagation(),a(t.id)},className:"flex-1 flex items-center justify-center gap-1 py-1.5 rounded-md text-[10px] font-semibold bg-accent/10 border border-accent/20 text-accent hover:bg-accent/15 hover:border-accent/30 transition-all duration-150",children:[(0,s.jsx)(e8.Z,{size:10})," Approve & Create"]}),(0,s.jsx)("button",{onClick:e=>{e.stopPropagation(),n(t.id)},className:"flex items-center justify-center gap-1 py-1.5 px-3 rounded-md text-[10px] bg-transparent border border-border text-text-muted hover:text-danger hover:border-danger/30 hover:bg-danger/5 transition-all duration-150",children:(0,s.jsx)(h.Z,{size:10})})]})]})]})}var ts=a(6362);let tn=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function tr(e){let{projectSlug:t}=e,a=(0,eo.q)(e=>e.planner.discoveredItems),n=(0,eo.q)(e=>e.planner.active),r=(0,R.E)(e=>e.addToast),l=(0,o.U)(e=>e.goToWorkItem),c=a.filter(e=>!e.approvedAs),i=a.filter(e=>!!e.approvedAs),d=c.filter(e=>"ready"===e.status).length,m=async e=>{try{let t=await fetch("".concat(tn,"/api/planner/approve"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({itemId:e})}),a=await t.json();a.ok?r("Work item created","success"):r(a.error||"Failed to approve","error")}catch(e){r("Failed to connect","error")}},u=async e=>{try{await fetch("".concat(tn,"/api/planner/discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({itemId:e})})}catch(e){}};return 0===a.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 px-4",children:[(0,s.jsx)(x.Z,{size:20,className:"text-text-muted/20"}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-xxs font-mono text-text-muted/40",children:"Discovered items"}),(0,s.jsx)("p",{className:"text-xxs font-mono text-text-muted/25 mt-1",children:"will appear here"})]})]}):(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"px-3 py-2.5 border-b border-border flex-shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[9px] font-mono text-text-muted uppercase tracking-widest",children:"Discovered"}),(0,s.jsxs)("span",{className:"text-[9px] font-mono text-text-muted/50",children:[c.length," pending"]})]}),d>0&&(0,s.jsxs)("p",{className:"text-[9px] text-accent dark:text-accent mt-1.5 leading-snug",children:[d," item",d>1?"s":""," ready — approve to create on the board"]})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto px-2 py-2 flex flex-col gap-1.5",children:[c.map(e=>(0,s.jsx)(ta,{item:e,onApprove:m,onDiscard:u},e.id)),n&&c.length>0&&(0,s.jsx)("div",{className:"flex items-center justify-center py-2",children:(0,s.jsx)("span",{className:"text-[9px] font-mono text-text-muted/30",children:c.every(e=>"ready"===e.status)?"All items ready":"More items coming..."})})]}),i.length>0&&(0,s.jsxs)("div",{className:"px-3 pb-3 border-t border-border pt-2.5 flex-shrink-0",children:[(0,s.jsxs)("div",{className:"text-[8px] font-mono text-accent dark:text-accent uppercase tracking-widest mb-2 flex items-center gap-1.5",children:[(0,s.jsx)(e8.Z,{size:8})," Created (",i.length,")"]}),(0,s.jsx)("div",{className:"flex flex-col gap-0.5",children:i.map(e=>(0,s.jsxs)("button",{onClick:()=>e.approvedAs&&l(t,e.approvedAs),className:"group flex items-center gap-2 text-left py-1.5 px-2 rounded-sm text-[10px] text-text-secondary hover:text-accent hover:bg-accent/5 dark:text-text-muted/60 dark:hover:text-accent transition-all duration-150",children:[(0,s.jsx)(e8.Z,{size:8,className:"text-accent/50 flex-shrink-0"}),(0,s.jsx)("span",{className:"truncate flex-1",children:e.title}),(0,s.jsx)(ts.Z,{size:8,className:"opacity-0 group-hover:opacity-100 flex-shrink-0"})]},e.id))})]})]})}let to=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555",tl=[{text:"Launching Claude Sonnet...",delay:0},{text:"Analyzing your request...",delay:3e3},{text:"This is an interactive process — Claude will ask you questions to understand your needs",delay:7e3},{text:"Hang tight, first response takes a moment...",delay:14e3}];function tc(e){let{projectSlug:t}=e,[a,n]=(0,c.useState)(""),[r,o]=(0,c.useState)(!1),[l,i]=(0,c.useState)(0),d=(0,R.E)(e=>e.addToast),m=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(!r){i(0);return}let e=tl.slice(1).map((e,t)=>setTimeout(()=>i(t+1),e.delay));return()=>e.forEach(clearTimeout)},[r]);let u=async()=>{if(a.trim()&&!r){o(!0);try{let e=await fetch("".concat(to,"/api/planner/start"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectSlug:t,prompt:a.trim()})}),s=await e.json();s.ok||(d(s.error||"Failed to start planner","error"),o(!1))}catch(e){d("Failed to connect to server","error"),o(!1)}}};return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-6 animate-fade-in-up px-8",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(x.Z,{size:36,className:"text-accent/20 ".concat(r?"animate-spin":"animate-breathe")}),(0,s.jsx)("div",{className:"absolute inset-0 blur-[20px] bg-accent/5 rounded-full"})]}),(0,s.jsxs)("div",{className:"flex flex-col items-center gap-1.5 text-center",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-text tracking-tight",children:"AI Planner"}),r?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3 mt-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e1.Z,{size:13,className:"text-accent animate-spin"}),(0,s.jsx)("span",{className:"text-body text-accent font-medium animate-pulse",children:tl[l].text})]}),l>=2&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xxs text-text-muted/40 font-mono animate-fade-in-up",children:[(0,s.jsx)(e2.Z,{size:10}),"Claude Sonnet will ask you questions one at a time"]})]}):(0,s.jsxs)("p",{className:"text-body text-text-muted max-w-[440px] leading-relaxed",children:["Describe what you want to build. Claude will identify features, ask clarifying questions, and create plans with tasks for each one.",(0,s.jsx)("span",{className:"block mt-1.5 text-xxs text-text-muted/50 font-mono",children:"Interactive process — your input will be needed along the way"})]})]}),(0,s.jsxs)("div",{className:"w-full max-w-[520px] flex flex-col gap-3 transition-opacity duration-300 ".concat(r?"opacity-40 pointer-events-none":""),children:[(0,s.jsx)("textarea",{ref:m,value:a,onChange:e=>n(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),u())},disabled:r,placeholder:"I need a user authentication system with login, signup, password reset, and OAuth for Google and GitHub...",className:"w-full min-h-[140px] resize-y rounded-lg border border-border/60 bg-surface/40 px-4 py-3 text-body text-text placeholder:text-text-muted/30 focus:border-accent/30 focus:shadow-[0_0_16px_rgba(99,102,241,0.06)] focus:outline-none transition-all duration-200",rows:5,autoFocus:!0}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xxs font-mono text-text-muted/30",children:"Ctrl+Enter to start"}),(0,s.jsxs)("button",{onClick:u,disabled:!a.trim()||r,className:"inline-flex items-center gap-2 px-5 py-2 text-white text-label font-semibold rounded-md bg-gradient-to-br from-indigo-600 to-indigo-400 relative overflow-hidden before:absolute before:inset-0 before:bg-gradient-to-b before:from-white/15 before:to-transparent before:pointer-events-none transition-all duration-200 ease-out-expo hover:enabled:shadow-[0_0_24px_rgba(99,102,241,0.3)] hover:enabled:-translate-y-px disabled:opacity-30 disabled:cursor-not-allowed",children:[(0,s.jsx)(Z.Z,{size:13}),"Start Planning"]})]})]})]})}function ti(){let e=(0,eo.q)(e=>e.planner.active),t=(0,eo.q)(e=>e.planner.discoveredItems),a=t.filter(e=>!e.approvedAs).length,n=t.filter(e=>!!e.approvedAs).length,r=t.length,o=async()=>{await fetch("".concat(to,"/api/planner/stop"),{method:"POST"})};return(0,s.jsxs)("div",{className:"flex items-center gap-3 px-5 py-2.5 border-b border-border flex-shrink-0 bg-gradient-to-b from-bg-subtle to-bg relative after:content-[''] after:absolute after:bottom-0 after:left-[5%] after:right-[5%] after:h-px after:bg-[linear-gradient(90deg,transparent,var(--border-glow),transparent)]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-h2 font-semibold",children:[(0,s.jsx)(x.Z,{size:16,className:e?"text-accent animate-tab-process":"text-accent"}),"Planner",e&&(0,s.jsx)("span",{className:"w-[7px] h-[7px] rounded-full bg-accent animate-breathe shadow-[0_0_8px_var(--accent-glow)]"}),(0,s.jsx)("span",{className:"text-[9px] font-mono text-text-muted bg-surface px-1.5 py-0.5 rounded border border-border ml-1",children:"opus"})]}),r>0&&(0,s.jsxs)("div",{className:"flex items-center gap-2 ml-2 text-[9px] font-mono",children:[a>0&&(0,s.jsxs)("span",{className:"text-accent",children:[a," pending"]}),n>0&&(0,s.jsxs)("span",{className:"text-text-muted",children:[n," created"]})]}),(0,s.jsx)("div",{className:"flex-1"}),e&&(0,s.jsxs)("button",{onClick:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 border border-danger/20 text-danger text-label font-semibold rounded-sm transition-all duration-150 ease-out-expo hover:bg-danger-dim",children:[(0,s.jsx)(D.Z,{size:12})," Stop"]})]})}function td(e){let{projectSlug:t}=e,a=(0,eo.q)(e=>e.planner.active),n=(0,eo.q)(e=>e.planner.messages.length),r=(0,eo.q)(e=>e.planner.discoveredItems.length),o=(0,eo.q)(e=>{var t,a;return null!==(a=null===(t=e.planner.escalation)||void 0===t?void 0:t.id)&&void 0!==a?a:null}),l=(0,R.E)(e=>e.addToast),i=(0,c.useCallback)(async e=>{let t=eo.q.getState().planner.escalation;if(t)try{await fetch("".concat(to,"/api/escalation/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t.id,response:e})}),eo.q.getState().onPlannerEscalationResponded(e),l("Response sent","success")}catch(e){l("Failed to send response","error")}},[o,l]);return a||n>0||r>0?(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsx)(ti,{}),(0,s.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden border-r border-border/50",children:[(0,s.jsx)(e3,{onRespondToEscalation:i}),(0,s.jsx)(e6,{onRespondToEscalation:i})]}),(0,s.jsx)("div",{className:"w-[300px] flex-shrink-0 overflow-hidden bg-bg-subtle/30",children:(0,s.jsx)(tr,{projectSlug:t})})]})]}):(0,s.jsx)(tc,{projectSlug:t})}var tx=a(3468),tm=a(1347);let tu=[{key:"planner",label:"Planner",icon:(0,s.jsx)(x.Z,{size:15}),shortcut:"P"},{key:"work-items",label:"Work Items",icon:(0,s.jsx)(tx.Z,{size:15}),shortcut:"W"},{key:"console",label:"Console",icon:(0,s.jsx)(eS.Z,{size:15}),shortcut:"C"},{key:"teams",label:"Teams",icon:(0,s.jsx)(ev.Z,{size:15}),shortcut:"T"},{key:"soul",label:"Soul",icon:(0,s.jsx)(eG.Z,{size:15}),shortcut:"S"}],tp=[{key:"board",label:"Board",icon:(0,s.jsx)(tx.Z,{size:15}),shortcut:"B"},{key:"ralph",label:"Ralph",icon:(0,s.jsx)(eh.Z,{size:15}),shortcut:"R"}];function tb(){let{view:e,setView:t,projectSlug:a,workItemSlug:n}=(0,o.U)(),r=function(){let e=(0,eo.q)(e=>e.ralph.status),t=(0,eo.q)(e=>e.teams.active),a=(0,eo.q)(e=>e.terminal.status),s=(0,eo.q)(e=>e.planner.active),n=new Set;return"running"===a&&n.add("console"),t&&n.add("teams"),("running"===e||"paused"===e)&&n.add("ralph"),s&&n.add("planner"),n}();if(!a)return null;let l=n?"wi-tab-indicator":"proj-tab-indicator";return(0,s.jsx)("nav",{className:"flex relative",children:(n?tp:tu).map(a=>{let n=e===a.key,o=r.has(a.key);return(0,s.jsxs)("button",{className:"flex flex-col items-center gap-[3px] px-5 pt-2 pb-2.5 text-data font-medium relative\n border-b-2 border-transparent transition-all duration-180 ease-out-expo\n ".concat(n?"text-text":"text-text-muted hover:text-text-secondary hover:bg-[rgba(148,163,242,0.02)]"),onClick:()=>t(a.key),title:"".concat(a.label," (").concat(a.shortcut,")"),children:[(0,s.jsx)("span",{className:"flex transition-colors duration-180 ease-out-expo\n ".concat(o?"animate-tab-process":"","\n ").concat(n&&!o?"text-accent drop-shadow-[0_0_4px_var(--accent-glow)]":""),children:a.icon}),(0,s.jsx)("span",{className:"font-mono text-xxs tracking-[0.06em] uppercase\n ".concat(o?"text-emerald-400":""),children:a.label}),o&&(0,s.jsx)("span",{className:"absolute top-1.5 right-2.5 w-1.5 h-1.5 rounded-full bg-emerald-400 animate-breathe shadow-[0_0_6px_rgba(52,211,153,0.5)]"}),n&&(0,s.jsx)(tm.E.span,{layoutId:l,className:"absolute -bottom-px left-[20%] right-[20%] h-[2px] rounded-t-sm\n ".concat(o?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.5)]":"bg-accent shadow-[0_0_8px_var(--accent-glow)]"),transition:{type:"spring",stiffness:500,damping:35}})]},a.key)})})}let th=a(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function tf(){let[e,t]=(0,c.useState)([]),[a,n]=(0,c.useState)(!1),[r,o]=(0,c.useState)(!1),l=(0,c.useCallback)(async()=>{try{let e=await fetch("".concat(th,"/api/scheduler/schedules")),a=await e.json();a.ok&&t(a.data||[])}catch(e){}},[]);(0,c.useEffect)(()=>{l();let e=setInterval(l,3e4);return()=>clearInterval(e)},[l]);let i=async(e,t)=>{await fetch("".concat(th,"/api/scheduler/schedules/").concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t})}),l()},d=async e=>{o(!0),await fetch("".concat(th,"/api/scheduler/schedules/").concat(e,"/run"),{method:"POST"}),setTimeout(()=>{l(),o(!1)},1e3)},x=async e=>{await fetch("".concat(th,"/api/scheduler/schedules/").concat(e),{method:"DELETE"}),l()},m=e.filter(e=>e.enabled).length,u=e.filter(e=>"running"===e.lastStatus).length;return 0===e.length?null:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("button",{onClick:()=>n(!a),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-sm text-xxs font-mono font-medium border transition-all duration-150\n ".concat(u>0?"text-accent bg-accent-muted border-accent/20 animate-breathe":m>0?"text-text-secondary bg-pill border-border hover:border-border-light hover:text-text":"text-text-muted bg-pill border-border/50"),children:[(0,s.jsx)(F.Z,{size:11}),m,"/",e.length,u>0&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-breathe"}),a?(0,s.jsx)(e9.Z,{size:9}):(0,s.jsx)(E.Z,{size:9})]}),a&&(0,s.jsxs)("div",{className:"absolute top-[calc(100%+6px)] right-0 z-50 w-[380px] bg-surface-elevated border border-border-light rounded-md shadow-[0_12px_40px_rgba(0,0,0,0.4)] animate-fade-in-up overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-bg-subtle",children:[(0,s.jsx)("span",{className:"text-xxs font-semibold text-text-muted uppercase tracking-[0.1em] font-mono",children:"Scheduled Tasks"}),(0,s.jsxs)("span",{className:"text-xxs text-text-muted font-mono",children:[m," active \xb7 ",u," running"]})]}),(0,s.jsx)("div",{className:"max-h-[320px] overflow-y-auto",children:e.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/50 hover:bg-surface-hover transition-colors duration-100",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0 ".concat("running"===e.lastStatus?"bg-accent animate-breathe":e.enabled?"failed"===e.lastStatus?"bg-danger":"success"===e.lastStatus?"bg-success":"bg-warning":"bg-text-muted/30")}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"text-xs font-medium text-text truncate",children:e.taskTitle}),(0,s.jsxs)("div",{className:"text-xxs text-text-muted font-mono flex items-center gap-2",children:[(0,s.jsx)("span",{children:e.projectSlug}),(0,s.jsx)("span",{className:"text-text-muted/30",children:"\xb7"}),(0,s.jsxs)("span",{children:[e.frequency," ",e.time]}),e.nextRun&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-muted/30",children:"\xb7"}),(0,s.jsx)("span",{className:"running"===e.lastStatus?"text-accent":"",children:"running"===e.lastStatus?"running":"next: ".concat(function(e){if(!e)return"—";let t=new Date(e).getTime()-Date.now();if(t<0)return"due";let a=Math.floor(t/6e4);if(a<60)return"".concat(a,"m");let s=Math.floor(a/60);return s<24?"".concat(s,"h ").concat(a%60,"m"):"".concat(Math.floor(s/24),"d")}(e.nextRun))})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[(0,s.jsx)("button",{className:"btn-icon w-6 h-6",onClick:()=>d(e.id),title:"Run now",disabled:r||"running"===e.lastStatus,children:r?(0,s.jsx)(e1.Z,{size:10,className:"animate-spin"}):(0,s.jsx)(Z.Z,{size:10})}),(0,s.jsx)("button",{className:"btn-icon w-6 h-6",onClick:()=>i(e.id,!e.enabled),title:e.enabled?"Pause":"Enable",children:(0,s.jsx)(L.Z,{size:10,className:e.enabled?"text-warning":"text-success"})}),(0,s.jsx)("button",{className:"btn-icon w-6 h-6 hover:!text-danger",onClick:()=>x(e.id),title:"Delete",children:(0,s.jsx)(h.Z,{size:10})})]})]},e.id))}),(0,s.jsxs)("div",{className:"px-3 py-1.5 border-t border-border bg-bg-subtle text-xxs text-text-muted font-mono text-center",children:["Schedules run automatically \xb7 ",e.reduce((e,t)=>e+t.runCount,0)," total executions"]})]})]})}var tg=a(6858),tj=a(8124),tv=a(5051);function tN(e){let{icon:t,title:a,subtitle:n,accentColor:r,children:o,defaultOpen:l=!1}=e,[i,d]=(0,c.useState)(l);return(0,s.jsxs)("div",{className:"rounded-lg border transition-all duration-250 ease-out-expo overflow-hidden flex flex-col\n ".concat(i?"border-border-light bg-surface/80 shadow-card":"border-border/50 bg-surface/30 hover:border-border/80 hover:bg-surface/50"),children:[(0,s.jsxs)("button",{type:"button",onClick:()=>d(!i),className:"w-full flex items-center gap-3 px-4 py-3 text-left",children:[(0,s.jsx)("div",{className:"flex items-center justify-center w-7 h-7 rounded-md shrink-0 ".concat(r),children:t}),(0,s.jsxs)("div",{className:"flex flex-col gap-0 min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text",children:a}),(0,s.jsx)("span",{className:"text-xs text-text-muted leading-snug",children:n})]}),(0,s.jsx)(E.Z,{size:14,className:"text-text-muted/40 shrink-0 transition-transform duration-250 ease-out-expo\n ".concat(i?"rotate-180":"")})]}),(0,s.jsx)("div",{className:"grid transition-all duration-250 ease-out-expo\n ".concat(i?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),children:(0,s.jsx)("div",{className:"overflow-hidden",children:(0,s.jsx)("div",{className:"px-4 pb-4 pt-1",children:o})})})]})}function ty(e){let{label:t,color:a}=e;return(0,s.jsx)("div",{className:"px-2.5 py-1 rounded text-[11px] font-medium border truncate ".concat(a),children:t})}function tw(e){let{title:t,children:a,highlight:n}=e;return(0,s.jsxs)("div",{className:"flex flex-col gap-1 flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"text-[10px] font-mono uppercase tracking-wider text-center pb-0.5 border-b mb-0.5\n ".concat(n?"text-accent border-accent/30":"text-text-muted/40 border-border/40"),children:t}),(0,s.jsx)("div",{className:"flex flex-col gap-1",children:a})]})}function tk(){return(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2.5",children:[(0,s.jsxs)("div",{className:"rounded-md border border-border/40 bg-bg/50 p-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2.5",children:[(0,s.jsx)(eS.Z,{size:12,className:"text-text-muted/50"}),(0,s.jsx)("span",{className:"text-[11px] font-mono font-medium text-text-secondary",children:"Claude Code"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 text-[11px] text-text-muted leading-relaxed",children:[(0,s.jsx)("span",{children:"“Fix this bug”"}),(0,s.jsx)("span",{children:"“Refactor this function”"}),(0,s.jsx)("span",{children:"“Explain this code”"}),(0,s.jsx)("span",{children:"“Write tests for X”"})]}),(0,s.jsx)("div",{className:"mt-2.5 pt-2 border-t border-border/30 text-[10px] font-mono text-text-muted/40",children:"One task, one session"})]}),(0,s.jsxs)("div",{className:"rounded-md border border-accent/30 bg-accent/[0.03] p-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2.5",children:[(0,s.jsx)("span",{className:"text-accent text-[13px]",children:"◇"}),(0,s.jsx)("span",{className:"text-[11px] font-mono font-medium text-accent",children:"KANBAII"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 text-[11px] text-text-secondary leading-relaxed",children:[(0,s.jsx)("span",{children:"“Build the auth system”"}),(0,s.jsx)("span",{children:"“8 bugs to triage this week”"}),(0,s.jsx)("span",{children:"“MVP with 15 features”"}),(0,s.jsx)("span",{children:"“Track sprint progress”"})]}),(0,s.jsx)("div",{className:"mt-2.5 pt-2 border-t border-accent/20 text-[10px] font-mono text-accent/40",children:"Many tasks, full visibility"})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1",children:[(0,s.jsx)("div",{className:"h-px flex-1 bg-border/30"}),(0,s.jsx)("span",{className:"text-[10px] font-mono text-text-muted/40 px-2",children:"They work together"}),(0,s.jsx)("div",{className:"h-px flex-1 bg-border/30"})]}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-3 text-[11px] text-text-muted font-mono",children:[(0,s.jsx)("span",{className:"text-text-secondary",children:"You organize in KANBAII"}),(0,s.jsx)(tg.Z,{size:10,className:"text-accent/40"}),(0,s.jsx)("span",{className:"text-text-secondary",children:"KANBAII sends tasks to Claude Code"}),(0,s.jsx)(tg.Z,{size:10,className:"text-accent/40"}),(0,s.jsx)("span",{className:"text-text-secondary",children:"Results come back to the board"})]})]})}function tC(){return(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-0 rounded-md border border-border/40 bg-bg/50 p-3 font-mono text-[11px]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-accent",children:"◇"}),(0,s.jsx)("span",{className:"text-text font-medium",children:"My Startup MVP"}),(0,s.jsx)("span",{className:"text-text-muted/40 ml-auto text-[11px]",children:"project"})]}),(0,s.jsxs)("div",{className:"ml-3 border-l border-border/30 pl-3 mt-1.5 flex flex-col gap-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-feature"}),(0,s.jsx)("span",{className:"text-text-secondary",children:"User Authentication"}),(0,s.jsx)("span",{className:"text-text-muted/30 ml-auto text-[11px]",children:"feature"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-feature"}),(0,s.jsx)("span",{className:"text-text-secondary",children:"Payment Integration"}),(0,s.jsx)("span",{className:"text-text-muted/30 ml-auto text-[11px]",children:"feature"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-bug"}),(0,s.jsx)("span",{className:"text-text-secondary",children:"Login 500 error"}),(0,s.jsx)("span",{className:"text-text-muted/30 ml-auto text-[11px]",children:"bug"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-refactor"}),(0,s.jsx)("span",{className:"text-text-secondary",children:"Cleanup API routes"}),(0,s.jsx)("span",{className:"text-text-muted/30 ml-auto text-[11px]",children:"refactor"})]})]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted leading-relaxed text-center",children:"Each work item has its own plan, tasks, and kanban board."})]})}function tS(){return(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"text-[11px] font-mono text-text-muted/40 uppercase tracking-wider mb-1.5 flex items-center gap-1.5",children:[(0,s.jsx)(tj.Z,{size:9}),"Level 1 — Work Items"]}),(0,s.jsxs)("div",{className:"flex gap-1.5 rounded-md border border-border/40 bg-bg/50 p-2.5",children:[(0,s.jsx)(tw,{title:"Planning",children:(0,s.jsx)(ty,{label:"Payment",color:"text-feature bg-feature/10 border-feature/20"})}),(0,s.jsxs)(tw,{title:"Active",highlight:!0,children:[(0,s.jsx)(ty,{label:"User Auth",color:"text-feature bg-feature/10 border-feature/20"}),(0,s.jsx)(ty,{label:"Login 500",color:"text-bug bg-bug/10 border-bug/20"})]}),(0,s.jsx)(tw,{title:"Review",children:(0,s.jsx)(ty,{label:"Cleanup API",color:"text-refactor bg-refactor/10 border-refactor/20"})}),(0,s.jsx)(tw,{title:"Done"})]})]}),(0,s.jsx)("div",{className:"flex items-center justify-center",children:(0,s.jsx)(tv.Z,{size:12,className:"text-text-muted/20"})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"text-[11px] font-mono text-text-muted/40 uppercase tracking-wider mb-1.5 flex items-center gap-1.5",children:[(0,s.jsx)(tx.Z,{size:9}),'Level 2 — Tasks inside "User Auth"']}),(0,s.jsxs)("div",{className:"flex gap-1 rounded-md border border-accent/20 bg-accent/[0.02] p-2.5",children:[(0,s.jsx)(tw,{title:"Backlog",children:(0,s.jsx)(ty,{label:"OAuth",color:"text-text-muted bg-surface border-border/40"})}),(0,s.jsx)(tw,{title:"Todo",children:(0,s.jsx)(ty,{label:"DB schema",color:"text-text-muted bg-surface border-border/40"})}),(0,s.jsx)(tw,{title:"Doing",highlight:!0,children:(0,s.jsx)(ty,{label:"JWT",color:"text-text-muted bg-surface border-border/40"})}),(0,s.jsx)(tw,{title:"Review",children:(0,s.jsx)(ty,{label:"Login form",color:"text-text-muted bg-surface border-border/40"})}),(0,s.jsx)(tw,{title:"Done",children:(0,s.jsx)(ty,{label:"User model",color:"text-text-muted/40 bg-transparent border-border/20"})})]})]})]})}function tT(){return(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"rounded-md border border-border/40 bg-bg/50 overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-3 py-2.5 border-b border-border/30 flex items-start gap-2.5",children:[(0,s.jsx)("div",{className:"w-1 h-full min-h-[16px] rounded-full bg-accent/40 shrink-0 mt-0.5"}),(0,s.jsx)("span",{className:"text-xs text-text-secondary italic leading-relaxed",children:'"I need user auth with login, signup, password reset, and OAuth for Google & GitHub"'})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border/20",children:[(0,s.jsxs)("div",{className:"px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] font-mono text-warning/60 mb-1.5",children:[(0,s.jsx)(x.Z,{size:9}),"Plan generated"]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 text-[11px] text-text-muted leading-relaxed",children:[(0,s.jsx)("span",{children:"1. Design user model & DB schema"}),(0,s.jsx)("span",{children:"2. Auth endpoints (JWT-based)"}),(0,s.jsx)("span",{children:"3. Password reset flow w/ email"}),(0,s.jsx)("span",{children:"4. OAuth integration"}),(0,s.jsx)("span",{children:"5. Frontend login/signup forms"})]})]}),(0,s.jsxs)("div",{className:"px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] font-mono text-success/60 mb-1.5",children:[(0,s.jsx)(tx.Z,{size:9}),"Tasks created"]}),(0,s.jsx)("div",{className:"flex flex-col gap-0.5 text-[11px]",children:["User model schema","Login endpoint","Signup endpoint","JWT middleware","Password reset","Google OAuth","GitHub OAuth","Login page UI"].map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-success/50 text-[10px]",children:"✓"}),(0,s.jsx)("span",{className:"text-text-muted",children:e})]},e))})]})]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted leading-relaxed text-center",children:"Review, edit, approve. Skip any step. Create manually if you prefer."})]})}function t_(){return(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,s.jsxs)("div",{className:"rounded-md border border-accent/20 bg-accent/[0.02] p-3 font-mono text-[11px]",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-accent font-medium",children:[(0,s.jsx)(eN.Z,{size:11}),'Ralph executing "User Auth"']}),(0,s.jsx)("span",{className:"text-[11px] text-accent/40",children:"3/6 tasks"})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1.5 ml-1",children:[{label:"Read plan for context",status:"done"},{label:"DB schema → created",status:"done"},{label:"Login endpoint → created",status:"done"},{label:"JWT middleware",status:"running"},{label:"Password reset",status:"queued"},{label:"OAuth integration",status:"queued"}].map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 ".concat("queued"===e.status?"opacity-35":""),children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0\n ".concat("done"===e.status?"bg-success":"","\n ").concat("running"===e.status?"bg-accent animate-breathe":"","\n ").concat("queued"===e.status?"bg-text-muted/30":"")}),(0,s.jsx)("span",{className:"running"===e.status?"text-text-secondary":"text-text-muted/60",children:e.label}),(0,s.jsx)("span",{className:"ml-auto text-[11px]\n ".concat("done"===e.status?"text-success/50":"","\n ").concat("running"===e.status?"text-accent/50 animate-breathe":"","\n ").concat("queued"===e.status?"text-text-muted/20":""),children:e.status})]},e.label))})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted leading-relaxed text-center",children:"One work item, full attention. Sequential and parallel where safe."})]})}function tz(){return(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,s.jsxs)("div",{className:"rounded-md border border-success/20 bg-success/[0.02] p-3 font-mono text-[11px]",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-success font-medium",children:[(0,s.jsx)(ev.Z,{size:11}),"Teams — 3 workers active"]}),(0,s.jsx)("span",{className:"text-[11px] text-success/40",children:"parallel"})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:[{worker:"Worker 1",item:"User Auth",type:"feature",progress:"3/6",running:!0},{worker:"Worker 2",item:"Payment",type:"feature",progress:"1/4",running:!0},{worker:"Worker 3",item:"Login 500",type:"bug",progress:"2/2",running:!1}].map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2.5 px-2.5 py-2 rounded bg-surface/50 border border-border/30",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0 ".concat(e.running?"bg-accent animate-breathe":"bg-success")}),(0,s.jsx)("span",{className:"text-text-secondary w-16",children:e.worker}),(0,s.jsxs)("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0 ".concat("feature"===e.type?"bg-feature":"bg-bug")}),(0,s.jsx)("span",{className:"text-text-muted truncate",children:e.item})]}),(0,s.jsx)("div",{className:"w-12 h-1 rounded-full bg-border/30 overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full ".concat(e.running?"bg-accent/50":"bg-success/50"),style:{width:"".concat(parseInt(e.progress)/parseInt(e.progress.split("/")[1])*100,"%")}})}),(0,s.jsx)("span",{className:"text-[11px] tabular-nums w-8 text-right ".concat(e.running?"text-accent/40":"text-success/40"),children:e.progress})]},e.worker))})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted leading-relaxed text-center",children:"Multiple work items, multiple workers, all advancing at once."})]})}function tZ(){return(0,s.jsx)("div",{className:"h-full overflow-y-auto",children:(0,s.jsxs)("div",{className:"flex flex-col gap-8 max-w-[920px] w-full mx-auto px-8 py-10 animate-fade-in-up",children:[(0,s.jsxs)("div",{className:"flex items-center gap-6",children:[(0,s.jsxs)("div",{className:"relative shrink-0",children:[(0,s.jsx)("span",{className:"text-[44px] leading-none text-accent opacity-20 animate-breathe select-none",children:"◇"}),(0,s.jsx)("div",{className:"absolute inset-0 blur-[24px] bg-accent/10 rounded-full"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,s.jsx)("h1",{className:"text-[26px] font-semibold text-text tracking-tight",children:"The organization layer for Claude Code"}),(0,s.jsx)("p",{className:"text-sm text-text-secondary leading-relaxed max-w-lg",children:"Claude Code is great at executing one task. KANBAII lets you see the whole project, plan the work, and let AI execute across many tasks at once."})]})]}),(0,s.jsx)(tN,{icon:(0,s.jsx)(P.Z,{size:14}),title:"KANBAII + Claude Code",subtitle:"Not a replacement — the project layer Claude Code doesn't have",accentColor:"bg-accent/8 text-accent/60",defaultOpen:!0,children:(0,s.jsx)(tk,{})}),(0,s.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2.5 items-stretch",children:[(0,s.jsx)(tN,{icon:(0,s.jsx)(tj.Z,{size:14}),title:"Organize in two levels",subtitle:"Project → Work Items → Tasks",accentColor:"bg-accent/8 text-accent/60",defaultOpen:!0,children:(0,s.jsx)(tC,{})}),(0,s.jsx)(tN,{icon:(0,s.jsx)(tx.Z,{size:14}),title:"Every item gets a kanban board",subtitle:"Drag tasks through Backlog → Done",accentColor:"bg-feature/10 text-feature/70",defaultOpen:!0,children:(0,s.jsx)(tS,{})})]}),(0,s.jsx)(tN,{icon:(0,s.jsx)(x.Z,{size:14}),title:"AI Planner",subtitle:"Describe what you need → get a structured plan and tasks",accentColor:"bg-warning/10 text-warning/70",children:(0,s.jsx)(tT,{})}),(0,s.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2.5",children:[(0,s.jsx)(tN,{icon:(0,s.jsx)(eN.Z,{size:14}),title:"Ralph — focused executor",subtitle:"One work item, executed end to end by AI",accentColor:"bg-accent/8 text-accent/60",children:(0,s.jsx)(t_,{})}),(0,s.jsx)(tN,{icon:(0,s.jsx)(ev.Z,{size:14}),title:"Teams — parallel execution",subtitle:"Multiple items, multiple AI workers, at once",accentColor:"bg-success/10 text-success/70",children:(0,s.jsx)(tz,{})})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-border/40 bg-surface/30 p-5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 mb-3",children:[(0,s.jsx)(eS.Z,{size:14,className:"text-accent/50"}),(0,s.jsx)("span",{className:"text-sm font-medium text-text",children:"Quick Start"})]}),(0,s.jsxs)("div",{className:"font-mono text-[12px] text-text-muted leading-relaxed flex flex-col gap-1",children:[(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("span",{className:"text-text-muted/30 select-none",children:"$"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"text-accent/70",children:"npm"})," install -g kanbaii"]})]}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("span",{className:"text-text-muted/30 select-none",children:"$"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"text-accent/70",children:"kanbaii"})," doctor"]}),(0,s.jsx)("span",{className:"text-text-muted/30 ml-4",children:"# verify Claude CLI + auth"})]}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("span",{className:"text-text-muted/30 select-none",children:"$"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"text-accent/70",children:"kanbaii"})," start"]}),(0,s.jsx)("span",{className:"text-text-muted/30 ml-4",children:"# opens this dashboard"})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 text-xs text-text-muted font-mono pb-4",children:[(0,s.jsx)(P.Z,{size:10,className:"text-accent/30"}),"Create a project from the sidebar to begin"]})]})})}function tP(){let{projectSlug:e,workItemSlug:t,goHome:a,goBack:c}=(0,o.U)(),i=(0,l.i)(e=>e.projects).find(t=>t.slug===e);return(0,s.jsxs)("nav",{className:"flex items-center gap-1 text-xxs font-mono tracking-wide mr-auto",children:[(0,s.jsxs)("button",{onClick:a,className:"flex items-center gap-1.5 text-text-muted hover:text-accent transition-colors duration-150 group",children:[(0,s.jsx)(n.Z,{size:11,className:"opacity-50 group-hover:opacity-100 transition-opacity duration-150"}),(0,s.jsx)("span",{className:"uppercase tracking-widest",children:"Kanbaii"})]}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Z,{size:10,className:"text-text-muted/30"}),t?(0,s.jsx)("button",{onClick:c,className:"text-text-muted hover:text-accent transition-colors duration-150 truncate max-w-[160px]",children:i.title}):(0,s.jsx)("span",{className:"text-text-secondary truncate max-w-[160px]",children:i.title})]}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Z,{size:10,className:"text-text-muted/30"}),(0,s.jsx)("span",{className:"text-text-secondary truncate max-w-[160px]",children:t})]})]})}function tE(){let{projectSlug:e,workItemSlug:t,view:a}=(0,o.U)();return e?t?(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center px-4 py-2 border-b border-border flex-shrink-0 bg-bg gap-4",children:[(0,s.jsx)(tP,{}),(0,s.jsx)(tb,{})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(()=>{switch(a){case"board":default:return(0,s.jsx)(eb,{projectSlug:e,wiSlug:t});case"ralph":return(0,s.jsx)(eg,{projectSlug:e,wiSlug:t})}})()})]}):(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center px-4 py-2 border-b border-border flex-shrink-0 bg-bg gap-4",children:[(0,s.jsx)(tP,{}),(0,s.jsx)(tb,{}),(0,s.jsx)(tf,{})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(()=>{switch(a){case"work-items":default:return(0,s.jsx)(_,{projectSlug:e});case"console":return(0,s.jsx)(eK,{projectSlug:e});case"teams":return(0,s.jsx)(eF,{projectSlug:e});case"soul":return(0,s.jsx)(eQ,{projectSlug:e});case"planner":return(0,s.jsx)(td,{projectSlug:e})}})()})]}):(0,s.jsx)(tZ,{})}}},function(e){e.O(0,[184,759,23,971,117,744],function(){return e(e.s=7972)}),_N_E=e.O()}]);
|