#pragma once

#include <filesystem>
#include <cstdint>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "core/project_model.hpp"

namespace smartcut::core {

struct EditSnapshot {
  std::string source_uuid;
  std::uint64_t frame_count{};
  std::vector<std::pair<std::uint64_t, std::uint64_t>> cuts;
  std::vector<std::size_t> selected_streams;
  std::vector<std::uint64_t> chapter_markers;
  bool scene_mode{};
  std::int64_t audio_offset_ms{};
};

class ProjectJournal {
 public:
  static bool append_add_segment(const std::filesystem::path& path, const KeptSegment& segment);
  static bool append_export_evidence(const std::filesystem::path& path, const ExportEvidence& evidence);
  static bool append_audio_validation(const std::filesystem::path& path, const std::string& status);
  static bool append_edit_snapshot(const std::filesystem::path& path, const EditSnapshot& snapshot);
  static std::optional<EditSnapshot> latest_edit_snapshot(const std::filesystem::path& path);
  static bool recover(const std::filesystem::path& path, Project& project);
};

}  // namespace smartcut::core
