@if(!empty($advertisements))
    @php
        $count = $advertisements->where('position', 2)->count();
    @endphp
    <div class="container py-2">
        <div class="row">
            @foreach ($advertisements->where('position', 2) as $advertisement)
                <div class="{{ $count == 1 ? 'col-12 col-sm-12 col-md-12' : ($count == 2 ? 'col-12 col-sm-12 col-md-6' : 'col-12 col-sm-12 col-md-4') }} bg-white rounded-2 py-2">
                    @if ($advertisement->type == 1)
                        <a href="{{ $advertisement->url }}" target="_blank"><img src="{{ $advertisement->image }}" alt="Advertisement Image"></a>
                    @elseif ($advertisement->type == 2)
                        <iframe width="100%" height="100%"  src="https://www.youtube.com/embed/{{ $advertisement->video }}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
                    @else
                        {!! $advertisement->content !!}
                    @endif
                </div>
            @endforeach
        </div>
    </div>
@endif