using System.Text;

namespace QCRPG.TSL.ZigBee.Packets;

public static class MlmeScanTypeInfo
{
	public static MlmeScanTypeEnum ValueToMlmeScanType(uint value)
	{
		switch (value)
		{
		case 0u:
			return MlmeScanTypeEnum.ED_SCAN;
		case 1u:
			return MlmeScanTypeEnum.ACTIVE_SCAN;
		case 2u:
			return MlmeScanTypeEnum.PASSIVE_SCAN;
		case 3u:
			return MlmeScanTypeEnum.ORPHAN_SCAN;
		default:
			if (value >= 4 && value <= 255)
			{
				return MlmeScanTypeEnum.RESERVED;
			}
			return MlmeScanTypeEnum.InvalidMlmeScanTypeValue;
		}
	}

	public static uint MlmeScanTypeToValue(MlmeScanTypeEnum enumItem)
	{
		return enumItem switch
		{
			MlmeScanTypeEnum.ED_SCAN => 0u, 
			MlmeScanTypeEnum.ACTIVE_SCAN => 1u, 
			MlmeScanTypeEnum.PASSIVE_SCAN => 2u, 
			MlmeScanTypeEnum.ORPHAN_SCAN => 3u, 
			MlmeScanTypeEnum.RESERVED => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string MlmeScanTypeToString(MlmeScanTypeEnum enumItem)
	{
		return enumItem switch
		{
			MlmeScanTypeEnum.ED_SCAN => "ED scan (optional for RFD)", 
			MlmeScanTypeEnum.ACTIVE_SCAN => "active scan (optional for RFD)", 
			MlmeScanTypeEnum.PASSIVE_SCAN => "passive scan", 
			MlmeScanTypeEnum.ORPHAN_SCAN => "orphan scan", 
			MlmeScanTypeEnum.RESERVED => "RESERVED", 
			_ => "Invalid MlmeScanType Value", 
		};
	}

	public static string MlmeScanTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = ED scan (optional for RFD)");
		stringBuilder.AppendLine("0x1 = active scan (optional for RFD)");
		stringBuilder.AppendLine("0x2 = passive scan");
		stringBuilder.AppendLine("0x3 = orphan scan");
		stringBuilder.AppendLine("0x4-0xFF = RESERVED");
		return stringBuilder.ToString();
	}
}
