{%- extends "_layout.html" %}

{%- block content %}
{%- set ads_limits = get_limit_counter() %}
                <div>

                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="{{ url_for('home.index') }}">{{ _('Home') }}</a>
                        </li>
                        <li class="breadcrumb-item">
                            <a href="{{ url_for('events.search') }}">{{ _('Event database') }}</a>
                        </li>
                        <li class="breadcrumb-item active">
                            {{ _('Event detail') }}
                        </li>
                    </ol>
                    <h3>
                        {% if item['Description'] %}
                            {{ item['Description'] }}
                        {% else %}
                            {{ item.get_id() }}
                        {% endif %}
                    </h3>
                    <div class="clearfix">
                        <div class="float-end mt-1 ms-3">
                            {{ macros_page.render_menu_actions(item) }}
                        </div>
                        {% if item['Note'] %}
                            <p class="m-0 mb-3">
                                <small>
                                    {{ item['Note'] }}
                                </small>
                            </p>
                        {% endif %}
                    </div>
                </div>
                <div role="tabpanel" class="tab-pane fade in show active">
                    <button class="mt-1 mb-0 btn btn-outline-dark btn-lg fw-bold border-secondary" data-bs-toggle="collapse" data-bs-target="#general-properties-table">{{ get_icon('collapse') }} {{ _('General properties') }}</button>
                    <table class="mb-4 table table-sm table-striped align-middle collapse show" id="general-properties-table">
                        <tr>
                            <th>
                                {{ _('ID') }}:
                            </th>
                            <td>
                                {{ item.get_id() }}
                            </td>
                        </tr>
                        {%- if item.get_jpath_values('AltNames') %}
                        <tr>
                            <th>
                                {{ _('Alternative identifiers') }}:
                            </th>
                            <td>
                                {{ ", ".join(item.get_jpath_values('AltNames')) }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('Description') %}
                        <tr>
                            <th>
                                {{ _('Description') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('Description') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('Note') %}
                        <tr>
                            <th>
                                {{ _('Note') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('Note') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('Confidence') is not none %}
                        <tr>
                            <th>
                                {{ _('Confidence') }}:
                            </th>
                            <td>
                                {{ (item.get_jpath_value('Confidence')*100) | round | int }} %
                            </td>
                        </tr>
                        {%- endif %}
                        <tr>
                            <th>
                                {{ _('Categories') }}:
                            </th>
                            <td>
                                {{ macros_site.render_widget_csag_category(item.get_categories(), align_right = True, separate_dropdown = True) }}
                            </td>
                        </tr>
                        <tr>
                            <th>
                                {{ _('Source severity') }}:
                            </th>
                            <td>
                                {%- if item.get_severity() %}
                                {{ macros_site.render_widget_csag_severity([item.get_severity()], align_right = True) }}
                                {%- else %}
                                {{ _('-- unassigned --') }}
                                {%- endif %}
                            </td>
                        </tr>
                        {%- if item.get_target_severity() -%}
                        <tr>
                            <th>
                                {{ _('Target severity') }}:
                            </th>
                            <td>
                                {%- if item.get_target_severity() %}
                                {{ macros_site.render_widget_csag_severity([item.get_target_severity()], align_right = True) }}
                                {%- else %}
                                {{ _('-- unassigned --') }}
                                {%- endif %}
                            </td>
                        </tr>
                        {%- endif -%}
                        <tr>
                            <th>
                                {{ _('Source class') }}:
                            </th>
                            <td>
                                {%- if item.get_class() %}
                                    {{ item.get_class() }}
                                    {{ macros_site.render_widget_csag_class([item.get_class()], align_right = True, separate_dropdown = True, without_label = True) }}
                                    {%- set event_class_obj = get_event_class(item.get_class()) -%}
                                    {%- if event_class_obj and event_class_obj.reference %}
                                        <a href="{{ event_class_obj.reference }}" target="_blank">[documentation]</a>
                                    {%- endif %}
                                {%- else %}
                                        {{ _('-- unclassified --') }}
                                {%- endif %}
                            </td>
                        </tr>
                        {%- if item.get_target_class() -%}
                        <tr>
                            <th>
                                {{ _('Target class') }}:
                            </th>
                            <td>
                                {%- if item.get_target_class() %}
                                    {{ item.get_target_class() }}
                                    {{ macros_site.render_widget_csag_class([item.get_target_class()], align_right = True, separate_dropdown = True, without_label = True) }}
                                    {%- set event_class_obj = get_event_class(item.get_target_class()) -%}
                                    {%- if event_class_obj and event_class_obj.reference %}
                                        <a href="{{ event_class_obj.reference }}" target="_blank">[documentation]</a>
                                    {%- endif %}
                                {%- else %}
                                        {{ _('-- unclassified --') }}
                                {%- endif %}
                            </td>
                        </tr>
                        {%- endif -%}
                        <tr>
                            <th>
                                {{ _('Source groups') }}:
                            </th>
                            <td>
                                {{ macros_site.render_widget_csag_abuse(item.get_source_groups(), align_right = True, separate_dropdown = True) }}
                            </td>
                        </tr>
                        <tr>
                            <th>
                                {{ _('Target groups') }}:
                            </th>
                            <td>
                                {{ macros_site.render_widget_csag_abuse(item.get_target_groups(), align_right = True, separate_dropdown = True) }}
                            </td>
                        </tr>
                        {%- if item.get_countries_src() %}
                        <tr>
                            <th>
                                {{ _('Source countries') }}:
                            </th>
                            <td>
                                {%- for subitem in item.get_countries_src() %}
                                {{ subitem | upper }} {{ get_country_flag(subitem) }}{% if not loop.last %}&nbsp;|&nbsp;{% endif %}
                                {%- endfor %}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_asns_src() %}
                        <tr>
                            <th>
                                {{ _('Source autonomous systems (ASNs)') }}:
                            </th>
                            <td>
                                {%- for subitem in item.get_asns_src() %}
                                {{ subitem | upper }} {% if not loop.last %}&nbsp;|&nbsp;{% endif %}
                                {%- endfor %}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- set tmpval = item.get_jpath_values('Ref') %}
                        {%- if tmpval %}
                        <tr>
                            <th>
                                {{ _('References') }}:
                            </th>
                            <td>
                                {%- for ref in tmpval %}
                                <p class="my-0">{{ macros_site.ref_to_html_link(ref) }}</p>
                                {%- endfor %}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if permission_can('power') %}
                        {%- if item.get_subclass() %}
                        <tr>
                            <th>
                                {{ get_icon('role-admin') }} {{ _('Source subclass') }}:
                            </th>
                            <td>
                                {{ item.get_subclass() }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_target_subclass() %}
                            <th>
                                {{ get_icon('role-admin') }} {{ _('Target subclass') }}:
                            </th>
                            <td>
                                {{ item.get_target_subclass() }}
                            </td>
                        {%- endif %}
                        {%- set tmpval = item.get_inspection_errors() %}
                            {%- if tmpval %}
                            <tr>
                                <th>
                                    {{ get_icon('role-admin') }} {{ _('Inspection errors') }}
                                </th>
                                <td>
                                    {%- for subitem in tmpval %}
                                    <span class="badge bg-danger me-1">{{ get_icon('alert-warning') }} <strong>{{ subitem }}</strong></span>
                                    {%- endfor %}
                                </td>
                            </tr>
                            {%- endif %}
                        {%- endif %}
                    </table>

                    <p class="mt-2 mb-0"><button class="btn btn-outline-dark btn-lg fw-bold border-secondary" data-bs-toggle="collapse" data-bs-target="#statistics-table">{{ get_icon('collapse') }} {{ _('Time and statistics') }}</button></p>
                    <table class="mb-4 table table-sm table-striped align-middle collapse show" id="statistics-table">
                        <tr>
                            <th>
                                {{ _('Detection time') }}:
                            </th>
                            <td>
                                {{ babel_format_datetime(item.get_detect_time()) }} ({{ macros_site.render_info_timeinterval(item.get_detect_time(), current_datetime_utc) }})
                            </td>
                        </tr>
                        {%- set tmpval = item.get_jpath_value('CreateTime') %}
                        {%- if tmpval %}
                        <tr>
                            <th>
                                {{ _('Creation time') }}:
                            </th>
                            <td>
                                {{ babel_format_datetime(tmpval) }} ({{ macros_site.render_info_timeinterval(tmpval, current_datetime_utc) }})
                            </td>
                        </tr>
                        <tr>
                            <th>
                                {{ _('Creation delay') }}:
                            </th>
                            <td>
                                {{ babel_format_timedelta(tmpval - item.get_detect_time()) }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- set tmpval_a = item.get_jpath_value('EventTime') %}
                        {%- if tmpval_a %}
                        <tr>
                            <th>
                                {{ _('Event time') }}:
                            </th>
                            <td>
                                {{ babel_format_datetime(tmpval_a) }} ({{ macros_site.render_info_timeinterval(tmpval_a, current_datetime_utc) }})
                            </td>
                        </tr>
                        {%- endif %}
                        {%- set tmpval_b = item.get_jpath_value('CeaseTime') %}
                        {%- if tmpval_b %}
                        <tr>
                            <th>
                                {{ _('Cease time') }}:
                            </th>
                            <td>
                                {{ babel_format_datetime(tmpval_b) }} ({{ macros_site.render_info_timeinterval(tmpval_b, current_datetime_utc) }})
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if tmpval_a and tmpval_b %}
                        <tr>
                            <th>
                                {{ _('Event duration') }}:
                            </th>
                            <td>
                                {{ babel_format_timedelta(tmpval_b - tmpval_a) }} ({{ (tmpval_b - tmpval_a) }})
                            </td>
                        </tr>
                        {%- endif %}
                        {%- set tmpval_a = item.get_jpath_value('WinStartTime') %}
                        {%- if tmpval_a %}
                        <tr>
                            <th>
                                {{ _('Aggregation window start time') }}:
                            </th>
                            <td>
                                {{ babel_format_datetime(tmpval_a) }} ({{ macros_site.render_info_timeinterval(tmpval_a, current_datetime_utc) }})
                            </td>
                        </tr>
                        {%- endif %}
                        {%- set tmpval_b = item.get_jpath_value('WinEndTime') %}
                        {%- if tmpval_b %}
                        <tr>
                            <th>
                                {{ _('Aggregation window end time') }}:
                            </th>
                            <td>
                                {{ babel_format_datetime(tmpval_b) }} ({{ macros_site.render_info_timeinterval(tmpval_b, current_datetime_utc) }})
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if tmpval_a and tmpval_b %}
                        <tr>
                            <th>
                                {{ _('Aggregation window size') }}:
                            </th>
                            <td>
                                {{ babel_format_timedelta(tmpval_b - tmpval_a) }} ({{ (tmpval_b - tmpval_a) }})
                            </td>
                        </tr>
                        {%- endif %}
                        <tr>
                            <th>
                                {{ _('Storage time') }}:
                            </th>
                            <td>
                                {{ babel_format_datetime(item.get_storage_time()) }} ({{ macros_site.render_info_timeinterval(item.get_storage_time(), current_datetime_utc) }})
                            </td>
                        </tr>
                        <tr>
                            <th>
                                {{ _('Storage delay') }}:
                            </th>
                            <td>
                                {{ babel_format_timedelta(item.get_storage_time() - item.get_detect_time()) }}
                            </td>
                        </tr>
                        {%- if item.get_jpath_value('ConnCount') is not none %}
                        <tr>
                            <th>
                                {{ _('Connection count') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('ConnCount') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('FlowCount') is not none %}
                        <tr>
                            <th>
                                {{ _('Flow count') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('FlowCount') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('FlowCountDropped') is not none %}
                        <tr>
                            <th>
                                {{ _('Dropped flow count') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('FlowCountDropped') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('PacketCount') is not none %}
                        <tr>
                            <th>
                                {{ _('Packet count') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('PacketCount') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('PacketCountDropped') is not none %}
                        <tr>
                            <th>
                                {{ _('Dropped packet count') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('PacketCountDropped') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('ByteCount') is not none %}
                        <tr>
                            <th>
                                {{ _('Byte count') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('ByteCount') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('ByteCountDropped') is not none %}
                        <tr>
                            <th>
                                {{ _('Dropped byte count') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('ByteCountDropped') }}
                            </td>
                        </tr>
                        {%- endif %}
                        {%- if item.get_jpath_value('AvgPacketSize') is not none %}
                        <tr>
                            <th>
                                {{ _('Average packet size') }}:
                            </th>
                            <td>
                                {{ item.get_jpath_value('AvgPacketSize') }}
                            </td>
                        </tr>
                        {%- endif %}
                    </table>

                    {%- for node_type in [['Source', _('Sources')], ['Target', _('Targets')]] %}
                        {%- set tmpval = item.get_jpath_values(node_type[0]) %}
                        {%- if tmpval %}
                    <p class="mt-2 mb-0"><button class="btn btn-outline-dark btn-lg fw-bold border-secondary" data-bs-toggle="collapse" data-bs-target="#{{ node_type[0] }}">{{ get_icon('collapse') }} {{ node_type[1] }}</button></p>
                    <ul class="mb-4 list-group collapse show" id="{{ node_type[0] }}">
                            {%- for subitem in tmpval %}
                        <li class="list-group-item border-secondary">
                            <table class="table table-sm table-event-detail-node align-middle">
                                {%- if subitem.get('Anonymised', None) or subitem.get('Spoofed', None) or subitem.get('Imprecise', None) %}
                                <tr>
                                    <th>
                                        {{ _('Warnings') }}:
                                    </th>
                                    <td>
                                        {%- if subitem.get('Anonymised', None) %}<span class="badge bg-danger me-1">{{ get_icon('alert-warning') }} {{ _('Anonymised') }}</span>{%- endif %}
                                        {%- if subitem.get('Spoofed', None) %}<span class="badge bg-danger me-1">{{ get_icon('alert-warning') }} {{ _('Spoofed') }}</span>{%- endif %}
                                        {%- if subitem.get('Imprecise', None) %}<span class="badge bg-danger">{{ get_icon('alert-warning') }} {{ _('Imprecise') }}</span>{%- endif %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Hostname' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Hostname') }}:
                                    </th>
                                    <td>
                                        {%- for hostname in subitem['Hostname'] %}
                                        {%- if loop.index0 < search_widget_item_limit -%}
                                        <div>
                                            {{ macros_site.render_widget_csag_hostname(
                                                [hostname],
                                                separate_dropdown = True
                                            ) }}
                                            {%- if ads_limits.count_and_check('{}.{}'.format(node_type[0], 'Hostname')) %}
                                            <div class="popover-hover-container object-additional-data onload" data-object-type="host" data-object-name="{{ hostname }}" data-render-error="true" data-render-flash="false"></div>
                                            {%- else %}
                                            <div class="popover-hover-container object-additional-data ondemand" data-object-type="host" data-object-name="{{ hostname }}" data-render-error="true" data-render-flash="false">
                                                <span role="button" data-bs-toggle="tooltip" title="{{ _('Additional data service load limit for objects of this type was reached, please click to load on demand.') }}">
                                                    {{ get_icon('action-reload') }}
                                                </span>
                                            </div>
                                            {%- endif %}
                                        </div>
                                        {%- elif loop.index0 == search_widget_item_limit %}
                                        <span class="underlined-tooltip" data-bs-toggle="tooltip" title="{{ _('Please download raw message to view full list.') }}">
                                            ({{ _('%(count)s more', count = loop.length - loop.index0) }})
                                        </span>
                                        {%- endif %}
                                    {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'IP4' in subitem %}
                                <tr style="border-top: 0">
                                    <th>
                                        {{ _('IP4') }}:
                                    </th>
                                    <td>
                                    {%- for itemaddr in subitem['IP4'] %}
                                        {%- if loop.index0 < search_widget_item_limit -%}
                                        <div>
                                            {{ macros_site.render_widget_csag_address(
                                                [itemaddr],
                                                separate_dropdown = True
                                            ) }}
                                            {%- if ads_limits.count_and_check('{}.{}'.format(node_type[0], 'IP4')) %}
                                            <div class="popover-hover-container object-additional-data onload" data-object-type="ip4" data-object-name="{{ itemaddr }}" data-render-error="true" data-render-flash="false"></div>
                                            {%- else %}
                                            <div class="popover-hover-container object-additional-data ondemand" data-object-type="ip4" data-object-name="{{ itemaddr }}" data-render-error="true" data-render-flash="false">
                                                <span role="button" data-bs-toggle="tooltip" title="{{ _('Additional data service load limit for objects of this type was reached, please click to load on demand.') }}">
                                                    {{ get_icon('action-reload') }}
                                                </span>
                                            </div>
                                            {%- endif %}
                                        </div>
                                        {%- elif loop.index0 == search_widget_item_limit %}
                                        <span class="underlined-tooltip" data-bs-toggle="tooltip" title="{{ _('Please download raw message to view full list.') }}">
                                            ({{ _('%(count)s more', count = loop.length - loop.index0) }})
                                        </span>
                                        {%- endif %}
                                    {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'IP6' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('IP6') }}:
                                    </th>
                                    <td>
                                    {%- for itemaddr in subitem['IP6'] %}
                                        {%- if loop.index0 < search_widget_item_limit -%}
                                        <div>
                                            {{ macros_site.render_widget_csag_address(
                                                [itemaddr],
                                                separate_dropdown = True
                                            ) }}
                                            {%- if ads_limits.count_and_check('{}.{}'.format(node_type[0], 'IP6')) %}
                                            <div class="popover-hover-container object-additional-data onload" data-object-type="ip6" data-object-name="{{ itemaddr }}" data-render-error="true" data-render-flash="false"></div>
                                            {%- else %}
                                            <div class="popover-hover-container object-additional-data ondemand" data-object-type="ip6" data-object-name="{{ itemaddr }}" data-render-error="true" data-render-flash="false">
                                                <span role="button" data-bs-toggle="tooltip" title="{{ _('Additional data service load limit for objects of this type was reached, please click to load on demand.') }}">
                                                    {{ get_icon('action-reload') }}
                                                </span>
                                            </div>
                                            {%- endif %}
                                        </div>
                                        {%- elif loop.index0 == search_widget_item_limit %}
                                        <span class="underlined-tooltip" data-bs-toggle="tooltip" title="{{ _('Please download raw message to view full list.') }}">
                                            ({{ _('%(count)s more', count = loop.length - loop.index0) }})
                                        </span>
                                        {%- endif %}
                                    {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'BitMask' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('BitMask') }}:
                                    </th>
                                    <td>
                                        {%- for mask in subitem['BitMask'] %}
                                        <span class="badge bg-primary user-select-all">{{ mask }}</span>
                                        {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'MAC' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('MAC') }}:
                                    </th>
                                    <td>
                                        {%- for asn in subitem['MAC'] %}
                                        <p class="my-2"><code>{{ asn | upper }}</code></p>
                                        {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'ServiceName' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Service name') }}:
                                    </th>
                                    <td>
                                        {{ subitem['ServiceName'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'ServiceVersion' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Service version') }}:
                                    </th>
                                    <td>
                                        {{ subitem['ServiceVersion'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Port' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Port') }}:
                                    </th>
                                    <td>
                                        <div>
                                            {{ macros_site.render_widget_csag_port(subitem['Port'], separate_dropdown = True, item_limit = search_widget_item_limit) }}
                                        </div>
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Proto' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Proto') }}:
                                    </th>
                                    <td>
                                        <div>
                                            {{ macros_site.render_widget_csag_protocol(subitem['Proto'], separate_dropdown = True, item_limit = search_widget_item_limit) }}
                                        </div>
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Email' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('E-mail') }}:
                                    </th>
                                    <td>
                                        {%- for mail in subitem['Email'] %}
                                        <span class="badge bg-primary user-select-all">{{ mail }}</span>
                                        {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Interface' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Interface') }}:
                                    </th>
                                    <td>
                                        {%- for interface in subitem['Interface'] %}
                                        <span class="badge bg-primary user-select-all">{{ interface }}</span>
                                        {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Router' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Router') }}:
                                    </th>
                                    <td>
                                        {%- for router in subitem['Router'] %}
                                        <span class="badge bg-primary user-select-all">{{ router }}</span>
                                        {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Netname' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Netname') }}:
                                    </th>
                                    <td>
                                        {%- for net in subitem['Netname'] %}
                                        <span class="badge bg-primary user-select-all">{{ net }}</span>
                                        {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Type' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Type') }}:
                                    </th>
                                    <td>
                                        <div>
                                            {{ macros_site.render_widget_csag_hosttype(subitem['Type'], separate_dropdown = True) }}
                                        </div>
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'ASN' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('ASN') }}:
                                    </th>

                                    <td>
                                        {%- for asn in subitem['ASN'] %}
                                        {{ asn | upper }} {% if not loop.last %}&nbsp;|&nbsp;{% endif %}
                                        {%- endfor %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'ClockSkew' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('ClockSkew') }}:
                                    </th>

                                    <td>
                                        {{ subitem['ClockSkew'] }} s
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'X509ExpiredTime' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('X509 expired time') }}:
                                    </th>
                                    <td>
                                        {%- set expired_time = parse_datetime(subitem['X509ExpiredTime']) -%}
                                        {{ babel_format_datetime(expired_time) }}
                                        ({{ macros_site.render_info_timeinterval(expired_time, get_datetime_utc(aware=True)) }})
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'InFlowCount' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('InFlowCount') }}:
                                    </th>
                                    <td>
                                        {{ subitem['InFlowCount'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'InPacketCount' in subitem or 'InPacketsCount' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('InPacketCount') }}:
                                    </th>
                                    <td>
                                        {{ subitem['InPacketCount'] or subitem['InPacketsCount'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'InByteCount' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('InByteCount') }}:
                                    </th>
                                    <td>
                                        {{ subitem['InByteCount'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'OutFlowCount' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('OutFlowCount') }}:
                                    </th>
                                    <td>
                                        {{ subitem['OutFlowCount'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'OutPacketCount' in subitem or 'OutPacketsCount' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('OutPacketCount') }}:
                                    </th>
                                    <td>
                                        {{ subitem['OutPacketCount'] or subitem['OutPacketsCount'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'OutByteCount' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('OutByteCount') }}:
                                    </th>
                                    <td>
                                        {{ subitem['OutByteCount'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- for type in ['URL', 'Ref'] %}
                                    {%- set tmpval = subitem.get(type, None) %}
                                    {%- if tmpval %}
                                    <tr>
                                        <th>
                                            {%- if type == 'URL' %}
                                            {{ _('URL') }}:
                                            {%- else %}
                                            {{ _('References') }}:
                                            {%- endif %}
                                        </th>
                                        <td>
                                            {%- for ref in tmpval %}
                                            <p class="my-0">{{ macros_site.ref_to_html_link(ref) }}</p>
                                            {%- endfor %}
                                        </td>
                                    </tr>
                                    {%- endif %}
                                {%- endfor %}
                                {%- if 'Note' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Note') }}:
                                    </th>
                                    <td>
                                        {{ subitem['Note'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                            </table>
                        </li>
                            {%- endfor %}
                    </ul>
                        {%- endif %}
                    {%- endfor %}

                    {%- set tmpval = item.get_jpath_values('Node') %}
                    {%- if tmpval %}
                    <p class="mt-2 mb-0"><button class="btn btn-outline-dark btn-lg fw-bold border-secondary" data-bs-toggle="collapse" data-bs-target="#detectors-list">{{ get_icon('collapse') }} {{ _('Detectors') }}</button></p>
                    <ul class="mb-4 list-group collapse show" id="detectors-list">
                        {%- for subitem in tmpval | reverse %}
                        <li class="list-group-item{% if loop.first %} list-group-item-info{% endif %} border-secondary">
                            {%- if not loop.first %}<small>{%- endif %}
                            <table class="table {% if loop.first %} table-info{% endif %} table-condensed table-event-detail-node">
                                {%- if 'Name' in subitem %}
                                <tr style="border-top: 0">
                                    <th>
                                        {{ _('Name') }}:
                                    </th>
                                    <td>
                                        {% if loop.first %}{{ macros_site.render_widget_csag_detector([subitem['Name']], separate_dropdown = True) }}{% else %}{{ subitem['Name'] }}{%- endif %}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'SW' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Software') }}:
                                    </th>
                                    <td>
                                        {{ subitem['SW'] | join(', ') }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Type' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Type') }}:
                                    </th>
                                    <td>
                                        {{ macros_site.render_widget_csag_detectortype(subitem['Type'], separate_dropdown = True) }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'AggrWin' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Aggregation window') }}:
                                    </th>
                                    <td>
                                        {{ subitem['AggrWin'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                                {%- if 'Note' in subitem %}
                                <tr>
                                    <th>
                                        {{ _('Note') }}:
                                    </th>
                                    <td>
                                        {{ subitem['Note'] }}
                                    </td>
                                </tr>
                                {%- endif %}
                            </table>
                            {%- if not loop.first %}</small>{%- endif %}
                        </li>
                        {%- endfor %}
                    </ul>
                    {%- endif %}

                    {%- if item.get_jpath_values('Credentials') %}
                    <p class="mt-2 mb-0"><button class="btn btn-outline-dark btn-lg fw-bold border-secondary" data-bs-toggle="collapse" data-bs-target="#credentials">{{ get_icon('collapse') }} {{ _('Credentials') }}</button></p>
<div class="mb-4 border border-secondary rounded overflow-hidden collapse show" id="credentials">
{% highlight 'json' %}
{{ item.get_credentials_as_json_string() }}
{% endhighlight %}
</div>
                    {%- endif %}

                    {%- set tmpval = item.get_jpath_values('Attach') %}
                    {%- if tmpval %}
                    <p class="mt-2 mb-0"><button class="btn btn-outline-dark btn-lg fw-bold border-secondary" data-bs-toggle="collapse" data-bs-target="#attachments-list">{{ get_icon('collapse') }} {{ _('Attachments') }}</button></p>
                    <ul class="mb-4 list-group collapse show" id="attachments-list">
                        {%- for subitem in tmpval %}
                            {%- set attachment_content = item.get_attachment_content(loop.index) %}
                            <li class="list-group-item border-secondary p-3">
                                <div class="d-flex w-100">
                                    <p class="mb-2 fw-bold h5">{{ _('Attachment') }} {{ loop.index }}{%- if 'FileName' in subitem %} ({{ ",".join(subitem['FileName']) }}){%- endif %}</p>
                                    {%- if attachment_content %}
                                        <a role="button" class="btn btn-secondary btn-sm align-self-center ms-auto" href="{{ url_for('events.attachmentdownload', item_id=item.get_id(), attachment_number=loop.index) }}">
                                            {{ get_icon('action-download') }} {{ _('Download') }}
                                        </a>
                                    {%- endif %}
                                </div>
                            {%- if item.get_jpath_values('Category') and "Malware" in item.get_jpath_values('Category')
                                    or "Malware.Virus" in item.get_jpath_values('Category') -%}
                                <div class="alert alert-warning my-1" role="alert">
                                    {{ _('This attachment could contain malware, so be cautious and do not execute it without sandboxing and other preventive measures!') }}
                                </div>
                            {%- endif -%}
                            {%- if 'Note' in subitem %}
                                <p class="m-0"><b>{{ _('Note') }}:</b> {{ subitem['Note'] }}</p>
                            {%- endif %}
                            {%- if 'Type' in subitem %}
                                <p class="m-0"><b>{{ _('Type') }}:</b> {{ ", ".join(subitem['Type']) }}</p>
                            {%- endif %}
                            {%- for type in ['ExternalURI', 'Ref'] %}
                                {%- set tmpval = subitem.get(type, None) %}
                                {%- if subitem[type] %}
                                    {%- if type == 'ExternalURI' %}
                                        <b>{{ _('External URI') }}:</b>
                                    {%- else %}
                                        <b>{{ _('References') }}:</b>
                                    {%- endif %}
                                    {%- for ref in subitem[type] %}
                                        {{ macros_site.ref_to_html_link(ref) }}
                                    {%- endfor %}
                                {%- endif %}
                            {%- endfor %}
                            {%- if attachment_content %}
                                {%- set content = attachment_content[0] %}
                                {%- set attachment_extension = attachment_content[1] %}
                                {%- if attachment_extension in ['tsv', 'csv'] %}
                                    {%- if parse_csv(content, '\t' if attachment_extension == 'tsv' else ',') %}
                                        <div class="table-responsive mb-1 mt-2">
                                            <table class="table table-light table-bordered align-middle m-0">
                                            {%- for row in parse_csv(content, '\t' if attachment_extension == 'tsv' else ',') %}
                                                <tr>
                                                    {%- for element in row %}
                                                        <td>{{ element }}</td>
                                                    {%- endfor %}
                                                </tr>
                                            {%- endfor %}
                                            </table>
                                        </div>
                                    {%- else %}
                                        <pre class="p-1 mb-1 mt-2 bg-light border rounded">{{ content }}</pre>
                                    {%- endif %}
                                {%- elif attachment_extension == 'json' %}
                                <div class="mb-1 mt-2 border rounded">
{% highlight 'json' %}
{{ content }}
{% endhighlight %}
                                </div>
                                {%- else %}
                                    <pre class="p-1 mb-1 mt-2 bg-light border rounded">{{ content }}</pre>
                                {%- endif %}
                            {%- elif item.get_attachment(loop.index) and 'Content' not in item.get_attachment(loop.index) -%}
                                <div class="alert alert-warning my-1" role="alert">
                                    {{ _('This attachment has no content.') }}
                                </div>
                            {%- else %}
                                <div class="alert alert-danger my-1" role="alert">
                                    {{ _('Something went wrong and the content of this attachment could not be loaded. Please look at it in the JSON view.') }}
                                </div>
                            {%- endif %}
                            {%- if 'ContentType' in subitem %}
                                <p class="m-0"><b>{{ _('Content type') }}:</b> {{ subitem['ContentType'] }}</p>
                            {%- endif %}
                            {%- if 'ContentEncoding' in subitem %}
                                <p class="m-0"><b>{{ _('Content encoding') }}:</b> {{ subitem['ContentEncoding'] }}</p>
                            {%- endif %}
                            {%- if 'ContentCharset' in subitem %}
                                <p class="m-0"><b>{{ _('Content charset') }}:</b> {{ subitem['ContentCharset'] }}</p>
                            {%- endif %}
                            {%- if 'Hash' in subitem %}
                                <p class="m-0"><b>{{ _('Hash') }}:</b>
                                {% for hash in subitem['Hash'] -%}
                                    {%- set hash_without_sha = hash if ':' not in hash else hash.split(':')[1] -%}
                                    {{ hash }} (<a href="https://www.virustotal.com/gui/file/{{ hash_without_sha }}" target="_blank">VirusTotal</a>)
                                    {%- if not loop.last %},{% endif %}
                                {%- endfor -%}
                                </p>
                            {%- endif %}
                            {%- if 'Size' in subitem %}
                                <p class="m-0"><b>{{ _('Size') }}:</b> {{ subitem['Size'] }}</p>
                            {%- endif %}
                            </li>
                        {%- endfor %}
                    </ul>
                    {%- endif %}
                </div>

{%- endblock content %}
