local GC = select(2, ...)

local private = {modules = {}}

-- Global API object
LA_API = {}
GC.LA_API = LA_API

function LA_API.RegisterModule(theModule)
    GC.Debug.Log("RegisterModule")
    GC.Debug.TableToString(theModule)

    if not private.modules then private.modules = {} end
    private.modules[theModule.name] = theModule
end

function LA_API.GetVersion() return GC.CONST.METADATA.VERSION end

function LA_API.GetCurrentSession() return GC.Session.GetCurrentSession() end

function LA_API.PauseSession() GC.Session.Pause() end

function LA_API.StartSession(qualityFilter, priceSource, ...)
    if not qualityFilter or not priceSource then return end

    local startPaused
    for i = 1, select('#', ...) do
        local opt = select(i, ...)
        if opt and  opt == "START_PAUSED" then
            startPaused = true
        end
    end

    GC.db.profile.notification.qualityFilter = qualityFilter
    GC.db.profile.pricesource.source = priceSource

    GC.Session.Start(true)
    GC.Session.New()

    if startPaused then GC.Session.Pause() end
end

function GC.GetModules() return private.modules end

-- Legacy API for older LAC versions
function GC:RegisterModule(theModule) LA_API.RegisterModule(theModule) end

