using System.Text.Json.Serialization;
using RelayShared.Services;

namespace RelayShared.Rtc;

public sealed class RtcSessionDescription
{
    public string Type { get; set; } = string.Empty;
    public string Sdp { get; set; } = string.Empty;
}

public sealed class RtcOffer
{
    public string ChannelId { get; set; } = string.Empty;
    public string Username { get; set; } = string.Empty;
    public RtcSessionDescription SessionDescription { get; set; } = new();
}

public sealed class RtcAnswer
{
    public string ChannelId { get; set; } = string.Empty;
    public string Username { get; set; } = string.Empty;
    public RtcSessionDescription SessionDescription { get; set; } = new();
}
public class RtcIceCandidate
{
    public required string ChannelId { get; set; }
    public required string Username { get; set; }
    public required IceCandidate Candidate { get; set; }
}

public class IceCandidate
{
    public required string candidate { get; set; }
    public required string sdpMid { get; set; }
    public required int sdpMLineIndex { get; set; }
    public required string usernameFragment { get; set; }
    
}

public sealed class RtcJoinRequest
{
    public string ChannelId { get; set; } = string.Empty;
    public string Username { get; set; } = string.Empty;
}

public sealed class RtcJoinResponse
{
    public string ChannelId { get; set; } = string.Empty;
    public string[] Participants { get; set; } = [];
}

public sealed class RtcLeaveRequest
{
    public string ChannelId { get; set; } = string.Empty;
    public string Username { get; set; } = string.Empty;
}
public sealed class RtcNotificationMessage //TODO: Review for removal
{
    public SignalType? Type { get; set; }
    public string? ChannelId { get; set; }
    public string? Username { get; set; }
    public string? Direction { get; set; }
}
public sealed class RtcSignalMessage //TODO: Review for removal.
{
    [JsonPropertyName("type")]
    public string Type { get; set; } = string.Empty;

    [JsonPropertyName("from")]
    public string From { get; set; } = string.Empty;

    [JsonPropertyName("to")]
    public string To { get; set; } = string.Empty;

    [JsonPropertyName("channelId")]
    public string ChannelId { get; set; } = string.Empty;

    [JsonPropertyName("sdp")]
    public string? Sdp { get; set; }

    [JsonPropertyName("candidate")]
    public string? Candidate { get; set; }

    [JsonPropertyName("sdpMid")]
    public string? SdpMid { get; set; }

    [JsonPropertyName("sdpMLineIndex")]
    public int? SdpMLineIndex { get; set; }

    [JsonPropertyName("isInitiator")]
    public bool IsInitiator { get; set; }
}