using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class AdvertisingDataStatusInfo
{
	public static AdvertisingDataStatusEnum ValueToAdvertisingDataStatus(uint value)
	{
		switch (value)
		{
		case 0u:
			return AdvertisingDataStatusEnum.Data_complete;
		case 1u:
			return AdvertisingDataStatusEnum.Data_incomplete_more_data_to_come;
		case 2u:
			return AdvertisingDataStatusEnum.Data_incomplete_data_truncated_no_more_to_come;
		default:
			if (value >= 3 && value <= 255)
			{
				return AdvertisingDataStatusEnum.Reserved_for_future_use;
			}
			return AdvertisingDataStatusEnum.InvalidAdvertisingDataStatusValue;
		}
	}

	public static uint AdvertisingDataStatusToValue(AdvertisingDataStatusEnum enumItem)
	{
		return enumItem switch
		{
			AdvertisingDataStatusEnum.Data_complete => 0u, 
			AdvertisingDataStatusEnum.Data_incomplete_more_data_to_come => 1u, 
			AdvertisingDataStatusEnum.Data_incomplete_data_truncated_no_more_to_come => 2u, 
			AdvertisingDataStatusEnum.Reserved_for_future_use => 3u, 
			_ => uint.MaxValue, 
		};
	}

	public static string AdvertisingDataStatusToString(AdvertisingDataStatusEnum enumItem)
	{
		return enumItem switch
		{
			AdvertisingDataStatusEnum.Data_complete => "Data complete", 
			AdvertisingDataStatusEnum.Data_incomplete_more_data_to_come => "Data incomplete, more data to come", 
			AdvertisingDataStatusEnum.Data_incomplete_data_truncated_no_more_to_come => "Data incomplete, data truncated, no more to come", 
			AdvertisingDataStatusEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid AdvertisingDataStatus Value", 
		};
	}

	public static string AdvertisingDataStatusToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Data complete");
		stringBuilder.AppendLine("0x1 = Data incomplete, more data to come");
		stringBuilder.AppendLine("0x2 = Data incomplete, data truncated, no more to come");
		stringBuilder.AppendLine("0x3-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
