local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = {}
local statEquals
local ____cachedEnumValues = require("cachedEnumValues")
local PLAYER_STAT_VALUES = ____cachedEnumValues.PLAYER_STAT_VALUES
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
local ____bitSet128 = require("functions.bitSet128")
local isBitSet128 = ____bitSet128.isBitSet128
local ____color = require("functions.color")
local colorEquals = ____color.colorEquals
local isColor = ____color.isColor
local ____playerIndex = require("functions.playerIndex")
local getPlayerIndex = ____playerIndex.getPlayerIndex
local ____stats = require("functions.stats")
local getPlayerStat = ____stats.getPlayerStat
local ____types = require("functions.types")
local isBoolean = ____types.isBoolean
local isNumber = ____types.isNumber
local ____vector = require("functions.vector")
local isVector = ____vector.isVector
local vectorEquals = ____vector.vectorEquals
local ____shouldFire = require("shouldFire")
local shouldFirePlayer = ____shouldFire.shouldFirePlayer
local ____DefaultMap = require("classes.DefaultMap")
local DefaultMap = ____DefaultMap.DefaultMap
local ____CustomCallback = require("classes.private.CustomCallback")
local CustomCallback = ____CustomCallback.CustomCallback
function statEquals(self, oldValue, newValue)
    local isNumberStat = isNumber(nil, oldValue) and isNumber(nil, newValue)
    if isNumberStat then
        return oldValue == newValue
    end
    local isBooleanStat = isBoolean(nil, oldValue) and isBoolean(nil, newValue)
    if isBooleanStat then
        return oldValue == newValue
    end
    local isBitSet128Stat = isBitSet128(nil, oldValue) and isBitSet128(nil, newValue)
    if isBitSet128Stat then
        return oldValue == newValue
    end
    local isColorStat = isColor(nil, oldValue) and isColor(nil, newValue)
    if isColorStat then
        return colorEquals(nil, oldValue, newValue)
    end
    local isVectorStat = isVector(nil, oldValue) and isVector(nil, newValue)
    if isVectorStat then
        return vectorEquals(nil, oldValue, newValue)
    end
    error("Failed to determine the type of a stat in the \"POST_PLAYER_CHANGE_STAT\" callback.")
end
local v = {run = {playersStatMap = __TS__New(
    DefaultMap,
    function() return __TS__New(Map) end
)}}
____exports.PostPlayerChangeStat = __TS__Class()
local PostPlayerChangeStat = ____exports.PostPlayerChangeStat
PostPlayerChangeStat.name = "PostPlayerChangeStat"
__TS__ClassExtends(PostPlayerChangeStat, CustomCallback)
function PostPlayerChangeStat.prototype.____constructor(self)
    CustomCallback.prototype.____constructor(self)
    self.v = v
    self.shouldFire = shouldFirePlayer
    self.postPEffectReordered = function(____, player)
        local playerIndex = getPlayerIndex(nil, player, true)
        local playerStatMap = v.run.playersStatMap:getAndSetDefault(playerIndex)
        for ____, statType in ipairs(PLAYER_STAT_VALUES) do
            do
                local storedStatValue = playerStatMap:get(statType)
                local currentStatValue = getPlayerStat(nil, player, statType)
                playerStatMap:set(statType, currentStatValue)
                if storedStatValue == nil then
                    goto __continue5
                end
                if not statEquals(nil, storedStatValue, currentStatValue) then
                    local isNumberStat = isNumber(nil, storedStatValue) and isNumber(nil, currentStatValue)
                    local difference = isNumberStat and currentStatValue - storedStatValue or 0
                    self:fire(
                        player,
                        statType,
                        difference,
                        storedStatValue,
                        currentStatValue
                    )
                end
            end
            ::__continue5::
        end
    end
    self.customCallbacksUsed = {{ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED, self.postPEffectReordered}}
end
return ____exports
