{% set nav_path = request.url.path %}
{% set nav_roles = ui_roles if ui_roles is defined else [] %}
{% set nav_perms = ui_perms if ui_perms is defined else [] %}
{% set nav_workspace = 'employee' %}
{% if nav_path.startswith('/system-admin') %}{% set nav_workspace = 'system' %}
{% elif nav_path.startswith('/firm-admin') %}{% set nav_workspace = 'firm' %}
{% elif nav_path.startswith('/partner') %}{% set nav_workspace = 'partner' %}
{% elif nav_path.startswith('/manager') or nav_path.startswith('/employees/work') or nav_path.startswith('/employees/progress') or nav_path.startswith('/employees/attendance') or nav_path.startswith('/employees/leave') %}{% set nav_workspace = 'manager' %}
{% elif nav_path.startswith('/consultant') %}{% set nav_workspace = 'consultant' %}
{% elif nav_path.startswith('/client') %}{% set nav_workspace = 'client' %}
{% elif nav_path.startswith('/employee') %}{% set nav_workspace = 'employee' %}
{% elif 'System Admin' in nav_roles %}{% set nav_workspace = 'system' %}
{% elif 'Firm Admin' in nav_roles %}{% set nav_workspace = 'firm' %}
{% elif 'Partner' in nav_roles %}{% set nav_workspace = 'partner' %}
{% elif 'Manager' in nav_roles or 'Branch Manager' in nav_roles %}{% set nav_workspace = 'manager' %}
{% elif 'Consultant' in nav_roles %}{% set nav_workspace = 'consultant' %}
{% elif 'Client' in nav_roles %}{% set nav_workspace = 'client' %}
{% endif %}
{% macro nav_link(url, label, prefixes=None) -%}
{% set checks = prefixes if prefixes else [url] %}
{% set ns = namespace(active=false) %}
{% for prefix in checks %}{% if nav_path == prefix or nav_path.startswith(prefix ~ '/') %}{% set ns.active = true %}{% endif %}{% endfor %}
{{ label }}
{%- endmacro %}
{% macro dropdown(label, prefixes) -%}
{% set ns = namespace(active=false) %}
{% for prefix in prefixes %}{% if nav_path == prefix or nav_path.startswith(prefix ~ '/') %}{% set ns.active = true %}{% endif %}{% endfor %}
{{ label }}