using Divooka.Framework.Plugin;
using Divooka.Multimedia.Image;

namespace CustomPlugin
{
    public struct Profile
    {
        public string Nickname { get; set; }
        public string[] WorkingExperience { get; set; }
    }
    public struct ComplexType
    {
        public string Name { get; set; }
        public string Abstract { get; set; }
        public int Age { get; set; }
        public Profile Profile { get; set; }
    }
    public static class MyTool
    {
        /// <summary>
        /// Make a new profile for the person.
        /// </summary>
        /// <param name="abstract" textFormat="text"></param>
        /// <returns name="Profile"></returns>
        /// <snap>https://publication.tor1.cdn.digitaloceanspaces.com/Websites/MethodoxWiki/Images/Divooka-ProceduralContext_Example.jpg</snap>
        /// <youtube>https://youtu.be/oyzLJae3foY?si=2D1nRic9PBAI9ZTv</youtube>
        public static ComplexType MakeProfile(string name = "Alice", string @abstract = "")
        {
            return new ComplexType()
            {
                Name = name,
                Abstract = @abstract,
                Age = 23
            };
        }
        /// <hidden>true</hidden>
        public static double GetAge()
        {
            return 0;
        }
    }
    public static class InternalType
    {
        public static void Random()
        {

        }
    }

    public class MyCustomPluginDefinition : IDevookaEnginePlugin
    {
        #region Lifetime
        public void Initialize(IPluginServiceProvider provider)
        {
            IPluginServiceProvider.PluginFeature featureSet = provider.GetFeatureSet();
            if (featureSet.HasFlag(IPluginServiceProvider.PluginFeature.DynamicPackages))
            {
                provider.RegisterPackages(typedToolboxes: [
                     new("My Toolbox 2222", typeof(MyTool), false),
                ]);
            }
            if (featureSet.HasFlag(IPluginServiceProvider.PluginFeature.ConnectorVisualCustomizations))
            {
                provider.RegisterTypeConnectionAppearance(typeof(ComplexType), IPluginServiceProvider.BuiltinConnectorShape.HollowSquare, Colors.MediumSlateBlue);
            }
            if (featureSet.HasFlag(IPluginServiceProvider.PluginFeature.PreviewProcessor))
            {
                provider.RegisterPreviewProcessor(typeof(ComplexType), value =>
                {
                    var instance = (ComplexType)value;
                    return $"Name: {instance.Name}; Age: {instance.Age}";
                });
            }
        }
        public void Shutdown(IPluginServiceProvider provider)
        {
        }
        #endregion

        #region Callbacks
        #endregion
    }
}
