<div class="search row clearfix">
  {{search-text-field value=searchTerm class="full-page-search input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
  {{d-button action="search" icon="search" class="btn-primary" disabled=searching}}

  {{#if canCreateTopic}}
    <span class="new-topic-btn">{{d-button id="create-topic" class="btn-default" action="createTopic" actionParam=searchTerm icon="plus" label="topic.create"}}</span>
  {{/if}}

  {{#if canBulkSelect}}
    {{d-button icon="list" class="bulk-select" title="topics.bulk.toggle" action="toggleBulkSelect"}}
    {{bulk-select-button selected=selected action="search"}}
  {{/if}}
</div>

{{#if bulkSelectEnabled}}
  <div class='fps-select'>
    {{d-link action="selectAll" label="search.select_all"}}
    {{d-link action="clearAll" label="search.clear_all"}}
  </div>
{{/if}}

{{#if invalidSearch}}
  <div class='fps-invalid'>
    {{i18n "search.too_short"}}
  </div>
{{/if}}

{{#if context}}
  <div class='fps-search-context'>
    <label>
      {{input type="checkbox" name="searchContext" checked=searchContextEnabled}} {{searchContextDescription}}
    </label>
  </div>
{{/if}}

{{#conditional-loading-spinner condition=loading}}

  {{#unless hasResults}}
    <h3>
      {{#if searchActive}}
        {{i18n "search.no_results"}}
      {{/if}}
      <a href class="show-help" {{action "showSearchHelp" bubbles=false}}>{{i18n "search.search_help"}}</a>
    </h3>
  {{/unless}}

  {{#if hasResults}}
    <div class='search-title clearfix'>
      <div class='result-count'>
        <span>
          {{{i18n "search.result_count" count=resultCount term=noSortQ}}}
        </span>
      </div>
      <div class='sort-by'>
        <span class='desc'>
          {{i18n "search.sort_by"}}
        </span>
        {{combo-box value=sortOrder content=sortOrders castInteger="true"}}
      </div>
    </div>
  {{/if}}

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

      <div class='fps-topic'>
        <div class='topic'>
          {{#if bulkSelectEnabled}}
            {{track-selected selectedList=selected selectedId=result.topic}}
          {{/if}}

          <a class='search-link' href='{{unbound result.url}}'>
            {{topic-status topic=result.topic disableActions=true}}<span class='topic-title'>{{#highlight-text highlight=q}}{{{unbound result.topic.fancyTitle}}}{{/highlight-text}}</span>
          </a>

          <div class='search-category'>
            {{category-link result.topic.category}}
            {{#each result.topic.tags as |tag|}}
              {{discourse-tag tag}}
            {{/each}}
            {{plugin-outlet "full-page-search-category"}}
          </div>
        </div>

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

          {{#if result.blurb}}
            {{#highlight-text highlight=q}}
              {{{unbound result.blurb}}}
            {{/highlight-text}}
          {{/if}}
        </div>

        {{#if showLikeCount}}
          {{#if result.like_count}}
            <span class='like-count'>
              {{result.like_count}} {{fa-icon "heart"}}
            </span>
          {{/if}}
        {{/if}}
      </div>
    </div>
  {{/each}}

  {{#if hasResults}}
    <h3 class="search-footer">
      {{i18n "search.no_more_results"}}
      <a href class="show-help" {{action "showSearchHelp" bubbles=false}}>{{i18n "search.search_help"}}</a>
    </h3>
  {{/if}}

{{/conditional-loading-spinner}}
