{#
/**
 * @file
 * Theme override for a details element.
 *
 * Available variables
 * - attributes: A list of HTML attributes for the details element.
 * - errors: (optional) Any errors for this details element, may not be set.
 * - title: (optional) The title of the element, may not be set.
 * - summary_attributes: A list of HTML attributes for the summary element.
 * - description: (optional) The description of the element, may not be set.
 * - children: (optional) The children of the element, may not be set.
 * - value: (optional) The value of the element, may not be set.
 *
 * @see template_preprocess_details()
 */
#}
{% set attributes = attributes|default(create_attribute()) %}

<details{{ attributes }}>
  {%- if title -%}
    {% set summary_classes = summary_classes|default([]) %}
    {% if required %}
      {% set summary_classes = summary_classes|merge([
        'js-form-required',
        'form-required',
      ]) %}
    {% endif %}
    <summary{{ summary_attributes.addClass(summary_classes) }}>{{ title }}</summary>
  {%- endif -%}
  <div class="details-wrapper">
    {% if errors %}
      <div class="form-item--error-message">
        <strong>{{ errors }}</strong>
      </div>
    {% endif %}
    {% block details_description %}
      {%- if description -%}
        <div class="details-description">{{ description }}</div>
      {%- endif -%}
    {% endblock details_description %}
    {% block details_children %}
      {%- if children -%}
        {{ children }}
      {%- endif -%}
    {% endblock details_children %}
    {% block details_value %}
      {%- if value -%}
        {{ value }}
      {%- endif -%}
    {% endblock details_value %}
  </div>
</details>
