<?if(!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true ) die();?>
<?
$this->setFrameMode(true);
if($arResult['ITEMS']){
	foreach($arResult['ITEMS'] as $i => $arItem){
		if(!is_array($arItem['FIELDS']['PREVIEW_PICTURE'])){
			unset($arResult['ITEMS'][$i]);
		}
	}
}
?>
<?if($arResult['ITEMS']):?>
    <div class="partners-width-heading">
        <?php if($arParams['BLOCK_TITLE']):?>
            <h2 class="title-block underline"><?php echo $arParams['BLOCK_TITLE']?></h2>
        <?php endif?>
        <div class="partners-width-heading__slider slider <?php if(is_callable($arResult['ITEMS']) && count($arResult['ITEMS'] > 5)):?> partners-width-heading__slider--width-button<?php endif?>">
            <div class="partners-width-heading__list swiper-wrapper">
                <?foreach($arResult['ITEMS'] as $i => $arItem):?>
                    <?
                    // edit/add/delete buttons for edit mode
                    $this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem['IBLOCK_ID'], 'ELEMENT_EDIT'));
                    $this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem['IBLOCK_ID'], 'ELEMENT_DELETE'), array('CONFIRM' => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
                    // use detail link?
                    $bDetailLink = $arParams['SHOW_DETAIL_LINK'] != 'N' && (!strlen($arItem['DETAIL_TEXT']) ? ($arParams['HIDE_LINK_WHEN_NO_DETAIL'] !== 'Y' && $arParams['HIDE_LINK_WHEN_NO_DETAIL'] != 1) : true);
                    // preview image
                    $bImage = strlen($arItem['FIELDS']['PREVIEW_PICTURE']['SRC']);
                    $arImage = ($bImage ? CFile::ResizeImageGet($arItem['FIELDS']['PREVIEW_PICTURE']['ID'], array('width' => 166, 'height' => 90), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true) : array());
                    $imageSrc = ($bImage ? $arImage['src'] : SITE_TEMPLATE_PATH.'/images/noimage.png');
                    ?>
                    <li class="partners-width-heading__item slider__item swiper-slide">
                        <a><img loading="lazy"
                                    class="preview_picture"
                                    src="<?=$imageSrc?>"
                                    width="<?= $arItem["PREVIEW_PICTURE"]["WIDTH"] ?>"
                                    height="<?= $arItem["PREVIEW_PICTURE"]["HEIGHT"] ?>"
                                    alt="<?=($bImage ? $arItem['PREVIEW_PICTURE']['ALT'] : $arItem['NAME'])?>"
                            /></a>
                    </li>
                <?endforeach;?>
            </div>
            <div class="slider__button slider__button--prev"><i class="slider__button-icon"></i></div>
            <div class="slider__button slider__button--next"><i  class="slider__button-icon"></i></div>
	    </div>
    </div>
    <script>
        new Swiper('.partners-width-heading__slider', {
            lazy: true,
            slidesPerView: 5,
            spaceBetween: 20,
            navigation: {
                nextEl: ".partners-width-heading__slider .slider__button--next",
                prevEl: ".partners-width-heading__slider .slider__button--prev",
            },
            breakpoints: {
                320: {
                    slidesPerView: 2,
                },
                480: {
                    slidesPerView: 3,
                },
                768: {
                    slidesPerView: 5,
                }
            }
        });
    </script>
<?endif;?>