kanbaii 0.4.0 → 0.5.0

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.
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/735f5195647c6b5c.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-5c1d03322d6ecf76.js"/><script src="/_next/static/chunks/fd9d1056-1f1f859026f5f0fa.js" async=""></script><script src="/_next/static/chunks/117-749dc8b5f56031ab.js" async=""></script><script src="/_next/static/chunks/main-app-2f313c3206a6e049.js" async=""></script><script src="/_next/static/chunks/184-15d72b1991c86ab9.js" async=""></script><script src="/_next/static/chunks/23-4a72ba4a90f008a6.js" async=""></script><script src="/_next/static/chunks/app/layout-ccc8d24485f54bd6.js" async=""></script><meta name="robots" content="noindex"/><meta name="theme-color" content="#6366f1"/><title>KANBAII</title><meta name="description" content="Structure for your ideas. AI to move them forward."/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.svg" type="image/svg+xml"/><link rel="icon" href="/favicon-16x16.svg" sizes="16x16" type="image/svg+xml"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><script src="/_next/static/chunks/webpack-5c1d03322d6ecf76.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/css/735f5195647c6b5c.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[2846,[],\"\"]\n4:I[4707,[],\"\"]\n5:I[6423,[],\"\"]\n6:I[792,[\"184\",\"static/chunks/184-15d72b1991c86ab9.js\",\"23\",\"static/chunks/23-4a72ba4a90f008a6.js\",\"185\",\"static/chunks/app/layout-ccc8d24485f54bd6.js\"],\"AppShell\"]\nc:I[1060,[],\"\"]\n7:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n8:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n9:{\"display\":\"inline-block\"}\na:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\nd:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L2\",null,{\"buildId\":\"k3eq3Vr89K2vwr7X2Gdl2\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"_not-found\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/735f5195647c6b5c.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L6\",null,{\"children\":[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$7\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$8\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$9\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$a\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lb\"],\"globalErrorComponent\":\"$c\",\"missingSlots\":\"$Wd\"}]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"name\":\"theme-color\",\"content\":\"#6366f1\"}],[\"$\",\"meta\",\"2\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"3\",{\"children\":\"KANBAII\"}],[\"$\",\"meta\",\"4\",{\"name\":\"description\",\"content\":\"Structure for your ideas. AI to move them forward.\"}],[\"$\",\"link\",\"5\",{\"rel\":\"manifest\",\"href\":\"/manifest.json\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"link\",\"6\",{\"rel\":\"icon\",\"href\":\"/favicon.svg\",\"type\":\"image/svg+xml\"}],[\"$\",\"link\",\"7\",{\"rel\":\"icon\",\"href\":\"/favicon-16x16.svg\",\"sizes\":\"16x16\",\"type\":\"image/svg+xml\"}]]\n3:null\n"])</script></body></html>
1
+ <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/735f5195647c6b5c.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-5c1d03322d6ecf76.js"/><script src="/_next/static/chunks/fd9d1056-1f1f859026f5f0fa.js" async=""></script><script src="/_next/static/chunks/117-749dc8b5f56031ab.js" async=""></script><script src="/_next/static/chunks/main-app-2f313c3206a6e049.js" async=""></script><script src="/_next/static/chunks/184-15d72b1991c86ab9.js" async=""></script><script src="/_next/static/chunks/23-4a72ba4a90f008a6.js" async=""></script><script src="/_next/static/chunks/app/layout-4b8075f77af9a0e2.js" async=""></script><meta name="robots" content="noindex"/><meta name="theme-color" content="#6366f1"/><title>KANBAII</title><meta name="description" content="Structure for your ideas. AI to move them forward."/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.svg" type="image/svg+xml"/><link rel="icon" href="/favicon-16x16.svg" sizes="16x16" type="image/svg+xml"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><script src="/_next/static/chunks/webpack-5c1d03322d6ecf76.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/css/735f5195647c6b5c.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[2846,[],\"\"]\n4:I[4707,[],\"\"]\n5:I[6423,[],\"\"]\n6:I[792,[\"184\",\"static/chunks/184-15d72b1991c86ab9.js\",\"23\",\"static/chunks/23-4a72ba4a90f008a6.js\",\"185\",\"static/chunks/app/layout-4b8075f77af9a0e2.js\"],\"AppShell\"]\nc:I[1060,[],\"\"]\n7:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n8:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n9:{\"display\":\"inline-block\"}\na:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\nd:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L2\",null,{\"buildId\":\"g0V9ldKabJaJ3dsXFDa0k\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"_not-found\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/735f5195647c6b5c.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L6\",null,{\"children\":[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$7\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$8\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$9\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$a\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lb\"],\"globalErrorComponent\":\"$c\",\"missingSlots\":\"$Wd\"}]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"name\":\"theme-color\",\"content\":\"#6366f1\"}],[\"$\",\"meta\",\"2\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"3\",{\"children\":\"KANBAII\"}],[\"$\",\"meta\",\"4\",{\"name\":\"description\",\"content\":\"Structure for your ideas. AI to move them forward.\"}],[\"$\",\"link\",\"5\",{\"rel\":\"manifest\",\"href\":\"/manifest.json\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"link\",\"6\",{\"rel\":\"icon\",\"href\":\"/favicon.svg\",\"type\":\"image/svg+xml\"}],[\"$\",\"link\",\"7\",{\"rel\":\"icon\",\"href\":\"/favicon-16x16.svg\",\"sizes\":\"16x16\",\"type\":\"image/svg+xml\"}]]\n3:null\n"])</script></body></html>
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{4732:function(e,t,s){Promise.resolve().then(s.t.bind(s,7960,23)),Promise.resolve().then(s.bind(s,792))},792:function(e,t,s){"use strict";s.d(t,{AppShell:function(){return ek}});var a=s(7437),n=s(2265);let r=(0,n.createContext)(void 0);function o(e){let{children:t}=e,[s,o]=(0,n.useState)("dark"),[l,i]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let e=localStorage.getItem("kanbaii-theme");"light"===e||"dark"===e?o(e):o("dark"),i(!0)},[]),(0,n.useEffect)(()=>{l&&(document.documentElement.setAttribute("data-theme",s),localStorage.setItem("kanbaii-theme",s))},[s,l]),l)?(0,a.jsx)(r.Provider,{value:{theme:s,toggleTheme:()=>{o(e=>"dark"===e?"light":"dark")}},children:t}):null}function l(){let e=(0,n.useContext)(r);if(!e)throw Error("useTheme must be used within ThemeProvider");return e}var i=s(2829);let c=(0,i.Z)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);var d=s(9397);let x=(0,i.Z)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),u=(0,i.Z)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);var p=s(8930),m=s(407),h=s(9076);let f=(0,i.Z)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);var b=s(8728),g=s(9747),v=s(9449),j=s(2569),y=s(9405),k=s(1347);function N(){let{theme:e,toggleTheme:t}=l();return(0,a.jsxs)("button",{className:"relative w-12 h-[26px] rounded-[13px] border border-border bg-surface cursor-pointer p-0 transition-all duration-250 ease-out-expo overflow-hidden shrink-0 hover:border-accent hover:bg-surface-hover hover:shadow-[0_0_8px_var(--accent-glow)]",onClick:t,title:"Switch to ".concat("dark"===e?"light":"dark"," theme"),children:[(0,a.jsx)(k.E.div,{className:"absolute top-0.5 left-0.5 w-5 h-5 rounded-[10px] bg-accent shadow-[0_2px_6px_rgba(0,0,0,0.3)] flex items-center justify-center",initial:!1,animate:{x:"dark"===e?0:22},transition:{type:"spring",stiffness:300,damping:30},children:"dark"===e?(0,a.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):(0,a.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,a.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,a.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,a.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,a.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,a.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,a.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,a.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,a.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})}),(0,a.jsxs)("div",{className:"absolute inset-0 flex items-center justify-between px-1.5 pointer-events-none",children:[(0,a.jsx)("div",{className:"ml-0.5 transition-opacity duration-250 ease-out-expo ".concat("dark"===e?"opacity-30":"opacity-0"),children:(0,a.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),(0,a.jsx)("div",{className:"mr-0.5 transition-opacity duration-250 ease-out-expo ".concat("light"===e?"opacity-30":"opacity-0"),children:(0,a.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,a.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,a.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"})]})})]})]})}var w=s(2489),C=s(1171),S=s(9116);let T=["#6366f1","#ef4444","#f59e0b","#22c55e","#3b82f6","#8b5cf6","#ec4899","#14b8a6"];function z(e){let{onClose:t}=e,s=(0,v.U)(e=>e.goToProject),r=(0,g.i)(e=>e.createProject),[o,l]=(0,n.useState)(""),[i,c]=(0,n.useState)(""),[d,x]=(0,n.useState)(""),[u,p]=(0,n.useState)(T[0]),[m,h]=(0,n.useState)(!1),{overlayProps:f}=(0,C.N)(t,{disabled:m});(0,n.useEffect)(()=>{S.h.getHealth().then(e=>{e.cwd&&!d&&x(e.cwd)}).catch(()=>{})},[]);let b=async e=>{if(e.preventDefault(),o.trim()){h(!0);try{let e=await r({title:o.trim(),description:i.trim()||void 0,color:u,workingDir:d.trim()||void 0});t(),s(e.slug)}catch(e){h(!1)}}};return(0,a.jsx)("div",{className:"glass-overlay",...f,children:(0,a.jsxs)("div",{className:"modal-box w-[440px] max-w-[92%] p-7",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-7",children:[(0,a.jsx)("span",{className:"text-h2 font-semibold tracking-tight",children:"New Project"}),(0,a.jsx)("button",{className:"btn-icon",onClick:t,children:(0,a.jsx)(w.Z,{size:16})})]}),(0,a.jsxs)("form",{className:"flex flex-col gap-5",onSubmit:b,children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Title"}),(0,a.jsx)("input",{value:o,onChange:e=>l(e.target.value),placeholder:"Project name...",autoFocus:!0})]}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Description (optional)"}),(0,a.jsx)("input",{value:i,onChange:e=>c(e.target.value),placeholder:"Brief description..."})]}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Working Directory"}),(0,a.jsx)("input",{value:d,onChange:e=>x(e.target.value),placeholder:"C:\\Users\\...\\my-project"}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted mt-1 opacity-60",children:"Where Claude runs commands. Defaults to where kanbaii was started."})]}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Color"}),(0,a.jsx)("div",{className:"flex gap-2",children:T.map(e=>(0,a.jsx)("button",{type:"button",className:"w-6 h-6 rounded-full border-2 cursor-pointer transition-all duration-150 ease-out-expo\n ".concat(u===e?"border-text shadow-[0_0_8px_currentColor]":"border-transparent shadow-[0_0_0_0_transparent]","\n hover:scale-[1.2] hover:shadow-[0_0_12px_currentColor]"),style:{background:e},onClick:()=>p(e)},e))})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,a.jsx)("button",{type:"button",className:"btn-ghost",onClick:t,children:"Cancel"}),(0,a.jsx)("button",{type:"submit",className:"btn-primary",disabled:!o.trim()||m,children:m?"Creating...":"Create"})]})]})]})})}let E=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555",P=[{key:"general",label:"General"},{key:"ralph",label:"Ralph"},{key:"scheduler",label:"Scheduler"},{key:"terminal",label:"Terminal"},{key:"auth",label:"Auth"},{key:"integrations",label:"Integrations"}];function M(e){let{onClose:t}=e,s=(0,y.E)(e=>e.addToast),[r,o]=(0,n.useState)("general"),[l,i]=(0,n.useState)(null),[c,d]=(0,n.useState)(!1),{overlayProps:x}=(0,C.N)(t),u=(0,n.useCallback)(async()=>{try{let e=await fetch("".concat(E,"/api/settings")),t=await e.json();t.ok&&i(t.data)}catch(e){}},[]);(0,n.useEffect)(()=>{u()},[u]);let p=async(e,t)=>{d(!0);try{await fetch("".concat(E,"/api/settings/").concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s("Settings saved","success"),u()}catch(e){s("Failed to save","error")}d(!1)};return l?(0,a.jsx)("div",{className:"glass-overlay",...x,children:(0,a.jsxs)("div",{className:"modal-box max-w-[680px] w-[95%] max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-6 pt-5 pb-4 shrink-0",children:[(0,a.jsxs)("div",{className:"text-h2 font-semibold tracking-tight flex items-center gap-2",children:[(0,a.jsx)(b.Z,{size:16})," Settings"]}),(0,a.jsx)("button",{className:"btn-icon",onClick:t,children:(0,a.jsx)(w.Z,{size:16})})]}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,a.jsx)("div",{className:"w-40 shrink-0 border-r border-border p-2 flex flex-col gap-0.5 bg-bg-subtle",children:P.map(e=>(0,a.jsx)("button",{className:"px-3 py-2 text-xs font-medium text-text-muted rounded-sm text-left transition-all duration-150 ease-out-expo hover:text-text-secondary hover:bg-surface-hover ".concat(r===e.key?"text-text bg-accent-muted":""),onClick:()=>o(e.key),children:e.label},e.key))}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:["general"===r&&(0,a.jsxs)(_,{title:"General",onSave:e=>p("general",e),saving:c,children:[(0,a.jsx)(I,{label:"Default Model",type:"select",value:l.general.defaultModel,options:["haiku","sonnet","opus"],field:"defaultModel"}),(0,a.jsx)(I,{label:"Timezone",value:l.general.timezone,field:"timezone"}),(0,a.jsx)(I,{label:"Port",type:"number",value:l.general.port,field:"port"})]}),"ralph"===r&&(0,a.jsxs)(_,{title:"Ralph",onSave:e=>p("ralph",e),saving:c,children:[(0,a.jsx)(I,{label:"Max Iterations",type:"number",value:l.ralph.maxIterations,field:"maxIterations"}),(0,a.jsx)(I,{label:"Circuit Breaker (max errors)",type:"number",value:l.ralph.circuitBreaker,field:"circuitBreaker"}),(0,a.jsx)(I,{label:"Task Filter",type:"select",value:l.ralph.taskFilter,options:["todo-only","all"],field:"taskFilter"})]}),"scheduler"===r&&(0,a.jsxs)(_,{title:"Scheduler",onSave:e=>p("scheduler",e),saving:c,children:[(0,a.jsx)(I,{label:"Enabled",type:"toggle",value:l.scheduler.enabled,field:"enabled"}),(0,a.jsx)(I,{label:"Max Concurrent",type:"number",value:l.scheduler.maxConcurrent,field:"maxConcurrent"}),(0,a.jsx)(I,{label:"Timeout (ms)",type:"number",value:l.scheduler.timeout,field:"timeout"}),(0,a.jsx)(I,{label:"Stale Threshold (min)",type:"number",value:l.scheduler.staleThreshold,field:"staleThreshold"})]}),"terminal"===r&&(0,a.jsxs)(_,{title:"Terminal",onSave:e=>p("terminal",e),saving:c,children:[(0,a.jsx)(I,{label:"Inactivity Warn (min)",type:"number",value:l.terminal.inactivityWarn,field:"inactivityWarn"}),(0,a.jsx)(I,{label:"Inactivity Kill (min)",type:"number",value:l.terminal.inactivityKill,field:"inactivityKill"}),(0,a.jsx)(I,{label:"Max Timeout (min)",type:"number",value:l.terminal.maxTimeout,field:"maxTimeout"})]}),"auth"===r&&(0,a.jsxs)(_,{title:"Authentication",onSave:e=>p("auth",e),saving:c,children:[(0,a.jsx)(I,{label:"Enabled",type:"toggle",value:l.auth.enabled,field:"enabled"}),(0,a.jsx)(I,{label:"Secret Key",value:l.auth.secret,field:"secret",placeholder:"auto-generated if empty"}),(0,a.jsx)(I,{label:"Token Expiry",value:l.auth.tokenExpiry,field:"tokenExpiry",placeholder:"24h"})]}),"integrations"===r&&(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)(_,{title:"Telegram",onSave:e=>p("integrations",{telegram:e}),saving:c,children:[(0,a.jsx)(I,{label:"Enabled",type:"toggle",value:l.integrations.telegram.enabled,field:"enabled"}),(0,a.jsx)(I,{label:"Bot Token",value:l.integrations.telegram.botToken,field:"botToken",placeholder:"123456:ABC-DEF..."}),(0,a.jsx)(I,{label:"Chat ID",value:l.integrations.telegram.chatId,field:"chatId",placeholder:"-100123456789"})]}),(0,a.jsxs)(_,{title:"Voice Input",onSave:e=>p("integrations",{voice:e}),saving:c,children:[(0,a.jsx)(I,{label:"Enabled",type:"toggle",value:l.integrations.voice.enabled,field:"enabled"}),(0,a.jsx)(I,{label:"OpenAI API Key",value:l.integrations.voice.openaiApiKey||"",field:"openaiApiKey",placeholder:"sk-... (for Whisper fallback)"})]})]})]})]})]})}):null}function _(e){let{title:t,children:s,onSave:r,saving:o}=e,[l,i]=(0,n.useState)({});(0,n.useEffect)(()=>{let e={};n.Children.forEach(s,t=>{var s;(null==t?void 0:null===(s=t.props)||void 0===s?void 0:s.field)&&(e[t.props.field]=t.props.value)}),i(e)},[s]);let c=(e,t)=>{i(s=>({...s,[e]:t}))};return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-body font-semibold text-text tracking-tight",children:t}),(0,a.jsx)("button",{className:"btn-primary",onClick:()=>r(l),disabled:o,children:o?"Saving...":"Save"})]}),(0,a.jsx)("div",{className:"flex flex-col gap-3",children:n.Children.map(s,e=>{var t,s;return(null==e?void 0:null===(t=e.props)||void 0===t?void 0:t.field)?n.cloneElement(e,{value:null!==(s=l[e.props.field])&&void 0!==s?s:e.props.value,onChange:t=>c(e.props.field,t)}):e})})]})}function I(e){let{label:t,value:s,field:n,type:r,options:o,placeholder:l,onChange:i}=e;return"toggle"===r?(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-secondary min-w-[140px] shrink-0",children:t}),(0,a.jsx)("button",{className:"px-3 py-1 text-data font-semibold rounded-xs font-mono border transition-all duration-150 ease-out-expo tracking-wide ".concat(s?"text-success border-success-dim bg-success-dim":"text-text-muted border-border"),onClick:()=>null==i?void 0:i(!s),children:s?"ON":"OFF"})]}):"select"===r&&o?(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-secondary min-w-[140px] shrink-0",children:t}),(0,a.jsx)("div",{className:"flex gap-1",children:o.map(e=>(0,a.jsx)("button",{className:"px-2.5 py-1 text-data font-medium rounded-full border font-mono transition-all duration-150 ease-out-expo ".concat(s===e?"border-accent-dim text-accent bg-accent-muted":"border-border text-text-muted hover:border-border-light hover:text-text-secondary"),onClick:()=>null==i?void 0:i(e),children:e},e))})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-secondary min-w-[140px] shrink-0",children:t}),(0,a.jsx)("input",{type:r||"text",value:null!=s?s:"",onChange:e=>null==i?void 0:i("number"===r?Number(e.target.value):e.target.value),placeholder:l,className:"flex-1 max-w-[200px] text-right font-mono text-xs"})]})}let A=(0,i.Z)("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);var Z=s(1239),R=s(1723);let D=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function F(e){return e<.01?"$".concat(e.toFixed(4)):"$".concat(e.toFixed(2))}function L(e){var t;let{projectSlug:s}=e,r=(0,y.E)(e=>e.addToast),[o,l]=(0,n.useState)(null),[i,c]=(0,n.useState)([]),[d,x]=(0,n.useState)("30d"),[u,m]=(0,n.useState)(s?"project":"global"),h=(0,n.useCallback)(async()=>{let e="project"===u&&s?s:void 0,t="7d"===d?7:"30d"===d?30:void 0,[a,n]=await Promise.all([fetch("".concat(D,"/api/costs/summary").concat(e?"?projectSlug=".concat(e):"")).then(e=>e.json()).catch(()=>({data:null})),fetch("".concat(D,"/api/costs/executions?limit=50").concat(e?"&projectSlug=".concat(e):"").concat(t?"&days=".concat(t):"")).then(e=>e.json()).catch(()=>({data:[]}))]);l(a.data||null),c(n.data||[])},[s,u,d]);(0,n.useEffect)(()=>{h()},[h]);let b=async()=>{let e="project"===u&&s?"?projectSlug=".concat(s):"";await fetch("".concat(D,"/api/costs/clear").concat(e),{method:"DELETE"}),r("Execution history cleared","info"),h()},g={opus:"#a855f7",sonnet:"#6366f1",haiku:"#22c55e"};return(0,a.jsxs)("div",{className:"flex flex-col h-full overflow-y-auto gap-5 p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,a.jsxs)("div",{className:"text-h2 font-semibold tracking-tight flex items-center gap-2",children:[(0,a.jsx)(f,{size:18})," Costs & Analytics"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[s&&(0,a.jsxs)("div",{className:"flex border border-border rounded-sm overflow-hidden",children:[(0,a.jsx)("button",{className:"px-2.5 py-1 text-xxs font-semibold font-mono tracking-wide uppercase text-text-muted transition-all duration-150 ease-out-expo hover:text-text-secondary hover:bg-surface-hover ".concat("project"===u?"text-accent bg-accent-muted":""),onClick:()=>m("project"),children:"Project"}),(0,a.jsx)("button",{className:"px-2.5 py-1 text-xxs font-semibold font-mono tracking-wide uppercase text-text-muted transition-all duration-150 ease-out-expo hover:text-text-secondary hover:bg-surface-hover ".concat("global"===u?"text-accent bg-accent-muted":""),onClick:()=>m("global"),children:"Global"})]}),(0,a.jsx)("div",{className:"flex border border-border rounded-sm overflow-hidden",children:["7d","30d","all"].map(e=>(0,a.jsx)("button",{className:"px-2.5 py-1 text-xxs font-semibold font-mono tracking-wide uppercase text-text-muted transition-all duration-150 ease-out-expo hover:text-text-secondary hover:bg-surface-hover ".concat(d===e?"text-accent bg-accent-muted":""),onClick:()=>x(e),children:e},e))})]})]}),o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-4 gap-2 max-md:grid-cols-2",children:[(0,a.jsxs)("div",{className:"p-4 border border-border rounded-md bg-card text-center relative overflow-hidden",children:[(0,a.jsx)("div",{className:"text-accent mb-1.5 flex justify-center",children:(0,a.jsx)(A,{size:14})}),(0,a.jsx)("div",{className:"text-h1 font-bold text-text font-mono tracking-tight",children:F(o.todayCost)}),(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mt-1",children:"Today"})]}),(0,a.jsxs)("div",{className:"p-4 border border-border rounded-md bg-card text-center relative overflow-hidden",children:[(0,a.jsx)("div",{className:"text-accent mb-1.5 flex justify-center",children:(0,a.jsx)(A,{size:14})}),(0,a.jsx)("div",{className:"text-h1 font-bold text-text font-mono tracking-tight",children:F(o.monthlyCost)}),(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mt-1",children:"This Month"})]}),(0,a.jsxs)("div",{className:"p-4 border border-border rounded-md bg-card text-center relative overflow-hidden",children:[(0,a.jsx)("div",{className:"text-accent mb-1.5 flex justify-center",children:(0,a.jsx)(Z.Z,{size:14})}),(0,a.jsx)("div",{className:"text-h1 font-bold text-text font-mono tracking-tight",children:(t=o.monthlyTokens)>=1e6?"".concat((t/1e6).toFixed(1),"M"):t>=1e3?"".concat((t/1e3).toFixed(0),"K"):"".concat(t)}),(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mt-1",children:"Tokens (Month)"})]}),(0,a.jsxs)("div",{className:"p-4 border border-border rounded-md bg-card text-center relative overflow-hidden",children:[(0,a.jsx)("div",{className:"text-accent mb-1.5 flex justify-center",children:(0,a.jsx)(R.Z,{size:14})}),(0,a.jsx)("div",{className:"text-h1 font-bold text-text font-mono tracking-tight",children:o.monthlyExecutions}),(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mt-1",children:"Executions (Month)"})]})]}),Object.keys(o.byModel).length>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Model Breakdown"}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5",children:Object.entries(o.byModel).map(e=>{let[t,s]=e;return(0,a.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2.5 border border-border rounded-sm bg-card",children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:g[t]||"#6366f1"}}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text",children:t}),(0,a.jsxs)("span",{className:"text-data text-text-muted font-mono ml-2",children:[s.count," runs — ",F(s.cost)]})]}),(0,a.jsx)("div",{className:"w-20 h-1 rounded-full overflow-hidden",style:{background:"rgba(148, 163, 242, 0.06)"},children:(0,a.jsx)("div",{className:"h-full rounded-full transition-[width] duration-500 ease-out-expo",style:{width:"".concat(o.totalExecutions>0?s.count/o.totalExecutions*100:0,"%"),background:g[t]||"#6366f1"}})})]},t)})})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Recent Executions"}),(0,a.jsxs)("button",{className:"inline-flex items-center gap-[3px] text-xxs text-text-muted px-2 py-[3px] rounded-xs font-mono border border-border transition-all duration-120 ease-out-expo hover:text-danger hover:border-danger-dim",onClick:b,children:[(0,a.jsx)(p.Z,{size:10})," Clear"]})]}),0===i.length?(0,a.jsx)("div",{className:"text-text-muted text-label text-center py-8 font-mono opacity-50",children:"No executions recorded yet"}):(0,a.jsxs)("div",{className:"border border-border rounded-md overflow-hidden bg-card",children:[(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_70px_70px_60px_40px] px-3.5 py-2 text-xxs font-semibold text-text-muted uppercase tracking-wide font-mono border-b border-border bg-bg-subtle",children:[(0,a.jsx)("span",{children:"Task"}),(0,a.jsx)("span",{children:"Model"}),(0,a.jsx)("span",{children:"Duration"}),(0,a.jsx)("span",{children:"Cost"}),(0,a.jsx)("span",{children:"Status"})]}),i.map(e=>{var t;return(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_70px_70px_60px_40px] px-3.5 py-2 text-label border-b border-b-[rgba(148,163,242,0.03)] last:border-b-0 transition-colors duration-120 ease-out-expo hover:bg-surface-hover",children:[(0,a.jsx)("span",{className:"text-text overflow-hidden text-ellipsis whitespace-nowrap",children:e.taskTitle||e.projectSlug}),(0,a.jsx)("span",{className:"font-mono text-data font-semibold",style:{color:g[e.model]||"#6366f1"},children:e.model}),(0,a.jsx)("span",{className:"text-text-muted font-mono text-data",children:(t=e.duration)<1e3?"".concat(t,"ms"):"".concat((t/1e3).toFixed(1),"s")}),(0,a.jsx)("span",{className:"text-text-secondary font-mono text-data font-medium",children:F(e.costUsd)}),(0,a.jsx)("span",{className:"text-center ".concat("success"===e.status?"text-success":"text-danger"),children:"success"===e.status?"✓":"✗"})]},e.id)})]})]})]})}var q=s(7168),U=s(4401),B=s(6766);let O=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555",K="kanbaii-claude-usage";function W(e){return e>=80?"#ef4444":e>=60?"#f59e0b":"#6366f1"}function G(){try{var e;let t=sessionStorage.getItem(K);if(!t)return null;let s=JSON.parse(t);if((null==s?void 0:null===(e=s.entries)||void 0===e?void 0:e.length)>0&&Date.now()-new Date(s.timestamp).getTime()<3e5)return s}catch(e){}return null}function H(e){let{isExpanded:t}=e,[s,r]=(0,n.useState)(G),[o,l]=(0,n.useState)(!1),i=(0,n.useRef)(!0),c=(0,n.useCallback)(e=>{if(i.current){r(e),l(!1);try{sessionStorage.setItem(K,JSON.stringify(e))}catch(e){}}},[]),d=(0,n.useCallback)(async()=>{try{var e;let t=await fetch("".concat(O,"/api/costs/claude-usage")),s=await t.json(),a=(null==s?void 0:s.data)||s;if((null==a?void 0:null===(e=a.entries)||void 0===e?void 0:e.length)>0)return c(a),!0}catch(e){}return!1},[c]);(0,n.useEffect)(()=>{i.current=!0;let e=null,t=null,a=null,n=()=>{t=setInterval(async()=>{await d()&&t&&(clearInterval(t),t=null)},3e3),a=setTimeout(()=>{t&&(clearInterval(t),t=null),i.current&&!s&&l(!0)},3e4)};return e=setInterval(d,6e4),d().then(e=>{e||n()}),()=>{i.current=!1,e&&clearInterval(e),t&&clearInterval(t),a&&clearTimeout(a)}},[]),(0,n.useEffect)(()=>{let e=(0,B.h)(),t=e=>{var t;(null==e?void 0:null===(t=e.entries)||void 0===t?void 0:t.length)>0&&c(e)};return e.on("claude-usage",t),e.on("connect",()=>{d()}),()=>{e.off("claude-usage",t)}},[c,d]);let x=s?Math.max(...s.entries.map(e=>e.percent),0):0;return t?s?(0,a.jsxs)("div",{className:"px-3 py-2 flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mb-0.5",children:[(0,a.jsx)(U.Z,{size:10,className:"text-text-muted opacity-50"}),(0,a.jsx)("span",{className:"text-[8px] font-semibold text-text-muted uppercase tracking-[0.1em] font-mono opacity-60",children:"Rate Limits"})]}),s.entries.map((e,t)=>{var s;let n=W(e.percent),r=(s=e.percent)>=80?"rgba(239,68,68,0.3)":s>=60?"rgba(245,158,11,0.2)":"rgba(99,102,241,0.15)";return(0,a.jsxs)("div",{className:"flex flex-col gap-[3px]",children:[(0,a.jsxs)("div",{className:"flex justify-between items-baseline",children:[(0,a.jsx)("span",{className:"text-[9px] text-text-muted truncate max-w-[110px] font-mono",children:e.label}),(0,a.jsxs)("span",{className:"text-[10px] font-bold font-mono tabular-nums ".concat(e.percent>=80?"animate-breathe":""),style:{color:n},children:[e.percent,"%"]})]}),(0,a.jsx)("div",{className:"w-full h-[3px] rounded-full overflow-hidden",style:{background:"rgba(148,163,242,0.06)"},children:(0,a.jsx)("div",{className:"h-full rounded-full transition-[width] duration-700 ease-out",style:{width:"".concat(Math.min(e.percent,100),"%"),background:n,boxShadow:e.percent>40?"0 0 6px ".concat(r):"none"}})}),e.resetsAt&&(0,a.jsxs)("span",{className:"text-[7px] text-text-muted font-mono opacity-40",children:["Resets ",e.resetsAt]})]},t)})]}):o?(0,a.jsxs)("div",{className:"px-3 py-2 flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"text-[8px] text-text-muted font-mono opacity-40",children:"Unavailable"}),(0,a.jsxs)("button",{className:"text-[8px] text-accent font-mono opacity-60 hover:opacity-100 transition-opacity flex items-center gap-1",onClick:()=>{l(!1),d()},children:[(0,a.jsx)(q.Z,{size:8})," Retry"]})]}):(0,a.jsxs)("div",{className:"px-3 py-2 flex items-center justify-center gap-2",children:[(0,a.jsx)("div",{className:"w-2.5 h-2.5 border border-text-muted/20 border-t-accent/50 rounded-full animate-spin"}),(0,a.jsx)("span",{className:"text-[8px] text-text-muted font-mono opacity-40",children:"Loading usage..."})]}):s?(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1 py-1",title:s.entries.map(e=>"".concat(e.label,": ").concat(e.percent,"%")).join("\n"),children:[(0,a.jsx)("div",{className:"w-[5px] h-5 rounded-full overflow-hidden flex flex-col-reverse",style:{background:"rgba(148, 163, 242, 0.06)"},children:(0,a.jsx)("div",{className:"w-full rounded-full transition-[height] duration-500",style:{height:"".concat(Math.min(x,100),"%"),background:W(x)}})}),(0,a.jsxs)("span",{className:"text-[7px] text-text-muted font-mono opacity-50",children:[x,"%"]})]}):null}let V=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function J(){let{projects:e,fetchProjects:t,setActiveSlug:s,deleteProject:r,permanentDeleteProject:o,updateProject:l}=(0,g.i)(),{projectSlug:i,goToProject:k,goHome:w}=(0,v.U)(),C=(0,j.q)(e=>e.ralph),S=(0,j.q)(e=>e.teams),T=(0,y.E)(e=>e.addToast),[E,P]=(0,n.useState)(!1),[_,I]=(0,n.useState)(!1),[A,Z]=(0,n.useState)(!1),[R,D]=(0,n.useState)(null),[F,q]=(0,n.useState)(null),[U,B]=(0,n.useState)(null),[O,K]=(0,n.useState)(!1),[W,G]=(0,n.useState)(!1),[J,$]=(0,n.useState)(!0),[Q,Y]=(0,n.useState)(!1),ee=(0,n.useRef)(null),et=J||Q,es=(0,j.q)(e=>e.terminal.status),ea=(0,j.q)(e=>e.planner.active),en="running"===C.status||"paused"===C.status||S.active||"running"===es||ea;(0,n.useEffect)(()=>{t()},[t]),(0,n.useEffect)(()=>{if(!U)return;let e=e=>{e.target.closest("[data-context-menu]")||B(null)},t=setTimeout(()=>document.addEventListener("click",e),0);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},[U]);let er=e=>{s(e.slug),k(e.slug)},eo=async(e,t)=>{e.stopPropagation(),B(null);try{await l(t.slug,{status:"archived"}),i===t.slug&&w(),T("".concat(t.title," archived"),"success")}catch(e){T("Failed to archive","error")}},el=async(e,t)=>{e.stopPropagation(),B(null);try{await r(t.slug),i===t.slug&&w(),T("".concat(t.title," moved to trash"),"success")}catch(e){T("Failed to move to trash","error")}},ei=async(e,t)=>{if(e.stopPropagation(),F!==t.slug){q(t.slug),setTimeout(()=>q(null),3e3);return}B(null);try{await o(t.slug),T("".concat(t.title," permanently deleted"),"success"),q(null)}catch(e){T("Failed to delete","error")}},ec=async(e,t)=>{e.stopPropagation(),B(null);try{await l(t.slug,{status:"active"}),T("".concat(t.title," restored"),"success")}catch(e){T("Failed to restore","error")}},ed=(e,t)=>{e.stopPropagation(),fetch("".concat(V,"/api/system/open-folder"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.workingDir})}).catch(()=>T("Failed to open folder","error"))},ex=e.filter(e=>"active"===e.status),eu=e.filter(e=>"archived"===e.status),ep=e.filter(e=>"deleted"===e.status);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("aside",{className:"flex-shrink-0 border-r border-border bg-bg-subtle flex flex-col overflow-hidden relative z-10\n transition-all duration-300 ease-out-expo ".concat(et?"w-sidebar":"w-sidebar-collapsed"),onMouseEnter:()=>{ee.current&&clearTimeout(ee.current),Y(!0)},onMouseLeave:()=>{ee.current=setTimeout(()=>Y(!1),200)},children:[(0,a.jsxs)("div",{className:"flex items-center flex-shrink-0 min-h-[48px]\n ".concat(et?"px-3 pt-3.5 pb-2.5 justify-between":"px-0 pt-3.5 pb-[18px] justify-center"),children:[(0,a.jsxs)("div",{className:"flex items-center ".concat(et?"gap-2.5":"gap-0"),children:[(0,a.jsx)("div",{className:"rounded-sm flex items-center justify-center flex-shrink-0 overflow-hidden relative\n transition-all duration-400\n ".concat(et?"w-[26px] h-[26px]":"w-7 h-7","\n ").concat(en?"bg-gradient-to-br from-emerald-800 to-emerald-500 shadow-[0_0_10px_rgba(16,185,129,0.3),0_0_20px_rgba(16,185,129,0.1)] border border-emerald-500/35 animate-breathe":"bg-gradient-to-br from-indigo-800 to-indigo-400 shadow-[0_0_8px_rgba(99,102,241,0.15),inset_0_0_6px_rgba(99,102,241,0.06)] border border-indigo-500/12"),children:(0,a.jsxs)("svg",{width:et?26:28,height:et?26:28,viewBox:"0 0 32 32",className:"block",children:[(0,a.jsxs)("defs",{children:[(0,a.jsxs)("linearGradient",{id:"kc1",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"0%",stopColor:en?"#d1fae5":"#e0e7ff"}),(0,a.jsx)("stop",{offset:"100%",stopColor:en?"#a7f3d0":"#c7d2fe"})]}),(0,a.jsxs)("linearGradient",{id:"kc2",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"0%",stopColor:en?"#f0fdf4":"#f5f3ff"}),(0,a.jsx)("stop",{offset:"100%",stopColor:en?"#d1fae5":"#e0e7ff"})]}),(0,a.jsxs)("filter",{id:"kglow",children:[(0,a.jsx)("feGaussianBlur",{stdDeviation:"1.5",result:"b"}),(0,a.jsxs)("feMerge",{children:[(0,a.jsx)("feMergeNode",{in:"b"}),(0,a.jsx)("feMergeNode",{in:"SourceGraphic"})]})]})]}),(0,a.jsxs)("g",{filter:"url(#kglow)",children:[(0,a.jsx)("rect",{x:"7",y:"10",width:"4.5",height:"12",fill:"url(#kc1)",rx:"1.5"}),(0,a.jsx)("rect",{x:"13.75",y:"7.5",width:"4.5",height:"17",fill:"url(#kc2)",rx:"1.5"}),(0,a.jsx)("rect",{x:"20.5",y:"11",width:"4.5",height:"10",fill:"url(#kc1)",rx:"1.5"})]})]})}),et&&(0,a.jsx)("span",{className:"text-[17px] font-light tracking-[0.15em] uppercase text-gradient opacity-90",children:"KANBAII"})]}),et&&(0,a.jsx)("button",{className:"w-[26px] h-[26px] flex items-center justify-center rounded-md transition-all duration-200\n ".concat(J?"text-accent bg-accent-muted":"text-text-muted bg-transparent opacity-50 hover:opacity-100 hover:bg-surface hover:text-text"),onClick:()=>$(!J),title:J?"Unpin sidebar":"Pin sidebar",children:(0,a.jsx)(c,{size:13,fill:J?"currentColor":"none",className:"transition-transform duration-300 ".concat(J?"rotate-0":"-rotate-45")})})]}),(0,a.jsx)("div",{className:"h-px flex-shrink-0 opacity-50 ".concat(et?"mx-3 my-[2px_12px_6px]":"mx-2.5 my-[2px_10px_6px]"),style:{background:"linear-gradient(90deg, transparent 10%, var(--border-glow) 50%, transparent 90%)",margin:et?"2px 12px 6px":"2px 10px 6px"}}),(0,a.jsx)("div",{className:"flex-shrink-0 px-2 py-1",children:(0,a.jsxs)("button",{className:"w-full rounded-sm border border-dashed border-border-light bg-transparent text-text-muted text-xs font-medium\n flex items-center gap-2 cursor-pointer transition-all duration-200 ease-out-expo\n hover:bg-accent-muted hover:border-accent/25 hover:text-accent\n ".concat(et?"py-2 px-2.5 justify-start":"py-2 px-0 justify-center"),onClick:()=>P(!0),children:[(0,a.jsx)(d.Z,{size:14}),et&&"New Project"]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden px-2 py-1 pb-4",children:0===ex.length&&0===eu.length&&0===ep.length?(0,a.jsx)("div",{className:"text-center text-text-muted text-body py-8 px-3 transition-opacity duration-150 ".concat(et?"opacity-100":"opacity-0"),children:"No projects yet"}):(0,a.jsxs)(a.Fragment,{children:[ex.map(e=>{let t=i===e.slug,s=C.projectSlug===e.slug&&("running"===C.status||"paused"===C.status),n=S.active&&S.projectSlug===e.slug,r=ea&&j.q.getState().planner.projectSlug===e.slug,o=s||n||r,l=function(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:{r:99,g:102,b:241}}(e.color);return(0,a.jsxs)("div",{className:"relative mb-0.5 group ".concat(U===e.slug?"z-[200]":""),children:[(0,a.jsxs)("button",{className:"w-full rounded-sm text-left flex items-center transition-all duration-200 cursor-pointer\n ".concat(et?"py-3 px-3.5 justify-start gap-3":"py-2.5 px-0 justify-center gap-0","\n ").concat(t?"bg-surface border border-border":"bg-transparent border border-transparent hover:bg-surface"),onClick:()=>er(e),children:[(0,a.jsx)("div",{className:"rounded-full flex-shrink-0 transition-all duration-400\n ".concat(et?"w-2.5 h-2.5":"w-3 h-3","\n ").concat(o?"!bg-emerald-500 animate-dot-pulse":""),style:{"--dot-r":l.r,"--dot-g":l.g,"--dot-b":l.b,...o?{}:{background:e.color,boxShadow:t?"0 0 8px ".concat(e.color,"50"):"none"}}}),et&&(0,a.jsxs)("div",{className:"flex-1 min-w-0 pr-6",children:[(0,a.jsx)("div",{className:"text-sm font-medium whitespace-nowrap overflow-hidden text-ellipsis tracking-tight\n ".concat(t?"text-text":"text-text-secondary"),children:e.title}),e.workingDir?(0,a.jsxs)("button",{className:"text-label flex items-center gap-1 mt-0.5 whitespace-nowrap overflow-hidden text-ellipsis text-text-muted hover:text-accent transition-colors duration-150",onClick:t=>ed(t,e),title:"Open folder in explorer",children:[(0,a.jsx)(x,{size:10}),e.workingDir.split(/[/\\]/).slice(-2).join("/")]}):(0,a.jsxs)("button",{className:"text-label flex items-center gap-1 mt-0.5 text-warning hover:text-accent transition-colors duration-150",onClick:t=>{t.stopPropagation(),D({slug:e.slug,current:""})},title:"Click to set project folder",children:[(0,a.jsx)(x,{size:10})," Set folder"]})]})]}),et&&(0,a.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[e.workingDir&&(0,a.jsx)("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-sm text-text-muted bg-transparent transition-all duration-150 opacity-0 group-hover:opacity-100 hover:bg-surface hover:text-accent",onClick:t=>ed(t,e),title:"Open folder",children:(0,a.jsx)(x,{size:11})}),(0,a.jsx)("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-sm text-text-muted bg-transparent transition-all duration-150 opacity-0 group-hover:opacity-100 hover:bg-surface hover:text-text-secondary",onClick:t=>{t.stopPropagation(),B(U===e.slug?null:e.slug),q(null)},children:(0,a.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,a.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})})]}),U===e.slug&&et&&(0,a.jsxs)("div",{className:"absolute right-1 top-full mt-0.5 min-w-[160px] bg-glass backdrop-blur-[12px] backdrop-saturate-[160%] border border-glass-border rounded-md shadow-elevated z-[100] py-1 overflow-hidden animate-filter-in","data-context-menu":!0,onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>{t.stopPropagation(),B(null),D({slug:e.slug,current:e.workingDir||""})},children:[(0,a.jsx)(x,{size:14})," ",e.workingDir?"Change Folder":"Set Folder"]}),e.workingDir&&(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>{t.stopPropagation(),B(null),ed(t,e)},children:[(0,a.jsx)(x,{size:14})," Open Folder"]}),(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>eo(t,e),children:[(0,a.jsx)(u,{size:14})," Archive"]}),(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 text-danger text-xs text-left transition-colors duration-100 bg-transparent hover:bg-danger-dim",onClick:t=>el(t,e),children:[(0,a.jsx)(p.Z,{size:14})," Move to Trash"]})]})]},e.id)}),eu.length>0&&et&&(0,a.jsxs)("div",{className:"mt-3 pt-2 border-t border-border/20",children:[(0,a.jsxs)("button",{className:"w-full flex items-center gap-1.5 px-2.5 py-1.5 text-[10px] font-medium uppercase tracking-wider text-text-muted/50 hover:text-text-muted transition-colors",onClick:()=>K(!O),children:[(0,a.jsx)(m.Z,{size:10,className:"transition-transform duration-200 ".concat(O?"rotate-90":"")}),(0,a.jsx)(u,{size:10}),"Archived (",eu.length,")"]}),O&&eu.map(e=>(0,a.jsxs)("div",{className:"relative mb-0.5 group opacity-50 hover:opacity-70 transition-opacity ".concat(U===e.slug?"z-[200]":""),children:[(0,a.jsxs)("button",{className:"w-full rounded-sm text-left flex items-center transition-all duration-200 cursor-pointer py-2 px-3.5 justify-start gap-3 bg-transparent border border-transparent hover:bg-surface",onClick:()=>er(e),children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:e.color}}),(0,a.jsx)("span",{className:"text-xs font-medium whitespace-nowrap overflow-hidden text-ellipsis tracking-tight text-text-secondary flex-1 min-w-0",children:e.title})]}),(0,a.jsx)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:(0,a.jsx)("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-sm text-text-muted bg-transparent transition-all duration-150 opacity-0 group-hover:opacity-100 hover:bg-surface hover:text-text-secondary",onClick:t=>{t.stopPropagation(),B(U===e.slug?null:e.slug),q(null)},children:(0,a.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,a.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})})}),U===e.slug&&(0,a.jsxs)("div",{className:"absolute right-1 top-full mt-0.5 min-w-[160px] bg-glass backdrop-blur-[12px] backdrop-saturate-[160%] border border-glass-border rounded-md shadow-elevated z-[100] py-1 overflow-hidden animate-filter-in","data-context-menu":!0,onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>ec(t,e),children:[(0,a.jsx)(h.Z,{size:14})," Unarchive"]}),(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 text-danger text-xs text-left transition-colors duration-100 bg-transparent hover:bg-danger-dim",onClick:t=>el(t,e),children:[(0,a.jsx)(p.Z,{size:14})," Move to Trash"]})]})]},e.id))]}),ep.length>0&&et&&(0,a.jsxs)("div",{className:"mt-2 pt-2 border-t border-border/20",children:[(0,a.jsxs)("button",{className:"w-full flex items-center gap-1.5 px-2.5 py-1.5 text-[10px] font-medium uppercase tracking-wider text-text-muted/50 hover:text-text-muted transition-colors",onClick:()=>G(!W),children:[(0,a.jsx)(m.Z,{size:10,className:"transition-transform duration-200 ".concat(W?"rotate-90":"")}),(0,a.jsx)(p.Z,{size:10}),"Trash (",ep.length,")"]}),W&&ep.map(e=>(0,a.jsxs)("div",{className:"relative mb-0.5 group opacity-40 hover:opacity-60 transition-opacity ".concat(U===e.slug?"z-[200]":""),children:[(0,a.jsxs)("div",{className:"w-full rounded-sm text-left flex items-center py-2 px-3.5 justify-start gap-3",children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-full flex-shrink-0 opacity-50",style:{background:e.color}}),(0,a.jsx)("span",{className:"text-xs font-medium whitespace-nowrap overflow-hidden text-ellipsis tracking-tight text-text-muted line-through flex-1 min-w-0",children:e.title})]}),(0,a.jsx)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:(0,a.jsx)("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-sm text-text-muted bg-transparent transition-all duration-150 opacity-0 group-hover:opacity-100 hover:bg-surface hover:text-text-secondary",onClick:t=>{t.stopPropagation(),B(U===e.slug?null:e.slug),q(null)},children:(0,a.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,a.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})})}),U===e.slug&&(0,a.jsxs)("div",{className:"absolute right-1 top-full mt-0.5 min-w-[160px] bg-glass backdrop-blur-[12px] backdrop-saturate-[160%] border border-glass-border rounded-md shadow-elevated z-[100] py-1 overflow-hidden animate-filter-in","data-context-menu":!0,onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>ec(t,e),children:[(0,a.jsx)(h.Z,{size:14})," Restore"]}),(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 text-xs text-left transition-colors duration-100\n ".concat(F===e.slug?"text-danger bg-danger-dim":"text-danger bg-transparent hover:bg-danger-dim"),onClick:t=>ei(t,e),children:[(0,a.jsx)(p.Z,{size:14})," ",F===e.slug?"Confirm Delete?":"Delete Permanently"]})]})]},e.id))]})]})}),(0,a.jsx)("div",{className:"border-t border-[rgba(148,163,242,0.03)] flex-shrink-0",children:(0,a.jsx)(H,{isExpanded:et})}),(0,a.jsxs)("div",{className:"border-t border-[rgba(148,163,242,0.03)] flex-shrink-0 flex items-center\n ".concat(et?"px-3 py-2.5 flex-row gap-1 justify-center":"px-0 py-3 flex-col gap-3 justify-center"),children:[(0,a.jsx)("button",{className:"inline-flex items-center justify-center w-7 h-7 rounded-sm text-text-muted transition-all duration-150 hover:text-accent hover:bg-accent-muted",onClick:()=>Z(!0),title:"Costs & Analytics",children:(0,a.jsx)(f,{size:14})}),(0,a.jsx)("button",{className:"inline-flex items-center justify-center w-7 h-7 rounded-sm text-text-muted transition-all duration-150 hover:text-text-secondary hover:bg-surface-hover",onClick:()=>I(!0),title:"Settings",children:(0,a.jsx)(b.Z,{size:14})}),(0,a.jsx)(N,{}),et&&(0,a.jsx)("span",{className:"text-data text-text-muted opacity-30 font-mono ml-auto",children:"H"})]})]}),E&&(0,a.jsx)(z,{onClose:()=>P(!1)}),R&&(0,a.jsx)(X,{currentPath:R.current,onSave:async e=>{try{await l(R.slug,{workingDir:e}),T("Folder linked","success")}catch(e){T("Failed to set folder","error")}D(null)},onClose:()=>D(null)}),_&&(0,a.jsx)(M,{onClose:()=>I(!1)}),A&&(0,a.jsx)("div",{className:"fixed inset-0 z-[200] bg-overlay backdrop-blur-[16px] backdrop-saturate-[180%] flex items-center justify-center animate-overlay-in",onClick:()=>Z(!1),children:(0,a.jsxs)("div",{className:"bg-modal border border-glass-border rounded-lg shadow-modal max-w-[800px] w-[95%] max-h-[85vh] overflow-hidden animate-spring-pop",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border",children:[(0,a.jsxs)("span",{className:"text-h2 font-semibold flex items-center gap-2",children:[(0,a.jsx)(f,{size:16})," Costs & Analytics"]}),(0,a.jsx)("button",{className:"btn-icon",onClick:()=>Z(!1),children:(0,a.jsx)("span",{className:"text-text-muted",children:"\xd7"})})]}),(0,a.jsx)("div",{className:"overflow-y-auto max-h-[calc(85vh-52px)]",children:(0,a.jsx)(L,{projectSlug:i||void 0})})]})})]})}function X(e){let{currentPath:t,onSave:s,onClose:r}=e,[o,l]=(0,n.useState)(t),i=(0,n.useRef)(null);return(0,n.useEffect)(()=>{var e,t;null===(e=i.current)||void 0===e||e.focus(),null===(t=i.current)||void 0===t||t.select()},[]),(0,a.jsx)("div",{className:"fixed inset-0 z-[200] bg-overlay backdrop-blur-[16px] backdrop-saturate-[180%] flex items-center justify-center animate-overlay-in",onClick:r,children:(0,a.jsxs)("div",{className:"bg-modal border border-glass-border rounded-lg shadow-modal max-w-[440px] w-[92%] animate-spring-pop relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("div",{className:"absolute top-0 left-[15%] right-[15%] h-px pointer-events-none",style:{background:"linear-gradient(90deg, transparent, rgba(129, 140, 248, 0.2), transparent)"}}),(0,a.jsxs)("div",{className:"px-6 pt-5 pb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,a.jsx)(x,{size:16,className:"text-accent"}),(0,a.jsx)("span",{className:"text-h2 font-semibold tracking-tight",children:t?"Change Folder":"Link Project Folder"})]}),(0,a.jsx)("p",{className:"text-label text-text-muted leading-relaxed",children:"Set the local directory where this project's code lives. Ralph and the terminal will use this path."})]}),(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),o.trim()&&s(o.trim())},className:"px-6 pb-5 flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Folder Path"}),(0,a.jsx)("input",{ref:i,value:o,onChange:e=>l(e.target.value),placeholder:"C:\\Users\\marti\\projects\\my-app",className:"w-full font-mono text-xs",spellCheck:!1})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)("button",{type:"button",className:"btn-ghost",onClick:r,children:"Cancel"}),(0,a.jsxs)("button",{type:"submit",className:"btn-primary",disabled:!o.trim(),children:[(0,a.jsx)(x,{size:12})," ",t?"Update":"Link Folder"]})]})]})]})})}var $=s(401);let Q=(0,i.Z)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),Y=(0,i.Z)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),ee={success:{accent:"border-l-success",iconColor:"text-success",icon:(0,a.jsx)($.Z,{size:14})},error:{accent:"border-l-danger",iconColor:"text-danger",icon:(0,a.jsx)(Q,{size:14})},info:{accent:"border-l-accent",iconColor:"text-accent",icon:(0,a.jsx)(Y,{size:14})}};function et(){let{toasts:e,removeToast:t}=(0,y.E)();return 0===e.length?null:(0,a.jsx)("div",{className:"fixed bottom-4 right-4 flex flex-col gap-1.5 z-[400] pointer-events-none",children:e.map((s,n)=>{let r=ee[s.type]||ee.info,o=n<e.length-1;return(0,a.jsxs)("div",{className:"bg-glass backdrop-blur-[16px] backdrop-saturate-[160%] border border-glass-border rounded-md\n px-3.5 py-2.5 text-xs font-medium text-text shadow-elevated\n flex items-center gap-2.5 animate-toast-in pointer-events-auto min-w-[220px]\n relative overflow-hidden border-l-2 ".concat(r.accent,"\n transition-all duration-200 ease-out-expo\n ").concat(o?"scale-[0.97] opacity-80":""),children:[(0,a.jsx)("div",{className:"absolute top-0 left-[15%] right-[15%] h-px bg-gradient-to-r from-transparent via-white/[0.04] to-transparent pointer-events-none"}),(0,a.jsx)("span",{className:"flex flex-shrink-0 ".concat(r.iconColor),children:r.icon}),(0,a.jsx)("span",{className:"flex-1",children:s.message}),(0,a.jsx)("button",{className:"text-text-muted p-0.5 flex rounded-xs transition-all duration-120 ease-out-expo hover:text-text hover:bg-surface-hover",onClick:()=>t(s.id),children:(0,a.jsx)(w.Z,{size:12})})]},s.id)})})}let es=[{title:"Navigation",shortcuts:[{keys:["↑","↓"],desc:"Previous / next project"},{keys:["B"],desc:"Board view"},{keys:["C"],desc:"Console / Terminal"},{keys:["R"],desc:"Ralph / Agents"},{keys:["S"],desc:"Soul"}]},{title:"Actions",shortcuts:[{keys:["N"],desc:"New task"},{keys:["Ctrl","F"],desc:"Toggle filter bar"}]},{title:"General",shortcuts:[{keys:["H"],desc:"Show this help"},{keys:["Esc"],desc:"Close modal / go back"}]}];function ea(e){let{onClose:t}=e,{overlayProps:s}=(0,C.N)(t);return(0,a.jsx)("div",{className:"glass-overlay",...s,children:(0,a.jsxs)("div",{className:"modal-box w-[400px] max-w-[90%] p-7",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,a.jsx)("span",{className:"text-h2 font-semibold tracking-tight",children:"Keyboard Shortcuts"}),(0,a.jsx)("button",{className:"btn-icon",onClick:t,children:(0,a.jsx)(w.Z,{size:16})})]}),(0,a.jsx)("div",{className:"flex flex-col gap-[22px]",children:es.map(e=>(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mb-1",children:e.title}),e.shortcuts.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between py-1",children:[(0,a.jsx)("div",{className:"flex items-center gap-[3px]",children:e.keys.map((t,s)=>(0,a.jsxs)("span",{children:[(0,a.jsx)("kbd",{className:"inline-flex items-center justify-center min-w-[24px] h-6 px-[7px] bg-[rgba(148,163,242,0.04)] border border-[rgba(148,163,242,0.08)] border-b-2 border-b-[rgba(148,163,242,0.1)] rounded-[5px] text-[10px] font-semibold text-text font-mono",children:t}),s<e.keys.length-1&&(0,a.jsx)("span",{className:"text-xxs text-text-muted opacity-50",children:"+"})]},s))}),(0,a.jsx)("span",{className:"text-xs text-text-secondary",children:e.desc})]},e.desc))]},e.title))})]})})}let en=(0,i.Z)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),er=(0,i.Z)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),eo=(0,i.Z)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);var el=s(3468),ei=s(2222),ec=s(221),ed=s(5805),ex=s(2208),eu=s(3247),ep=s(15);function em(e){let{onClose:t,onShowCreateProject:s,onShowCreateWorkItem:r,onShowHelp:o}=e,[i,c]=(0,n.useState)(""),[u,p]=(0,n.useState)(0),m=(0,n.useRef)(null),h=(0,n.useRef)(null),f=(0,g.i)(e=>e.projects),b=(0,ep.o)(e=>e.workItems),{goToProject:j,goToWorkItem:y,setView:k,projectSlug:N,workItemSlug:w}=(0,v.U)(),{theme:C,toggleTheme:S}=l(),T=(0,n.useMemo)(()=>{let e=[];return e.push({id:"create-project",label:"Create Project",section:"Actions",icon:(0,a.jsx)(d.Z,{size:14}),action:()=>{t(),null==s||s()}}),N&&e.push({id:"create-wi",label:"Create Work Item",section:"Actions",icon:(0,a.jsx)(d.Z,{size:14}),action:()=>{t(),null==r||r()}}),e.push({id:"toggle-theme",label:"Switch to ".concat("dark"===C?"Light":"Dark"," mode"),section:"Actions",icon:"dark"===C?(0,a.jsx)(en,{size:14}):(0,a.jsx)(er,{size:14}),action:()=>{S(),t()}}),e.push({id:"keyboard-shortcuts",label:"Keyboard Shortcuts",section:"Actions",icon:(0,a.jsx)(eo,{size:14}),shortcut:"H",action:()=>{t(),null==o||o()}}),N&&(w?[{key:"board",label:"Go to Board",icon:(0,a.jsx)(el.Z,{size:14}),shortcut:"B"},{key:"ralph",label:"Go to Ralph",icon:(0,a.jsx)(ei.Z,{size:14}),shortcut:"R"}]:[{key:"work-items",label:"Go to Work Items",icon:(0,a.jsx)(el.Z,{size:14}),shortcut:"W"},{key:"console",label:"Go to Console",icon:(0,a.jsx)(ec.Z,{size:14}),shortcut:"C"},{key:"teams",label:"Go to Teams",icon:(0,a.jsx)(ed.Z,{size:14}),shortcut:"T"},{key:"soul",label:"Go to Soul",icon:(0,a.jsx)(ex.Z,{size:14}),shortcut:"S"}]).forEach(s=>{e.push({id:"nav-".concat(s.key),label:s.label,section:"Navigation",icon:s.icon,shortcut:s.shortcut,action:()=>{k(s.key),t()}})}),f.forEach(s=>{e.push({id:"project-".concat(s.slug),label:s.title,section:"Projects",icon:(0,a.jsx)(x,{size:14}),action:()=>{j(s.slug),t()}})}),N&&b.forEach(s=>{e.push({id:"wi-".concat(s.slug),label:s.title,section:"Work Items",icon:(0,a.jsx)(Z.Z,{size:14}),action:()=>{y(N,s.slug),t()}})}),e},[f,b,N,C,t,s,r,o,j,y,k,S]),z=(0,n.useMemo)(()=>{if(!i.trim())return T;let e=i.toLowerCase();return T.filter(t=>t.label.toLowerCase().includes(e)||t.section.toLowerCase().includes(e))},[T,i]);(0,n.useEffect)(()=>{p(0)},[z.length]),(0,n.useEffect)(()=>{var e;null===(e=m.current)||void 0===e||e.focus()},[]);let E=(0,n.useCallback)(e=>{"ArrowDown"===e.key?(e.preventDefault(),p(e=>Math.min(e+1,z.length-1))):"ArrowUp"===e.key?(e.preventDefault(),p(e=>Math.max(e-1,0))):"Enter"===e.key&&z[u]?(e.preventDefault(),z[u].action()):"Escape"===e.key&&t()},[z,u,t]);(0,n.useEffect)(()=>{var e;let t=null===(e=h.current)||void 0===e?void 0:e.querySelector('[data-selected="true"]');null==t||t.scrollIntoView({block:"nearest"})},[u]);let P=(0,n.useMemo)(()=>{let e=new Map;return z.forEach(t=>{let s=e.get(t.section)||[];s.push(t),e.set(t.section,s)}),e},[z]),M=-1;return(0,a.jsx)("div",{className:"fixed inset-0 z-[500] flex items-start justify-center pt-[20vh] animate-overlay-in",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(8px)"},onClick:t,children:(0,a.jsxs)("div",{className:"w-full max-w-[520px] bg-modal rounded-xl overflow-hidden shadow-modal animate-spring-pop border border-glass-border relative",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("div",{className:"absolute top-0 left-[15%] right-[15%] h-px bg-gradient-to-r from-transparent via-[rgba(129,140,248,0.2)] to-transparent pointer-events-none z-10"}),(0,a.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[(0,a.jsx)(eu.Z,{size:16,className:"text-text-muted flex-shrink-0"}),(0,a.jsx)("input",{ref:m,type:"text",value:i,onChange:e=>c(e.target.value),onKeyDown:E,placeholder:"Type a command or search...",className:"flex-1 bg-transparent border-none outline-none text-body text-text placeholder:text-text-muted p-0 shadow-none"}),(0,a.jsx)("kbd",{className:"text-data font-mono text-text-muted bg-surface px-1.5 py-0.5 rounded border border-border",children:"ESC"})]}),(0,a.jsx)("div",{ref:h,className:"max-h-[320px] overflow-y-auto py-1",children:0===z.length?(0,a.jsx)("div",{className:"px-4 py-8 text-center text-text-muted text-xs",children:"No results found"}):Array.from(P.entries()).map(e=>{let[t,s]=e;return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"px-4 pt-2 pb-1 text-xxs font-semibold text-text-muted uppercase tracking-[0.08em]",children:t}),s.map(e=>{let t=++M===u,s=M;return(0,a.jsxs)("button",{"data-selected":t,className:"w-full flex items-center gap-3 px-4 py-2 text-xs text-left transition-colors duration-75\n ".concat(t?"bg-accent-muted text-text":"text-text-secondary hover:bg-surface-hover hover:text-text"),onClick:e.action,onMouseEnter:()=>p(s),children:[(0,a.jsx)("span",{className:"flex-shrink-0 ".concat(t?"text-accent":"text-text-muted"),children:e.icon}),(0,a.jsx)("span",{className:"flex-1 truncate",children:e.label}),e.shortcut&&(0,a.jsx)("kbd",{className:"text-data font-mono text-text-muted bg-surface px-1.5 py-0.5 rounded border border-border",children:e.shortcut})]},e.id)})]},t)})})]})})}var eh=s(4822);let ef=(0,i.Z)("skip-forward",[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]]);var eb=s(1094),eg=s(4743);let ev=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function ej(){let e=(0,j.q)(e=>e.escalation),t=(0,y.E)(e=>e.addToast),[s,r]=(0,n.useState)(""),[o,l]=(0,n.useState)(!1),i=(0,n.useRef)(null);if((0,n.useEffect)(()=>{e&&(r(""),setTimeout(()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.focus()},100),"undefined"!=typeof Notification&&("granted"===Notification.permission?new Notification("KANBAII — ".concat("ralph"===e.source?"Ralph":"Teams"," needs input"),{body:e.question.slice(0,120),icon:"/favicon.svg"}):"denied"!==Notification.permission&&Notification.requestPermission()))},[e]),!e||"planner"===e.source)return null;let c=async a=>{let n=a||s.trim();if(n&&!o){l(!0);try{await fetch("".concat(ev,"/api/escalation/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,response:n})}),t("Response sent to Claude","success")}catch(e){t("Failed to send response","error")}l(!1)}},d="ralph"===e.source,x=d?eh.Z:ed.Z,u=d?"Ralph":"Teams",p=function(e){try{let t=JSON.parse(e);if(t.questions&&Array.isArray(t.questions)&&t.questions.length>0){let s=t.questions[0];return{question:s.question||s.header||e,options:(s.options||[]).map(e=>({label:"string"==typeof e?e:e.label||e.text||"",description:e.description}))}}if(t.question)return{question:t.question,options:(t.options||[]).map(e=>({label:"string"==typeof e?e:e.label||""}))}}catch(e){}return{question:e,options:[]}}(e.question),m=p.question,h=p.options.length>0?p.options:e.options;return(0,a.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center animate-overlay-in",style:{background:"rgba(3, 3, 8, 0.85)",backdropFilter:"blur(20px) saturate(180%)"},children:(0,a.jsxs)("div",{className:"max-w-[520px] w-[94%] animate-spring-pop relative",children:[(0,a.jsx)("div",{className:"absolute -inset-px rounded-lg animate-breathe",style:{background:d?"linear-gradient(135deg, rgba(99,102,241,0.3), rgba(129,140,248,0.1), rgba(99,102,241,0.3))":"linear-gradient(135deg, rgba(16,185,129,0.3), rgba(52,211,153,0.1), rgba(16,185,129,0.3))"}}),(0,a.jsxs)("div",{className:"relative bg-modal border border-glass-border rounded-lg shadow-modal overflow-hidden",children:[(0,a.jsx)("div",{className:"absolute top-0 left-[10%] right-[10%] h-px pointer-events-none",style:{background:d?"linear-gradient(90deg, transparent, rgba(99,102,241,0.4), transparent)":"linear-gradient(90deg, transparent, rgba(52,211,153,0.4), transparent)"}}),(0,a.jsxs)("div",{className:"flex items-center gap-3 px-6 pt-5 pb-3",children:[(0,a.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center animate-breathe\n ".concat(d?"bg-accent-muted border border-accent/20":"bg-success-dim border border-success/20"),children:(0,a.jsx)(x,{size:16,className:d?"text-accent":"text-success"})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-sm font-semibold text-text tracking-tight",children:[u," needs your input"]}),e.taskTitle&&(0,a.jsxs)("div",{className:"text-xxs text-text-muted font-mono mt-0.5",children:["Task: ",e.taskTitle]})]})]}),(0,a.jsx)("div",{className:"mx-6 mb-4 p-3 bg-bg border border-border rounded-md shadow-inset",children:(0,a.jsx)("div",{className:"text-sm text-text leading-relaxed",children:m})}),h.length>0&&(0,a.jsx)("div",{className:"mx-6 mb-3 flex flex-col gap-1.5",children:h.map((e,t)=>(0,a.jsxs)("button",{className:"flex flex-col gap-0.5 px-3 py-2.5 text-left rounded-sm border border-border transition-all duration-150 hover:border-accent hover:bg-accent-muted group",onClick:()=>c("string"==typeof e?e:e.label),disabled:o,children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text group-hover:text-accent transition-colors",children:"string"==typeof e?e:e.label}),"string"!=typeof e&&e.description&&(0,a.jsx)("span",{className:"text-xxs text-text-muted leading-snug",children:e.description})]},t))}),(0,a.jsxs)("div",{className:"px-6 pb-5",children:[(0,a.jsx)("textarea",{ref:i,value:s,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),c())},placeholder:"Type your response... (Enter to send)",rows:2,className:"w-full resize-none text-xs",disabled:o}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-3",children:[(0,a.jsxs)("button",{className:"inline-flex items-center gap-1.5 text-xxs text-text-muted font-mono px-3 py-1.5 rounded-sm border border-border transition-all duration-150 hover:text-text-secondary hover:bg-surface-hover",onClick:()=>c("yes"),disabled:o,children:[(0,a.jsx)(ef,{size:11})," Skip (yes)"]}),(0,a.jsxs)("button",{className:"inline-flex items-center gap-1.5 text-xxs text-danger font-mono px-3 py-1.5 rounded-sm border border-danger/20 transition-all duration-150 hover:bg-danger-dim",onClick:async()=>{await fetch(d?"".concat(ev,"/api/ralph/stop"):"".concat(ev,"/api/teams/stop"),{method:"POST"}),c("STOP"),t("".concat(u," stopped"),"info")},disabled:o,children:[(0,a.jsx)(eb.Z,{size:11})," Stop ",u]}),(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsxs)("button",{className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-white text-xs font-semibold rounded-sm\n bg-gradient-to-br ".concat(d?"from-indigo-600 to-indigo-400":"from-emerald-600 to-emerald-400","\n relative overflow-hidden\n before:absolute before:inset-0 before:bg-gradient-to-b before:from-white/15 before:to-transparent before:pointer-events-none\n transition-all duration-150 hover:shadow-glow-accent hover:-translate-y-px disabled:opacity-40"),onClick:()=>c(),disabled:!s.trim()||o,children:[o?(0,a.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-white/20 border-t-white rounded-full animate-spin"}):(0,a.jsx)(eg.Z,{size:12}),"Send"]})]})]})]})]})})}function ey(e){let{children:t}=e;!function(){let e=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(e.current)return;e.current=!0;let t=(0,B.h)(),s=j.q.getState,a=g.i.getState,n=ep.o.getState;return t.on("project:updated",e=>{let{project:t}=e;return a().onProjectUpdated(t)}),t.on("project:deleted",e=>{let{slug:t}=e;return a().onProjectDeleted(t)}),t.on("workItem:updated",e=>{let{projectSlug:t,workItem:s}=e;return n().onWorkItemUpdated(t,s)}),t.on("workItem:deleted",e=>{let{projectSlug:t,workItemId:s}=e;return n().onWorkItemDeleted(t,s)}),t.on("ralph:started",e=>s().onRalphStarted(e)),t.on("ralph:progress",e=>s().onRalphProgress(e)),t.on("ralph:output",e=>s().onRalphOutput(e)),t.on("ralph:completed",e=>s().onRalphCompleted(e)),t.on("ralph:error",e=>s().onRalphError(e)),t.on("ralph:input-needed",e=>s().onRalphInputNeeded(e)),t.on("live:started",e=>s().onTeamsStarted(e)),t.on("live:worker-assigned",e=>s().onTeamsWorkerAssigned(e)),t.on("live:worker-completed",e=>s().onTeamsWorkerCompleted(e)),t.on("live:metrics",e=>s().onTeamsMetrics(e)),t.on("live:output",e=>s().onTeamsOutput(e)),t.on("live:stopped",e=>s().onTeamsStopped(e)),t.on("teams:input-needed",e=>s().onTeamsInputNeeded(e)),t.on("coordinator:thinking",e=>s().onCoordinatorThinking(e)),t.on("coordinator:tool_call",e=>s().onCoordinatorToolCall(e)),t.on("coordinator:completed",e=>s().onCoordinatorCompleted(e)),t.on("escalation:created",e=>{if("planner"===e.source){s().onPlannerEscalation({id:e.id,source:"planner",taskId:e.taskId||"planner",taskTitle:e.taskTitle||"AI Planner",question:e.question,options:e.options||[],timeoutMs:e.timeoutMs||18e5});return}s().onEscalationCreated(e)}),t.on("escalation:responded",e=>{s().planner.escalation?s().onPlannerEscalationResponded((null==e?void 0:e.response)||"responded"):s().onEscalationResponded()}),t.on("escalation:timeout",()=>{s().planner.escalation?s().onPlannerEscalationResponded("(timed out)"):s().onEscalationTimeout()}),t.on("planner:started",e=>s().onPlannerStarted(e)),t.on("planner:message",e=>s().onPlannerMessage(e)),t.on("planner:item-discovered",e=>s().onPlannerItemDiscovered(e)),t.on("planner:item-updated",e=>s().onPlannerItemUpdated(e)),t.on("planner:escalation",e=>s().onPlannerEscalation(e)),t.on("planner:item-approved",e=>s().onPlannerItemApproved(e)),t.on("planner:stopped",()=>s().onPlannerStopped()),t.on("terminal:output",e=>{let t=v.U.getState().projectSlug;e.projectSlug&&e.projectSlug!==t||(s().appendTerminalOutput(e.text),s().setTerminalStatus("running"))}),t.on("terminal:closed",e=>{let t=v.U.getState().projectSlug;null!=e&&e.projectSlug&&e.projectSlug!==t||s().setTerminalStatus("idle")}),t.on("terminal:error",e=>{let t=v.U.getState().projectSlug;null!=e&&e.projectSlug&&e.projectSlug!==t||(s().appendTerminalOutput("ERROR: ".concat(e.message)),s().setTerminalStatus("error"))}),s().rehydrate(),t.on("connect",()=>s().rehydrate()),()=>{(0,B.l)(),e.current=!1}},[])}();let[s,r]=(0,n.useState)(!1),[o,l]=(0,n.useState)(!1),i=(0,n.useCallback)(()=>r(e=>!e),[]),c=(0,n.useCallback)(()=>r(!1),[]),d=(0,n.useCallback)(()=>l(e=>!e),[]),x=(0,n.useCallback)(()=>l(!1),[]);return!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{projectSlug:t,workItemSlug:s,setView:a,goToProject:r}=(0,v.U)(),o=(0,g.i)(e=>e.projects);(0,n.useEffect)(()=>{let n=n=>{var l,i,c,d,x;let u=n.target.tagName;if("INPUT"!==u&&"TEXTAREA"!==u&&"SELECT"!==u&&!n.target.isContentEditable){if((n.ctrlKey||n.metaKey)&&"k"===n.key){n.preventDefault(),null===(l=e.onToggleCommandPalette)||void 0===l||l.call(e);return}if((n.ctrlKey||n.metaKey)&&"f"===n.key){n.preventDefault(),null===(i=e.onToggleFilter)||void 0===i||i.call(e);return}if(!n.ctrlKey&&!n.metaKey&&!n.altKey)switch(n.key.toLowerCase()){case"w":t&&!s&&a("work-items");break;case"c":t&&!s&&a("console");break;case"t":t&&!s&&a("teams");break;case"s":t&&!s&&a("soul");break;case"b":s&&a("board");break;case"r":s&&a("ralph");break;case"n":null===(c=e.onNewTask)||void 0===c||c.call(e);break;case"h":null===(d=e.onToggleHelp)||void 0===d||d.call(e);break;case"escape":null===(x=e.onEscape)||void 0===x||x.call(e);break;case"arrowup":{n.preventDefault();let e=o.findIndex(e=>e.slug===t);e>0&&r(o[e-1].slug);break}case"arrowdown":{n.preventDefault();let e=o.findIndex(e=>e.slug===t);e<o.length-1&&r(o[e+1].slug)}}}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t,s,o,a,r,e])}({onToggleHelp:i,onToggleCommandPalette:d,onEscape:()=>{o?x():c()}}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex h-screen w-screen overflow-hidden",children:[(0,a.jsx)(J,{}),(0,a.jsx)("div",{className:"w-px flex-shrink-0 bg-gradient-to-b from-transparent via-border-glow to-transparent"}),(0,a.jsx)("main",{className:"flex-1 overflow-hidden flex flex-col surface-gradient",children:t})]}),(0,a.jsx)(et,{}),(0,a.jsx)(ej,{}),s&&(0,a.jsx)(ea,{onClose:c}),o&&(0,a.jsx)(em,{onClose:x,onShowHelp:()=>{x(),i()}})]})}function ek(e){let{children:t}=e;return(0,a.jsx)(o,{children:(0,a.jsx)(ey,{children:t})})}},7960:function(){}},function(e){e.O(0,[587,184,23,971,117,744],function(){return e(e.s=4732)}),_N_E=e.O()}]);
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/735f5195647c6b5c.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-5c1d03322d6ecf76.js"/><script src="/_next/static/chunks/fd9d1056-1f1f859026f5f0fa.js" async=""></script><script src="/_next/static/chunks/117-749dc8b5f56031ab.js" async=""></script><script src="/_next/static/chunks/main-app-2f313c3206a6e049.js" async=""></script><script src="/_next/static/chunks/184-15d72b1991c86ab9.js" async=""></script><script src="/_next/static/chunks/759-3d8fc7952548ec08.js" async=""></script><script src="/_next/static/chunks/23-4a72ba4a90f008a6.js" async=""></script><script src="/_next/static/chunks/app/page-7b3ca7e8c5d980ab.js" async=""></script><script src="/_next/static/chunks/app/layout-ccc8d24485f54bd6.js" async=""></script><meta name="theme-color" content="#6366f1"/><title>KANBAII</title><meta name="description" content="Structure for your ideas. AI to move them forward."/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.svg" type="image/svg+xml"/><link rel="icon" href="/favicon-16x16.svg" sizes="16x16" type="image/svg+xml"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><script src="/_next/static/chunks/webpack-5c1d03322d6ecf76.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/css/735f5195647c6b5c.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[2846,[],\"\"]\n4:I[9107,[],\"ClientPageRoot\"]\n5:I[2039,[\"184\",\"static/chunks/184-15d72b1991c86ab9.js\",\"759\",\"static/chunks/759-3d8fc7952548ec08.js\",\"23\",\"static/chunks/23-4a72ba4a90f008a6.js\",\"931\",\"static/chunks/app/page-7b3ca7e8c5d980ab.js\"],\"default\",1]\n6:I[792,[\"184\",\"static/chunks/184-15d72b1991c86ab9.js\",\"23\",\"static/chunks/23-4a72ba4a90f008a6.js\",\"185\",\"static/chunks/app/layout-ccc8d24485f54bd6.js\"],\"AppShell\"]\n7:I[4707,[],\"\"]\n8:I[6423,[],\"\"]\na:I[1060,[],\"\"]\nb:[]\n0:[\"$\",\"$L2\",null,{\"buildId\":\"k3eq3Vr89K2vwr7X2Gdl2\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"\"],\"initialTree\":[\"\",{\"children\":[\"__PAGE__\",{}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[\"$\",\"$L4\",null,{\"props\":{\"params\":{},\"searchParams\":{}},\"Component\":\"$5\"}],null],null],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/735f5195647c6b5c.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L6\",null,{\"children\":[\"$\",\"$L7\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L8\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"pad"])</script><script>self.__next_f.push([1,"ding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[null,\"$L9\"],\"globalErrorComponent\":\"$a\",\"missingSlots\":\"$Wb\"}]\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"name\":\"theme-color\",\"content\":\"#6366f1\"}],[\"$\",\"meta\",\"2\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"3\",{\"children\":\"KANBAII\"}],[\"$\",\"meta\",\"4\",{\"name\":\"description\",\"content\":\"Structure for your ideas. AI to move them forward.\"}],[\"$\",\"link\",\"5\",{\"rel\":\"manifest\",\"href\":\"/manifest.json\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"link\",\"6\",{\"rel\":\"icon\",\"href\":\"/favicon.svg\",\"type\":\"image/svg+xml\"}],[\"$\",\"link\",\"7\",{\"rel\":\"icon\",\"href\":\"/favicon-16x16.svg\",\"sizes\":\"16x16\",\"type\":\"image/svg+xml\"}]]\n3:null\n"])</script></body></html>
1
+ <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/735f5195647c6b5c.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-5c1d03322d6ecf76.js"/><script src="/_next/static/chunks/fd9d1056-1f1f859026f5f0fa.js" async=""></script><script src="/_next/static/chunks/117-749dc8b5f56031ab.js" async=""></script><script src="/_next/static/chunks/main-app-2f313c3206a6e049.js" async=""></script><script src="/_next/static/chunks/184-15d72b1991c86ab9.js" async=""></script><script src="/_next/static/chunks/759-3d8fc7952548ec08.js" async=""></script><script src="/_next/static/chunks/23-4a72ba4a90f008a6.js" async=""></script><script src="/_next/static/chunks/app/page-7b3ca7e8c5d980ab.js" async=""></script><script src="/_next/static/chunks/app/layout-4b8075f77af9a0e2.js" async=""></script><meta name="theme-color" content="#6366f1"/><title>KANBAII</title><meta name="description" content="Structure for your ideas. AI to move them forward."/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.svg" type="image/svg+xml"/><link rel="icon" href="/favicon-16x16.svg" sizes="16x16" type="image/svg+xml"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><script src="/_next/static/chunks/webpack-5c1d03322d6ecf76.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/css/735f5195647c6b5c.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[2846,[],\"\"]\n4:I[9107,[],\"ClientPageRoot\"]\n5:I[2039,[\"184\",\"static/chunks/184-15d72b1991c86ab9.js\",\"759\",\"static/chunks/759-3d8fc7952548ec08.js\",\"23\",\"static/chunks/23-4a72ba4a90f008a6.js\",\"931\",\"static/chunks/app/page-7b3ca7e8c5d980ab.js\"],\"default\",1]\n6:I[792,[\"184\",\"static/chunks/184-15d72b1991c86ab9.js\",\"23\",\"static/chunks/23-4a72ba4a90f008a6.js\",\"185\",\"static/chunks/app/layout-4b8075f77af9a0e2.js\"],\"AppShell\"]\n7:I[4707,[],\"\"]\n8:I[6423,[],\"\"]\na:I[1060,[],\"\"]\nb:[]\n0:[\"$\",\"$L2\",null,{\"buildId\":\"g0V9ldKabJaJ3dsXFDa0k\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"\"],\"initialTree\":[\"\",{\"children\":[\"__PAGE__\",{}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[\"$\",\"$L4\",null,{\"props\":{\"params\":{},\"searchParams\":{}},\"Component\":\"$5\"}],null],null],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/735f5195647c6b5c.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L6\",null,{\"children\":[\"$\",\"$L7\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L8\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"pad"])</script><script>self.__next_f.push([1,"ding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[null,\"$L9\"],\"globalErrorComponent\":\"$a\",\"missingSlots\":\"$Wb\"}]\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"name\":\"theme-color\",\"content\":\"#6366f1\"}],[\"$\",\"meta\",\"2\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"3\",{\"children\":\"KANBAII\"}],[\"$\",\"meta\",\"4\",{\"name\":\"description\",\"content\":\"Structure for your ideas. AI to move them forward.\"}],[\"$\",\"link\",\"5\",{\"rel\":\"manifest\",\"href\":\"/manifest.json\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"link\",\"6\",{\"rel\":\"icon\",\"href\":\"/favicon.svg\",\"type\":\"image/svg+xml\"}],[\"$\",\"link\",\"7\",{\"rel\":\"icon\",\"href\":\"/favicon-16x16.svg\",\"sizes\":\"16x16\",\"type\":\"image/svg+xml\"}]]\n3:null\n"])</script></body></html>
@@ -1,8 +1,8 @@
1
1
  2:I[9107,[],"ClientPageRoot"]
2
2
  3:I[2039,["184","static/chunks/184-15d72b1991c86ab9.js","759","static/chunks/759-3d8fc7952548ec08.js","23","static/chunks/23-4a72ba4a90f008a6.js","931","static/chunks/app/page-7b3ca7e8c5d980ab.js"],"default",1]
3
- 4:I[792,["184","static/chunks/184-15d72b1991c86ab9.js","23","static/chunks/23-4a72ba4a90f008a6.js","185","static/chunks/app/layout-ccc8d24485f54bd6.js"],"AppShell"]
3
+ 4:I[792,["184","static/chunks/184-15d72b1991c86ab9.js","23","static/chunks/23-4a72ba4a90f008a6.js","185","static/chunks/app/layout-4b8075f77af9a0e2.js"],"AppShell"]
4
4
  5:I[4707,[],""]
5
5
  6:I[6423,[],""]
6
- 0:["k3eq3Vr89K2vwr7X2Gdl2",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/735f5195647c6b5c.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L4",null,{"children":["$","$L5",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L6",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]}]],null],null],["$L7",null]]]]
6
+ 0:["g0V9ldKabJaJ3dsXFDa0k",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{"props":{"params":{},"searchParams":{}},"Component":"$3"}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/735f5195647c6b5c.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L4",null,{"children":["$","$L5",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L6",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]}]],null],null],["$L7",null]]]]
7
7
  7:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"name":"theme-color","content":"#6366f1"}],["$","meta","2",{"charSet":"utf-8"}],["$","title","3",{"children":"KANBAII"}],["$","meta","4",{"name":"description","content":"Structure for your ideas. AI to move them forward."}],["$","link","5",{"rel":"manifest","href":"/manifest.json","crossOrigin":"use-credentials"}],["$","link","6",{"rel":"icon","href":"/favicon.svg","type":"image/svg+xml"}],["$","link","7",{"rel":"icon","href":"/favicon-16x16.svg","sizes":"16x16","type":"image/svg+xml"}]]
