globalThis.process ??= {};
globalThis.process.env ??= {};
import { r as __exportAll } from "./rolldown-runtime_-UtK6b3T.mjs";
import { d as renderTemplate, i as renderComponent } from "./server_DAChoow1.mjs";
import { t as createComponent } from "./compiler_CLrjY88v.mjs";
import { M as list, S as parseHomepage, g as getSetting, j as getBySlug, m as SETTINGS_KEYS, p as DEFAULT_SITE_NAME, w as parseSiteIdentity } from "./crypto_CY2zBtG3.mjs";
import { n as getFullDb } from "./db_BQ9NAt8x.mjs";
import { i as $$DefaultIndexBody, p as resolveScreen, t as resolveModTheme } from "./registry_CB_IcduS.mjs";
import { t as $$Base } from "./Base_AuO_PBeT.mjs";
import { t as loadAppearanceSelection } from "./appearance-server_BGcx6aOu.mjs";
import { i as getModule, t as MOD_CMS_MODULES } from "./catalogue_C7Gcv984.mjs";
import { env } from "cloudflare:workers";
//#region src/pages/index.astro
var pages_exports = /* @__PURE__ */ __exportAll({
	default: () => $$Index,
	file: () => $$file,
	prerender: () => false,
	url: () => ""
});
var $$Index = createComponent(async ($$result, $$props, $$slots) => {
	let heroHtml = "<p>mod-cms is a content management distribution built on the platform — pages, posts, and site settings you author through a standard interface, served with server-rendered HTML.</p>";
	let posts = [];
	let siteName = DEFAULT_SITE_NAME;
	try {
		const { db } = getFullDb(env);
		const rawSiteName = await getSetting(db, SETTINGS_KEYS.siteName);
		siteName = parseSiteIdentity(rawSiteName, null).name;
		const homepage = parseHomepage(await getSetting(db, SETTINGS_KEYS.homepage));
		let pageBody = null;
		if (homepage.mode === "page") {
			const chosen = await getBySlug(db, "page", homepage.slug, null);
			if (chosen?.body) pageBody = chosen.body;
		}
		const home = await getBySlug(db, "page", "home", null);
		if (pageBody) heroHtml = pageBody;
		else if (home?.body) heroHtml = home.body;
		posts = await list(db, {
			status: "published",
			type: "post"
		}, null);
	} catch {}
	const modCards = MOD_CMS_MODULES.map((id) => getModule(id)).filter((m) => !!m);
	const selection = await loadAppearanceSelection(env);
	const IndexBody = resolveScreen(resolveModTheme(selection.themeId), "index", $$DefaultIndexBody);
	return renderTemplate`${renderComponent($$result, "Base", $$Base, {
		"title": "mod-cms",
		"description": "A content distribution built on the platform",
		"selection": selection
	}, { "default": ($$result) => renderTemplate`${renderComponent($$result, "IndexBody", IndexBody, {
		"siteName": siteName,
		"heroHtml": heroHtml,
		"posts": posts.map((p) => ({
			slug: p.slug,
			title: p.title,
			createdAt: p.createdAt?.toISOString() ?? ""
		})),
		"modCards": modCards
	})}` })}`;
}, "/home/user/runs/run-20260823T175424Z-2fpke4/repo/apps/mod-cms/src/pages/index.astro", void 0);
var $$file = "/home/user/runs/run-20260823T175424Z-2fpke4/repo/apps/mod-cms/src/pages/index.astro";
//#endregion
//#region \0virtual:astro:page:src/pages/index@_@astro
var page = () => pages_exports;
//#endregion
export { page };
