local addonName, SinsToolkit = ...

local DevTools = SinsToolkit.DevTools or {}
SinsToolkit.DevTools = DevTools

local tools = DevTools.tools or {}
local orderedToolIDs = DevTools.orderedToolIDs or {}

DevTools.tools = tools
DevTools.orderedToolIDs = orderedToolIDs

function DevTools:RegisterTool(id, definition)
    if type(id) ~= "string" or id == "" or type(definition) ~= "table" then
        return nil
    end

    if not tools[id] then
        orderedToolIDs[#orderedToolIDs + 1] = id
    end

    definition.id = definition.id or id
    tools[id] = definition
    return definition
end

function DevTools:GetTool(id)
    if type(id) ~= "string" then return nil end
    return tools[id]
end

function DevTools:GetTools()
    local list = {}
    for _, id in ipairs(orderedToolIDs) do
        if tools[id] then
            list[#list + 1] = tools[id]
        end
    end
    return list
end
