globalThis.process ??= {};
globalThis.process.env ??= {};
import { r as __exportAll } from "./rolldown-runtime_-UtK6b3T.mjs";
import { d as mapContentError, u as jsonOk } from "./crypto_CY2zBtG3.mjs";
import { f as createDbNotificationStore } from "./db_BQ9NAt8x.mjs";
import { a as requireEditor } from "./auth_B0DWM0G6.mjs";
import { r as getNotificationsDb } from "./notifications_aUOPzd3M.mjs";
import { env } from "cloudflare:workers";
//#region src/pages/api/admin/notifications/index.ts
var notifications_exports = /* @__PURE__ */ __exportAll({
	GET: () => GET,
	prerender: () => false
});
var GET = async ({ request, cookies, url }) => {
	try {
		const { actor } = await requireEditor(request, env, cookies);
		const cursor = url.searchParams.get("cursor") ?? void 0;
		const limitRaw = url.searchParams.get("limit");
		const limit = limitRaw ? Number(limitRaw) : void 0;
		const unreadOnly = url.searchParams.get("unreadOnly") === "true";
		const result = await createDbNotificationStore(getNotificationsDb(env)).list(actor.id, {
			...cursor ? { cursor } : {},
			...limit !== void 0 && Number.isFinite(limit) ? { limit } : {},
			...unreadOnly ? { unreadOnly } : {}
		});
		return jsonOk(result);
	} catch (error) {
		return mapContentError(error);
	}
};
//#endregion
//#region \0virtual:astro:page:src/pages/api/admin/notifications/index@_@ts
var page = () => notifications_exports;
//#endregion
export { page };