8
8
  1:null
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.createApp = createApp;
40
40
  const express_1 = __importDefault(require("express"));
41
+ const helmet_1 = __importDefault(require("helmet"));
41
42
  const cors_1 = __importDefault(require("cors"));
42
43
  const http_1 = require("http");
43
44
  const socket_io_1 = require("socket.io");
@@ -68,6 +69,8 @@ const voice_1 = __importDefault(require("./routes/voice"));
68
69
  const escalation_1 = __importDefault(require("./routes/escalation"));
69
70
  const planner_1 = __importDefault(require("./routes/planner"));
70
71
  const authMiddleware_1 = require("./lib/authMiddleware");
72
+ const authService_1 = require("./services/authService");
73
+ const validateSlug_1 = require("./lib/validateSlug");
71
74
  const requestLogger_1 = require("./lib/requestLogger");
72
75
  const rateLimiter_1 = require("./lib/rateLimiter");
73
76
  const claudeUsage_1 = require("./services/claudeUsage");
@@ -88,7 +91,37 @@ function createApp() {
88
91
  serveClient: false,
89
92
  });
90
93
  (0, typedEmit_1.setIO)(io);
91
- // Middleware
94
+ // Socket.IO auth — validates JWT when auth is enabled
95
+ io.use((socket, next) => {
96
+ if (!(0, authService_1.isAuthEnabled)())
97
+ return next();
98
+ const token = socket.handshake.auth?.token
99
+ || socket.handshake.headers?.authorization?.replace('Bearer ', '');
100
+ if (!token)
101
+ return next(new Error('Authentication required'));
102
+ const payload = (0, authService_1.verifyToken)(token);
103
+ if (!payload)
104
+ return next(new Error('Invalid or expired token'));
105
+ socket.userId = payload.userId;
106
+ socket.username = payload.username;
107
+ next();
108
+ });
109
+ // Middleware — security headers first
110
+ app.use((0, helmet_1.default)({
111
+ contentSecurityPolicy: {
112
+ directives: {
113
+ defaultSrc: ["'self'"],
114
+ scriptSrc: ["'self'", "'unsafe-inline'", "'unsafe-eval'"],
115
+ styleSrc: ["'self'", "'unsafe-inline'"],
116
+ imgSrc: ["'self'", "data:", "blob:"],
117
+ connectSrc: ["'self'", "ws:", "wss:", `http://localhost:${PORT}`, "http://localhost:3000"],
118
+ fontSrc: ["'self'", "data:"],
119
+ frameSrc: ["'none'"],
120
+ },
121
+ },
122
+ crossOriginEmbedderPolicy: false,
123
+ xFrameOptions: { action: 'deny' },
124
+ }));
92
125
  app.use((0, cors_1.default)({ origin: allowedOrigins }));
