import { x as head, e as ensure_array_like, g as derived, b as attr_class, a as attr, c as escape_html, d as attr_style } from './dev-BNpEUZI3.js';
import { H as HeroHeader } from './HeroHeader-v4Q9vaGr.js';
import { B as Badge } from './Tabs-DzG6Bn9a.js';
import { B as Button } from './ui-DR8zOSpC.js';
import { D as DetailDrawer, g as gatesFromJson, a as StatusBadge, P as PriorityBadge } from './tasks2-DtLXCqqM.js';
import './index-server-DocJvixA.js';
import './chunk-DDP5xfzh.js';
import 'node:module';
import './tasks-CnwUAUXf.js';
import './paths-2M_UxD_H.js';
import 'node:fs';
import 'node:path';
import 'node:os';
import 'node:events';
import 'node:diagnostics_channel';
import 'fs';
import 'events';
import 'util';
import 'path';
import 'assert';
import 'worker_threads';
import 'module';
import 'node:url';
import 'url';
import 'buffer';
import 'node:child_process';
import 'node:crypto';
import 'node:process';
import 'node:async_hooks';
import './data-accessor-CVbz8X_7.js';
import './conduit-Ca_OFWR_.js';
import './indexes-aYlULWG3.js';
import './utils-BvHPJOVk.js';
import './unique-constraint-BM-Apx1H.js';
import './sqlite-Dsbe0wec.js';
import './dual-scope-db-ATrwq0LH.js';
import './memory-schema-Bi7cChwo.js';
import './agent-registry-BtE5uhMO.js';
import './nexus-sqlite2-DgTuv9BQ.js';
import './nexus-schema2-BEd-ol6e.js';
import './logger-ChCwlV5k.js';
import 'node:sqlite';
import './lock-BoHF25mx.js';
import './index-IVoIz4D5.js';
import 'constants';
import 'stream';
import 'node:fs/promises';
import 'jsonc-parser';
import '@cleocode/cant';
import 'node:util';
import 'node:buffer';
import 'child_process';
import './branch-lock-qP1EkZ7p.js';
import './src2-DK8DKufK.js';
import 'llmtxt/identity';
import './sessions-j73dkbCI.js';
import './registry2-BSyCTA3q.js';
import './index-Ca4C2M45.js';
import './mvi-helpers-BNsJ8ZpQ.js';
import './session-store-OwQWMSf_.js';
import './session-manifest-ZHrj54LR.js';
import './storage-B9UA3BHR.js';
import './config-B0nEjgSh.js';
import './json-DXl7iDYg.js';
import './data-safety-central-vmfu_Y4J.js';
import './sqlite-data-accessor-C59wZ0zp.js';
import './cross-db-cleanup-C_FLyd-6.js';
import './StatBlock-DHJMmOCx.js';
import './no-face-up-DcejJLy-.js';
import 'd3';

