@php
    $section = $section ?? [];
    $section = is_array($section) ? $section : [];

    $view = is_string($section['view'] ?? null) && trim($section['view']) !== '' ? trim($section['view']) : null;
    $entries = is_array($section['entries'] ?? null) ? $section['entries'] : [];
    $emptyState = is_array($section['emptyState'] ?? null) ? $section['emptyState'] : null;
@endphp

<x-filament::section
    :heading="$section['title'] ?? 'Technical detail'"
    :description="$section['description'] ?? 'Technical metadata stays available here without taking over the main reading path.'"
    :collapsible="(bool) ($section['collapsible'] ?? true)"
    :collapsed="(bool) ($section['collapsed'] ?? true)"
>
    @if ($entries !== [])
        @include('filament.infolists.entries.enterprise-detail.section-items', [
            'items' => $entries,
            'variant' => is_string($section['variant'] ?? null) ? $section['variant'] : 'technical',
        ])
    @endif

    @if ($view !== null)
        <div @class(['mt-4' => $entries !== []])>
            {!! view($view, is_array($section['viewData'] ?? null) ? $section['viewData'] : [])->render() !!}
        </div>
    @elseif ($emptyState !== null)
        <div @class(['mt-4' => $entries !== []])>
            @include('filament.infolists.entries.enterprise-detail.empty-state', ['state' => $emptyState])
        </div>
    @endif
</x-filament::section>
