<?php
/**
 * Hyvä Themes - https://hyva.io
 * Copyright © Hyvä Themes. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

use Magento\Framework\Escaper;
use Magento\Catalog\Helper\Output as CatalogOutputHelper;
use Magento\Catalog\Block\Product\View\Attributes;
use Magento\Catalog\Model\Product;

// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper

/** @var Escaper $escaper */
/** @var CatalogOutputHelper $output */
/** @var Attributes $block */


/** @var CatalogOutputHelper $catalogOutputHelper */
$catalogOutputHelper = $this->helper(CatalogOutputHelper::class);

/** @var Product $product */
$product = $block->getProduct();
?>

<?php if ($attributes = $block->getAdditionalData()): ?>
    <div class="table-wrapper max-w-prose overflow-x-auto" id="product-attributes">
        <table class="additional-attributes w-full">
            <?php foreach ($attributes as $attribute): ?>
                <tr class="border-b border-gray-300 last:border-b-0">
                    <th class="col label w-1/2 py-2 text-left text-fg-secondary font-normal product-attribute-label"
                        scope="row"><?= $escaper->escapeHtml($attribute['label']) ?></th>
                    <td class="col data w-1/2 py-2 pl-2 text-left product-attribute-value"
                        data-th="<?= $escaper->escapeHtmlAttr($attribute['label']) ?>"
                    ><?= /* @noEscape */
                     $catalogOutputHelper->productAttribute($product, $attribute['value'], $attribute['code']) ?></td>
                </tr>
            <?php endforeach; ?>
        </table>
    </div>
<?php endif;?>
