{% extends "freeform/_layouts/main" %}

{% set selectedSubnavItem = 'settings' %}
{% set fullPageForm = true %}

{% set navItems = craft.freeform.settingsNavigation %}

{% set segment2 = craft.app.request.getSegment(2) %}
{% set segment3 = craft.app.request.getSegment(3) %}
{% set segment4 = craft.app.request.getSegment(4) %}

{% block actionButton %}
    <div class="buttons">
        <div class="btngroup submit">
            <input type="submit" class="btn submit" value="{{ 'Save'|t('freeform') }}">
        </div>
    </div>
{% endblock %}

{% block sidebar %}
    {% set segment = segment3~(segment4 ? '/'~segment4) %}
    {% set segment = segment|freeformRegexReplace('/\\/\\d+$/') %}

    <nav>
        <ul>
            {% for id, item in navItems %}
                {% if item.heading is defined %}
                    <li class="heading"><span>{{ item.heading }}</span></li>
                {% else %}
                    <li>
                        {% set selected = id == segment %}
                        <a href="{{ url('freeform/settings/'~id) }}"{% if selected %} class="sel"{% endif %}>
                            {{ item.title | raw }}
                        </a>
                    </li>
                {% endif %}
            {% endfor %}
        </ul>
    </nav>
{% endblock %}
