<?php
/**
 * File Path: includes/blocks/class-mbs-block-timeline.php
 *
 * mbs/timeline Block Render -- DISPLAY-1
 *
 * PHP render_callback for the mbs/timeline Gutenberg block.
 * Delegates to MBS_Shortcode_Timeline::render() so block and shortcode
 * output are always identical.
 *
 * Attributes:
 *   bookId (number) -- Book post ID. Default 0 (uses current post).
 *
 * @package    My_Book_Showroom
 * @subpackage Includes/Blocks
 * @since      1.0.0
 */

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

/**
 * Class MBS_Block_Timeline
 *
 * Render callback for the mbs/timeline Gutenberg block.
 *
 * @since 1.0.0
 */
class MBS_Block_Timeline {

	/**
	 * Render the mbs/timeline block.
	 *
	 * @param array $attributes Block attribute values.
	 * @return string Rendered HTML.
	 */
	public static function render( array $attributes ): string {
		$book_id = max( 0, (int) ( $attributes['bookId'] ?? 0 ) );
		return MBS_Shortcode_Timeline::render( array( 'book_id' => $book_id ) );
	}
}
