using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class LePhyInfo
{
	public static LePhyEnum ValueToLePhy(uint value)
	{
		if (value == 1)
		{
			return LePhyEnum.LE_1M;
		}
		if (value == 2)
		{
			return LePhyEnum.LE_2M;
		}
		if (value == 3)
		{
			return LePhyEnum.LE_Coded;
		}
		if (value >= 4 && value <= 255)
		{
			return LePhyEnum.Reserved_for_future_use;
		}
		return LePhyEnum.InvalidLePhyValue;
	}

	public static uint LePhyToValue(LePhyEnum enumItem)
	{
		return enumItem switch
		{
			LePhyEnum.LE_1M => 1u, 
			LePhyEnum.LE_2M => 2u, 
			LePhyEnum.LE_Coded => 3u, 
			LePhyEnum.Reserved_for_future_use => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string LePhyToString(LePhyEnum enumItem)
	{
		return enumItem switch
		{
			LePhyEnum.LE_1M => "LE 1M PHY", 
			LePhyEnum.LE_2M => "LE 2M PHY", 
			LePhyEnum.LE_Coded => "LE Coded PHY", 
			LePhyEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid LePhy Value", 
		};
	}

	public static string LePhyToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x1 = LE 1M PHY");
		stringBuilder.AppendLine("0x2 = LE 2M PHY");
		stringBuilder.AppendLine("0x3 = LE Coded PHY");
		stringBuilder.AppendLine("0x4-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
