aura_env.trackedSpells = {
	20271, -- Judgement
	26573, -- Consecration
	209202, -- Eye of Tyr
	213652, -- Hand of the Protector
	31935, -- Avenger's Shield
	53600, -- Shield of the Righteous
	1044, -- Hand of Freedom
	155145, -- Arcane Torrent
	853, -- Hammer of Justice
	6940, -- Hand of Sacrifice
	31850, -- Ardent Defender
	86659, -- Guardian of Ancient Kings
	204018, -- Blessing of Spellwarding
	--
	108416, -- Dark Pact
	196447, -- Channel Demonfire
	104773, -- Unending Resolve
	196586, -- Dimensional Rift
}
local iconDisplayDuration = 0.4
local gcdDuration = 1.5

aura_env.cache = {}
for k, spellId in pairs(aura_env.trackedSpells) do
	aura_env.cache[spellId] = {
		ready = true,
		hasCharges = false,
	}
	if GetSpellCharges(spellId) then
		aura_env.cache[spellId].hasCharges = true
		aura_env.cache[spellId].charges = select(1, GetSpellCharges(spellId))
	end
end

aura_env.processEvent = function(allstates)
	for k, spellId in pairs(aura_env.trackedSpells) do
		-- Handle spells with charges
		local isReady
		if aura_env.cache[spellId].hasCharges then
			local charges = select(1, GetSpellCharges(spellId))
			if charges > aura_env.cache[spellId].charges then
				isReady = true
				aura_env.cache[spellId].charges = charges
			else
				isReady = false
				aura_env.cache[spellId].charges = charges
			end
		else
			isReady = select(2, GetSpellCooldown(spellId)) < gcdDuration
		end

		if not aura_env.cache[spellId].ready and isReady then
			local icon = select(3, GetSpellInfo(spellId))
			allstates[spellId] = {
				show = true,
				changed = true,
				index = GetTime(),
				resort = true,

				icon = icon,

				progressType = "timed",
				expirationTime = GetTime() + iconDisplayDuration,
				duration = iconDisplayDuration,
				autoHide = true,
			}
		end

		aura_env.cache[spellId].ready = isReady
	end
end
