#pragma once

#include "ImGuiContext.h"
#include "IconManager.h"
#include "StageEditorPanel.h"
#include "SceneHierarchyPanel.h"
#include "ViewportPanel.h"
#include "PropertyPanel.h"
#include "TimelinePanel.h"
#include "../core/UsdStageManager.h"
#include "../core/LayerManager.h"
#include "../core/PropertyManager.h"
#include "../core/CommandHistory.h"
#include <memory>
#include <string>

namespace UsdLayerManager {

class Application {
public:
    Application();
    ~Application();
    
    bool Initialize(const std::string& windowTitle = "USD Layer Manager", int width = 1280, int height = 720);
    void Run();
    void Shutdown();
    
private:
    void Update();
    void RenderUI();
    void RenderMenuBar();
    void RenderStatusBar();
    void RenderStageInfo();
    void RefreshManagers();
    
    // File operations
    void OpenUsdFile();
    void CreateNewUsdFile();       // creates fresh in-memory stage
    void SaveUsdFile();
    void SaveUsdFileAs();
    void CloseUsdFile();           // closes file-backed stage, falls back to default stage

    // Stage editing operations (also exposed via Stage menu)
    void AddReferenceToStage();
    void CreatePrimOnStage(const std::string& typeName);
    
    std::unique_ptr<ImGuiContext> m_imguiContext;
    std::unique_ptr<IconManager> m_iconManager;
    std::unique_ptr<UsdStageManager> m_stageManager;
    std::unique_ptr<LayerManager> m_layerManager;
    std::unique_ptr<PropertyManager> m_propertyManager;
    CommandHistory m_commandHistory;
    std::unique_ptr<StageEditorPanel> m_stageEditorPanel;
    std::unique_ptr<SceneHierarchyPanel> m_sceneHierarchyPanel;
    std::unique_ptr<ViewportPanel> m_viewportPanel;
    std::unique_ptr<PropertyPanel> m_propertyPanel;
    std::unique_ptr<TimelinePanel> m_timelinePanel;
    bool m_showDemoWindow;
    bool m_showStageInfo;
    bool m_showStageEditor;
    bool m_showSceneHierarchy;
    bool m_showViewport;
    bool m_showPropertyPanel;
    bool m_showTimeline;
    bool m_running;
};

} // namespace UsdLayerManager
