<div class="collection [[ browse:is-writable($context) ]]" data-root="[[ $context?request?parameters?path ]]">
    [# Receives a list of documents to display in $documents #]
    <ul class="documents">
        [% if empty($documents) %]
        <li class="document card"><h5>No documents</h5></li>
        [% else %]
            [% for $doc in $documents %]
            [% let $options = browse:document-options($doc) %]
            <li class="document card">
                <header>[[ browse:header($context, $doc, $options) ]]</header>
                <div class="matches">
                    [[ browse:show-hits($context, $doc) ]]
                </div>
                <div class="actions">
                    [% if $menu?download %]
                    <details class="dropdown-button">
                        <summary title="menu.download.title" data-i18n="[title]menu.download.title">
                            <svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512"><path d="M320 336h76c55 0 100-21.21 100-75.6s-53-73.47-96-75.6C391.11 99.74 329 48 256 48c-69 0-113.44 45.79-128 91.2-60 5.7-112 35.88-112 98.4S70 336 136 336h56M192 400.1l64 63.9 64-63.9M256 224v224.03" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/></svg>
                            <span>Download</span>
                        </summary>
                        <ul>
                            <li>
                                <pb-edit-xml data-i18n="[title]menu.download.view-tei" title="view-tei" path="[[ document-uri(root($doc)) ]]">
                                    XML
                                </pb-edit-xml>
                            </li>
                            [% if empty($options?media) or "print" = $options?media %]
                            <li>
                                <a href="[[ $context-path ]]/print/[[ $options?relpath ]]?odd=[[$options?odd]]" target="_blank">Print CSS</a>
                            </li>
                            [% endif %]
                            [% if empty($options?media) or "latex" = $options?media %]
                            <li>
                                <pb-download type="tex" dialog="downloadDialog" data-i18n="[title]menu.download.pdf-latex" title="i18n(pdf-latex)" odd="[[ $options?odd ]]" url="api/document/[[ escape-uri($options?relpath, true()) ]]">
                                    <pb-i18n key="menu.download.pdf-latex">Download</pb-i18n>
                                </pb-download>
                            </li>
                            [% endif %]
                            [% if empty($options?media) or "latex" = $options?media %]
                            <li>
                                <pb-download type="tex" dialog="downloadDialog" data-i18n="[title]menu.download.pdf-latex" title="i18n(pdf-latex)" source="source" odd="[[ $options?odd ]]" url="api/document/[[ escape-uri($options?relpath, true()) ]]">
                                    <pb-i18n key="menu.download.latex-source"/>
                                </pb-download>
                            </li>
                            [% endif %]
                            [% if empty($options?media) or "fo" = $options?media %]
                            <li>
                                <pb-download type="pdf" dialog="downloadDialog" data-i18n="[title]menu.download.pdf-fo" title="i18n(pdf-fo)" odd="[[ $options?odd ]]" url="api/document/[[ escape-uri($options?relpath, true()) ]]">
                                    <pb-i18n key="menu.download.pdf-fo"/>
                                </pb-download>
                            </li>
                            [% endif %]
                            [% if empty($options?media) or "fo" = $options?media %]
                            <li>
                                <pb-download type="pdf" dialog="downloadDialog" data-i18n="[title]menu.download.fo-source" title="pdf-fo" source="source" odd="[[ $options?odd ]]" url="api/document/[[ escape-uri($options?relpath, true()) ]]">
                                    <pb-i18n key="menu.download.fo-source"/>
                                </pb-download>
                            </li>
                            [% endif %]
                            [% if empty($options?media) or "epub" = $options?media %]
                            <li>
                                <pb-download type="epub" dialog="downloadDialog" odd="[[ $options?odd ]]" url="api/document/[[ escape-uri($options?relpath, true()) ]]">
                                    ePUB
                                </pb-download>
                            </li>
                            [% endif %]
                            [% block document-download %][% endblock %]
                        </ul>
                    </details>
                    [% endif %]
                    [% block document-actions %][% endblock %]
                    [% if $menu?delete %]
                    <pb-restricted login="login" group="tei">
                        <pb-ajax data-i18n="[title]menu.delete" title="Delete" url="api/document/[[ escape-uri($options?relpath, true()) ]]" method="delete" emit="search" event="pb-search-resubmit" confirm="browse.confirmDeletion" quiet="">
                            <button>
                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash3" viewBox="0 0 16 16">
                                    <path d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5M11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47M8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5"/>
                                </svg>
                            </button>
                            <h3 slot="title"><pb-i18n key="menu.delete">Delete</pb-i18n></h3>
                        </pb-ajax>
                    </pb-restricted>
                [% endif %]
                </div>
            </li>
            [% endlet %]
            [% endfor %]
        [% endif %]
    </ul>
</div>