import "../../../../../after-B1IIdH3Y.mjs";
import "../../../../../object-cache-Bok5j2ae.mjs";
import "../../../../../base64-CmWvODNW.mjs";
import "../../../../../types-CuW0zWDA.mjs";
import { o as handleMenuItemReorder } from "../../../../../menus-Cfivc2Ad.mjs";
import { a as unwrapResult, r as handleError } from "../../../../../error-CkAseSqZ.mjs";
import { i as parseQuery, n as parseBody, t as isParseError } from "../../../../../parse-GmjecGct.mjs";
import { Fn as localeFilterQuery, st as reorderMenuItemsBody } from "../../../../../redirects-DXEXBAII.mjs";
import "../../../../../byline-fields-2Lp5Hbgf.mjs";
import "../../../../../status-CqJQX1QN.mjs";
import "../../../../../api/schemas/index.mjs";
import { n as requirePerm } from "../../../../../authorize-Dz88F_Fw.mjs";

//#region src/astro/routes/api/menus/[name]/reorder.ts
const prerender = false;
const POST = async ({ params, request, locals }) => {
	const { emdash, user } = locals;
	const name = params.name;
	const denied = requirePerm(user, "menus:manage");
	if (denied) return denied;
	const localeQ = parseQuery(new URL(request.url), localeFilterQuery);
	if (isParseError(localeQ)) return localeQ;
	try {
		const body = await parseBody(request, reorderMenuItemsBody);
		if (isParseError(body)) return body;
		return unwrapResult(await handleMenuItemReorder(emdash.db, name, body.items, { locale: localeQ.locale }));
	} catch (error) {
		return handleError(error, "Failed to reorder menu items", "MENU_REORDER_ERROR");
	}
};

//#endregion
export { POST, prerender };
//# sourceMappingURL=reorder.mjs.map