<?php

/**
 * Copyright © MageWorx. All rights reserved.
 * See LICENSE.txt for license details.
 */
?>

<?php /** @var \MageWorx\Downloads\Block\Catalog\Product\Attachments $block */ ?>
<?php $attachments = $block->getAttachments(); ?>
<?php if ($attachments) : ?>
    <div class="overflow-x-auto table-wrapper">
        <?php if (!$block->isGroupBySection()) : ?>
            <?php foreach ($attachments as $attachment) : ?>
                <?= $block->getAttachmentHtml($attachment); ?>
            <?php endforeach; ?>
        <?php else : ?>
            <?php $pseudoSections = $block->getGroupAttachments(); ?>
            <?php foreach ($pseudoSections as $pseudoSection) : ?>
                <div class="section-title"><?= $block->escapeHtml($pseudoSection['title']); ?></div>
                <div class="section-files">
                    <?php foreach ($pseudoSection['attachments'] as $item) : ?>
                        <?= $block->getAttachmentHtml($item); ?>
                    <?php endforeach; ?>
                </div>
            <?php endforeach; ?>
        <?php endif; ?>
        <?php if ($block->isShowHowToDownloadMessage()) : ?>
            <div class="access-notice">
                <span>* <?= $block->escapeHtml($block->getHowToDownloadMessage(), ['a']) ?></span>
            </div>
        <?php endif; ?>
    </div>
<?php endif;
