-- HDG_HT_W_ThemedSets.lua  (C3)
-- Top closest-to-complete themed collections (chairs, tables, etc.) from
-- HDG_CollectionDefinitions. Renders via MiniCardStrip.

local _, privateDB = ...
privateDB.HDG_HT = privateDB.HDG_HT or {}
privateDB.HDG_HT.Widgets = privateDB.HDG_HT.Widgets or {}
local W = { id = "themedSets", title = "Themed Sets" }
privateDB.HDG_HT.Widgets.ThemedSets = W

local Patterns = privateDB.HDG_HT.Patterns

function W.Create(parent, dims)
    local self = {}
    self.pattern = Patterns.MiniCardStrip(parent, dims, {
        cardCount = (dims and dims.cardCount) or 4,
        cardGap   = (dims and dims.cardGap)   or 6,
    })

    function self:Refresh(snap)
        local sets = (snap and snap.themedSets) or {}
        local cards = {}
        for i, s in ipairs(sets) do
            cards[i] = {
                title = s.name,
                value = s.collected,
                total = s.total,
                pct   = s.pct or 0,
            }
        end
        self.pattern:Update({ cards = cards })
    end

    function self:Resize(w, h) self.pattern:Resize(w, h) end
    return self
end

return W
