using Newtonsoft.Json.Linq;
using System;

namespace InABox.Core
{
    public class DFLayoutNotesFieldProperties : DFLayoutFieldProperties<string[], string[]?>
    {
        
        [EditorSequence(-995)]
        [NotesEditor]
        public override string[] Default { get; set; }
        
        public override string FormatValue(string[]? value)
        {
            if(value is string[] arr)
            {
                return string.Join(", ", arr);
            }
            else
            {
                return "";
            }
        }

        public override void SerializeValue(DFSaveStorageEntry entry, string[]? value)
        {
            entry.SetValue(value);
        }

        public override string[]? DeserializeValue(DFLoadStorageEntry entry)
        {
            return entry.GetValue<string[]>();
        }

        public override string[] GetValue(string[]? value)
        {
            return value ?? Default;
        }
    }
}