<% cache [locale_and_user_status, debate, current_user&.voted_as_when_voted_for(debate)] do %>
  <div id="<%= dom_id(debate) %>" class="debate clear" data-type="debate">
    <div class="panel">
      <div class="debate-content">
        <h3><%= link_to debate.title, debate %></h3>
        <p class="debate-info">
          <%= l debate.created_at.to_date %>
          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <%= render Shared::CommentsCountComponent.new(
            debate.comments_count,
            url: debate_path(debate, anchor: "comments")
          ) %>

          <% if debate.author.hidden? || debate.author.erased? %>
            <span class="bullet">&nbsp;&bull;&nbsp;</span>
            <span class="author">
              <%= t("debates.show.author_deleted") %>
            </span>
          <% else %>
            <span class="bullet">&nbsp;&bull;&nbsp;</span>
            <span class="author">
              <%= debate.author.name %>
            </span>
            <% if debate.author.display_official_position_badge? %>
              <span class="bullet">&nbsp;&bull;&nbsp;</span>
              <span class="label round level-<%= debate.author.official_level %>">
                <%= debate.author.official_position %>
              </span>
            <% end %>
          <% end %>

          <% if debate.author.verified_organization? %>
            <span class="bullet">&nbsp;&bull;&nbsp;</span>
            <span class="label round is-association">
              <%= t("shared.collective") %>
            </span>
          <% end %>

        </p>
        <div class="debate-description">
          <%= wysiwyg(debate.description) %>
          <div class="truncate"></div>
        </div>
        <%= render "shared/tags", taggable: debate, limit: 5 %>
      </div>

      <div id="<%= dom_id(debate) %>_votes">
        <%= render Debates::VotesComponent.new(debate) %>
      </div>
    </div>
  </div>
<% end %>
