{%- import '_macros_site.html' as macros_site with context -%}
{%- import 'geoip/_macros.html' as macros_geoip with context -%}
{%- set content_id = get_uuid4() -%}
<div class="popover-hover" role="button" data-popover-content="#po-{{ content_id }}">
    <span class="badge text-bg-secondary">
        {{ get_icon('module-geoip') }} | {{ search_result['city']['ctr_code'] | upper }} {{ get_country_flag(search_result['city']['ctr_code']) }}
    </span>
    <div id="po-{{ content_id }}" class="d-none">
        <div class="popover top">
            <div class="popover-arrow" data-popper-arrow></div>
            <h3 class="popover-title">
                <a href="{{ url_for('host_info.search', submit = _('Search'), search = search_item) }}" data-bs-toggle="tooltip" title="{{ _('Go to full search page') }}">
                    {{ macros_geoip.get_city_title() }}
                </a>
                <span class="float-end">
                    <span data-bs-toggle="tooltip" title="{{ _('Query time') }}: {{ get_timedelta(g.requeststart) }}">
                        {{ get_icon('stopwatch') }}
                    </span>
                </span>
            </h3>
            <div class="popover-content-outer">
                <div class="popover-content">
                    <table class="table table-sm">
                        <tbody>
    {%- if 'cnt_name' in search_result['city'] and search_result['city']['cnt_name'] %}
                            <tr>
                                <th>{{ _('Continent') }}:</th>
                                <td>{{ search_result['city']['cnt_name'] }} ({{ search_result['city']['cnt_code'] | upper }})</td>
                            </tr>
    {%- endif %}
    {%- if 'ctr_name' in search_result['city'] and search_result['city']['ctr_name'] %}
                            <tr>
                                <th>{{ _('Country') }}:</th>
                                <td>{{ search_result['city']['ctr_name'] }} ({{ search_result['city']['ctr_code'] | upper }}, {{ get_country_flag(search_result['city']['ctr_code']) }})</td>
                            </tr>
    {%- endif %}
    {%- if 'cty_name' in search_result['city'] and search_result['city']['cty_name'] %}
                            <tr>
                                <th>{{ _('City') }}:</th>
                                <td>{{ search_result['city']['cty_name'] }}</td>
                            </tr>
    {%- endif %}
    {%- if 'timezone' in search_result['city'] %}
                            <tr>
                                <th>{{ _('Timezone') }}:</th>
                                <td>{{ search_result['city']['timezone'] }}</td>
                            </tr>
    {%- endif %}
    {%- if 'latitude' in search_result['city'] and 'longitude' in search_result['city'] %}
                            <tr>
                                <th>{{ _('Coordinates') }}:</th>
                                <td>@{{ search_result['city']['latitude'] }},{{ search_result['city']['longitude'] }}</td>
                            </tr>
    {%- endif %}
                        </tbody>
                    </table>
                    {{ macros_geoip.maxmind_attribution() }}
                </div>
            </div>
        </div>
    </div>
</div>