//#region src/lib/components/pipeline/StageSwimLane.svelte
function StageSwimLane($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		const KNOWN_STATUSES = new Set([
			"pending",
			"active",
			"blocked",
			"done",
			"cancelled",
			"archived",
			"proposed"
		]);
		const KNOWN_PRIORITIES = new Set([
			"low",
			"medium",
			"high",
			"critical"
		]);
		function toStatus(s) {
			return KNOWN_STATUSES.has(s) ? s : "pending";
		}
		function toPriority(p) {
			return KNOWN_PRIORITIES.has(p) ? p : "medium";
		}
		/** Column id (`research`, `implementation`, …). */
		/** Human-readable column label. */
		/** Total tasks in this column. */
		/** Tasks rendered as cards. */
		/** When true, highlight the column as focused. */
		/** Row index of the currently-focused card, or -1 when none. */
		/** Called when a card is clicked / activated. */
		let { id, label, count, tasks, focused = false, focusedRow = -1} = $$props;
		/**
		* Fraction of tasks in this column whose `done` gate is set. Used
		* for the header progress bar. Terminal columns (`done`,
		* `cancelled`) always show as 100% / 0% respectively so the bar
		* reads as a finish line.
		*/
		const progressPct = derived(() => (() => {
			if (id === "done") return 100;
			if (id === "cancelled") return 0;
			if (tasks.length === 0) return 0;
			let done = 0;
			for (const t of tasks) {
				const gates = gatesFromJson(t.verification_json ?? null);
				if (gates.implemented && gates.testsPassed && gates.qaPassed) done++;
			}
			return Math.round(done / tasks.length * 100);
		})());
		$$renderer.push(`<section${attr_class("swimlane svelte-1sq3ngf", void 0, { "is-focused": focused })}${attr("data-stage", id)}${attr("aria-label", label)}><header class="lane-head svelte-1sq3ngf"><div class="head-row svelte-1sq3ngf"><span class="head-label svelte-1sq3ngf">${escape_html(label)}</span> `);
		Badge($$renderer, {
			tone: count > 0 ? "accent" : "neutral",
			size: "sm",
			children: ($$renderer) => {
				$$renderer.push(`<!---->${escape_html(count)}`);
			}});
		$$renderer.push(`<!----></div> <div class="progress-track svelte-1sq3ngf" aria-hidden="true"><div class="progress-fill svelte-1sq3ngf"${attr_style(`width: ${progressPct()}%`)}></div></div> <div class="progress-label svelte-1sq3ngf"><span class="progress-pct svelte-1sq3ngf">${escape_html(progressPct())}%</span> <span class="progress-hint svelte-1sq3ngf">gates passed</span></div></header> <div class="lane-body svelte-1sq3ngf">`);
		if (tasks.length === 0) {
			$$renderer.push("<!--[0-->");
			$$renderer.push(`<p class="lane-empty svelte-1sq3ngf">—</p>`);
		} else {
			$$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--[-->`);
			const each_array = ensure_array_like(tasks);
			for (let i = 0, $$length = each_array.length; i < $$length; i++) {
				let task = each_array[i];
				const gates = gatesFromJson(task.verification_json ?? null);
				$$renderer.push(`<button type="button"${attr_class("lane-card svelte-1sq3ngf", void 0, { "is-focused": focused && focusedRow === i })}><div class="card-head svelte-1sq3ngf"><span class="card-id svelte-1sq3ngf">${escape_html(task.id)}</span> `);
				StatusBadge($$renderer, {
					status: toStatus(task.status),
					compact: true
				});
				$$renderer.push(`<!----></div> <p class="card-title svelte-1sq3ngf">${escape_html(task.title)}</p> <div class="card-foot svelte-1sq3ngf">`);
				PriorityBadge($$renderer, {
					priority: toPriority(task.priority),
					compact: true
				});
				$$renderer.push(`<!----> `);
				if (task.size) {
					$$renderer.push("<!--[0-->");
					$$renderer.push(`<span class="card-size svelte-1sq3ngf">${escape_html(task.size)}</span>`);
				} else $$renderer.push("<!--[-1-->");
				$$renderer.push(`<!--]--> <div class="card-gates svelte-1sq3ngf" aria-label="Verification gates"><span${attr_class("g-dot svelte-1sq3ngf", void 0, { "g-pass": gates.implemented })} title="Implemented">I</span> <span${attr_class("g-dot svelte-1sq3ngf", void 0, { "g-pass": gates.testsPassed })} title="Tests">T</span> <span${attr_class("g-dot svelte-1sq3ngf", void 0, { "g-pass": gates.qaPassed })} title="QA">Q</span> <span class="g-dot svelte-1sq3ngf" title="Documented">D</span> <span class="g-dot svelte-1sq3ngf" title="Security">S</span> <span class="g-dot svelte-1sq3ngf" title="Cleanup">C</span></div></div></button>`);
			}
			$$renderer.push(`<!--]-->`);
		}
		$$renderer.push(`<!--]--></div></section>`);
	});
}
//#endregion
//#region src/routes/tasks/pipeline/+page.svelte
function _page($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		let { data } = $$props;
		const columns = derived(() => data.columns ?? []);
		let focusedCol = 0;
		let focusedRow = 0;
		let selectedTaskId = null;
		const allTasks = derived(() => columns().flatMap((c) => c.tasks));
		const KNOWN_STATUSES = new Set([
			"pending",
			"active",
			"blocked",
			"done",
			"cancelled",
			"archived",
			"proposed"
		]);
		const KNOWN_PRIORITIES = new Set([
			"low",
			"medium",
			"high",
			"critical"
		]);
		const KNOWN_TYPES = new Set([
			"epic",
			"task",
			"subtask"
		]);
		const KNOWN_SIZES = new Set([
			"small",
			"medium",
			"large"
		]);
		function buildDrawerTask(raw) {
			const status = KNOWN_STATUSES.has(raw.status) ? raw.status : "pending";
			const priority = KNOWN_PRIORITIES.has(raw.priority) ? raw.priority : "medium";
			const type = KNOWN_TYPES.has(raw.type) ? raw.type : void 0;
			const size = raw.size && KNOWN_SIZES.has(raw.size) ? raw.size : void 0;
			return {
				id: raw.id,
				title: raw.title,
				description: raw.title,
				status,
				priority,
				type,
				size,
				parentId: raw.parent_id,
				createdAt: (/* @__PURE__ */ new Date()).toISOString()
			};
		}
		const drawerTask = derived(() => (() => {
			if (!selectedTaskId) return null;
			const raw = allTasks().find((t) => t.id === selectedTaskId);
			if (!raw) return null;
			return buildDrawerTask(raw);
		})());
		const totalTasks = derived(() => columns().reduce((sum, c) => sum + c.count, 0));
		function closeDrawer() {
			selectedTaskId = null;
		}
		head("1jyay8m", $$renderer, ($$renderer) => {
			$$renderer.title(($$renderer) => {
				$$renderer.push(`<title>Pipeline — CLEO Studio</title>`);
			});
		});
		$$renderer.push(`<div class="pipeline-view svelte-1jyay8m" role="main" tabindex="-1">`);
		{
			function actions($$renderer) {
				Button($$renderer, {
					variant: "ghost",
					size: "sm",
					href: "/tasks",
					children: ($$renderer) => {
						$$renderer.push(`<!---->← Tasks`);
					}});
				$$renderer.push(`<!----> `);
				Button($$renderer, {
					variant: "ghost",
					size: "sm",
					href: "/tasks/sessions",
					children: ($$renderer) => {
						$$renderer.push(`<!---->Sessions`);
					}});
				$$renderer.push(`<!---->`);
			}
			HeroHeader($$renderer, {
				eyebrow: "PIPELINE",
				title: "RCASD-IVTR+C",
				subtitle: "Stage swim-lanes across every non-archived task. Arrow keys to navigate · Enter to open.",
				meta: `${totalTasks()} tasks · ${columns().length} stages`,
				actions});
		}
		$$renderer.push(`<!----> <div class="board-scroll svelte-1jyay8m"><div class="board svelte-1jyay8m"><!--[-->`);
		const each_array = ensure_array_like(columns());
		for (let ci = 0, $$length = each_array.length; ci < $$length; ci++) {
			let col = each_array[ci];
			StageSwimLane($$renderer, {
				id: col.id,
				label: col.label,
				count: col.count,
				tasks: col.tasks,
				focused: ci === focusedCol,
				focusedRow: ci === focusedCol ? focusedRow : -1});
		}
		$$renderer.push(`<!--]--></div></div> <footer class="pipeline-foot svelte-1jyay8m"><span class="hint svelte-1jyay8m">Arrows navigate · Enter opens · Esc closes</span></footer></div> `);
		if (drawerTask()) {
			$$renderer.push("<!--[0-->");
			DetailDrawer($$renderer, {
				task: drawerTask(),
				onClose: closeDrawer
			});
		} else $$renderer.push("<!--[-1-->");
		$$renderer.push(`<!--]-->`);
	});
}

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