globalThis.process ??= {};
globalThis.process.env ??= {};
import { r as __exportAll } from "./rolldown-runtime_-UtK6b3T.mjs";
import { d as renderTemplate, i as renderComponent, w as createAstro } from "./server_DAChoow1.mjs";
import { t as createComponent } from "./compiler_CLrjY88v.mjs";
import { A as getById, c as isEntityId } from "./crypto_CY2zBtG3.mjs";
import { n as getFullDb } from "./db_BQ9NAt8x.mjs";
import { i as requireAdmin } from "./auth_B0DWM0G6.mjs";
import { t as AdminApp } from "./AdminApp_Bgy8QKyU.mjs";
import { t as $$Base } from "./Base_AuO_PBeT.mjs";
import { env } from "cloudflare:workers";
//#region src/pages/admin/content/[id].astro
var _id__exports = /* @__PURE__ */ __exportAll({
	default: () => $$Id,
	file: () => $$file,
	prerender: () => false,
	url: () => $$url
});
createAstro("https://astro.build");
var $$Id = createComponent(async ($$result, $$props, $$slots) => {
	const Astro = $$result.createAstro($$props, $$slots);
	Astro.self = $$Id;
	const idParam = Astro.params.id;
	let entry = null;
	try {
		const { actor } = await requireAdmin(Astro.request, env, Astro.cookies);
		if (idParam && idParam !== "new") {
			if (!isEntityId(idParam)) return Astro.redirect("/admin");
			entry = await getById(getFullDb(env).db, idParam, actor);
			if (entry == null) return Astro.redirect("/admin");
		}
	} catch (error) {
		const name = error.name;
		if (name === "InvalidSessionError" || name === "RoleDeniedError") return Astro.redirect("/admin/login");
		throw error;
	}
	return renderTemplate`${renderComponent($$result, "Base", $$Base, {
		"title": entry ? "Edit post · mod-cms admin" : "New post · mod-cms admin",
		"description": "Admin content editor for mod-cms"
	}, { "default": ($$result) => renderTemplate`${renderComponent($$result, "AdminApp", AdminApp, {
		"client:load": true,
		"screen": "editor",
		"entry": entry,
		"client:component-hydration": "load",
		"client:component-path": "/home/user/runs/run-20260823T175424Z-2fpke4/repo/apps/mod-cms/src/components/admin/AdminApp.tsx",
		"client:component-export": "default"
	})}` })}`;
}, "/home/user/runs/run-20260823T175424Z-2fpke4/repo/apps/mod-cms/src/pages/admin/content/[id].astro", void 0);
var $$file = "/home/user/runs/run-20260823T175424Z-2fpke4/repo/apps/mod-cms/src/pages/admin/content/[id].astro";
var $$url = "/admin/content/[id]";
//#endregion
//#region \0virtual:astro:page:src/pages/admin/content/[id]@_@astro
var page = () => _id__exports;
//#endregion
export { page };
