using System.Collections.Generic;
namespace LibMpc
{
    public partial class Commands
    {
        /// 
        /// https://www.musicpd.org/doc/protocol/output_commands.html
        /// 
        public class Output
        {
            /// 
            /// Turns an output off.
            /// 
            public class DisableOutput : IMpcCommand
            {
                private readonly int _outputId;
                public DisableOutput(int outputId)
                {
                    _outputId = outputId;
                }
                public string Value => string.Join(" ", "disableoutput", _outputId);
                public IDictionary FormatResponse(IList> response)
                {
                    return response.ToDefaultDictionary();
                }
            }
            /// 
            /// Turns an output on.
            /// 
            public class EnableOutput : IMpcCommand
            {
                private readonly int _outputId;
                public EnableOutput(int outputId)
                {
                    _outputId = outputId;
                }
                public string Value => string.Join(" ", "enableoutput", _outputId);
                public IDictionary FormatResponse(IList> response)
                {
                    return response.ToDefaultDictionary();
                }
            }
            // TODO: toggleoutput // Turns an output on or off, depending on the current state.
            /// 
            /// Shows information about all outputs.
            /// 
            public class Outputs : IMpcCommand>>
            {
                public string Value => "outputs";
                
                public IDictionary>> FormatResponse(IList> response)
                {
                    var result = new Dictionary>>
                    {
                        { "outputs", new List>() }
                    };
                    for (var i = 0; i < response.Count; i += 3)
                    {
                        var outputId = response[i].Value;
                        var outputName = response[i + 1].Value;
                        var outputEnabled = response[i + 2].Value;
                        result["outputs"].Add(new Dictionary
                        {
                            {"id", outputId},
                            {"name", outputName},
                            {"enabled", outputEnabled}
                        });
                    }
                    return result;
                }
            }
        }
    }
}