@php
	$data =[];
	if(isset($payload)){
        $item = (object) [];
        foreach ($payload as $key => $value) {
            if (preg_match('/^image\d+$/', $key)) {
                $item = (object) [
                    'title' => $payload->title->value ?? null,
                    'subtitle' => $payload->subtitle->value ?? null,
                    'imgLogo' => $payload->imageLogo->src ?? null,
                    'altLogo' => $payload->imageLogo->alt ?? null,
                    'description' => $payload->description->value ?? null,
                    'interval' => $payload->interval->value ?? null,
                    'image' => $value, // Atribui a imagem ao objeto
                ];
                $data[] = $item;
            }
        }
	}
    $first = true;
    
@endphp

<!-- Header Area -->
<header class="header bg-img-contact" id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel">
    <div class="carousel-inner banner-size"style="">
        @foreach ($data as $item)
            <div class="carousel-item {{$first === true ? 'active' : ''}}" data-bs-interval="10000">
                <div class="container container-header">
                    <div class="header-wrap">
                        <div class="header-text d-flex flex-column align-items-start">
                            @if (isset($item->title))
                                <span>{{ $item->title }}</span>
                            @endif
                            @if (isset($item->subtitle))
                                <h1>{{ $item->subtitle }}</h1>
                            @endif
                            @if (isset($item->imgLogo))
                                <img class="img-height" src="{{asset ($item->imgLogo)}}"
                                    alt="{{ $item->altLogo}}" />
                            @endif
                            @if (isset($item->description))
                                <p>{{ $item->description }}</p>
                            @endif
                        </div>
                    </div>
                </div>
                <img src="{{asset( $item->image->src) }}" class="d-block w-100" alt="{{asset($item->image->alt )}}">
            </div>
        @php $first = false;  @endphp
        @endforeach
    </div>
    <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="visually-hidden">Previous</span>
    </button>
    <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="visually-hidden">Next</span>
    </button>
</header>
<!-- End Header Area -->
