{% 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 %}
  <div class="panel panel-primary">
      <div class="panel-heading">
          <h3 class="panel-title">{{ 'mautic.user.config.header.saml'|trans }}</h3>
      </div>
      <div class="panel-body">
          <div class="row">
            {% if fields.saml_idp_entity_id is defined %}
              <div class="col-md-6">
                  {{ form_row(fields.saml_idp_entity_id) }}
              </div>
            {% endif %}
              <div class="col-md-6">
                  {{ form_row(fields.saml_idp_metadata, {'fieldValue': formConfig.parameters.saml_idp_metadata}) }}
              </div>
              <div class="col-md-6">
                  {{ 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-md-6">
                  {{ form_row(fields.saml_idp_email_attribute) }}
              </div>
              <div class="col-md-6">
                  {{ form_row(fields.saml_idp_username_attribute) }}
              </div>
          </div>
          <div class="row">
              <div class="col-md-6">
                  {{ form_row(fields.saml_idp_firstname_attribute) }}
              </div>
              <div class="col-md-6">
                  {{ 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-md-6">
                  {{ form_row(fields.saml_idp_own_certificate, {'fieldValue': formConfig.parameters.saml_idp_own_certificate}) }}
              </div>
              <div class="col-md-6">
                  {{ form_row(fields.saml_idp_own_private_key, {'fieldValue': formConfig.parameters.saml_idp_own_private_key}) }}
              </div>
          </div>
          <div class="row">
              <div class="col-md-6">
                  {{ form_row(fields.saml_idp_own_password) }}
              </div>
          </div>
      </div>
  </div>
{% endif %}
{% endblock %}
