{#
/**
 * @file
 * Vartheme BS5 Starter Kit implementation for the Impressed Card component.
 *
 * Available properties:
 * - style_size: Card style size. (xsmall|small|medium|large|xlarge).
 * - card_border: Add a default padding to the card. (true|false).
 * - padded: Add a default padding to the card. (true|false).
 * - equal_height: Equal height. (true|false).
 * - anchor_all: Anchor All (true|false).
 * - media_position: Choose the location of the media from (top|bottom).
 * - card_impressed_utility_classes: Use to add extra Bootstrap utility classes for the main Card wrapper.
 *                    E.g. `mb-3 shadow-lg` ( Do not add `card`).
 * - card_impressed_media_utility_classes: Use to add extra Bootstrap utility classes for the Card Media region wrapper.
 *                          E.g. `bg-secondary mb-3` ( Do not add `card-img`).
 * - card_impressed_content_utility_classes: Use to add extra Bootstrap utility classes for the Card Content region wrapper.
 *                            E.g. `w-75 mb-3 overflow-y-hidden`  ( Do not add `card-body`).
 *
 * Available attributes:
 * - card_attributes: HTML attributes for the card element.
 * - media_attributes: HTML attributes for the media element.
 * - content_attributes: HTML attributes for the content element.
 *
 * Available slots:
 * - media: The media image/video slot for the card.
 * - content: The content slot for the card.
 */
#}

{% set style_size = style_size ? [style_size]: [] %}
{% set card_border = card_border ? ['bordered'] : ['border-0'] %}
{% set padded = padded ? ['p-4'] : [''] %}
{% set equal_height = equal_height ? ['h-100'] : [] %}
{% set anchor_all = anchor_all ? ['anchor-all'] : [] %}
{% set media_position = media_position ?? 'top' %}
{% set media_position_classes = media_position == 'bottom' ? ['flex-column-reverse'] : [] %}
{% set card_impressed_utility_classes = card_impressed_utility_classes ? card_impressed_utility_classes : [] %}
{% set card_impressed_media_utility_classes = card_impressed_media_utility_classes ? card_impressed_media_utility_classes : [] %}
{% set card_impressed_content_utility_classes = card_impressed_content_utility_classes ? card_impressed_content_utility_classes : [] %}

{%
  set card_classes = [
    'card',
    'varbase-impressed-card',
  ]|merge(style_size)|merge(card_border)|merge(padded)|merge(equal_height)|merge(anchor_all)|merge(media_position_classes)|merge(card_impressed_utility_classes)
%}

{%
  set media_classes = [
    'card-img',
    'card-img-' ~ media_position,
  ]|merge(card_impressed_media_utility_classes)
%}

{%
  set content_classes = [
    'impressed-card-content',
    'card-body'
  ]|merge(card_impressed_content_utility_classes)
%}

{% if not card_attributes %}
  {% set card_attributes = create_attribute() %}
{% endif %}

{% if not content_attributes %}
  {% set content_attributes = create_attribute() %}
{% endif %}

{% if not media_attributes %}
  {% set media_attributes = create_attribute() %}
{% endif %}

{% set card_attributes = card_attributes.addClass(card_classes) %}
{% set content_attributes = content_attributes.addClass(content_classes) %}
{% set media_attributes = media_attributes.addClass(media_classes) %}

<div{{ card_attributes }}>
  {% if media is not empty %}
    {% if media_classes|length > 0 %}<div{{ media_attributes }}>{% endif %}
    {{ media }}
    {% if media_classes|length > 0 %}</div>{% endif %}
  {% endif %}
  <div{{ content_attributes }}>
    {{ content }}
  </div>
</div>
