import { registerSerializer } from '../registry.js';
function baseSingle(entity) {
    return {
        type: 'database-table',
        slug: entity.slug,
        name: entity.data.name,
        description: entity.data.description ?? null,
        columns: entity.data.columns ?? [],
        indexes: entity.data.indexes ?? [],
        tags: entity.tags,
    };
}
const databaseTableSerializer = {
    type: 'database-table',
    version: '1.0.0',
    inlineMention: (entity) => ({
        type: 'database-table',
        slug: entity.slug,
        label: entity.data.name ?? entity.slug,
        href: `/database-tables/${entity.slug}`,
    }),
    singleElement: (entity) => baseSingle(entity),
    elementListItem: (entity) => {
        const { indexes: _indexes, ...trim } = baseSingle(entity);
        return trim;
    },
    taggedListItem: (entity) => {
        const { indexes: _indexes, ...trim } = baseSingle(entity);
        return trim;
    },
    detail: (entity, ctx) => {
        const base = baseSingle(entity);
        const references = ctx.reader.findSectionReferences('database-table', entity.id).map((r) => ({
            anchor: r.anchor,
            pagePath: r.pagePath,
            headingText: r.headingText,
            relation: r.relation,
        }));
        return {
            ...base,
            _references: references,
        };
    },
};
registerSerializer(databaseTableSerializer);
//# sourceMappingURL=database-table.js.map