local AddName, Ns = ...
local L = Ns.L


------------------------------
--		Stat Options		--
------------------------------
local Both, Enhanced, Base, Damage, DamageTaken, Melee, Ranged, World, Realm, Equipped, Overall, Level, Honor, Max, Live, Enchanted, Ingenuity = 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 2
local Percentage, Rating, MainHand, OffHand, SameLevel, BossLevel, Regen, Casting, Critical, CritDamage, Average, Low, Static, Normal, Shadowflame = 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 3, 2, 1, 1
local Season, Expansion, Spark, Splinter, Gigantic, Plump, Current, Earned, Empty, Vintage = 1, 2, 1, 2, 1, 2, 1, 2, 1, 2

Ns.ConfigWidth = 975
Ns.ConfigHeight = 540
if GetLocale() == "frFR" or GetLocale() == "zhCN" or GetLocale() == "zhTW" or GetLocale() == "koKR" then
	Ns.ConfigWidth = 960
end

--local honorIcon = 73824
--local faction = UnitFactionGroup("player")
--if faction == "Horde" then honorIcon = 59641 end

------------------------------
--		Global Updater		--
------------------------------
function Ns.MeleeUpdate() end
function Ns.DefenseUpdate() end
function Ns.RangedUpdate() end
function Ns.SpellUpdate() end

