namespace Flyshot.ControllerClientCompat;

/// <summary>
/// 保存一条已上传到兼容层内存目录中的飞拍轨迹，供 HTTP API 层列出、执行和删除。
/// </summary>
public sealed class ControllerClientCompatUploadedTrajectory
{
    /// <summary>
    /// 初始化一条飞拍轨迹快照，并立即复制所有数组，避免调用方后续原地修改。
    /// </summary>
    /// <param name="name">轨迹名称。</param>
    /// <param name="waypoints">关节路点集合。</param>
    /// <param name="shotFlags">拍摄标志集合。</param>
    /// <param name="offsetValues">偏移周期集合。</param>
    /// <param name="addressGroups">地址组集合。</param>
    public ControllerClientCompatUploadedTrajectory(
        string name,
        IEnumerable<IReadOnlyList<double>> waypoints,
        IEnumerable<bool> shotFlags,
        IEnumerable<int> offsetValues,
        IEnumerable<IReadOnlyList<int>> addressGroups)
    {
        if (string.IsNullOrWhiteSpace(name))
        {
            throw new ArgumentException("轨迹名称不能为空。", nameof(name));
        }

        ArgumentNullException.ThrowIfNull(waypoints);
        ArgumentNullException.ThrowIfNull(shotFlags);
        ArgumentNullException.ThrowIfNull(offsetValues);
        ArgumentNullException.ThrowIfNull(addressGroups);

        Name = name;
        Waypoints = waypoints.Select(static waypoint => waypoint.ToArray()).ToArray();
        ShotFlags = shotFlags.ToArray();
        OffsetValues = offsetValues.ToArray();
        AddressGroups = addressGroups.Select(static group => group.ToArray()).ToArray();
    }

    /// <summary>
    /// 获取轨迹名称。
    /// </summary>
    public string Name { get; }

    /// <summary>
    /// 获取已复制的关节路点集合。
    /// </summary>
    public IReadOnlyList<double[]> Waypoints { get; }

    /// <summary>
    /// 获取拍摄标志集合。
    /// </summary>
    public IReadOnlyList<bool> ShotFlags { get; }

    /// <summary>
    /// 获取偏移周期集合。
    /// </summary>
    public IReadOnlyList<int> OffsetValues { get; }

    /// <summary>
    /// 获取地址组集合。
    /// </summary>
    public IReadOnlyList<int[]> AddressGroups { get; }
}
