local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local ItemType = ____isaac_2Dtypescript_2Ddefinitions.ItemType
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
local ____playerDataStructures = require("functions.playerDataStructures")
local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
local ____types = require("functions.types")
local asNumber = ____types.asNumber
local ____PickingUpItem = require("types.PickingUpItem")
local newPickingUpItem = ____PickingUpItem.newPickingUpItem
local resetPickingUpItem = ____PickingUpItem.resetPickingUpItem
local ____DefaultMap = require("classes.DefaultMap")
local DefaultMap = ____DefaultMap.DefaultMap
local ____Feature = require("classes.private.Feature")
local Feature = ____Feature.Feature
local v = {run = {playersPickingUpItemMap = __TS__New(
    DefaultMap,
    function() return newPickingUpItem(nil) end
)}}
____exports.ItemPickupDetection = __TS__Class()
local ItemPickupDetection = ____exports.ItemPickupDetection
ItemPickupDetection.name = "ItemPickupDetection"
__TS__ClassExtends(ItemPickupDetection, Feature)
function ItemPickupDetection.prototype.____constructor(self, postItemPickup, preItemPickup)
    Feature.prototype.____constructor(self)
    self.v = v
    self.postPEffectUpdateReordered = function(____, player)
        local pickingUpItem = defaultMapGetPlayer(nil, v.run.playersPickingUpItemMap, player)
        if player:IsItemQueueEmpty() then
            self:queueEmpty(player, pickingUpItem)
        else
            self:queueNotEmpty(player, pickingUpItem)
        end
    end
    self.customCallbacksUsed = {{ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED, self.postPEffectUpdateReordered}}
    self.postItemPickup = postItemPickup
    self.preItemPickup = preItemPickup
end
function ItemPickupDetection.prototype.queueEmpty(self, player, pickingUpItem)
    if pickingUpItem.itemType == ItemType.NULL or asNumber(nil, pickingUpItem.subType) == 0 then
        return
    end
    self.postItemPickup:fire(player, pickingUpItem)
    resetPickingUpItem(nil, pickingUpItem)
end
function ItemPickupDetection.prototype.queueNotEmpty(self, player, pickingUpItem)
    local queuedItem = player.QueuedItem.Item
    if queuedItem == nil or queuedItem.Type == ItemType.NULL then
        return
    end
    if queuedItem.Type ~= pickingUpItem.itemType or queuedItem.ID ~= pickingUpItem.subType then
        pickingUpItem.itemType = queuedItem.Type
        pickingUpItem.subType = queuedItem.ID
        self.preItemPickup:fire(player, pickingUpItem)
    end
end
return ____exports
