import "../../../../../after-B1IIdH3Y.mjs";
import "../../../../../object-cache-Bok5j2ae.mjs";
import "../../../../../base64-CmWvODNW.mjs";
import "../../../../../types-CuW0zWDA.mjs";
import "../../../../../comment-CzeatwBV.mjs";
import { a as unwrapResult, i as requireDb, r as handleError, t as apiError } from "../../../../../error-CkAseSqZ.mjs";
import { n as requirePerm } from "../../../../../authorize-Dz88F_Fw.mjs";
import { a as handleCommentGet, i as handleCommentDelete } from "../../../../../comments-BLE-jv5k.mjs";

//#region src/astro/routes/api/admin/comments/[id].ts
const prerender = false;
/**
* Get single comment detail (includes moderation_metadata)
*/
const GET = async ({ params, locals }) => {
	const { emdash, user } = locals;
	const { id } = params;
	if (!id) return apiError("VALIDATION_ERROR", "Comment ID required", 400);
	const dbErr = requireDb(emdash?.db);
	if (dbErr) return dbErr;
	const denied = requirePerm(user, "comments:moderate");
	if (denied) return denied;
	try {
		return unwrapResult(await handleCommentGet(emdash.db, id));
	} catch (error) {
		return handleError(error, "Failed to get comment", "COMMENT_GET_ERROR");
	}
};
/**
* Hard delete a comment (ADMIN only)
*/
const DELETE = async ({ params, locals }) => {
	const { emdash, user } = locals;
	const { id } = params;
	if (!id) return apiError("VALIDATION_ERROR", "Comment ID required", 400);
	const dbErr = requireDb(emdash?.db);
	if (dbErr) return dbErr;
	const denied = requirePerm(user, "comments:delete");
	if (denied) return denied;
	try {
		return unwrapResult(await handleCommentDelete(emdash.db, id));
	} catch (error) {
		return handleError(error, "Failed to delete comment", "COMMENT_DELETE_ERROR");
	}
};

//#endregion
export { DELETE, GET, prerender };
//# sourceMappingURL=_id_.mjs.map