local E, _, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local C, L = unpack(select(2, ...))
local UF = E:GetModule('UnitFrames');
local ACH = E.Libs.ACH

E.Options.args.unitframe.name = '04.'.. L["UnitFrames"]
E.Options.args.unitframe.args.generalOptionsGroup.args.generalGroup.args.transparent = {
	order = 5,
	type = 'toggle',
	name = L["Transparent Theme"],
	disabled = function() return E.db.general.transparent == false end,
	set = function(info, value) E.db.unitframe.transparent = value; E:StaticPopup_Show("CONFIG_RL") end,
}
E.Options.args.unitframe.args.generalOptionsGroup.args.generalGroup.args.powertrans = {
	order = 6,
	type = 'toggle',
	name = L["Transparent Power"],
	disabled = function() return E.db.general.transparent == false end,
	set = function(info, value) E.db.unitframe.powertrans = value; E:StaticPopup_Show("CONFIG_RL") end,
}
E.Options.args.unitframe.args.generalOptionsGroup.args.generalGroup.args.unitframeType = {
	order = 7,
	name = E.ValColor..L["Eui UF Style"].."|r",
	type = 'range',
	min = 1, max = 9, step = 1,
	set = function(info, value)
		E.db.unitframe.unitframeType = value
		E:SetupUFStyle(value)
	end,
}

