{% if not nsm_rulebook_groups and not nsm_link_type_groups %}
{% trans "None" %}
{% endif %}
{# ── Rulebooks → Rulebook → Field → Rule ────────────────────────────── #}
{% if nsm_rulebook_groups %}
{% trans "Rulebooks" %}
{{ nsm_unique_rules_total }}
{% for group in nsm_rulebook_groups %}
{% with rb=group.rulebook %}
{% if group.rules_tab_url %}
{{ rb.name }}
{% else %}
{{ rb.name }}
{% endif %}
{{ group.unique_count }}
{% for fg in group.field_groups %}
{{ fg.field.name }}
{{ fg.rule_count }}
{% endfor %}
{% endwith %}
{% endfor %}
{% endif %}
{% if nsm_rulebook_groups and nsm_link_type_groups %}
{% endif %}
{# ── ObjectLink type groups (manual assignments) ─────────────────── #}
{% for group in nsm_link_type_groups %}
{{ group.type_label }}
{{ group.count }}
15 %}style="max-height:420px;overflow-y:auto;"{% endif %}>
{% for linked in group.objects %}
{% if linked.parent_url %}{{ linked.parent_name }} / {% endif %}{{ linked.name }} {% if linked.status_icon_html %}{{ linked.status_icon_html|safe }}{% endif %}
{% if linked.inherited_from_name %}
({% trans "from" %} {{ linked.inherited_from_name }} )
{% endif %}
{% if group.show_comment %}{% endif %}
{% if group.show_actions %}
{% if linked.supports_addr_analysis or linked.edit_url or linked.delete_url %}
{% if linked.supports_addr_analysis %}
{% endif %}
{% if linked.edit_url %}
{% endif %}
{% if linked.delete_url %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{# ── Rulebooks assigned to this object (Device / VM / VDC only) ────── #}
{% if nsm_enforcer_assignments %}
{% trans "Rulebooks" %}
{{ nsm_enforcer_assignments|length }}
{% if nsm_enforcer_add_url %}
{% endif %}
{% endif %}
{# ── Per-interface analysis (Device / VM only) ─────────────────────── #}
{% if nsm_interface_analysis %}
{% trans "Analysis" %}
{{ nsm_interface_analysis|length }}
{% for iface in nsm_interface_analysis %}
{% if iface.link_rows %}
{% for link in iface.link_rows %}
{{ link.type_label }}:
{% if link.url %}
{{ link.name|safe }}
{% else %}
{{ link.name|safe }}
{% endif %}
{% endfor %}
{% endif %}
{% if iface.rulebook_groups %}
{% for group in iface.rulebook_groups %}
{% with rb=group.rulebook %}
{% if group.rules_tab_url %}
{{ rb.name }}
{% else %}
{{ rb.name }}
{% endif %}
{{ group.unique_count }}
{% for fg in group.field_groups %}
{{ fg.field.name }}
{{ fg.rule_count }}
{% endfor %}
{% endwith %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}