@namespace Lumeo

<div class="@CssClass" style="@StyleValue" @attributes="AdditionalAttributes">
    @ChildContent
</div>

@code {
    [Parameter] public RenderFragment? ChildContent { get; set; }
    [Parameter] public bool Top { get; set; } = true;
    [Parameter] public bool Bottom { get; set; } = true;
    [Parameter] public bool Left { get; set; } = false;
    [Parameter] public bool Right { get; set; } = false;
    [Parameter] public string? Class { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

    private string CssClass => $"lumeo-safe-area {Class}".Trim();

    private string StyleValue
    {
        get
        {
            var parts = new List<string>();
            if (Top)    parts.Add("padding-top: env(safe-area-inset-top, 0)");
            if (Bottom) parts.Add("padding-bottom: env(safe-area-inset-bottom, 0)");
            if (Left)   parts.Add("padding-left: env(safe-area-inset-left, 0)");
            if (Right)  parts.Add("padding-right: env(safe-area-inset-right, 0)");
            return string.Join("; ", parts);
        }
    }
}
