<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_settings_search_search_index %}
<sw-card
    position-identifier="sw-settings-search-search-index"
    :title="$tc('sw-settings-search.generalTab.labelSearchIndex')"
    :is-loading="isLoading"
>

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_search_search_index_description %}
    <sw-alert
        v-if="isRebuildInProgress"
        class="sw-settings-search__search-index-warning-text"
        variant="warning"
    >

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_search_index_warning_top %}
        <p class="sw-settings-search__search-index-warning-top">
            {{ $tc('sw-settings-search.generalTab.textWarningOpenTab') }}
        </p>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_search_index_warning_bottom %}
        <p>{{ $tc('sw-settings-search.generalTab.textRebuildSearchIndexDescription') }}</p>
        {% endblock %}

    </sw-alert>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_search_search_index_rebuild_button %}
    <sw-button-process
        variant="ghost"
        class="sw-settings-search__search-index-rebuild-button"
        :is-loading="isRebuildInProgress"
        :disabled="isRebuildInProgress || !acl.can('product_search_config.editor')"
        :process-success="isRebuildSuccess"
        @update:process-success="buildFinish"
        @click="rebuildSearchIndex"
    >
        {{ $tc('sw-settings-search.generalTab.buttonRebuildSearchIndex') }}
    </sw-button-process>

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_search_search_index_lastest_build %}
    <span class="sw-settings-search__search-index-latest-build">
        <template v-if="latestIndex">
            {{ $tc('sw-settings-search.generalTab.textLastedBuild') }} <sw-time-ago :date="latestIndex.firstDate" /> &dash; <sw-time-ago :date="latestIndex.lastDate" />
        </template>
        <template v-else>
            {{ $tc('sw-settings-search.generalTab.textSearchNotIndexedYet') }}
        </template>
    </span>
    {% endblock %}
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_search_search_index_rebuild_progress %}
    <div
        v-if="progressBarValue"
        class="sw-settings-search__search-index-rebuilding-progress"
    >

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_search_index_rebuild_progress_text %}
        <span class="sw-settings-search__search-index-rebuilding-text">
            {{ $tc('sw-settings-search.generalTab.textRebuildingSearchIndex') }}
        </span>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_search_index_rebuild_progress_bar %}
        <sw-progress-bar
            :value="progressBarValue"
            :max-value="100"
        >
            {{ $tc('sw-settings-search.generalTab.textRebuildingSearchIndex') }}
        </sw-progress-bar>
        {% endblock %}
    </div>
    {% endblock %}

</sw-card>
{% endblock %}
