<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Tree;
use Illuminate\Support\Collection;

/**
 * @var Collection<int,string> $main_blocks
 * @var Collection<int,string> $side_blocks
 * @var Tree                   $tree
 */

?>
<div class="row">
    <?php if ($main_blocks->isEmpty() || $side_blocks->isEmpty()) : ?>
        <div class="col-md-12 wt-main-blocks">
            <?php foreach ($main_blocks->concat($side_blocks) as $block_id => $block) : ?>
                <?= view('tree-page-block', ['block_id' => $block_id, 'block' => $block, 'tree' => $tree]) ?>
            <?php endforeach ?>
        </div>
    <?php else : ?>
        <div class="col-md-8 wt-main-blocks">
            <?php foreach ($main_blocks as $block_id => $block) : ?>
                <?= view('tree-page-block', ['block_id' => $block_id, 'block' => $block, 'tree' => $tree]) ?>
            <?php endforeach ?>
        </div>
        <div class="col-md-4 wt-side-blocks">
            <?php foreach ($side_blocks as $block_id => $block) : ?>
                <?= view('tree-page-block', ['block_id' => $block_id, 'block' => $block, 'tree' => $tree]) ?>
            <?php endforeach ?>
        </div>
    <?php endif ?>
</div>
