package ccolor

import (
	
	
	
)

// String color style string. TODO
// eg:
//
//	s := String("red,bold")
//	s.Println("some text message")
type String string

// Style for color render.
type Style struct {
	Fg   Color
	Bg   Color
	Opts []Color
}

// NewStyle fg, bg and options
func ( Color,  Color,  ...Color) *Style {
	return &Style{
		Fg:   ,
		Bg:   ,
		Opts: ,
	}
}

// Print like fmt.Print, but with color
func ( *Style) ( ...any) {
	doPrint(.String(), fmt.Sprint(...))
}

// Println like fmt.Println, but with color
func ( *Style) ( ...any) {
	doPrintln(.String(), )
}

// Printf render and print text
func ( *Style) ( string,  ...any) {
	doPrint(.String(), fmt.Sprintf(, ...))
}

// Sprint like fmt.Sprint, but with color
func ( *Style) ( ...any) string {
	return RenderString(.String(), fmt.Sprint(...))
}

// Sprintln like fmt.Sprintln, but with color
func ( *Style) ( ...any) string {
	return RenderWithSpaces(.String(), ...)
}

// Sprintf format and render message.
func ( *Style) ( string,  ...any) string {
	return RenderString(.String(), fmt.Sprintf(, ...))
}

// Fprint like fmt.Fprint, but with color
func ( *Style) ( io.Writer,  ...any) {
	doPrintTo(, .String(), fmt.Sprint(...))
}

// Fprintf like fmt.Fprintf, but with color
func ( *Style) ( io.Writer,  string,  ...any) {
	doPrintTo(, .String(), fmt.Sprintf(, ...))
}

// Fprintln like fmt.Fprintln, but with color
func ( *Style) ( io.Writer,  ...any) {
	doPrintlnTo(, .String(), )
}

// String convert style setting to color code string.
func ( *Style) () string {
	var  []string
	if .Fg.IsFg() {
		 = append(, .Fg.String())
	}
	if .Bg.IsBg() {
		 = append(, .Bg.String())
	}

	if len(.Opts) > 0 {
		 = append(, ColorsToCode(.Opts...))
	}

	if len() == 0 {
		return ""
	}
	return strings.Join(, ";")
}

var (
	// Info color style
	Info = &Style{Fg: FgGreen}
	// Warn color style
	Warn = &Style{Fg: FgYellow}
	// Error color style
	Error = NewStyle(FgLightWhite, BgRed)
	// Debug color style
	Debug = &Style{Fg: FgCyan}
	// Success color style
	Success = &Style{Fg: FgGreen, Opts: []Color{OpBold}}
)