<?php
/**
 * Server-side render for the Glance Live Search block.
 *
 * @var array  $attributes Block attributes.
 * @var string $content    Inner block content (unused - no innerBlocks).
 * @var WP_Block $block    Block instance.
 */

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

$placeholder = str_replace( [ '[', ']' ], '', ! empty( $attributes['placeholder'] ) ? $attributes['placeholder'] : '' );

// Wrap in a block element so the block editor can apply spacing/alignment.
$wrapper_attributes = get_block_wrapper_attributes();

// Delegate to the existing shortcode renderer so behaviour stays in sync.
echo '<div ' . $wrapper_attributes . '>' . do_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wrapper attrs are safe; shortcode output is escaped in the template.
    $placeholder !== ''
        ? '[glance_search placeholder="' . esc_attr( $placeholder ) . '"]'
        : '[glance_search]'
) . '</div>';
