namespace HellionChat.Ui;

internal static class HellionStyleHelpers
{
    // Child surfaces are drawn over WindowBg, so at partial window opacity
    // the theme's own ChildBg alpha would double-multiply and read too solid.
    // Above ~full opacity we preserve the theme alpha; below it we wipe to 0
    // so WindowBg alone carries the coverage. The 0.999f threshold is a
    // float-imprecision guard around the user-facing 100% slider value.
    // TEST-MIRROR: ../../Hellion Build test/_Helpers/HellionStyleHelpersTests.cs
    public static uint ResolveChildBgAlpha(uint themeChildBgRgba, float windowOpacity)
    {
        var alphaPreserved = windowOpacity >= 0.999f;
        var childBgAlpha = alphaPreserved ? (themeChildBgRgba & 0xFFu) : 0u;
        return (themeChildBgRgba & 0xFFFFFF00u) | childBgAlpha;
    }
}
