@php
    $title = get_field('title');
@endphp

@if (have_rows('links'))
    <section class="featured-links">
        @if ($title)
            <div class='row'>
                <div class='col-xs-12'>
                    <h2 class="featured-links__title section-title section-title--big">{!! $title !!}</h2>
                </div>
            </div>
        @endif
        <div class='row'>
            <div class='col-xs-12'>
                <div class="featured-links__items swiper-container">
                    <div class="swiper-wrapper">
                        @while (have_rows('links'))
                            @php
                                the_row();
                                $icon = get_sub_field( 'icon' );
                                $link_title = get_sub_field( 'link_title' );
                                $link_text = get_sub_field( 'link_text' );
                                $link = get_sub_field( 'link' );
                                $wrapperStart = "<div class='featured-links__item swiper-slide'>";
                                $wrapperEnd = "</div>";
                                if ($link) {
                                    $link_target = $link['target'] ? $link['target'] : '_self';
                                    $wrapperStart = "<a href=" . $link['url'] . " target='" . $link_target . "' class='featured-links__item swiper-slide'>";
                                    $wrapperEnd = "</a>";
                                }
                            @endphp
                            {!! $wrapperStart !!}
                                @if ($icon)
                                    <div class="featured-links__item__icon">
                                        @include('elements.image', ['image_id' => $icon])
                                    </div>
                                @endif
                                @if ($link_title)
                                    <h3 class="featured-links__item__title section-title section-title--small">{!! $link_title !!}</h3>
                                @endif
                                @if ($link_text)
                                    <div class="featured-links__item__text image-text__paragraph">{!! $link_text !!}</div>
                                @endif
                                @if ($link)
                                    <p class="featured-links__item__link">{{ __('Learn more', 'aphea') }}</p>
                                @endif
                            {!! $wrapperEnd !!}
                        @endwhile
                    </div>
                </a>
            </div>
        </div>
    </section>
@endif
