import { g as getTaskAccessor } from './data-accessor-CVbz8X_7.js';
import { l as listSessions } from './sessions-j73dkbCI.js';
import { c as computeTaskViews, B as AGENT_LIFECYCLE_LANES, E as resolveAgentLifecycleLane, F as AGENT_LIFECYCLE_LANE_HINTS, G as AGENT_LIFECYCLE_LANE_LABELS } from './tasks-CnwUAUXf.js';
import { l as listTasks } from './list-DfOyEStk.js';
import 'node:module';
import 'node:fs';
import 'node:path';
import 'node:child_process';
import 'node:crypto';
import 'node:os';
import './paths-2M_UxD_H.js';
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:process';
import 'node:async_hooks';
import './dual-scope-db-ATrwq0LH.js';
import './indexes-aYlULWG3.js';
import './utils-BvHPJOVk.js';
import './registry2-BSyCTA3q.js';
import './sqlite-Dsbe0wec.js';
import './chunk-DDP5xfzh.js';
import './conduit-Ca_OFWR_.js';
import './unique-constraint-BM-Apx1H.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 './index-Ca4C2M45.js';
import './mvi-helpers-BNsJ8ZpQ.js';
import './session-store-OwQWMSf_.js';
import 'node:util';
import './session-manifest-ZHrj54LR.js';
import 'jsonc-parser';
import '@cleocode/cant';
import 'node:buffer';
import 'child_process';
import './branch-lock-qP1EkZ7p.js';
import './src2-DK8DKufK.js';
import 'llmtxt/identity';
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';

//#region src/routes/tasks/kanban/+page.server.ts
/** Build the ordered, board-ready lane definitions from the lane taxonomy. */
function buildLanes() {
	return AGENT_LIFECYCLE_LANES.map((id) => ({
		id,
		label: AGENT_LIFECYCLE_LANE_LABELS[id],
		hint: AGENT_LIFECYCLE_LANE_HINTS[id]
	}));
}
/**
* Project a core `Task` + its `TaskView` slice + the active-worker set onto
* the framework-free {@link AgentLifecycleSignal} the resolver consumes.
*
* @param task - The core task row.
* @param view - Aligned `TaskView` (gates, readyToComplete, nextAction), or undefined.
* @param activeWorkerIds - Set of task ids currently claimed by an active session.
* @returns The normalised signal bundle.
*/
function toSignal(task, view, activeWorkerIds) {
	const depends = task.depends ?? [];
	const blockedOnDeps = view?.nextAction === "blocked-on-deps";
	const unmetDependsCount = depends.length === 0 ? 0 : blockedOnDeps ? depends.length : 0;
	return {
		status: task.status,
		blockedBy: task.blockedBy ?? null,
		depends,
		unmetDependsCount,
		gates: view?.gatesStatus ?? null,
		readyToComplete: view?.readyToComplete ?? false,
		prAwaiting: false,
		hitlPending: false,
		workerActive: activeWorkerIds.has(task.id),
		nextAction: view?.nextAction
	};
}
/** Project a core `Task` onto a presentational {@link BoardCard}. */
function toCard(task, workerActive) {
	return {
		id: task.id,
		title: task.title,
		status: task.status,
		priority: task.priority,
		size: task.size ?? null,
		verificationJson: task.verification !== void 0 && task.verification !== null ? JSON.stringify(task.verification) : null,
		workerActive
	};
}
var load = async ({ locals }) => {
	const ctx = locals.projectCtx;
	const lanes = buildLanes();
	const emptyColumns = lanes.map((lane) => ({
		lane,
		cards: [],
		count: 0
	}));
	if (!ctx.tasksDbExists) return {
		columns: emptyColumns,
		total: 0,
		error: "tasks.db unavailable"
	};
	try {
		const accessor = await getTaskAccessor(ctx.projectPath);
		const tasks = (await listTasks({
			excludeArchived: true,
			sortByPriority: true,
			limit: 1e3
		}, ctx.projectPath, accessor)).tasks;
		const views = await computeTaskViews(tasks.map((t) => t.id), accessor);
		const viewById = new Map(views.map((v) => [v.id, v]));
		let activeWorkerIds = /* @__PURE__ */ new Set();
		try {
			const activeSessions = await listSessions(ctx.projectPath, { status: "active" });
			activeWorkerIds = new Set(activeSessions.map((s) => s.taskWork?.taskId ?? null).filter((id) => id !== null));
		} catch {}
		const byLane = /* @__PURE__ */ new Map();
		for (const lane of AGENT_LIFECYCLE_LANES) byLane.set(lane, []);
		let total = 0;
		for (const task of tasks) {
			if (!isSurfacedStatus(task.status)) continue;
			const view = viewById.get(task.id);
			const workerActive = activeWorkerIds.has(task.id);
			const lane = resolveAgentLifecycleLane(toSignal(task, view, activeWorkerIds));
			byLane.get(lane)?.push(toCard(task, workerActive));
			total += 1;
		}
		return {
			columns: lanes.map((lane) => {
				const cards = byLane.get(lane.id) ?? [];
				return {
					lane,
					cards,
					count: cards.length
				};
			}),
			total
		};
	} catch (err) {
		return {
			columns: emptyColumns,
			total: 0,
			error: String(err)
		};
	}
};
/** Statuses surfaced on the dispatcher board (everything except pre-lifecycle / archived). */
function isSurfacedStatus(status) {
	return status !== "archived" && status !== "proposed";
}

