local ____exports = {}
local OBJECT_NAME
local ____SerializationBrand = require("enums.private.SerializationBrand")
local SerializationBrand = ____SerializationBrand.SerializationBrand
local ____isaacAPIClass = require("functions.isaacAPIClass")
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
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 `BitSet128` object.
function ____exports.isBitSet128(self, object)
    return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
end
OBJECT_NAME = "BitSet128"
local KEYS = {"l", "h"}
--- Helper function to copy a `BitSet128` Isaac API class.
function ____exports.copyBitSet128(self, bitSet128)
    if not ____exports.isBitSet128(nil, bitSet128) then
        error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
    end
    local lowBits = bitSet128.l
    local highBits = bitSet128.h
    return BitSet128(lowBits, highBits)
end
--- Helper function to convert a `SerializedBitSet128` object to a normal `BitSet128` object. (This
-- is used by the save data manager when reading data from the "save#.dat" file.)
function ____exports.deserializeBitSet128(self, bitSet128)
    if not isTable(nil, bitSet128) then
        error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
    end
    local l, h = table.unpack(getNumbersFromTable(
        nil,
        bitSet128,
        OBJECT_NAME,
        table.unpack(KEYS)
    ))
    assertDefined(nil, l, ("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: l")
    assertDefined(nil, h, ("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: h")
    return BitSet128(l, h)
end
--- Used to determine is the given table is a serialized `BitSet128` object created by the `deepCopy`
-- function.
function ____exports.isSerializedBitSet128(self, object)
    if not isTable(nil, object) then
        return false
    end
    return tableHasKeys(
        nil,
        object,
        table.unpack(KEYS)
    ) and object[SerializationBrand.BIT_SET_128] ~= nil
end
--- Helper function to convert a `BitSet128` object to a `SerializedBitSet128` object. (This is used
-- by the save data manager when writing data from the "save#.dat" file.)
function ____exports.serializeBitSet128(self, bitSet128)
    if not ____exports.isBitSet128(nil, bitSet128) then
        error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
    end
    local bitSet128Table = {}
    copyUserdataValuesToTable(nil, bitSet128, KEYS, bitSet128Table)
    bitSet128Table[SerializationBrand.BIT_SET_128] = ""
    return bitSet128Table
end
return ____exports
