<?php
/**
 * File Path: includes/blocks/class-mbs-block-definitions.php
 *
 * Block Definitions Data
 *
 * Returns the static definition array consumed by MBS_Blocks_Registry::register().
 * Each entry must have: name (string), class (string), attributes (array).
 *
 * To add a new block: create class-mbs-block-[name].php with a static render()
 * method, then append one entry to MBS_Block_Definitions::get(). Do not add
 * render logic here.
 *
 * @package    My_Book_Showroom
 * @subpackage Includes/Blocks
 * @since      1.0.0
 */

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

/**
 * Class MBS_Block_Definitions
 *
 * Provides the canonical block definition array for all MBS Gutenberg blocks.
 * Called exclusively by MBS_Blocks_Registry::register().
 *
 * @since 1.0.0
 */
class MBS_Block_Definitions {

	/**
	 * Returns the full block definition array.
	 *
	 * Each entry:
	 *   'name'       => block slug (string)
	 *   'class'      => render class name (string)
	 *   'attributes' => block attribute schema (array)
	 *
	 * To add a block: append an entry here, then create the matching render class.
	 *
	 * @return array<int, array{name: string, class: string, attributes: array}>
	 */
	public static function get(): array {
		return array(

			// Featured Book -- cover, teaser, buy links for a single book (FREE).
			array(
				'name'       => 'mbs/featured-book',
				'class'      => 'MBS_Block_Featured_Book',
				'attributes' => array(
					'bookId' => array( 'type' => 'number' ),
					'title'  => array( 'type' => 'string' ),
				),
			),

			// Book Grid -- filterable grid using [mbs_books] params (FREE).
			array(
				'name'       => 'mbs/book-grid',
				'class'      => 'MBS_Block_Book_Grid',
				'attributes' => array(
					'limit'      => array( 'type' => 'number',  'default' => 6     ),
					'columns'    => array( 'type' => 'number',  'default' => 3     ), // BLK-GRID-1
					'orderby'    => array( 'type' => 'string',  'default' => 'date' ),
					'show_cover' => array( 'type' => 'boolean', 'default' => true  ),
					'author'     => array( 'type' => 'string',  'default' => ''    ),
					'series'     => array( 'type' => 'string',  'default' => ''    ),
					'genre'      => array( 'type' => 'string',  'default' => ''    ),
					'tag'        => array( 'type' => 'string',  'default' => ''    ),
				),
			),

			// Buy Links -- format row buy buttons for a book (FREE).
			array(
				'name'       => 'mbs/buy-links',
				'class'      => 'MBS_Block_Buy_Links',
				'attributes' => array(
					'bookId'  => array( 'type' => 'number' ),
					'context' => array( 'type' => 'string', 'default' => 'single' ),
				),
			),

			// Term List -- linked grid of all terms in a taxonomy (FREE).
			array(
				'name'       => 'mbs/term-list',
				'class'      => 'MBS_Block_Term_List',
				'attributes' => array(
					'taxonomy'   => array( 'type' => 'string',  'default' => MBS_TAX_AUTHOR ),
					'columns'    => array( 'type' => 'number',  'default' => 3            ),
					'show_count' => array( 'type' => 'boolean', 'default' => false        ),
				),
			),

			// Single Book -- full single-book display via [mbs_book id="X"] (FREE).
			array(
				'name'       => 'mbs/single-book',
				'class'      => 'MBS_Block_Single_Book',
				'attributes' => array(
					'bookId' => array( 'type' => 'number' ),
				),
			),

			// Series -- description + reading order + book grid (FREE).
			array(
				'name'       => 'mbs/series',
				'class'      => 'MBS_Block_Series',
				'attributes' => array(
					'slug'     => array( 'type' => 'string', 'default' => ''  ),
					'per_page' => array( 'type' => 'number', 'default' => 20 ),
				),
			),

			// Universe -- description + optional PRO reading order + book grid (FREE).
			array(
				'name'       => 'mbs/universe',
				'class'      => 'MBS_Block_Universe',
				'attributes' => array(
					'slug'     => array( 'type' => 'string', 'default' => ''  ),
					'per_page' => array( 'type' => 'number', 'default' => 20 ),
				),
			),

			// Collection -- type label + description + optional PRO order + grid (FREE).
			array(
				'name'       => 'mbs/collection',
				'class'      => 'MBS_Block_Collection',
				'attributes' => array(
					'slug'     => array( 'type' => 'string', 'default' => ''  ),
					'per_page' => array( 'type' => 'number', 'default' => 20 ),
				),
			),

			// Genre -- description + book grid (FREE).
			array(
				'name'       => 'mbs/genre',
				'class'      => 'MBS_Block_Genre',
				'attributes' => array(
					'slug'     => array( 'type' => 'string', 'default' => ''  ),
					'per_page' => array( 'type' => 'number', 'default' => 20 ),
				),
			),

			// Tags -- book grid filtered by mbs_tag taxonomy term (FREE). BLK-002.
			array(
				'name'       => 'mbs/tags',
				'class'      => 'MBS_Block_Tags',
				'attributes' => array(
					'slug'     => array( 'type' => 'string', 'default' => ''  ),
					'per_page' => array( 'type' => 'number', 'default' => 20 ),
				),
			),

			// Author -- bio + social links + optional PRO hero + book grid (S13-16 FSE).
			array(
				'name'       => 'mbs/author',
				'class'      => 'MBS_Block_Author',
				'attributes' => array(
					'slug'     => array( 'type' => 'string', 'default' => ''     ),
					'per_page' => array( 'type' => 'number', 'default' => 20     ),
					'layout'   => array( 'type' => 'string', 'default' => 'grid' ),
				),
			),

			// Genre Cloud -- tag cloud scaled by book count (FREE).
			array(
				'name'       => 'mbs/genre-cloud',
				'class'      => 'MBS_Block_Genre_Cloud',
				'attributes' => array(
					'min_count' => array( 'type' => 'number', 'default' => 1  ),
					'limit'     => array( 'type' => 'number', 'default' => 30 ),
					'min_size'  => array( 'type' => 'number', 'default' => 12 ),
					'max_size'  => array( 'type' => 'number', 'default' => 22 ),
				),
			),

			// Search -- live AJAX book search widget (FREE).
			array(
				'name'       => 'mbs/search',
				'class'      => 'MBS_Block_Search',
				'attributes' => array(),
			),

			// Author Directory -- author grid with bio, book counts, A-Z filter (PRO).
			array(
				'name'       => 'mbs/author-directory',
				'class'      => 'MBS_Block_Author_Directory',
				'attributes' => array(
					'columns'             => array( 'type' => 'number',  'default' => 3            ),
					'show_count'          => array( 'type' => 'boolean', 'default' => true         ),
					'show_bio'            => array( 'type' => 'boolean', 'default' => true         ),
					'bio_length'          => array( 'type' => 'number',  'default' => 120          ),
					'show_website'        => array( 'type' => 'boolean', 'default' => true         ),
					'show_featured_first' => array( 'type' => 'boolean', 'default' => true         ),
					'show_filter'         => array( 'type' => 'boolean', 'default' => true         ),
					'orderby'             => array( 'type' => 'string',  'default' => 'name'       ),
					'order'               => array( 'type' => 'string',  'default' => 'ASC'        ),
					'sort'                => array( 'type' => 'string',  'default' => 'first_name' ),
				),
			),

			// Series Directory -- accordion of all series with reading-order lists (PRO).
			array(
				'name'       => 'mbs/series-directory',
				'class'      => 'MBS_Block_Series_Directory',
				'attributes' => array(
					'sort' => array( 'type' => 'string', 'default' => 'name' ),
				),
			),

			// Book Cover -- cover image via MBS_Cover_Renderer (FREE/PRO enhancements).
			array(
				'name'       => 'mbs/book-cover',
				'class'      => 'MBS_Block_Book_Cover',
				'attributes' => array(
					'bookId'       => array( 'type' => 'number',  'default' => 0    ),
					'link_to_book' => array( 'type' => 'boolean', 'default' => true ),
				),
			),

			// Book Teaser -- mbs_teaser postmeta blurb, optional cover thumbnail (FREE).
			array(
				'name'       => 'mbs/book-teaser',
				'class'      => 'MBS_Block_Book_Teaser',
				'attributes' => array(
					'bookId'     => array( 'type' => 'number',  'default' => 0     ),
					'show_cover' => array( 'type' => 'boolean', 'default' => false ),
				),
			),

			// Endorsements -- endorsements / blurbs list for a book (FREE).
			array(
				'name'       => 'mbs/endorsements',
				'class'      => 'MBS_Block_Endorsements',
				'attributes' => array(
					'bookId' => array( 'type' => 'number', 'default' => 0 ),
				),
			),

			// Reading Order -- numbered reading-order list for a series (PRO).
			array(
				'name'       => 'mbs/reading-order',
				'class'      => 'MBS_Block_Reading_Order',
				'attributes' => array(
					'slug' => array( 'type' => 'string', 'default' => '' ),
				),
			),

			// New Releases -- books published within last N days (FREE).
			array(
				'name'       => 'mbs/new-releases',
				'class'      => 'MBS_Block_New_Releases',
				'attributes' => array(
					'limit' => array( 'type' => 'number', 'default' => 6  ),
					'days'  => array( 'type' => 'number', 'default' => 30 ),
				),
			),

			// Coming Soon -- books with coming_soon lifecycle state (PRO-gated render).
			array(
				'name'       => 'mbs/coming-soon',
				'class'      => 'MBS_Block_Coming_Soon',
				'attributes' => array(
					'limit' => array( 'type' => 'number', 'default' => 6 ),
				),
			),

			// Book Club -- Book Club Resources section for a book (PRO).
			array(
				'name'       => 'mbs/book-club',
				'class'      => 'MBS_Block_Book_Club',
				'attributes' => array(
					'postId' => array( 'type' => 'number', 'default' => 0 ),
				),
			),

			// Related Books -- shared genre/series/collection terms (PRO).
			array(
				'name'       => 'mbs/related-books',
				'class'      => 'MBS_Block_Related_Books',
				'attributes' => array(
					'bookId' => array( 'type' => 'number', 'default' => 0 ),
					'limit'  => array( 'type' => 'number', 'default' => 6 ),
					'layout' => array( 'type' => 'string', 'default' => 'grid' ),
				),
			),

			// Bestseller Badge/List -- books by PA-API sales rank (PRO). DISPLAY-2
			array(
				'name'       => 'mbs/bestseller',
				'class'      => 'MBS_Block_Bestseller',
				'attributes' => array(
					'limit'  => array( 'type' => 'number', 'default' => 10   ),
					'layout' => array( 'type' => 'string', 'default' => 'grid' ),
				),
			),

			// Publication Timeline -- vertical timeline per format edition + ARC dates (FREE). DISPLAY-1
			array(
				'name'       => 'mbs/timeline',
				'class'      => 'MBS_Block_Timeline',
				'attributes' => array(
					'bookId' => array( 'type' => 'number', 'default' => 0 ),
				),
			),

			// ARC Signup -- self-nomination form for ARC reviewers (PRO).
			array(
				'name'       => 'mbs/arc-signup',
				'class'      => 'MBS_Block_Arc_Signup',
				'attributes' => array(
					'bookId'           => array( 'type' => 'number',  'default' => 0    ),
					'title'            => array( 'type' => 'string',  'default' => 'Apply to Review This Book' ),
					'buttonLabel'      => array( 'type' => 'string',  'default' => 'Submit Application' ),
					'successMessage'   => array( 'type' => 'string',  'default' => "Thank you! We'll be in touch." ),
					'showMessageField' => array( 'type' => 'boolean', 'default' => true  ),
					'consentText'      => array( 'type' => 'string',  'default' => ''    ),
					'requireConsent'   => array( 'type' => 'boolean', 'default' => true  ),
				),
			),

			// ESP Signup -- newsletter/ESP signup form, mirrors [mbs_esp_signup] shortcode (PRO).
			array(
				'name'       => 'mbs/esp-signup',
				'class'      => 'MBS_Block_Esp_Signup',
				'attributes' => array(
					'bookId'           => array( 'type' => 'number',  'default' => 0           ),
					'showConsentField' => array( 'type' => 'boolean', 'default' => true        ),
					'buttonLabel'      => array( 'type' => 'string',  'default' => 'Subscribe' ),
				),
			),

		);
	}
}
