#include "WidgetFactory.hpp"
#include "LabelWidget.hpp"
#include "ButtonWidget.hpp"
#include "LedWidget.hpp"
#include "IconWidget.hpp"
#include "TabViewWidget.hpp"
#include "TabPageWidget.hpp"
#include "PowerFlowWidget.hpp"
#include "PowerNodeWidget.hpp"
#include "PowerLinkWidget.hpp"
#include "ChartWidget.hpp"
#include "ClockWidget.hpp"
#include "RoomCardBubbleWidget.hpp"
#include "RoomCardTileWidget.hpp"
#include "RectangleWidget.hpp"
#include "ArcWidget.hpp"
#include "ButtonMatrixWidget.hpp"

std::unique_ptr<Widget> WidgetFactory::create(const WidgetConfig& config) {
    if (!config.visible) return nullptr;

    switch (config.type) {
        case WidgetType::LABEL:
            return std::make_unique<LabelWidget>(config);
        case WidgetType::BUTTON:
            return std::make_unique<ButtonWidget>(config);
        case WidgetType::LED:
            return std::make_unique<LedWidget>(config);
        case WidgetType::ICON:
            return std::make_unique<IconWidget>(config);
        case WidgetType::TABVIEW:
            return std::make_unique<TabViewWidget>(config);
        case WidgetType::TABPAGE:
            return std::make_unique<TabPageWidget>(config);
        case WidgetType::POWERFLOW:
            return std::make_unique<PowerFlowWidget>(config);
        case WidgetType::POWERNODE:
            return std::make_unique<PowerNodeWidget>(config);
        case WidgetType::POWERLINK:
            return std::make_unique<PowerLinkWidget>(config);
        case WidgetType::CHART:
            return std::make_unique<ChartWidget>(config);
        case WidgetType::CLOCK:
            return std::make_unique<ClockWidget>(config);
        case WidgetType::ROOMCARD:
            // cardStyle: 0=Bubble, 1=Tile
            if (config.cardStyle == 1) {
                return std::make_unique<RoomCardTileWidget>(config);
            }
            return std::make_unique<RoomCardBubbleWidget>(config);
        case WidgetType::RECTANGLE:
            return std::make_unique<RectangleWidget>(config);
        case WidgetType::ARC:
            return std::make_unique<ArcWidget>(config);
        case WidgetType::BUTTONMATRIX:
            return std::make_unique<ButtonMatrixWidget>(config);
        default:
            return nullptr;
    }
}
