const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-page-B7b2m1KH.js","assets/index-CUDottTv.js","assets/index-e2kYo9r7.css","assets/tabs-BoJRkfaU.js","assets/textarea-DAwdLdON.js","assets/overview-page-j5X9SBqW.js","assets/zap-D8s7B8fi.js","assets/metric-card-DE3zVnFg.js","assets/sparkline-BYGr_Iny.js","assets/minus-BzY257S7.js","assets/wifi-B9CHDUUG.js","assets/clock-CmDPWLyG.js","assets/hard-drive-D8jrlixH.js","assets/use-connected-3Ljk-Uwv.js","assets/issue-detector-CH2FjMfV.js","assets/network-page-CiQu5Dem.js","assets/topbar-892TvyNb.js","assets/badge-BOfEUuSW.js","assets/data-table-A2Iq_hk5.js","assets/detail-panel-YWSVnqP_.js","assets/filter-bar-CP39inkf.js","assets/status-dot-C1nxHZIG.js","assets/download-CwvkYJyJ.js","assets/export-button-D7y2ugNf.js","assets/format-CF_gowqw.js","assets/console-page-B3sYOQK9.js","assets/json-viewer-Dup5M0px.js","assets/chevron-right-Df1qu9CE.js","assets/info-C0v7mgTM.js","assets/renders-page-C9THhZZ3.js","assets/empty-config-state-ReVUjdJ_.js","assets/state-page-CQDLPZ5t.js","assets/performance-page-ImE9xvEt.js","assets/issues-page-8abUxnvT.js","assets/api-map-page-Btbazs5z.js","assets/database-page-DYOGNtgK.js","assets/code-block-D47Pz1qB.js","assets/processes-page-BIMoApg0.js","assets/square-C1plLKPb.js","assets/infra-page-Cwb8--Fc.js","assets/sessions-page-BYNnSmUH.js","assets/events-page-d6_fhDSn.js","assets/breadcrumbs-page-ahYuYyrd.js","assets/tag-Czqgl1tA.js","assets/play-Cx2BEZVZ.js","assets/tasks-page-sjVxAPDG.js","assets/folder-open-D-HQTMMw.js","assets/file-text-h8kcLd2l.js","assets/circle-check-big-Dd6W5_do.js","assets/trash-2-C4Tvwfqn.js","assets/sessions-page-VWQ2b-LR.js","assets/message-square-Dwj0jRjI.js","assets/dollar-sign-BDj484XE.js","assets/notes-page-XazIKqZP.js","assets/memory-page-CnpiwsEL.js","assets/save-BGeL2PJM.js","assets/rules-page-CBgSauuM.js","assets/capex-page-H_aV7VU6.js","assets/git-page-5wVisusM.js","assets/sdk-page-C2D4FU-Y.js"])))=>i.map(i=>d[i]);
import{a as k,u as j,b as x,j as e,E as A,r as o,L as R,C as z,c as _,f as I,X as D,P as w,d as y,e as T,g as O,s as V,h as M,i as q,_ as f}from"./index-CUDottTv.js";import{B as C}from"./badge-BOfEUuSW.js";import"./textarea-DAwdLdON.js";import{S}from"./status-dot-C1nxHZIG.js";import{T as K}from"./tag-Czqgl1tA.js";import{S as E}from"./square-C1plLKPb.js";import{P as B}from"./play-Cx2BEZVZ.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $=k("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const L=k("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const H=k("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),G=o.lazy(()=>f(()=>import("./runtime-page-B7b2m1KH.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44])).then(t=>({default:t.RuntimePage}))),U=o.lazy(()=>f(()=>import("./tasks-page-sjVxAPDG.js"),__vite__mapDeps([45,1,2,17,4,46,22,47,48,49,21,43,38,44])).then(t=>({default:t.TasksPage}))),X=o.lazy(()=>f(()=>import("./sessions-page-VWQ2b-LR.js"),__vite__mapDeps([50,1,2,17,4,18,19,7,8,9,51,52,11,6])).then(t=>({default:t.PmSessionsPage}))),F=o.lazy(()=>f(()=>import("./notes-page-XazIKqZP.js"),__vite__mapDeps([53,1,2,4,49])).then(t=>({default:t.NotesPage}))),J=o.lazy(()=>f(()=>import("./memory-page-CnpiwsEL.js"),__vite__mapDeps([54,1,2,4,47,22,49,55])).then(t=>({default:t.MemoryPage}))),Q=o.lazy(()=>f(()=>import("./rules-page-CBgSauuM.js"),__vite__mapDeps([56,1,2,4,3,47,55])).then(t=>({default:t.RulesPage}))),W=o.lazy(()=>f(()=>import("./capex-page-H_aV7VU6.js"),__vite__mapDeps([57,1,2,17,4,18,7,8,9,48,22,11,52])).then(t=>({default:t.CapexPage}))),Y=o.lazy(()=>f(()=>import("./git-page-5wVisusM.js"),__vite__mapDeps([58,1,2,4,46,9,27,17,21,43,38,44])).then(t=>({default:t.GitPage}))),Z=o.lazy(()=>f(()=>import("./sdk-page-C2D4FU-Y.js"),__vite__mapDeps([59,1,2,17,4,21,10])).then(t=>({default:t.SdkPage})));function ee({projectId:t,category:a}){const[r,i]=o.useState(!1),[u,g]=o.useState(""),h=x(l=>l.categories),c=o.useRef(null);o.useEffect(()=>{function l(b){c.current&&!c.current.contains(b.target)&&i(!1)}return r&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]);const d=l=>{x.getState().updateProject(t,{category:l??void 0}),i(!1)},p=()=>{const l=u.trim();l&&(x.getState().updateProject(t,{category:l}),x.getState().fetchCategories(),g(""),i(!1))};return e.jsxs("div",{ref:c,className:"relative inline-block",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),className:_("inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium transition-colors cursor-pointer",a?"bg-purple-500/15 text-purple-400 hover:bg-purple-500/25":"bg-bg-surface text-text-muted hover:bg-bg-hover"),children:[e.jsx(K,{size:10}),a||"Uncategorized",e.jsx(z,{size:10})]}),r&&e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 w-48 rounded-lg border border-border-default bg-bg-elevated shadow-lg overflow-hidden",children:[e.jsxs("div",{className:"py-1",children:[a&&e.jsx("button",{type:"button",onClick:()=>d(null),className:"w-full px-3 py-1.5 text-left text-xs text-text-muted hover:bg-bg-hover cursor-pointer",children:"Remove category"}),h.map(l=>e.jsx("button",{type:"button",onClick:()=>d(l),className:_("w-full px-3 py-1.5 text-left text-xs hover:bg-bg-hover cursor-pointer",l===a?"text-accent font-medium":"text-text-primary"),children:l},l))]}),e.jsxs("div",{className:"border-t border-border-muted px-3 py-2 flex gap-1.5",children:[e.jsx("input",{type:"text",value:u,onChange:l=>g(l.target.value),onKeyDown:l=>l.key==="Enter"&&p(),placeholder:"New category...",className:"flex-1 bg-transparent text-xs text-text-primary placeholder:text-text-muted outline-none"}),u.trim()&&e.jsx("button",{type:"button",onClick:p,className:"text-xs text-accent font-medium cursor-pointer",children:"Add"})]})]})]})}function te({project:t}){const a=j(m=>m.projects),r=y(m=>m.servers.get(t.id)),[i,u]=o.useState(!1),g=o.useRef(!1),h=T(a,{runtimescopeProject:t.runtimescopeProject,runtimeApps:t.runtimeApps,name:t.name}),c=!!(h!=null&&h.isConnected),d=r==null?void 0:r.status,p=(r==null?void 0:r.port)??null,b=c||(d==="running"||d==="starting");o.useEffect(()=>{p&&!g.current&&d==="running"&&(g.current=!0,window.open(`http://localhost:${p}`,"_blank")),(d==="idle"||d==="stopped"||d==="crashed")&&(g.current=!1)},[p,d]);const v=o.useCallback(async()=>{u(!0),y.getState().setOptimisticStarting(t.id);try{const m=await O(t.id);await V(t.id,{script:(m==null?void 0:m.recommended)??"dev"}),M()}catch{y.getState().setStatus(t.id,"idle")}u(!1)},[t.id]),P=o.useCallback(async()=>{u(!0);try{await q(t.id),y.getState().setStatus(t.id,"stopped")}catch{}u(!1)},[t.id]);return t.path?d==="starting"?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(C,{variant:"amber",size:"sm",children:[e.jsx(H,{size:10,className:"animate-spin"}),"Starting..."]}),e.jsx("button",{type:"button",onClick:P,disabled:i,className:"p-1 rounded hover:bg-bg-hover text-text-muted hover:text-red transition-colors cursor-pointer",title:"Stop dev server",children:e.jsx(E,{size:12})})]}):b?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(C,{variant:"green",size:"sm",children:[e.jsx(S,{color:"green",size:"sm",pulse:!0}),p?`Running on :${p}`:"Running"]}),p&&e.jsx("a",{href:`http://localhost:${p}`,target:"_blank",rel:"noopener noreferrer",className:"p-1 rounded hover:bg-bg-hover text-text-muted hover:text-accent transition-colors",title:"Open in browser",children:e.jsx($,{size:12})}),e.jsx("button",{type:"button",onClick:P,disabled:i,className:"p-1 rounded hover:bg-bg-hover text-text-muted hover:text-red transition-colors cursor-pointer",title:"Stop dev server",children:e.jsx(E,{size:12})})]}):t.sdkInstalled?e.jsxs("button",{type:"button",onClick:v,disabled:i,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-bg-surface text-text-muted hover:bg-bg-hover hover:text-text-primary transition-colors cursor-pointer",children:[e.jsx(B,{size:10}),i?"Starting...":"Start"]}):null:null}function se({project:t}){const[a,r]=o.useState(!1),[i,u]=o.useState(""),g=j(s=>s.projects),h=o.useRef(null),c=t.runtimeApps??(t.runtimescopeProject?[t.runtimescopeProject]:[]),d=I(g,{runtimescopeProject:t.runtimescopeProject,runtimeApps:t.runtimeApps,name:t.name});o.useEffect(()=>{function s(n){h.current&&!h.current.contains(n.target)&&r(!1)}return a&&document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[a]);const p=()=>{const s=i.trim();if(!s||c.includes(s))return;const n=[...c,s];x.getState().updateProject(t.id,{runtimeApps:n}),u("")},l=s=>{const n=c.filter(N=>N!==s);x.getState().updateProject(t.id,{runtimeApps:n.length?n:void 0})},b=d.filter(s=>s.isConnected),v=g.filter(s=>!c.some(n=>n.toLowerCase()===s.appName.toLowerCase())),m=x.getState().projects.filter(s=>s.id!==t.id&&(s.sdkInstalled||s.runtimescopeProject)).map(s=>s.runtimescopeProject??s.name).filter(s=>!c.some(n=>n.toLowerCase()===s.toLowerCase())&&!v.some(n=>n.appName.toLowerCase()===s.toLowerCase()));return c.length===0&&!a?e.jsxs("button",{type:"button",onClick:()=>r(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-bg-surface text-text-muted hover:bg-bg-hover transition-colors cursor-pointer",children:[e.jsx(L,{size:10}),"Link Apps"]}):e.jsxs("div",{ref:h,className:"relative inline-block",children:[e.jsxs("button",{type:"button",onClick:()=>r(!a),className:_("inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium transition-colors cursor-pointer",b.length>0?"bg-green-500/15 text-green-400 hover:bg-green-500/25":"bg-bg-surface text-text-muted hover:bg-bg-hover"),children:[e.jsx(L,{size:10}),c.length," app",c.length!==1?"s":"",b.length>0&&` (${b.length} live)`,e.jsx(z,{size:10})]}),a&&e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 w-64 rounded-lg border border-border-default bg-bg-elevated shadow-lg overflow-hidden",children:[e.jsx("div",{className:"py-1",children:c.map(s=>{const n=d.find(N=>N.appName.toLowerCase()===s.toLowerCase());return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[e.jsx(S,{color:n!=null&&n.isConnected?"green":"gray",size:"sm",pulse:n==null?void 0:n.isConnected}),e.jsx("span",{className:"text-xs text-text-primary flex-1 truncate font-mono",children:s}),e.jsx("button",{type:"button",onClick:()=>l(s),className:"p-0.5 rounded text-text-muted hover:text-red hover:bg-red-muted transition-colors cursor-pointer",children:e.jsx(D,{size:10})})]},s)})}),(v.length>0||m.length>0)&&e.jsxs("div",{className:"border-t border-border-muted py-1",children:[e.jsx("p",{className:"px-3 py-1 text-[10px] text-text-muted uppercase tracking-wider",children:"Available"}),v.map(s=>e.jsxs("button",{type:"button",onClick:()=>{const n=[...c,s.appName];x.getState().updateProject(t.id,{runtimeApps:n})},className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-text-secondary hover:bg-bg-hover cursor-pointer",children:[e.jsx(w,{size:10,className:"text-text-tertiary"}),e.jsx("span",{className:"font-mono truncate",children:s.appName}),s.isConnected&&e.jsx(S,{color:"green",size:"sm",pulse:!0})]},s.appName)),m.map(s=>e.jsxs("button",{type:"button",onClick:()=>{const n=[...c,s];x.getState().updateProject(t.id,{runtimeApps:n})},className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-text-muted hover:bg-bg-hover cursor-pointer",children:[e.jsx(w,{size:10,className:"text-text-tertiary"}),e.jsx("span",{className:"font-mono truncate",children:s}),e.jsx("span",{className:"text-[10px] text-text-tertiary",children:"SDK"})]},s))]}),e.jsxs("div",{className:"border-t border-border-muted px-3 py-2 flex gap-1.5",children:[e.jsx("input",{type:"text",value:i,onChange:s=>u(s.target.value),onKeyDown:s=>s.key==="Enter"&&p(),placeholder:"Add app name...",className:"flex-1 bg-transparent text-xs text-text-primary placeholder:text-text-muted outline-none font-mono"}),i.trim()&&e.jsx("button",{type:"button",onClick:p,className:"text-xs text-accent font-medium cursor-pointer",children:"Add"})]})]})]})}function re(){const t=j(i=>i.selectedPmProject),a=j(i=>i.activeProjectTab);j(i=>i.setActiveProjectTab);const r=x(i=>i.projects.find(u=>u.id===t));return r?e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"px-5 pt-4 pb-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-lg font-semibold text-text-primary",children:r.name}),e.jsx(ee,{projectId:r.id,category:r.category}),e.jsx(se,{project:r}),e.jsx(te,{project:r})]}),r.path&&e.jsx("p",{className:"text-[12px] text-text-muted font-mono truncate mt-0.5",children:r.path})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:e.jsxs(o.Suspense,{fallback:e.jsx(R,{rows:8}),children:[a==="tasks"&&e.jsx(U,{projectId:r.id}),a==="git"&&e.jsx(Y,{projectId:r.id,projectPath:r.path}),a==="sessions"&&e.jsx(X,{projectId:r.id}),a==="sdk"&&e.jsx(Z,{project:r}),a==="runtime"&&e.jsx(G,{project:r}),a==="notes"&&e.jsx(F,{projectId:r.id}),a==="memory"&&e.jsx(J,{projectId:r.id,claudeProjectKey:r.claudeProjectKey}),a==="rules"&&e.jsx(Q,{projectId:r.id}),a==="capex"&&e.jsx(W,{projectId:r.id})]})})]}):e.jsx(A,{title:"No Project Selected",description:"Select a project from the header dropdown to get started."})}const ue=Object.freeze(Object.defineProperty({__proto__:null,ProjectView:re},Symbol.toStringTag,{value:"Module"}));export{$ as E,H as L,ue as p};
