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

  {{#if showPositionInput}}
    <section class="field position-fields">
      <label for="category-position">
        {{i18n "category.position"}}
      </label>
      {{text-field value=category.position id="category-position" class="position-input" type="number"}}
    </section>
  {{/if}}

  {{#unless showPositionInput}}
    <section class="field">
      {{i18n "category.position_disabled"}}
      <a href={{get-url "/admin/site_settings/category/basic"}}>{{i18n "category.position_disabled_click"}}</a>
    </section>
  {{/unless}}

  <section class="field">
    <label for="category-number-featured-topics">
      {{#if category.parent_category_id}}
        {{i18n "category.subcategory_num_featured_topics"}}
      {{else}}
        {{i18n "category.num_featured_topics"}}
      {{/if}}
    </label>
    {{text-field value=category.num_featured_topics id="category-number-featured-topics" type="number"}}
  </section>

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

  <section class="field">
    <label>
      {{input type="checkbox" checked=category.allow_badges}}
      {{i18n "category.allow_badges_label"}}
    </label>
  </section>

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

  <section class="field">
    <label>
      {{input type="checkbox" checked=category.navigate_to_first_post_after_read}}
      {{i18n "category.navigate_to_first_post_after_read"}}
    </label>
  </section>

  <section class="field">
    <label>
      {{input type="checkbox" checked=category.all_topics_wiki}}
      {{i18n "category.all_topics_wiki"}}
    </label>
  </section>
</section>

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

  <section class="field">
    <label>
      {{input type="checkbox" checked=category.custom_fields.require_topic_approval}}
      {{i18n "category.require_topic_approval"}}
    </label>
  </section>

  <section class="field">
    <label>
      {{input type="checkbox" checked=category.custom_fields.require_reply_approval}}
      {{i18n "category.require_reply_approval"}}
    </label>
  </section>

  <section class="field">
    <div class="control-group">
      <label for="topic-auto-close">
        {{i18n "topic.auto_close.label"}}
      </label>
      {{text-field value=category.auto_close_hours id="topic-auto-close" type="number"}}
      <label>
        {{input type="checkbox" checked=category.auto_close_based_on_last_post}}
        {{i18n "topic.auto_close.based_on_last_post"}}
      </label>
    </div>
  </section>

  {{#if siteSettings.tagging_enabled}}
    <section class="field minimum-required-tags">
      <label for="category-minimum-tags">
        {{i18n "category.minimum_required_tags"}}
      </label>
      {{text-field value=category.minimum_required_tags id="category-minimum-tags" type="number" min="0"}}
    </section>
  {{/if}}

  <section class="field">
    <label for="category-number-daily-bump">
      {{i18n "category.num_auto_bump_daily"}}
    </label>
    {{text-field value=category.custom_fields.num_auto_bump_daily id="category-number-daily-bump" type="number"}}
  </section>
</section>

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

  <section class="field default-view-field">
    <label for="category-default-view">
      {{i18n "category.default_view"}}
    </label>
    <div class="controls">
      {{combo-box
        valueProperty="value"
        id="category-default-view"
        content=availableViews
        value=category.default_view
        options=(hash
          placementStrategy="absolute"
        )
      }}
    </div>
  </section>

  <section class="field default-top-period-field">
    <label for="category-default-period">
      {{i18n "category.default_top_period"}}
    </label>
    <div class="controls">
      {{combo-box
        valueProperty="value"
        id="category-default-period"
        content=availableTopPeriods
        value=category.default_top_period
        options=(hash
          placementStrategy="absolute"
        )
      }}
    </div>
  </section>

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

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

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

  {{#if showSubcategoryListStyle}}
    <section class="field subcategory-list-style-field">
      <label for="subcategory-list-style">
        {{i18n "category.subcategory_list_style"}}
      </label>
      {{combo-box
        valueProperty="value"
        id="subcategory-list-style"
        content=availableSubcategoryListStyles
        value=category.subcategory_list_style
        options=(hash
          placementStrategy="absolute"
        )
      }}
    </section>
  {{/if}}

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

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

  {{#if emailInEnabled}}
    <section class="field">
      <label for="category-email-in">
        {{d-icon "far-envelope"}}
        {{i18n "category.email_in"}}
      </label>
      {{text-field id="category-email-in" class="email-in" value=category.email_in}}
    </section>

    <section class="field">
      <label>
        {{input type="checkbox" checked=category.email_in_allow_strangers}}
        {{i18n "category.email_in_allow_strangers"}}
      </label>
    </section>

    <section class="field">
      <label>
        {{input type="checkbox" checked=category.mailinglist_mirror}}
        {{i18n "category.mailinglist_mirror"}}
      </label>
    </section>

    {{plugin-outlet name="category-email-in" args=(hash category=category)}}
  {{/if}}

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

{{plugin-outlet name="category-custom-settings" args=(hash category=category) connectorTagName="" tagName="section"}}
