<?php
/**
 * File Path: includes/blocks/class-mbs-block-genre-cloud.php
 *
 * Genre Cloud Block — Render
 *
 * PHP render_callback for the mbs/genre-cloud Gutenberg block.
 * Registered by MBS_Blocks_Registry::register_genre_cloud_block().
 *
 * Renders a tag-cloud of genres with font sizes scaled by book count.
 * Delegates to MBS_Shortcode_Genre_Cloud::render(). FREE tier.
 *
 * Attributes:
 *   min_count (number) — Hide genres with fewer than this many books. Default 1.
 *   limit     (number) — Max genres shown (0 = unlimited). Default 30.
 *   min_size  (number) — Smallest font size in px. Default 12.
 *   max_size  (number) — Largest font size in px. Default 22.
 *
 * @package    My_Book_Showroom
 * @subpackage Includes/Blocks
 * @since      1.0.0
 */

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

class MBS_Block_Genre_Cloud { // 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 '';
		}

		return MBS_Shortcode_Genre_Cloud::render( array(
			'min_count' => max( 1, (int) ( $attributes['min_count'] ?? 1 ) ),
			'limit'     => max( 0, (int) ( $attributes['limit']     ?? 30 ) ),
			'min_size'  => max( 8, (int) ( $attributes['min_size']  ?? 12 ) ),
			'max_size'  => max( 8, (int) ( $attributes['max_size']  ?? 22 ) ),
		) );
	}
}
