--[[--------------------------------------------------------------------------
	Boom - Modern Healing & Support Raid Frames
	Core/Defaults.lua

	THE PROFILE SCHEMA. This table is the single source of truth for every
	setting in the addon. Config.lua deep-copies it into new profiles and
	back-fills missing keys into existing ones on load, so adding a key here is
	all that is required to ship a new option.

	Read settings as  Boom.profile.<section>.<key>  from anywhere.
	Never write to Boom.profile directly from UI code - go through
	Boom.Config:Set("section.key", value) so listeners fire.
----------------------------------------------------------------------------]]

local ADDON_NAME, Boom = ...

--------------------------------------------------------------------------------
-- Which language a BRAND NEW profile starts in
--
-- Taken from the client, not hardcoded. This addon was written in Turkish first
-- and used to default to it outright, which is correct for one author and wrong
-- for everybody else: there is no Turkish WoW client, so that default reached
-- every new user in the world regardless of what language they play in.
--
-- Only languages Boom actually has a table for are accepted; anything else gets
-- English, whose strings are the translation keys themselves and are therefore
-- always complete. Existing profiles keep whatever they already saved - Config
-- only back-fills keys that are missing.
--------------------------------------------------------------------------------

local function defaultLocale()
	local client = GetLocale and GetLocale() or "enUS"
	-- Core/Locale.lua loads before this file, so LOCALES is already populated.
	if Boom.LOCALES and Boom.LOCALES[client] then return client end
	return "enUS"
end

--------------------------------------------------------------------------------
-- Shared sub-schemas
--------------------------------------------------------------------------------

-- Every visual layout ("party", "raid", "pet", "maintank") uses this shape.
local function layoutDefaults(overrides)
	local t = {
		enabled       = true,

		-- Anchor of the whole panel on screen.
		point         = "CENTER",
		relativePoint = "CENTER",
		x             = 0,
		y             = 0,
		scale         = 1.0,

		-- Unit button geometry.
		width         = 90,
		height        = 44,
		spacingX      = 3,
		spacingY      = 3,

		-- Growth. "RIGHT_DOWN" means units fill rightwards, new columns downwards.
		-- Valid: RIGHT_DOWN, RIGHT_UP, LEFT_DOWN, LEFT_UP,
		--        DOWN_RIGHT, DOWN_LEFT, UP_RIGHT, UP_LEFT
		growth        = "DOWN_RIGHT",

		-- How many units before a new column/row starts. 5 = one raid group each.
		unitsPerColumn = 5,
		maxColumns     = 8,

		-- Sorting. "GROUP" | "CLASS" | "ROLE" | "NAME" | "INDEX"
		sortMode       = "GROUP",
		-- Order used when sortMode is ROLE or CLASS.
		roleOrder      = "TANK,HEALER,DAMAGER",
		reverseOrder   = false,
		keepGroupsTogether = true,

		-- Which raid groups to display (raid layout only).
		groupFilter    = { true, true, true, true, true, true, true, true },

		showPlayer     = true,
		showSolo       = false,
		showPets       = false,

		-- Fade the whole panel when not in combat.
		combatFadeAlpha = 1.0,
	}

	if overrides then
		for k, v in pairs(overrides) do t[k] = v end
	end
	return t
end

-- Every indicator uses this shape plus its own extras.
local function indicator(point, x, y, extras)
	local t = {
		enabled = true,
		point   = point or "CENTER",
		x       = x or 0,
		y       = y or 0,
	}
	if extras then
		for k, v in pairs(extras) do t[k] = v end
	end
	return t
end

--------------------------------------------------------------------------------
-- The default profile
--------------------------------------------------------------------------------

