<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_extension_permissions_modal %}
<sw-modal
    class="sw-extension-permissions-modal"
    :title="modalTitle"
    variant="small"
    v-on="listeners"
>
    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_extension_permissions_modal_content %}
    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_extension_permissions_modal_intro %}
    <div class="sw-extension-permissions-modal__intro">
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_extension_permissions_modal_intro_image %}
        <img
            class="sw-extension-permissions-modal__image"
            :src="assetFilter('/administration/static/img/extension-store/permissions.svg')"
            alt=""
        >
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_extension_permissions_modal_intro_text %}
        <p class="sw-extension-permissions-modal__description">
            {{ descriptionText }}
        </p>

        <p
            v-if="domainsList.length > 0"
            class="sw-extension-permissions-modal__domain-hint"
        >
            {{ $tc('sw-extension-store.component.sw-extension-permissions-modal.domainHint') }}
        </p>
        {% endblock %}
    </div>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_extension_permissions_modal_categories %}
    <div class="sw-extension-permissions-modal__categories">
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_extension_permissions_modal_category %}
        <div
            v-for="(permission, key) in permissionsWithGroupedOperations"
            :key="key"
            class="sw-extension-permissions-modal__category"
        >
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_extension_permissions_modal_category_inner %}
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_extension_permissions_modal_category_label %}
            <span class="sw-extension-permissions-modal__category-label">
                {{ categoryLabel(key) }}
            </span>
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_extension_permissions_modal_link %}
            <sw-button
                class="sw-extension-permissions-modal__link"
                @click="openDetailsModal(key)"
            >
                {{ $tc('sw-extension-store.component.sw-extension-permissions-modal.textEntities') }}
                <sw-icon
                    name="regular-long-arrow-right"
                    size="12px"
                />
            </sw-button>
            {% endblock %}
            {% endblock %}
        </div>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_extension_permissions_modal_category_domains %}
        <div
            v-if="domainsList.length > 0"
            class="sw-extension-permissions-modal__category"
        >
            <span class="sw-extension-permissions-modal__category-label">
                {{ $tc('sw-extension-store.component.sw-extension-permissions-modal.domains') }}
            </span>

            <sw-button
                class="sw-extension-permissions-modal__link"
                @click="toggleDomainsModal(true)"
            >
                {{ $tc('sw-extension-store.component.sw-extension-permissions-modal.showDomains') }}

                <sw-icon
                    name="regular-long-arrow-right"
                    size="12px"
                />
            </sw-button>
        </div>
        {% endblock %}
    </div>
    {% endblock %}
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_extension_permissions_modal_footer %}
    <template #modal-footer>
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_extension_permissions_modal_footer_inner %}
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_extension_permissions_modal_footer_close %}
        <sw-button
            :variant="actionLabel === null ? 'primary' : ''"
            size="small"
            @click="close"
        >
            {{ closeBtnLabel }}
        </sw-button>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_extension_permissions_modal_footer_action %}
        <sw-button
            v-if="actionLabel"
            variant="primary"
            size="small"
            @click="closeWithAction"
        >
            {{ actionLabel }}
        </sw-button>
        {% endblock %}
        {% endblock %}
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_extension_permissions_modal_details %}
    <sw-extension-permissions-details-modal
        v-if="showDetailsModal"
        :modal-title="modalTitle"
        :permissions="permissionsWithGroupedOperations"
        :selected-entity="selectedEntity"
        @modal-close="closeDetailsModal"
    />
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_extension_permissions_modal_domains %}
    <sw-extension-domains-modal
        v-if="showDomainsModal"
        :extension-label="extensionLabel"
        :domains="domainsList"
        @modal-close="toggleDomainsModal(false)"
    />
    {% endblock %}
</sw-modal>
{% endblock %}
