using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class SlotDurationsInfo
{
	public static SlotDurationsEnum ValueToSlotDurations(uint value)
	{
		switch (value)
		{
		case 0u:
			return SlotDurationsEnum.NO_Switching_and_Sampling;
		case 1u:
			return SlotDurationsEnum.Switching_and_sampling_slots_are_1_us_each;
		case 2u:
			return SlotDurationsEnum.Switching_and_sampling_slots_are_2_us_each;
		default:
			if (value >= 3 && value <= 255)
			{
				return SlotDurationsEnum.Reserved_for_future_use;
			}
			return SlotDurationsEnum.InvalidSlotDurationsValue;
		}
	}

	public static uint SlotDurationsToValue(SlotDurationsEnum enumItem)
	{
		return enumItem switch
		{
			SlotDurationsEnum.NO_Switching_and_Sampling => 0u, 
			SlotDurationsEnum.Switching_and_sampling_slots_are_1_us_each => 1u, 
			SlotDurationsEnum.Switching_and_sampling_slots_are_2_us_each => 2u, 
			SlotDurationsEnum.Reserved_for_future_use => 3u, 
			_ => uint.MaxValue, 
		};
	}

	public static string SlotDurationsToString(SlotDurationsEnum enumItem)
	{
		return enumItem switch
		{
			SlotDurationsEnum.NO_Switching_and_Sampling => "NO_Switching_and_Sampling", 
			SlotDurationsEnum.Switching_and_sampling_slots_are_1_us_each => "Switching and sampling slots are 1 us each", 
			SlotDurationsEnum.Switching_and_sampling_slots_are_2_us_each => "Switching and sampling slots are 2 us each", 
			SlotDurationsEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid SlotDurations Value", 
		};
	}

	public static string SlotDurationsToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = NO_Switching_and_Sampling");
		stringBuilder.AppendLine("0x1 = Switching and sampling slots are 1 us each");
		stringBuilder.AppendLine("0x2 = Switching and sampling slots are 2 us each");
		stringBuilder.AppendLine("0x3-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
