globalThis.process ??= {};
globalThis.process.env ??= {};
import { r as __exportAll } from "./rolldown-runtime_-UtK6b3T.mjs";
import { V as unpublish, d as mapContentError, f as parseIdBody, u as jsonOk } from "./crypto_CY2zBtG3.mjs";
import { n as getFullDb } from "./db_BQ9NAt8x.mjs";
import { n as recordAudit, t as clientIp } from "./audit_D9EAE4GF.mjs";
import { a as requireEditor, c as assertCsrf } from "./auth_B0DWM0G6.mjs";
import { env } from "cloudflare:workers";
//#region src/pages/api/admin/unpublish.ts
var unpublish_exports = /* @__PURE__ */ __exportAll({
	POST: () => POST,
	prerender: () => false
});
var POST = async ({ request, cookies }) => {
	try {
		const { actor, authMode } = await requireEditor(request, env, cookies);
		assertCsrf(request, {
			authMode,
			siteOrigin: env.SITE_ORIGIN
		});
		const { db } = getFullDb(env);
		const id = parseIdBody(await request.json());
		const ref = await unpublish(db, id, actor);
		await recordAudit(db, {
			actorId: actor.id,
			ip: clientIp(request)
		}, {
			action: "content.unpublish",
			entityType: "content",
			entityId: id
		});
		return jsonOk(ref);
	} catch (error) {
		return mapContentError(error);
	}
};
//#endregion
//#region \0virtual:astro:page:src/pages/api/admin/unpublish@_@ts
var page = () => unpublish_exports;
//#endregion
export { page };
