// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

package ui

import "github.com/charmbracelet/lipgloss"

// Style wraps lipgloss.Style to conditionally render based on output mode.
type Style struct {
	style lipgloss.Style
}

// Render applies the style to the given text, or returns plain text in plain mode.
func (s Style) Render(strs ...string) string {
	if IsPlain() {
		result := ""
		for _, str := range strs {
			result += str
		}

		return result
	}

	return s.style.Render(strs...)
}

// Style returns the underlying lipgloss.Style for advanced use.
func (s Style) Style() lipgloss.Style {
	return s.style
}

// Terminal output styles using ANSI colors for broad compatibility.
//
//nolint:gochecknoglobals // intentional globals for styled output
var (
	Success = Style{lipgloss.NewStyle().Foreground(lipgloss.Color("2"))} // green
	Warning = Style{lipgloss.NewStyle().Foreground(lipgloss.Color("3"))} // yellow
	Error   = Style{lipgloss.NewStyle().Foreground(lipgloss.Color("1"))} // red
	Bold    = Style{lipgloss.NewStyle().Bold(true)}
)
