#ifndef __SCRIPTING__PYTHON_ENGINE_H__
#define __SCRIPTING__PYTHON_ENGINE_H__

#include <pybind11/embed.h>
#include <string>
#include <chrono>
#include <functional>

namespace py = pybind11;

class PythonEngine
{
public:
    static PythonEngine& Get();
    
    void Init();
    void Shutdown();
    
    void Exec(const std::string& code);
    py::object Call(const std::string& module, const std::string& func, py::args args = {});
    
    // Hot-Reloading API
    bool ReloadModule(const std::string& module_name);
    void ReloadAllScripts();
    
    // Background watcher
    void StartAutoReload(float intervalSeconds = 1.0f);
    void StopAutoReload();
    
private:
    PythonEngine() = default;
    ~PythonEngine() = default;
    
    bool initialized_ = false;

    // Auto-reload stuff
    bool autoReloadRunning_ = false;
    std::thread autoReloadThread_;
    std::unordered_map<std::string, std::chrono::file_clock::time_point> lastWriteTimes_;

};

#endif