var _page_server_ts = /*#__PURE__*/Object.freeze({
	__proto__: null,
	load: load
});

const index = 28;
let component_cache;
const component = async () => component_cache ??= (await import('./_page.svelte-BIx0Fiak.js')).default;
const server_id = "src/routes/tasks/kanban/+page.server.ts";
const imports = ["_app/immutable/nodes/28.C_ZihDQr.js","_app/immutable/chunks/DyGQ_VXC.js","_app/immutable/chunks/DrKWWDpL.js","_app/immutable/chunks/BgPpRtmk.js","_app/immutable/chunks/BrUKpZTl.js","_app/immutable/chunks/DsQIgu-4.js","_app/immutable/chunks/Bcuvp8aL.js","_app/immutable/chunks/DnOaYask.js","_app/immutable/chunks/Cjus22ap.js","_app/immutable/chunks/DOqzs8kl2.js","_app/immutable/chunks/DTkg6Mnx.js","_app/immutable/chunks/DIQmuJJZ.js","_app/immutable/chunks/D7w7HllH.js","_app/immutable/chunks/DB5ifLM-.js","_app/immutable/chunks/CxlOpib82.js","_app/immutable/chunks/BKc98lKx.js","_app/immutable/chunks/DsanjglN.js","_app/immutable/chunks/CbGRcr-D.js","_app/immutable/chunks/CX8DOZuw2.js","_app/immutable/chunks/djL6V-tr.js","_app/immutable/chunks/CQCxd1p9.js","_app/immutable/chunks/JPJd4fEI.js","_app/immutable/chunks/RptFUp2P.js","_app/immutable/chunks/CEqOYim7.js","_app/immutable/chunks/CqF5Lomf.js","_app/immutable/chunks/v8nUY1ct.js","_app/immutable/chunks/wI_OOyoh.js"];
const stylesheets = ["_app/immutable/assets/StatBlock.DX6OXz7z.css","_app/immutable/assets/no-face-up.BlswZ73M.css","_app/immutable/assets/Tabs.CU9_rsWl.css","_app/immutable/assets/ui.CH-9N9-0.css","_app/immutable/assets/tasks.BZWJL4jq.css","_app/immutable/assets/saga-board.XH0XIkul.css","_app/immutable/assets/HeroHeader.ByXNeezk.css","_app/immutable/assets/28.B2KOVxyP.css"];
const fonts = [];

export { component, fonts, imports, index, _page_server_ts as server, server_id, stylesheets };
//# sourceMappingURL=28-4qnBS02W.js.map
