package ansi

import (
	
	
)

// SetPalette sets the palette color for the given index. The index is a 16
// color index between 0 and 15. The color is a 24-bit RGB color.
//
//	OSC P n rrggbb BEL
//
// Where n is the color index in hex (0-f), and rrggbb is the color in
// hexadecimal format (e.g., ff0000 for red).
//
// This sequence is specific to the Linux Console and may not work in other
// terminal emulators.
//
// See https://man7.org/linux/man-pages/man4/console_codes.4.html
func ( int,  color.Color) string {
	if  == nil ||  < 0 ||  > 15 {
		return ""
	}
	, , ,  := .RGBA()
	return fmt.Sprintf("\x1b]P%x%02x%02x%02x\x07", , >>8, >>8, >>8)
}

// ResetPalette resets the color palette to the default values.
//
// This sequence is specific to the Linux Console and may not work in other
// terminal emulators.
//
// See https://man7.org/linux/man-pages/man4/console_codes.4.html
const ResetPalette = "\x1b]R\x07"