{% macro posting(form) %}
    <section class="section-form">
        {{ form_start(form) }}
        {{ form_errors(form) }}
        {% if form.in is defined %}
            {{ form_row(form.in) }}
        {% endif %}
        {{ form_row(form.visibility) }}
        {{ form_row(form.content_type) }}
        {{ form_row(form.content) }}
        {{ form_row(form.attachments) }}

        <details class="section-details-subtitle frame-section">
            <summary class="details-summary-subtitle">
                <strong>
                    {% trans %}Additional options{% endtrans %}
                </strong>
            </summary>
            <section class="section-form">
                {{ form_row(form.language) }}
                {{ form_row(form.tag_use_canonical) }}
            </section>
        </details>
        {{ form_rest(form) }}
        {{ form_end(form) }}
    </section>
{% endmacro %}

{% macro posting_section_vanilla(widget) %}
    <section class="frame-section" title="{% trans %}Create a new note{% endtrans %}">
        <details class="section-details-title" open="open"
                 title="{% trans %}Expand if you want to access more options{% endtrans %}">
            <summary class="details-summary-title">
                <span>
                    {% trans %}Create a note{% endtrans %}
                </span>
            </summary>

            {% import _self as forms %}
            {{ forms.posting(widget) }}
        </details>
    </section>
{% endmacro %}

{% macro posting_section_reply(widget, extra) %}
    <section class="frame-section" title="{% trans %}Create a new note{% endtrans %}">
        <details class="section-details-title" open="open"
                 title="{% trans %}Expand if you want to access more options{% endtrans %}">
            <summary class="details-summary-title">
                <span>
                    {% trans %}Reply to note{% endtrans %}
                </span>
            </summary>

            {% for block in extra %}
                <section class="posting-extra">
                    {{ block | raw }}
                </section>
            {% endfor %}

            {% import _self as forms %}
            {{ forms.posting(widget) }}
        </details>
    </section>
{% endmacro %}

{% block rightpanel %}
    {% import _self as this %}
    <label class="panel-right-icon" for="toggle-panel-right"
           tabindex="-1">{{ icon('chevron-left', 'icon icon-right') | raw }}</label>
    <a id="anchor-right-panel" class="anchor-hidden" tabindex="0"
       title="{% trans %}Press tab followed by a space to access right panel{% endtrans %}"></a>
       <input type="checkbox" id="toggle-panel-right" tabindex="0" title="{% trans %}Open right panel{% endtrans %}"
           {% if app.request.get('_route') == 'conversation_reply_to' %}checked{% endif %}>

    <aside class="section-panel section-panel-right">
        {% set var_list = {'path': app.request.get('_route'), 'request': app.request, 'vars': right_panel_vars | default } %}
        {% set blocks = add_right_panel_block('prepend', var_list) %}
        {% set blocks = blocks|merge(add_right_panel_block('main', var_list)) %}
        {% set blocks = blocks|merge(add_right_panel_block('append', var_list)) %}

        <section class="panel-content accessibility-target">
            {% for widget in blocks %}
                {% if widget is iterable and widget.vars.id == 'post_note' %}
                    {% if app.request.get('_route') == 'conversation_reply_to' %}
                        {% set extra = handle_event('PrependPostingForm', request) %}
                        {{ this.posting_section_reply(widget, extra) }}
                    {% else %}
                        {{ this.posting_section_vanilla(widget) }}
                    {% endif %}
                {% else %}
                    {{ widget | raw }}
                {% endif %}
            {% endfor %}
        </section>
    </aside>
{% endblock rightpanel %}