<?php

namespace App\Providers;

use App\Domain\Website\Blocks\BlockRegistry;
use App\Domain\Website\Blocks\Types;
use Illuminate\Support\ServiceProvider;

/**
 * Registers every block the website builder offers.
 *
 * To add a capability to the builder: create a class in Blocks/Types and add it
 * to the list below. No migration, no enum change, no CHECK constraint.
 */
class WebsiteServiceProvider extends ServiceProvider
{
    /** @var array<class-string> */
    public const BLOCKS = [
        // Layout
        Types\SectionBlock::class,
        Types\ColumnsBlock::class,
        Types\SpacerBlock::class,
        Types\DividerBlock::class,

        // Hero
        Types\HeroBlock::class,

        // Content
        Types\TextImageBlock::class,
        Types\CardGridBlock::class,
        Types\RichTextBlock::class,
        Types\StatsBlock::class,
        Types\AccordionBlock::class,

        // Media
        Types\GalleryBlock::class,
        Types\VideoBlock::class,

        // People
        Types\ProfileCardBlock::class,
        Types\TrainersBlock::class,
        Types\TestimonialsBlock::class,

        // Live ERP data
        Types\BranchesBlock::class,
        Types\ProgramsBlock::class,
        Types\ActivitiesBlock::class,
        Types\ScheduleBlock::class,
        Types\NewsBlock::class,
        Types\EventsBlock::class,

        // Commerce
        Types\PricingBlock::class,

        // Social & contact
        Types\LogoStripBlock::class,
        Types\InfoCardsBlock::class,
        Types\MapBlock::class,
        Types\SocialLinksBlock::class,

        // Action
        Types\CtaBlock::class,
        Types\ContactFormBlock::class,
        Types\AppDownloadBlock::class,

        // Advanced
        Types\CustomHtmlBlock::class,
        Types\EmbedBlock::class,
    ];

    public function register(): void
    {
        $this->app->singleton(BlockRegistry::class, function () {
            return (new BlockRegistry)->registerMany(self::BLOCKS);
        });
    }
}
