<section>
  {{#if this.showPositionInput}}
    <section class="field position-fields">
      <label for="category-position">
        {{i18n "category.position"}}
      </label>
      <NumberField
        @number={{this.category.position}}
        @id="category-position"
        @class="position-input"
        @type="number"
        @min="0"
      />
    </section>
  {{/if}}

  {{#unless this.showPositionInput}}
    <section class="field position-disabled">
      {{html-safe
        (i18n
          "category.position_disabled"
          url=(get-url
            "/admin/site_settings/category/all_results?filter=fixed_category_positions"
          )
        )
      }}
    </section>
  {{/unless}}

  <section class="field num-featured-topics">
    <label for="category-number-featured-topics">
      {{#if this.category.parent_category_id}}
        {{i18n "category.subcategory_num_featured_topics"}}
      {{else}}
        {{i18n "category.num_featured_topics"}}
      {{/if}}
    </label>
    <NumberField
      @number={{this.category.num_featured_topics}}
      @id="category-number-featured-topics"
      @type="number"
      @min="1"
    />
  </section>

  <section class="field search-priority">
    <label>
      {{i18n "category.search_priority.label"}}
    </label>
    <div class="controls">
      <ComboBox
        @valueProperty="value"
        @id="category-search-priority"
        @content={{this.searchPrioritiesOptions}}
        @value={{this.category.search_priority}}
        @onChange={{action (mut this.category.search_priority)}}
        @options={{hash placementStrategy="absolute"}}
      />
    </div>
  </section>

  {{#if this.siteSettings.enable_badges}}
    <section class="field allow-badges">
      <label>
        <Input @type="checkbox" @checked={{this.category.allow_badges}} />
        {{i18n "category.allow_badges_label"}}
      </label>
    </section>
  {{/if}}

  {{#if this.siteSettings.topic_featured_link_enabled}}
    <section class="field topic-featured-link-allowed">
      <div class="allowed-topic-featured-link-category">
        <label class="checkbox-label">
          <Input
            @type="checkbox"
            @checked={{this.category.topic_featured_link_allowed}}
          />
          {{i18n "category.topic_featured_link_allowed"}}
        </label>
      </div>
    </section>
  {{/if}}

  <section class="field navigate-to-first-post-after-read">
    <label>
      <Input
        @type="checkbox"
        @checked={{this.category.navigate_to_first_post_after_read}}
      />
      {{i18n "category.navigate_to_first_post_after_read"}}
    </label>
  </section>

  <section class="field all-topics-wiki">
    <label>
      <Input @type="checkbox" @checked={{this.category.all_topics_wiki}} />
      {{i18n "category.all_topics_wiki"}}
    </label>
  </section>

  <section class="field allow-unlimited-owner-edits-on-first-post">
    <label>
      <Input
        @type="checkbox"
        @checked={{this.category.allow_unlimited_owner_edits_on_first_post}}
      />
      {{i18n "category.allow_unlimited_owner_edits_on_first_post"}}
    </label>
  </section>
</section>

<section>
  <h3>{{i18n "category.settings_sections.moderation"}}</h3>
  {{#if this.siteSettings.enable_category_group_moderation}}
    <section class="field reviewable-by-group">
      <label>{{i18n "category.reviewable_by_group"}}</label>
      <GroupSelector
        @groupFinder={{this.groupFinder}}
        @single="true"
        @groupNames={{this.category.reviewable_by_group_name}}
        @placeholderKey="category.review_group_name"
      />
    </section>
  {{/if}}

  <section class="field require-topic-approval">
    <label>
      <Input
        @type="checkbox"
        @checked={{this.category.custom_fields.require_topic_approval}}
      />
      {{i18n "category.require_topic_approval"}}
    </label>
  </section>

  <section class="field require-reply-approval">
    <label>
      <Input
        @type="checkbox"
        @checked={{this.category.custom_fields.require_reply_approval}}
      />
      {{i18n "category.require_reply_approval"}}
    </label>
  </section>

  <section class="field default-slow-mode">
    <div class="control-group">
      <label for="category-default-slow-mode">
        {{i18n "category.default_slow_mode"}}
      </label>
      <div class="category-default-slow-mode-seconds">
        <RelativeTimePicker
          @id="category-default-slow-mode"
          @durationMinutes={{this.category.defaultSlowModeMinutes}}
          @hiddenIntervals={{this.hiddenRelativeIntervals}}
          @onChange={{action "onDefaultSlowModeDurationChange"}}
        />
      </div>
    </div>
  </section>

  <section class="field auto-close">
    <div class="control-group">
      <label for="topic-auto-close">
        {{i18n "topic.auto_close.label"}}
      </label>
      <div class="category-topic-auto-close-hours">
        <RelativeTimePicker
          @id="topic-auto-close"
          @durationHours={{this.category.auto_close_hours}}
          @hiddenIntervals={{this.hiddenRelativeIntervals}}
          @onChange={{action "onAutoCloseDurationChange"}}
        />
      </div>
      <label>
        <Input
          @type="checkbox"
          @checked={{this.category.auto_close_based_on_last_post}}
        />
        {{i18n "topic.auto_close.based_on_last_post"}}
      </label>
    </div>
  </section>

  <section class="field num-auto-bump-daily">
    <label for="category-number-daily-bump">
      {{i18n "category.num_auto_bump_daily"}}
    </label>
    <NumberField
      @number={{this.category.custom_fields.num_auto_bump_daily}}
      @id="category-number-daily-bump"
      @type="number"
      @min="0"
    />
  </section>
</section>

<section>
  <h3>{{i18n "category.settings_sections.appearance"}}</h3>

  <section class="field default-view-field">
    <label>
      {{i18n "category.default_view"}}
    </label>
    <div class="controls">
      <ComboBox
        @valueProperty="value"
        @id="category-default-view"
        @content={{this.availableViews}}
        @value={{this.category.default_view}}
        @options={{hash placementStrategy="absolute"}}
      />
    </div>
  </section>

  <section class="field default-top-period-field">
    <label>
      {{i18n "category.default_top_period"}}
    </label>
    <div class="controls">
      <ComboBox
        @valueProperty="value"
        @id="category-default-period"
        @content={{this.availableTopPeriods}}
        @value={{this.category.default_top_period}}
        @options={{hash placementStrategy="absolute"}}
      />
    </div>
  </section>

  <section class="field sort-order">
    <label>
      {{i18n "category.sort_order"}}
    </label>
    <div class="controls">
      <ComboBox
        @valueProperty="value"
        @content={{this.availableSorts}}
        @value={{this.category.sort_order}}
        @options={{hash none="category.sort_options.default"}}
        @onChange={{action (mut this.category.sort_order)}}
      />
      {{#unless this.isDefaultSortOrder}}
        <ComboBox
          @valueProperty="value"
          @content={{this.sortAscendingOptions}}
          @value={{this.sortAscendingOption}}
          @options={{hash
            none="category.sort_options.default"
            placementStrategy="absolute"
          }}
          @onChange={{action (mut this.category.sort_ascending)}}
        />
      {{/unless}}
    </div>
  </section>

  <section class="field default-filter">
    <label>
      {{i18n "category.default_list_filter"}}
    </label>
    <div class="controls">
      <ComboBox
        @id="category-default-filter"
        @valueProperty="value"
        @content={{this.availableListFilters}}
        @value={{this.category.default_list_filter}}
      />
    </div>
  </section>

  {{#if this.isParentCategory}}
    <section class="field show-subcategory-list-field">
      <label>
        <Input
          @type="checkbox"
          @checked={{this.category.show_subcategory_list}}
        />
        {{i18n "category.show_subcategory_list"}}
      </label>
    </section>
  {{/if}}

  {{#if this.showSubcategoryListStyle}}
    <section class="field subcategory-list-style-field">
      <label>
        {{i18n "category.subcategory_list_style"}}
      </label>
      <ComboBox
        @valueProperty="value"
        @id="subcategory-list-style"
        @content={{this.availableSubcategoryListStyles}}
        @value={{this.category.subcategory_list_style}}
        @options={{hash placementStrategy="absolute"}}
      />
    </section>
  {{/if}}

  <section class="field category-read-only-banner">
    <label for="read-only-message">{{i18n "category.read_only_banner"}}</label>
    <TextField
      @valueProperty="value"
      @id="read-only-message"
      @value={{this.category.read_only_banner}}
      @options={{hash placementStrategy="absolute"}}
    />
  </section>
</section>

<section>
  <h3>{{i18n "category.settings_sections.email"}}</h3>

  {{#if this.emailInEnabled}}
    <section class="field category-email-in">
      <label for="category-email-in">
        {{d-icon "envelope"}}
        {{i18n "category.email_in"}}
      </label>
      <TextField
        @id="category-email-in"
        @class="email-in"
        @value={{this.category.email_in}}
      />
      <span>
        {{d-icon "info-circle"}}
        <DTooltip>{{i18n "category.email_in_tooltip"}}</DTooltip>
      </span>
    </section>

    <section class="field email-in-allow-strangers">
      <label>
        <Input
          @type="checkbox"
          @checked={{this.category.email_in_allow_strangers}}
        />
        {{i18n "category.email_in_allow_strangers"}}
      </label>
    </section>

    <section class="field mailinglist-mirror">
      <label>
        <Input @type="checkbox" @checked={{this.category.mailinglist_mirror}} />
        {{i18n "category.mailinglist_mirror"}}
      </label>
    </section>

    <span>
      <PluginOutlet
        @name="category-email-in"
        @connectorTagName="div"
        @outletArgs={{hash category=this.category}}
      />
    </span>
  {{/if}}

  {{#unless this.emailInEnabled}}
    <section class="field email-in-disabled">
      {{i18n "category.email_in_disabled"}}
      <a href={{get-url "/admin/site_settings/category/email"}}>{{i18n
          "category.email_in_disabled_click"
        }}</a>
    </section>
  {{/unless}}
</section>

<section>
  <PluginOutlet
    @name="category-custom-settings"
    @outletArgs={{hash category=this.category}}
  />
</section>