<?php

use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Location;
use Fisharebest\Webtrees\Place;

/**
 * @var bool                 $showlink
 * @var Place                $place
 * @var int                  $id
 * @var string               $sidebar_class
 * @var array<string,string> $stats
 */
?>

<li class="gchart px-md-2 <?= $sidebar_class ?>" data-wt-feature-id="<?= $id ?>">
    <div class="row label">
        <div class="col" style="word-wrap: break-word">
            <?php if ($showlink) : ?>
                <a href="<?= e($place->url()) ?>">
                    <?= $place->placeName() ?>
                </a>
            <?php else : ?>
                <?= $place->placeName() ?>
            <?php endif ?>
        </div>
    </div>

    <?php if ($sidebar_class === 'unmapped') : ?>
        <div class="row">
            <div class="col-sm-9"><i><?= I18N::translate('The location of this place is not known.') ?></i></div>
            <div class="col-sm-3 align-digits"><?= view('icons/warning') ?></div>
        </div>
    <?php endif ?>

    <div class="row">
        <div class="col-sm-9"><?= I18N::translate('Individuals') ?></div>
        <div class="col-sm-3 align-digits"><?= I18N::number($stats[Individual::RECORD_TYPE]) ?></div>
    </div>

    <?php if ($stats[Family::RECORD_TYPE] > 0): ?>
        <div class="row">
            <div class="col-sm-9"><?= I18N::translate('Families') ?></div>
            <div class="col-sm-3 align-digits"><?= I18N::number($stats[Family::RECORD_TYPE]) ?></div>
        </div>
    <?php endif ?>

    <?php if ($stats[Location::RECORD_TYPE] > 0): ?>
        <div class="row">
            <div class="col-sm-9"><?= I18N::translate('Locations') ?></div>
            <div class="col-sm-3 align-digits"><?= I18N::number($stats[Location::RECORD_TYPE]) ?></div>
        </div>
    <?php endif ?>
</li>
