<?php
/**
 * BookiFlex
 *
 * @package   BookiFlex
 * @author    BookiFlex
 * @copyright Copyright (c) 2025 BookiFlex
 * @license   GPL-2.0-or-later
 *
 * @link https://bookiflex.com
 */

declare(strict_types=1);

namespace BookiFlex\Plugin\UI\Blocks;

use BookiFlex\Core\Admin\Block\AbstractBlock;
use BookiFlex\Plugin\UI\SearchFormRenderer;

defined('ABSPATH') || exit;

class SearchFormBlock extends AbstractBlock
{
    protected function blockDir(): string
    {
        return $this->plugin->getPluginDir() . 'assets/blocks/search-form';
    }

    public function render(array $attributes, string $content, ?\WP_Block $block = null): string
    {
        wp_enqueue_script('bookiflex-search-form');

        $wrapperAttrs = get_block_wrapper_attributes([
            'class' => 'bookiflex-search-form-block',
        ]);

        return sprintf(
            '<div %s>%s</div>',
            $wrapperAttrs,
            (new SearchFormRenderer())->renderTag($attributes)
        );
    }
}
