#ifndef APPMANAGERITEMWIDGET_H
#define APPMANAGERITEMWIDGET_H

#include <QFrame>

#include "ISelectComboxItem.h"
#include "AppManagerSelectComboxItem.h"
#include "AppManagerSliderItem.h"
#include "ISelectComboxItem.h"
#include "BaseType.h"

using namespace UkuiAudioFramwork;

enum class StreamDirection {
    STREAM_DIRECTION_INPUT = 0,
    STREAM_DIRECTION_OUTPUT,
    STREAM_DIRECTION_BOTH,
    STREAM_DIRECTION_UNKNOWN
};

class AppManagerItemWidget : public QWidget
{
    Q_OBJECT
public:
    AppManagerItemWidget(uint32_t, QLabel*, const QString&, StreamDirection, QWidget* parent = nullptr);
    ~AppManagerItemWidget() = default;

public:
    void setValue(const VolumeSliderType&, int);

    void setMuted(const VolumeSliderType&, bool);

    void setCurrentIndex(const NodeType&, int);

    void insertItem(const NodeType&, const QString&, const QVariant& = QVariant());

    void removeItem(const NodeType&, int);

    IVolumeSliderItem* getSliderItem() const;

    std::unordered_map<NodeType, ISelectComboxItem*> getSelectComboxItems() const;

Q_SIGNALS:
    void closeWindowSignals();

private Q_SLOTS:
    void closeWindowSlots();

private:
    void createItems();

    void initUi();

    void initSlots();

private:
    uint32_t m_idx {};
    QString m_name {};
    QLabel* m_pTitileLabel {};
    QPushButton* m_pConfirmBtn {};

    std::unordered_map<VolumeSliderType, QString> m_volumeKeys {
        {VolumeSliderType::VOLUME_SLIDER_SINKINPUT, tr("Output Volume")},
    };
    std::unordered_map<NodeType, QStringList> m_selectKeys {
        {NodeType::OUTPUT, QStringList{std::initializer_list<QString>{tr("Output Device"), QObject::tr("This case does not support setting the output device")}}},
        {NodeType::INPUT, QStringList{std::initializer_list<QString>{tr("Input Device"), QObject::tr("This case does not support setting the input device")}}},
    };

    std::unordered_map<VolumeSliderType, IVolumeSliderItem*> m_volumeSliderItemMap;
    std::unordered_map<NodeType, ISelectComboxItem*> m_selectComboxItemMap;
    StreamDirection m_direction = StreamDirection::STREAM_DIRECTION_BOTH;
};

#endif // APPMANAGERITEMWIDGET_H
