{#
/**
 * @file
 * Theme override for a fieldset element and its children.
 *
 * Available variables:
 * - attributes: HTML attributes for the fieldset element.
 * - errors: (optional) Any errors for this fieldset element, may not be set.
 * - required: Boolean indicating whether the fieldeset element is required.
 * - legend: The legend element containing the following properties:
 *   - title: Title of the fieldset, intended for use as the text of the legend.
 *   - attributes: HTML attributes to apply to the legend.
 * - description: The description element containing the following properties:
 *   - content: The description content of the fieldset.
 *   - attributes: HTML attributes to apply to the description container.
 * - children: The rendered child elements of the fieldset.
 * - prefix: The content to add before the fieldset children.
 * - suffix: The content to add after the fieldset children.
 *
 * @see template_preprocess_fieldset()
 */
#}
{% set error_attributes = create_attribute() %}
{%
  set classes = [
    'fieldset',
    'js-form-item',
    'form-item',
    'js-form-wrapper',
    'form-wrapper',
  ]|merge(utility_classes ? utility_classes : [])
%}
<fieldset{{ attributes.addClass(classes) }}>
  {%
    set legend_classes = [
      'fieldset__legend',
      required ? 'js-form-required',
      required ? 'form-required',
    ]|merge(legend_classes ? legend_classes : [])
  %}

  {% if title_display != 'none' %}
    <legend{{ legend.attributes.addClass(legend_classes) }}>
      {{ legend.title }}
    </legend>
  {% endif %}

  <div {{ wrapper_attributes.addClass(['fieldset__wrapper']|merge(wrapper_classes ? wrapper_classes : []))}}>
    {% if description_display == 'before' and description.content %}
      <small{{ description.attributes.addClass('description', 'form-text', 'text-muted') }}>{{ description.content }}</small>
    {% endif %}
    {% if errors %}
      <div {{ error_attributes.addClass(['webform__errors']|merge(error_classes ? error_classes : []))}}>
        <span aria-hidden="true" class="material-symbols-sharp">error</span>
        {{ errors }}
      </div>
    {% endif %}
    {% if prefix %}
      <span class="fieldset__prefix">{{ prefix }}</span>
    {% endif %}
    {{ children }}
    {% if suffix %}
      <span class="fieldset__suffix">{{ suffix }}</span>
    {% endif %}
    {% if description_display in ['after', 'invisible'] and description.content %}
      <small{{ description.attributes.addClass('description', 'form-text', 'text-muted') }}>{{ description.content }}</small>
    {% endif %}
  </div>
</fieldset>
{% if libraries %}
  {% for library in libraries %}
    {{ attach_library(library) }}
  {% endfor %}
{% endif %}