{% load evelinks %}
{% load i18n %}

{% if esi_fleet.has_open_esi_fleets %}
    <div class="aa-callout aa-callout-info" role="alert">
        <p>
            {% blocktranslate count esi_fleet.open_esi_fleets_list|length as open_esi_fleets %}
                You currently have an active ESI fleet under the following character:
            {% plural %}
                You currently have {{ open_esi_fleets }} active ESI fleets under the following characters:
            {% endblocktranslate %}

            <sup>*</sup>
        </p>

        <ul class="esi-fleet-list my-3 p-0">
            {% for open_esi_fleet in esi_fleet.open_esi_fleets_list %}
                <li class="esi-fleet-list-item py-2 px-3">
                    <div class="eve-image-with-text">
                        <div class="eve-image">
                            <img class="eve-character-portrait rounded me-2" src="{{ open_esi_fleet.character|character_portrait_url:64 }}" alt="{{ open_esi_fleet.character.character_name }}" width="48px" height="48px">
                        </div>
                        <div class="eve-image-text small">
                            {{ open_esi_fleet.character.character_name }}<br>
                            <small>({% translate "Fleet name" %}: {{ open_esi_fleet.fleet }} // {% translate "ESI fleet ID" %}: {{ open_esi_fleet.esi_fleet_id }})</small>
                        </div>
                    </div>

                    <div>
                        <button
                            class="btn btn-primary btn-sm ms-1"
                            title="{% translate 'Clicking here will stop the automatic tracking through ESI for this fleet and close the associated FAT link.' %}"
                            data-bs-toggle="modal"
                            data-bs-target="#cancelEsiFleetModal"
                            data-url="{% url 'afat:fatlinks_close_esi_fatlink' open_esi_fleet.hash %}?next={% url 'afat:fatlinks_add_fatlink' %}"
                            data-body-text="{% blocktranslate with esi_fleet_id=open_esi_fleet.esi_fleet_id character_name=open_esi_fleet.character.character_name %}<p>Are you sure you want to close ESI fleet with ID {{ esi_fleet_id }} from {{ character_name }}</p>{% endblocktranslate %}"
                            data-confirm-text="{% translate 'Stop tracking' %}"
                        >
                            <i class="fa-solid fa-times"></i>
                            <!-- {% translate "Stop tracking" %} -->
                        </button>
                    </div>
                </li>
            {% endfor %}
        </ul>

        <p>
            {% blocktranslate count esi_fleet.open_esi_fleets_list|length as open_esi_fleets %}
                This fleet is already automatically tracked.
            {% plural %}
                These fleets are already automatically tracked.
            {% endblocktranslate %}

            {% translate "However, you can still open more fleets with other alts, if that&apos;s what you like to do." %}
        </p>

        <p>
            (<small><sup>(*)</sup> {% translate "Note: Information about your registered fleets might be delayed by up to 5 minutes." %})</small>
        </p>
    </div>

    {% translate "Close ESI Fleet Tracking" as translated_title %}
    {% include "afat/modals/general.html" with modal_name="cancelEsiFleet" modal_title=translated_title confirm_button_class="btn-danger" %}
{% endif %}
