package tui

import (
	"gitgud.io/mike/mpv-manager/pkg/constants"
	"github.com/charmbracelet/bubbles/list"
)

// setupUISelectList creates the UI selection list for choosing MPV overlay
func (m *Model) setupUISelectList() {
	items := []list.Item{
		uiOptionItem{
			id:          constants.UITypeModernZ,
			title:       "ModernZ",
			description: "Classic OSC look with modern features and minimal design",
			recommended: true,
		},
		uiOptionItem{
			id:          constants.UITypeUOSC,
			title:       "UOSC",
			description: "Feature-rich modern UI with touch support and extensive customization",
			recommended: false,
		},
		uiOptionItem{
			id:          constants.UITypeNone,
			title:       "No UI Overlay",
			description: "Use MPV's default on-screen controls",
			recommended: false,
		},
	}

	l := m.createStyledList("Select UI Overlay", items)
	l.SetShowStatusBar(false)
	l.SetFilteringEnabled(false)
	l.SetShowHelp(false)

	m.uiSelectList = l
}

// needsUISelection checks if the install method needs UI overlay selection
func needsUISelection(methodID string) bool {
	// MPV binary installations and package manager installations support UI overlays
	mpvMethods := []string{
		constants.MethodMPVBinary,
		constants.MethodMPVBinaryV3,
		constants.MethodMPVFlatpak,
		constants.MethodMPVSnap,
		constants.MethodMPVPackage,
		constants.MethodMPVBrew,
		constants.MethodMPVApp,
	}

	for _, m := range mpvMethods {
		if methodID == m {
			return true
		}
	}
	return false
}

// getAppNameForMethod gets the display name for an install method
func getAppNameForMethod(methodID string) string {
	if name, ok := constants.MethodIDToName[methodID]; ok {
		return name
	}
	return methodID
}
