import type { components } from '$lib/generated/api';

type TagTreeNodeDTO = components['schemas']['TagTreeNodeDTO'];

/**
 * Whether a tag's whole subtree holds any documents — keyed on the subtree rollup
 * (`subtreeDocumentCount`), which the backend already computes across all descendants.
 * Used by the reader surfaces (/themen page, dashboard ThemenWidget) to hide empty topics.
 * A single field read: no recursion needed, the rollup is authoritative.
 */
export function hasAnyDocuments(node: TagTreeNodeDTO): boolean {
	return (node.subtreeDocumentCount ?? 0) > 0;
}
