using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class VoiceSettingMapInfo
{
	public static VoiceSettingMapEnumCollection ValueToVoiceSettingMap(uint value)
	{
		VoiceSettingMapEnumCollection voiceSettingMapEnumCollection = new VoiceSettingMapEnumCollection();
		voiceSettingMapEnumCollection.AirCodingFormat = VoiceSettingMapEnumCollection.AirCodingFormatInfo.ValueToAirCodingFormat(value & 3u);
		voiceSettingMapEnumCollection.InputSampleSize = VoiceSettingMapEnumCollection.InputSampleSizeInfo.ValueToInputSampleSize((value & 0x20) >> 5);
		voiceSettingMapEnumCollection.InputDataFormat = VoiceSettingMapEnumCollection.InputDataFormatInfo.ValueToInputDataFormat((value & 0xC0) >> 6);
		voiceSettingMapEnumCollection.InputCoding = VoiceSettingMapEnumCollection.InputCodingInfo.ValueToInputCoding((value & 0x300) >> 8);
		return voiceSettingMapEnumCollection;
	}

	public static uint VoiceSettingMapToValue(VoiceSettingMapEnumCollection enumCollection)
	{
		uint num = 0u;
		num |= VoiceSettingMapEnumCollection.AirCodingFormatInfo.AirCodingFormatToValue(enumCollection.AirCodingFormat);
		num |= VoiceSettingMapEnumCollection.InputSampleSizeInfo.InputSampleSizeToValue(enumCollection.InputSampleSize) << 5;
		num |= VoiceSettingMapEnumCollection.InputDataFormatInfo.InputDataFormatToValue(enumCollection.InputDataFormat) << 6;
		return num | (VoiceSettingMapEnumCollection.InputCodingInfo.InputCodingToValue(enumCollection.InputCoding) << 8);
	}

	public static string VoiceSettingMapToString(VoiceSettingMapEnumCollection enumCollection)
	{
		string text = "";
		text = text + "Air Coding Format: " + VoiceSettingMapEnumCollection.AirCodingFormatInfo.AirCodingFormatToString(enumCollection.AirCodingFormat) + "\r\n";
		text = text + "Input Sample Size: " + VoiceSettingMapEnumCollection.InputSampleSizeInfo.InputSampleSizeToString(enumCollection.InputSampleSize) + "\r\n";
		text = text + "Input Data Format: " + VoiceSettingMapEnumCollection.InputDataFormatInfo.InputDataFormatToString(enumCollection.InputDataFormat) + "\r\n";
		text = text + "Input Coding: " + VoiceSettingMapEnumCollection.InputCodingInfo.InputCodingToString(enumCollection.InputCoding) + "\r\n";
		return text.TrimEnd('\r', '\n');
	}

	public static string VoiceSettingMapToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("Bits 1-0: Air Coding Format");
		stringBuilder.AppendLine(VoiceSettingMapEnumCollection.AirCodingFormatInfo.AirCodingFormatToDescription());
		stringBuilder.AppendLine("Bits 4-2: Linear PCM Bit Position");
		stringBuilder.AppendLine("Bit 5: Input Sample Size");
		stringBuilder.AppendLine(VoiceSettingMapEnumCollection.InputSampleSizeInfo.InputSampleSizeToDescription());
		stringBuilder.AppendLine("Bits 7-6: Input Data Format");
		stringBuilder.AppendLine(VoiceSettingMapEnumCollection.InputDataFormatInfo.InputDataFormatToDescription());
		stringBuilder.AppendLine("Bits 9-8: Input Coding");
		stringBuilder.AppendLine(VoiceSettingMapEnumCollection.InputCodingInfo.InputCodingToDescription());
		stringBuilder.AppendLine("Bits 15-10: Reserved");
		return stringBuilder.ToString();
	}
}
