globalThis.process ??= {};
globalThis.process.env ??= {};
import { r as __exportAll } from "./rolldown-runtime_-UtK6b3T.mjs";
import { d as renderTemplate, f as maybeRenderHead, i as renderComponent, m as addAttribute, w as createAstro, x as unescapeHTML } from "./server_DAChoow1.mjs";
import { t as createComponent } from "./compiler_CLrjY88v.mjs";
import { j as getBySlug } from "./crypto_CY2zBtG3.mjs";
import { t as getDb } from "./db_BQ9NAt8x.mjs";
import { t as $$Base } from "./Base_AuO_PBeT.mjs";
import { t as sanitizeContentBody } from "./sanitize_CLHlWQbC.mjs";
import { a as layers, i as getModule, r as getBlueprint } from "./catalogue_C7Gcv984.mjs";
import { env } from "cloudflare:workers";
//#region src/components/BlueprintGraph.astro
createAstro("https://astro.build");
var $$BlueprintGraph = createComponent(($$result, $$props, $$slots) => {
	const Astro = $$result.createAstro($$props, $$slots);
	Astro.self = $$BlueprintGraph;
	const { blueprintId } = Astro.props;
	const bp = getBlueprint(blueprintId);
	if (!bp) throw new Error(`Unknown blueprint: ${blueprintId}`);
	const CMS_PLUGIN_MODULES = [
		"content",
		"db",
		"auth",
		"seo",
		"uploads"
	];
	const nodeModules = [.../* @__PURE__ */ new Set([...bp.modules, ...CMS_PLUGIN_MODULES.filter((id) => bp.plugins.includes("cms"))])].map((id) => getModule(id)).filter((m) => !!m);
	const presentLayers = [
		"L3",
		"L2",
		"L1",
		"L0"
	].filter((lid) => nodeModules.some((m) => m.layer === lid));
	const LC = {
		L0: "var(--l0)",
		L1: "var(--l1)",
		L2: "var(--l2)",
		L3: "var(--l3)",
		UI: "var(--lUI)"
	};
	const W = 820;
	const boxW = 168;
	const boxH = 88;
	const rowH = 116;
	const bpY = 34;
	const presetY = 88;
	const hasPlugins = bp.plugins.length > 0;
	const pluginY = 128;
	const moduleStartY = (hasPlugins ? pluginY : presetY) + 14 + boxH / 2 + 24;
	const H = moduleStartY + (presentLayers.length - 1) * rowH + boxH / 2 + 34;
	const pos = {};
	pos[bp.id] = {
		x: W / 2,
		y: bpY,
		kind: "blueprint"
	};
	bp.presets.forEach((pid, i) => {
		const spread = 200;
		const x = W / 2 - spread / 2 + (bp.presets.length === 1 ? spread / 2 : spread * i / (bp.presets.length - 1));
		pos[`preset:${pid}`] = {
			x,
			y: presetY,
			kind: "preset"
		};
	});
	bp.plugins.forEach((plid, i) => {
		const x = W / 2 + (i - (bp.plugins.length - 1) / 2) * 90;
		pos[`plugin:${plid}`] = {
			x,
			y: pluginY,
			kind: "plugin"
		};
	});
	const areaLeft = 216;
	const span = 480;
	presentLayers.forEach((lid, i) => {
		const inLayer = nodeModules.filter((m) => m.layer === lid);
		const y = moduleStartY + i * rowH;
		inLayer.forEach((m, j) => {
			const x = inLayer.length === 1 ? 456 : areaLeft + span * j / (inLayer.length - 1);
			pos[m.id] = {
				x,
				y,
				kind: "module"
			};
		});
	});
	const nodeSet = new Set(Object.keys(pos).filter((k) => !k.includes(":")));
	const edges = [];
	for (const pid of bp.presets) edges.push({
		from: bp.id,
		to: `preset:${pid}`,
		dashed: true
	});
	for (const plid of bp.plugins) {
		edges.push({
			from: bp.id,
			to: `plugin:${plid}`,
			dashed: true
		});
		if (plid === "cms") {
			for (const mid of CMS_PLUGIN_MODULES) if (pos[mid]) edges.push({
				from: `plugin:${plid}`,
				to: mid
			});
		}
	}
	for (const m of nodeModules) for (const dep of m.deps) if (nodeSet.has(dep) && pos[m.id] && pos[dep]) edges.push({
		from: m.id,
		to: dep
	});
	function wirePath(a, b) {
		const my = (a.y + b.y) / 2;
		return `M${a.x},${a.y} C${a.x},${my} ${b.x},${my} ${b.x},${b.y}`;
	}
	function wrapLines(text, maxChars, maxLines) {
		const words = text.split(/\s+/).filter(Boolean);
		const lines = [];
		let cur = "";
		let i = 0;
		for (; i < words.length; i++) {
			const cand = cur ? `${cur} ${words[i]}` : words[i];
			if (cand.length <= maxChars) cur = cand;
			else {
				if (cur) lines.push(cur);
				cur = words[i];
				if (lines.length === maxLines - 1) break;
			}
		}
		if (lines.length < maxLines && cur) lines.push(cur);
		const consumed = lines.join(" ").replace(/\s+/g, " ").trim();
		const full = text.replace(/\s+/g, " ").trim();
		if (consumed.length < full.length && lines.length) {
			const last = lines[lines.length - 1];
			lines[lines.length - 1] = `${last.slice(0, Math.max(0, maxChars - 1)).trimEnd()}…`;
		}
		return lines;
	}
	const namedy = -20;
	const taglineTop = -2;
	const lineH = 13;
	const layerMeta = new Map(layers.map((l) => [l.id, l]));
	return renderTemplate`${maybeRenderHead($$result)}<div class="graph-wrap blueprint-graph" role="img"${addAttribute(`Architecture blueprint for ${bp.name}`, "aria-label")} data-astro-cid-4zcinyyx><svg class="blueprint-graph__svg"${addAttribute(`0 0 ${W} ${H}`, "viewBox")}${addAttribute(W, "width")}${addAttribute(H, "height")} xmlns="http://www.w3.org/2000/svg" data-astro-cid-4zcinyyx><defs data-astro-cid-4zcinyyx><pattern id="bp-grid" width="20" height="20" patternUnits="userSpaceOnUse" data-astro-cid-4zcinyyx><path d="M 20 0 L 0 0 0 20" fill="none" stroke="var(--graph-line)" stroke-width="0.5" opacity="0.35" data-astro-cid-4zcinyyx></path></pattern></defs><rect${addAttribute(W, "width")}${addAttribute(H, "height")} fill="url(#bp-grid)" opacity="0.4" data-astro-cid-4zcinyyx></rect><g class="wires" data-astro-cid-4zcinyyx>${edges.map((e) => {
		const a = pos[e.from];
		const b = pos[e.to];
		if (!a || !b) return null;
		return renderTemplate`<path${addAttribute(wirePath(a, b), "d")} fill="none"${addAttribute(e.dashed ? "var(--tpl-accent)" : "var(--l0)", "stroke")}${addAttribute(e.dashed ? "1.2" : "1.6", "stroke-width")}${addAttribute(e.dashed ? "4 3" : void 0, "stroke-dasharray")} opacity="0.85" data-astro-cid-4zcinyyx></path>`;
	})}</g><g class="blueprint-node" data-astro-cid-4zcinyyx><rect${addAttribute(pos[bp.id].x - 72, "x")}${addAttribute(pos[bp.id].y - 22, "y")} width="144" height="44" rx="2" fill="var(--mod-color-surface)" stroke="var(--bp-accent)" stroke-width="2" data-astro-cid-4zcinyyx></rect><text${addAttribute(pos[bp.id].x, "x")}${addAttribute(pos[bp.id].y + 5, "y")} text-anchor="middle" fill="var(--graph-ink)" font-size="14" font-weight="700" data-astro-cid-4zcinyyx>${bp.name}</text></g>${bp.presets.map((pid) => {
		const p = pos[`preset:${pid}`];
		if (!p) return null;
		return renderTemplate`<g data-astro-cid-4zcinyyx><rect${addAttribute(p.x - 36, "x")}${addAttribute(p.y - 14, "y")} width="72" height="28" rx="2" fill="var(--mod-color-surface)" stroke="var(--tpl-accent)" stroke-width="1.2" stroke-dasharray="3 2" data-astro-cid-4zcinyyx></rect><text${addAttribute(p.x, "x")}${addAttribute(p.y + 4, "y")} text-anchor="middle" fill="var(--graph-ink-soft)" font-size="11" data-astro-cid-4zcinyyx>preset:${pid}</text></g>`;
	})}${bp.plugins.map((plid) => {
		const p = pos[`plugin:${plid}`];
		if (!p) return null;
		return renderTemplate`<g data-astro-cid-4zcinyyx><rect${addAttribute(p.x - 40, "x")}${addAttribute(p.y - 14, "y")} width="80" height="28" rx="2" fill="var(--mod-color-surface)" stroke="var(--plg-accent)" stroke-width="1.2" data-astro-cid-4zcinyyx></rect><text${addAttribute(p.x, "x")}${addAttribute(p.y + 4, "y")} text-anchor="middle" fill="var(--plg-accent)" font-size="11" font-weight="600" data-astro-cid-4zcinyyx>${plid}</text></g>`;
	})}${presentLayers.map((lid, i) => {
		const cy = moduleStartY + i * rowH;
		const meta = layerMeta.get(lid);
		return renderTemplate`<g data-astro-cid-4zcinyyx><rect x="0"${addAttribute(cy - boxH / 2, "y")} width="4"${addAttribute(boxH, "height")} rx="2"${addAttribute(LC[lid], "fill")} opacity="0.55" data-astro-cid-4zcinyyx></rect><text x="16"${addAttribute(cy - 2, "y")}${addAttribute(LC[lid], "fill")} font-size="17" font-weight="800" data-astro-cid-4zcinyyx>${lid}</text><text x="16"${addAttribute(cy + 13, "y")} fill="var(--graph-ink-faint)" font-size="8" data-astro-cid-4zcinyyx>${meta?.name ?? lid}</text></g>`;
	})}<g class="module-rooms" data-astro-cid-4zcinyyx>${nodeModules.map((m) => {
		const p = pos[m.id];
		if (!p) return null;
		const tlines = wrapLines(m.tagline, 28, 3);
		return renderTemplate`<g${addAttribute(m.id, "data-module")} data-astro-cid-4zcinyyx><rect${addAttribute(p.x - boxW / 2, "x")}${addAttribute(p.y - boxH / 2, "y")}${addAttribute(boxW, "width")}${addAttribute(boxH, "height")} rx="3" fill="var(--mod-color-surface)"${addAttribute(LC[m.layer], "stroke")} stroke-width="1.2"${addAttribute(m.status !== "available" ? "4 2" : void 0, "stroke-dasharray")} data-astro-cid-4zcinyyx></rect><text${addAttribute(p.x, "x")}${addAttribute(p.y + namedy, "y")} text-anchor="middle" fill="var(--graph-ink)" font-size="13" font-weight="700" data-astro-cid-4zcinyyx>${m.name}</text>${tlines.map((ln, k) => renderTemplate`<text${addAttribute(p.x, "x")}${addAttribute(p.y + taglineTop + k * lineH, "y")} text-anchor="middle" fill="var(--graph-ink-faint)" font-size="9" data-astro-cid-4zcinyyx>${ln}</text>`)}<circle${addAttribute(p.x - boxW / 2 + 12, "cx")}${addAttribute(p.y + boxH / 2 - 11, "cy")} r="3"${addAttribute(m.status === "available" ? "var(--l0)" : "var(--graph-ink-faint)", "fill")} data-astro-cid-4zcinyyx></circle></g>`;
	})}</g></svg></div>`;
}, "/home/user/runs/run-20260823T175424Z-2fpke4/repo/apps/mod-cms/src/components/BlueprintGraph.astro", void 0);
//#endregion
//#region src/pages/blueprint/[slug].astro
var _slug__exports = /* @__PURE__ */ __exportAll({
	default: () => $$Slug,
	file: () => $$file,
	prerender: () => false,
	url: () => $$url
});
createAstro("https://astro.build");
var $$Slug = createComponent(async ($$result, $$props, $$slots) => {
	const Astro = $$result.createAstro($$props, $$slots);
	Astro.self = $$Slug;
	if (Astro.params.slug !== "cms") return new Response(null, { status: 404 });
	const bp = getBlueprint("bp-cms");
	if (!bp) return new Response(null, { status: 404 });
	let bodyHtml = null;
	try {
		const { db } = getDb(env);
		const entry = await getBySlug(db, "blueprint", "cms");
		if (entry?.status === "published" && entry.body) bodyHtml = entry.body;
	} catch {}
	const composedModules = [.../* @__PURE__ */ new Set([
		...bp.modules,
		"content",
		"db",
		"auth",
		"seo",
		"uploads"
	])].map((id) => getModule(id)).filter((m) => !!m);
	return renderTemplate`${renderComponent($$result, "Base", $$Base, {
		"title": `${bp.name} blueprint · mod-cms`,
		"description": bp.tagline
	}, { "default": ($$result) => renderTemplate`${maybeRenderHead($$result)}<p class="page-meta"><a href="/">← Home</a></p><p class="hero__eyebrow">Blueprint</p><h1>${bp.name}</h1><p>${bp.tagline}</p>${renderComponent($$result, "BlueprintGraph", $$BlueprintGraph, { "blueprintId": "bp-cms" })}${bodyHtml ? renderTemplate`<div class="cms-body">${unescapeHTML(sanitizeContentBody(bodyHtml))}</div>` : renderTemplate`<p>${bp.tagline}</p>`}<section class="section"><h2>Composed modules</h2><div class="card-grid">${composedModules.map((mod) => renderTemplate`<a class="card"${addAttribute(`/module/${mod.id}`, "href")}><div class="card__name">${mod.name}</div><p class="card__tagline">${mod.tagline}</p><span class="card__layer">${mod.layer}</span></a>`)}</div></section>` })}`;
}, "/home/user/runs/run-20260823T175424Z-2fpke4/repo/apps/mod-cms/src/pages/blueprint/[slug].astro", void 0);
var $$file = "/home/user/runs/run-20260823T175424Z-2fpke4/repo/apps/mod-cms/src/pages/blueprint/[slug].astro";
var $$url = "/blueprint/[slug]";
//#endregion
//#region \0virtual:astro:page:src/pages/blueprint/[slug]@_@astro
var page = () => _slug__exports;
//#endregion
export { page };
