<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_import_export_edit_profile_modal %}
<div class="sw-import-export-edit-profile-modal">
    <sw-modal
        v-if="show && profile"
        class="sw-import-export-edit-profile-modal"
        :title="modalTitle"
        variant="full"
        @modal-close="$emit('profile-close')"
    >

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_import_export_edit_profile_modal_alert %}
        <sw-alert
            v-if="profile.systemDefault"
            variant="info"
        >
            {{ $tc('sw-import-export.profile.systemDefaultInfoText') }}
        </sw-alert>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_import_export_edit_profile_modal_tabs %}
        <sw-tabs
            position-identifier="sw-import-export-edit-profile-modal"
            :small="false"
            default-item="general"
        >

            <template #default="{ active }">

                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_import_export_edit_profile_modal_tabs_general %}
                <sw-tabs-item
                    :title="$tc('sw-import-export.profile.generalTab')"
                    :active-tab="active"
                    name="general"
                >
                    {{ $tc('sw-import-export.profile.generalTab') }}
                </sw-tabs-item>
                {% endblock %}

                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_import_export_edit_profile_modal_tabs_field_mappings %}
                <sw-tabs-item
                    :title="$tc('sw-import-export.profile.mappingsTab')"
                    :active-tab="active"
                    name="mappings"
                >
                    {{ $tc('sw-import-export.profile.mappingsTab') }}
                </sw-tabs-item>
                {% endblock %}

                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_import_export_edit_profile_modal_tabs_field_advanced %}
                <sw-tabs-item
                    v-if="profile.type !== 'export' && profile.config.updateEntities !== false"
                    :title="$tc('sw-import-export.profile.advancedTab')"
                    :active-tab="active"
                    name="advanced"
                >
                    {{ $tc('sw-import-export.profile.advancedTab') }}
                </sw-tabs-item>
                {% endblock %}
            </template>

            <template #content="{ active }">
                <template v-if="active === 'general'">
                    <sw-import-export-edit-profile-general :profile="profile" />

                    <sw-import-export-edit-profile-field-indicators :profile="profile" />
                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_import_export_edit_profile_modal_tabs_general_import_settings %}
                    <sw-import-export-edit-profile-import-settings :profile="profile" />
                    {% endblock %}
                </template>

                <template v-if="active === 'mappings'">
                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_import_export_edit_profile_modal_tabs_mappings %}

                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_import_export_edit_profile_modal_tabs_mappings_text %}
                    <p class="sw-import-export-edit-profile-modal__text">
                        {{ $tc('sw-import-export.profile.mappingDescription') }}
                    </p>
                    {% endblock %}

                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_import_export_edit_profile_modal_tabs_mappings_mapping %}
                    <sw-import-export-edit-profile-modal-mapping
                        :profile="profile"
                        :system-required-fields="systemRequiredFields"
                        @update-mapping="updateMapping"
                    />
                    {% endblock %}
                    {% endblock %}
                </template>

                <template v-if="active === 'advanced' && profile.type !== 'export' && profile.config.updateEntities !== false">
                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_import_export_edit_profile_modal_tabs_advanced %}

                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_import_export_edit_profile_modal_tabs_advanced_text %}
                    <p class="sw-import-export-edit-profile-modal__text">
                        {{ $tc('sw-import-export.profile.advancedDescription') }}
                    </p>
                    {% endblock %}

                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_import_export_edit_profile_modal_tabs_advanced_identifiers %}
                    <sw-import-export-edit-profile-modal-identifiers
                        :profile="profile"
                    />
                    {% endblock %}
                    {% endblock %}
                </template>

                <template v-if="active === 'fieldIndicators'">
                    <p class="sw-import-export-edit-profile-modal__text">
                        {{ $tc('sw-import-export.profile.csvDescriptionBlock') }}
                    </p>
                </template>
            </template>
        </sw-tabs>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_import_export_edit_profile_modal_footer %}
        <template #modal-footer>
            <sw-button
                size="small"
                @click="$emit('profile-close')"
            >
                {{ $tc('global.default.cancel') }}
            </sw-button>
            <template v-if="profile.systemDefault">
                <sw-button
                    class="sw-import-export-edit-profile-modal__save-action"
                    size="small"
                    variant="primary"
                    @click="$emit('profile-close')"
                >
                    {{ $tc('sw-import-export.profile.closeProfileLabel') }}
                </sw-button>
            </template>
            <template v-else>
                <sw-button
                    class="sw-import-export-edit-profile-modal__save-action"
                    size="small"
                    :disabled="!profile.sourceEntity
                        || profile.sourceEntity.length <= 0
                        || !profile.type"
                    variant="primary"
                    @click="saveProfile"
                >
                    {{ saveLabelSnippet }}
                </sw-button>
            </template>
        </template>
        {% endblock %}
    </sw-modal>

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_import_export_edit_profile_violation_modal %}
    <sw-modal
        v-if="showValidationError"
        :title="$tc('global.default.error')"
        class="sw-import-export-edit-profile-modal__violation-modal"
        @modal-close="resetViolations"
    >

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_import_export_edit_profile_violation_modal_message %}
        <p>{{ $tc('sw-import-export.profile.violationMessage') }}</p>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_import_export_edit_profile_violation_modal_required_fields %}
        <ul>
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_import_export_edit_profile_violation_modal_required_field %}
            <li
                v-for="requiredField in missingRequiredFields"
                :key="requiredField"
            >
                {{ requiredField }}
            </li>
            {% endblock %}
        </ul>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_import_export_edit_profile_violation_modal_footer %}
        <template #modal-footer>
            <sw-button
                size="small"
                @click="resetViolations"
            >
                {{ $tc('sw-import-export.profile.closeViolation') }}
            </sw-button>
        </template>
        {% endblock %}
    </sw-modal>
    {% endblock %}
</div>
{% endblock %}
