local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local CallbackPriority = ____isaac_2Dtypescript_2Ddefinitions.CallbackPriority
local ____ModFeature = require("classes.ModFeature")
local MOD_FEATURE_CALLBACKS_KEY = ____ModFeature.MOD_FEATURE_CALLBACKS_KEY
local MOD_FEATURE_CUSTOM_CALLBACKS_KEY = ____ModFeature.MOD_FEATURE_CUSTOM_CALLBACKS_KEY
local ____tstlClass = require("functions.tstlClass")
local getTSTLClassName = ____tstlClass.getTSTLClassName
--- A decorator function that signifies that the decorated class method should be automatically
-- registered with `Mod.AddPriorityCallback`.
-- 
-- @allowEmptyVariadic
-- @ignore
function ____exports.PriorityCallback(self, modCallback, priority, ...)
    local optionalArgs = {...}
    return function(____, target, propertyKey, _descriptor)
        local methodName = propertyKey
        local method = target[methodName]
        local callbackTuple = {modCallback, priority, method, optionalArgs}
        local constructor = target.constructor
        if constructor == nil then
            local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
            error(("Failed to get the constructor for class \"" .. tstlClassName) .. "\". Did you decorate a static method? You can only decorate non-static class methods, because the \"Mod\" object is not present before the class is instantiated.")
        end
        if not (constructor[MOD_FEATURE_CALLBACKS_KEY] ~= nil) then
            constructor[MOD_FEATURE_CALLBACKS_KEY] = {}
        end
        local callbackTuples = constructor[MOD_FEATURE_CALLBACKS_KEY]
        callbackTuples[#callbackTuples + 1] = callbackTuple
    end
end
--- A decorator function that signifies that the decorated class method should be automatically
-- registered with `ModUpgraded.AddCallbackCustom`.
-- 
-- @allowEmptyVariadic
-- @ignore
function ____exports.PriorityCallbackCustom(self, modCallbackCustom, priority, ...)
    local optionalArgs = {...}
    return function(____, target, propertyKey, _descriptor)
        local methodName = propertyKey
        local method = target[methodName]
        local callbackTuple = {modCallbackCustom, priority, method, optionalArgs}
        local constructor = target.constructor
        if constructor == nil then
            local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
            error(("Failed to get the constructor for class \"" .. tstlClassName) .. "\". Did you decorate a static method? You can only decorate non-static class methods, because the \"Mod\" object is not present before the class is instantiated.")
        end
        if not (constructor[MOD_FEATURE_CUSTOM_CALLBACKS_KEY] ~= nil) then
            constructor[MOD_FEATURE_CUSTOM_CALLBACKS_KEY] = {}
        end
        local callbackTuples = constructor[MOD_FEATURE_CUSTOM_CALLBACKS_KEY]
        callbackTuples[#callbackTuples + 1] = callbackTuple
    end
end
--- A decorator function that signifies that the decorated class method should be automatically
-- registered with `Mod.AddCallback`.
-- 
-- @allowEmptyVariadic
-- @ignore
function ____exports.Callback(self, modCallback, ...)
    return ____exports.PriorityCallback(nil, modCallback, CallbackPriority.DEFAULT, ...)
end
--- A decorator function that signifies that the decorated class method should be automatically
-- registered with `ModUpgraded.AddCallbackCustom`.
-- 
-- @allowEmptyVariadic
-- @ignore
function ____exports.CallbackCustom(self, modCallbackCustom, ...)
    return ____exports.PriorityCallbackCustom(nil, modCallbackCustom, CallbackPriority.DEFAULT, ...)
end
return ____exports
