using System;

namespace InABox.Core
{
    public interface IEntityDocument<T> : IEntityDocument where T : IEntityLink
    {
        T EntityLink { get; }
    }

    [UserTracking(typeof(User))]
    public abstract class EntityDocument<T> : Entity, IPersistent, IRemotable, IEntityDocument<T> where T : BaseObject, IEntityLink, new()
    {
        [EntityRelationship(DeleteAction.SetNull)]
        [EditorSequence(2)]
        public DocumentTypeLink Type => InitializeField(ref _type, nameof(Type));
        private DocumentTypeLink? _type;

        [EntityRelationship(DeleteAction.Cascade)]
        [NullEditor]
        public T EntityLink => InitializeField(ref _entityLink, nameof(EntityLink));
        private T? _entityLink;
        
        [EntityRelationship(DeleteAction.Cascade)]
        [EditorSequence(1)]
        public DocumentLink DocumentLink => InitializeField(ref _documentLink, nameof(DocumentLink));
        private DocumentLink? _documentLink;

        [TimestampEditor(Visible = Visible.Optional)]
        [EditorSequence(3)]
        public DateTime Superceded { get; set; }

        [NullEditor]
        public byte[]? Thumbnail { get; set; }
        
        [MemoEditor]
        public String Notes { get; set; }

        //[NullEditor]
        //public string Annotations { get; set; }
    }

    public enum EntityDocumentAnnotationType
    {
        Line,
        Ellipse,
        Rectangle,
        Text,
        Ink,
        OKStamp,
        WarningStamp,
        ErrorStamp
    }

    [UserTracking(typeof(User))]
    public class EntityDocumentAnnotation : Entity, IPersistent, IRemotable, ILicense<CoreLicense>
    {
        public Guid EntityDocument { get; set; }

        public int Page { get; set; }

        public EntityDocumentAnnotationType Type { get; set; }

        public string Data { get; set; } = "";
    }
}