{% block _config_userconfig_widget %}
{% set fields = form.children %}
{% set fieldKeys = fields|keys %}

{% if fieldKeys|filter(v => v in ['saml_idp_metadata', 'saml_idp_own_certificate', 'saml_idp_own_private_key', 'saml_idp_own_password'])|length > 0 %}
    <h4 class="fw-sb mt-48 mb-xs">{{ 'mautic.user.config.header.saml'|trans }}</h4>
    <div class="text-muted small pb-md">{{ 'mautic.core.config.header.saml.description'|trans }}</div>
    <div class="row">
        <div class="panel panel-default mb-md">
            <div class="panel-body">
                <div class="row">
                    {% if fields.saml_idp_entity_id is defined %}
                        <div class="col-xs-12">
                            {{ form_row(fields.saml_idp_entity_id) }}
                        </div>
                    {% endif %}
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_metadata, {'fieldValue': formConfig.parameters.saml_idp_metadata}) }}
                    </div>
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_default_role) }}
                    </div>
                </div>

                <hr />
                <div class="alert alert-info">{{ 'mautic.user.config.form.saml.idp_attributes'|trans }}</div>

                <div class="row">
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_email_attribute) }}
                    </div>
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_username_attribute) }}
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_firstname_attribute) }}
                    </div>
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_lastname_attribute) }}
                    </div>
                </div>

                <hr />
                <div class="alert alert-info">{{ 'mautic.user.config.form.saml.idp.own_certificate.description'|trans }}</div>

                <div class="row">
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_own_certificate, {'fieldValue': formConfig.parameters.saml_idp_own_certificate}) }}
                    </div>
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_own_private_key, {'fieldValue': formConfig.parameters.saml_idp_own_private_key}) }}
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        {{ form_row(fields.saml_idp_own_password) }}
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endif %}
{% endblock %}
