using Newtonsoft.Json;
using OF_DL.Models.Dtos.Common;
using OF_DL.Utils;

namespace OF_DL.Models.Dtos.Archived;

public class ListItemDto
{
    private string _rawText = "";

    [JsonProperty("responseType")] public string ResponseType { get; set; } = "";

    [JsonProperty("id")] public long Id { get; set; }

    [JsonProperty("postedAt")] public DateTime PostedAt { get; set; }

    [JsonProperty("postedAtPrecise")] public string PostedAtPrecise { get; set; } = "";

    [JsonProperty("expiredAt")] public object ExpiredAt { get; set; } = new();

    [JsonProperty("author")] public AuthorDto Author { get; set; } = new();

    [JsonProperty("text")] public string Text { get; set; } = "";

    [JsonProperty("rawText")]
    public string RawText
    {
        get
        {
            if (string.IsNullOrEmpty(_rawText))
            {
                _rawText = XmlUtils.EvaluateInnerText(Text);
            }

            return _rawText;
        }
        set => _rawText = value;
    }

    [JsonProperty("lockedText")] public bool? LockedText { get; set; }

    [JsonProperty("isFavorite")] public bool? IsFavorite { get; set; }

    [JsonProperty("canReport")] public bool? CanReport { get; set; }

    [JsonProperty("canDelete")] public bool? CanDelete { get; set; }

    [JsonProperty("canComment")] public bool? CanComment { get; set; }

    [JsonProperty("canEdit")] public bool? CanEdit { get; set; }

    [JsonProperty("isPinned")] public bool? IsPinned { get; set; }

    [JsonProperty("favoritesCount")] public int? FavoritesCount { get; set; }

    [JsonProperty("mediaCount")] public int? MediaCount { get; set; }

    [JsonProperty("isMediaReady")] public bool? IsMediaReady { get; set; }

    [JsonProperty("voting")] public object Voting { get; set; } = new();

    [JsonProperty("isOpened")] public bool IsOpened { get; set; }

    [JsonProperty("canToggleFavorite")] public bool? CanToggleFavorite { get; set; }

    [JsonProperty("streamId")] public object StreamId { get; set; } = new();

    [JsonProperty("price")] public string Price { get; set; } = "";

    [JsonProperty("hasVoting")] public bool? HasVoting { get; set; }

    [JsonProperty("isAddedToBookmarks")] public bool? IsAddedToBookmarks { get; set; }

    [JsonProperty("isArchived")] public bool IsArchived { get; set; }

    [JsonProperty("isPrivateArchived")] public bool? IsPrivateArchived { get; set; }

    [JsonProperty("isDeleted")] public bool? IsDeleted { get; set; }

    [JsonProperty("hasUrl")] public bool? HasUrl { get; set; }

    [JsonProperty("isCouplePeopleMedia")] public bool? IsCouplePeopleMedia { get; set; }

    [JsonProperty("commentsCount")] public int? CommentsCount { get; set; }

    [JsonProperty("mentionedUsers")] public List<object> MentionedUsers { get; set; } = [];

    [JsonProperty("linkedUsers")] public List<object> LinkedUsers { get; set; } = [];

    [JsonProperty("media")] public List<MediumDto> Media { get; set; } = [];

    [JsonProperty("canViewMedia")] public bool? CanViewMedia { get; set; }

    [JsonProperty("preview")] public List<object> Preview { get; set; } = [];

    [JsonProperty("cantCommentReason")] public string CantCommentReason { get; set; } = "";
}
