local ____exports = {}
local OBJECT_NAME
local ____SerializationBrand = require("enums.private.SerializationBrand")
local SerializationBrand = ____SerializationBrand.SerializationBrand
local ____isaacAPIClass = require("functions.isaacAPIClass")
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
local ____random = require("functions.random")
local getRandom = ____random.getRandom
local ____rng = require("functions.rng")
local isRNG = ____rng.isRNG
local newRNG = ____rng.newRNG
local ____table = require("functions.table")
local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
local getNumbersFromTable = ____table.getNumbersFromTable
local tableHasKeys = ____table.tableHasKeys
local ____types = require("functions.types")
local isTable = ____types.isTable
local ____utils = require("functions.utils")
local assertDefined = ____utils.assertDefined
--- Helper function to check if something is an instantiated `Color` object.
function ____exports.isColor(self, object)
    return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
end
OBJECT_NAME = "Color"
local KEYS = {
    "R",
    "G",
    "B",
    "A",
    "RO",
    "GO",
    "BO"
}
function ____exports.colorEquals(self, color1, color2)
    return isaacAPIClassEquals(nil, color1, color2, KEYS)
end
--- Helper function to copy a `Color` Isaac API class.
function ____exports.copyColor(self, color)
    if not ____exports.isColor(nil, color) then
        error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
    end
    return Color(
        color.R,
        color.G,
        color.B,
        color.A,
        color.RO,
        color.GO,
        color.BO
    )
end
--- Helper function to convert a `SerializedColor` object to a normal `Color` object. (This is used
-- by the save data manager when reading data from the "save#.dat" file.)
function ____exports.deserializeColor(self, color)
    if not isTable(nil, color) then
        error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
    end
    local r, g, b, a, ro, go, bo = table.unpack(
        getNumbersFromTable(
            nil,
            color,
            OBJECT_NAME,
            table.unpack(KEYS)
        ),
        1,
        7
    )
    assertDefined(nil, r, ("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: R")
    assertDefined(nil, g, ("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: G")
    assertDefined(nil, b, ("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: B")
    return Color(
        r,
        g,
        b,
        a,
        ro,
        go,
        bo
    )
end
--- Helper function to get a random `Color` object.
-- 
-- If you want to generate an unseeded object, you must explicitly pass `undefined` to the
-- `seedOrRNG` parameter.
-- 
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
-- `RNG.Next` method will be called. If `undefined` is provided, it will default to
-- a random seed.
-- @param alpha Optional. The alpha value to use. Default is 1.
function ____exports.getRandomColor(self, seedOrRNG, alpha)
    if alpha == nil then
        alpha = 1
    end
    local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
    local r = getRandom(nil, rng)
    local g = getRandom(nil, rng)
    local b = getRandom(nil, rng)
    return Color(r, g, b, alpha)
end
--- Used to determine is the given table is a serialized `Color` object created by the `deepCopy`
-- function.
function ____exports.isSerializedColor(self, object)
    if not isTable(nil, object) then
        return false
    end
    return tableHasKeys(
        nil,
        object,
        table.unpack(KEYS)
    ) and object[SerializationBrand.COLOR] ~= nil
end
--- Helper function to convert a `Color` object to a `SerializedColor` object. (This is used by the
-- save data manager when writing data from the "save#.dat" file.)
function ____exports.serializeColor(self, color)
    if not ____exports.isColor(nil, color) then
        error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
    end
    local colorTable = {}
    copyUserdataValuesToTable(nil, color, KEYS, colorTable)
    colorTable[SerializationBrand.COLOR] = ""
    return colorTable
end
return ____exports
