local Format = {}

function Format.StyleParts(s)
    s = s or {}
    if s.compactNumbers then
        return "", "", "/"
    elseif s.compactInitials then
        return (s.critInitial or "") .. ":", (s.hitInitial or "") .. ":", " "
    elseif s.compactLabels then
        return (s.critShort or "") .. ": ", (s.hitShort or "") .. ": ", "  "
    else
        return (s.critFull or "") .. ": ", (s.hitFull or "") .. ": ", "  "
    end
end

function Format.RecordPair(opts)
    opts = opts or {}
    local crit = opts.critValue or 0
    local hit = opts.hitValue or 0
    if crit <= 0 and hit <= 0 then
        return opts.fallback
    end

    local critLabel = opts.critLabel or ""
    local hitLabel = opts.hitLabel or ""
    local separator = opts.separator or "  "

    local critPart, hitPart
    if crit > 0 then
        critPart = "|c" .. opts.critHex .. critLabel .. crit .. "|r"
    end
    if hit > 0 then
        hitPart = "|c" .. opts.hitHex .. hitLabel .. hit .. "|r"
    end

    local first, second
    if opts.hitFirst then
        first, second = hitPart, critPart
    else
        first, second = critPart, hitPart
    end

    local parts = {}
    if first then parts[#parts + 1] = first end
    if second then parts[#parts + 1] = second end

    return table.concat(parts, separator)
end

function Format.CategoryColorKeys(category)
    if category == "healing" then
        return "critHeal", "heal"
    elseif category == "pet" then
        return "petCrit", "petHit"
    else
        return "crit", "hit"
    end
end

_G.CritMaticBrokerFormat = Format

return Format
