{block name='snippets-slider-items'}
    {$lazyLoadImages=$lazyLoadImages|default:true}
    {et_getGlobalSettings assign="etGlobalSettings"}
    {et_isShopVersionAtLeast value="5.4.0-rc.1" assign='shopIsAtLeast54'}
    {$infoBoxes=$infoBoxes|default:[]}
    {foreach $items as $item}
        {* Product Slider *}
        {if $type === 'product'}
            {block name='snippets-slider-info-boxes-before'}
                {foreach $infoBoxes as $infoBox}
                    {if $infoBox.targetPosition === $item@index}
                        {include file='widgets/snippets/product_slider_info_box.tpl' infoBox=$infoBox}
                    {/if}
                {/foreach}
            {/block}
            {block name='snippets-slider-items-product'}
                <div class="et-product-slider-product et-slider-slide productbox et-item-slider product-wrapper product-wrapper-product{if $item@first && $item@last} m-auto{elseif $item@first} ml-auto-util {elseif $item@last} mr-auto{/if}" {if $tplscope !== 'box'}{if isset($Link) && $Link->getLinkType() === $smarty.const.LINKTYP_STARTSEITE || $nSeitenTyp === $smarty.const.PAGE_ARTIKELLISTE}itemprop="about"{else}itemprop="isRelatedTo"{/if} itemscope itemtype="https://schema.org/Product"{/if}>
                    {include file='productlist/item_slider.tpl' Artikel=$item tplscope=$tplscope lazyLoadImages=$lazyLoadImages}
                </div>
            {/block}
            {block name='snippets-slider-info-boxes-after'}
                {if $item@last}
                    {foreach $infoBoxes as $infoBox}
                        {if $infoBox.targetPosition < 0 || $infoBox.targetPosition > $item@index}
                            {include file='widgets/snippets/product_slider_info_box.tpl' infoBox=$infoBox}
                        {/if}
                    {/foreach}
                {/if}
            {/block}
        {* News Slider *}
        {elseif $type === 'news'}
            {block name='snippets-slider-items-news'}
                <div class="product-wrapper product-wrapper-news et-slider-slide
                            {if $item@first && $item@last}
                                mx-auto
                            {elseif $item@first}
                                ml-auto-util
                            {elseif $item@last}
                                mr-auto
                            {/if}">
                    {include file='blog/preview.tpl' newsItem=$item lazyLoadImages=$lazyLoadImages}
                </div>
            {/block}
        {* Free Gift Slider *}
        {elseif $type === 'freegift'}
            {$itemIsAvailable = true}
            {$freeGiftProduct = $item}
            {if $shopIsAtLeast54}
                {if $item->getStillMissingAmount() > 0}
                    {$itemIsAvailable = false}
                {/if}
                {if $Einstellungen.sonstiges.sonstiges_gratisgeschenk_noch_nicht_verfuegbar_anzeigen === 'N' && !$itemIsAvailable}
                    {continue}
                {/if}
                {$freeGiftProduct = $item->getProduct()}
            {/if}
            {block name='snippets-slider-items-freegift'}
                {* Setup Default options *}
                {if !isset($hideManufacturers)}
                    {assign var=hideManufacturers value=false}
                {/if}
                <div class="et-product-slider-product et-slider-slide productbox et-item-slider product-wrapper product-wrapper-freegift  {if $item@first && $item@last} m-auto {elseif $item@first} ml-auto-util {elseif $item@last} mr-auto {/if}freegift{if !$itemIsAvailable} not-available-yet{/if}">
                    <div class="custom-control custom-radio">
                        <input class="custom-control-input" type="radio" id="gift{$freeGiftProduct->kArtikel}" name="gratisgeschenk" value="{$freeGiftProduct->kArtikel}" onclick="submit();"{if !$itemIsAvailable} disabled="disabled"{/if}>
                        <label for="gift{$freeGiftProduct->kArtikel}" class="custom-control-label {if $selectedFreegift===$freeGiftProduct->kArtikel}badge-check{/if}">
                            {if $selectedFreegift===$freeGiftProduct->kArtikel}<span class="badge badge-secondary badge-circle"><i class="{et_getIcon key="complete"} mx-auto"></i></span>{/if}
                                {block name='snippets-slider-items-freegift-image'}
                                    <div class="{if empty($etGlobalSettings.freeAspectRatioImagesEnabled)}square square-image{/if}">
                                        <div class="inner">
                                            {image lazy=$lazyLoadImages
                                                webp=true
                                                src=$freeGiftProduct->Bilder[0]->cURLNormal
                                                fluid=true
                                                alt=$freeGiftProduct->cName}
                                        </div>
                                    </div>
                                {/block}
                            <div class="productbox-caption">
                                <p class="small text-muted-util">{lang key='freeGiftFrom1'} {$freeGiftProduct->cBestellwert} {lang key='freeGiftFrom2'}</p>

                                {* Show Manufacturer *}
                                {if $Einstellungen.artikeldetails.artikeldetails_hersteller_anzeigen !== 'N' && isset($freeGiftProduct->cHersteller) && !$hideManufacturers}
                                    {block name='snippets-slider-items-freegift-manufacturer'}
                                        <div class="productbox-manufacturer" itemprop="brand" itemscope itemtype="https://schema.org/Brand">
                                            <meta itemprop="name" content="{$freeGiftProduct->cHersteller|escape:'quotes'}" />
                                            <a href="{if !empty($freeGiftProduct->cHerstellerHomepage)}{$freeGiftProduct->cHerstellerHomepage}{else}{$ShopURL}/{$freeGiftProduct->cHerstellerSeo}{/if}"
                                                class="link-discreet"
                                                {if $Einstellungen.artikeldetails.artikeldetails_hersteller_anzeigen === 'B'}
                                                    data-toggle="tooltip"
                                                    data-placement="left"
                                                    title="{$freeGiftProduct->cHersteller}"
                                                {/if}
                                            itemprop="url"
                                            >
                                                {* Show Manufacturer Image *}
                                                {if ($Einstellungen.artikeldetails.artikeldetails_hersteller_anzeigen === 'B'
                                                    || $Einstellungen.artikeldetails.artikeldetails_hersteller_anzeigen === 'BT')
                                                    && !empty($freeGiftProduct->cHerstellerBildURLKlein)
                                                }
                                                    {block name='snippets-slider-items-freegift-manufacturer-image'}
                                                        {image lazy=$lazyLoadImages
                                                            webp=true
                                                            src=$freeGiftProduct->cHerstellerBildURLKlein
                                                            alt=$freeGiftProduct->cHersteller
                                                        }
                                                        <meta itemprop="logo" content="{$freeGiftProduct->cHerstellerBildURLKlein}">
                                                    {/block}
                                                {/if}

                                                {* Show Manufacturer Name *}
                                                {if $Einstellungen.artikeldetails.artikeldetails_hersteller_anzeigen !== 'B'}
                                                    {block name='snippets-slider-items-freegift-manufacturer-name'}
                                                        <span>{$freeGiftProduct->cHersteller}</span>
                                                    {/block}
                                                {/if}
                                            </a>
                                        </div>
                                    {/block}
                                {/if}

                                {* Show short description and parts-List in case of bundle *}
                                {block name='snippets-slider-items-freegift-caption-short-desc'}
                                    <div class="productbox-title">
                                        <a href="{$freeGiftProduct->cURLFull}{if $shopIsAtLeast54}?isfreegift=1{/if}" class="link-discreet">
                                            <span class="item-slider-desc {block 'snippets-slider-items-freegift-caption-short-desc-text-clamp-class'}text-clamp-2{/block}">
                                                {block name='snippets-slider-items-freegift-caption-short-desc-content'}
                                                    {$freeGiftProduct->cKurzbezeichnung}
                                                {/block}
                                            </span>
                                        </a>
                                    </div>
                                {/block}

                                {* GPSR *}
                                {block name='snippets-slider-items-freegift-caption-gpsr'}
                                    {if !empty($etGlobalSettings.gpsrSource) && $etGlobalSettings.gpsrSource !== 'none'}
                                        {include file="widgets/snippets/gpsr.tpl" etGlobalSettings=$etGlobalSettings gpsrContext='freegift' gpsrProduct=$freeGiftProduct}
                                    {/if}
                                {/block}

                                {block name='snippets-slider-items-freegift-caption-missing-amount-progress-bar'}
                                    {if $shopIsAtLeast54}
                                        {if !$itemIsAvailable}
                                            <div class="progress rounded">
                                                <div class="progress-bar" role="progressbar" aria-label="{et_language key="et360_aria_freegift_progressbar"}"
                                                     style="width: {if $item->availableFrom > 0}{(($item->availableFrom - $item->getStillMissingAmount()) * 100) / $item->availableFrom}{else}100{/if}%;"
                                                     aria-valuenow="{$item->availableFrom - $item->getStillMissingAmount()}"
                                                     aria-valuemin="0"
                                                     aria-valuemax="{$item->availableFrom}">
                                                </div>
                                            </div>
                                            <div class="small text-center">
                                                {lang section='basket' key='freeGiftsStillMissingAmount' printf=JTL\Catalog\Product\Preise::getLocalizedPriceString($item->getStillMissingAmount())}
                                            </div>
                                        {/if}
                                    {/if}
                                {/block}
                            </div>
                        </label>
                    </div>
                </div>
            {/block}
        {/if}
    {foreachelse}
        {if $type === 'product'}
            {block name='snippets-slider-info-boxes-only'}
                {* Render only infoboxes *}
                {foreach $infoBoxes as $infoBox}
                    {include file='widgets/snippets/product_slider_info_box.tpl' infoBox=$infoBox}
                {/foreach}
            {/block}
        {/if}
    {/foreach}
{/block}