93
126
  app.use(express_1.default.json({ limit: '2mb' }));
94
127
  app.use(requestLogger_1.requestLogger);
@@ -100,23 +133,29 @@ function createApp() {
100
133
  app.use('/api/ralph/start', rateLimiter_1.executionLimiter);
101
134
  app.use('/api/teams/start', rateLimiter_1.executionLimiter);
102
135
  app.use('/api/voice', rateLimiter_1.voiceLimiter);
103
- // Health
104
- app.get('/api/health', (_req, res) => {
105
- const mem = process.memoryUsage();
106
- res.json({
107
- ok: true,
108
- version: require('../../package.json').version,
109
- uptime: Math.floor(process.uptime()),
110
- memory: {
111
- heapUsedMB: Math.round(mem.heapUsed / 1024 / 1024),
112
- heapTotalMB: Math.round(mem.heapTotal / 1024 / 1024),
113
- rssMB: Math.round(mem.rss / 1024 / 1024),
114
- },
115
- node: process.version,
116
- platform: process.platform,
117
- cwd: process.cwd(),
118
- });
136
+ // Health — full diagnostics only when authenticated or auth disabled
137
+ app.get('/api/health', (req, res) => {
138
+ const version = require('../../package.json').version;
139
+ const basic = { ok: true, version };
140
+ if (!(0, authService_1.isAuthEnabled)() || req.userId) {
141
+ const mem = process.memoryUsage();
142
+ return res.json({
143
+ ...basic,
144
+ uptime: Math.floor(process.uptime()),
145
+ memory: {
146
+ heapUsedMB: Math.round(mem.heapUsed / 1024 / 1024),
147
+ heapTotalMB: Math.round(mem.heapTotal / 1024 / 1024),
148
+ rssMB: Math.round(mem.rss / 1024 / 1024),
149
+ },
150
+ node: process.version,
151
+ platform: process.platform,
152
+ });
153
+ }
154
+ res.json(basic);
119
155
  });
156
+ // Slug parameter validation
157
+ app.param('slug', (req, _res, next, _val) => (0, validateSlug_1.validateSlugParam)('slug')(req, _res, next));
158
+ app.param('wiId', (req, _res, next, _val) => (0, validateSlug_1.validateSlugParam)('wiId')(req, _res, next));
120
159
  // API Routes
121
160
  app.use('/api/projects', projects_1.default);
122
161
  app.use('/api/projects/:slug/work-items', workItems_1.default);
@@ -5,10 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.voiceLimiter = exports.executionLimiter = exports.authLimiter = exports.apiLimiter = void 0;
7
7
  const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
8
+ const isTest = process.env.NODE_ENV === 'test';
8
9
  // General API: 100 requests per minute
9
10
  exports.apiLimiter = (0, express_rate_limit_1.default)({
10
11
  windowMs: 60 * 1000,
11
- max: 100,
12
+ max: isTest ? 10000 : 100,
12
13
  standardHeaders: true,
13
14
  legacyHeaders: false,
14
15
  message: { ok: false, error: 'Too many requests, try again later' },
@@ -16,7 +17,7 @@ exports.apiLimiter = (0, express_rate_limit_1.default)({
16
17
  // Auth endpoints: 10 attempts per 15 minutes
17
18
  exports.authLimiter = (0, express_rate_limit_1.default)({
18
19
  windowMs: 15 * 60 * 1000,
19
- max: 10,
20
+ max: isTest ? 10000 : 10,
20
21
  message: { ok: false, error: 'Too many login attempts' },
21
22
  });
22
23
  // Execution endpoints (ralph/teams/start): 5 per minute
@@ -11,8 +11,8 @@ exports.ClaudeModelSchema = zod_1.z.enum(['opus', 'sonnet', 'haiku']);
11
11
  exports.ProjectStatusSchema = zod_1.z.enum(['active', 'archived', 'deleted']);
12
12
  // --- Plan ---
13
13
  exports.PlanSchema = zod_1.z.object({
14
- prompt: zod_1.z.string().optional(),
15
- content: zod_1.z.string().optional(),
14
+ prompt: zod_1.z.string().max(50000).optional(),
15
+ content: zod_1.z.string().max(100000).optional(),
16
16
  status: zod_1.z.enum(['empty', 'draft', 'approved']),
17
17
  generatedBy: zod_1.z.enum(['claude', 'manual']).optional(),
18
18
  createdAt: zod_1.z.string().optional(),
@@ -28,8 +28,8 @@ exports.TaskSummarySchema = zod_1.z.object({
28
28
  });
29
29
  exports.TaskSchema = zod_1.z.object({
30
30
  id: zod_1.z.string().min(1),
31
- title: zod_1.z.string().min(1),
32
- description: zod_1.z.string(),
31
+ title: zod_1.z.string().min(1).max(200),
32
+ description: zod_1.z.string().max(5000),
33
33
  completed: zod_1.z.boolean(),
34
34
  model: exports.ClaudeModelSchema,
35
35
  priority: exports.PrioritySchema.optional(),
@@ -41,7 +41,7 @@ exports.TaskSchema = zod_1.z.object({
41
41
  updatedAt: zod_1.z.string().optional(),
42
42
  completedAt: zod_1.z.string().optional(),
43
43
  previousColumn: zod_1.z.string().optional(),
44
- output: zod_1.z.string().optional(),
44
+ output: zod_1.z.string().max(100000).optional(),
45
45
  summary: exports.TaskSummarySchema.optional(),
46
46
  });
47
47
  // --- Work Item ---
@@ -55,7 +55,7 @@ exports.ColumnsSchema = zod_1.z.object({
55
55
  exports.WorkItemSchema = zod_1.z.object({
56
56
  id: zod_1.z.string().min(1),
57
57
  slug: zod_1.z.string().min(1),
58
- title: zod_1.z.string().min(1),
58
+ title: zod_1.z.string().min(1).max(200),
59
59
  category: exports.WorkItemCategorySchema,
60
60
  status: exports.WorkItemStatusSchema,
61
61
  linkedWorkItem: zod_1.z.string().nullable().optional(),
@@ -68,8 +68,8 @@ exports.WorkItemSchema = zod_1.z.object({
68
68
  exports.ProjectSchema = zod_1.z.object({
69
69
  id: zod_1.z.string().min(1),
70
70
  slug: zod_1.z.string().min(1),
71
- title: zod_1.z.string().min(1),
72
- description: zod_1.z.string().optional(),
71
+ title: zod_1.z.string().min(1).max(200),
72
+ description: zod_1.z.string().max(5000).optional(),
73
73
  color: zod_1.z.string().regex(/^#[0-9a-fA-F]{6}$/, 'Invalid hex color'),
74
74
  workingDir: zod_1.z.string().optional(),
75
75
  status: exports.ProjectStatusSchema,
@@ -127,7 +127,7 @@ exports.UpdateTaskDto = zod_1.z.object({
127
127
  agent: zod_1.z.string().nullable().optional(),
128
128
  depends: zod_1.z.array(zod_1.z.string()).optional(),
129
129
  due: zod_1.z.string().optional(),
130
- output: zod_1.z.string().optional(),
130
+ output: zod_1.z.string().max(100000).optional(),
131
131
  summary: exports.TaskSummarySchema.optional(),
132
132
  });
133
133
  exports.MoveTaskDto = zod_1.z.object({
@@ -9,7 +9,15 @@ exports.isEncrypted = isEncrypted;
9
9
  const crypto_1 = __importDefault(require("crypto"));
10
10
  const os_1 = __importDefault(require("os"));
11
11
  const ALGORITHM = 'aes-256-gcm';
12
+ if (!process.env.KANBAII_SECRET) {
13
+ console.warn('[kanbaii] \u26a0 KANBAII_SECRET not set \u2014 using machine-specific encryption key. Set KANBAII_SECRET env var for portable encryption.');
14
+ }
12
15
  function deriveKey() {
16
+ const envSecret = process.env.KANBAII_SECRET;
17
+ if (envSecret) {
18
+ return crypto_1.default.scryptSync(envSecret, 'kanbaii-env-salt', 32);
19
+ }
20
+ // Fallback: machine-specific key
13
21
  const material = [os_1.default.hostname(), os_1.default.homedir(), 'kanbaii-v1'].join(':');
14
22
  return crypto_1.default.scryptSync(material, 'kanbaii-salt', 32);
15
23
  }
@@ -0,0 +1,6 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ /**
3
+ * Express param middleware — validates that a route param is a valid slug.
4
+ * Rejects path traversal, special chars, and anything not lowercase-alphanumeric-hyphen.
5
+ */
6
+ export declare function validateSlugParam(paramName: string): (req: Request, res: Response, next: NextFunction) => void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSlugParam = validateSlugParam;
4
+ const SLUG_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/;
5
+ /**
6
+ * Express param middleware — validates that a route param is a valid slug.
7
+ * Rejects path traversal, special chars, and anything not lowercase-alphanumeric-hyphen.
8
+ */
9
+ function validateSlugParam(paramName) {
10
+ return (req, res, next) => {
11
+ const value = req.params[paramName];
12
+ if (!value || value.length > 100 || !SLUG_PATTERN.test(value)) {
13
+ res.status(400).json({ ok: false, error: `Invalid ${paramName}: must be lowercase alphanumeric with hyphens` });
14
+ return;
15
+ }
16
+ next();
17
+ };
18
+ }
@@ -52,8 +52,8 @@ router.post('/register', (req, res) => {
52
52
  if (!username || !password) {
53
53
  return res.status(400).json({ ok: false, error: 'username and password required' });
54
54
  }
55
- if (password.length < 4) {
56
- return res.status(400).json({ ok: false, error: 'Password must be at least 4 characters' });
55
+ if (password.length < 8) {
56
+ return res.status(400).json({ ok: false, error: 'Password must be at least 8 characters' });
57
57
  }
58
58
  try {
59
59
  const result = authService.register(username, password);
@@ -36,6 +36,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const express_1 = require("express");
37
37
  const mcpConfig = __importStar(require("../services/mcpConfig"));
38
38
  const router = (0, express_1.Router)();
39
+ // Command whitelist — only known safe executables
40
+ const ALLOWED_COMMANDS = new Set([
41
+ 'node', 'npx', 'cmd', 'cmd.exe', 'python', 'python3', 'uvx', 'pip', 'pipx',
42
+ ]);
43
+ // Shell metacharacter pattern — reject args that could enable injection
44
+ const SHELL_META = /[;&|`$(){}!<>\\"\n\r]/;
45
+ function validateMcpCommand(command, args) {
46
+ const cmdBase = (command.split(/[\\/]/).pop() || command).toLowerCase();
47
+ if (!ALLOWED_COMMANDS.has(cmdBase)) {
48
+ return `Command not allowed: ${command}. Allowed: ${[...ALLOWED_COMMANDS].join(', ')}`;
49
+ }
50
+ for (const arg of args) {
51
+ if (typeof arg !== 'string' || SHELL_META.test(arg)) {
52
+ return 'Invalid argument: contains shell metacharacters';
53
+ }
54
+ }
55
+ return null;
56
+ }
39
57
  // GET /api/mcp/servers
40
58
  router.get('/servers', (_req, res) => {
41
59
  res.json({ ok: true, data: mcpConfig.listServers() });
@@ -50,7 +68,12 @@ router.post('/servers', (req, res) => {
50
68
  if (!name || !command) {
51
69
  return res.status(400).json({ ok: false, error: 'name and command are required' });
52
70
  }
53
- const server = mcpConfig.addServer({ name, command, args: args || [], env: env || {}, enabled: enabled !== false });
71
+ const argList = args || [];
72
+ const validationError = validateMcpCommand(command, argList);
73
+ if (validationError) {
74
+ return res.status(400).json({ ok: false, error: validationError });
75
+ }
76
+ const server = mcpConfig.addServer({ name, command, args: argList, env: env || {}, enabled: enabled !== false });
54
77
  res.json({ ok: true, data: server });
55
78
  });
56
79
  // POST /api/mcp/servers/:name/test — test connection
@@ -37,7 +37,10 @@ const express_1 = require("express");
37
37
  const projectStore = __importStar(require("../services/projectStore"));
38
38
  const typedEmit_1 = require("../lib/typedEmit");
39
39
  const zod_1 = require("zod");
40
+ const validateSlug_1 = require("../lib/validateSlug");
40
41
  const router = (0, express_1.Router)();
42
+ // Validate :slug param for all routes in this router
43
+ router.param('slug', (req, res, next) => (0, validateSlug_1.validateSlugParam)('slug')(req, res, next));
41
44
  // GET /api/projects
42
45
  router.get('/', (_req, res) => {
43
46
  const projects = projectStore.listProjects();
@@ -34,31 +34,87 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const express_1 = require("express");
37
+ const zod_1 = require("zod");
37
38
  const settingsService = __importStar(require("../services/settingsService"));
38
39
  const router = (0, express_1.Router)();
40
+ // Schema restricts updates to known keys only — prevents arbitrary key injection
41
+ const SettingsSchema = zod_1.z.object({
42
+ general: zod_1.z.object({
43
+ defaultModel: zod_1.z.enum(['opus', 'sonnet', 'haiku']).optional(),
44
+ timezone: zod_1.z.string().max(100).optional(),
45
+ port: zod_1.z.number().int().min(1024).max(65535).optional(),
46
+ }).optional(),
47
+ scheduler: zod_1.z.object({
48
+ enabled: zod_1.z.boolean().optional(),
49
+ maxConcurrent: zod_1.z.number().int().min(1).max(20).optional(),
50
+ timeout: zod_1.z.number().int().min(10000).max(3600000).optional(),
51
+ staleThreshold: zod_1.z.number().int().min(1).max(1440).optional(),
52
+ }).optional(),
53
+ terminal: zod_1.z.object({
54
+ inactivityWarn: zod_1.z.number().int().min(1).max(1440).optional(),
55
+ inactivityKill: zod_1.z.number().int().min(1).max(1440).optional(),
56
+ maxTimeout: zod_1.z.number().int().min(1).max(1440).optional(),
57
+ }).optional(),
58
+ ralph: zod_1.z.object({
59
+ maxIterations: zod_1.z.number().int().min(1).max(500).optional(),
60
+ circuitBreaker: zod_1.z.number().int().min(1).max(50).optional(),
61
+ taskFilter: zod_1.z.enum(['all', 'todo-only']).optional(),
62
+ }).optional(),
63
+ auth: zod_1.z.object({
64
+ enabled: zod_1.z.boolean().optional(),
65
+ secret: zod_1.z.string().max(500).optional(),
66
+ tokenExpiry: zod_1.z.string().regex(/^\d+(h|d|m)$/).optional(),
67
+ }).optional(),
68
+ integrations: zod_1.z.object({
69
+ telegram: zod_1.z.object({
70
+ enabled: zod_1.z.boolean().optional(),
71
+ botToken: zod_1.z.string().max(500).optional(),
72
+ chatId: zod_1.z.string().max(100).optional(),
73
+ }).optional(),
74
+ voice: zod_1.z.object({
75
+ enabled: zod_1.z.boolean().optional(),
76
+ openaiApiKey: zod_1.z.string().max(500).optional(),
77
+ }).optional(),
78
+ }).optional(),
79
+ }).strict();
80
+ // Allowed section names
81
+ const VALID_SECTIONS = new Set(['general', 'scheduler', 'terminal', 'ralph', 'auth', 'integrations']);
39
82
  // GET /api/settings
40
83
  router.get('/', (_req, res) => {
41
84
  res.json({ ok: true, data: settingsService.getSettings() });
42
85
  });
43
86
  // PUT /api/settings — update entire settings
44
87
  router.put('/', (req, res) => {
45
- const settings = settingsService.updateSettings(req.body);
88
+ const parsed = SettingsSchema.safeParse(req.body);
89
+ if (!parsed.success) {
90
+ return res.status(400).json({ ok: false, error: parsed.error.issues[0]?.message || 'Invalid settings' });
91
+ }
92
+ const settings = settingsService.updateSettings(parsed.data);
46
93
  res.json({ ok: true, data: settings });
47
94
  });
48
95
  // GET /api/settings/:section
49
96
  router.get('/:section', (req, res) => {
50
97
  const section = req.params.section;
51
- const settings = settingsService.getSettings();
52
- if (!(section in settings))
98
+ if (!VALID_SECTIONS.has(req.params.section))
53
99
  return res.status(404).json({ ok: false, error: 'Section not found' });
100
+ const settings = settingsService.getSettings();
54
101
  res.json({ ok: true, data: settings[section] });
55
102
  });
56
103
  // PATCH /api/settings/:section — update a section
57
104
  router.patch('/:section', (req, res) => {
58
- const section = req.params.section;
59
- const settings = settingsService.getSettings();
60
- if (!(section in settings))
105
+ if (!VALID_SECTIONS.has(req.params.section))
61
106
  return res.status(404).json({ ok: false, error: 'Section not found' });
107
+ const section = req.params.section;
108
+ // Validate just the section being updated
109
+ const sectionSchema = SettingsSchema.shape[section];
110
+ if (sectionSchema) {
111
+ const parsed = sectionSchema.safeParse(req.body);
112
+ if (!parsed.success) {
113
+ return res.status(400).json({ ok: false, error: parsed.error.issues[0]?.message || 'Invalid settings' });
114
+ }
115
+ const updated = settingsService.updateSection(section, parsed.data);
116
+ return res.json({ ok: true, data: updated });
117
+ }
62
118
  const updated = settingsService.updateSection(section, req.body);
63
119
  res.json({ ok: true, data: updated });
64
120
  });
@@ -100,18 +100,28 @@ router.get('/logs', (req, res) => {
100
100
  });
101
101
  // GET /api/projects/:slug/soul/logs/:date
102
102
  router.get('/logs/:date', (req, res) => {
103
- const log = soulStore.getDailyLog(req.params.slug, req.params.date);
104
- if (!log)
105
- return res.status(404).json({ ok: false, error: 'Log not found' });
106
- res.json({ ok: true, data: log });
103
+ try {
104
+ const log = soulStore.getDailyLog(req.params.slug, req.params.date);
105
+ if (!log)
106
+ return res.status(404).json({ ok: false, error: 'Log not found' });
107
+ res.json({ ok: true, data: log });
108
+ }
109
+ catch (err) {
110
+ res.status(400).json({ ok: false, error: err.message });
111
+ }
107
112
  });
108
113
  // POST /api/projects/:slug/soul/logs
109
114
  router.post('/logs', (req, res) => {
110
115
  const { entry, date } = req.body;
111
116
  if (!entry)
112
117
  return res.status(400).json({ ok: false, error: 'entry required' });
113
- soulStore.appendDailyLog(req.params.slug, entry, date);
114
- res.json({ ok: true });
118
+ try {
119
+ soulStore.appendDailyLog(req.params.slug, entry, date);
120
+ res.json({ ok: true });
121
+ }
122
+ catch (err) {
123
+ res.status(400).json({ ok: false, error: err.message });
124
+ }
115
125
  });
116
126
  // ─── Config ───
117
127
  // GET /api/projects/:slug/soul/config
@@ -37,7 +37,10 @@ const express_1 = require("express");
37
37
  const workItemStore = __importStar(require("../services/workItemStore"));
38
38
  const typedEmit_1 = require("../lib/typedEmit");
39
39
  const zod_1 = require("zod");
40
+ const validateSlug_1 = require("../lib/validateSlug");
40
41
  const router = (0, express_1.Router)({ mergeParams: true });
42
+ // Validate :wiId param for all routes in this router
43
+ router.param('wiId', (req, res, next) => (0, validateSlug_1.validateSlugParam)('wiId')(req, res, next));
41
44
  // GET /api/projects/:slug/work-items
42
45
  router.get('/', (req, res) => {
43
46
  const items = workItemStore.listWorkItems(req.params.slug);
@@ -108,6 +108,11 @@ exports.MCP_PRESETS = [
108
108
  function getPresets() {
109
109
  return exports.MCP_PRESETS;
110
110
  }
111
+ // Command safety — only allow known executables
112
+ const ALLOWED_COMMANDS = new Set([
113
+ 'node', 'npx', 'cmd', 'cmd.exe', 'python', 'python3', 'uvx', 'pip', 'pipx',
114
+ ]);
115
+ const SHELL_META = /[;&|`$(){}!<>\\"\n\r]/;
111
116
  /**
112
117
  * Test if an MCP server can be spawned and responds.
113
118
  * Spawns the command, waits briefly, and checks if process is alive.
@@ -116,6 +121,16 @@ async function testServer(name) {
116
121
  const server = getServer(name);
117
122
  if (!server)
118
123
  return { ok: false, message: 'Server not found' };
124
+ // Validate command before spawning
125
+ const cmdBase = (server.command.split(/[\\/]/).pop() || server.command).toLowerCase();
126
+ if (!ALLOWED_COMMANDS.has(cmdBase)) {
127
+ return { ok: false, message: `Command not allowed: ${server.command}` };
128
+ }
129
+ for (const arg of server.args || []) {
130
+ if (typeof arg !== 'string' || SHELL_META.test(arg)) {
131
+ return { ok: false, message: 'Invalid argument: contains shell metacharacters' };
132
+ }
133
+ }
119
134
  const { spawn } = require('child_process');
120
135
  return new Promise((resolve) => {
121
136
  const timeout = setTimeout(() => {
@@ -128,6 +128,12 @@ function resetMemory(projectSlug) {
128
128
  writeMemory(projectSlug, []);
129
129
  }
130
130
  // ─── Daily Logs ───
131
+ const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
132
+ function validateDate(date) {
133
+ if (!DATE_PATTERN.test(date)) {
134
+ throw new Error('Invalid date format: must be YYYY-MM-DD');
135
+ }
136
+ }
131
137
  function listDailyLogs(projectSlug) {
132
138
  ensureSoulDir(projectSlug);
133
139
  const dir = logsDir(projectSlug);
@@ -145,6 +151,7 @@ function listDailyLogs(projectSlug) {
145
151
  });
146
152
  }
147
153
  function getDailyLog(projectSlug, date) {
154
+ validateDate(date);
148
155
  const filePath = path_1.default.join(logsDir(projectSlug), `${date}.md`);
149
156
  if (!fs_1.default.existsSync(filePath))
150
157
  return null;
@@ -154,6 +161,7 @@ function getDailyLog(projectSlug, date) {
154
161
  function appendDailyLog(projectSlug, entry, date) {
155
162
  ensureSoulDir(projectSlug);
156
163
  const d = date || new Date().toISOString().split('T')[0];
164
+ validateDate(d);
157
165
  const filePath = path_1.default.join(logsDir(projectSlug), `${d}.md`);
158
166
  const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
159
167
  const line = `- [${timestamp}] ${entry}\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kanbaii",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Visual cockpit for Claude Code. Plan visually, track progress, let AI execute. Same engine, better cockpit.",
5
5
  "keywords": [
6
6
  "kanban",
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{4732:function(e,t,s){Promise.resolve().then(s.t.bind(s,7960,23)),Promise.resolve().then(s.bind(s,792))},792:function(e,t,s){"use strict";s.d(t,{AppShell:function(){return ek}});var a=s(7437),n=s(2265);let r=(0,n.createContext)(void 0);function o(e){let{children:t}=e,[s,o]=(0,n.useState)("dark"),[l,i]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let e=localStorage.getItem("kanbaii-theme");"light"===e||"dark"===e?o(e):o("dark"),i(!0)},[]),(0,n.useEffect)(()=>{l&&(document.documentElement.setAttribute("data-theme",s),localStorage.setItem("kanbaii-theme",s))},[s,l]),l)?(0,a.jsx)(r.Provider,{value:{theme:s,toggleTheme:()=>{o(e=>"dark"===e?"light":"dark")}},children:t}):null}function l(){let e=(0,n.useContext)(r);if(!e)throw Error("useTheme must be used within ThemeProvider");return e}var i=s(2829);let c=(0,i.Z)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);var d=s(9397);let x=(0,i.Z)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),u=(0,i.Z)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);var p=s(8930),m=s(407),h=s(9076);let f=(0,i.Z)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);var b=s(8728),g=s(9747),v=s(9449),j=s(2569),y=s(9405),k=s(1347);function N(){let{theme:e,toggleTheme:t}=l();return(0,a.jsxs)("button",{className:"relative w-12 h-[26px] rounded-[13px] border border-border bg-surface cursor-pointer p-0 transition-all duration-250 ease-out-expo overflow-hidden shrink-0 hover:border-accent hover:bg-surface-hover hover:shadow-[0_0_8px_var(--accent-glow)]",onClick:t,title:"Switch to ".concat("dark"===e?"light":"dark"," theme"),children:[(0,a.jsx)(k.E.div,{className:"absolute top-0.5 left-0.5 w-5 h-5 rounded-[10px] bg-accent shadow-[0_2px_6px_rgba(0,0,0,0.3)] flex items-center justify-center",initial:!1,animate:{x:"dark"===e?0:22},transition:{type:"spring",stiffness:300,damping:30},children:"dark"===e?(0,a.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):(0,a.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,a.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,a.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,a.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,a.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,a.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,a.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,a.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,a.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})}),(0,a.jsxs)("div",{className:"absolute inset-0 flex items-center justify-between px-1.5 pointer-events-none",children:[(0,a.jsx)("div",{className:"ml-0.5 transition-opacity duration-250 ease-out-expo ".concat("dark"===e?"opacity-30":"opacity-0"),children:(0,a.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),(0,a.jsx)("div",{className:"mr-0.5 transition-opacity duration-250 ease-out-expo ".concat("light"===e?"opacity-30":"opacity-0"),children:(0,a.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,a.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,a.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"})]})})]})]})}var w=s(2489),C=s(1171),S=s(9116);let T=["#6366f1","#ef4444","#f59e0b","#22c55e","#3b82f6","#8b5cf6","#ec4899","#14b8a6"];function z(e){let{onClose:t}=e,s=(0,v.U)(e=>e.goToProject),r=(0,g.i)(e=>e.createProject),[o,l]=(0,n.useState)(""),[i,c]=(0,n.useState)(""),[d,x]=(0,n.useState)(""),[u,p]=(0,n.useState)(T[0]),[m,h]=(0,n.useState)(!1),{overlayProps:f}=(0,C.N)(t,{disabled:m});(0,n.useEffect)(()=>{S.h.getHealth().then(e=>{e.cwd&&!d&&x(e.cwd)}).catch(()=>{})},[]);let b=async e=>{if(e.preventDefault(),o.trim()){h(!0);try{let e=await r({title:o.trim(),description:i.trim()||void 0,color:u,workingDir:d.trim()||void 0});t(),s(e.slug)}catch(e){h(!1)}}};return(0,a.jsx)("div",{className:"glass-overlay",...f,children:(0,a.jsxs)("div",{className:"modal-box w-[440px] max-w-[92%] p-7",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-7",children:[(0,a.jsx)("span",{className:"text-h2 font-semibold tracking-tight",children:"New Project"}),(0,a.jsx)("button",{className:"btn-icon",onClick:t,children:(0,a.jsx)(w.Z,{size:16})})]}),(0,a.jsxs)("form",{className:"flex flex-col gap-5",onSubmit:b,children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Title"}),(0,a.jsx)("input",{value:o,onChange:e=>l(e.target.value),placeholder:"Project name...",autoFocus:!0})]}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Description (optional)"}),(0,a.jsx)("input",{value:i,onChange:e=>c(e.target.value),placeholder:"Brief description..."})]}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Working Directory"}),(0,a.jsx)("input",{value:d,onChange:e=>x(e.target.value),placeholder:"C:\\Users\\...\\my-project"}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted mt-1 opacity-60",children:"Where Claude runs commands. Defaults to where kanbaii was started."})]}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-widest mb-2 font-mono",children:"Color"}),(0,a.jsx)("div",{className:"flex gap-2",children:T.map(e=>(0,a.jsx)("button",{type:"button",className:"w-6 h-6 rounded-full border-2 cursor-pointer transition-all duration-150 ease-out-expo\n ".concat(u===e?"border-text shadow-[0_0_8px_currentColor]":"border-transparent shadow-[0_0_0_0_transparent]","\n hover:scale-[1.2] hover:shadow-[0_0_12px_currentColor]"),style:{background:e},onClick:()=>p(e)},e))})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,a.jsx)("button",{type:"button",className:"btn-ghost",onClick:t,children:"Cancel"}),(0,a.jsx)("button",{type:"submit",className:"btn-primary",disabled:!o.trim()||m,children:m?"Creating...":"Create"})]})]})]})})}let E=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555",P=[{key:"general",label:"General"},{key:"ralph",label:"Ralph"},{key:"scheduler",label:"Scheduler"},{key:"terminal",label:"Terminal"},{key:"auth",label:"Auth"},{key:"integrations",label:"Integrations"}];function M(e){let{onClose:t}=e,s=(0,y.E)(e=>e.addToast),[r,o]=(0,n.useState)("general"),[l,i]=(0,n.useState)(null),[c,d]=(0,n.useState)(!1),{overlayProps:x}=(0,C.N)(t),u=(0,n.useCallback)(async()=>{try{let e=await fetch("".concat(E,"/api/settings")),t=await e.json();t.ok&&i(t.data)}catch(e){}},[]);(0,n.useEffect)(()=>{u()},[u]);let p=async(e,t)=>{d(!0);try{await fetch("".concat(E,"/api/settings/").concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s("Settings saved","success"),u()}catch(e){s("Failed to save","error")}d(!1)};return l?(0,a.jsx)("div",{className:"glass-overlay",...x,children:(0,a.jsxs)("div",{className:"modal-box max-w-[680px] w-[95%] max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-6 pt-5 pb-4 shrink-0",children:[(0,a.jsxs)("div",{className:"text-h2 font-semibold tracking-tight flex items-center gap-2",children:[(0,a.jsx)(b.Z,{size:16})," Settings"]}),(0,a.jsx)("button",{className:"btn-icon",onClick:t,children:(0,a.jsx)(w.Z,{size:16})})]}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,a.jsx)("div",{className:"w-40 shrink-0 border-r border-border p-2 flex flex-col gap-0.5 bg-bg-subtle",children:P.map(e=>(0,a.jsx)("button",{className:"px-3 py-2 text-xs font-medium text-text-muted rounded-sm text-left transition-all duration-150 ease-out-expo hover:text-text-secondary hover:bg-surface-hover ".concat(r===e.key?"text-text bg-accent-muted":""),onClick:()=>o(e.key),children:e.label},e.key))}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:["general"===r&&(0,a.jsxs)(_,{title:"General",onSave:e=>p("general",e),saving:c,children:[(0,a.jsx)(I,{label:"Default Model",type:"select",value:l.general.defaultModel,options:["haiku","sonnet","opus"],field:"defaultModel"}),(0,a.jsx)(I,{label:"Timezone",value:l.general.timezone,field:"timezone"}),(0,a.jsx)(I,{label:"Port",type:"number",value:l.general.port,field:"port"})]}),"ralph"===r&&(0,a.jsxs)(_,{title:"Ralph",onSave:e=>p("ralph",e),saving:c,children:[(0,a.jsx)(I,{label:"Max Iterations",type:"number",value:l.ralph.maxIterations,field:"maxIterations"}),(0,a.jsx)(I,{label:"Circuit Breaker (max errors)",type:"number",value:l.ralph.circuitBreaker,field:"circuitBreaker"}),(0,a.jsx)(I,{label:"Task Filter",type:"select",value:l.ralph.taskFilter,options:["todo-only","all"],field:"taskFilter"})]}),"scheduler"===r&&(0,a.jsxs)(_,{title:"Scheduler",onSave:e=>p("scheduler",e),saving:c,children:[(0,a.jsx)(I,{label:"Enabled",type:"toggle",value:l.scheduler.enabled,field:"enabled"}),(0,a.jsx)(I,{label:"Max Concurrent",type:"number",value:l.scheduler.maxConcurrent,field:"maxConcurrent"}),(0,a.jsx)(I,{label:"Timeout (ms)",type:"number",value:l.scheduler.timeout,field:"timeout"}),(0,a.jsx)(I,{label:"Stale Threshold (min)",type:"number",value:l.scheduler.staleThreshold,field:"staleThreshold"})]}),"terminal"===r&&(0,a.jsxs)(_,{title:"Terminal",onSave:e=>p("terminal",e),saving:c,children:[(0,a.jsx)(I,{label:"Inactivity Warn (min)",type:"number",value:l.terminal.inactivityWarn,field:"inactivityWarn"}),(0,a.jsx)(I,{label:"Inactivity Kill (min)",type:"number",value:l.terminal.inactivityKill,field:"inactivityKill"}),(0,a.jsx)(I,{label:"Max Timeout (min)",type:"number",value:l.terminal.maxTimeout,field:"maxTimeout"})]}),"auth"===r&&(0,a.jsxs)(_,{title:"Authentication",onSave:e=>p("auth",e),saving:c,children:[(0,a.jsx)(I,{label:"Enabled",type:"toggle",value:l.auth.enabled,field:"enabled"}),(0,a.jsx)(I,{label:"Secret Key",value:l.auth.secret,field:"secret",placeholder:"auto-generated if empty"}),(0,a.jsx)(I,{label:"Token Expiry",value:l.auth.tokenExpiry,field:"tokenExpiry",placeholder:"24h"})]}),"integrations"===r&&(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)(_,{title:"Telegram",onSave:e=>p("integrations",{telegram:e}),saving:c,children:[(0,a.jsx)(I,{label:"Enabled",type:"toggle",value:l.integrations.telegram.enabled,field:"enabled"}),(0,a.jsx)(I,{label:"Bot Token",value:l.integrations.telegram.botToken,field:"botToken",placeholder:"123456:ABC-DEF..."}),(0,a.jsx)(I,{label:"Chat ID",value:l.integrations.telegram.chatId,field:"chatId",placeholder:"-100123456789"})]}),(0,a.jsxs)(_,{title:"Voice Input",onSave:e=>p("integrations",{voice:e}),saving:c,children:[(0,a.jsx)(I,{label:"Enabled",type:"toggle",value:l.integrations.voice.enabled,field:"enabled"}),(0,a.jsx)(I,{label:"OpenAI API Key",value:l.integrations.voice.openaiApiKey||"",field:"openaiApiKey",placeholder:"sk-... (for Whisper fallback)"})]})]})]})]})]})}):null}function _(e){let{title:t,children:s,onSave:r,saving:o}=e,[l,i]=(0,n.useState)({});(0,n.useEffect)(()=>{let e={};n.Children.forEach(s,t=>{var s;(null==t?void 0:null===(s=t.props)||void 0===s?void 0:s.field)&&(e[t.props.field]=t.props.value)}),i(e)},[s]);let c=(e,t)=>{i(s=>({...s,[e]:t}))};return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-body font-semibold text-text tracking-tight",children:t}),(0,a.jsx)("button",{className:"btn-primary",onClick:()=>r(l),disabled:o,children:o?"Saving...":"Save"})]}),(0,a.jsx)("div",{className:"flex flex-col gap-3",children:n.Children.map(s,e=>{var t,s;return(null==e?void 0:null===(t=e.props)||void 0===t?void 0:t.field)?n.cloneElement(e,{value:null!==(s=l[e.props.field])&&void 0!==s?s:e.props.value,onChange:t=>c(e.props.field,t)}):e})})]})}function I(e){let{label:t,value:s,field:n,type:r,options:o,placeholder:l,onChange:i}=e;return"toggle"===r?(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-secondary min-w-[140px] shrink-0",children:t}),(0,a.jsx)("button",{className:"px-3 py-1 text-data font-semibold rounded-xs font-mono border transition-all duration-150 ease-out-expo tracking-wide ".concat(s?"text-success border-success-dim bg-success-dim":"text-text-muted border-border"),onClick:()=>null==i?void 0:i(!s),children:s?"ON":"OFF"})]}):"select"===r&&o?(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-secondary min-w-[140px] shrink-0",children:t}),(0,a.jsx)("div",{className:"flex gap-1",children:o.map(e=>(0,a.jsx)("button",{className:"px-2.5 py-1 text-data font-medium rounded-full border font-mono transition-all duration-150 ease-out-expo ".concat(s===e?"border-accent-dim text-accent bg-accent-muted":"border-border text-text-muted hover:border-border-light hover:text-text-secondary"),onClick:()=>null==i?void 0:i(e),children:e},e))})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-secondary min-w-[140px] shrink-0",children:t}),(0,a.jsx)("input",{type:r||"text",value:null!=s?s:"",onChange:e=>null==i?void 0:i("number"===r?Number(e.target.value):e.target.value),placeholder:l,className:"flex-1 max-w-[200px] text-right font-mono text-xs"})]})}let A=(0,i.Z)("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);var Z=s(1239),R=s(1723);let D=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function F(e){return e<.01?"$".concat(e.toFixed(4)):"$".concat(e.toFixed(2))}function L(e){var t;let{projectSlug:s}=e,r=(0,y.E)(e=>e.addToast),[o,l]=(0,n.useState)(null),[i,c]=(0,n.useState)([]),[d,x]=(0,n.useState)("30d"),[u,m]=(0,n.useState)(s?"project":"global"),h=(0,n.useCallback)(async()=>{let e="project"===u&&s?s:void 0,t="7d"===d?7:"30d"===d?30:void 0,[a,n]=await Promise.all([fetch("".concat(D,"/api/costs/summary").concat(e?"?projectSlug=".concat(e):"")).then(e=>e.json()).catch(()=>({data:null})),fetch("".concat(D,"/api/costs/executions?limit=50").concat(e?"&projectSlug=".concat(e):"").concat(t?"&days=".concat(t):"")).then(e=>e.json()).catch(()=>({data:[]}))]);l(a.data||null),c(n.data||[])},[s,u,d]);(0,n.useEffect)(()=>{h()},[h]);let b=async()=>{let e="project"===u&&s?"?projectSlug=".concat(s):"";await fetch("".concat(D,"/api/costs/clear").concat(e),{method:"DELETE"}),r("Execution history cleared","info"),h()},g={opus:"#a855f7",sonnet:"#6366f1",haiku:"#22c55e"};return(0,a.jsxs)("div",{className:"flex flex-col h-full overflow-y-auto gap-5 p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,a.jsxs)("div",{className:"text-h2 font-semibold tracking-tight flex items-center gap-2",children:[(0,a.jsx)(f,{size:18})," Costs & Analytics"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[s&&(0,a.jsxs)("div",{className:"flex border border-border rounded-sm overflow-hidden",children:[(0,a.jsx)("button",{className:"px-2.5 py-1 text-xxs font-semibold font-mono tracking-wide uppercase text-text-muted transition-all duration-150 ease-out-expo hover:text-text-secondary hover:bg-surface-hover ".concat("project"===u?"text-accent bg-accent-muted":""),onClick:()=>m("project"),children:"Project"}),(0,a.jsx)("button",{className:"px-2.5 py-1 text-xxs font-semibold font-mono tracking-wide uppercase text-text-muted transition-all duration-150 ease-out-expo hover:text-text-secondary hover:bg-surface-hover ".concat("global"===u?"text-accent bg-accent-muted":""),onClick:()=>m("global"),children:"Global"})]}),(0,a.jsx)("div",{className:"flex border border-border rounded-sm overflow-hidden",children:["7d","30d","all"].map(e=>(0,a.jsx)("button",{className:"px-2.5 py-1 text-xxs font-semibold font-mono tracking-wide uppercase text-text-muted transition-all duration-150 ease-out-expo hover:text-text-secondary hover:bg-surface-hover ".concat(d===e?"text-accent bg-accent-muted":""),onClick:()=>x(e),children:e},e))})]})]}),o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-4 gap-2 max-md:grid-cols-2",children:[(0,a.jsxs)("div",{className:"p-4 border border-border rounded-md bg-card text-center relative overflow-hidden",children:[(0,a.jsx)("div",{className:"text-accent mb-1.5 flex justify-center",children:(0,a.jsx)(A,{size:14})}),(0,a.jsx)("div",{className:"text-h1 font-bold text-text font-mono tracking-tight",children:F(o.todayCost)}),(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mt-1",children:"Today"})]}),(0,a.jsxs)("div",{className:"p-4 border border-border rounded-md bg-card text-center relative overflow-hidden",children:[(0,a.jsx)("div",{className:"text-accent mb-1.5 flex justify-center",children:(0,a.jsx)(A,{size:14})}),(0,a.jsx)("div",{className:"text-h1 font-bold text-text font-mono tracking-tight",children:F(o.monthlyCost)}),(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mt-1",children:"This Month"})]}),(0,a.jsxs)("div",{className:"p-4 border border-border rounded-md bg-card text-center relative overflow-hidden",children:[(0,a.jsx)("div",{className:"text-accent mb-1.5 flex justify-center",children:(0,a.jsx)(Z.Z,{size:14})}),(0,a.jsx)("div",{className:"text-h1 font-bold text-text font-mono tracking-tight",children:(t=o.monthlyTokens)>=1e6?"".concat((t/1e6).toFixed(1),"M"):t>=1e3?"".concat((t/1e3).toFixed(0),"K"):"".concat(t)}),(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mt-1",children:"Tokens (Month)"})]}),(0,a.jsxs)("div",{className:"p-4 border border-border rounded-md bg-card text-center relative overflow-hidden",children:[(0,a.jsx)("div",{className:"text-accent mb-1.5 flex justify-center",children:(0,a.jsx)(R.Z,{size:14})}),(0,a.jsx)("div",{className:"text-h1 font-bold text-text font-mono tracking-tight",children:o.monthlyExecutions}),(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mt-1",children:"Executions (Month)"})]})]}),Object.keys(o.byModel).length>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Model Breakdown"}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5",children:Object.entries(o.byModel).map(e=>{let[t,s]=e;return(0,a.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2.5 border border-border rounded-sm bg-card",children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:g[t]||"#6366f1"}}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text",children:t}),(0,a.jsxs)("span",{className:"text-data text-text-muted font-mono ml-2",children:[s.count," runs — ",F(s.cost)]})]}),(0,a.jsx)("div",{className:"w-20 h-1 rounded-full overflow-hidden",style:{background:"rgba(148, 163, 242, 0.06)"},children:(0,a.jsx)("div",{className:"h-full rounded-full transition-[width] duration-500 ease-out-expo",style:{width:"".concat(o.totalExecutions>0?s.count/o.totalExecutions*100:0,"%"),background:g[t]||"#6366f1"}})})]},t)})})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Recent Executions"}),(0,a.jsxs)("button",{className:"inline-flex items-center gap-[3px] text-xxs text-text-muted px-2 py-[3px] rounded-xs font-mono border border-border transition-all duration-120 ease-out-expo hover:text-danger hover:border-danger-dim",onClick:b,children:[(0,a.jsx)(p.Z,{size:10})," Clear"]})]}),0===i.length?(0,a.jsx)("div",{className:"text-text-muted text-label text-center py-8 font-mono opacity-50",children:"No executions recorded yet"}):(0,a.jsxs)("div",{className:"border border-border rounded-md overflow-hidden bg-card",children:[(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_70px_70px_60px_40px] px-3.5 py-2 text-xxs font-semibold text-text-muted uppercase tracking-wide font-mono border-b border-border bg-bg-subtle",children:[(0,a.jsx)("span",{children:"Task"}),(0,a.jsx)("span",{children:"Model"}),(0,a.jsx)("span",{children:"Duration"}),(0,a.jsx)("span",{children:"Cost"}),(0,a.jsx)("span",{children:"Status"})]}),i.map(e=>{var t;return(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_70px_70px_60px_40px] px-3.5 py-2 text-label border-b border-b-[rgba(148,163,242,0.03)] last:border-b-0 transition-colors duration-120 ease-out-expo hover:bg-surface-hover",children:[(0,a.jsx)("span",{className:"text-text overflow-hidden text-ellipsis whitespace-nowrap",children:e.taskTitle||e.projectSlug}),(0,a.jsx)("span",{className:"font-mono text-data font-semibold",style:{color:g[e.model]||"#6366f1"},children:e.model}),(0,a.jsx)("span",{className:"text-text-muted font-mono text-data",children:(t=e.duration)<1e3?"".concat(t,"ms"):"".concat((t/1e3).toFixed(1),"s")}),(0,a.jsx)("span",{className:"text-text-secondary font-mono text-data font-medium",children:F(e.costUsd)}),(0,a.jsx)("span",{className:"text-center ".concat("success"===e.status?"text-success":"text-danger"),children:"success"===e.status?"✓":"✗"})]},e.id)})]})]})]})}var q=s(7168),U=s(4401),B=s(6766);let O=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555",K="kanbaii-claude-usage";function W(e){return e>=80?"#ef4444":e>=60?"#f59e0b":"#6366f1"}function G(){try{var e;let t=sessionStorage.getItem(K);if(!t)return null;let s=JSON.parse(t);if((null==s?void 0:null===(e=s.entries)||void 0===e?void 0:e.length)>0&&Date.now()-new Date(s.timestamp).getTime()<3e5)return s}catch(e){}return null}function H(e){let{isExpanded:t}=e,[s,r]=(0,n.useState)(G),[o,l]=(0,n.useState)(!1),i=(0,n.useRef)(!0),c=(0,n.useCallback)(e=>{if(i.current){r(e),l(!1);try{sessionStorage.setItem(K,JSON.stringify(e))}catch(e){}}},[]),d=(0,n.useCallback)(async()=>{try{var e;let t=await fetch("".concat(O,"/api/costs/claude-usage")),s=await t.json(),a=(null==s?void 0:s.data)||s;if((null==a?void 0:null===(e=a.entries)||void 0===e?void 0:e.length)>0)return c(a),!0}catch(e){}return!1},[c]);(0,n.useEffect)(()=>{i.current=!0;let e=null,t=null,a=null,n=()=>{t=setInterval(async()=>{await d()&&t&&(clearInterval(t),t=null)},3e3),a=setTimeout(()=>{t&&(clearInterval(t),t=null),i.current&&!s&&l(!0)},3e4)};return e=setInterval(d,6e4),d().then(e=>{e||n()}),()=>{i.current=!1,e&&clearInterval(e),t&&clearInterval(t),a&&clearTimeout(a)}},[]),(0,n.useEffect)(()=>{let e=(0,B.h)(),t=e=>{var t;(null==e?void 0:null===(t=e.entries)||void 0===t?void 0:t.length)>0&&c(e)};return e.on("claude-usage",t),e.on("connect",()=>{d()}),()=>{e.off("claude-usage",t)}},[c,d]);let x=s?Math.max(...s.entries.map(e=>e.percent),0):0;return t?s?(0,a.jsxs)("div",{className:"px-3 py-2 flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mb-0.5",children:[(0,a.jsx)(U.Z,{size:10,className:"text-text-muted opacity-50"}),(0,a.jsx)("span",{className:"text-[8px] font-semibold text-text-muted uppercase tracking-[0.1em] font-mono opacity-60",children:"Rate Limits"})]}),s.entries.map((e,t)=>{var s;let n=W(e.percent),r=(s=e.percent)>=80?"rgba(239,68,68,0.3)":s>=60?"rgba(245,158,11,0.2)":"rgba(99,102,241,0.15)";return(0,a.jsxs)("div",{className:"flex flex-col gap-[3px]",children:[(0,a.jsxs)("div",{className:"flex justify-between items-baseline",children:[(0,a.jsx)("span",{className:"text-[9px] text-text-muted truncate max-w-[110px] font-mono",children:e.label}),(0,a.jsxs)("span",{className:"text-[10px] font-bold font-mono tabular-nums ".concat(e.percent>=80?"animate-breathe":""),style:{color:n},children:[e.percent,"%"]})]}),(0,a.jsx)("div",{className:"w-full h-[3px] rounded-full overflow-hidden",style:{background:"rgba(148,163,242,0.06)"},children:(0,a.jsx)("div",{className:"h-full rounded-full transition-[width] duration-700 ease-out",style:{width:"".concat(Math.min(e.percent,100),"%"),background:n,boxShadow:e.percent>40?"0 0 6px ".concat(r):"none"}})}),e.resetsAt&&(0,a.jsxs)("span",{className:"text-[7px] text-text-muted font-mono opacity-40",children:["Resets ",e.resetsAt]})]},t)})]}):o?(0,a.jsxs)("div",{className:"px-3 py-2 flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"text-[8px] text-text-muted font-mono opacity-40",children:"Unavailable"}),(0,a.jsxs)("button",{className:"text-[8px] text-accent font-mono opacity-60 hover:opacity-100 transition-opacity flex items-center gap-1",onClick:()=>{l(!1),d()},children:[(0,a.jsx)(q.Z,{size:8})," Retry"]})]}):(0,a.jsxs)("div",{className:"px-3 py-2 flex items-center justify-center gap-2",children:[(0,a.jsx)("div",{className:"w-2.5 h-2.5 border border-text-muted/20 border-t-accent/50 rounded-full animate-spin"}),(0,a.jsx)("span",{className:"text-[8px] text-text-muted font-mono opacity-40",children:"Loading usage..."})]}):s?(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1 py-1",title:s.entries.map(e=>"".concat(e.label,": ").concat(e.percent,"%")).join("\n"),children:[(0,a.jsx)("div",{className:"w-[5px] h-5 rounded-full overflow-hidden flex flex-col-reverse",style:{background:"rgba(148, 163, 242, 0.06)"},children:(0,a.jsx)("div",{className:"w-full rounded-full transition-[height] duration-500",style:{height:"".concat(Math.min(x,100),"%"),background:W(x)}})}),(0,a.jsxs)("span",{className:"text-[7px] text-text-muted font-mono opacity-50",children:[x,"%"]})]}):null}let V=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function J(){let{projects:e,fetchProjects:t,setActiveSlug:s,deleteProject:r,permanentDeleteProject:o,updateProject:l}=(0,g.i)(),{projectSlug:i,goToProject:k,goHome:w}=(0,v.U)(),C=(0,j.q)(e=>e.ralph),S=(0,j.q)(e=>e.teams),T=(0,y.E)(e=>e.addToast),[E,P]=(0,n.useState)(!1),[_,I]=(0,n.useState)(!1),[A,Z]=(0,n.useState)(!1),[R,D]=(0,n.useState)(null),[F,q]=(0,n.useState)(null),[U,B]=(0,n.useState)(null),[O,K]=(0,n.useState)(!1),[W,G]=(0,n.useState)(!1),[J,$]=(0,n.useState)(!0),[Q,Y]=(0,n.useState)(!1),ee=(0,n.useRef)(null),et=J||Q,es=(0,j.q)(e=>e.terminal.status),ea=(0,j.q)(e=>e.planner.active),en="running"===C.status||"paused"===C.status||S.active||"running"===es||ea;(0,n.useEffect)(()=>{t()},[t]),(0,n.useEffect)(()=>{if(!U)return;let e=()=>B(null),t=setTimeout(()=>document.addEventListener("click",e),0);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},[U]);let er=e=>{s(e.slug),k(e.slug)},eo=async(e,t)=>{e.stopPropagation(),B(null);try{await l(t.slug,{status:"archived"}),i===t.slug&&w(),T("".concat(t.title," archived"),"success")}catch(e){T("Failed to archive","error")}},el=async(e,t)=>{e.stopPropagation(),B(null);try{await r(t.slug),i===t.slug&&w(),T("".concat(t.title," moved to trash"),"success")}catch(e){T("Failed to move to trash","error")}},ei=async(e,t)=>{if(e.stopPropagation(),F!==t.slug){q(t.slug),setTimeout(()=>q(null),3e3);return}B(null);try{await o(t.slug),T("".concat(t.title," permanently deleted"),"success"),q(null)}catch(e){T("Failed to delete","error")}},ec=async(e,t)=>{e.stopPropagation(),B(null);try{await l(t.slug,{status:"active"}),T("".concat(t.title," restored"),"success")}catch(e){T("Failed to restore","error")}},ed=(e,t)=>{e.stopPropagation(),fetch("".concat(V,"/api/system/open-folder"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.workingDir})}).catch(()=>T("Failed to open folder","error"))},ex=e.filter(e=>"active"===e.status),eu=e.filter(e=>"archived"===e.status),ep=e.filter(e=>"deleted"===e.status);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("aside",{className:"flex-shrink-0 border-r border-border bg-bg-subtle flex flex-col overflow-hidden relative z-10\n transition-all duration-300 ease-out-expo ".concat(et?"w-sidebar":"w-sidebar-collapsed"),onMouseEnter:()=>{ee.current&&clearTimeout(ee.current),Y(!0)},onMouseLeave:()=>{ee.current=setTimeout(()=>Y(!1),200)},children:[(0,a.jsxs)("div",{className:"flex items-center flex-shrink-0 min-h-[48px]\n ".concat(et?"px-3 pt-3.5 pb-2.5 justify-between":"px-0 pt-3.5 pb-[18px] justify-center"),children:[(0,a.jsxs)("div",{className:"flex items-center ".concat(et?"gap-2.5":"gap-0"),children:[(0,a.jsx)("div",{className:"rounded-sm flex items-center justify-center flex-shrink-0 overflow-hidden relative\n transition-all duration-400\n ".concat(et?"w-[26px] h-[26px]":"w-7 h-7","\n ").concat(en?"bg-gradient-to-br from-emerald-800 to-emerald-500 shadow-[0_0_10px_rgba(16,185,129,0.3),0_0_20px_rgba(16,185,129,0.1)] border border-emerald-500/35 animate-breathe":"bg-gradient-to-br from-indigo-800 to-indigo-400 shadow-[0_0_8px_rgba(99,102,241,0.15),inset_0_0_6px_rgba(99,102,241,0.06)] border border-indigo-500/12"),children:(0,a.jsxs)("svg",{width:et?26:28,height:et?26:28,viewBox:"0 0 32 32",className:"block",children:[(0,a.jsxs)("defs",{children:[(0,a.jsxs)("linearGradient",{id:"kc1",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"0%",stopColor:en?"#d1fae5":"#e0e7ff"}),(0,a.jsx)("stop",{offset:"100%",stopColor:en?"#a7f3d0":"#c7d2fe"})]}),(0,a.jsxs)("linearGradient",{id:"kc2",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"0%",stopColor:en?"#f0fdf4":"#f5f3ff"}),(0,a.jsx)("stop",{offset:"100%",stopColor:en?"#d1fae5":"#e0e7ff"})]}),(0,a.jsxs)("filter",{id:"kglow",children:[(0,a.jsx)("feGaussianBlur",{stdDeviation:"1.5",result:"b"}),(0,a.jsxs)("feMerge",{children:[(0,a.jsx)("feMergeNode",{in:"b"}),(0,a.jsx)("feMergeNode",{in:"SourceGraphic"})]})]})]}),(0,a.jsxs)("g",{filter:"url(#kglow)",children:[(0,a.jsx)("rect",{x:"7",y:"10",width:"4.5",height:"12",fill:"url(#kc1)",rx:"1.5"}),(0,a.jsx)("rect",{x:"13.75",y:"7.5",width:"4.5",height:"17",fill:"url(#kc2)",rx:"1.5"}),(0,a.jsx)("rect",{x:"20.5",y:"11",width:"4.5",height:"10",fill:"url(#kc1)",rx:"1.5"})]})]})}),et&&(0,a.jsx)("span",{className:"text-[17px] font-light tracking-[0.15em] uppercase text-gradient opacity-90",children:"KANBAII"})]}),et&&(0,a.jsx)("button",{className:"w-[26px] h-[26px] flex items-center justify-center rounded-md transition-all duration-200\n ".concat(J?"text-accent bg-accent-muted":"text-text-muted bg-transparent opacity-50 hover:opacity-100 hover:bg-surface hover:text-text"),onClick:()=>$(!J),title:J?"Unpin sidebar":"Pin sidebar",children:(0,a.jsx)(c,{size:13,fill:J?"currentColor":"none",className:"transition-transform duration-300 ".concat(J?"rotate-0":"-rotate-45")})})]}),(0,a.jsx)("div",{className:"h-px flex-shrink-0 opacity-50 ".concat(et?"mx-3 my-[2px_12px_6px]":"mx-2.5 my-[2px_10px_6px]"),style:{background:"linear-gradient(90deg, transparent 10%, var(--border-glow) 50%, transparent 90%)",margin:et?"2px 12px 6px":"2px 10px 6px"}}),(0,a.jsx)("div",{className:"flex-shrink-0 px-2 py-1",children:(0,a.jsxs)("button",{className:"w-full rounded-sm border border-dashed border-border-light bg-transparent text-text-muted text-xs font-medium\n flex items-center gap-2 cursor-pointer transition-all duration-200 ease-out-expo\n hover:bg-accent-muted hover:border-accent/25 hover:text-accent\n ".concat(et?"py-2 px-2.5 justify-start":"py-2 px-0 justify-center"),onClick:()=>P(!0),children:[(0,a.jsx)(d.Z,{size:14}),et&&"New Project"]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden px-2 py-1 pb-4",children:0===ex.length&&0===eu.length&&0===ep.length?(0,a.jsx)("div",{className:"text-center text-text-muted text-body py-8 px-3 transition-opacity duration-150 ".concat(et?"opacity-100":"opacity-0"),children:"No projects yet"}):(0,a.jsxs)(a.Fragment,{children:[ex.map(e=>{let t=i===e.slug,s=C.projectSlug===e.slug&&("running"===C.status||"paused"===C.status),n=S.active&&S.projectSlug===e.slug,r=ea&&j.q.getState().planner.projectSlug===e.slug,o=s||n||r,l=function(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:{r:99,g:102,b:241}}(e.color);return(0,a.jsxs)("div",{className:"relative mb-0.5 group ".concat(U===e.slug?"z-[200]":""),children:[(0,a.jsxs)("button",{className:"w-full rounded-sm text-left flex items-center transition-all duration-200 cursor-pointer\n ".concat(et?"py-3 px-3.5 justify-start gap-3":"py-2.5 px-0 justify-center gap-0","\n ").concat(t?"bg-surface border border-border":"bg-transparent border border-transparent hover:bg-surface"),onClick:()=>er(e),children:[(0,a.jsx)("div",{className:"rounded-full flex-shrink-0 transition-all duration-400\n ".concat(et?"w-2.5 h-2.5":"w-3 h-3","\n ").concat(o?"!bg-emerald-500 animate-dot-pulse":""),style:{"--dot-r":l.r,"--dot-g":l.g,"--dot-b":l.b,...o?{}:{background:e.color,boxShadow:t?"0 0 8px ".concat(e.color,"50"):"none"}}}),et&&(0,a.jsxs)("div",{className:"flex-1 min-w-0 pr-6",children:[(0,a.jsx)("div",{className:"text-sm font-medium whitespace-nowrap overflow-hidden text-ellipsis tracking-tight\n ".concat(t?"text-text":"text-text-secondary"),children:e.title}),e.workingDir?(0,a.jsxs)("button",{className:"text-label flex items-center gap-1 mt-0.5 whitespace-nowrap overflow-hidden text-ellipsis text-text-muted hover:text-accent transition-colors duration-150",onClick:t=>ed(t,e),title:"Open folder in explorer",children:[(0,a.jsx)(x,{size:10}),e.workingDir.split(/[/\\]/).slice(-2).join("/")]}):(0,a.jsxs)("button",{className:"text-label flex items-center gap-1 mt-0.5 text-warning hover:text-accent transition-colors duration-150",onClick:t=>{t.stopPropagation(),D({slug:e.slug,current:""})},title:"Click to set project folder",children:[(0,a.jsx)(x,{size:10})," Set folder"]})]})]}),et&&(0,a.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[e.workingDir&&(0,a.jsx)("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-sm text-text-muted bg-transparent transition-all duration-150 opacity-0 group-hover:opacity-100 hover:bg-surface hover:text-accent",onClick:t=>ed(t,e),title:"Open folder",children:(0,a.jsx)(x,{size:11})}),(0,a.jsx)("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-sm text-text-muted bg-transparent transition-all duration-150 opacity-0 group-hover:opacity-100 hover:bg-surface hover:text-text-secondary",onClick:t=>{t.stopPropagation(),B(U===e.slug?null:e.slug),q(null)},children:(0,a.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,a.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})})]}),U===e.slug&&et&&(0,a.jsxs)("div",{className:"absolute right-1 top-full mt-0.5 min-w-[160px] bg-glass backdrop-blur-[12px] backdrop-saturate-[160%] border border-glass-border rounded-md shadow-elevated z-[100] py-1 overflow-hidden animate-filter-in",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>{t.stopPropagation(),B(null),D({slug:e.slug,current:e.workingDir||""})},children:[(0,a.jsx)(x,{size:14})," ",e.workingDir?"Change Folder":"Set Folder"]}),e.workingDir&&(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>{t.stopPropagation(),B(null),ed(t,e)},children:[(0,a.jsx)(x,{size:14})," Open Folder"]}),(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>eo(t,e),children:[(0,a.jsx)(u,{size:14})," Archive"]}),(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 text-danger text-xs text-left transition-colors duration-100 bg-transparent hover:bg-danger-dim",onClick:t=>el(t,e),children:[(0,a.jsx)(p.Z,{size:14})," Move to Trash"]})]})]},e.id)}),eu.length>0&&et&&(0,a.jsxs)("div",{className:"mt-3 pt-2 border-t border-border/20",children:[(0,a.jsxs)("button",{className:"w-full flex items-center gap-1.5 px-2.5 py-1.5 text-[10px] font-medium uppercase tracking-wider text-text-muted/50 hover:text-text-muted transition-colors",onClick:()=>K(!O),children:[(0,a.jsx)(m.Z,{size:10,className:"transition-transform duration-200 ".concat(O?"rotate-90":"")}),(0,a.jsx)(u,{size:10}),"Archived (",eu.length,")"]}),O&&eu.map(e=>(0,a.jsxs)("div",{className:"relative mb-0.5 group opacity-50 hover:opacity-70 transition-opacity ".concat(U===e.slug?"z-[200]":""),children:[(0,a.jsxs)("button",{className:"w-full rounded-sm text-left flex items-center transition-all duration-200 cursor-pointer py-2 px-3.5 justify-start gap-3 bg-transparent border border-transparent hover:bg-surface",onClick:()=>er(e),children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:e.color}}),(0,a.jsx)("span",{className:"text-xs font-medium whitespace-nowrap overflow-hidden text-ellipsis tracking-tight text-text-secondary flex-1 min-w-0",children:e.title})]}),(0,a.jsx)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:(0,a.jsx)("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-sm text-text-muted bg-transparent transition-all duration-150 opacity-0 group-hover:opacity-100 hover:bg-surface hover:text-text-secondary",onClick:t=>{t.stopPropagation(),B(U===e.slug?null:e.slug),q(null)},children:(0,a.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,a.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})})}),U===e.slug&&(0,a.jsxs)("div",{className:"absolute right-1 top-full mt-0.5 min-w-[160px] bg-glass backdrop-blur-[12px] backdrop-saturate-[160%] border border-glass-border rounded-md shadow-elevated z-[100] py-1 overflow-hidden animate-filter-in",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>ec(t,e),children:[(0,a.jsx)(h.Z,{size:14})," Unarchive"]}),(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 text-danger text-xs text-left transition-colors duration-100 bg-transparent hover:bg-danger-dim",onClick:t=>el(t,e),children:[(0,a.jsx)(p.Z,{size:14})," Move to Trash"]})]})]},e.id))]}),ep.length>0&&et&&(0,a.jsxs)("div",{className:"mt-2 pt-2 border-t border-border/20",children:[(0,a.jsxs)("button",{className:"w-full flex items-center gap-1.5 px-2.5 py-1.5 text-[10px] font-medium uppercase tracking-wider text-text-muted/50 hover:text-text-muted transition-colors",onClick:()=>G(!W),children:[(0,a.jsx)(m.Z,{size:10,className:"transition-transform duration-200 ".concat(W?"rotate-90":"")}),(0,a.jsx)(p.Z,{size:10}),"Trash (",ep.length,")"]}),W&&ep.map(e=>(0,a.jsxs)("div",{className:"relative mb-0.5 group opacity-40 hover:opacity-60 transition-opacity ".concat(U===e.slug?"z-[200]":""),children:[(0,a.jsxs)("div",{className:"w-full rounded-sm text-left flex items-center py-2 px-3.5 justify-start gap-3",children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-full flex-shrink-0 opacity-50",style:{background:e.color}}),(0,a.jsx)("span",{className:"text-xs font-medium whitespace-nowrap overflow-hidden text-ellipsis tracking-tight text-text-muted line-through flex-1 min-w-0",children:e.title})]}),(0,a.jsx)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:(0,a.jsx)("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-sm text-text-muted bg-transparent transition-all duration-150 opacity-0 group-hover:opacity-100 hover:bg-surface hover:text-text-secondary",onClick:t=>{t.stopPropagation(),B(U===e.slug?null:e.slug),q(null)},children:(0,a.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,a.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})})}),U===e.slug&&(0,a.jsxs)("div",{className:"absolute right-1 top-full mt-0.5 min-w-[160px] bg-glass backdrop-blur-[12px] backdrop-saturate-[160%] border border-glass-border rounded-md shadow-elevated z-[100] py-1 overflow-hidden animate-filter-in",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 bg-transparent text-text-secondary text-xs text-left transition-colors duration-100 hover:bg-surface-hover",onClick:t=>ec(t,e),children:[(0,a.jsx)(h.Z,{size:14})," Restore"]}),(0,a.jsxs)("button",{className:"w-full py-2 px-3 flex items-center gap-2 text-xs text-left transition-colors duration-100\n ".concat(F===e.slug?"text-danger bg-danger-dim":"text-danger bg-transparent hover:bg-danger-dim"),onClick:t=>ei(t,e),children:[(0,a.jsx)(p.Z,{size:14})," ",F===e.slug?"Confirm Delete?":"Delete Permanently"]})]})]},e.id))]})]})}),(0,a.jsx)("div",{className:"border-t border-[rgba(148,163,242,0.03)] flex-shrink-0",children:(0,a.jsx)(H,{isExpanded:et})}),(0,a.jsxs)("div",{className:"border-t border-[rgba(148,163,242,0.03)] flex-shrink-0 flex items-center\n ".concat(et?"px-3 py-2.5 flex-row gap-1 justify-center":"px-0 py-3 flex-col gap-3 justify-center"),children:[(0,a.jsx)("button",{className:"inline-flex items-center justify-center w-7 h-7 rounded-sm text-text-muted transition-all duration-150 hover:text-accent hover:bg-accent-muted",onClick:()=>Z(!0),title:"Costs & Analytics",children:(0,a.jsx)(f,{size:14})}),(0,a.jsx)("button",{className:"inline-flex items-center justify-center w-7 h-7 rounded-sm text-text-muted transition-all duration-150 hover:text-text-secondary hover:bg-surface-hover",onClick:()=>I(!0),title:"Settings",children:(0,a.jsx)(b.Z,{size:14})}),(0,a.jsx)(N,{}),et&&(0,a.jsx)("span",{className:"text-data text-text-muted opacity-30 font-mono ml-auto",children:"H"})]})]}),E&&(0,a.jsx)(z,{onClose:()=>P(!1)}),R&&(0,a.jsx)(X,{currentPath:R.current,onSave:async e=>{try{await l(R.slug,{workingDir:e}),T("Folder linked","success")}catch(e){T("Failed to set folder","error")}D(null)},onClose:()=>D(null)}),_&&(0,a.jsx)(M,{onClose:()=>I(!1)}),A&&(0,a.jsx)("div",{className:"fixed inset-0 z-[200] bg-overlay backdrop-blur-[16px] backdrop-saturate-[180%] flex items-center justify-center animate-overlay-in",onClick:()=>Z(!1),children:(0,a.jsxs)("div",{className:"bg-modal border border-glass-border rounded-lg shadow-modal max-w-[800px] w-[95%] max-h-[85vh] overflow-hidden animate-spring-pop",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border",children:[(0,a.jsxs)("span",{className:"text-h2 font-semibold flex items-center gap-2",children:[(0,a.jsx)(f,{size:16})," Costs & Analytics"]}),(0,a.jsx)("button",{className:"btn-icon",onClick:()=>Z(!1),children:(0,a.jsx)("span",{className:"text-text-muted",children:"\xd7"})})]}),(0,a.jsx)("div",{className:"overflow-y-auto max-h-[calc(85vh-52px)]",children:(0,a.jsx)(L,{projectSlug:i||void 0})})]})})]})}function X(e){let{currentPath:t,onSave:s,onClose:r}=e,[o,l]=(0,n.useState)(t),i=(0,n.useRef)(null);return(0,n.useEffect)(()=>{var e,t;null===(e=i.current)||void 0===e||e.focus(),null===(t=i.current)||void 0===t||t.select()},[]),(0,a.jsx)("div",{className:"fixed inset-0 z-[200] bg-overlay backdrop-blur-[16px] backdrop-saturate-[180%] flex items-center justify-center animate-overlay-in",onClick:r,children:(0,a.jsxs)("div",{className:"bg-modal border border-glass-border rounded-lg shadow-modal max-w-[440px] w-[92%] animate-spring-pop relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("div",{className:"absolute top-0 left-[15%] right-[15%] h-px pointer-events-none",style:{background:"linear-gradient(90deg, transparent, rgba(129, 140, 248, 0.2), transparent)"}}),(0,a.jsxs)("div",{className:"px-6 pt-5 pb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,a.jsx)(x,{size:16,className:"text-accent"}),(0,a.jsx)("span",{className:"text-h2 font-semibold tracking-tight",children:t?"Change Folder":"Link Project Folder"})]}),(0,a.jsx)("p",{className:"text-label text-text-muted leading-relaxed",children:"Set the local directory where this project's code lives. Ralph and the terminal will use this path."})]}),(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),o.trim()&&s(o.trim())},className:"px-6 pb-5 flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("label",{className:"text-data font-semibold text-text-muted uppercase tracking-widest font-mono",children:"Folder Path"}),(0,a.jsx)("input",{ref:i,value:o,onChange:e=>l(e.target.value),placeholder:"C:\\Users\\marti\\projects\\my-app",className:"w-full font-mono text-xs",spellCheck:!1})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)("button",{type:"button",className:"btn-ghost",onClick:r,children:"Cancel"}),(0,a.jsxs)("button",{type:"submit",className:"btn-primary",disabled:!o.trim(),children:[(0,a.jsx)(x,{size:12})," ",t?"Update":"Link Folder"]})]})]})]})})}var $=s(401);let Q=(0,i.Z)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),Y=(0,i.Z)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),ee={success:{accent:"border-l-success",iconColor:"text-success",icon:(0,a.jsx)($.Z,{size:14})},error:{accent:"border-l-danger",iconColor:"text-danger",icon:(0,a.jsx)(Q,{size:14})},info:{accent:"border-l-accent",iconColor:"text-accent",icon:(0,a.jsx)(Y,{size:14})}};function et(){let{toasts:e,removeToast:t}=(0,y.E)();return 0===e.length?null:(0,a.jsx)("div",{className:"fixed bottom-4 right-4 flex flex-col gap-1.5 z-[400] pointer-events-none",children:e.map((s,n)=>{let r=ee[s.type]||ee.info,o=n<e.length-1;return(0,a.jsxs)("div",{className:"bg-glass backdrop-blur-[16px] backdrop-saturate-[160%] border border-glass-border rounded-md\n px-3.5 py-2.5 text-xs font-medium text-text shadow-elevated\n flex items-center gap-2.5 animate-toast-in pointer-events-auto min-w-[220px]\n relative overflow-hidden border-l-2 ".concat(r.accent,"\n transition-all duration-200 ease-out-expo\n ").concat(o?"scale-[0.97] opacity-80":""),children:[(0,a.jsx)("div",{className:"absolute top-0 left-[15%] right-[15%] h-px bg-gradient-to-r from-transparent via-white/[0.04] to-transparent pointer-events-none"}),(0,a.jsx)("span",{className:"flex flex-shrink-0 ".concat(r.iconColor),children:r.icon}),(0,a.jsx)("span",{className:"flex-1",children:s.message}),(0,a.jsx)("button",{className:"text-text-muted p-0.5 flex rounded-xs transition-all duration-120 ease-out-expo hover:text-text hover:bg-surface-hover",onClick:()=>t(s.id),children:(0,a.jsx)(w.Z,{size:12})})]},s.id)})})}let es=[{title:"Navigation",shortcuts:[{keys:["↑","↓"],desc:"Previous / next project"},{keys:["B"],desc:"Board view"},{keys:["C"],desc:"Console / Terminal"},{keys:["R"],desc:"Ralph / Agents"},{keys:["S"],desc:"Soul"}]},{title:"Actions",shortcuts:[{keys:["N"],desc:"New task"},{keys:["Ctrl","F"],desc:"Toggle filter bar"}]},{title:"General",shortcuts:[{keys:["H"],desc:"Show this help"},{keys:["Esc"],desc:"Close modal / go back"}]}];function ea(e){let{onClose:t}=e,{overlayProps:s}=(0,C.N)(t);return(0,a.jsx)("div",{className:"glass-overlay",...s,children:(0,a.jsxs)("div",{className:"modal-box w-[400px] max-w-[90%] p-7",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,a.jsx)("span",{className:"text-h2 font-semibold tracking-tight",children:"Keyboard Shortcuts"}),(0,a.jsx)("button",{className:"btn-icon",onClick:t,children:(0,a.jsx)(w.Z,{size:16})})]}),(0,a.jsx)("div",{className:"flex flex-col gap-[22px]",children:es.map(e=>(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("div",{className:"text-xxs font-semibold text-text-muted uppercase tracking-widest font-mono mb-1",children:e.title}),e.shortcuts.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between py-1",children:[(0,a.jsx)("div",{className:"flex items-center gap-[3px]",children:e.keys.map((t,s)=>(0,a.jsxs)("span",{children:[(0,a.jsx)("kbd",{className:"inline-flex items-center justify-center min-w-[24px] h-6 px-[7px] bg-[rgba(148,163,242,0.04)] border border-[rgba(148,163,242,0.08)] border-b-2 border-b-[rgba(148,163,242,0.1)] rounded-[5px] text-[10px] font-semibold text-text font-mono",children:t}),s<e.keys.length-1&&(0,a.jsx)("span",{className:"text-xxs text-text-muted opacity-50",children:"+"})]},s))}),(0,a.jsx)("span",{className:"text-xs text-text-secondary",children:e.desc})]},e.desc))]},e.title))})]})})}let en=(0,i.Z)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),er=(0,i.Z)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),eo=(0,i.Z)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);var el=s(3468),ei=s(2222),ec=s(221),ed=s(5805),ex=s(2208),eu=s(3247),ep=s(15);function em(e){let{onClose:t,onShowCreateProject:s,onShowCreateWorkItem:r,onShowHelp:o}=e,[i,c]=(0,n.useState)(""),[u,p]=(0,n.useState)(0),m=(0,n.useRef)(null),h=(0,n.useRef)(null),f=(0,g.i)(e=>e.projects),b=(0,ep.o)(e=>e.workItems),{goToProject:j,goToWorkItem:y,setView:k,projectSlug:N,workItemSlug:w}=(0,v.U)(),{theme:C,toggleTheme:S}=l(),T=(0,n.useMemo)(()=>{let e=[];return e.push({id:"create-project",label:"Create Project",section:"Actions",icon:(0,a.jsx)(d.Z,{size:14}),action:()=>{t(),null==s||s()}}),N&&e.push({id:"create-wi",label:"Create Work Item",section:"Actions",icon:(0,a.jsx)(d.Z,{size:14}),action:()=>{t(),null==r||r()}}),e.push({id:"toggle-theme",label:"Switch to ".concat("dark"===C?"Light":"Dark"," mode"),section:"Actions",icon:"dark"===C?(0,a.jsx)(en,{size:14}):(0,a.jsx)(er,{size:14}),action:()=>{S(),t()}}),e.push({id:"keyboard-shortcuts",label:"Keyboard Shortcuts",section:"Actions",icon:(0,a.jsx)(eo,{size:14}),shortcut:"H",action:()=>{t(),null==o||o()}}),N&&(w?[{key:"board",label:"Go to Board",icon:(0,a.jsx)(el.Z,{size:14}),shortcut:"B"},{key:"ralph",label:"Go to Ralph",icon:(0,a.jsx)(ei.Z,{size:14}),shortcut:"R"}]:[{key:"work-items",label:"Go to Work Items",icon:(0,a.jsx)(el.Z,{size:14}),shortcut:"W"},{key:"console",label:"Go to Console",icon:(0,a.jsx)(ec.Z,{size:14}),shortcut:"C"},{key:"teams",label:"Go to Teams",icon:(0,a.jsx)(ed.Z,{size:14}),shortcut:"T"},{key:"soul",label:"Go to Soul",icon:(0,a.jsx)(ex.Z,{size:14}),shortcut:"S"}]).forEach(s=>{e.push({id:"nav-".concat(s.key),label:s.label,section:"Navigation",icon:s.icon,shortcut:s.shortcut,action:()=>{k(s.key),t()}})}),f.forEach(s=>{e.push({id:"project-".concat(s.slug),label:s.title,section:"Projects",icon:(0,a.jsx)(x,{size:14}),action:()=>{j(s.slug),t()}})}),N&&b.forEach(s=>{e.push({id:"wi-".concat(s.slug),label:s.title,section:"Work Items",icon:(0,a.jsx)(Z.Z,{size:14}),action:()=>{y(N,s.slug),t()}})}),e},[f,b,N,C,t,s,r,o,j,y,k,S]),z=(0,n.useMemo)(()=>{if(!i.trim())return T;let e=i.toLowerCase();return T.filter(t=>t.label.toLowerCase().includes(e)||t.section.toLowerCase().includes(e))},[T,i]);(0,n.useEffect)(()=>{p(0)},[z.length]),(0,n.useEffect)(()=>{var e;null===(e=m.current)||void 0===e||e.focus()},[]);let E=(0,n.useCallback)(e=>{"ArrowDown"===e.key?(e.preventDefault(),p(e=>Math.min(e+1,z.length-1))):"ArrowUp"===e.key?(e.preventDefault(),p(e=>Math.max(e-1,0))):"Enter"===e.key&&z[u]?(e.preventDefault(),z[u].action()):"Escape"===e.key&&t()},[z,u,t]);(0,n.useEffect)(()=>{var e;let t=null===(e=h.current)||void 0===e?void 0:e.querySelector('[data-selected="true"]');null==t||t.scrollIntoView({block:"nearest"})},[u]);let P=(0,n.useMemo)(()=>{let e=new Map;return z.forEach(t=>{let s=e.get(t.section)||[];s.push(t),e.set(t.section,s)}),e},[z]),M=-1;return(0,a.jsx)("div",{className:"fixed inset-0 z-[500] flex items-start justify-center pt-[20vh] animate-overlay-in",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(8px)"},onClick:t,children:(0,a.jsxs)("div",{className:"w-full max-w-[520px] bg-modal rounded-xl overflow-hidden shadow-modal animate-spring-pop border border-glass-border relative",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("div",{className:"absolute top-0 left-[15%] right-[15%] h-px bg-gradient-to-r from-transparent via-[rgba(129,140,248,0.2)] to-transparent pointer-events-none z-10"}),(0,a.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[(0,a.jsx)(eu.Z,{size:16,className:"text-text-muted flex-shrink-0"}),(0,a.jsx)("input",{ref:m,type:"text",value:i,onChange:e=>c(e.target.value),onKeyDown:E,placeholder:"Type a command or search...",className:"flex-1 bg-transparent border-none outline-none text-body text-text placeholder:text-text-muted p-0 shadow-none"}),(0,a.jsx)("kbd",{className:"text-data font-mono text-text-muted bg-surface px-1.5 py-0.5 rounded border border-border",children:"ESC"})]}),(0,a.jsx)("div",{ref:h,className:"max-h-[320px] overflow-y-auto py-1",children:0===z.length?(0,a.jsx)("div",{className:"px-4 py-8 text-center text-text-muted text-xs",children:"No results found"}):Array.from(P.entries()).map(e=>{let[t,s]=e;return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"px-4 pt-2 pb-1 text-xxs font-semibold text-text-muted uppercase tracking-[0.08em]",children:t}),s.map(e=>{let t=++M===u,s=M;return(0,a.jsxs)("button",{"data-selected":t,className:"w-full flex items-center gap-3 px-4 py-2 text-xs text-left transition-colors duration-75\n ".concat(t?"bg-accent-muted text-text":"text-text-secondary hover:bg-surface-hover hover:text-text"),onClick:e.action,onMouseEnter:()=>p(s),children:[(0,a.jsx)("span",{className:"flex-shrink-0 ".concat(t?"text-accent":"text-text-muted"),children:e.icon}),(0,a.jsx)("span",{className:"flex-1 truncate",children:e.label}),e.shortcut&&(0,a.jsx)("kbd",{className:"text-data font-mono text-text-muted bg-surface px-1.5 py-0.5 rounded border border-border",children:e.shortcut})]},e.id)})]},t)})})]})})}var eh=s(4822);let ef=(0,i.Z)("skip-forward",[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]]);var eb=s(1094),eg=s(4743);let ev=s(257).env.NEXT_PUBLIC_API_URL||"http://localhost:5555";function ej(){let e=(0,j.q)(e=>e.escalation),t=(0,y.E)(e=>e.addToast),[s,r]=(0,n.useState)(""),[o,l]=(0,n.useState)(!1),i=(0,n.useRef)(null);if((0,n.useEffect)(()=>{e&&(r(""),setTimeout(()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.focus()},100),"undefined"!=typeof Notification&&("granted"===Notification.permission?new Notification("KANBAII — ".concat("ralph"===e.source?"Ralph":"Teams"," needs input"),{body:e.question.slice(0,120),icon:"/favicon.svg"}):"denied"!==Notification.permission&&Notification.requestPermission()))},[e]),!e||"planner"===e.source)return null;let c=async a=>{let n=a||s.trim();if(n&&!o){l(!0);try{await fetch("".concat(ev,"/api/escalation/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,response:n})}),t("Response sent to Claude","success")}catch(e){t("Failed to send response","error")}l(!1)}},d="ralph"===e.source,x=d?eh.Z:ed.Z,u=d?"Ralph":"Teams",p=function(e){try{let t=JSON.parse(e);if(t.questions&&Array.isArray(t.questions)&&t.questions.length>0){let s=t.questions[0];return{question:s.question||s.header||e,options:(s.options||[]).map(e=>({label:"string"==typeof e?e:e.label||e.text||"",description:e.description}))}}if(t.question)return{question:t.question,options:(t.options||[]).map(e=>({label:"string"==typeof e?e:e.label||""}))}}catch(e){}return{question:e,options:[]}}(e.question),m=p.question,h=p.options.length>0?p.options:e.options;return(0,a.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center animate-overlay-in",style:{background:"rgba(3, 3, 8, 0.85)",backdropFilter:"blur(20px) saturate(180%)"},children:(0,a.jsxs)("div",{className:"max-w-[520px] w-[94%] animate-spring-pop relative",children:[(0,a.jsx)("div",{className:"absolute -inset-px rounded-lg animate-breathe",style:{background:d?"linear-gradient(135deg, rgba(99,102,241,0.3), rgba(129,140,248,0.1), rgba(99,102,241,0.3))":"linear-gradient(135deg, rgba(16,185,129,0.3), rgba(52,211,153,0.1), rgba(16,185,129,0.3))"}}),(0,a.jsxs)("div",{className:"relative bg-modal border border-glass-border rounded-lg shadow-modal overflow-hidden",children:[(0,a.jsx)("div",{className:"absolute top-0 left-[10%] right-[10%] h-px pointer-events-none",style:{background:d?"linear-gradient(90deg, transparent, rgba(99,102,241,0.4), transparent)":"linear-gradient(90deg, transparent, rgba(52,211,153,0.4), transparent)"}}),(0,a.jsxs)("div",{className:"flex items-center gap-3 px-6 pt-5 pb-3",children:[(0,a.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center animate-breathe\n ".concat(d?"bg-accent-muted border border-accent/20":"bg-success-dim border border-success/20"),children:(0,a.jsx)(x,{size:16,className:d?"text-accent":"text-success"})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-sm font-semibold text-text tracking-tight",children:[u," needs your input"]}),e.taskTitle&&(0,a.jsxs)("div",{className:"text-xxs text-text-muted font-mono mt-0.5",children:["Task: ",e.taskTitle]})]})]}),(0,a.jsx)("div",{className:"mx-6 mb-4 p-3 bg-bg border border-border rounded-md shadow-inset",children:(0,a.jsx)("div",{className:"text-sm text-text leading-relaxed",children:m})}),h.length>0&&(0,a.jsx)("div",{className:"mx-6 mb-3 flex flex-col gap-1.5",children:h.map((e,t)=>(0,a.jsxs)("button",{className:"flex flex-col gap-0.5 px-3 py-2.5 text-left rounded-sm border border-border transition-all duration-150 hover:border-accent hover:bg-accent-muted group",onClick:()=>c("string"==typeof e?e:e.label),disabled:o,children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text group-hover:text-accent transition-colors",children:"string"==typeof e?e:e.label}),"string"!=typeof e&&e.description&&(0,a.jsx)("span",{className:"text-xxs text-text-muted leading-snug",children:e.description})]},t))}),(0,a.jsxs)("div",{className:"px-6 pb-5",children:[(0,a.jsx)("textarea",{ref:i,value:s,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),c())},placeholder:"Type your response... (Enter to send)",rows:2,className:"w-full resize-none text-xs",disabled:o}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-3",children:[(0,a.jsxs)("button",{className:"inline-flex items-center gap-1.5 text-xxs text-text-muted font-mono px-3 py-1.5 rounded-sm border border-border transition-all duration-150 hover:text-text-secondary hover:bg-surface-hover",onClick:()=>c("yes"),disabled:o,children:[(0,a.jsx)(ef,{size:11})," Skip (yes)"]}),(0,a.jsxs)("button",{className:"inline-flex items-center gap-1.5 text-xxs text-danger font-mono px-3 py-1.5 rounded-sm border border-danger/20 transition-all duration-150 hover:bg-danger-dim",onClick:async()=>{await fetch(d?"".concat(ev,"/api/ralph/stop"):"".concat(ev,"/api/teams/stop"),{method:"POST"}),c("STOP"),t("".concat(u," stopped"),"info")},disabled:o,children:[(0,a.jsx)(eb.Z,{size:11})," Stop ",u]}),(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsxs)("button",{className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-white text-xs font-semibold rounded-sm\n bg-gradient-to-br ".concat(d?"from-indigo-600 to-indigo-400":"from-emerald-600 to-emerald-400","\n relative overflow-hidden\n before:absolute before:inset-0 before:bg-gradient-to-b before:from-white/15 before:to-transparent before:pointer-events-none\n transition-all duration-150 hover:shadow-glow-accent hover:-translate-y-px disabled:opacity-40"),onClick:()=>c(),disabled:!s.trim()||o,children:[o?(0,a.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-white/20 border-t-white rounded-full animate-spin"}):(0,a.jsx)(eg.Z,{size:12}),"Send"]})]})]})]})]})})}function ey(e){let{children:t}=e;!function(){let e=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(e.current)return;e.current=!0;let t=(0,B.h)(),s=j.q.getState,a=g.i.getState,n=ep.o.getState;return t.on("project:updated",e=>{let{project:t}=e;return a().onProjectUpdated(t)}),t.on("project:deleted",e=>{let{slug:t}=e;return a().onProjectDeleted(t)}),t.on("workItem:updated",e=>{let{projectSlug:t,workItem:s}=e;return n().onWorkItemUpdated(t,s)}),t.on("workItem:deleted",e=>{let{projectSlug:t,workItemId:s}=e;return n().onWorkItemDeleted(t,s)}),t.on("ralph:started",e=>s().onRalphStarted(e)),t.on("ralph:progress",e=>s().onRalphProgress(e)),t.on("ralph:output",e=>s().onRalphOutput(e)),t.on("ralph:completed",e=>s().onRalphCompleted(e)),t.on("ralph:error",e=>s().onRalphError(e)),t.on("ralph:input-needed",e=>s().onRalphInputNeeded(e)),t.on("live:started",e=>s().onTeamsStarted(e)),t.on("live:worker-assigned",e=>s().onTeamsWorkerAssigned(e)),t.on("live:worker-completed",e=>s().onTeamsWorkerCompleted(e)),t.on("live:metrics",e=>s().onTeamsMetrics(e)),t.on("live:output",e=>s().onTeamsOutput(e)),t.on("live:stopped",e=>s().onTeamsStopped(e)),t.on("teams:input-needed",e=>s().onTeamsInputNeeded(e)),t.on("coordinator:thinking",e=>s().onCoordinatorThinking(e)),t.on("coordinator:tool_call",e=>s().onCoordinatorToolCall(e)),t.on("coordinator:completed",e=>s().onCoordinatorCompleted(e)),t.on("escalation:created",e=>{if("planner"===e.source){s().onPlannerEscalation({id:e.id,source:"planner",taskId:e.taskId||"planner",taskTitle:e.taskTitle||"AI Planner",question:e.question,options:e.options||[],timeoutMs:e.timeoutMs||18e5});return}s().onEscalationCreated(e)}),t.on("escalation:responded",e=>{s().planner.escalation?s().onPlannerEscalationResponded((null==e?void 0:e.response)||"responded"):s().onEscalationResponded()}),t.on("escalation:timeout",()=>{s().planner.escalation?s().onPlannerEscalationResponded("(timed out)"):s().onEscalationTimeout()}),t.on("planner:started",e=>s().onPlannerStarted(e)),t.on("planner:message",e=>s().onPlannerMessage(e)),t.on("planner:item-discovered",e=>s().onPlannerItemDiscovered(e)),t.on("planner:item-updated",e=>s().onPlannerItemUpdated(e)),t.on("planner:escalation",e=>s().onPlannerEscalation(e)),t.on("planner:item-approved",e=>s().onPlannerItemApproved(e)),t.on("planner:stopped",()=>s().onPlannerStopped()),t.on("terminal:output",e=>{let t=v.U.getState().projectSlug;e.projectSlug&&e.projectSlug!==t||(s().appendTerminalOutput(e.text),s().setTerminalStatus("running"))}),t.on("terminal:closed",e=>{let t=v.U.getState().projectSlug;null!=e&&e.projectSlug&&e.projectSlug!==t||s().setTerminalStatus("idle")}),t.on("terminal:error",e=>{let t=v.U.getState().projectSlug;null!=e&&e.projectSlug&&e.projectSlug!==t||(s().appendTerminalOutput("ERROR: ".concat(e.message)),s().setTerminalStatus("error"))}),s().rehydrate(),t.on("connect",()=>s().rehydrate()),()=>{(0,B.l)(),e.current=!1}},[])}();let[s,r]=(0,n.useState)(!1),[o,l]=(0,n.useState)(!1),i=(0,n.useCallback)(()=>r(e=>!e),[]),c=(0,n.useCallback)(()=>r(!1),[]),d=(0,n.useCallback)(()=>l(e=>!e),[]),x=(0,n.useCallback)(()=>l(!1),[]);return!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{projectSlug:t,workItemSlug:s,setView:a,goToProject:r}=(0,v.U)(),o=(0,g.i)(e=>e.projects);(0,n.useEffect)(()=>{let n=n=>{var l,i,c,d,x;let u=n.target.tagName;if("INPUT"!==u&&"TEXTAREA"!==u&&"SELECT"!==u&&!n.target.isContentEditable){if((n.ctrlKey||n.metaKey)&&"k"===n.key){n.preventDefault(),null===(l=e.onToggleCommandPalette)||void 0===l||l.call(e);return}if((n.ctrlKey||n.metaKey)&&"f"===n.key){n.preventDefault(),null===(i=e.onToggleFilter)||void 0===i||i.call(e);return}if(!n.ctrlKey&&!n.metaKey&&!n.altKey)switch(n.key.toLowerCase()){case"w":t&&!s&&a("work-items");break;case"c":t&&!s&&a("console");break;case"t":t&&!s&&a("teams");break;case"s":t&&!s&&a("soul");break;case"b":s&&a("board");break;case"r":s&&a("ralph");break;case"n":null===(c=e.onNewTask)||void 0===c||c.call(e);break;case"h":null===(d=e.onToggleHelp)||void 0===d||d.call(e);break;case"escape":null===(x=e.onEscape)||void 0===x||x.call(e);break;case"arrowup":{n.preventDefault();let e=o.findIndex(e=>e.slug===t);e>0&&r(o[e-1].slug);break}case"arrowdown":{n.preventDefault();let e=o.findIndex(e=>e.slug===t);e<o.length-1&&r(o[e+1].slug)}}}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t,s,o,a,r,e])}({onToggleHelp:i,onToggleCommandPalette:d,onEscape:()=>{o?x():c()}}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex h-screen w-screen overflow-hidden",children:[(0,a.jsx)(J,{}),(0,a.jsx)("div",{className:"w-px flex-shrink-0 bg-gradient-to-b from-transparent via-border-glow to-transparent"}),(0,a.jsx)("main",{className:"flex-1 overflow-hidden flex flex-col surface-gradient",children:t})]}),(0,a.jsx)(et,{}),(0,a.jsx)(ej,{}),s&&(0,a.jsx)(ea,{onClose:c}),o&&(0,a.jsx)(em,{onClose:x,onShowHelp:()=>{x(),i()}})]})}function ek(e){let{children:t}=e;return(0,a.jsx)(o,{children:(0,a.jsx)(ey,{children:t})})}},7960:function(){}},function(e){e.O(0,[587,184,23,971,117,744],function(){return e(e.s=4732)}),_N_E=e.O()}]);