<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Media;
use Fisharebest\Webtrees\Module\ModuleSidebarInterface;
use Fisharebest\Webtrees\Module\ModuleTabInterface;
use Fisharebest\Webtrees\Tree;
use Illuminate\Support\Collection;

/**
 * @var string                                 $age
 * @var bool                                   $can_upload_media
 * @var Collection<int,Media>                  $individual_media
 * @var Collection<int,Fact>                   $name_records
 * @var Individual                             $record
 * @var Collection<int,Fact>                   $sex_records
 * @var Collection<int,string>                 $shares
 * @var Collection<int,ModuleSidebarInterface> $sidebars
 * @var Collection<int,ModuleTabInterface>     $tabs
 * @var Tree                                   $tree
 * @var string                                 $user_link
 */
?>

<?php if ($individual_media->isNotEmpty() || $tree->getPreference('USE_SILHOUETTE') === '1') : ?>
    <div class="col-sm-3">
        <?php if ($individual_media->isEmpty()) : ?>
            <div class="img-thumbnail">
                <i class="wt-individual-silhouette wt-individual-silhouette-<?= strtolower($record->sex()) ?> wt-icon-flip-rtl w-100"></i>
            </div>
        <?php elseif ($individual_media->count() === 1) : ?>
            <?= $individual_media->first()->displayImage(400, 400, 'contain', ['class' => 'img-thumbnail img-fluid w-100']) ?>
        <?php else : ?>
            <div id="individual-images" class="carousel slide" data-bs-interval="false">
                <div class="carousel-inner">
                    <?php foreach ($individual_media as $n => $media_file) : ?>
                        <div class="carousel-item <?= $n === 0 ? 'active' : '' ?>">
                            <?= $media_file->displayImage(400, 400, 'contain', ['class' => 'img-thumbnail img-fluid w-100']) ?>
                        </div>
                    <?php endforeach ?>
                </div>
            </div>
        <?php endif ?>
    </div>
<?php endif ?>
