local ADDON_NAME, ns = ...
ns = ns or {}
local Util = ns.Util

local Const = {}
ns.Const = Const

Const.ADDON_NAME = ADDON_NAME
Const.PANEL_NAME = "ACAU_MainPanel"
Const.TOP5_NAME = "ACAU_Top5"

Const.DEFAULTS = {
    threshold = 80,
    filterMode = "All",
    parseSpeed = "Auto",
    sortMode = "Percent Desc.",
    theme = "Modern",
    themeAlpha = 1,
    remixModeEnabled = false,
    remixAutoApply = true,
    customTheme = {
        bgColor = { 0.06, 0.06, 0.06, 0.94 },
        borderColor = { 0.22, 0.22, 0.22, 1 },
        textPrimary = { 1, 0.82, 0 },
        textSecondary = { 0.9, 0.9, 0.9 },
        accent = { 1, 0.78, 0.2 },
        accentAlt = { 0.55, 0.78, 1 },
    },
    toggleWithAchievementFrame = true,
    detached = true,
    collapsed = false,
    manualScanOnly = false,
    cacheTTL = 300,
    panelHidden = false,
    viewState = {
        filtersOpen = false,
        ignoredOpen = false,
        metaOpen = false,
        metaMode = "landing",
        metaSelectedID = nil,
    },
    metaTopOverride = nil,
    metaTopOverrideName = nil,
    top5 = {
        shown = false,
        locked = false,
        clickThrough = false,
        alpha = 0.9,
        point = nil,
        applyTheme = true,
    },
}

Const.CATEGORY_DEFAULTS = {
    ["Characters"] = true, ["Quests"] = true, ["Exploration"] = true,
    ["Delves"] = true, ["Player vs. Player"] = true, ["Dungeons & Raids"] = true,
    ["Reputation"] = true, ["Pet Battles"] = true, ["Collections"] = true,
    ["Expansion Features"] = true, ["Legion: Remix"] = true,
    ["ProfessionsMode"] = "Learned",
    ["WorldEventsMode"] = "Active",
}

Const.EXPANSION_LIST = {
    "The War Within",
    "Midnight",
    "The Last Titan",
    "Dragonflight",
    "Shadowlands",
    "Battle for Azeroth",
    "Legion",
    "Warlords of Draenor",
    "Mists of Pandaria",
    "Cataclysm",
    "Wrath of the Lich King",
    "The Burning Crusade",
    "Classic",
}

Const.EXPANSION_DEFAULTS = {
    ["Classic"] = false,
    ["The Burning Crusade"] = false,
    ["Wrath of the Lich King"] = false,
    ["Cataclysm"] = false,
    ["Mists of Pandaria"] = false,
    ["Warlords of Draenor"] = false,
    ["Legion"] = false,
    ["Battle for Azeroth"] = false,
    ["Shadowlands"] = false,
    ["Dragonflight"] = false,
    ["The War Within"] = false,
    ["Midnight"] = false,
}

Const.SPEED_PRESETS = {
    Auto   = { batch = 0, delay = 0 },
    Fast   = { batch = 50, delay = 0.010 },
    Smooth = { batch = 20, delay = 0.025 },
    Slow   = { batch = 8,  delay = 0.040 },
}

Const.SORT_LIST = {
    "Percent Desc.",
    "Percent Asc.",
    "Name Asc.",
    "Name Desc.",
    "Points Desc.",
    "Points Asc.",
}

Const.FILTER_LIST = {
    "All",
    "Any reward",
    "Mount",
    "Pet",
    "Title",
    "Infinite Knowledge",
    "Bronze Cache",
    "Decor",
    "Toy",
    "Appearance",
    "Tabard",
    "Illusion",
    "Drake Customization",
    "Warband Campsite",
    "Other",
}

Const.REWARD_MATCHERS = {
    ["All"] = function() return true end,
    ["Any reward"] = function(r) return Util:SanitizeReward(r) ~= "" end,
    ["Mount"] = function(r) return Util:RewardMatches(r, { "Mount" }) end,
    ["Pet"] = function(r) return Util:RewardMatches(r, { "Pet" }) end,
    ["Title"] = function(r) return Util:RewardMatches(r, { "Title" }) end,
    ["Infinite Knowledge"] = function(r) return Util:RewardMatches(r, { "Infinite Knowledge", "Pouch of Infinite Knowledge" }) end,
    ["Bronze Cache"] = function(r) return Util:RewardMatches(r, { "Bronze Cache", "Greater Bronze Cache", "Lesser Bronze Cache", "Minor Bronze Cache" }) end,
    ["Decor"] = function(r) return Util:RewardMatches(r, { "Decor" }) end,
    ["Toy"] = function(r) return Util:RewardMatches(r, { "Toy", "Toy:" }) end,
    ["Appearance"] = function(r) return Util:RewardMatches(r, { "Appearance", "Transmog" }) end,
    ["Tabard"] = function(r) return Util:RewardMatches(r, { "Tabard" }) end,
    ["Illusion"] = function(r) return Util:RewardMatches(r, { "Illusion", "Illusion:" }) end,
    ["Drake Customization"] = function(r) return Util:RewardMatches(r, { "Drake Customization" }) end,
    ["Warband Campsite"] = function(r) return Util:RewardMatches(r, { "Campsite" }) end,
    ["Other"] = function(r)
        local s = Util:SanitizeReward(r)
        if s == "" then return false end
        local known = { "Mount","Title","Pet","Toy","Appearance","Transmog","Tabard","Drake Customization","Decor","Campsite","Bronze Cache","Greater Bronze Cache","Lesser Bronze Cache","Minor Bronze Cache","Infinite Knowledge","Illusion" }
        for _, k in ipairs(known) do
            if Util:RewardMatches(s, { k }) then return false end
        end
        return true
    end,
}

Const.EVENTS = {
    AddonLoaded = "ADDON_LOADED",
    PlayerLogin = "PLAYER_ENTERING_WORLD",
    AchEarned   = "ACHIEVEMENT_EARNED",
}

Const.REMIX_SEASON_ID = 2
Const.REMIX_THEME = "Fel Remix"
Const.REMIX_CATEGORY = "Legion: Remix"
Const.REMIX_EXPANSION = "Legion"
