@namespace Lumeo
@inject Lumeo.Services.Localization.ILumeoLocalizer L

@{
    var isHorizontal = Context.Orientation == Carousel.CarouselOrientation.Horizontal;
    var positionClass = isHorizontal
        ? "-start-12 top-1/2 -translate-y-1/2"
        : "left-1/2 -translate-x-1/2 -top-12";
}

<button class="@($"absolute h-8 w-8 rounded-full border bg-background shadow-sm inline-flex items-center justify-center hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-[1.5px] focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 {positionClass} {Class}".Trim())"
        disabled="@(!Context.CanScrollPrev)"
        aria-label="@L["Carousel.PreviousSlide"]"
        @onclick="() => Context.ScrollPrev.InvokeAsync()"
        @attributes="AdditionalAttributes">
    @if (isHorizontal)
    {
        <Blazicon Svg="Lucide.ChevronLeft" class="h-4 w-4 [dir=rtl]:rotate-180" />
    }
    else
    {
        <Blazicon Svg="Lucide.ChevronUp" class="h-4 w-4" />
    }
    <span class="sr-only">@L["Carousel.PreviousSlide"]</span>
</button>

@code {
    [CascadingParameter] public Carousel.CarouselContext Context { get; set; } = default!;
    [Parameter] public string? Class { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }
}
