{{#if this.redirectedReason}}
  <div class="alert alert-info">{{this.redirectedReason}}</div>
{{/if}}

<TopicDismissButtons
  @position="top"
  @selectedTopics={{this.selected}}
  @model={{this.model}}
  @showResetNew={{this.showResetNew}}
  @showDismissRead={{this.showDismissRead}}
  @resetNew={{action "resetNew"}}
/>

{{#if this.model.sharedDrafts}}
  <TopicList
    @class="shared-drafts"
    @listTitle="shared_drafts.title"
    @top={{this.top}}
    @hideCategory="true"
    @category={{this.category}}
    @topics={{this.model.sharedDrafts}}
    @discoveryList={{true}}
  />
{{/if}}

<DiscoveryTopicsList
  @model={{this.model}}
  @refresh={{action "refresh"}}
  @loadingComplete={{action "loadingComplete"}}
  @incomingCount={{this.topicTrackingState.incomingCount}}
  @autoAddTopicsToBulkSelect={{this.autoAddTopicsToBulkSelect}}
  @bulkSelectEnabled={{this.bulkSelectEnabled}}
  @addTopicsToBulkSelect={{action "addTopicsToBulkSelect"}}
  as |discoveryTopicList|
>
  {{#if this.top}}
    <div class="top-lists">
      <PeriodChooser
        @period={{this.period}}
        @action={{action "changePeriod"}}
        @fullDay={{false}}
      />
    </div>
  {{else}}
    {{#if this.topicTrackingState.hasIncoming}}
      <div class="show-more {{if this.hasTopics 'has-topics'}}">
        <a
          tabindex="0"
          href
          {{on "click" this.showInserted}}
          class="alert alert-info clickable"
        >
          <CountI18n
            @key="topic_count_"
            @suffix={{this.topicTrackingState.filter}}
            @count={{this.topicTrackingState.incomingCount}}
          />
        </a>
      </div>
    {{/if}}
  {{/if}}
  <span>
    <PluginOutlet
      @name="before-topic-list"
      @connectorTagName="div"
      @outletArgs={{hash category=this.category}}
    />
  </span>

  {{#if this.hasTopics}}
    <TopicList
      @highlightLastVisited={{true}}
      @top={{this.top}}
      @showTopicPostBadges={{this.showTopicPostBadges}}
      @showPosters={{true}}
      @canBulkSelect={{this.canBulkSelect}}
      @changeSort={{route-action "changeSort"}}
      @toggleBulkSelect={{action "toggleBulkSelect"}}
      @updateAutoAddTopicsToBulkSelect={{action
        "updateAutoAddTopicsToBulkSelect"
      }}
      @hideCategory={{this.model.hideCategory}}
      @order={{this.order}}
      @ascending={{this.ascending}}
      @bulkSelectEnabled={{this.bulkSelectEnabled}}
      @bulkSelectAction={{action "refresh"}}
      @selected={{this.selected}}
      @expandGloballyPinned={{this.expandGloballyPinned}}
      @expandAllPinned={{this.expandAllPinned}}
      @category={{this.category}}
      @topics={{this.model.topics}}
      @discoveryList={{true}}
      @scrollOnLoad={{true}}
      @onScroll={{discoveryTopicList.saveScrollPosition}}
      @focusLastVisitedTopic={{true}}
    />
  {{/if}}

  <span>
    <PluginOutlet
      @name="after-topic-list"
      @connectorTagName="div"
      @outletArgs={{hash category=this.category}}
    />
  </span>
</DiscoveryTopicsList>

<footer class="topic-list-bottom">
  <ConditionalLoadingSpinner @condition={{this.model.loadingMore}} />
  {{#if this.allLoaded}}
    <TopicDismissButtons
      @position="bottom"
      @selectedTopics={{this.selected}}
      @model={{this.model}}
      @showResetNew={{this.showResetNew}}
      @showDismissRead={{this.showDismissRead}}
      @resetNew={{action "resetNew"}}
    />

    <FooterMessage
      @education={{this.footerEducation}}
      @message={{this.footerMessage}}
    >
      {{#if this.latest}}
        {{#if this.canCreateTopicOnCategory}}
          <DiscourseLinkedText
            @action={{route-action "createTopic"}}
            @text="topic.suggest_create_topic"
          />
        {{/if}}
      {{else if this.top}}
        {{html-safe
          (i18n
            "topic.browse_all_categories_latest_or_top" basePath=(base-path)
          )
        }}
        <TopPeriodButtons
          @period={{this.period}}
          @action={{action "changePeriod"}}
        />
      {{else}}
        {{html-safe
          (i18n "topic.browse_all_categories_latest" basePath=(base-path))
        }}
      {{/if}}
    </FooterMessage>
  {{/if}}
</footer>