<div id="related-topics" class="more-topics__list " role="complementary" aria-labelledby="related-topics-title">
  <h3 id="related-topics-title" class="more-topics__list-title">
    <%= t 'js.discourse_ai.related_topics.title' %>
  </h3>
  <div class="topic-list-container" itemscope itemtype='http://schema.org/ItemList'>
    <meta itemprop='itemListOrder' content='http://schema.org/ItemListOrderDescending'>
    <table class='topic-list'>
      <thead>
        <tr>
          <th><%= t 'js.topic.title' %></th>
          <th></th>
          <th class="replies"><%= t 'js.replies' %></th>
          <th class="views"><%= t 'js.views' %></th>
          <th><%= t 'js.activity' %></th>
        </tr>
      </thead>
      <tbody>
        <% @list.each_with_index do |topic, idx| %>
          <tr class="topic-list-item" id="topic-list-item-<%= topic.id %>">
            <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
              <meta itemprop='position' content='<%= idx + 1 %>'>
              <span class="link-top-line">
                <a itemprop='url' href='<%= topic.url %>' class='title raw-link raw-topic-link'><%= topic.title %></a>
              </span>
              <div class="link-bottom-line">
                <% if (!@category || @category.has_children?) && topic.category && !topic.category.uncategorized? %>
                  <a href='<%= topic.category.url %>' class='badge-wrapper bullet'>
                    <span class='badge-category-bg' style='background-color: #<%= topic.category.color %>'></span>
                    <span class='badge-category clear-badge'>
                      <span class='category-name'><%= topic.category.name %></span>
                    </span>
                  </a>
                <% end %>
                <% if tags = topic.visible_tags(guardian) %>
                  <div class="discourse-tags">
                    <% tags.each_with_index do |tag, index| %>
                      <a href='<%= tag.full_url %>' class='discourse-tag'><%= tag.name %></a>
                      <% if index < tags.size - 1 %>,&nbsp;<% end %>
                    <% end %>
                  </div>
                <% end %>
              </div>
            </td>
            <td class="replies">
              <span class='posts' title='<%= t 'posts' %>'><%= topic.posts_count - 1 %></span>
            </td>
            <td class="views">
              <span class='views' title='<%= t 'views' %>'><%= topic.views %></span>
            </td>
            <td>
              <%= I18n.l(topic.last_posted_at || topic.created_at, format: :date_only) %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
