import "../../../../dialect-helpers-DRI5pyY3.mjs";
import "../../../../base64-CmWvODNW.mjs";
import "../../../../types-CuW0zWDA.mjs";
import "../../../../fts-manager-BbFaF_V8.mjs";
import "../../../../loader-CB6YHeul.mjs";
import { n as apiSuccess, r as handleError, t as apiError } from "../../../../error-CkAseSqZ.mjs";
import { i as getSearchStats } from "../../../../search-DZN2HZ-V.mjs";
import { n as requirePerm } from "../../../../authorize-Dz88F_Fw.mjs";

//#region src/astro/routes/api/search/stats.ts
const prerender = false;
/**
* Get search index statistics
*/
const GET = async ({ locals }) => {
	const { emdash, user } = locals;
	const denied = requirePerm(user, "search:manage");
	if (denied) return denied;
	if (!emdash?.db) return apiError("NOT_CONFIGURED", "EmDash not configured", 500);
	try {
		return apiSuccess(await getSearchStats(emdash.db));
	} catch (error) {
		return handleError(error, "Failed to get stats", "STATS_ERROR");
	}
};

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