@props([
    'type' => 'info',
    'message' => null,
    'dismissible' => false,
    'autoDismiss' => false,
])

@php
    $classes = match ($type) {
        'success' => 'alert-success',
        'danger', 'error' => 'alert-danger',
        'warning' => 'alert-warning',
        default => 'alert-info',
    };
@endphp

<div {{ $attributes->merge(['class' => "alert {$classes}" . ($dismissible ? ' alert-dismissible fade show' : ''), 'role' => 'alert']) }}
     @if ($autoDismiss) data-auto-dismiss @endif>
    @if ($message)
        {{ $message }}
    @else
        {{ $slot }}
    @endif

    @if ($dismissible)
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    @endif
</div>
