--TSU
--COMBAT_LOG_EVENT_UNFILTERED GROUP_ROSTER_UPDATE
function(allstates, e, ...)
    if e == "GROUP_ROSTER_UPDATE" then
        for i = 1, GetNumGroupMembers() do
            local u = "raid" .. i
            if aura_env.healers[UnitName(u)] then aura_env.healers[UnitName(u)] = NULL end
            -- if UnitGroupRolesAssigned(u) == "TANK" then
            if UnitGroupRolesAssigned(u) == "HEALER" then
                aura_env.healers[UnitName(u)] = true
            end
            for k,v in pairs(aura_env.healers) do
                allstates[k] = {
                    show = true,
                    changed = true,
                    progressType = "static",
                    value = 0,
                    total = 100,
                    name = k,
                    class = select(3, UnitClass(k)),
                }
            end
        end
        --DevTools_Dump(allstates)
        return true
    elseif e == "COMBAT_LOG_EVENT_UNFILTERED" then
        local se = select(2, ...)
        if se == "SPELL_CAST_SUCCESS" then
            local spellId = select(12, ...)
            if aura_env.dispels[spellId] then
                local caster = select(5, ...)
                allstates[caster] = {
                    show = true,
                    changed = true,
                    progressType = "timed",
                    duration = 8,
                    expirationTime = GetTime() + 8,
                    name = caster,
                    class = select(3, UnitClass(caster)),
                }
            end
        end
        return true
    end
end

--ON SHOW
if aura_env.statee then
    local class = aura_env.statee.class
    aura_env.region.bar:SetForegroundColor(aura_env.classColor(class))
end

--INIT
aura_env.healers = {}
aura_env.dispels = {
    [4987] = true, -- Cleanse
    [88423] = true, -- Nature's Cure
    [77130] = true, -- Purify Spirit
    [115450] = true, -- Detox
    -- [236186] = true, -- Tank dispel, testing
}
aura_env.classColor = function(class)
    if class == 1 then return 0.78, 0.61, 0.43, 1 elseif
    class == 2 then return 0.96, 0.55, 0.73, 1 elseif
    class == 3 then return 0.67, 0.83, 0.45, 1 elseif
    class == 4 then return 1, 0.96, 0.41, 1 elseif
    class == 5 then return 1, 1, 1, 1 elseif
    class == 6 then return 0.77, 0.12, 0.23, 1 elseif
    class == 7 then return 0, 0.44, 0.87, 1 elseif
    class == 8 then return 0.25, 0.78, 0.92, 1 elseif
    class == 9 then return 0.53, 0.53, 0.93, 1 elseif
    class == 10 then return 0, 1, 0.59, 1 elseif
    class == 11 then return 1, 0.49, 0.04, 1 elseif
    class == 12 then return 0.64, 0.19, 0.79, 1 else
    return 1, 1, 1, 1 end
end