#pragma once

#include <string>
#include <vector>
#include <memory>
#include <unordered_map> // For std::unordered_map

#include "lumacs/minibuffer_mode.hpp" // For MinibufferMode enum
#include "lumacs/minibuffer_mode_hash.hpp" // For MinibufferMode hash specialization
#include "lumacs/completion_common.hpp" // For CompletionCandidate struct

namespace lumacs {

// Forward declaration
class EditorCore; 

/// @brief Interface for a completion source.
/// Different minibuffer modes will use different implementations of this interface.
class ICompletionSource {
public:
    virtual ~ICompletionSource() = default;

    /// @brief Retrieves completion candidates based on the current input.
    /// @param input_text The current text entered by the user in the minibuffer.
    /// @return A vector of matching completion candidates.
    virtual std::vector<CompletionCandidate> get_candidates(const std::string& input_text) = 0;
};

/// @brief Manages various completion sources and provides candidates for the minibuffer.
class CompletionSystem {
public:
    explicit CompletionSystem(EditorCore& core);

    /// @brief Registers a completion source for a specific minibuffer mode.
    void register_source(MinibufferMode mode, std::unique_ptr<ICompletionSource> source);

    /// @brief Retrieves completion candidates for a given mode and input.
    std::vector<CompletionCandidate> get_candidates_for_mode(MinibufferMode mode, const std::string& input_text);

private:
    [[maybe_unused]] EditorCore& core_; // Reserved for future use
    std::unordered_map<MinibufferMode, std::unique_ptr<ICompletionSource>> sources_;
};

} // namespace lumacs
