namespace Backend.Contracts;

public sealed record AdminRiskFlagDto(
    int Id,
    string Source,
    string Type,
    string Severity,
    string Status,
    string Summary,
    string? TwitchUserId,
    string CreatedFromIp,
    DateTimeOffset CreatedAt,
    string MetadataJson,
    string? ReviewNote,
    string? ReviewedByTwitchId,
    DateTimeOffset? ReviewedAt,
    AdminRiskEntityLinkDto[] EntityLinks);

public sealed record AdminRiskEntityLinkDto(
    string Label,
    string EntityType,
    string EntityId,
    string To);

public sealed record AdminRiskCountDto(string Key, int Count);

public sealed record AdminRiskFlagsResponse(
    AdminRiskFlagDto[] Items,
    int TotalCount,
    int ReturnedCount,
    int Offset,
    int Limit,
    bool HasMore,
    AdminRiskCountDto[] SeverityCounts,
    AdminRiskCountDto[] StatusCounts);

public sealed record AdminAuditEntryDto(
    int Id,
    string AdminTwitchUserId,
    string ActionType,
    string EntityType,
    string EntityId,
    string Summary,
    DateTimeOffset CreatedAt,
    string MetadataJson,
    string? CreatedFromIp,
    string UserAgent);

public sealed record AdminAuditEntriesResponse(
    AdminAuditEntryDto[] Items,
    int TotalCount,
    int ReturnedCount,
    string? NextCursor,
    int Limit);

public sealed record AdminNominationReviewItemDto(
    int Id,
    int? CategoryId,
    string CategoryGroupName,
    string CategoryName,
    string SubmittedByTwitchId,
    string CandidateText,
    string? StreamUrl,
    string? ResolvedChannel,
    string? ResolvedPlatform,
    int? AvgViewers,
    int? SuggestedCategoryId,
    string? SuggestedCategoryName,
    int? StreamerIdentityId,
    string TrackerStatus,
    DateTimeOffset? TrackerCheckedAt,
    string TrackingReviewStatus,
    bool RequiresManualReview,
    AdminTrackingFlagHitDto[] TrackingFlags,
    AdminTrackingMetricStateDto[] TrackingMetrics,
    string? TrackingReviewNote,
    string? TrackingReviewedByTwitchId,
    DateTimeOffset? TrackingReviewedAt,
    string Status,
    DateTimeOffset CreatedAt,
    int? CandidateId,
    string? CandidateDisplayName,
    string? ReviewNote,
    string? ReviewedByTwitchId,
    DateTimeOffset? ReviewedAt);

public sealed record AdminNominationReviewGroupDto(
    int Id,
    int[] NominationIds,
    string CategoryGroupName,
    string DisplayName,
    string? StreamUrl,
    string? ResolvedChannel,
    string? ResolvedPlatform,
    int? AvgViewers,
    int? SuggestedCategoryId,
    string? SuggestedCategoryName,
    int? StreamerIdentityId,
    string TrackerStatus,
    DateTimeOffset? TrackerCheckedAt,
    string TrackingReviewStatus,
    bool RequiresManualReview,
    AdminTrackingFlagHitDto[] TrackingFlags,
    AdminTrackingMetricStateDto[] TrackingMetrics,
    string? TrackingReviewNote,
    string? TrackingReviewedByTwitchId,
    DateTimeOffset? TrackingReviewedAt,
    int NominationTally,
    int UniqueSubmitterCount,
    DateTimeOffset FirstSubmittedAt,
    DateTimeOffset LastSubmittedAt);

public sealed record AdminClipSubmissionItemDto(
    int Id,
    int? CategoryId,
    int? CandidateId,
    string SubmittedByTwitchId,
    string ClipUrl,
    string Title,
    string Creator,
    string Platform,
    string Status,
    DateTimeOffset CreatedAt,
    string? ReviewNote,
    string? ReviewedByTwitchId,
    DateTimeOffset? ReviewedAt);

public sealed record ApproveNominationRequest(
    string? DisplayName,
    string? ChannelSlug,
    string? Platform,
    int? CategoryId,
    string? ReviewNote);

public sealed record RejectNominationRequest(string? ReviewNote);

public sealed record ReopenRejectedNominationRequest(string? ReviewNote);

public sealed record UpdateNominationTrackingReviewRequest(
    string Status,
    string? ReviewNote);

public sealed record AdminNominationLinkBlacklistEntryDto(string Url);

public sealed record AdminNominationLinkBlacklistResponse(AdminNominationLinkBlacklistEntryDto[] Entries);

public sealed record UpdateNominationLinkBlacklistRequest(string[] Urls);

public sealed record AddNominationLinkBlacklistEntryRequest(string Url);

public sealed record UpdateClipStatusRequest(
    string Status,
    string? ReviewNote);

public sealed record ResolveRiskFlagRequest(
    string Status,
    string? ReviewNote);

public sealed record BulkResolveRiskFlagsRequest(
    int[] RiskFlagIds,
    string Status,
    string? ReviewNote);

public sealed record AdminRiskRuleDto(
    string Key,
    string Label,
    bool Enabled,
    int Threshold,
    int WindowMinutes,
    string Severity,
    string Description);

public sealed record AdminRiskRulesResponse(AdminRiskRuleDto[] Rules);

public sealed record UpdateRiskRulesRequest(AdminRiskRuleDto[] Rules);

public sealed record AdminWorkflowRuleDto(
    string Key,
    string Label,
    bool Enabled,
    int Limit,
    string Mode,
    string Description);

public sealed record AdminWorkflowRulesResponse(AdminWorkflowRuleDto[] Rules);

public sealed record UpdateWorkflowRulesRequest(AdminWorkflowRuleDto[] Rules);

public sealed record AdminTrackingFlagHitDto(
    string Key,
    string Label,
    string Severity,
    string Description,
    bool RequiresManualReview,
    bool BlocksApproval,
    bool AdminNoteRequiredOnOverride);

public sealed record AdminTrackingMetricStateDto(
    string Key,
    string Label,
    bool Required,
    string SourceSupport,
    bool Present,
    string Value,
    string Description,
    string WindowKey,
    string WindowLabel,
    bool AutoWindowSupported);