E.Options.args.unitframe.args.individualUnits.args.player.args.Swing = {
	order = 801,
	type = 'group',
	name = L['Swing'],
	get = function(info) return E.db.unitframe.units['player']['Swing'][ info[#info] ] end,
	set = function(info, value) E.db.unitframe.units['player']['Swing'][ info[#info] ] = value; UF:CreateAndUpdateUF('player'); end,
	args = {
		enable = {
			type = 'toggle',
			order = 1,
			name = L['Enable'],
			desc = L['Swing Bar'],
		},
		width = {
			order = 2,
			name = L['Width'],
			type = 'range',
			min = 20, max = 600, step = 1,
		},
		height = {
			order = 3,
			name = L['Height'],
			type = 'range',
			min = 4, max = 200, step = 1,
		},
		text = {
			order = 4,
			name = L['Display Text'],
			type = 'toggle',
		},
		color = {
			order = 5,
			type = 'color',
			name = L['Color'],
			get = function(info)
				local t = E.db.unitframe.units['player']['Swing'].color
				return t.r, t.g, t.b, t.a
			end,
			set = function(info, r, g, b)
				local t = E.db.unitframe.units['player']['Swing'].color
				t.r, t.g, t.b = r, g, b
				UF:CreateAndUpdateUF('player');
			end,			
		},			
	},
}
E.Options.args.unitframe.args.individualUnits.args.player.args.gcd = {
	order = 12,
	name = L['GCD Bar'],
	desc = L['GCD Bar'],
	set = function(info, value) E.db.unitframe.units.player.gcd = value; E:StaticPopup_Show("CONFIG_RL") end,
	get = function(info) return E.db.unitframe.units.player.gcd; end,
	type = 'toggle',
}

E.Options.args.unitframe.args.individualUnits.args.player.args.tankshield = {
	order = 1200,
	type = 'group',
	name = L['BloodShield'],
	desc = L["BloodShield desc"],
	get = function(info) return E.db.unitframe.units['player']['tankshield'][ info[#info] ] end,
	set = function(info, value) E.db.unitframe.units['player']['tankshield'][ info[#info] ] = value; UF:CreateAndUpdateUF('player') end,
	args = {
		enable = {
			type = 'toggle',
			order = 1,
			name = L['Enable'],
		},
		xOffset = {
			order = 8,
			type = 'range',
			name = L['xOffset'],
			min = -600, max = 600, step = 1,
		},
		yOffset = {
			order = 9,
			type = 'range',
			name = L['yOffset'],
			min = -600, max = 600, step = 1,
		},
		sizeOverride = {
			type = 'range',
			order = 10,
			name = L['Size Override'],
			min = 0, max = 150, step = 1,
		},
	},
}

E.Options.args.unitframe.args.individualUnits.args.player.args.stagger = nil;
E.Options.args.unitframe.args.individualUnits.args.player.args.casttimeformat = {
	order = 6,
	type = 'range',
	min = 0, max = 2, step = 1,
	name = L['Castbar time Decimal places'],
}

E.Options.args.unitframe.args.individualUnits.args.player.args.classbar.args.text = {
	order = 5,
	type = 'toggle',
	name = L['Text'],
}

if E.myclass == 'DEATHKNIGHT' then
	E.Options.args.unitframe.args.individualUnits.args.player.args.classbar.args.dkText = {
		order = 6,
		type = 'toggle',
		name = L['Rune Time'],
	}
	E.Options.args.unitframe.args.individualUnits.args.player.args.classbar.args.dkTextXoffset = {
		order = 7,
		type = 'range',
		min = -100, max = 100, step = 1,
		name = L['Rune Time'].. L['xOffset'],
		disabled = function() return not E.db.unitframe.units.player.classbar.dkText; end,
	}
	E.Options.args.unitframe.args.individualUnits.args.player.args.classbar.args.dkTextYoffset = {
		order = 8,
		type = 'range',
		min = -100, max = 100, step = 1,
		name = L['Rune Time'].. L['yOffset'],
		disabled = function() return not E.db.unitframe.units.player.classbar.dkText; end,
	}
end


E.Options.args.unitframe.args.individualUnits.args.player.args.classbar.args.dkRunesBorderColor = {
	order = 6,
	type = 'toggle',
	name = L['dkRunesBorderColor'],
	hidden = (E.myclass ~= 'DEATHKNIGHT'),
}


E.Options.args.unitframe.args.individualUnits.args.player.args.classbar.args.height.max = 100

if E.myclass == 'MAGE' then
	for i = 1, 3 do
		E.Options.args.unitframe.args.individualUnits.args.args.player.args.power.args['tick'..i] = {
			order = 30+i,
			name = L['Display Tick'..i],
			desc = L['Set to 0 to disable.'],
			type = 'range',
			min = 0, max = 1, step = 0.01,
			isPercent = true,
		}
	end
	EE.Options.args.unitframe.args.individualUnits.args.player.args.power.args.minperc = {
		order = 35,
		name = L['Powerbar min perc'],
		desc = L['Set to 0 to disable.'],
		type = 'range',
		min = 0, max = 1, step = 0.01,
		isPercent = true,
	}
end

E.Options.args.unitframe.args.individualUnits.args.target.args.DragonOverlayStyle = {
	order = 13,
	type = 'select',
	name = L['Dragon Overlay Style'],
	values = {
		['classic'] = L['classic'],
		['modern'] = L['modern'],
		['none'] = NONE,
	},
	set = function(info,value) E.db.unitframe.units['target'].DragonOverlayStyle = value; UF:CreateAndUpdateUF('target'); end
}

E.Options.args.unitframe.args.individualUnits.args.target.args.range = {
	order = 350,
	type = 'group',
	name = L["Range"],
	get = function(info) return E.db.unitframe.units['target']['range'][ info[#info] ] end,
	set = function(info, value) E.db.unitframe.units['target']['range'][ info[#info] ] = value; UF:CreateAndUpdateUF('target') end,
	args = {
		enable = {
			order = 1,
			type = 'toggle',
			name = L['Enable'],
		},
		position = {
			type = 'select',
			order = 2,
			name = L['Position'],
			values = {
				TOPLEFT = L['TOPLEFT'],
				LEFT = L['LEFT'],
				BOTTOMLEFT = L['BOTTOMLEFT'],
				RIGHT = L['RIGHT'],
				TOPRIGHT = L['TOPRIGHT'],
				BOTTOMRIGHT = L['BOTTOMRIGHT'],
				CENTER = L['CENTER'],
				TOP = L['TOP'],
				BOTTOM = L['BOTTOM'],
			},
		},		
		offsetX = {
			order = 3,
			type = 'range',
			name = L['X Offset'],
			min = -500, max = 500, step = 1,
		},
		offsetY = {
			order = 4,
			type = 'range',
			name = L['Y Offset'],
			min = -500, max = 500, step = 1,
		},
		fontSize = {
			order = 4,
			type = 'range',
			name = L["Font Size"],
			min = 7, max = 212, step = 1,
		},
	},
}

E.Options.args.unitframe.args.individualUnits.args.target.args.castbar.args.InterruptSound = {
	order = 100,
	type = 'toggle',
	name = L['Interrupting the voice prompts'],
}

E.Options.args.unitframe.args.individualUnits.args.focus.args.castbar.args.InterruptSound = {
	order = 100,
	type = 'toggle',
	name = L['Interrupting the voice prompts'],
}

E.Options.args.unitframe.args.individualUnits.args.focus.args.range = {
	order = 350,
	type = 'group',
	name = L["Range"],
	get = function(info) return E.db.unitframe.units['focus']['range'][ info[#info] ] end,
	set = function(info, value) E.db.unitframe.units['focus']['range'][ info[#info] ] = value; UF:CreateAndUpdateUF('focus') end,
	args = {
		enable = {
			order = 1,
			type = 'toggle',
			name = L['Enable'],
		},
		position = {
			type = 'select',
			order = 2,
			name = L['Position'],
			values = {
				TOPLEFT = L['TOPLEFT'],
				LEFT = L['LEFT'],
				BOTTOMLEFT = L['BOTTOMLEFT'],
				RIGHT = L['RIGHT'],
				TOPRIGHT = L['TOPRIGHT'],
				BOTTOMRIGHT = L['BOTTOMRIGHT'],
				CENTER = L['CENTER'],
				TOP = L['TOP'],
				BOTTOM = L['BOTTOM'],
			},
		},		
		offsetX = {
			order = 3,
			type = 'range',
			name = L['X Offset'],
			min = -500, max = 500, step = 1,
		},
		offsetY = {
			order = 4,
			type = 'range',
			name = L['Y Offset'],
			min = -500, max = 500, step = 1,
		},
		fontSize = {
			order = 4,
			type = 'range',
			name = L["Font Size"],
			min = 7, max = 212, step = 1,
		},
	},
}

E.Options.args.unitframe.args.groupUnits.args.raid.name = L['Raid Frames'];
E.Options.args.unitframe.args.groupUnits.args.raid.args.health.args.colorClass = {
	order = 6,
	type = 'toggle',
	name = L['Class Health'],
	desc = L['Color health by classcolor or reaction.'],											
}

E.Options.args.unitframe.args.groupUnits.args.raid.args.generalGroup.args.mouseGlow = {
	order = 10,
	type = 'toggle',
	name = L['mouseGlow'],
}

E.Options.args.unitframe.args.groupUnits.args.boss.args.mouseGlow = {
	order = 10,
	type = 'toggle',
	name = L['mouseGlow'],
}

E.Options.args.unitframe.args.groupUnits.args.raid.args.generalGroup.args.visibilityGroup.args.soloShow = {
	order = 4,
	type = 'execute',
	name = L['Solo Show'],
	func = function()
		E.db.unitframe.units['raid'].visibility = '[@player,exists,nogroup:party] show;';
		UF:CreateAndUpdateHeaderGroup('raid', nil, nil, true)
	end,
}
E.Options.args.unitframe.args.groupUnits.args.raid.args.generalGroup.args.visibilityGroup.args.partyShow = {
	order = 5,
	type = 'execute',
	name = L['Party Show'],
	func = function()
		E.db.unitframe.units['raid'].visibility = '[group:party,nogroup:raid] show;';
		UF:CreateAndUpdateHeaderGroup('raid', nil, nil, true)
	end,
}
E.Options.args.unitframe.args.groupUnits.args.raid.args.generalGroup.args.visibilityGroup.args.raidShow = {
	order = 6,
	type = 'execute',
	name = L['Raid Show'],
	func = function()
		E.db.unitframe.units['raid'].visibility = '[@raid2,noexists] hide;show';
		UF:CreateAndUpdateHeaderGroup('raid', nil, nil, true)
	end,
}
E.Options.args.unitframe.args.groupUnits.args.raid.args.generalGroup.args.visibilityGroup.args.visibility.order = 7;


E.Options.args.unitframe.args.groupUnits.args.party.args.generalGroup.args.visibilityGroup.args.soloShow = {
	order = 4,
	type = 'execute',
	name = L['Solo Show'],
	func = function()
		E.db.unitframe.units['party'].visibility = '[@raid2,exists] hide;show';
		UF:CreateAndUpdateHeaderGroup('party', nil, nil, true)
	end,
}
E.Options.args.unitframe.args.groupUnits.args.party.args.generalGroup.args.visibilityGroup.args.partyShow = {
	order = 5,
	type = 'execute',
	name = L['Party Show'],
	func = function()
		E.db.unitframe.units['party'].visibility = '[@raid2,exists][@party1,noexists] hide;show';
		UF:CreateAndUpdateHeaderGroup('party', nil, nil, true)
	end,
}
E.Options.args.unitframe.args.groupUnits.args.party.args.generalGroup.args.visibilityGroup.args.raidShow = {
	order = 6,
	type = 'execute',
	name = L['Raid Show'],
	func = function()
		E.db.unitframe.units['party'].visibility = '[@raid2,noexists] hide;show';
		UF:CreateAndUpdateHeaderGroup('party', nil, nil, true)
	end,
}
E.Options.args.unitframe.args.groupUnits.args.party.args.generalGroup.args.visibilityGroup.args.arenaShow = {
	order = 7,
	type = 'execute',
	name = L['Arena Show'],
	func = function()
		E.db.unitframe.units['party'].visibility = '[@raid6,exists][nogroup] hide;show';
		UF:CreateAndUpdateHeaderGroup('party', nil, nil, true)
	end,
}

E.Options.args.unitframe.args.groupUnits.args.party.args.generalGroup.args.visibilityGroup.args.visibility.order = 7;

--E.Options.args.unitframe.args.raidpet = nil

E.Options.args.unitframe.args.groupUnits.args.boss.args.attack_color = {
	order = 12,
	name = L['attack_color'],
	type = 'toggle',
}

E.Options.args.unitframe.args.groupUnits.args.boss.args.threatStyle = nil
E.Options.args.unitframe.args.groupUnits.args.boss.args.space = {
	order = 9,
	name = L['Vertical Spacing'],
	type = 'range',
	min = 10, max = 100, step = 1,
}

E.Options.args.unitframe.args.groupUnits.args.boss.args.targetBossColor = {
	order = 13,
	type = 'color',
	name = CHOOSE..TARGET..COLOR,
	get = function(info)
		local t = E.db.unitframe.units.boss.targetBossColor
		return t.r, t.g, t.b, t.a
	end,
	set = function(info, r, g, b)
		local t = E.db.unitframe.units.boss.targetBossColor
		t.r, t.g, t.b = r, g, b
		UF:Update_AllFrames()
	end,	
}

E.Options.args.unitframe.args.individualUnits.args.target.args.factionIcon = {
	order = 1000,
	type = 'group',
	name = L["Faction Icon"],
	get = function(info) return E.db.unitframe.units['target']['factionIcon'][ info[#info] ] end,
	set = function(info, value) E.db.unitframe.units['target']['factionIcon'][ info[#info] ] = value; UF:CreateAndUpdateUF('target') end,
	args = {
		enable = {
			type = 'toggle',
			order = 1,
			name = L['Enable'],
		},
		xOffset = {
			order = 2,
			type = 'range',
			name = L['xOffset'],
			desc = L['An X offset (in pixels) to be used when anchoring new frames.'],
			min = -500, max = 500, step = 1,		
		},
		yOffset = {
			order = 3,
			type = 'range',
			name = L['yOffset'],
			desc = L['An Y offset (in pixels) to be used when anchoring new frames.'],
			min = -500, max = 500, step = 1,		
		},
		size = {
			order = 4,
			type = 'range',
			name = L['Size'],
			min = 4, max = 100, step = 1,
		},
	},
}

local iFilger = E:GetModule('iFilger')
iFilger.db = E.db.iFilger
iFilger.NAMES = {'Cooldowns','ItemCooldowns','Buffs','Procs','Enhancements','Debuffs','TargetDebuffs','FocusBuffs','FocusDebuffs'}

local function GetSelectedSpell()
	if selectedSpell and selectedSpell ~= '' then
		local spell = strmatch(selectedSpell, " %((%d+)%)$") or selectedSpell
		if spell then
			return tonumber(spell) or spell
		end
	end
end

E.Options.args.Watch.args.iFilger = ACH:Group('04.'..E.ValColor..L[iFilger.Title].."|r", iFilger.Description, 4, nil, function(info) return iFilger.db[info[#info]] end, function(info, value) iFilger.db[info[#info]] = value end)
E.Options.args.Watch.args.iFilger.args.Header = ACH:Header(iFilger.Header, 0)
E.Options.args.Watch.args.iFilger.args.Enable = ACH:Toggle(L['Enable'], nil, 1, nil, nil, nil, nil, function(info, value)
	iFilger.db[info[#info]] = value 
	for _, Name in ipairs(iFilger.NAMES) do
		iFilger.db[Name]['Enable'] = value
	end
	if (not iFilger.isEnabled) then iFilger:Initialize() else _G.StaticPopup_Show('PROJECTAZILROKA_RL') end
end)
E.Options.args.Watch.args.iFilger.args.AuthorHeader = ACH:Header(L['Authors:'], 2)
E.Options.args.Watch.args.iFilger.args.Authors = ACH:Description(iFilger.Authors, 3, 'middle')
E.Options.args.Watch.args.iFilger.args.GourpHeader = ACH:Header(L["Group Name"], 4)

for _, Name in ipairs(iFilger.NAMES) do
	E.Options.args.Watch.args.iFilger.args[Name] = {
		type = 'group',
		name = L[Name] or Name,
		get = function(info) return iFilger.db[Name][info[#info]] end,
		set = function(info, value) iFilger.db[Name][info[#info]] = value iFilger:UpdateAll() end,
		childGroups = 'tree',
		args = {
			Enable = {
				type = 'toggle',
				order = 0,
				name = L['Enable'],
			},
			Size = {
				type = 'range',
				order = 1,
				name = L['Icon Size'],
				min = 16, max = 64, step = 1,
			},
			Spacing = {
				type = 'range',
				order = 2,
				name = L['Spacing'],
				min = 1, max = 18, step = 1,
			},
			NumPerRow = {
				type = 'range',
				order = 3,
				name = L['Buttons Per Row'],
				min = 1, max = 24, step = 1,
				hidden = function() return iFilger.db[Name].StatusBar end,
			},
			Direction = {
				name = L['Growth Direction'],
				order = 4,
				type = 'select',
				hidden = function() return iFilger.db[Name].StatusBar end,
				values = {LEFT = L['Left'], RIGHT = L['Right']},
			},
			FilterByList = {
				name = L['Filter by List'],
				order = 5,
				type = 'select',
				hidden = Name == 'Cooldowns',
				values = { None = 'None', Whitelist = L['Whitelist'], Blacklist = L['Blacklist'] },
			},
			IconStack = {
				type = 'group',
				name = L['Stack Counter'],
				order = 10,
				args = {
					StackCountFont = {
						type = 'select', dialogControl = 'LSM30_Font',
						order = 1,
						name = L['Font'],
						values = E.LSM:HashTable('font'),
					},
					StackCountFontSize = {
						type = 'range',
						order = 2,
						name = L['Font Size'],
						min = 8, max = 18, step = 1,
					},
					StackCountFontFlag = {
						name = L["Font Outline"],
						order = 3,
						type = 'select',
						values = C.Values.FontFlags,
					},
				},
			},
			StatusBarGroup = {
				type = 'group',
				name = L['Statusbar'],
				order = 11,
				args = {
					StatusBar = {
						order = 1,
						type = 'toggle',
						name = L['Enable'],
					},
					StatusBarWidth = {
						type = 'range',
						order = 3,
						name = L['Width'],
						min = 1, max = 256, step = 1,
						disabled = function() return not iFilger.db[Name].StatusBar end,
					},
					StatusBarHeight = {
						type = 'range',
						order = 4,
						name = L['Height'],
						min = 1, max = 64, step = 1,
						disabled = function() return not iFilger.db[Name].StatusBar end,
					},
					StatusBarTexture = {
						type = 'select', dialogControl = 'LSM30_Statusbar',
						order = 5,
						name = L['Texture'],
						values = E.LSM:HashTable('statusbar'),
						disabled = function() return not iFilger.db[Name].StatusBar end,
					},
					StatusBarTextureColor = {
						type = 'color',
						order = 6,
						name = L['Colors'],
						hasAlpha = false,
						get = function(info) return unpack(iFilger.db[Name][info[#info]]) end,
						set = function(info, r, g, b, a) iFilger.db[Name][info[#info]] = { r, g, b, a} end,
						disabled = function() return not iFilger.db[Name].StatusBar end,
					},
					StatusBarFont = {
						type = 'select', dialogControl = 'LSM30_Font',
						order = 7,
						name = L['Font'],
						values = E.LSM:HashTable('font'),
						disabled = function() return not iFilger.db[Name].StatusBar end,
					},
					StatusBarFontSize = {
						type = 'range',
						order = 8,
						name = L['Font Size'],
						min = 8, max = 18, step = 1,
						disabled = function() return not iFilger.db[Name].StatusBar end,
					},
					StatusBarFontFlag = {
						name = L["Font Outline"],
						order = 9,
						type = 'select',
						disabled = function() return not iFilger.db[Name].StatusBar end,
						values = C.Values.FontFlags,
					},
					StatusBarDirection = {
						name = L['Growth Direction'],
						order = 10,
						type = 'select',
						disabled = function() return not iFilger.db[Name].StatusBar end,
						values = {
							UP = L['Up'],
							DOWN = L['Down'],
						},
					},
					StatusBarName = {
						type = 'group',
						name = L['Name'],
						order = 11,
						guiInline = true,
						disabled = function() return not iFilger.db[Name].StatusBar end,
						args = {
							StatusBarNameEnabled = {
								order = 1,
								type = 'toggle',
								name = L['Enable'],
							},
							StatusBarNameX = {
								type = 'range',
								order = 2,
								name = L['X Offset'],
								min = -256, max = 256, step = 1,
							},
							StatusBarNameY = {
								type = 'range',
								order = 3,
								name = L['Y Offset'],
								min = -64, max = 64, step = 1,
							},
						},
					},
					StatusBarTime = {
						type = 'group',
						name = L['Time'],
						order = 12,
						guiInline = true,
						disabled = function() return not iFilger.db[Name].StatusBar end,
						args = {
							StatusBarTimeEnabled = {
								order = 1,
								type = 'toggle',
								name = L['Enable'],
							},
							StatusBarTimeX = {
								type = 'range',
								order = 12,
								name = L['X Offset'],
								min = -256, max = 256, step = 1,
							},
							StatusBarTimeY = {
								type = 'range',
								order = 13,
								name = L['Y Offset'],
								min = -64, max = 64, step = 1,
							},
						},
					},
				},
			},
			filterGroup = {
				type = 'group',
				name = L["Filters"],
				order = 12,
				hidden = Name == 'Cooldowns',
				args = {
					selectFilter = {
						order = 2,
						type = 'select',
						name = L["Select Filter"],
						get = function(info) return selectedFilter end,
						set = function(info, value)
							selectedFilter, selectedSpell = nil, nil
							if value ~= '' then
								selectedFilter = value
							end
						end,
						values = { Whitelist = L['Whitelist'], Blacklist = L['Blacklist']},
					},
					filterGroup = {
						type = 'group',
						name = function() return selectedFilter end,
						hidden = function() return not selectedFilter end,
						guiInline = true,
						order = 10,
						args = {
							addSpell = {
								order = 1,
								name = L["Add SpellID"],
								desc = L["Add a spell to the filter."],
								type = 'input',
								get = function(info) return "" end,
								set = function(info, value)
									value = tonumber(value)
									if not value then return end

									local spellName = GetSpellInfo(value)
									selectedSpell = (spellName and value) or nil
									if not selectedSpell then return end

									iFilger.db[Name][selectedFilter][value] = true
								end,
							},
							removeSpell = {
								order = 2,
								name = L["Remove Spell"],
								desc = L["Remove a spell from the filter. Use the spell ID if you see the ID as part of the spell name in the filter."],
								type = 'execute',
								func = function()
									local value = GetSelectedSpell()
									if not value then return end
									selectedSpell = nil

									iFilger.db[Name][selectedFilter][value] = nil;
								end,
							},
							selectSpell = {
								name = L["Select Spell"],
								type = 'select',
								order = 10,
								width = "double",
								get = function(info)
									if not iFilger.db[Name][selectedFilter][selectedSpell] then
										selectedSpell = nil
									end
									return selectedSpell or ''
								end,
								set = function(info, value)
									selectedSpell = (value ~= '' and value) or nil
								end,
								values = function()
									local list = iFilger.db[Name][selectedFilter]
									if not list then return end
									wipe(spellList)

									for filter in pairs(list) do
										local spellName = tonumber(filter) and GetSpellInfo(filter)
										local name = (spellName and format("%s |cFF888888(%s)|r", spellName, filter)) or tostring(filter)
										spellList[filter] = name
									end

									if not next(spellList) then
										spellList[''] = L["None"]
									end

									return spellList
								end,
							},
						},
					},
					resetFilter = {
						order = 2,
						type = "execute",
						name = L["Reset Filter"],
						desc = L["This will reset the contents of this filter back to default. Any spell you have added to this filter will be removed."],
						confirm = true,
						func = function(info) wipe(iFilger.db[Name][selectedFilter]) selectedSpell = nil end,
					},
					spellGroup = {
						type = "group",
						name = function()
							local spell = GetSelectedSpell()
							local spellName = spell and GetSpellInfo(spell)
							return (spellName and spellName..' |cFF888888('..spell..')|r') or spell or ' '
						end,
						hidden = function() return not GetSelectedSpell() end,
						order = -15,
						guiInline = true,
						args = {
							enabled = {
								name = L["Enable"],
								order = 0,
								type = 'toggle',
								get = function(info)
									local spell = GetSelectedSpell()
									if not spell then return end

									return iFilger.db[Name][selectedFilter][spell]
								end,
								set = function(info, value)
									local spell = GetSelectedSpell()
									if not spell then return end

									iFilger.db[Name][selectedFilter][spell] = value
								end,
							},
						},
					}
				},
			}
		},
	}
end

E.Options.args.Watch.args.iFilger.args.Cooldowns.args.UpdateSpeed = ACH:Range(L['Update Speed'], nil, 5, { min = .1, max = .5, step = .1 })
E.Options.args.Watch.args.iFilger.args.ItemCooldowns.args.UpdateSpeed = ACH:Range(L['Update Speed'], nil, 5, { min = .1, max = .5, step = .1 })

E.Options.args.Watch.args.iFilger.args.Cooldowns.args.SuppressDuration = ACH:Range(L['Suppress Duration Threshold'], L['Duration in Seconds'], 6, { min = 2, max = 600, step = 1 })
E.Options.args.Watch.args.iFilger.args.Cooldowns.args.IgnoreDuration = ACH:Range(L['Ignore Duration Threshold'], L['Duration in Seconds'], 7, { min = 2, max = 600, step = 1 })

E.Options.args.Watch.args.iFilger.args.Cooldowns.args.Spells = ACH:Group(_G.SPELLS, nil, 12, nil, function(info) return iFilger.db.Cooldowns.SpellCDs[tonumber(info[#info])] end, function(info, value) iFilger.db.Cooldowns.SpellCDs[tonumber(info[#info])] = value end)
E.Options.args.Watch.args.iFilger.args.Cooldowns.args.Spells.args = iFilger:GenerateSpellOptions()