local mod	= DBM:NewMod(1982, "DBM-Party-Legion", 13, 945)
local L		= mod:GetLocalizedStrings()

mod:SetRevision("20260322094133")
mod:SetCreatureID(124870)--124745 Greater Rift Warden
mod:SetEncounterID(2068)

mod:RegisterCombat("combat")

if DBM:IsPostMidnight() then
	--TODO, add any missing timers or events if possible
	--Custom Sounds on cast/cooldown expiring
	mod:AddCustomAlertSoundOption(1265419, true, 2)--Notes of Despair
	mod:AddCustomAlertSoundOption(1265421, true, 2)--Dirge of Despair
	mod:AddCustomAlertSoundOption(1264196, true, 2)--Disintegrate
	mod:AddCustomAlertSoundOption(1265689, true, 2)--Grim Chorus
	mod:AddCustomAlertSoundOption(1265426, true, 3)--Symphony of the Eternal Night
	mod:AddCustomAlertSoundOption(1266001, true, 2)--Backlash
	--Custom timer colors, countdowns, and disables
	mod:AddCustomTimerOptions(1265419, true, 5, 0)
	mod:AddCustomTimerOptions(1265421, true, 2, 0)
	mod:AddCustomTimerOptions(1265426, true, 3, 0)
	mod:AddCustomTimerOptions(1264196, true, 3, 0)
	mod:AddCustomTimerOptions(1265689, true, 2, 0)
	--Midnight private aura replacements
	mod:AddPrivateAuraSoundOption(1265426, true, 1265426, 2, 1, "debuffyou", 17)

	function mod:OnLimitedCombatStart()
		self:DisableSpecialWarningSounds()
		self:EnableAlertOptions(1265419, 248, "specialsoon", 2)
		self:EnableAlertOptions(1265421, 249, "aesoon", 2)
		self:EnableAlertOptions(1265426, 250, "watchstep", 2)
		self:EnableAlertOptions(1264196, 251, "aesoon", 2)
		self:EnableAlertOptions(1265689, 252, "stilldanger", 2)
		self:EnableAlertOptions(1266001, 254, "carefly", 2, 4, 0)--Check if event actually works

		self:EnableTimelineOptions(1265419, 248)
		self:EnableTimelineOptions(1265421, 249)
		self:EnableTimelineOptions(1265426, 250)
		self:EnableTimelineOptions(1264196, 251)
		self:EnableTimelineOptions(1265689, 252)

	end
else
	mod:RegisterEventsInCombat(
		"SPELL_CAST_START 247795 245164 249009",
		"SPELL_CAST_SUCCESS 247930",
		"SPELL_AURA_APPLIED 247816 248535",
		"SPELL_AURA_REMOVED 247816"
	--	"CHAT_MSG_RAID_BOSS_EMOTE",
	--	"UNIT_SPELLCAST_SUCCEEDED boss1"
	)

	--TODO, more timer work, with good english mythic or mythic+ transcriptor logs with start/stop properly used
	--TODO, start grand shift timer on phase 2 trigger on mythic/mythic+ only
	--TODO, RP timer
	local warnBacklash						= mod:NewTargetAnnounce(247816, 1)
	local warnNaarusLamen					= mod:NewTargetAnnounce(248535, 2)

	local specWarnCalltoVoid				= mod:NewSpecialWarningSwitch(247795, nil, nil, nil, 1, 2)
	local specWarnFragmentOfDespair			= mod:NewSpecialWarningSpell(245164, nil, nil, nil, 1, 2)
	local specWarnGrandShift				= mod:NewSpecialWarningDodge(249009, nil, nil, nil, 2, 2)

	--local timerCalltoVoidCD					= mod:NewAITimer(12, 247795, nil, nil, nil, 1)
	local timerGrandShiftCD					= mod:NewCDTimer(14.6, 249009, nil, nil, nil, 3, nil, DBM_COMMON_L.HEROIC_ICON)
	local timerUmbralCadenceCD				= mod:NewCDTimer(10.9, 247930, nil, nil, nil, 2, nil, DBM_COMMON_L.HEALER_ICON)
	local timerBacklash						= mod:NewBuffActiveTimer(12.5, 247816, nil, nil, nil, 6)

	function mod:OnCombatStart(delay)
		self:SetStage(1)
		--timerCalltoVoidCD:Start(1-delay)--Done instantly
	end

	function mod:SPELL_CAST_START(args)
		local spellId = args.spellId
		if spellId == 247795 then
			specWarnCalltoVoid:Show()
			specWarnCalltoVoid:Play("killmob")
			--timerCalltoVoidCD:Start()
		elseif spellId == 245164 and self:AntiSpam(3, 1) then
			specWarnFragmentOfDespair:Show()
			specWarnFragmentOfDespair:Play("helpsoak")
		elseif spellId == 249009 then
			specWarnGrandShift:Show()
			specWarnGrandShift:Play("watchstep")
			timerGrandShiftCD:Start()
		end
	end

	function mod:SPELL_CAST_SUCCESS(args)
		local spellId = args.spellId
		if spellId == 247930 then
			timerUmbralCadenceCD:Start()
		end
	end

	function mod:SPELL_AURA_APPLIED(args)
		local spellId = args.spellId
		if spellId == 247816 then--Backlash
			warnBacklash:Show(args.destName)
			timerBacklash:Start()
			--Pause Timers?
		elseif spellId == 248535 then
			warnNaarusLamen:Show(args.destName)
		end
	end

	function mod:SPELL_AURA_REMOVED(args)
		local spellId = args.spellId
		if spellId == 247816 then--Backlash
			timerBacklash:Stop()
			--Resume timers?
		end
	end

	--[[
	function mod:CHAT_MSG_RAID_BOSS_EMOTE(msg)
		if msg:find("inv_misc_monsterhorn_03") then

		end
	end

	function mod:UNIT_SPELLCAST_SUCCEEDED(uId, _, spellId)
		if spellId == 250011 then--Alleria Describes L'ura Conversation

		end
	end
	--]]
end
