<div class="admin-title">
  <PeriodChooser
    @period={{this.period}}
    @onChange={{action (mut this.period)}}
  />
  <ComboBox
    @content={{this.searchTypeOptions}}
    @value={{this.searchType}}
    @class="search-logs-filter"
    @onChange={{action (mut this.searchType)}}
  />
</div>

<h2>
  <LinkTo
    @route="full-page-search"
    @query={{hash q=this.term}}
  >{{this.term}}</LinkTo>
</h2>

<ConditionalLoadingSpinner @condition={{this.refreshing}}>
  <AdminGraph @model={{this.model}} @type="bar" />

  <br /><br />
  <h2> {{i18n "admin.logs.search_logs.header_search_results"}} </h2>
  <br />

  <div class="header-search-results">
    {{#each this.model.search_result.posts as |result|}}
      <div class="fps-result">
        <div class="author">
          <a href={{result.userPath}} data-user-card={{result.username}}>
            {{avatar result imageSize="large"}}
          </a>
        </div>

        <div class="fps-topic">
          <div class="topic">
            <a href={{result.url}} class="search-link">
              <TopicStatus @topic={{result.topic}} @disableActions={{true}} />
              <span class="topic-title">
                {{#if result.useTopicTitleHeadline}}
                  {{html-safe result.topicTitleHeadline}}
                {{else}}
                  <HighlightSearch @highlight={{this.q}}>
                    {{html-safe result.topic.fancyTitle}}
                  </HighlightSearch>
                {{/if}}
              </span>
            </a>

            <div class="search-category">
              {{#if result.topic.category.parentCategory}}
                {{category-link result.topic.category.parentCategory}}
              {{/if}}
              {{category-link result.topic.category hideParent=true}}
              {{#each result.topic.tags as |tag|}}
                {{discourse-tag tag}}
              {{/each}}
            </div>
          </div>

          <div class="blurb container">
            <span class="date">
              {{format-age result.created_at}}
              {{#if result.blurb}}
                -
              {{/if}}
            </span>

            {{#if result.blurb}}
              {{#if this.siteSettings.use_pg_headlines_for_excerpt}}
                {{html-safe result.blurb}}
              {{else}}
                <HighlightSearch @highlight={{this.highlightQuery}}>
                  {{html-safe result.blurb}}
                </HighlightSearch>
              {{/if}}
            {{/if}}
          </div>
        </div>
      </div>
    {{/each}}
  </div>
</ConditionalLoadingSpinner>