local addonName, privateDB = ...

-- ============================================================================
-- DYE CRAFTING DATABASE
-- Static data: herb → pigment → dye crafting chains
-- Professions: Midnight Alchemy or Midnight Inscription
-- Each pigment requires 10 of any one listed herb → produces 1 pigment → 1 dye
-- ============================================================================

HDG_DyeCraftingDB = {
    -- ========================================================================
    -- PIGMENTS: [pigmentItemID] = { name, category, herbQty, herbs = {itemID, ...} }
    -- ========================================================================
    pigments = {
        [262639] = {
            name = "Black Dye Pigment", category = "Black", herbQty = 10,
            herbs = {
                3818,    -- Fadeleaf (Classic)
                22785,   -- Felweed (BC)
                36905,   -- Lichbloom (Wrath)
                52983,   -- Azshara's Veil (Cata)
                72237,   -- Desecrated Herb (MoP)
                109128,  -- Nagrand Arrowbloom (WoD)
                128304,  -- Yseralline Seed (Legion)
                152505,  -- Riverbud (BfA)
                168589,  -- Death Blossom (SL)
                191460,  -- Writhebark (DF)
                210796,  -- Blessing Blossom (TWW)
                236774,  -- Azeroot (Midnight)
            },
        },
        [262643] = {
            name = "Blue Dye Pigment", category = "Blue", herbQty = 10,
            herbs = {
                765,     -- Silverleaf (Classic)
                22789,   -- Terocone (BC)
                36906,   -- Icethorn (Wrath)
                52987,   -- Stormvine (Cata)
                72234,   -- Silkweed (MoP)
                109124,  -- Frostweed (WoD)
                124102,  -- Dreamleaf (Legion)
                152507,  -- Akunda's Bite (BfA)
                168589,  -- Death Blossom (SL)
                191467,  -- Bubble Poppy (DF)
                210800,  -- Luredrop (TWW)
                236775,  -- Argentleaf (Midnight)
            },
        },
        [262642] = {
            name = "Brown Dye Pigment", category = "Brown", herbQty = 10,
            herbs = {
                2450,    -- Briarthorn (Classic)
                22786,   -- Dreaming Glory (BC)
                36903,   -- Adder's Tongue (Wrath)
                52983,   -- Azshara's Veil (Cata) -- Cinderbloom per some sources
                72237,   -- Desecrated Herb (MoP)
                109126,  -- Gorgrond Flytrap (WoD)
                124103,  -- Foxflower (Legion)
                152511,  -- Sea Stalk (BfA)
                168583,  -- Marrowroot (SL)
                191460,  -- Writhebark (DF)
                210799,  -- Mycobloom (TWW)
                236774,  -- Azeroot (Midnight)
            },
        },
        [262647] = {
            name = "Green Dye Pigment", category = "Green", herbQty = 10,
            herbs = {
                2452,    -- Swiftthistle (Classic)
                22785,   -- Felweed (BC) -- listed as "Felwood" in some sources
                36903,   -- Adder's Tongue (Wrath)
                52983,   -- Azshara's Veil (Cata)
                72234,   -- Silkweed (MoP) -- Green Tea Leaf in some sources
                109128,  -- Nagrand Arrowbloom (WoD)
                124102,  -- Dreamleaf (Legion)
                152505,  -- Riverbud (BfA)
                170554,  -- Vigil's Torch (SL)
                191467,  -- Bubble Poppy (DF)
                210796,  -- Blessing Blossom (TWW)
                236770,  -- Sanguithorn (Midnight)
            },
        },
        [262656] = {
            name = "Orange Dye Pigment", category = "Orange", herbQty = 10,
            herbs = {
                13464,   -- Golden Sansam (Classic)
                22792,   -- Nightmare Vine (BC)
                36901,   -- Goldclover (Wrath)
                52986,   -- Heartblossom (Cata)
                72238,   -- Rain Poppy (MoP)
                109125,  -- Fireweed (WoD)
                124103,  -- Foxflower (Legion)
                152508,  -- Siren's Pollen (BfA)
                168586,  -- Widowbloom (SL)
                191460,  -- Writhebark (DF)
                210800,  -- Luredrop (TWW)
                236770,  -- Sanguithorn (Midnight)
            },
        },
        [262625] = {
            name = "Purple Dye Pigment", category = "Purple", herbQty = 10,
            herbs = {
                3356,    -- Kingsblood (Classic)
                22793,   -- Mana Thistle (BC)
                36907,   -- Talandra's Rose (Wrath)
                52988,   -- Twilight Jasmine (Cata)
                79011,   -- Fool's Cap (MoP)
                109129,  -- Talador Orchid (WoD)
                124101,  -- Aethril (Legion)
                152510,  -- Zin'anthid (BfA)
                170554,  -- Vigil's Torch (SL)
                191461,  -- Hochenblume (DF)
                210802,  -- Orbinid (TWW)
                236761,  -- Tranquility Bloom (Midnight)
            },
        },
        [262655] = {
            name = "Red Dye Pigment", category = "Red", herbQty = 10,
            herbs = {
                785,     -- Mageroyal (Classic)
                22791,   -- Netherbloom (BC)
                36904,   -- Tiger Lily (Wrath)
                52985,   -- Cinderbloom (Cata)
                72238,   -- Rain Poppy (MoP)
                109125,  -- Fireweed (WoD)
                124105,  -- Astral Glory (Legion)
                152506,  -- Star Moss (BfA)
                168586,  -- Widowbloom (SL)
                191462,  -- Saxifrage (DF)
                210797,  -- Arathor's Spear (TWW)
                236776,  -- Mana Lily (Midnight)
            },
        },
        [262628] = {
            name = "Teal Dye Pigment", category = "Teal", herbQty = 10,
            herbs = {
                2453,    -- Bruiseweed (Classic)
                22789,   -- Terocone (BC)
                36905,   -- Lichbloom (Wrath)
                52987,   -- Stormvine (Cata)
                72234,   -- Silkweed (MoP)
                109127,  -- Starflower (WoD)
                128304,  -- Yseralline Seed (Legion)
                152508,  -- Siren's Pollen (BfA)
                168583,  -- Marrowroot (SL)
                191461,  -- Hochenblume (DF)
                210802,  -- Orbinid (TWW)
                236761,  -- Tranquility Bloom (Midnight)
            },
        },
        [260947] = {
            name = "White Dye Pigment", category = "White", herbQty = 10,
            herbs = {
                2447,    -- Peacebloom (Classic)
                22787,   -- Ragveil (BC)
                36906,   -- Icethorn (Wrath)
                52989,   -- Whiptail (Cata)
                79010,   -- Snow Lily (MoP)
                109129,  -- Talador Orchid (WoD)
                124104,  -- Fjarnskaggl (Legion)
                152509,  -- Winter's Kiss (BfA)
                168586,  -- Widowbloom (SL) -- Rising Glory in some sources
                191462,  -- Saxifrage (DF)
                210799,  -- Mycobloom (TWW)
                236761,  -- Tranquility Bloom (Midnight)
            },
        },
        [262648] = {
            name = "Yellow Dye Pigment", category = "Yellow", herbQty = 10,
            herbs = {
                8838,    -- Sungrass (Classic)
                22786,   -- Dreaming Glory (BC)
                36901,   -- Goldclover (Wrath)
                52989,   -- Whiptail (Cata)
                72234,   -- Silkweed (MoP) -- Green Tea Leaf in some sources
                109126,  -- Gorgrond Flytrap (WoD)
                124104,  -- Fjarnskaggl (Legion)
                152511,  -- Sea Stalk (BfA)
                168587,  -- Rising Glory (SL)
                191462,  -- Saxifrage (DF)
                210797,  -- Arathor's Spear (TWW)
                236776,  -- Mana Lily (Midnight)
            },
        },
    },

    -- ========================================================================
    -- DYE RECIPES: [dyeItemID] = pigmentItemID
    -- Each dye requires 1 pigment of the matching color
    -- ========================================================================
    dyeRecipes = {
        -- Black dyes (from Black Dye Pigment 262639)
        [259109] = 262639, -- Dark Iron Dye
        [259121] = 262639, -- Obsidium Black Dye
        [259123] = 262639, -- Stormheim Grey Dye
        [259098] = 262639, -- Darkwood Dye
        [259111] = 262639, -- Ironclaw Dye
        [259104] = 262639, -- Stormsteel Dye

        -- Blue dyes (from Blue Dye Pigment 262643)
        [259115] = 262643, -- Alliance Blue Dye
        [259153] = 262643, -- Dusk Lily Grey Dye
        [259129] = 262643, -- Zephras Blue Dye
        [259135] = 262643, -- Midnight Blue Dye
        [259146] = 262643, -- Nazjatar Navy Dye

        -- Brown dyes (from Brown Dye Pigment 262642)
        [259053] = 262642, -- Warm Teak Dye
        [259096] = 262642, -- Mesquite Brown Dye
        [259101] = 262642, -- Pale Umber Dye
        [259103] = 262642, -- Heartwood Dye
        [259112] = 262642, -- Dark Gold Dye
        [259122] = 262642, -- Earthen Brown Dye
        [259141] = 262642, -- Vol'dun Taupe Dye
        [259145] = 262642, -- Timbermaw Brown Dye
        [259128] = 262642, -- Kalimdor Sand Dye

        -- Green dyes (from Green Dye Pigment 262647)
        [259114] = 262647, -- Lush Green Dye
        [259150] = 262647, -- Earthroot Dye
        [259124] = 262647, -- Silversage Green Dye
        [259133] = 262647, -- Dustwallow Green Dye
        [259143] = 262647, -- Gravemoss Green Dye
        [259147] = 262647, -- Grizzly Hills Green Dye
        [259134] = 262647, -- Emerald Dreaming Dye

        -- Orange dyes (from Orange Dye Pigment 262656)
        [259118] = 262656, -- Elwynn Pumpkin Dye
        [259132] = 262656, -- Kodohide Brown Dye
        [259105] = 262656, -- Copper Dye
        [259108] = 262656, -- Bronze Dye

        -- Purple dyes (from Purple Dye Pigment 262625)
        [259116] = 262625, -- Kirin Tor Violet Dye
        [259119] = 262625, -- Netherstorm Fuchsia Dye
        [259126] = 262625, -- Void Violet Dye
        [259130] = 262625, -- Nightsong Lilac Dye
        [259131] = 262625, -- Arcwine Dye
        [259140] = 262625, -- Moonberry Amethyst Dye
        [259144] = 262625, -- Forsaken Plum Dye

        -- Red dyes (from Red Dye Pigment 262655)
        [259127] = 262655, -- Firebloom Red Dye
        [259102] = 262655, -- Mahogany Dye
        [259142] = 262655, -- Ratchet Rust Dye
        [259113] = 262655, -- Horde Red Dye
        [259139] = 262655, -- Gilnean Rose Dye
        [259152] = 262655, -- Hinterlands Hickory Dye
        [259154] = 262655, -- Rain Poppy Red Dye
        [259151] = 262655, -- Deep Mageroyal Red Dye

        -- Teal dyes (from Teal Dye Pigment 262628)
        [259136] = 262628, -- Vortex Teal Dye
        [259125] = 262628, -- Un'Goro Green Dye
        [259110] = 262628, -- Kul Tiran Steel Dye
        [259148] = 262628, -- Tidesage Teal Dye

        -- White dyes (from White Dye Pigment 260947)
        [259120] = 260947, -- Bone-White Dye
        [259078] = 260947, -- Basic Birch Dye
        [259099] = 260947, -- Highland Birch Dye
        [259149] = 260947, -- Highborne Marble Dye

        -- Yellow dyes (from Yellow Dye Pigment 262648)
        [258838] = 262648, -- Gold Dye
        [259097] = 262648, -- Pinewood Dye
        [259100] = 262648, -- Holy Oak Tan Dye
        [259106] = 262648, -- Zandalari Gold Dye
        [259107] = 262648, -- Brass Dye
        [259117] = 262648, -- Sandfury Yellow Dye
        [259137] = 262648, -- Sungrass Yellow Dye
        [259138] = 262648, -- Savannah Gold Dye
    },
}

-- ============================================================================
-- HELPER API
-- ============================================================================

-- Get pigment info for a dye item
function HDG_DyeCraftingDB.GetPigmentForDye(dyeItemID)
    local pigmentID = HDG_DyeCraftingDB.dyeRecipes[dyeItemID]
    if not pigmentID then return nil end
    return pigmentID, HDG_DyeCraftingDB.pigments[pigmentID]
end

-- Get all herb options for a dye item (via its pigment)
function HDG_DyeCraftingDB.GetHerbsForDye(dyeItemID)
    local pigmentID = HDG_DyeCraftingDB.dyeRecipes[dyeItemID]
    if not pigmentID then return nil end
    local pigment = HDG_DyeCraftingDB.pigments[pigmentID]
    return pigment and pigment.herbs or nil
end
