<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Http\RequestHandlers\DeleteFact;
use Fisharebest\Webtrees\I18N;

/**
 * @var Fact $fact
 */

?>

<?php if ($fact->target() === null) : ?>
    <a class="btn btn-link btn-sm" href="#" data-wt-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', strip_tags($fact->name())) ?>" data-wt-post-url="<?= e(route(DeleteFact::class, ['tree' => $fact->record()->tree()->name(), 'xref' => $fact->record()->xref(), 'fact_id' => $fact->id()])) ?>" title="<?= I18N::translate('Delete') ?>">
        <?= view('icons/delete') ?>
        <span class="visually-hidden"><?= I18N::translate('Delete') ?></span>
    </a>
<?php else : ?>
    <a class="btn btn-link btn-sm" href="#" data-wt-confirm="<?= I18N::translate('Are you sure you want to delete the link to “%s”?', strip_tags($fact->target()->fullName())) ?>" data-wt-post-url="<?= e(route(DeleteFact::class, ['tree' => $fact->record()->tree()->name(), 'xref' => $fact->record()->xref(), 'fact_id' => $fact->id()])) ?>" title="<?= I18N::translate('Unlink') ?>">
        <?= view('icons/delete') ?>
        <span class="visually-hidden"><?= I18N::translate('Unlink') ?></span>
    </a>
<?php endif ?>
