<?php

use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Http\RequestHandlers\EditNotePage;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Note;
use Fisharebest\Webtrees\Registry;
use Illuminate\Support\Collection;

/**
 * @var Note                 $record
 * @var Collection<int,Fact> $clipboard_facts
 * @var string               $text
 */

?>

<table class="table wt-facts-table">
    <tr>
        <th scope="row">
            <?= I18N::translate('Shared note') ?>
            <?php if (Auth::isEditor($record->tree())) : ?>
                <div class="pt-2 wt-fact-edit-links">
                    <a class="btn btn-link" href="<?= e(route(EditNotePage::class, ['xref' => $record->xref(), 'tree' => $record->tree()->name()])) ?>" title="<?= I18N::translate('Edit') ?>">
                        <?= view('icons/edit') ?>
                        <span class="visually-hidden">
                            <?= I18N::translate('Edit') ?>
                        </span>
                    </a>
                </div>
            <?php endif ?>
        </th>
        <td>
          <?= Registry::elementFactory()->make('NOTE:CONC')->value($record->getNote(), $record->tree()) ?>
        </td>
    </tr>

    <?php foreach ($record->facts() as $fact) : ?>
        <?php if ($fact->tag() !== 'NOTE:CONT') : ?>
            <?= view('fact', ['fact' => $fact, 'record' => $record]) ?>
        <?php endif ?>
    <?php endforeach ?>
</table>
