---@class CerebroAddon
local Cerebro = LibStub("AceAddon-3.0"):GetAddon("Cerebro")

-------------------------------------------------------------------------------
-- PrepCheckDB: Item ID database for raid preparation validation
-- Organized by patch version ΓåÆ category ΓåÆ slot/type
-- Used to validate gems, enchants, and consumables via ID-based lookup
-- instead of fragile tooltip scanning.
--
-- All tables use [itemID] = true for fast set-membership checks.
-- Item names are preserved in comments for maintainability.
-------------------------------------------------------------------------------

Cerebro.PrepCheckDB = {
    ---------------------------------------------------------------------------
    -- Midnight (Patch 12.0)
    ---------------------------------------------------------------------------
    ["12.0"] = {

        -----------------------------------------------------------------------
        -- GEMS
        -- All are Flawless quality (highest tier), Prismatic, iLvl 295
        -----------------------------------------------------------------------
        gems = {
            -- Peridot Family (Primary: Haste)
            [240888] = true, -- Flawless Quick Peridot           (+14 Haste)
            [240890] = true, -- Flawless Deadly Peridot          (+12 Haste, +5 Crit)
            [240892] = true, -- Flawless Masterful Peridot       (+12 Haste, +5 Mastery)
            [240894] = true, -- Flawless Versatile Peridot       (+12 Haste, +5 Versatility)

            -- Amethyst Family (Primary: Mastery)
            [240896] = true, -- Flawless Masterful Amethyst      (+14 Mastery)
            [240898] = true, -- Flawless Deadly Amethyst         (+12 Mastery, +5 Crit)
            [240900] = true, -- Flawless Quick Amethyst          (+12 Mastery, +5 Haste)
            [240902] = true, -- Flawless Versatile Amethyst      (+12 Mastery, +5 Versatility)

            -- Garnet Family (Primary: Critical Strike)
            [240904] = true, -- Flawless Deadly Garnet           (+14 Crit)
            [240906] = true, -- Flawless Quick Garnet            (+12 Crit, +5 Haste)
            [240908] = true, -- Flawless Masterful Garnet        (+12 Crit, +5 Mastery)
            [240910] = true, -- Flawless Versatile Garnet        (+12 Crit, +5 Versatility)

            -- Lapis Family (Primary: Versatility)
            [240912] = true, -- Flawless Versatile Lapis         (+14 Versatility)
            [240914] = true, -- Flawless Deadly Lapis            (+12 Versatility, +5 Crit)
            [240916] = true, -- Flawless Quick Lapis             (+12 Versatility, +5 Haste)
            [240918] = true, -- Flawless Masterful Lapis         (+12 Versatility, +5 Mastery)

            -- Eversong Diamonds (Epic quality, Unique-Equipped: Thalassian Diamond x1)
            [240967] = true, -- Powerful Eversong Diamond        (+0.15% crit eff per unique gem color)
            [240969] = true, -- Telluric Eversong Diamond        (+1% max mana per unique gem color)
            [240971] = true, -- Stoic Eversong Diamond           (+23 Primary Stat, +13 Armor)
            [240983] = true, -- Indecipherable Eversong Diamond  (+32 Primary Stat)
        },

        -----------------------------------------------------------------------
        -- GEM SLOTS (Required) ΓÇö Equipment slots that MUST have a gem
        -- If the item in this slot has no socket, it's flagged as Miss
        -- Midnight 12.0: Head, Neck, Wrist, Waist, Ring1, Ring2
        -----------------------------------------------------------------------
        gemSlots = {
            [1]  = 1, -- Head: 1 socket
            [2]  = 2, -- Neck: 2 sockets
            [6]  = 1, -- Waist: 1 socket
            [9]  = 1, -- Wrist: 1 socket
            [11] = 2, -- Ring1: 2 sockets
            [12] = 2, -- Ring2: 2 sockets
            -- Total: 9 sockets
        },

        -----------------------------------------------------------------------
        -- ENCHANTS (Permanent)
        -- Keyed by equipment slot ID ΓåÆ set of valid enchant item IDs
        -- Slot IDs: 1=Head, 3=Shoulder, 5=Chest, 7=Legs, 8=Boots,
        --           11=Ring1, 12=Ring2, 16=MainHand
        -----------------------------------------------------------------------
        enchants = {
            -- Head (Slot 1) ΓÇö Empowered versions only, tertiary stats
            [1] = {
                [244007] = true, -- Empowered Rune of Avoidance      (+37 Avoidance + speed burst)
                [243951] = true, -- Empowered Hex of Leeching        (+55 Leech + heal on kill)
                [243981] = true, -- Empowered Blessing of Speed      (+22 Speed + Vigor on kill)
            },

            -- Shoulder (Slot 3) ΓÇö Upgraded versions only, tertiary stats
            [3] = {
                [243991] = true, -- Amirdrassil's Grace              (+111 Avoidance)
                [244021] = true, -- Silvermoon's Mending             (+166 Leech)
                [243963] = true, -- Akil'zon's Swiftness             (+65 Speed)
            },

            -- Chest (Slot 5) ΓÇö Primary stat enchants
            [5] = {
                [243975] = true, -- Mark of the Rootwarden           (+40 Agi, +15 Speed)
                [244003] = true, -- Mark of the Magister             (+40 Int, +% Mana)
                [243947] = true, -- Mark of Nalorakk                 (+40 Str, +116 Stamina)
                [243977] = true, -- Mark of the Worldsoul            (+50 Primary Stat)
            },

            -- Legs (Slot 7) ΓÇö Spellthreads (Int) and Armor Kits (Agi/Str)
            [7] = {
                [240133] = true, -- Sunfire Silk Spellthread         (+41 Int, +115 Stamina)
                [240155] = true, -- Arcanoweave Spellthread          (+41 Int, +4% Max Mana)
                [244641] = true, -- Forest Hunter's Armor Kit        (+41 Agi/Str, +115 Stamina)
                [244643] = true, -- Blood Knight's Armor Kit         (+41 Agi/Str, +27 Armor)
            },

            -- Boots (Slot 8) ΓÇö Defensive/utility, all include +232 Stamina
            [8] = {
                [243953] = true, -- Lynx's Dexterity                 (+19 Avoidance, +232 Stamina)
                [243983] = true, -- Shaladrassil's Roots             (+28 Leech, +232 Stamina)
                [244009] = true, -- Farstrider's Hunt                (+11 Speed, +232 Stamina)
            },

            -- Rings (Slots 11 & 12) ΓÇö Upgraded (+29) versions only
            [11] = {
                [243987] = true, -- Nature's Fury                    (+29 Crit)
                [243957] = true, -- Eyes of the Eagle                (+% Crit Effectiveness)
                [244015] = true, -- Silvermoon's Alacrity            (+29 Haste)
                [243959] = true, -- Zul'jin's Mastery                (+29 Mastery)
                [244017] = true, -- Silvermoon's Tenacity            (+29 Versatility)
            },
            [12] = {
                [243987] = true, -- Nature's Fury                    (+29 Crit)
                [243957] = true, -- Eyes of the Eagle                (+% Crit Effectiveness)
                [244015] = true, -- Silvermoon's Alacrity            (+29 Haste)
                [243959] = true, -- Zul'jin's Mastery                (+29 Mastery)
                [244017] = true, -- Silvermoon's Tenacity            (+29 Versatility)
            },

            -- Weapon (Slot 16) ΓÇö Permanent proc-based enchants
            [16] = {
                [243971] = true, -- Jan'alai's Precision             (Proc +124 Crit, 15s)
                [243973] = true, -- Berserker's Rage                 (Proc +124 Haste, 15s)
                [244031] = true, -- Arcane Mastery                   (Proc +124 Mastery, 15s)
                [244001] = true, -- Worldsoul Tenacity               (Proc +124 Vers, 15s)
                [244029] = true, -- Acuity of the Ren'dorei          (Proc +67 Primary, 15s)
                [243969] = true, -- Strength of Halazzi              (Proc bleed ~1893 dmg/18s)
                [244027] = true, -- Flames of the Sin'dorei          (Proc Fire DoT + AoE)
                [243999] = true, -- Worldsoul Aegis                  (Absorb shield, erupts)
                [243997] = true, -- Worldsoul Cradle                 (Heal absorb shield)
            },
        },

        -----------------------------------------------------------------------
        -- ENCHANT EFFECTS (Permanent) ΓÇö Effect IDs as they appear in item links
        -- Keyed by equipment slot ID ΓåÆ set of valid enchant effect IDs
        -- These are the IDs found at position 4 when splitting an item link by ":"
        -- Cross-referenced from LibEnchantData-MIDNIGHT library
        -- Slot IDs: 1=Head, 3=Shoulder, 5=Chest, 7=Legs, 8=Boots,
        --           11=Ring1, 12=Ring2, 16=MainHand
        -----------------------------------------------------------------------
        enchantEffects = {
            -- Head (Slot 1) ΓÇö Empowered versions only
            [1] = {
                [7961] = true, -- Empowered Hex of Leeching
                [7991] = true, -- Empowered Blessing of Speed
                [8017] = true, -- Empowered Rune of Avoidance
            },

            -- Shoulder (Slot 3)
            [3] = {
                [8001] = true, -- Amirdrassil's Grace
                [8031] = true, -- Silvermoon's Mending
                [7973] = true, -- Akil'zon's Celerity/Swiftness
            },

            -- Chest (Slot 5)
            [5] = {
                [7957] = true, -- Mark of Nalorakk
                [7985] = true, -- Mark of the Rootwarden
                [7987] = true, -- Mark of the Worldsoul
                [8013] = true, -- Mark of the Magister
            },

            -- Legs (Slot 7)
            [7] = {
                [7935] = true, -- Sunfire Silk Spellthread
                [7937] = true, -- Arcanoweave Spellthread
                [8159] = true, -- Forest Hunter's Armor Kit
                [8163] = true, -- Blood Knight's Armor Kit
            },

            -- Boots (Slot 8)
            [8] = {
                [7963] = true, -- Lynx's Dexterity
                [7993] = true, -- Shaladrassil's Roots
                [8019] = true, -- Farstrider's Hunt
            },

            -- Rings (Slots 11 & 12) ΓÇö Same set for both
            [11] = {
                [7997] = true, -- Nature's Fury
                [7967] = true, -- Eyes of the Eagle
                [8025] = true, -- Silvermoon's Alacrity
                [7969] = true, -- Zul'jin's Mastery
                [8027] = true, -- Silvermoon's Tenacity
            },
            [12] = {
                [7997] = true, -- Nature's Fury
                [7967] = true, -- Eyes of the Eagle
                [8025] = true, -- Silvermoon's Alacrity
                [7969] = true, -- Zul'jin's Mastery
                [8027] = true, -- Silvermoon's Tenacity
            },

            -- Weapon (Slot 16)
            [16] = {
                [7979] = true, -- Strength of Halazzi
                [7981] = true, -- Jan'alai's Precision
                [7983] = true, -- Berserker's Rage
                [8007] = true, -- Worldsoul Cradle
                [8009] = true, -- Worldsoul Aegis
                [8011] = true, -- Worldsoul Tenacity
                [8037] = true, -- Flames of the Sin'dorei
                [8039] = true, -- Acuity of the Ren'dorei
                [8041] = true, -- Arcane Mastery
            },
        },

        -----------------------------------------------------------------------
        -- WEAPON BUFFS (Temporary enhancements, 2hr duration)
        -- Applied via GetWeaponEnchantInfo(), not parsed from item link
        -----------------------------------------------------------------------
        weaponBuffs = {
            [243734] = true, -- Thalassian Phoenix Oil               (+16 Crit & Haste, 2hr)
        },

        -----------------------------------------------------------------------
        -- FLASKS (Alchemy, 1hr duration)
        -- Buff spell IDs (verified in-game via C_UnitAuras)
        -----------------------------------------------------------------------
        flasks = {
            [12351111] = true, -- Flask of the Shattered Sun           (+165 Crit, buff spellID)
            [12351110] = true, -- Flask of the Blood Knights           (+165 Haste, buff spellID)
            [12351108] = true, -- Flask of the Magisters               (+165 Mastery, buff spellID)
            [12355057] = true, -- Flask of Thalassian Resistance       (+165 Versatility, buff spellID)
        },

        -----------------------------------------------------------------------
        -- AUGMENT RUNES
        -----------------------------------------------------------------------
        augmentRunes = {
            [1264426] = true, -- Void-Touched Augment Rune            (+25 Primary Stat, 1hr, buff spellID)
        },

        -----------------------------------------------------------------------
        -----------------------------------------------------------------------
        -- FOOD & FEASTS (Cooking)
        -- Feasts only (buff spell IDs, verified in-game)
        -----------------------------------------------------------------------
        food = {
            -- Feast buff spell IDs (verified in-game via C_UnitAuras)
            -- Multiple feasts share the same buff spell ID per tier
            [1232535] = true, -- Silvermoon Parade / Harandar Celebration  (Feast, buff spellID)
            [1232806] = true, -- Blooming Feast / Quel'dorei Medley       (Feast, buff spellID)
        },

        -----------------------------------------------------------------------
        -- WEAPON ENHANCEMENTS (Temporary) ΓÇö Temp enchant effect IDs
        -- Validated via GetWeaponEnchantInfo() ΓåÆ enchantID
        -- Midnight 12.0: Oils, Whetstones, Weightstones
        -----------------------------------------------------------------------
        weaponEnhancements = {
            [8052] = true, -- (weapon enhancement buff)
        },
    }, -- end 12.0
}