using GmRelay.Shared.Features.Sessions.RescheduleSession;
using GmRelay.Shared.Rendering;

namespace GmRelay.Shared.Platform;

public sealed record PlatformMessageRef(
    PlatformKind Platform,
    string ExternalGroupId,
    string? ExternalThreadId,
    string ExternalMessageId);

public sealed record PlatformMessageAction(
    string Key,
    string Label,
    string Payload);

public sealed record PlatformScheduleMessage(
    PlatformGroup Group,
    SessionBatchViewModel View,
    PlatformMessageRef? ExistingMessage,
    string? ImageReference = null);

public sealed record PlatformPrivateMessage(
    PlatformUser Recipient,
    string HtmlText);

public sealed record PlatformInteractionReply(
    string InteractionId,
    string Text,
    bool ShowAlert = false);

public sealed record PlatformCalendarFile(
    PlatformGroup Group,
    string FileName,
    byte[] Content,
    string CaptionHtml,
    IReadOnlyList<PlatformMessageAction> Actions);

public sealed record PlatformSessionParticipant(
    PlatformUser User,
    string RsvpStatus,
    string RegistrationStatus,
    bool IsGm = false);

public sealed record PlatformConfirmationRequest(
    PlatformGroup Group,
    Guid SessionId,
    string Title,
    DateTime ScheduledAt,
    IReadOnlyList<PlatformSessionParticipant> Participants,
    PlatformMessageRef? ExistingMessage = null);

public sealed record PlatformJoinLinkNotification(
    PlatformGroup Group,
    Guid SessionId,
    string Title,
    DateTime ScheduledAt,
    string JoinLink,
    IReadOnlyList<PlatformSessionParticipant> ConfirmedPlayers,
    PlatformMessageRef? ExistingMessage = null);

public enum PlatformDirectSessionNotificationKind
{
    ConfirmationRequest = 0,
    OneHourReminder = 1,
    JoinLink = 2,
    RsvpAllConfirmed = 3,
    RsvpDeclined = 4,
    RescheduleApproved = 5,
    RescheduleRejected = 6
}

public sealed record PlatformDirectSessionNotification(
    PlatformDirectSessionNotificationKind Kind,
    PlatformUser Recipient,
    Guid SessionId,
    string Title,
    DateTime ScheduledAt,
    string? JoinLink = null,
    string? ActorDisplayName = null,
    string? Reason = null);

public sealed record PlatformRsvpMessageUpdate(
    PlatformConfirmationRequest Request,
    bool DisableActions);

public enum PlatformRsvpOutcomeKind
{
    GroupAllConfirmed = 0,
    GmAllConfirmed = 1,
    GmPlayerDeclined = 2
}

public sealed record PlatformRsvpOutcomeNotification(
    PlatformRsvpOutcomeKind Kind,
    PlatformGroup? Group,
    IReadOnlyList<PlatformUser> Recipients,
    Guid SessionId,
    string Title,
    DateTime ScheduledAt,
    string? ActorDisplayName = null);

public sealed record PlatformRescheduleVoteUpdate(
    PlatformGroup Group,
    PlatformMessageRef ExistingMessage,
    Guid ProposalId,
    Guid SessionId,
    string Title,
    DateTime CurrentScheduledAt,
    DateTimeOffset VotingDeadlineAt,
    RescheduleVoteDecision Decision,
    RescheduleOptionDto? SelectedOption,
    IReadOnlyList<RescheduleOptionDto> Options,
    IReadOnlyList<RescheduleOptionVoteDto> Votes,
    IReadOnlyList<VoteParticipantDto> Participants);
