{% block proc_cms_card %}
{% set config = element.translated.config %}
<div class="proc-cms-card-element {{ config.cardStyle.value }}" id="card_{{ element.id }}">
{% set displayMode = config.displayMode.value %}
{% if config.displayImage.value != "standard" %}
{% set imageDisplayMode %}
style="object-fit: {{ config.displayImage.value }};width:100%;{% if config.minHeight.value and config.displayImage.value == "cover" %}min-height: {{ element.translated.config.minHeight.value }};{% endif %}"
{% endset %}
{% endif %}
<div class="proc-cms-card-element-inner card--{{ displayMode }}
{% if config.positionImage.value == false %} card--horizontal-right{% endif %}"
{% if config.textButtonPosition.value === 'standard' and config.backgroundContainer.value != '' %} style='background-color: {{ config.backgroundContainer.value }}'{% endif %}
>
{# simplify ID access #}
{% set cardImage = config.media.value %}
{% if(cardImage) %}
{# fetch media as batch - optimized for performance #}
{% set cardImageCollection = searchMedia([cardImage], context.context) %}
{# extract single media object #}
{% set imageItem = cardImageCollection.get(cardImage) %}
{% endif %}
{% if imageItem %}
<div class="proc-cms-card-element-image text-center
cms-image-container is-{{ config.displayImage.value }}"
{% if config.minHeight.value and config.displayImage.value == "cover" %}
style="min-height: {{ element.translated.config.minHeight.value }};"
{% endif %}
{% if config.textButtonPosition.value === 'standard' and config.backgroundContainer.value != '' %} style='background-color: {{ config.backgroundContainer.value }}'{% endif %}
>
{% if config.url.value %}
<a href="{{ config.url.value }}"
class="cms-image-link"
{% if config.newTab.value %}target="_blank" rel="noopener"{% endif %}>
<img class="mx-auto" src="{{ imageItem.url }}" title="{{ imageItem.translated.title }}"
alt="{{ imageItem.translated.alt }}"
{{ imageDisplayMode }}
>
</a>
{% else %}
<img class="mx-auto" src="{{ imageItem.url }}" title="{{ imageItem.translated.title }}"
alt="{{ imageItem.translated.alt }}"
{{ imageDisplayMode }}
>
{% endif %}
</div>
{% endif %}
<div class="proc-cms-card-element-content{% if config.textButtonPosition.value != 'standard' %} proc-cms-card-element-content-row {{ config.textButtonPosition.value }}{% endif %}
{% if config.backgroundContainer.value != '' %} p-4" style='background-color: {{ config.backgroundContainer.value }}'{% else %}"{% endif %}>
<div class="proc-cms-card-element-content-text{% if config.url.value != '' and config.buttonText.value != '' and config.textButtonPosition.value === 'standard' %} mb-4{% endif %}
{% if config.textButtonPosition.value != 'standard' %} proc-cms-card-element-content-row {{ config.textButtonPosition.value }}{% endif %}"
{% if config.textButtonPosition.value === 'cmsCardTextRight' %}style="order: 2;"{% endif %}
>
{{ config.text.value|raw }}
</div>
{% if config.url.value != '' and config.buttonText.value != '' %}
{% block sw_cms_element_proc_cms_card_button %}
{% if config.buttonType.value != "" %}
<div class="cms-element-card-button{% if config.buttonPosition.value %} d-flex {{ config.buttonPosition.value }}{% endif %}
{% if config.textButtonPosition.value != 'standard' and config.buttonAlignment.value != '' %} {{ config.buttonAlignment.value }}{% endif %}"
>
{% endif %}
<a href="{{ config.url.value }}" target="{% if config.linkTarget.value == '' %}_self{% else %}{{ config.linkTarget.value }}{% endif %}"
class="{% if config.buttonType.value %}btn {{ config.buttonType.value }}{% endif %}">
{{ config.buttonText.value|raw }}
</a>
{% if config.buttonType.value != "" %}</div>{% endif %}
{% endblock %}
{% endif %}
</div>
</div>
</div>
{% endblock %}