import { x as head, c as escape_html, e as ensure_array_like, a as attr, g as derived } from './dev-BNpEUZI3.js';
import { o as onDestroy } from './index-server-DocJvixA.js';
import { H as HeroHeader } from './HeroHeader-v4Q9vaGr.js';
import { S as Sparkline } from './Sparkline-BJ-GuhRd.js';
import { S as StatBlock } from './StatBlock-DHJMmOCx.js';
import { C as Card, B as Badge } from './Tabs-DzG6Bn9a.js';
import { B as Button } from './ui-DR8zOSpC.js';
import './chunk-DDP5xfzh.js';
import 'node:module';

//#region src/routes/+page.svelte
function _page($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		let { data } = $$props;
		const portals = derived(() => [
			{
				href: "/brain",
				title: "Brain",
				subtitle: "Living canvas",
				description: "5-substrate graph — observations, decisions, quality.",
				stats: data.brainStats,
				tone: "info"
			},
			{
				href: "/code",
				title: "Code",
				subtitle: "Symbol intelligence",
				description: "Function calls, module graph, community clusters.",
				stats: data.nexusStats,
				tone: "accent"
			},
			{
				href: "/brain/overview",
				title: "Memory",
				subtitle: "BRAIN overview",
				description: "Decisions timeline · tier stats · quality distribution.",
				stats: data.brainStats,
				tone: "warning"
			},
			{
				href: "/tasks",
				title: "Tasks",
				subtitle: "RCASD-IVTR pipeline",
				description: "Explorer · hierarchy · kanban · sessions — read-only.",
				stats: data.tasksStats,
				tone: "success"
			}
		]);
		onDestroy(() => {});
		const activityPoints = derived(() => data.activity24h.map((b) => b.total));
		const totalObservations24h = derived(() => data.activity24h.reduce((a, b) => a + b.observations, 0));
		const totalCompletions24h = derived(() => data.activity24h.reduce((a, b) => a + b.completions, 0));
		const totalActivity24h = derived(() => totalObservations24h() + totalCompletions24h());
		function activityKindLabel(kind) {
			if (kind === "observation") return "OBS";
			if (kind === "decision") return "DEC";
			if (kind === "task-done") return "DONE";
			if (kind === "task-created") return "NEW";
			return "EVT";
		}
		function activityKindTone(kind) {
			if (kind === "observation") return "info";
			if (kind === "decision") return "accent";
			if (kind === "task-done") return "success";
			if (kind === "task-created") return "warning";
			return "info";
		}
		function activityHref(row) {
			if (row.kind === "task-done" || row.kind === "task-created") return `/tasks/${row.id}`;
			if (row.kind === "decision") return "/brain/decisions";
			if (row.kind === "observation") return "/brain/observations";
			return null;
		}
		function formatTime(iso) {
			try {
				const d = new Date(iso);
				const delta = Date.now() - d.getTime();
				if (delta < 6e4) return "just now";
				if (delta < 36e5) return `${Math.floor(delta / 6e4)}m ago`;
				if (delta < 864e5) return `${Math.floor(delta / 36e5)}h ago`;
				return d.toLocaleDateString(void 0, {
					month: "short",
					day: "numeric"
				});
			} catch {
				return iso;
			}
		}
		head("1uha8ag", $$renderer, ($$renderer) => {
			$$renderer.title(($$renderer) => {
				$$renderer.push(`<title>CLEO Studio</title>`);
			});
		});
		$$renderer.push(`<div class="mission-control svelte-1uha8ag">`);
		{
			function actions($$renderer) {
				Badge($$renderer, {
					tone: data.activeSessions > 0 ? "success" : "neutral",
					size: "md",
					children: ($$renderer) => {
						$$renderer.push(`<!---->${escape_html(data.activeSessions)} active session${escape_html(data.activeSessions === 1 ? "" : "s")}`);
					}});
				$$renderer.push(`<!----> `);
				Button($$renderer, {
					variant: "ghost",
					size: "sm",
					href: "/projects",
					children: ($$renderer) => {
						$$renderer.push(`<!---->Admin →`);
					}});
				$$renderer.push(`<!---->`);
			}
			HeroHeader($$renderer, {
				eyebrow: "MISSION CONTROL",
				title: "CLEO Studio",
				subtitle: "Unified observability portal for the CLEO agent platform — read-only views over live project data.",
				meta: data.projectPath,
				liveIndicator: data.activeSessions > 0,
				actions});
		}
		$$renderer.push(`<!----> <div class="grid svelte-1uha8ag"><section class="col col-activity svelte-1uha8ag" aria-label="Activity pulse">`);
		{
			function header($$renderer) {
				$$renderer.push(`<div class="card-label-row svelte-1uha8ag"><span class="card-label svelte-1uha8ag">Activity pulse</span> <span class="card-sub svelte-1uha8ag">last 24 hours</span></div>`);
			}
			Card($$renderer, {
				padding: "cozy",
				elevation: 1,
				header,
				children: ($$renderer) => {
					$$renderer.push(`<div class="activity-body svelte-1uha8ag"><div class="pulse-row svelte-1uha8ag">`);
					StatBlock($$renderer, {
						label: "Total",
						value: totalActivity24h(),
						hint: "events recorded",
						tone: "accent"
					});
					$$renderer.push(`<!----> `);
					StatBlock($$renderer, {
						label: "Observations",
						value: totalObservations24h(),
						tone: "info"
					});
					$$renderer.push(`<!----> `);
					StatBlock($$renderer, {
						label: "Completed",
						value: totalCompletions24h(),
						tone: "success"
					});
					$$renderer.push(`<!----></div> <div class="sparkline-block svelte-1uha8ag">`);
					Sparkline($$renderer, {
						points: activityPoints(),
						width: 320,
						height: 56,
						tone: "accent",
						ariaLabel: "24-hour activity trend"
					});
					$$renderer.push(`<!----> <div class="sparkline-axis svelte-1uha8ag"><span>24h ago</span> <span>now</span></div></div> <div class="pulse-footnote">`);
					StatBlock($$renderer, {
						label: "Active sessions",
						value: data.activeSessions,
						tone: data.activeSessions > 0 ? "success" : "neutral",
						hint: "right now"
					});
					$$renderer.push(`<!----></div></div>`);
				}});
		}
		$$renderer.push(`<!----></section> <section class="col col-portals svelte-1uha8ag" aria-label="Substrate portals">`);
		{
			function header($$renderer) {
				$$renderer.push(`<div class="card-label-row svelte-1uha8ag"><span class="card-label svelte-1uha8ag">Substrates</span> <span class="card-sub svelte-1uha8ag">click to explore</span></div>`);
			}
			Card($$renderer, {
				padding: "cozy",
				elevation: 1,
				header,
				children: ($$renderer) => {
					$$renderer.push(`<div class="portal-stack svelte-1uha8ag"><!--[-->`);
					const each_array = ensure_array_like(portals());
					for (let $$index_1 = 0, $$length = each_array.length; $$index_1 < $$length; $$index_1++) {
						let portal = each_array[$$index_1];
						$$renderer.push(`<a class="portal svelte-1uha8ag"${attr("href", portal.href)}${attr("data-tone", portal.tone)}><div class="portal-head svelte-1uha8ag"><span class="portal-title svelte-1uha8ag">${escape_html(portal.title)}</span> <span class="portal-subtitle svelte-1uha8ag">${escape_html(portal.subtitle)}</span></div> <p class="portal-desc svelte-1uha8ag">${escape_html(portal.description)}</p> `);
						if (portal.stats) {
							$$renderer.push("<!--[0-->");
							$$renderer.push(`<div class="portal-stats svelte-1uha8ag"><!--[-->`);
							const each_array_1 = ensure_array_like(portal.stats);
							for (let $$index = 0, $$length = each_array_1.length; $$index < $$length; $$index++) {
								let stat = each_array_1[$$index];
								$$renderer.push(`<div class="portal-stat svelte-1uha8ag"><span class="portal-stat-value svelte-1uha8ag">${escape_html(stat.value)}</span> <span class="portal-stat-label svelte-1uha8ag">${escape_html(stat.label)}</span></div>`);
							}
							$$renderer.push(`<!--]--></div>`);
						} else {
							$$renderer.push("<!--[-1-->");
							$$renderer.push(`<span class="portal-unavailable svelte-1uha8ag">database not found</span>`);
						}
						$$renderer.push(`<!--]--> <span class="portal-arrow svelte-1uha8ag" aria-hidden="true">→</span></a>`);
					}
					$$renderer.push(`<!--]--></div>`);
				}});
		}
		$$renderer.push(`<!----></section> <section class="col col-ops svelte-1uha8ag" aria-label="Operations status">`);
		{
			function header($$renderer) {
				$$renderer.push(`<div class="card-label-row svelte-1uha8ag"><span class="card-label svelte-1uha8ag">Ops status</span> `);
				$$renderer.push("<!--[-1-->");
				$$renderer.push(`<!--]--></div>`);
			}
			Card($$renderer, {
				padding: "cozy",
				elevation: 1,
				header,
				children: ($$renderer) => {
					$$renderer.push(`<div class="ops-body svelte-1uha8ag">`);
					$$renderer.push("<!--[-1-->");
					$$renderer.push(`<!--]--> `);
					$$renderer.push("<!--[-1-->");
					$$renderer.push(`<!--]--> <div class="ops-project svelte-1uha8ag"><div class="ops-project-label svelte-1uha8ag">Active project</div> <div class="ops-project-name svelte-1uha8ag">${escape_html(data.projectName)}</div> <code class="ops-project-path svelte-1uha8ag">${escape_html(data.projectPath)}</code></div> <div class="ops-actions svelte-1uha8ag">`);
					Button($$renderer, {
						variant: "secondary",
						size: "sm",
						href: "/projects",
						children: ($$renderer) => {
							$$renderer.push(`<!---->Scan`);
						}});
					$$renderer.push(`<!----> `);
					Button($$renderer, {
						variant: "ghost",
						size: "sm",
						href: "/projects",
						children: ($$renderer) => {
							$$renderer.push(`<!---->Backup`);
						}});
					$$renderer.push(`<!----> `);
					Button($$renderer, {
						variant: "ghost",
						size: "sm",
						href: "/projects",
						children: ($$renderer) => {
							$$renderer.push(`<!---->Doctor`);
						}});
					$$renderer.push(`<!----></div></div>`);
				}});
		}
		$$renderer.push(`<!----></section></div> <section class="recent-strip svelte-1uha8ag" aria-label="Recent activity"><header class="recent-head svelte-1uha8ag"><h2 class="recent-title svelte-1uha8ag"><span class="recent-label svelte-1uha8ag">Cross-feed</span> <span class="recent-sub svelte-1uha8ag">Brain · Nexus · Tasks · Conduit · SignalDock</span></h2> <span class="recent-count svelte-1uha8ag">${escape_html(data.recentActivity.length)} events</span></header> `);
		if (data.recentActivity.length === 0) {
			$$renderer.push("<!--[0-->");
			$$renderer.push(`<p class="recent-empty svelte-1uha8ag">Nothing recorded in the last 24 hours.</p>`);
		} else {
			$$renderer.push("<!--[-1-->");
			$$renderer.push(`<ol class="recent-list svelte-1uha8ag"><!--[-->`);
			const each_array_3 = ensure_array_like(data.recentActivity);
			for (let $$index_3 = 0, $$length = each_array_3.length; $$index_3 < $$length; $$index_3++) {
				let row = each_array_3[$$index_3];
				const href = activityHref(row);
				if (href) {
					$$renderer.push("<!--[0-->");
					$$renderer.push(`<li class="recent-row svelte-1uha8ag"><a class="recent-link svelte-1uha8ag"${attr("href", href)}>`);
					Badge($$renderer, {
						tone: activityKindTone(row.kind),
						size: "sm",
						children: ($$renderer) => {
							$$renderer.push(`<!---->${escape_html(activityKindLabel(row.kind))}`);
						}});
					$$renderer.push(`<!----> <span class="recent-id svelte-1uha8ag">${escape_html(row.id)}</span> <span class="recent-title-text svelte-1uha8ag">${escape_html(row.title)}</span> <time class="recent-time svelte-1uha8ag">${escape_html(formatTime(row.timestamp))}</time></a></li>`);
				} else {
					$$renderer.push("<!--[-1-->");
					$$renderer.push(`<li class="recent-row recent-row-inert svelte-1uha8ag">`);
					Badge($$renderer, {
						tone: activityKindTone(row.kind),
						size: "sm",
						children: ($$renderer) => {
							$$renderer.push(`<!---->${escape_html(activityKindLabel(row.kind))}`);
						}});
					$$renderer.push(`<!----> <span class="recent-id svelte-1uha8ag">${escape_html(row.id)}</span> <span class="recent-title-text svelte-1uha8ag">${escape_html(row.title)}</span> <time class="recent-time svelte-1uha8ag">${escape_html(formatTime(row.timestamp))}</time></li>`);
				}
				$$renderer.push(`<!--]-->`);
			}
			$$renderer.push(`<!--]--></ol>`);
		}
		$$renderer.push(`<!--]--></section></div>`);
	});
}

export { _page as default };
//# sourceMappingURL=_page.svelte-Clbkk1gm.js.map
