{%- import '_macros_site.html' as macros_site with context -%}
{%- import 'nerd/_macros.html' as macros_nerd 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-nerd') }} | {{ '{:.3f}'.format(search_result['rep']) }}
	</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_nerd.get_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">
                <table class="table table-sm">
                    <tbody>
    {%- if 'rep' in search_result and search_result['rep'] %}
                        <tr>
                            <th>{{ _('Reputation') }}:</th>
                            <td>{{ '{:.3f}'.format(search_result['rep']) }}</td>
                        </tr>
    {%- endif %}
    {%- if 'fmp' in search_result and search_result['fmp'] and 'general' in search_result['fmp'] and search_result['fmp']['general'] %}
                        <tr>
                            <th>{{ _('FMP score') }}:</th>
                            <td>{{ '{:.3f}'.format(search_result['fmp']['general']) }}</td>
                        </tr>
    {%- endif %}
    {%- if 'hostname' in search_result and search_result['hostname'] %}
                        <tr>
                            <th>{{ _('Hostname') }}:</th>
                            <td>{{ search_result['hostname'] }}</td>
                        </tr>
    {%- endif %}
    {%- if 'asn' in search_result and search_result['asn'] %}
                        <tr>
                            <th>{{ _('AS number') }}:</th>
                            <td>{{ search_result['asn'] | join(', ') }}</td>
                        </tr>
    {%- endif %}
    {%- if 'geo' in search_result and search_result['geo'] and 'ctry' in search_result['geo'] and search_result['geo']['ctry'] %}
                        <tr>
                            <th>{{ _('Country') }}:</th>
                            <td>{{ search_result['geo']['ctry'] | upper }} {{ get_country_flag(search_result['geo']['ctry']) }}</td>
                        </tr>
    {%- endif %}
    {%- if 'bgppref' in search_result and search_result['bgppref'] %}
                        <tr>
                            <th>{{ _('BGP prefix') }}:</th>
                            <td>{{ search_result['bgppref'] }}</td>
                        </tr>
    {%- endif %}
    {%- if 'ipblock' in search_result and search_result['ipblock'] %}
                        <tr>
                            <th>{{ _('IP block') }}:</th>
                            <td>{{ search_result['ipblock'] }}</td>
                        </tr>
    {%- endif %}
    {%- if 'bl' in search_result and search_result['bl'] %}
                        <tr>
                            <th>{{ _('Blacklists') }}:</th>
                            <td>{% for bl in search_result['bl'] %}
                                <span class="badge text-bg-secondary">{{ bl }}</span>
                                {% endfor %}
                            </td>
                        </tr>
    {%- endif %}
    {%- if 'tags' in search_result and search_result['tags'] %}
                        <tr>
                            <th>{{ _('Tags') }}:</th>
                            <td>{% for tag in search_result['tags'] %}
                                <span class="badge text-bg-secondary">
                            		{{ tag['n'] }} ({{ tag['c'] }}x)
                            	</span>
                            	{% endfor %}
                        	</td>
                        </tr>
    {%- endif %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
