{% extends "admin/base_site.html" %}
{% load i18n l10n admin_urls static %}

{% block extrahead %}
    {{ block.super }}
    {{ media }}
    <script src="{% static 'admin/js/cancel.js' %}" async></script>
{% endblock %}

{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation
    delete-selected-confirmation{% endblock %}

{% block breadcrumbs %}
    <div class="breadcrumbs text-sm">
        <ul>
            <li><a href="{% url 'admin:index' %}">{% translate 'Home' %}</a></li>
            <li><a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
            </li>
            <li><a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a></li>
            <li>{% translate 'Delete multiple objects' %}</li>
        </ul>
    </div>
{% endblock %}

{% block content %}
    <div class="card bg-base-100 shadow-md lg:p-6 p-3">
        {% if perms_lacking %}
            <div class="alert alert-warning">
                <p class="font-semibold">{% blocktranslate %}Deleting the selected {{ objects_name }} would result in
                    deleting related objects, but
                    your account doesn't have permission to delete the following types of
                    objects:{% endblocktranslate %}</p>
                <ul class="list-disc list-inside">{{ perms_lacking|unordered_list }}</ul>
            </div>
        {% elif protected %}
            <div class="alert alert-error">
                <p class="font-semibold">{% blocktranslate %}Deleting the selected {{ objects_name }} would require
                    deleting the following protected
                    related objects:{% endblocktranslate %}</p>
                <ul class="list-disc list-inside">{{ protected|unordered_list }}</ul>
            </div>
        {% else %}
            <p class="font-semibold">{% blocktranslate %}Are you sure you want to delete the selected {{ objects_name }}? All of the following objects and their related items will be deleted:{% endblocktranslate %}</p>

            {% include "admin/includes/object_delete_summary.html" %}

            <h2 class="text-lg font-bold mt-4">{% translate "Objects" %}</h2>
            <div class="overflow-y-auto max-h-64">
                {% for deletable_object in deletable_objects %}
                    <ul class="list-disc list-inside">{{ deletable_object|unordered_list }}</ul>
                {% endfor %}
            </div>
            <form method="post" class="mt-4">
                {% csrf_token %}
                <div class="flex flex-col space-y-2">
                    {% for obj in queryset %}
                        <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}">
                    {% endfor %}
                    <input type="hidden" name="action" value="delete_selected">
                    <input type="hidden" name="post" value="yes">
                    <div class="flex gap-4">
                        <input type="submit" class="btn btn-error" value="{% translate 'Yes, I’m sure' %}">
                        <a href="#" class="btn btn-outline cancel-link">{% translate "No, take me back" %}</a>
                    </div>
                </div>
            </form>
        {% endif %}
    </div>
{% endblock %}
