#ifndef UPDATER_H_809E7381
#define UPDATER_H_809E7381

#include <filesystem>
#include <set>
#include <string>

#include <wx/wxprec.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

class wxWebRequest;
class wxWebRequestEvent;

class Updater : public wxEvtHandler {
 public:
  explicit Updater(wxFrame* parent);

  void Cleanup();

  void CheckForUpdates(bool invisible);

 private:
  enum class UpdateState {
    GetVersionInvisible,
    GetVersionManual,
    GetPackage,
  };

  void OnWebRequestState(wxWebRequestEvent& event);

  void ProcessVersionFile(std::string data);

  void InstallUpdate(std::string url, std::string checksum,
                     std::vector<std::filesystem::path> files,
                     std::vector<std::filesystem::path> deletedFiles);

  bool DownloadWithProgress(wxWebRequest& request);

  wxFrame* parent_;
  UpdateState update_state_ = UpdateState::GetVersionInvisible;
  std::string package_path_;
};

#endif /* end of include guard: UPDATER_H_809E7381 */