<?php
/**
 * File Path: includes/blocks/class-mbs-block-series-directory.php
 *
 * Series Directory Block — Render
 *
 * PHP render_callback for the mbs/series-directory Gutenberg block.
 * Registered by MBS_Blocks_Registry::register_series_directory_block().
 *
 * Renders an accordion listing every series with their books in reading
 * order. Delegates to MBS_Shortcode_Series_Directory::render(). PRO-gated.
 *
 * Attributes:
 *   sort (string) — Sort series by 'name' or 'name_sort' (article-stripped). Default 'name'.
 *
 * @package    My_Book_Showroom
 * @subpackage Includes/Blocks
 * @since      1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class MBS_Block_Series_Directory { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- mbs_/MBS_ prefix is correct; scanner not configured with plugin prefix

	public static function render( array $attributes ): string {
		if ( ! mbs_is_registered() ) {
			return '';
		}
		// PRO gate enforced inside MBS_Shortcode_Series_Directory::render().

		$sort = in_array( $attributes['sort'] ?? 'name', array( 'name', 'name_sort' ), true )
			? $attributes['sort']
			: 'name';

		return MBS_Shortcode_Series_Directory::render( array( 'sort' => $sort ) );
	}
}
