#pragma once

#include <cstddef>
#include <cstdint>
#include <string>
#include <utility>
#include <vector>

namespace smartcut::core {

struct ProjectSource {
  ProjectSource() = default;
  ProjectSource(std::string uuid, std::string path,
                std::size_t audio = static_cast<std::size_t>(-1), int audio_num = 0,
                int audio_den = 0, int sample_rate = 0, int channels = 0,
                std::vector<std::size_t> streams = {})
      : source_uuid(std::move(uuid)), canonical_path(std::move(path)), audio_stream(audio),
        audio_time_base_num(audio_num), audio_time_base_den(audio_den),
        audio_sample_rate(sample_rate), audio_channels(channels),
        selected_streams(std::move(streams)) {}
  std::string source_uuid;
  std::string canonical_path;
  std::size_t audio_stream{static_cast<std::size_t>(-1)};
  int audio_time_base_num{};
  int audio_time_base_den{};
  int audio_sample_rate{};
  int audio_channels{};
  std::vector<std::size_t> selected_streams;
};
struct KeptSegment { std::string source_uuid; std::size_t video_stream{}; std::uint64_t first_display_frame{}; std::uint64_t end_display_frame_exclusive{}; };
struct ExportEvidence { std::string source_uuid; std::string output_uuid; std::uint64_t first_frame{}; std::uint64_t end_frame{}; std::string status; };

class Project {
 public:
  void add_source(ProjectSource source) { sources_.push_back(std::move(source)); }
  void add_segment(KeptSegment segment) { segments_.push_back(std::move(segment)); }
  void add_export_evidence(ExportEvidence evidence) { exports_.push_back(std::move(evidence)); }
  void set_chapter_markers(std::vector<std::uint64_t> markers) { chapter_markers_ = std::move(markers); }
  void set_scene_mode(bool enabled) { scene_mode_ = enabled; }
  void set_audio_offset_ms(std::int64_t offset) { audio_offset_ms_ = offset; }
  void set_audio_validation_status(std::string status) { audio_validation_status_ = std::move(status); }
  void set_journal_path(std::string path) { journal_path_ = std::move(path); }
  const std::vector<ProjectSource>& sources() const { return sources_; }
  const std::vector<KeptSegment>& segments() const { return segments_; }
  const std::vector<ExportEvidence>& exports() const { return exports_; }
  const std::vector<std::uint64_t>& chapter_markers() const { return chapter_markers_; }
  bool scene_mode() const { return scene_mode_; }
  std::int64_t audio_offset_ms() const { return audio_offset_ms_; }
  const std::string& journal_path() const { return journal_path_; }
  const std::string& audio_validation_status() const { return audio_validation_status_; }
  bool valid() const;
  std::string to_json() const;
 private:
  std::vector<ProjectSource> sources_;
  std::vector<KeptSegment> segments_;
  std::vector<ExportEvidence> exports_;
  std::vector<std::uint64_t> chapter_markers_;
  bool scene_mode_{};
  std::int64_t audio_offset_ms_{};
  std::string journal_path_;
  std::string audio_validation_status_;
};

}  // namespace smartcut::core
