import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{m as t}from"./vendor-dnd-C1cICjTT.js";import{s as n}from"./vendor-markdown-Db1-9wH7.js";import{t as r}from"./sessionStore-DVOX7Q2x.js";import{C as i,s as a,v as o}from"./index-Dzmo3iV3.js";import{t as s}from"./SidebarSessionTimeline-BQYELqYL.js";var c=e(t(),1),l=n(),u=d;function d({projectPath:e}){let t=(0,c.useRef)(null),[n,u]=(0,c.useState)(`cards`),d=o(a(e=>e.themeId)),f=r(e=>e.sessions),p=c.useMemo(()=>Array.from(f.values()).filter(t=>t.cwd===e),[e,f]),m=(0,c.useCallback)((t,n={})=>{i({piSessionId:t.id,sessionFilePath:t.filePath,cwd:t.cwd||e,title:t.title||`Personal OS session`,spawnPi:!1,sessionType:`pi`,wasIdle:t.status!==`active`})},[e]),h=(0,c.useCallback)(()=>{let e=t.current?.contentWindow;e&&e.postMessage({type:`mc-theme`,id:d.id,name:d.name,isDark:d.isDark,brandColor:d.brandColor,bgColor:d.bgColor},window.location.origin)},[d.id,d.name,d.isDark,d.brandColor,d.bgColor]);return(0,c.useEffect)(()=>{h()},[h]),(0,c.useEffect)(()=>{function e(e){if(e.origin!==window.location.origin)return;let t=e.data;t&&(t.type===`personal-os-ready`&&h(),t.type===`personal-os-view`&&t.view&&u(t.view))}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[h]),(0,l.jsxs)(`div`,{className:`relative h-full w-full overflow-hidden`,style:{background:d.bgColor},children:[(0,l.jsx)(`iframe`,{ref:t,src:`/embed/personal-os/`,title:`Personal OS`,className:`h-full w-full border-0`,style:{display:`block`,background:d.bgColor},onLoad:h}),n===`chat`&&(0,l.jsxs)(`div`,{className:`absolute inset-x-0 top-0 bottom-[calc(68px+env(safe-area-inset-bottom,0px))] z-10 flex min-h-0 flex-col overflow-hidden bg-terminal-bg px-3 pt-4`,children:[(0,l.jsx)(`h1`,{className:`mb-3 shrink-0 px-1 text-[28px] font-semibold tracking-[-0.04em] text-terminal-text`,children:`Chats`}),(0,l.jsx)(s,{sessions:p,showProjectTag:!1,variant:`embedded`,className:`mc-minimal-scrollbar min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto pb-5`,emptyLabel:`No Personal OS sessions yet.`,onSessionClick:m})]})]})}export{d as PersonalOSDashboard,u as default};