#pragma once

#include "rm_control/common/result.h"
#include "rm_control/common/robot_types.h"
#include "rm_control/interfaces/robot_arm.h"
#include "rm_control/modules/trajectory/trajectory_file_store.h"

#include <iosfwd>
#include <string>

namespace rm_control::core {

struct DragTeachRecordConfig {
    std::string storage_root;
    std::string session_name;
    int duration_seconds = 15;
    int sample_period_ms = 100;
    bool save_vendor_trajectory = true;
    common::DragTeachStartOptions drag_options;
};

struct DragTeachRecordSummary {
    modules::trajectory::TrajectoryFileSet files;
    int sample_count = 0;
    bool vendor_trajectory_saved = false;
    std::string vendor_save_message;
};

class DragTeachRecorder {
public:
    explicit DragTeachRecorder(interfaces::IRobotArm &robot);

    common::Result<DragTeachRecordSummary> record(const DragTeachRecordConfig &config,
                                                  std::ostream &out);

private:
    common::Result<void> validateConfig(const DragTeachRecordConfig &config) const;

    interfaces::IRobotArm &robot_;
};

} // namespace rm_control::core
