#pragma once

#include "rm_control/common/result.h"
#include "rm_control/common/robot_types.h"

#include <string>
#include <vector>

namespace rm_control::modules::trajectory {

struct TrajectoryStoragePaths {
    std::string root_dir;
    std::string csv_dir;
    std::string vendor_dir;
    std::string converted_dir;
    std::string reports_dir;
};

struct TrajectoryFileSet {
    std::string session_name;
    std::string csv_path;
    std::string vendor_path;
    std::string converted_cpp_path;
    std::string report_path;
};

std::string timestampString();
std::string sanitizeSessionName(const std::string &raw_name);
std::string defaultTrajectoryStorageRoot();

common::Result<TrajectoryStoragePaths> ensureTrajectoryStorage(const std::string &root_dir);
common::Result<TrajectoryFileSet> makeTrajectoryFileSet(const std::string &root_dir,
                                                        const std::string &session_name);

common::Result<void> writeTrajectoryCsv(const std::string &csv_path,
                                        const std::vector<common::TrajectorySample> &samples);
common::Result<std::vector<common::TrajectorySample>> loadTrajectoryCsv(const std::string &csv_path);

common::Result<void> exportTcpPathCpp(const std::string &cpp_path,
                                      const std::vector<common::TrajectorySample> &samples,
                                      const std::string &session_name);

} // namespace rm_control::modules::trajectory
