{#
/**
 * @file
 * Default implementation for bootstrap basic image gallery.
 *
 * Available variables:
 * - main: main image.
 * - thumbnails: thumbnail images.
 * - lazyload: the class for lazyloading.
 * - modal: array containing variables for rendering the modal
 * - carousel: array containing variables for rendering the carousel
 *
 * @ingroup themeable
 */
#}

<div class="bootstrap-basic-image-gallery">

  <div class="main-image mb-2" data-toggle="modal" data-slide-to="0" data-target="#{{ modal.id }}">{{ main }}</div>

  {% if thumbnails.images|length > 1 %}
    <div class="thumbnails">
      {% for key,image in thumbnails.images %}
        <div class="thumb {{ thumbnails.class }} me-1" style="width:{{ thumbnails.width }}%;" data-toggle="modal" data-slide-to="{{ key }}" data-target="#{{ modal.id }}">
          {{ image }}
        </div>
      {% endfor %}
    </div>
  {% endif %}

  <div class="modal carousel slide {{ lazyload }}" id="{{ modal.id }}" tabindex="-1" role="dialog" aria-labelledby="{{ modal.id }}-title" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-body">
          <div id="{{ carousel.id }}" class="carousel slide {{ lazyload }}" data-interval="{{ carousel.interval }}" data-ride="{{ carousel.autoplay }}">

            <div class="carousel-inner" role="listbox">
              {% for key,carousel_image in carousel.images %}
                <div class="item slide-{{key}} {% if loop.first %}active{% endif %}">
                  {{ carousel_image }}
                  <div class="carousel-caption">{{ attribute(carousel_image, '#caption') }}</div>
                </div>
              {% endfor %}

              {% if thumbnails.images|length > 1 %}
              <a class="left carousel-control" href="#{{ carousel.id }}" role="button" data-slide="prev">
                <span class="icon-prev"></span>
                <span class="sr-only">{% trans %}Previous{% endtrans %}</span>
              </a>
              <a class="right carousel-control" href="#{{ carousel.id }}" role="button" data-slide="next">
                <span class="icon-next"></span>
                <span class="sr-only">{% trans %}Next{% endtrans %}</span>
              </a>
              {% endif %}
            </div>

            {% if thumbnails.images|length > 1 %}
            <ol class="carousel-indicators">
              {% for index in 0..(carousel.images|length -1) %}
                <li data-target="#{{ carousel.id }}" data-slide-to="{{ index }}" class="{% if loop.first %}active{% endif %}"></li>
              {% endfor %}
            </ol>
            {% endif %}

          </div>
        </div>
      </div>
    </div>
  </div>

</div>
