<div id="sidebar-wrapper">
    <ul class="sidebar">
        <li class="sidebar-main"><a href="{{ url_for("home") }}">{% trans "Dashboard" %}</a></li>

        {% if currentUser.featureEnabled("schedule.view") %}
            <li class="sidebar-list"><a href="{{ url_for("schedule.view") }}">{% trans "Schedule" %}</a></li>
        {% endif %}

        {% if currentUser.featureEnabled("daypart.view") %}
            <li class="sidebar-list"><a href="{{ url_for("daypart.view") }}">{% trans "Dayparting" %}</a></li>
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["campaign.view", "layout.view", "template.view", "resolution.view"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-title"><a>{% trans "Design" %}</a></li>
            {% if currentUser.featureEnabled("campaign.view") %}
                <li class="sidebar-list"><a href="{{ url_for("campaign.view") }}">{% trans "Campaigns" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("layout.view") %}
                <li class="sidebar-list"><a href="{{ url_for("layout.view") }}">{% trans "Layouts" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("template.view") %}
                <li class="sidebar-list"><a href="{{ url_for("template.view") }}">{% trans "Templates" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("resolution.view") %}
                <li class="sidebar-list"><a href="{{ url_for("resolution.view") }}">{% trans "Resolutions" %}</a></li>
            {% endif %}
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["library.view", "playlist.view", "dataset.view", "menuBoard.view"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-title"><a>{% trans "Library" %}</a></li>
            {% if currentUser.featureEnabled("playlist.view") %}
                <li class="sidebar-list"><a href="{{ url_for("playlist.view") }}">{% trans "Playlists" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("library.view") %}
                <li class="sidebar-list"><a href="{{ url_for("library.view") }}">{% trans "Media" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("dataset.view") %}
                <li class="sidebar-list"><a href="{{ url_for("dataset.view") }}">{% trans "DataSets" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("menuBoard.view") %}
                <li class="sidebar-list"><a href="{{ url_for("menuBoard.view") }}">{% trans "Menu Boards" %}</a></li>
            {% endif %}
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["displays.view", "displaygroup.view", "displayprofile.view", "playersoftware.view", "command.view"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-title"><a>{% trans "Displays" %}</a></li>
            {% if currentUser.featureEnabled("displays.view") %}
                <li class="sidebar-list"><a href="{{ url_for("display.view") }}">{% trans "Displays" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("displaygroup.view") %}
                <li class="sidebar-list"><a href="{{ url_for("displaygroup.view") }}">{% trans "Display Groups" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("display.syncView") %}
                <li class="sidebar-list"><a href="{{ url_for("syncgroup.view") }}">{% trans "Sync Groups" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("displayprofile.view") %}
                <li class="sidebar-list"><a href="{{ url_for("displayprofile.view") }}">{% trans "Display Settings" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("playersoftware.view") %}
                <li class="sidebar-list"><a href="{{ url_for("playersoftware.view") }}">{% trans "Player Versions" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("command.view") %}
                <li class="sidebar-list"><a href="{{ url_for("command.view") }}">{% trans "Commands" %}</a></li>
            {% endif %}
        {% endif %}

        {% if currentUser.featureEnabled("users.view") and (currentUser.isGroupAdmin() or currentUser.isSuperAdmin()) %}
            {% set userMenuViewable = true %}
        {% else %}
            {% set userMenuViewable = false %}
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["usergroup.view", "module.view", "transition.view", "task.view"]) %}
        {% if countViewable > 0 or userMenuViewable %}
            <li class="sidebar-title"><a>{% trans "Administration" %}</a></li>

            {% if userMenuViewable %}
                <li class="sidebar-list"><a href="{{ url_for("user.view") }}">{% trans "Users" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("usergroup.view") %}
                <li class="sidebar-list"><a href="{{ url_for("group.view") }}">{% trans "User Groups" %}</a></li>
            {% endif %}

            {% if currentUser.isSuperAdmin() %}
                <li class="sidebar-list"><a href="{{ url_for("admin.view") }}">{% trans "Settings" %}</a></li>
            {% endif %}

            {% if currentUser.isSuperAdmin() %}
                <li class="sidebar-list"><a href="{{ url_for("application.view") }}">{% trans "Applications" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("module.view") %}
                <li class="sidebar-list"><a href="{{ url_for("module.view") }}">{% trans "Modules" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("transition.view") %}
                <li class="sidebar-list"><a href="{{ url_for("transition.view") }}">{% trans "Transitions" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("task.view") %}
                <li class="sidebar-list"><a href="{{ url_for("task.view") }}">{% trans "Tasks" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("tag.view") %}
                <li class="sidebar-list"><a href="{{ url_for("tag.view") }}">{% trans "Tags" %}</a></li>
            {% endif %}

            {% if currentUser.isSuperAdmin() %}
                <li class="sidebar-list"><a href="{{ url_for("folders.view") }}">{% trans "Folders" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("font.view") %}
                <li class="sidebar-list"><a href="{{ url_for("font.view") }}">{% trans "Fonts" %}</a></li>
            {% endif %}
        {% endif %}


        {% set countViewable = currentUser.featureEnabledCount(["report.view", "report.scheduling", "report.saving"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-title"><a>{% trans "Reporting" %}</a></li>

            {% if currentUser.featureEnabled("report.view") %}
                <li class="sidebar-list"><a href="{{ url_for("report.view") }}">{% trans "All Reports" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("report.scheduling") %}
                <li class="sidebar-list"><a href="{{ url_for("reportschedule.view") }}">{% trans "Report Schedules" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("report.saving") %}
                <li class="sidebar-list"><a href="{{ url_for("savedreport.view") }}">{% trans "Saved Reports" %}</a></li>
            {% endif %}

        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["log.view", "sessions.view", "auditlog.view", "fault.view"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-title"><a>{% trans "Advanced" %}</a></li>

            {% if currentUser.featureEnabled("log.view") %}
                <li class="sidebar-list"><a href="{{ url_for("log.view") }}">{% trans "Log" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("sessions.view") %}
                <li class="sidebar-list"><a href="{{ url_for("sessions.view") }}">{% trans "Sessions" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("auditlog.view") %}
                <li class="sidebar-list"><a href="{{ url_for("auditlog.view") }}">{% trans "Audit Trail" %}</a></li>
            {% endif %}

            {% if currentUser.featureEnabled("fault.view") %}
                <li class="sidebar-list"><a href="{{ url_for("fault.view") }}">{% trans "Report Fault" %}</a></li>
            {% endif %}
        {% endif %}
    </ul>
</div>
