<?php
/**
 * Hyvä Themes - https://hyva.io
 * Copyright © Hyvä Themes 2020-present. All rights reserved.
 * This product is licensed per Magento install
 * See https://hyva.io/license
 */

declare(strict_types=1);

use Hyva\Theme\Model\ViewModelRegistry;
use Hyva\Theme\ViewModel\StoreConfig;
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\Template;

/** @var Template $block */
/** @var Escaper $escaper */
/** @var ViewModelRegistry $viewModels */

/** @var StoreConfig $storeConfig */
$storeConfig = $viewModels->require(StoreConfig::class);

// Get store information
$storeName = $storeConfig->getStoreConfig('general/store_information/name') ?: 'Banyo';

// Get base URL
$baseUrl = $block->getUrl('');
$storeUrl = rtrim($baseUrl, '/');
?>
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "WebSite",
  "name": "<?= $escaper->escapeHtml($storeName) ?>",
  "url": "<?= $escaper->escapeUrl($storeUrl) ?>/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "<?= $escaper->escapeUrl($storeUrl) ?>/catalogsearch/result?q={search_term_string}",
    "query-input": "required name=search_term_string"
  }
}
</script>
