{% if topic %}

{% set replies = frappe.get_all("Discussion Reply", {"topic": topic.name},
["reply", "owner", "creation"], order_by="creation")%}

{% endif %}

<div class="collapse discussion-on-page" data-parent="#discussion-group"
	{% if topic %} id="t{{ topic.name }}" data-topic="{{ topic.name }}" {% endif %}>

	{% if not single_thread %}
	<div class="btn btn-md btn-default ellipsis back">
		{{ _("Back") }}
	</div>
	{% endif %}

	{% if topic and topic.title %}
	<div class="discussion-heading p-0">{{ topic.title }}</div>
	{% endif %}

	{% for reply in replies %}
	{% include "frappe/templates/discussions/reply_card.html" %}

	{% if loop.index != replies | length %}
	<div class="card-divider-dark mb-8"></div>
	{% endif %}
	{% endfor %}

	{% if frappe.session.user == "Guest" or (condition is defined and not condition) %}
	<div class="d-flex flex-column align-items-center small">
		{{ _("Want to join the discussion?") }}
		{% if frappe.session.user == "Guest" %}
		<div class="btn btn-default btn-md mt-3 mb-3" id="login-from-discussion">{{ _("Login") }}</div>
		{% elif not condition %}
		<div class="btn btn-default btn-md mt-3 mb-3" id="login-from-discussion" data-redirect="{{ redirect_to }}">{{ button_name }}
		</div>
		{% endif %}
	</div>
	{% else %}
	{% include "frappe/templates/discussions/comment_box.html" %}
	{% endif %}

</div>
