local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local ItemPoolType = ____isaac_2Dtypescript_2Ddefinitions.ItemPoolType
local ____cachedEnumValues = require("arrays.cachedEnumValues")
local ITEM_POOL_TYPE_VALUES = ____cachedEnumValues.ITEM_POOL_TYPE_VALUES
local ____cachedClasses = require("core.cachedClasses")
local game = ____cachedClasses.game
local ____itemPoolTypeToItemPoolName = require("maps.itemPoolTypeToItemPoolName")
local ITEM_POOL_TYPE_TO_ITEM_POOL_NAME = ____itemPoolTypeToItemPoolName.ITEM_POOL_TYPE_TO_ITEM_POOL_NAME
local ____itemPoolTypeToCollectibleTypesSet = require("objects.itemPoolTypeToCollectibleTypesSet")
local ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET = ____itemPoolTypeToCollectibleTypesSet.ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET
local ____array = require("functions.array")
local arrayRemove = ____array.arrayRemove
local getRandomArrayElement = ____array.getRandomArrayElement
local NORMAL_MODE_ONLY_ITEM_POOL_TYPES = {
    ItemPoolType.TREASURE,
    ItemPoolType.BOSS,
    ItemPoolType.SHOP,
    ItemPoolType.DEVIL,
    ItemPoolType.ANGEL,
    ItemPoolType.CURSE,
    ItemPoolType.SECRET
}
local GREED_MODE_ONLY_ITEM_POOL_TYPES = {
    ItemPoolType.GREED_TREASURE,
    ItemPoolType.GREED_BOSS,
    ItemPoolType.GREED_SHOP,
    ItemPoolType.GREED_DEVIL,
    ItemPoolType.GREED_ANGEL,
    ItemPoolType.GREED_CURSE,
    ItemPoolType.GREED_SECRET
}
local FAKE_ITEM_POOL_TYPES = {ItemPoolType.SHELL_GAME}
local ____arrayRemove_1 = arrayRemove
local ____array_0 = __TS__SparseArrayNew(
    nil,
    ITEM_POOL_TYPE_VALUES,
    table.unpack(GREED_MODE_ONLY_ITEM_POOL_TYPES)
)
__TS__SparseArrayPush(
    ____array_0,
    table.unpack(FAKE_ITEM_POOL_TYPES)
)
local NORMAL_MODE_ITEM_POOL_TYPES = ____arrayRemove_1(__TS__SparseArraySpread(____array_0))
local ____arrayRemove_3 = arrayRemove
local ____array_2 = __TS__SparseArrayNew(
    nil,
    ITEM_POOL_TYPE_VALUES,
    table.unpack(NORMAL_MODE_ONLY_ITEM_POOL_TYPES)
)
__TS__SparseArrayPush(
    ____array_2,
    table.unpack(FAKE_ITEM_POOL_TYPES)
)
local GREED_MODE_ITEM_POOL_TYPES = ____arrayRemove_3(__TS__SparseArraySpread(____array_2))
--- Helper function to get the collectibles that are in a particular item pool at the beginning of a
-- vanilla run.
function ____exports.getDefaultCollectibleTypesInItemPool(self, itemPoolType)
    return ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET[itemPoolType]
end
--- Helper function to get the item pools that a particular collectible starts in at the beginning of
-- a vanilla run.
-- 
-- This function will automatically account for Greed Mode. In other words, it will not return the
-- "normal" item pools when playing in Greed Mode.
function ____exports.getDefaultItemPoolsForCollectibleType(self, collectibleType)
    local collectibleItemPoolTypes = {}
    local itemPoolTypes = game:IsGreedMode() and GREED_MODE_ITEM_POOL_TYPES or NORMAL_MODE_ITEM_POOL_TYPES
    for ____, itemPoolType in ipairs(itemPoolTypes) do
        local collectibleTypesSet = ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET[itemPoolType]
        if collectibleTypesSet:has(collectibleType) then
            collectibleItemPoolTypes[#collectibleItemPoolTypes + 1] = itemPoolType
        end
    end
    return collectibleItemPoolTypes
end
--- Helper function to get the name for an item pool type as it appears in the "itempools.xml" file.
function ____exports.getItemPoolName(self, itemPoolType)
    return ITEM_POOL_TYPE_TO_ITEM_POOL_NAME[itemPoolType]
end
--- Helper function to get a random item pool. This is not as simple as getting a random value from
-- the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
-- Greed Mode item pools should be excluded if not playing in Greed Mode.
-- 
-- If you want to get an unseeded item pool, 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.
function ____exports.getRandomItemPool(self, seedOrRNG)
    local itemPoolTypes = game:IsGreedMode() and GREED_MODE_ITEM_POOL_TYPES or NORMAL_MODE_ITEM_POOL_TYPES
    return getRandomArrayElement(nil, itemPoolTypes, seedOrRNG)
end
--- Helper function to check if a particular collectibles is in a particular item pool at the
-- beginning of a vanilla run.
function ____exports.isCollectibleTypeInDefaultItemPool(self, collectibleType, itemPoolType)
    local collectibleTypesSet = ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET[itemPoolType]
    return collectibleTypesSet:has(collectibleType)
end
--- Helper function to remove one or more collectibles from all item pools.
-- 
-- This function is variadic, meaning you can pass as many collectible types as you want to remove.
function ____exports.removeCollectibleFromPools(self, ...)
    local collectibleTypes = {...}
    local itemPool = game:GetItemPool()
    for ____, collectibleType in ipairs(collectibleTypes) do
        itemPool:RemoveCollectible(collectibleType)
    end
end
--- Helper function to remove one or more trinkets from all item pools.
-- 
-- This function is variadic, meaning you can pass as many trinket types as you want to remove.
function ____exports.removeTrinketFromPools(self, ...)
    local trinketTypes = {...}
    local itemPool = game:GetItemPool()
    for ____, trinketType in ipairs(trinketTypes) do
        itemPool:RemoveTrinket(trinketType)
    end
end
return ____exports
