//
// © 2018-2020 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
//

import Foundation

extension IoTPlayer {
	var homeTheaterDisplayName: String {
		var parts = [displayName]
		if isSoundBar {
			var channels = [String]()

            if isHomeTheaterChannelAvailable(.subwoofer) {
                channels.append(NSLocalizedString("SUB", comment: "Abbreviation for subwoofer"))
            }

			if isHomeTheaterChannelAvailable(.leftSurround) {
				channels.append(NSLocalizedString("LS", comment: "Abbreviation for left surround"))
			}
			
			if isHomeTheaterChannelAvailable(.rightSurround) {
				channels.append(NSLocalizedString("RS", comment: "Abbreviation for right surround"))
			}

            if isHomeTheaterChannelAvailable(.leftRearSurround) {
                channels.append(NSLocalizedString("LRS", comment: "Abbreviation for left rear surround"))
            }

            if isHomeTheaterChannelAvailable(.rightRearSurround) {
                channels.append(NSLocalizedString("RRS", comment: "Abbreviation for right rear surround"))
            }

            if isHomeTheaterChannelAvailable(.leftUpfiringSurround) {
                channels.append(NSLocalizedString("LUS", comment: "Abbreviation for left upfiring surround"))
            }

            if isHomeTheaterChannelAvailable(.rightUpfiringSurround) {
                channels.append(NSLocalizedString("RUS", comment: "Abbreviation for right upfiring surround"))
            }

            if isHomeTheaterChannelAvailable(.leftRearUpfiringSurround) {
                channels.append(NSLocalizedString("LRUS", comment: "Abbreviation for left rear upfiring surround"))
            }

            if isHomeTheaterChannelAvailable(.rightRearUpfiringSurround) {
                channels.append(NSLocalizedString("RRUS", comment: "Abbreviation for right rear upfiring surround"))
            }

			if channels.count > 0 {
				let channelsStr = "(" + channels.joined(separator: " + ") + ")"
				parts.append(channelsStr)
			}
		}
		return parts.joined(separator: " ")
	}
}
