{% import "macros.html" as macros %}

{% include "question/question_card.html" %}

{% if answers %}

  {% include "question/answers_sort_nav.html" %}

  {% if settings.SHOW_ACCEPTED_ANSWER_FIRST == False %}
    {% if thread.has_accepted_answer() and answers and thread.accepted_answer != answers[0] %}
      <a class="accepted-answer-link" href="{{ thread.accepted_answer.get_absolute_url() }}">
        {% trans %}See the accepted answer{% endtrans %}
      </a>
    {% endif %}
  {% endif %} 

  {% for answer in answers %}
    {% include "question/answer_card.html" %}
    {% if loop.index == 1 and 'QUESTION_PAGE_ANSWER_BANNER'|show_block_to(request.user) %}
      <div class="banner">{{ settings.QUESTION_PAGE_ANSWER_BANNER|safe }}</div>
    {% endif %}
  {% endfor %}

  {{ macros.paginator(paginator_context, anchor='#sort-bottom') }}

  {% if settings.QUESTION_PAGE_ALWAYS_SHOW_ANSWER_BANNER %}
    {% if 'QUESTION_PAGE_ANSWER_BANNER'|show_block_to(request.user) %}
      <div class="banner">{{ settings.QUESTION_PAGE_ANSWER_BANNER|safe }}</div>
    {% endif %}
  {% endif %}
{% endif %}

{% if hide_answer_ui %}
  {# Empty branch - no form or answer-related buttons. Please do not delete this comment #}
{% elif show_answer_form %}
  {% include "question/new_answer_form.html" %}
{% elif not request.user.is_authenticated and not settings.ALLOW_POSTING_BEFORE_LOGGING_IN %}
  {% include "question/new_answer_form_title.html" %}
  <a class="btn submit mb-4"
    href="{{settings.LOGIN_URL}}?next={{ encode_jwt({'next_url': url('question', question.id)}) }}"
  >{{ settings.WORDS_LOGIN_SIGNUP_TO_ANSWER|escape }}</a>
{% elif request.user.is_authenticated and settings.LIMIT_ONE_ANSWER_PER_USER %}
  {% include "question/new_answer_form_title.html" %}
  <div class="info-box">
    <div class="mb-2">{{ settings.WORDS_ONLY_ONE_ANSWER_PER_USER_IS_ALLOWED|escape }}</div>
    <a class="btn" href="{{ url('edit_answer',  previous_answer.id ) }}">{{ settings.WORDS_EDIT_YOUR_PREVIOUS_ANSWER|escape }}</a>
  </div>
{% endif %}
