<script lang="ts">
  import { pruneAllManga } from '$lib/Media/Manga/cache';
  import locale from '$stores/locale';
  import settings from '$stores/settings';
  import SettingCheckboxToggle from '../SettingCheckboxToggle.svelte';
  import SettingHint from '../SettingHint.svelte';
</script>

<SettingCheckboxToggle
  setting="calculatePreferNativeChapterCount"
  text={$locale().settings.calculation.fields.preferNativeChapterCount.title}
  onChange={pruneAllManga}
>
  <SettingHint lineBreak>
    {$locale().settings.calculation.fields.preferNativeChapterCount.hint}
  </SettingHint>
</SettingCheckboxToggle>

<br />

<SettingCheckboxToggle
  setting="calculateChaptersRoundedDown"
  text={$locale().settings.calculation.fields.roundDownChapters.title}
>
  <SettingHint lineBreak>
    {$locale().settings.calculation.fields.roundDownChapters.hint}
  </SettingHint>
</SettingCheckboxToggle>

<br />

<SettingCheckboxToggle
  setting="displayNotStarted"
  text={$locale().settings.calculation.fields.showMediaWithZeroProgress.title}
>
  <SettingHint lineBreak>
    {$locale().settings.calculation.fields.showMediaWithZeroProgress.hint}
  </SettingHint>
</SettingCheckboxToggle>

<br />

<SettingCheckboxToggle
  setting="calculateDisableOutOfDateVolumeWarning"
  text={$locale().settings.calculation.fields.hideOutOfDateVolumeWarning.title}
>
  <SettingHint lineBreak>
    Out-of-date volume warnings display an alert when there is a mismatch between the chapter
    progress and number of volumes you have logged for a given title.
    <br />
    For example, an alert would be shown if you have tracked a manga up to Ch. 50 (Vol. 5), but have less
    than 4 volumes logged.

    <br />

    Disabling this option speeds up refresh times for manga lists.
  </SettingHint>
</SettingCheckboxToggle>

<br />

<SettingCheckboxToggle
  setting="calculateGuessingDisabled"
  text={$locale().settings.calculation.fields.smartChapterCountEstimation.title}
  invert
>
  <SettingHint lineBreak>
    Smart chapter count calculation uses statistical methods to estimate the number of chapters
    available for a given title based on user submitted progress.<br />Disabling this setting will
    disable light novel chapter count reporting and will disable smart chapter count calculation for
    titles which you have higher progress than officially reported.
  </SettingHint>
</SettingCheckboxToggle>

{#if !$settings.calculateGuessingDisabled}
  <br />

  <select bind:value={$settings.calculateGuessMethod} onchange={pruneAllManga}>
    <option value="mode">Mode (fast, moderate to low accuracy)</option>
    <option value="median">Median (moderate speed, high accuracy, recommended)</option>
    <option value="iqr_median">Interquartile Range with Median (slower, high accuracy)</option>
    <option value="iqr_mode">Interquartile Range with Mode (slower, high accuracy)</option>
  </select>
  Smart chapter count calculation method

  <SettingHint lineBreak>
    No chapter count estimation method will be 100% accurate. Since estimated media requires scores
    derived from user submitted progress, high (or low) false-reports skew the data.
  </SettingHint>
{/if}
