#pragma once

#include "../core/LayerManager.h"
#include "../core/CommandHistory.h"
#include "../core/RenderLayerManager.h"
#include "IconManager.h"
#include <imgui.h>
#include <memory>
#include <string>

namespace UsdLayerManager {

class StageEditorPanel {
public:
    StageEditorPanel();
    ~StageEditorPanel();

    void SetLayerManager(LayerManager* manager) { m_layerManager = manager; }
    void SetCommandHistory(CommandHistory* history) { m_commandHistory = history; }
    void SetIconManager(IconManager* icons) { m_iconManager = icons; }
    /// Optional. When set: sublayers RenderLayerManager created are badged
    /// and have their mute/remove controls disabled here (they're managed
    /// exclusively from the Render Layer panel so the two can't desync), and
    /// every row's edit-target checkbox is disabled while a non-Default
    /// render layer is active.
    void SetRenderLayerManager(RenderLayerManager* mgr) { m_renderLayerManager = mgr; }
    void Render();

private:
    void RenderFixedLayers(const std::vector<LayerInfo>& layers);
    void RenderSublayerList(const std::vector<LayerInfo>& sublayers);
    void RenderSublayerContextMenu(int i, const std::vector<LayerInfo>& sublayers);

    LayerManager*        m_layerManager       = nullptr;
    CommandHistory*      m_commandHistory     = nullptr;
    IconManager*         m_iconManager        = nullptr;
    RenderLayerManager*  m_renderLayerManager = nullptr;
    int             m_selectedIdx     = -1;
};

} // namespace UsdLayerManager
