#pragma once

#include "../CommandHistory.h"
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/sdf/layer.h>
#include <string>

namespace UsdLayerManager {

/// Disconnects a shader input from its upstream source, capturing that
/// source at construction time so Undo can restore it.
class DisconnectShaderAttrCommand : public ICommand {
public:
    /// editLayer: see ConnectShaderAttrsCommand's constructor doc — same
    /// capture-at-construction-time pattern, null/empty falls back to the
    /// ambient edit target at call time (today's behavior).
    DisconnectShaderAttrCommand(pxr::UsdStageRefPtr stage,
                                const pxr::SdfPath&  destNode,
                                const std::string&   destInput,
                                pxr::SdfLayerHandle  editLayer = pxr::SdfLayerHandle());

    void Execute() override;
    void Undo()    override;
    std::string GetDescription() const override { return m_description; }

private:
    pxr::UsdStageRefPtr m_stage;
    pxr::SdfPath        m_destNode;
    std::string         m_destInput;
    pxr::SdfLayerHandle m_editLayer;
    std::string         m_description;

    bool         m_hadConnection = false;
    pxr::SdfPath m_sourceNode;
    std::string  m_sourceOutput;
};

} // namespace UsdLayerManager