Boom.defaults = {

	schemaVersion = 1,

	----------------------------------------------------------------------------
	general = {
		locale            = defaultLocale(),   -- "enUS" | "trTR"
		lockFrames        = true,
		hideBlizzardRaid  = true,
		hideBlizzardParty = true,
		-- The pull-out tab on the left edge of the screen, not a unit frame. It
		-- carries raid markers, ready check and the role poll, all of which stay
		-- useful after Boom replaces the frames it configures - so hiding it is
		-- opt-in, unlike the frames themselves.
		hideBlizzardRaidManager = false,
		showTooltips      = true,
		tooltipsInCombat  = false,
		-- Specialization portraits in the setup wizard and the options window.
		showSpecArt       = true,
		clickThroughWhenLocked = false,
		testMode          = false,
	},

	----------------------------------------------------------------------------
	layouts = {
		party    = layoutDefaults({ unitsPerColumn = 5,  maxColumns = 1, growth = "DOWN_RIGHT", showSolo = false, width = 110, height = 52, x = -320, y = -120 }),
		raid     = layoutDefaults({ unitsPerColumn = 5,  maxColumns = 8, growth = "DOWN_RIGHT", x = -320, y = 0 }),
		pet      = layoutDefaults({ enabled = false, unitsPerColumn = 5, maxColumns = 8, width = 70, height = 26, x = -320, y = -260 }),
		maintank = layoutDefaults({ enabled = false, unitsPerColumn = 4, maxColumns = 1, width = 110, height = 40, x = -560, y = 0 }),
	},

	----------------------------------------------------------------------------
	appearance = {
		-- Media keys resolved through Boom.Media.
		barTexture   = "Boom Flat",
		bgTexture    = "Boom Flat",
		font         = "Boom Default",
		fontSize     = 12,
		fontOutline  = "OUTLINE",   -- "NONE" | "OUTLINE" | "THICKOUTLINE"

		borderSize   = 1,
		borderColor  = { 0.05, 0.05, 0.07, 1 },

		-- Health bar fill colour. "class" | "static" | "gradient" (green->red by hp)
		healthColorMode  = "class",
		staticHealthColor = { 0.15, 0.75, 0.35, 1 },
		-- Colour of the empty part of the bar. "dark" | "class" | "custom"
		backgroundColorMode = "dark",
		backgroundColor  = { 0.09, 0.09, 0.11, 1 },
		-- Multiplier applied to the class colour when backgroundColorMode == "class".
		backgroundClassMultiplier = 0.22,

		-- "HORIZONTAL" | "VERTICAL"
		barOrientation = "HORIZONTAL",
		-- Fill from LEFT / RIGHT / TOP / BOTTOM.
		barFillDirection = "LEFT",

		-- Subtle top-to-bottom gloss over the health bar. Purely cosmetic.
		gradientOverlay        = true,
		gradientOverlayAlpha   = 0.18,

		-- Alpha applied to the whole button.
		alphaOutOfRange = 0.40,
		alphaDead       = 0.65,
		alphaOffline    = 0.50,

		-- Shadow drawn behind each button for depth.
		dropShadow      = true,
		dropShadowAlpha = 0.55,

		-- Accent colour used across the options UI and highlights.
		accentColor = { 0.00, 0.83, 1.00, 1 },
	},

	----------------------------------------------------------------------------
	powerBar = {
		enabled       = true,
		height        = 4,
		position      = "BOTTOM",   -- "BOTTOM" | "RIGHT"
		onlyManaUsers = true,       -- hide for rage/energy/fury classes
		onlyGroupHealers = false,   -- show only for other healers
		colorByType   = true,
	},

	----------------------------------------------------------------------------
	indicators = {
		name = indicator("TOP", 0, -2, {
			fontSize    = 12,
			outline     = "OUTLINE",
			maxLength   = 8,
			classColor  = true,
			color       = { 1, 1, 1, 1 },
			hideInVehicle = false,
		}),

		healthText = indicator("BOTTOM", 0, 2, {
			fontSize   = 11,
			outline    = "OUTLINE",
			-- "none" | "percent" | "deficit" | "current" | "current_percent"
			format     = "deficit",
			hideAtFull = true,
			color      = { 0.85, 0.85, 0.85, 1 },
		}),

		statusText = indicator("CENTER", 0, 0, {
			fontSize = 12,
			outline  = "OUTLINE",
			color    = { 1, 0.35, 0.35, 1 },
		}),

		-- Your own heal-over-time effects, as small square icons.
		hots = indicator("TOPLEFT", 2, -2, {
			size          = 14,
			max           = 5,
			direction     = "RIGHT",     -- RIGHT | LEFT | DOWN | UP
			spacing       = 1,
			onlyMine      = true,
			showDuration  = true,
			showStacks    = true,
			durationFontSize = 9,
			-- Tint the icon border when the HoT is about to expire.
			expiryWarning = 3,
		}),

		-- Debuff you can personally remove. Deliberately loud.
		dispel = indicator("CENTER", 0, 0, {
			size            = 20,
			highlightBorder = true,
			borderThickness = 2,
			showIcon        = true,
			glow            = true,
			showCooldown    = true,
		}),

		-- Important / boss debuffs.
		debuffs = indicator("BOTTOMRIGHT", -2, 2, {
			size         = 16,
			max          = 3,
			direction    = "LEFT",
			spacing      = 1,
			showDuration = true,
			showStacks   = true,
			onlyImportant = true,   -- use the curated list + boss auras
			bossAuraScale = 1.35,
		}),

		-- Absorb / shield application (Power Word: Shield, Life Cocoon, ...).
		shield = indicator("TOPRIGHT", -2, -2, {
			size = 14,
			showAmount = true,
		}),

		-- A big obvious icon when someone has a defensive external on them.
		externals = indicator("RIGHT", -2, 0, {
			size = 22,
			showDuration = true,
		}),

		-- Augmentation / support buffs you applied (Ebon Might, Prescience...).
		support = indicator("LEFT", 2, 0, {
			size = 18,
			showDuration = true,
			max = 3,
			direction = "DOWN",
			spacing = 1,
			-- Pulse the icon when the buff is about to fall off.
			expiryWarning = 4,
		}),

		roleIcon   = indicator("TOPLEFT",  1, -1, { size = 12, hideDamager = true }),
		leaderIcon = indicator("TOPRIGHT", -1, -1, { size = 12 }),
		raidTarget = indicator("TOP", 0, -1, { size = 16, alpha = 0.9 }),
		readyCheck = indicator("CENTER", 0, 0, { size = 22 }),
		resurrect  = indicator("CENTER", 0, 8, { size = 20 }),
		summon     = indicator("CENTER", 0, 8, { size = 20 }),

		-- Blizzard-managed private auras (encounter mechanics only the player sees).
		privateAuras = indicator("BOTTOM", 0, 14, { size = 20, max = 2, showCountdownFrame = true, showCountdownNumbers = true }),

		aggro = indicator("CENTER", 0, 0, {
			mode = "border",           -- "border" | "healthColor" | "glow" | "off"
			thickness = 2,
			onlyTanks = false,
		}),

		targetHighlight   = indicator("CENTER", 0, 0, { color = { 1, 1, 1, 0.9 }, thickness = 2 }),
		mouseoverHighlight= indicator("CENTER", 0, 0, { color = { 1, 1, 1, 0.35 } }),

		-- Bar overlays.
		incomingHeal = indicator("CENTER", 0, 0, { alpha = 0.35, color = { 0.4, 1.0, 0.5, 1 }, maxOverflow = 1.05 }),
		absorb       = indicator("CENTER", 0, 0, { alpha = 0.55, color = { 0.7, 0.85, 1.0, 1 }, showOverAbsorbGlow = true }),
		healAbsorb   = indicator("CENTER", 0, 0, { alpha = 0.60, color = { 0.9, 0.2, 0.2, 1 } }),
	},

	----------------------------------------------------------------------------
	range = {
		enabled       = true,
		updateInterval= 0.20,
		-- "spell" uses your spec's actual healing range, "default" uses 40yd.
		mode          = "spell",
	},

	----------------------------------------------------------------------------
	auras = {
		-- Additional spell IDs to always show as important debuffs.
		extraImportant = {},
		-- Spell IDs never to show.
		blacklist      = {},
		-- Additional buffs to watch on allies (spellID -> true).
		buffWatch      = {},
		-- Additional HoTs to treat as "mine" (spellID -> true).
		extraHots      = {},

		showBossAuras   = true,
		showOnlyDispellable = false,
	},

	----------------------------------------------------------------------------
	clickcast = {
		enabled     = true,
		-- Deliberately an explicit boolean rather than "follow the
		-- ActionButtonUseKeyDown CVar". Click-casting should behave the same way
		-- every time regardless of the user's action bar preference, and a
		-- tri-state that a checkbox cannot represent only ever confuses.
		useKeyDown  = false,
		-- Do not fire bindings while the frame is being dragged/unlocked.
		disableWhenUnlocked = true,

		-- key -> binding.  key format: "[alt-][ctrl-][shift-]<button 1..5>"
		-- binding = { type = "spell",  id = 17,  ground = false }
		--         | { type = "macro",  text = "/cast [@mouseover] Foo" }
		--         | { type = "target" } | { type = "focus" } | { type = "assist" }
		--         | { type = "menu" }   | { type = "none" }
		bindings = {
			["1"] = { type = "target" },
			["2"] = { type = "menu"   },
		},
	},

	----------------------------------------------------------------------------
	support = {
		enabled            = true,
		-- Show a panel listing allies missing your support buff.
		missingBuffAlert   = true,
		-- Track defensive externals cast on group members by anyone.
		trackExternals     = true,
		-- Track raid cooldown availability of your group (Innervate, battle res...).
		trackRaidCooldowns = true,
		-- Extra ally buffs to track (spellID -> true).
		extraTracked       = {},

		cooldownBar = {
			enabled = true,
			point         = "CENTER",
			relativePoint = "CENTER",
			x       = 0,
			y       = 260,
			iconSize= 28,
			maxIcons= 12,
			growth  = "RIGHT",
			showOnlyReady = false,
		},
	},

}

--------------------------------------------------------------------------------
-- Global (account-wide, not per profile) defaults.
--------------------------------------------------------------------------------

Boom.globalDefaults = {
	minimap    = { hide = false, minimapPos = 205 },
	firstRun   = true,
	debugMode  = false,
	lastVersion= nil,
}
