{% import 'blocks\\macros.html.twig' as macros %}
{% set maxVisible = 1 %}
<section {% if settings.is_animated|default %}data-aos="{{ settings.animation_type|default("fade")}}"{% endif %} {% if settings.extra_block_id|default %} id="{{ settings.extra_block_id|default}}" {% endif %} class="block-happen-now {{ settings.extra_class|default }}" style="{{ macros.getStyles(settings) }}" {{ macros.getBlockDataAttributes(_context) }}>
<div class="cover">
<img src="{{ asset('custom/fake.png', 'global') }}" alt="Happen Now Cover" class="cover-image" fetchpriority="high">
</div>
<div class="container">
<div class="row justify-content-space-between">
<div class="col-lg-auto">
<div class="slideshow-happen-now-wrapper">
<h2 class="when">{{fields.title|default('A acontecer')}}</h2>
<div class="slideshow-happen-now">
{% for item in repeatable %}
{% set pageInfo=get_page_info(app.request.locale, item.content) %}
{% set pageInfotitle = pageInfo.title|default %}
{% set pageInfourl = pageInfo.url|default %}
{# {% set pageInfovideo = pageInfo.content.video|default %} #}
{# {% set pageInfovideo_mobile = pageInfo.content.video_mobile|default %} #}
{% set pageInfotext = pageInfo.content.short_text|default %}
{% set pageInfoimage = pageInfo.content.default_image|default %}
{# {% set pageInfoimagemobile = pageInfo.content.default_image_mobile|default %} #}
{% set pageInfocategories = pageInfo.categories|default %}
{# {% set territory = pageInfo.content.territory|default %} #}
<div class="slide-item {% if loop.first %} active {% endif %}" data-image="{% if pageInfo.content.default_image|default %}{{ (pageInfoimage)|imagine_filter('bannerbig')|urldecode }}{% endif %}">
<div class="dot"></div>
<div class="categories">
{% if pageInfocategories %}
{% set total = pageInfocategories|length %}
{% for category in pageInfocategories %}
{% if loop.index <= maxVisible %}
{% if category.title is defined and category.title is not empty and category.content.show_episode_number is not defined %}
{% set categoryLink = category.catpage.machineName|default(category.title) %}
<a href="/pt/pesquisa?themes[]={{ categoryLink|e }}" class="category">{{ category.title }}</a>
{% endif %}
{% endif %}
{% endfor %}
{% if total > maxVisible %}
<button type="button" class="category btn-more js-btn-more-categories">
+ {{ total - maxVisible }}
<div class="category-popover card card-blur">
<div class="arrow">{{ file_get_contents(asset('custom/popover-arrow-icon.svg', 'global'))|raw }}</div>
{% for category in pageInfocategories %}
{% if loop.index > maxVisible %}
{% if category.title is defined and category.title is not empty and category.content.show_episode_number is not defined %}
{% set categoryLink = category.catpage.machineName|default(category.title) %}
<a href="/pt/pesquisa?themes[]={{ categoryLink|e }}" class="category">{{ category.title }}</a>
{% endif %}
{% endif %}
{% endfor %}
</div>
</button>
{% endif %}
{% endif %}
</div>
<a href="{{ pageInfourl }}" class="slide-link">
<h3 class="title line-clamp-4">{{ pageInfotitle|raw }}</h3>
</a>
<div class="text">
<div class="desc line-clamp-3">{{ pageInfotext|raw }}</div>
</div>
<div class="time">
{% set tz = 'Europe/Lisbon' %}
{% set fmt = app.request.locale starts with('en') ? 'MMM d Y, HH:mm' : 'd MMM Y, HH:mm' %}
{{ file_get_contents(asset('custom/time-icon.svg', 'global'))|raw }}
{{ pageInfo.page.publishDate|default(null)|localizeddate('none', 'none', app.request.locale, tz, fmt) }}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
<div class="col-lg-auto ml-auto">
<div class="highlights">
{% for i in 1..3 %}
{% set highlight = attribute(fields, 'highlight' ~ i)|default %}
{% if highlight %}
{% set highlightPageInfo = get_page_info(app.request.locale, highlight) %}
{% set highlightTitle = highlightPageInfo.title|default %}
{% set highlightUrl = highlightPageInfo.url|default %}
{% set highlightImage = highlightPageInfo.content.default_image|default %}
{% if highlightImage is empty %}
{% set highlightImage = '/uploads/system/placeholder-horizontal.png' %}
{% endif %}
<a class="card card-blur w-100 happen-now-card-item" href="{{ highlightUrl }}">
<div class="image-container">
{# <form>
<input type="hidden" name="highlight_id" value="{{ highlight }}">
<button type="submit" class="favorites-button js-favorites-button">
{{ file_get_contents(asset('custom/favorites-icon.svg', 'global'))|raw }}
</button>
</form> #}
<img src="{{ (highlightImage)|imagine_filter('highlight_happennow_image')|urldecode }}" alt="{{ highlightTitle_alt|default }}" title="{{highlightTitle_alt|default}}" class="highlight-image">
</div>
<div class="text-container">
<div class="highlight-link">
<h3 class="highlight-title {% if i == 1 %}line-clamp-4{% endif %}" {% if i != 1 %}title="{{ highlightTitle|length > 80 ? highlightTitle : '' }}"{% endif %}>
{% if i == 1 %}
{{ highlightTitle }}
{% else %}
{{ highlightTitle|length > 80 ? highlightTitle|slice(0, 80) ~ '...' : highlightTitle }}
{% endif %}
</h3>
</div>
<div class="{% if i == 1 %}categories{% else %}categories-list{% endif %}">
{% set exclusiveTag = null %}
{% if highlightPageInfo and highlightPageInfo.page is defined and highlightPageInfo.page.tags is defined and highlightPageInfo.page.tags|length > 0 %}
{% set exclusiveTag = highlightPageInfo.page.tags|filter(t => t.domainValue.type.name == 'Exclusive')|first|default(null) %}
{% endif %}
{% set maxVisibleCategories = exclusiveTag ? maxVisible - 1 : maxVisible %}
{% if exclusiveTag is not null %}
<span data-link="/pt/pesquisa?tags[]={{ exclusiveTag.domainValue.machineName }}" class="category exclusive">
{{ exclusiveTag.domainValue.getLocalizedContents(languagecode).description|default('exclusive_conta_la'|trans({}, 'custom')) }}
</span>
{% endif %}
{% if highlightPageInfo.categories|default %}
{% set total = highlightPageInfo.categories|length %}
{% for category in highlightPageInfo.categories %}
{% if loop.index <= maxVisibleCategories %}
{% if category.title is defined and category.title is not empty and category.content.show_episode_number is not defined %}
{% set categoryLink = category.catpage.machineName|default(category.title) %}
<span class="category" data-link="/pt/pesquisa?themes[]={{ categoryLink|e }}">{{ category.title }}</span>
{% endif %}
{% endif %}
{% endfor %}
{% if total > maxVisibleCategories %}
<button type="button" class="category btn-more js-btn-more-categories">
+ {{ total - maxVisibleCategories }}
<div class="category-popover card card-blur">
<div class="arrow">{{ file_get_contents(asset('custom/popover-arrow-icon.svg', 'global'))|raw }}</div>
{% for category in highlightPageInfo.categories %}
{% if loop.index > maxVisibleCategories %}
{% if category.title is defined and category.title is not empty and category.content.show_episode_number is not defined %}
{% set categoryLink = category.catpage.machineName|default(category.title) %}
<span {% if i == 1 %}data-link{% else %}class="category" data-link{% endif %}="/pt/pesquisa?themes[]={{ categoryLink|e }}"{% if i == 1 %} class="category"{% endif %}>{{ category.title }}</span>
{% endif %}
{% endif %}
{% endfor %}
</div>
</button>
{% endif %}
{% endif %}
</div>
<div class="time">
{% set tz = 'Europe/Lisbon' %}
{% set fmt = app.request.locale starts with('en') ? 'MMM d Y, HH:mm' : 'd MMM Y, HH:mm' %}
{{ file_get_contents(asset('custom/time-icon.svg', 'global'))|raw }}
{{ highlightPageInfo.page.publishDate|default(null)|localizeddate('none', 'none', app.request.locale, tz, fmt) }}
</div>
</div>
</a>
{% endif %}
{% endfor %}
</div>
</div>
</section>