{#
/**
 * @file
 * Default theme implementation for a captcha.
 *
 * Available variables:
 * - is_visible: Boolean to indicate if the CAPTCHA is visible or was
 *   already solved (but element still needed for hidden inputs).
 * - attributes: HTML attributes for the containing element.
 * - title: The captcha title
 * - description: The captcha description
 * - element: The captcha element itself (image, recaptcha, ...)
 *
 * @see template_preprocess_captcha()
 *
 * @ingroup themeable
 */
#}

{%
set classes = [
	'captcha',
	('captcha-type-challenge--' ~ element['#captcha_type_challenge'])|clean_class,
]
%}

{% block captcha %}
  {% if is_visible %}
    {% block captcha_display %}
      {% if title is not empty %}
        <fieldset {{ attributes.addClass(classes) }}>
          <legend class="captcha__title js-form-required form-required">
            {{ title }}
          </legend>
        {% else %}
          <div {{ attributes.addClass(classes) }}>
        {% endif %}
          <div class="captcha__element">
            {{ element }}
          </div>
          {% if description is not empty %}
            <div class="captcha__description description">{{ description }}</div>
          {% endif %}
      {% if title is not empty %}
          </fieldset>
      {% else %}
        </div>
      {% endif %}
    {% endblock %}
  {% else %}
    {# Required for _captcha_required_for_user() to preserve the hidden fields
    				in the form even though the CAPTCHA is not visible. 	#}
    {{ element }}
  {% endif %}
{% endblock %}
