local addonName, ns = ...

local function GetLSM()
    if not LibStub then return nil end
    return LibStub("LibSharedMedia-3.0", true)
end

function ns.IsSharedMediaAvailable()
    return GetLSM() ~= nil
end

function ns.GetSharedMediaBorders()
    local lsm = GetLSM()
    if not lsm then return {} end

    local list = lsm:List("border")
    if type(list) ~= "table" then return {} end

    local result = {}
    for _, name in ipairs(list) do
        if type(name) == "string" and name ~= "" then
            result[#result + 1] = name
        end
    end
    table.sort(result)
    return result
end

function ns.FetchSharedMediaBorder(name)
    local lsm = GetLSM()
    if not lsm or type(name) ~= "string" or name == "" then return nil end
    return lsm:Fetch("border", name, true)
end
