local ADDON_NAME = ...
local LSM = LibStub and LibStub("LibSharedMedia-3.0", true)

local fonts = {
    "Beyond Wonderland.ttf",
    "Demon Stars.ttf",
    "Starlight Rune.ttf",
    "Gemini.ttf",
    "Medusa Gothic.otf",
    "Owbeirak Serif.otf",
    "Aladin.ttf",
    -- just add new fonts here if needed
}

local statusbars = {
    "Lunar Moonstone.png",
    "Sapphire Star.png",
    "Fury Orchid.png",
    "Void Amethyst.png",
    "Void Amethyst Glow.png",
    "Void Nebula.png",
    "Aquamarine.png",
    "Stagger Emerald.png",
    "Stagger Ruby.png",
    "Fury Facets.png",
    "Enchantment.png",
    "Stagger Gold.png",
    "Fury Orchid Glow.png",
    "Ebon Topaz.png",
    "Lapis Collapse.png",
    "Midnight Quartz.png",
    "Insanity Iolite.png",
    "Insanity Turquoise.png",
    "Runic Deathstone.png",
    "Runic Snowstone.png",
    "Runic Bloodstone.png",
    "Suramar Starstorm.png",
    "Elisande's Secret.png",
    "Lunar Mintstone.png",
    "Elisande's Felborne.png",
    { file = "Mono Sapphire Star.png", name = "Diva's Jewels: Mono Sapphire Star" },
    { file = "Mono Aquamarine.png", name = "Diva's Jewels: Mono Aquamarine" },
    { file = "Mono Ebon Topaz.png", name = "Diva's Jewels: Mono Ebon Topaz" },
    { file = "Mono Elisande's Felborne.png", name = "Diva's Jewels: Mono Elisande's Felborne" },
    { file = "Mono Elisande's Secret.png", name = "Diva's Jewels: Mono Elisande's Secret" },
    { file = "Mono Enchantment.png", name = "Diva's Jewels: Mono Enchantment" },
    { file = "Mono Fury Facets.png", name = "Diva's Jewels: Mono Fury Facets" },
    { file = "Mono Fury Orchid Glow.png", name = "Diva's Jewels: Mono Fury Orchid Glow" },
    { file = "Mono Fury Orchid.png", name = "Diva's Jewels: Mono Fury Orchid" },
    { file = "Mono Insanity Iolite.png", name = "Diva's Jewels: Mono Insanity Iolite" },
    { file = "Mono Insanity Turquoise.png", name = "Diva's Jewels: Mono Insanity Turquoise" },
    { file = "Mono Lapis Collapse.png", name = "Diva's Jewels: Mono Lapis Collapse" },
    { file = "Mono Lunar Mintstone.png", name = "Diva's Jewels: Mono Lunar Mintstone" },
    { file = "Mono Lunar Moonstone.png", name = "Diva's Jewels: Mono Lunar Moonstone" },
    { file = "Mono Midnight Quartz.png", name = "Diva's Jewels: Mono Midnight Quartz" },
    { file = "Mono Runic Bloodstone.png", name = "Diva's Jewels: Mono Runic Bloodstone" },
    { file = "Mono Runic Deathstone.png", name = "Diva's Jewels: Mono Runic Deathstone" },
    { file = "Mono Runic Snowstone.png", name = "Diva's Jewels: Mono Runic Snowstone" },
    { file = "Mono Stagger Emerald.png", name = "Diva's Jewels: Mono Stagger Emerald" },
    { file = "Mono Stagger Gold.png", name = "Diva's Jewels: Mono Stagger Gold" },
    { file = "Mono Stagger Ruby.png", name = "Diva's Jewels: Mono Stagger Ruby" },
    { file = "Mono Suramar Starstorm.png", name = "Diva's Jewels: Mono Suramar Starstorm" },
    { file = "Mono Void Amethyst Glow.png", name = "Diva's Jewels: Mono Void Amethyst Glow" },
    { file = "Mono Void Amethyst.png", name = "Diva's Jewels: Mono Void Amethyst" },
    { file = "Mono Void Nebula.png", name = "Diva's Jewels: Mono Void Nebula" },
    -- just add new textures here if needed
}

local function StripExtension(file)
    return file:gsub("%.ttf$", ""):gsub("%.otf$", ""):gsub("%.png$", ""):gsub("%.png$", "")
end

local function RegisterMedia()
    if not LSM then
        LSM = LibStub and LibStub("LibSharedMedia-3.0", true)
    end

    if not LSM then return end

    for _, file in ipairs(fonts) do
        LSM:Register(
            "font",
            StripExtension(file),
            "Interface\\AddOns\\SharedMedia_DivasJewels\\fonts\\" .. file
        )
    end

    for _, media in ipairs(statusbars) do
        local file = media
        local name

        if type(media) == "table" then
            file = media.file
            name = media.name
        else
            name = "Diva's Jewels - " .. StripExtension(file)
        end

        LSM:Register(
            "statusbar",
            name,
            "Interface\\AddOns\\SharedMedia_DivasJewels\\textures\\" .. file
        )
    end
end

RegisterMedia()

if not LSM then
    local f = CreateFrame("Frame")
    f:RegisterEvent("ADDON_LOADED")
    f:SetScript("OnEvent", function(_, _, addon)
        if addon ~= ADDON_NAME then return end
        RegisterMedia()
    end)
end



