local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local ____exports = {}
local ____constants = require("core.constants")
local CHEST_PICKUP_VARIANTS_SET = ____constants.CHEST_PICKUP_VARIANTS_SET
local ____batteryNames = require("objects.batteryNames")
local BATTERY_NAMES = ____batteryNames.BATTERY_NAMES
local DEFAULT_BATTERY_NAME = ____batteryNames.DEFAULT_BATTERY_NAME
local ____bombNames = require("objects.bombNames")
local BOMB_NAMES = ____bombNames.BOMB_NAMES
local DEFAULT_BOMB_NAME = ____bombNames.DEFAULT_BOMB_NAME
local ____chestNames = require("objects.chestNames")
local CHEST_NAMES = ____chestNames.CHEST_NAMES
local DEFAULT_CHEST_NAME = ____chestNames.DEFAULT_CHEST_NAME
local ____coinNames = require("objects.coinNames")
local COIN_NAMES = ____coinNames.COIN_NAMES
local DEFAULT_COIN_NAME = ____coinNames.DEFAULT_COIN_NAME
local ____coinSubTypeToValue = require("objects.coinSubTypeToValue")
local COIN_SUB_TYPE_TO_VALUE = ____coinSubTypeToValue.COIN_SUB_TYPE_TO_VALUE
local DEFAULT_COIN_VALUE = ____coinSubTypeToValue.DEFAULT_COIN_VALUE
local ____heartNames = require("objects.heartNames")
local DEFAULT_HEART_NAME = ____heartNames.DEFAULT_HEART_NAME
local HEART_NAMES = ____heartNames.HEART_NAMES
local ____keyNames = require("objects.keyNames")
local DEFAULT_KEY_NAME = ____keyNames.DEFAULT_KEY_NAME
local KEY_NAMES = ____keyNames.KEY_NAMES
local ____sackNames = require("objects.sackNames")
local DEFAULT_SACK_NAME = ____sackNames.DEFAULT_SACK_NAME
local SACK_NAMES = ____sackNames.SACK_NAMES
local ____redHeartSubTypesSet = require("sets.redHeartSubTypesSet")
local RED_HEART_SUB_TYPES_SET = ____redHeartSubTypesSet.RED_HEART_SUB_TYPES_SET
local ____entities = require("functions.entities")
local removeEntities = ____entities.removeEntities
local ____pickupVariants = require("functions.pickupVariants")
local isHeart = ____pickupVariants.isHeart
local ____pickupsSpecific = require("functions.pickupsSpecific")
local getHearts = ____pickupsSpecific.getHearts
--- Helper function to test if the provided pickup variant matches one of the various chest variants.
function ____exports.isChestVariant(self, pickupVariant)
    return CHEST_PICKUP_VARIANTS_SET:has(pickupVariant)
end
--- Helper function to get the name of a battery, as listed in the "entities2.xml" file. Returns
-- "Unknown" if the provided battery sub-type is not valid.
-- 
-- This function only works for vanilla battery types.
-- 
-- For example, `getBatteryName(BatterySubType.MICRO)` would return "Micro Battery".
function ____exports.getBatteryName(self, batterySubType)
    return BATTERY_NAMES[batterySubType] or DEFAULT_BATTERY_NAME
end
--- Helper function to get the name of a bomb, as listed in the "entities2.xml" file. Returns
-- "Unknown" if the provided bomb sub-type is not valid.
-- 
-- This function only works for vanilla bomb types.
-- 
-- For example, `getBombName(BombSubType.DOUBLE_PACK)` would return "Double Bomb".
function ____exports.getBombName(self, bombSubType)
    return BOMB_NAMES[bombSubType] or DEFAULT_BOMB_NAME
end
--- Helper function to get the name of a chest, as listed in the "entities2.xml" file. Returns
-- "Unknown" if the pickup variant was not a chest.
-- 
-- This function only works for vanilla chest types.
-- 
-- For example, `getChestName(PickupVariant.SPIKED_CHEST)` would return "Spiked Chest".
function ____exports.getChestName(self, pickupVariant)
    local chestNames = CHEST_NAMES
    return chestNames[pickupVariant] or DEFAULT_CHEST_NAME
end
--- Helper function to get the name of a coin, as listed in the "entities2.xml" file. Returns
-- "Unknown" if the provided coin sub-type is not valid.
-- 
-- This function only works for vanilla chest types.
-- 
-- For example, `getCoinName(CoinSubType.DOUBLE_PACK)` would return "Double Penny".
function ____exports.getCoinName(self, coinSubType)
    return COIN_NAMES[coinSubType] or DEFAULT_COIN_NAME
end
--- Helper function to get the corresponding coin amount from a `CoinSubType`. Returns 1 for modded
-- sub-types.
function ____exports.getCoinValue(self, coinSubType)
    local value = COIN_SUB_TYPE_TO_VALUE[coinSubType]
    return value or DEFAULT_COIN_VALUE
end
--- Helper function to get the name of a heart, as listed in the "entities2.xml" file. Returns
-- "Unknown" if the provided heart sub-type is not valid.
-- 
-- This function only works for vanilla heart types.
-- 
-- For example, `getHeartName(HeartSubType.ETERNAL)` would return "Heart (eternal)".
function ____exports.getHeartName(self, heartSubType)
    return HEART_NAMES[heartSubType] or DEFAULT_HEART_NAME
end
--- Helper function to get the name of a key, as listed in the "entities2.xml" file. Returns
-- "Unknown" if the provided key sub-type is not valid.
-- 
-- This function only works for vanilla key types.
-- 
-- For example, `getKeyName(KeySubType.DOUBLE_PACK)` would return "Key Ring".
function ____exports.getKeyName(self, keySubType)
    return KEY_NAMES[keySubType] or DEFAULT_KEY_NAME
end
--- Helper function to get all of the red heart pickup entities in the room.
function ____exports.getRedHearts(self)
    local hearts = getHearts(nil)
    return __TS__ArrayFilter(
        hearts,
        function(____, heart) return RED_HEART_SUB_TYPES_SET:has(heart.SubType) end
    )
end
--- Helper function to get the name of a sack, as listed in the "entities2.xml" file. Returns
-- "Unknown" if the provided sack sub-type is not valid.
-- 
-- This function only works for vanilla sack types.
-- 
-- For example, `getSackName(SackSubType.NORMAL)` would return "Grab Bag".
function ____exports.getSackName(self, sackSubType)
    return SACK_NAMES[sackSubType] or DEFAULT_SACK_NAME
end
--- Helper function to test if the provided pickup matches one of the various chest variants.
function ____exports.isChest(self, pickup)
    return ____exports.isChestVariant(nil, pickup.Variant)
end
--- Helper function to test if the provided pickup matches one of the various red heart sub-types.
function ____exports.isRedHeart(self, pickup)
    return isHeart(nil, pickup) and RED_HEART_SUB_TYPES_SET:has(pickup.SubType)
end
--- Helper function to test if the provided heart sub-type matches one of the various red heart
-- sub-types.
function ____exports.isRedHeartSubType(self, heartSubType)
    return RED_HEART_SUB_TYPES_SET:has(heartSubType)
end
--- Helper function to remove all of the red heart pickup entities in the room.
-- 
-- @param cap Optional. If specified, will only remove the given amount of hearts.
-- @returns The red hearts that were removed.
function ____exports.removeAllRedHearts(self, cap)
    local redHearts = ____exports.getRedHearts(nil)
    return removeEntities(nil, redHearts, cap)
end
return ____exports
