{% if affiliation_offers.offers is not empty or affiliation_offers.best_amazon_offer is not empty or affiliation_offers.best_ebay_offer is not empty  %}
<section id="prices" class="relative">
    {% set offers_count = affiliation_offers.offers|length %}
    {% set partners_count = affiliation_offers.partners_offers|length %}
    {% set default_tab = 'offers' %}


    <div class="tabs" x-data="{ activeTab: '{{ default_tab }}' }">
        <div class="mt-6 flex flex-wrap gap-2 border-b border-gray-200" role="tablist">
            <button
                type="button"
                class="whitespace-nowrap px-4 py-2 text-sm font-semibold border-b-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary"
                role="tab"
                :aria-selected="activeTab === 'offers'"
                :tabindex="activeTab === 'offers' ? 0 : -1"
                @click="activeTab = 'offers'"
                :class="activeTab === 'offers' ? 'text-primary border-primary' : 'text-gray-500 border-transparent hover:text-gray-700'"
            >
                Prezzi del Nuovo 
                {% if offers_count > 0 %}
                    <span class="ml-1 text-xs font-normal text-gray-400">({{ offers_count }})</span>
                {% endif %}
            </button>

            {% if partners_count > 0 %}
            <button
                type="button"
                class="whitespace-nowrap px-4 py-2 text-sm font-semibold border-b-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary"
                role="tab"
                :aria-selected="activeTab === 'partners'"
                :tabindex="activeTab === 'partners' ? 0 : -1"
                @click="activeTab = 'partners'"
                :class="activeTab === 'partners' ? 'text-primary border-primary' : 'text-gray-500 border-transparent hover:text-gray-700'"
            >
                Premium Partners 
                {% if partners_count > 0 %}
                <span class="ml-1 text-xs font-normal text-gray-400">({{ partners_count }})</span>
                {% endif %}
            </button>
            {% endif %}
        </div>
        

        <div
            class="tab-content"
            x-cloak
            x-show="activeTab === 'offers'"
            x-transition.opacity.duration.200ms
            role="tabpanel"
        >

        <div class="text-sm text-gray-500 p-4">Gli acquisti da link affiliati generano commissioni per HDB. I prezzi possono variare post pubblicazione.</div>

            <div class="grid grid-cols-1 gap-4 my-6">
                {% if affiliation_offers.best_amazon_offer is not empty %}
                    {% set item = affiliation_offers.best_amazon_offer %}
                    {% include "templates/components/cards/card-affiliation.twig" with {class: 'is_premium'} %}
                {% endif %}

                {% if affiliation_offers.best_ebay_offer is not empty %}
                    {% set item = affiliation_offers.best_ebay_offer %}
                    {% include "templates/components/cards/card-affiliation.twig" with {class: 'is_premium'} %}
                {% endif %}

                {% for item in affiliation_offers.offers %}
                {% if item.type == 'domination' %}
                {% include "templates/components/cards/card-domination-prices.twig" %}
                {% else %}
                    {% include "templates/components/cards/card-affiliation.twig" %}
                {% endif %}
                {% endfor %}
            </div>
        </div>

        {% if partners_count > 0 %}
        <div
            class="tab-content"
            x-cloak
            x-show="activeTab === 'partners'"
            x-transition.opacity.duration.200ms
            role="tabpanel"
        >
        <div class="text-sm text-gray-500 p-4">Gli acquisti da link affiliati generano commissioni per HDB. I prezzi possono variare post pubblicazione.</div>
        <div class="text-sm text-gray-500 p-4 m-0">I seguenti partner sono selezionati da HDblog sulla base della loro affidabilità nel tempo. I prezzi sono esposti in trasparenza ma potrebbero essere aggiornati sul sito del partner. Se vuoi essere inserito tra i Premium Partner di HDblog scrivi a <a class="font-semibold hover:underline" href="mailto:performance@blazemedia.it">performance@blazemedia.it</a></div>
            <div class="grid grid-cols-1 gap-4 my-6">
                {% for item in affiliation_offers.partners_offers %}
                    {% include "templates/components/cards/card-affiliation.twig" %}
                {% endfor %}
            </div>
        </div>
        {% endif %}
    </div>
</section>
{% endif %}