{% set isRTL = app.request.get('_locale') == 'ar' %}
{% set primaryActiveClass = hasPrimaryUnits ? 'active': '' %}
{% set allowActiveResale = not hasPrimaryUnits and hasResaleUnits %}
{% set resaleActiveClass = allowActiveResale ? 'active': '' %}
{% set allowActiveRent = not hasPrimaryUnits and not allowActiveResale and hasRentUnits %}
{% set rentActiveClass = allowActiveRent ? 'active': '' %}
{% set resaleEvent = [{'isFired':true , 'trigger': 'gtm-btn-resale-tab-click' }] %}
{% set primaryEvent = [{'isFired':true , 'trigger': 'gtm-btn-primary-tab-click' }] %}
{% set rentEvent = [{'isFired':true , 'trigger': 'gtm-btn-rent-tab-click' }] %}
{% set tableHeight = 188 %}
{% set unitsLimit = 5 %}
{% set listingSlug = listing.slug %}
{% if not isPrimaryUnitsOnly %}
<ul class="nav nav-justified units-tabs" id="pills-tab" role="tablist">
<li class="nav-item units-tabs__item">
<span class="{{primaryActiveClass}} units-tabs__link large-element-tab mb-0" id="pills-primary-tab" data-toggle="pill" href="#pills-primary" role="tab" aria-controls="pills-primary" aria-selected="true"
onclick="elementEvents.fireGTM('', '', {{ primaryEvent|json_encode() }})">
{{'compound_units.primary'|trans}}
</span>
</li>
{% if hasResaleUnits %}
<li class="nav-item units-tabs__item">
<span class="{{resaleActiveClass}} units-tabs__link large-element-tab mb-0" id="pills-resale-tab" data-toggle="pill" href="#pills-resale" role="tab" aria-controls="pills-resale" aria-selected="false"
onclick="elementEvents.fireGTM('', '', {{ resaleEvent|json_encode() }})">
{{'compound_units.resale'|trans}}
</span>
</li>
{% endif %}
{% if hasRentUnits %}
<li class="nav-item units-tabs__item">
<span class="{{rentActiveClass}} units-tabs__link large-element-tab mb-0" id="pills-rent-tab" data-toggle="pill" href="#pills-rent" role="tab" aria-controls="pills-rent" aria-selected="false"
onclick="elementEvents.fireGTM('', '', {{ rentEvent|json_encode() }})">
{{'compound_units.rent'|trans}}
</span>
</li>
{% endif %}
</ul>
{% endif %}
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane {{primaryActiveClass}}" id="pills-primary" role="tabpanel" aria-labelledby="pills-primary-tab">
{% if isPrimarySoldOutCta %}
{% include "@AqarmapListing/Listing/soldOutCta.html.twig" %}
{% else %}
<div class="properties-container">
{% for properties in liveUnitsPaginated %}
{% set units = properties.propertyTypeChildren %}
{% set isShowMoreEnabled = units|length > unitsLimit %}
{% set largeElementParent = isShowMoreEnabled ? 'large-element-parent' : ''%}
{% set largeElement = isShowMoreEnabled ? 'large-element' : ''%}
<div class="units-container {{largeElementParent}}">
<div class="units-list-container mb-0">
<p class="units-container__title">{{ properties.title }}</p>
<div class="units-list {{largeElement}}" data-height="{{tableHeight}}">
{% for unit in units %}
{% set unitUrl = listingSlug ? path('listing_slug', {'id': unit.id, 'slug':listingSlug}) : path('listing_view', {'id': unit.id}) %}
<a class=' units-list__item unit' href='{{ unitUrl }}' target="_blank">
<p class="unit__area border-0 px-0">{{ unit.area }} {{ get_setting('general', 'measurement_unit')|trans }}</p>
<p class="d-flex justify-content-end align-items-center">
<span class="unit__price">
{{ unit.price|number_format }} {{ get_setting('general', 'currency')|trans }}
</span>
{% if isRTL %}
<i class="fa fa-chevron-left unit__redirect-arrow"></i>
{% else %}
<i class="fa fa-chevron-right unit__redirect-arrow"></i>
{% endif %}
</p>
</a>
{% endfor %}
</div>
</div>
{% if isShowMoreEnabled %}
<a href="javascript:void(0)" class="see-more see-more-paragraph-button"
data-seeMore="
{{ 'listing.show_more'|trans }}
<i class='fa fa-chevron-down see-more__arrow'></i>"
data-seeLess="{{ 'listing.show_less'|trans }}
<i class='fa fa-chevron-up see-more__arrow'></i>">
</a>
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
</div>
{% if hasResaleUnits %}
<div class="tab-pane {{resaleActiveClass}}" id="pills-resale" role="tabpanel" aria-labelledby="pills-resale-tab">
<div class="properties-container">
{% for properties in resaleUnitsPaginated %}
{% set units = properties.propertyTypeChildren %}
{% set isShowMoreEnabled = units|length > unitsLimit %}
{% set largeElementParent = isShowMoreEnabled ? 'large-element-parent' : ''%}
{% set largeElement = isShowMoreEnabled ? 'large-element' : ''%}
<div class="units-container {{largeElementParent}}">
<div class="units-list-container mb-0">
<p class="units-container__title">{{ properties.title }}</p>
<div class="units-list {{largeElement}}" data-height="{{tableHeight}}">
{% for unit in units %}
{% set unitUrl = listingSlug ? path('listing_slug', {'id': unit.id, 'slug':listingSlug}) : path('listing_view', {'id': unit.id}) %}
<a class='units-list__item unit' href='{{ unitUrl }}' target="_blank">
<p class="unit__area border-0 px-0">{{ unit.area }} {{ get_setting('general', 'measurement_unit')|trans }}</p>
<p class="d-flex justify-content-end align-items-center">
<span class="unit__price">
{{ unit.price|number_format }} {{ get_setting('general', 'currency')|trans }}
</span>
{% if isRTL %}
<i class="fa fa-chevron-left unit__redirect-arrow"></i>
{% else %}
<i class="fa fa-chevron-right unit__redirect-arrow"></i>
{% endif %}
</p>
</a>
{% endfor %}
</div>
</div>
{% if isShowMoreEnabled %}
<a href="javascript:void(0)" class="see-more see-more-paragraph-button"
data-seeMore="
{{ 'listing.show_more'|trans }}
<i class='fa fa-chevron-down see-more__arrow'></i>"
data-seeLess="{{ 'listing.show_less'|trans }}
<i class='fa fa-chevron-up see-more__arrow'></i>">
</a>
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% if hasRentUnits %}
<div class="tab-pane {{rentActiveClass}} " id="pills-rent" role="tabpanel" aria-labelledby="pills-rent-tab">
<div class="properties-container">
{% for properties in rentUnitsPaginated %}
{% set units = properties.propertyTypeChildren %}
{% set isShowMoreEnabled = units|length > unitsLimit %}
{% set largeElementParent = isShowMoreEnabled ? 'large-element-parent' : ''%}
{% set largeElement = isShowMoreEnabled ? 'large-element' : ''%}
<div class="units-container {{largeElementParent}}">
<div class="units-list-container mb-0">
<p class="units-container__title">{{ properties.title }}</p>
<div class="units-list {{largeElement}}" data-height="{{tableHeight}}">
{% for unit in units %}
{% set unitUrl = listingSlug ? path('listing_slug', {'id': unit.id, 'slug':listingSlug}) : path('listing_view', {'id': unit.id})%}
<a class='units-list__item unit' href='{{ unitUrl }}' target="_blank">
<p class="unit__area border-0 px-0">{{ unit.area }} {{ get_setting('general', 'measurement_unit')|trans }}</p>
<p class="d-flex justify-content-end align-items-center">
<span class="unit__price">
{{ unit.price != 0 ? unit.price|number_format ~ ' ' ~ get_setting('general', 'currency')|trans : 'listing.call_for_price'|trans }}
</span>
{% if isRTL %}
<i class="fa fa-chevron-left unit__redirect-arrow"></i>
{% else %}
<i class="fa fa-chevron-right unit__redirect-arrow"></i>
{% endif %}
</p>
</a>
{% endfor %}
</div>
</div>
{% if isShowMoreEnabled %}
<a href="javascript:void(0)" class="see-more see-more-paragraph-button"
data-seeMore="
{{ 'listing.show_more'|trans }}
<i class='fa fa-chevron-down see-more__arrow'></i>"
data-seeLess="{{ 'listing.show_less'|trans }}
<i class='fa fa-chevron-up see-more__arrow'></i>">
</a>
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>