using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class AdvertisingSidInfo
{
	public static AdvertisingSidEnum ValueToAdvertisingSid(uint value)
	{
		if (value >= 0 && value <= 15)
		{
			return AdvertisingSidEnum.Value_of_the_Advertising_SID_subfield_in_the_ADI_field_of_the_PDU;
		}
		if (value >= 16 && value <= 255)
		{
			return AdvertisingSidEnum.Reserved_for_future_use;
		}
		return AdvertisingSidEnum.InvalidAdvertisingSidValue;
	}

	public static uint AdvertisingSidToValue(AdvertisingSidEnum enumItem)
	{
		return enumItem switch
		{
			AdvertisingSidEnum.Value_of_the_Advertising_SID_subfield_in_the_ADI_field_of_the_PDU => 0u, 
			AdvertisingSidEnum.Reserved_for_future_use => 16u, 
			_ => uint.MaxValue, 
		};
	}

	public static string AdvertisingSidToString(AdvertisingSidEnum enumItem)
	{
		return enumItem switch
		{
			AdvertisingSidEnum.Value_of_the_Advertising_SID_subfield_in_the_ADI_field_of_the_PDU => "Value of the Advertising SID subfield in the ADI field of the PDU", 
			AdvertisingSidEnum.Reserved_for_future_use => "Reserved for future use.", 
			_ => "Invalid AdvertisingSid Value", 
		};
	}

	public static string AdvertisingSidToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0-0xF = Value of the Advertising SID subfield in the ADI field of the PDU");
		stringBuilder.AppendLine("0x10-0xFF = Reserved for future use.");
		return stringBuilder.ToString();
	}
}
