import "../../../../../../dialect-helpers-DRI5pyY3.mjs";
import "../../../../../../after-B1IIdH3Y.mjs";
import "../../../../../../object-cache-Bok5j2ae.mjs";
import "../../../../../../content-DhgEth4k.mjs";
import "../../../../../../base64-CmWvODNW.mjs";
import "../../../../../../types-CuW0zWDA.mjs";
import "../../../../../../media-BrXIaMFN.mjs";
import "../../../../../../user-BjAOvU3Z.mjs";
import "../../../../../../taxonomy-BxGxZZdu.mjs";
import "../../../../../../comment-CzeatwBV.mjs";
import "../../../../../../options-DTTML-Tx.mjs";
import "../../../../../../menus-Cfivc2Ad.mjs";
import "../../../../../../redirect-IyfNirgS.mjs";
import "../../../../../../request-cache-KCNHp_RJ.mjs";
import "../../../../../../byline-registry-BOjqDOim.mjs";
import "../../../../../../field-defs-cache-WUI88LX5.mjs";
import "../../../../../../byline-Bm8ZgUP9.mjs";
import "../../../../../../seo-DXu2UQnC.mjs";
import { d as handleMarketplaceSearch } from "../../../../../../api-BFURZn1i.mjs";
import "../../../../../../dashboard-EvEKF5en.mjs";
import "../../../../../../content-refresh-CA4uKwzH.mjs";
import "../../../../../../fts-manager-BbFaF_V8.mjs";
import "../../../../../../registry-B65mUtPa.mjs";
import "../../../../../../loader-CB6YHeul.mjs";
import "../../../../../../schema-Blhoxp3P.mjs";
import "../../../../../../zod-generator-CacrR-i8.mjs";
import "../../../../../../seo-89-53DDs.mjs";
import "../../../../../../sections-CpF5SaGr.mjs";
import "../../../../../../settings-zhmdKyJQ.mjs";
import "../../../../../../settings-rZyHEcNT.mjs";
import "../../../../../../resolve-DR3wqMTy.mjs";
import "../../../../../../taxonomies-Cnb4F-Pb.mjs";
import "../../../../../../taxonomies-BGBd16Eu.mjs";
import "../../../../../../manifest-schema-BHlgZM1W.mjs";
import "../../../../../../types-DROWRxYV.mjs";
import "../../../../../../ssrf-1g7usGBg.mjs";
import { a as unwrapResult, t as apiError } from "../../../../../../error-CkAseSqZ.mjs";
import "../../../../../../parse-GmjecGct.mjs";
import "../../../../../../redirects-DXEXBAII.mjs";
import "../../../../../../byline-fields-2Lp5Hbgf.mjs";
import "../../../../../../status-CqJQX1QN.mjs";
import { n as requirePerm } from "../../../../../../authorize-Dz88F_Fw.mjs";

//#region src/astro/routes/api/admin/plugins/marketplace/index.ts
const prerender = false;
const GET = async ({ url, locals }) => {
	const { emdash, user } = locals;
	if (!emdash?.db) return apiError("NOT_CONFIGURED", "EmDash is not initialized", 500);
	const denied = requirePerm(user, "plugins:read");
	if (denied) return denied;
	const query = url.searchParams.get("q") ?? void 0;
	const category = url.searchParams.get("category") ?? void 0;
	const cursor = url.searchParams.get("cursor") ?? void 0;
	const limitParam = url.searchParams.get("limit");
	const limit = limitParam ? Math.min(Math.max(1, parseInt(limitParam, 10) || 50), 100) : void 0;
	return unwrapResult(await handleMarketplaceSearch(emdash.config.marketplace, query, {
		category,
		cursor,
		limit
	}));
};

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