import { a as __exportAll } from "./runner-K8XK101B.mjs";
import { n as cachedQuery, t as CacheNamespace } from "./object-cache-Bok5j2ae.mjs";
import { r as requestCached } from "./request-cache-KCNHp_RJ.mjs";
import { n as SchemaRegistry } from "./registry-B65mUtPa.mjs";
import { a as getDb } from "./loader-CB6YHeul.mjs";

//#region src/schema/query.ts
/**
* Get collection metadata by slug.
*
* @example
* ```ts
* import { getCollectionInfo } from "emdash";
*
* const info = await getCollectionInfo("posts");
* if (info?.commentsEnabled) {
*   // render comment UI
* }
* ```
*/
async function getCollectionInfo(slug) {
	return requestCached(`collection-info:${slug}`, () => cachedQuery({
		namespace: CacheNamespace.SCHEMA,
		key: `collection-info:${slug}`,
		load: async () => {
			return getCollectionInfoWithDb(await getDb(), slug);
		}
	}));
}
/**
* Get collection metadata with an explicit db handle.
*
* @internal Use `getCollectionInfo()` in templates. This variant is for
* routes that already have a database handle.
*/
async function getCollectionInfoWithDb(db, slug) {
	return new SchemaRegistry(db).getCollection(slug);
}

//#endregion
//#region src/schema/index.ts
var schema_exports = /* @__PURE__ */ __exportAll({ SchemaRegistry: () => SchemaRegistry });

//#endregion
export { getCollectionInfo as n, schema_exports as t };
//# sourceMappingURL=schema-Blhoxp3P.mjs.map