------------------------------
--		Display Order		--
------------------------------
Ns.DefaultOrder = { -- grp = SpellClass, options order = display order, ["on"]/["off"] option is implied in all stats so not required in the table. The [1]..[2] not required but just for example
{ stat="AP", onupdate=true, events={}, spell=29834, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, activeonload=true, },
{ stat="RAP", onupdate=true, events={}, spell=34497, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, activeonload=true, },
{ stat="DMG", onupdate=true, events={}, spell=29801, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="mDPS", onupdate=true, events={}, spell=29623, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="RDMG", onupdate=true, events={}, spell=34482, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="rDPS", onupdate=true, events={}, spell=36554, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Fire", onupdate=true, events={}, updatespeed=1, spell=34293, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, activeonload=true, },
{ stat="Frost", onupdate=true, events={}, spell=31674, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, },
{ stat="Arcane", onupdate=true, events={}, spell=31571, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Shadow", onupdate=true, events={}, spell=30293, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, },
{ stat="Nature", onupdate=true, events={}, spell=16578, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Healing", onupdate=true, events={}, spell=26022, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Holy", onupdate=true, events={}, spell=31837, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Crit", onupdate=true, events={}, spell=29859, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="CritBoss", onupdate=true, events={}, spell=27140, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="CritCap", onupdate=true, events={}, spell=30819, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="RangedCrit", onupdate=true, events={}, spell=34506, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="RangedCritBoss", onupdate=true, events={}, spell=33851, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="SpellCrit", onupdate=true, events={}, spell=30288, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="SpellCritBoss", onupdate=true, events={}, spell=17917, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Hit", onupdate=true, events={}, spell=31241, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="RangedHit", onupdate=true, events={}, spell=34485, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="SpellHit", onupdate=true, events={}, spell=34935, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="HasteMelee", onupdate=true, events={}, spell=31244, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="weaponSpeed", onupdate=true, events={}, spell=30664, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="HasteRanged", onupdate=true, events={}, spell=23989, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="rangedSpeed", onupdate=true, events={}, spell=34948, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="HasteCaster", onupdate=true, events={}, spell=30060, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, },
{ stat="ArmorPenetration", onupdate=true, events={}, spell=26866, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="BossReduc", onupdate=true, events={}, spell=20164, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, },
{ stat="Expertise", onupdate=true, events={}, spell=30920, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="MeleeMiss", onupdate=true, events={}, spell=1329, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, Level_Same_Boss=true, }, subgroup=true },
{ stat="Avoidance", onupdate=true, events={}, spell=31223, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, activeonload=true, },
{ stat="Crushing", onupdate=true, events={}, spell=32175, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="CritReceived", onupdate=true, events={}, spell=33856, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="RangedMiss", onupdate=true, events={}, spell=34460, spellclass="Ranged", widget={ type="CheckBox" }, options={ Show=true, Level_Same_Boss=true, }, subgroup=true },
{ stat="SpellPenetration", onupdate=true, events={}, spell=11242, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="SpellMiss", onupdate=true, events={}, spell=30108, spellclass="Spell", widget={ type="CheckBox" }, options={ Show=true, Level_Same_Boss=true, }, subgroup=true },
{ stat="ManaRegen", onupdate=true, events={}, spell=31833, spellclass="Spell", widget={ type="CheckBox" }, options={ Regen_Normal_Casting=true, }, subgroup=true },
{ stat="MP5", onupdate=true, events={}, spell=34861, spellclass="Spell", widget={ type="CheckBox" }, options={ Regen_Normal_Casting=true, }, subgroup=true, },
{ stat="Resilience", onupdate=true, events={}, spell=29623, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Armor", onupdate=true, events={}, spell=29140, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="NPCArmor", onupdate=true, events={}, spell=44520, spellclass="Melee", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="DMGReduc", onupdate=true, events={}, spell=871, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true }, subgroup=true },
{ stat="Defense", onupdate=true, events={}, spell=32700, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true }, subgroup=true },
{ stat="Dodge", onupdate=true, events={}, spell=13981, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Parry", onupdate=true, events={}, spell=3127, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true }, subgroup=true },
{ stat="Block", onupdate=true, events={}, spell=2565, spellclass="Defense", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="FireResist", events={ UNIT_RESISTANCES={ "player", }, }, spell=18459, spellclass="Resistance", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, activeonload=true, },
{ stat="FrostResist", events={ UNIT_RESISTANCES={ "player", }, }, spell=31667, spellclass="Resistance", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="ShadowResist", events={ UNIT_RESISTANCES={ "player", }, }, spell=30283, spellclass="Resistance", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="ArcaneResist", events={ UNIT_RESISTANCES={ "player", }, }, spell=16850, spellclass="Resistance", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="NatureResist", events={ UNIT_RESISTANCES={ "player", }, }, spell=30675, spellclass="Resistance", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Speed", onupdate=true, events={}, spell=31641, spellclass="Misc", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true, activeonload=true, },
{ stat="TargetSpeed", onupdate=true, events={}, spell=31641, spellclass="Misc", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Durability", events={ UPDATE_INVENTORY_DURABILITY=true, }, spell=3100, spellclass="Misc", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="BuffCounter", onupdate=true, events={}, spell=22888, spellclass="Misc", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="DebuffCounter", onupdate=true, events={}, spell=23154, spellclass="Misc", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="Lag", onupdate=true, events={}, spell=33592, spellclass="Misc", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
{ stat="FPS", onupdate=true, events={}, spell=19498, spellclass="Misc", widget={ type="CheckBox" }, options={ Show=true }, subgroup=true },
{ stat="Money", onupdate=true, events={}, spell=921, spellclass="Misc", widget={ type="CheckBox" }, options={ Show=true, }, subgroup=true },
}

------------------------------
--		Global Events		--
------------------------------
Ns.GlobalEvents = {
	UNIT_AURA={ "player", "target", },
	UNIT_INVENTORY_CHANGED={ "player", },
	UNIT_STATS={ "player", },
	UPDATE_INVENTORY_DURABILITY=true,
	UPDATE_FACTION=true,
	BIND_ENCHANT=true,
	CHARACTER_POINTS_CHANGED=true,
	PLAYER_LEVEL_UP=true,
	PLAYER_TARGET_CHANGED=true,
	REPLACE_ENCHANT=true,
	GET_ITEM_INFO_RECEIVED=true,
	TRAIT_CONFIG_UPDATED=true,
	MASTERY_UPDATE=true,
	UNIT_RESISTANCES={ "player", },
	UNIT_DAMAGE=true,
	UNIT_RANGEDDAMAGE=true,
	UNIT_ATTACK_POWER=true,
	UNIT_RANGED_ATTACK_POWER=true,
	UNIT_DEFENSE={ "player", },
	BAG_CLOSED=true,
	COMBAT_LOG_EVENT_UNFILTERED=true,
}

------------------------------
--		Settings Groups		--
------------------------------

Ns.SpellClass = {
	[0] = { stat="Settings", grp=Ns.SettingsGroupOrder, order=Ns.SettingsDisplayOrder, icon="Settings", },
	[1] = { stat="Layout", grp=Ns.LayoutGroupOrder, order=Ns.LayoutDisplayOrder, icon="Layout", },
	[2] = { stat="Events", grp=Ns.EventsGroupOrder, order=Ns.EventsDisplayOrder, icon="Events", },
	[3] = { stat="Profiles", grp=Ns.ProfileGroupOrder, order=Ns.ProfileDisplayOrder, icon="Profiles", },
	[4] = { stat="", },
	[5] = { stat="Search", icon="Search", },
	[6] = { stat="Melee", icon="Physical", },
	[7] = { stat="Defense", icon="Defense", },
	[8] = { stat="Ranged", icon="Ranged", },
	[9] = { stat="Spell", icon="Spell", },
	[10] = { stat="Resistance", icon="Resistance", },
	[11] = { stat="Misc", icon="Miscs", },
	[12] = { stat="", },
	[13] = { stat="FAQ", icon="Misc", },
}

------------------------------
--		Stat Options		--
------------------------------
Ns.Options = {
	{ stat="Show", widget={ type="CheckBox", } },
	{ stat="CustName", widget={ type="EditBox", width=100, height=20, numeric=false, }, tooltip=true, },
	{ stat="Level_Same_Boss", spellclass="Level_Same_Boss", widget={ type="Radio", }, tooltip=true, default=1, labels={ "SameLevel", "BossLevel", "Both"}, newline=true },
	{ stat="Regen_Normal_Casting", spellclass="Regen_Normal_Casting", widget={ type="Radio", }, tooltip=true, default=1, labels={ "Regen", "Casting", "Both"}, newline=true },

	-- caps
	{ stat="Cap_Percent", spellclass="Cap_Percent", default=100, tooltip=true, widget={ type="EditBox", width=60, height=20, numeric=true, format="%.2f%%", }, },
	{ stat="Cap_Rating", spellclass="Cap_Rating", default=0, tooltip=true, widget={ type="EditBox", width=60, height=20, numeric=true, format="%.2f", }, },
	{ stat="Editbox_D", spellclass="Editbox_D", default=8, tooltip=true, widget={ type="EditBox", width=60, height=20, numeric=true, format="%.0f", }, newline=true, },
	{ stat="Display_Delves", spellclass="Display_Delves", widget={ type="CheckBox", }, tooltip=false, default=false, labels={ "Display_Delves"}, },

	{ stat="ColorCustom", default=false, widget={ type="CheckBox", }, linked={ "ColorName", false, "ColorClass", false, "ColorValue", false, "ColorValueEndable", false, }, onclick="InitCustomColors", newline=true },
	{ stat="ColorName", default={ r=1, g=1, b=1, }, widget={ type="ColorPicker", }, },
	{ stat="ColorClass", default=false, widget={ type="CheckBox", }, },
	{ stat="ColorValueEndable", default=false, widget={ type="CheckBox", }, linked={ "ColorValue", false, }, newline=true },
	{ stat="ColorValue", default={ r=1, g=1, b=1, }, widget={ type="ColorPicker", }, },
}

--------------------------
--		Class & ID		--
--------------------------
Ns.byPlayerClass = {
--10.0 DF
	["EVOKER"] = 13,
--7.0 Legion
	["DEMONHUNTER"] = 12,
--5.0 Pandaria
	["MONK"] = 10,
--3.0 Wrath
	["DEATHKNIGHT"] = 6,
--1.0 Classic
	["DRUID"] = 11,
	["HUNTER"] = 3,
	["MAGE"] = 8,
	["PALADIN"] = 2,
	["PRIEST"] = 5,
	["ROGUE"] = 4,
	["SHAMAN"] = 7,
	["WARLOCK"] = 9,
	["WARRIOR"] = 1,
}

------------------------------
--		Class defaults		--
------------------------------
function Ns:GetClassDefaults(class)
	local defaults = {

--1.0 Classic
		DRUID = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Mastery = true,
			AP = true,
			SpellPower = true,
			Intellect = true,
			ManaRegen = true,
			EnergyRegen = true,
			Speed = true,
			Durability = true,
		},
		HUNTER = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Agility = true,
			Mastery = true,
			AP = true,
			Speed = true,
			Durability = true,
		},
		MAGE = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Mastery = true,
			Intellect = true,
			SpellPower = true,
			ManaRegen = true,
			Speed = true,
			Durability = true,
		},
		PALADIN = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Mastery = true,
			Intellect = true,
			ManaRegen = true,
			Healing = true,
			Speed = true,
			Durability = true,
		},
		PRIEST = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Mastery = true,
			Intellect = true,
			ManaRegen = true,
			SpellPower = true,
			Healing = true,
			Speed = true,
			Durability = true,
		},
		ROGUE = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Mastery = true,
			Agility = true,
			AP = true,
			EnergyRegen = true,
			Dodge = true,
			Speed = true,
			Durability = true,
		},
		SHAMAN = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Mastery = true,
			Intellect = true,
			ManaRegen = true,
			SpellPower = true,
			Healing = true,
			Speed = true,
			Durability = true,
		},
		WARLOCK = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Mastery = true,
			Intellect = true,
			SpellPower = true,
			Speed = true,
			Durability = true,
		},
		WARRIOR = {
			Haste = true,
			Versatility = true,
			CritChance = true,
			Mastery = true,
			Strength = true,
			AP = true,
			Armor = true,
			Block = true,
			Dodge = true,
			Speed = true,
			Durability = true,
		},
	}
	return class and defaults[strupper(class)] or defaults
end