// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// HelpPeerColorOption represents TL type `help.peerColorOption#ef8430ab`.
// Contains info about a color palette »¹.
//
// Links:
//  1. https://core.telegram.org/api/colors
//
// See https://core.telegram.org/constructor/help.peerColorOption for reference.
type HelpPeerColorOption struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this palette should not be displayed as an option to the user when choosing a
	// palette to apply to profile pages or message accents.
	Hidden bool
	// Palette ID.
	ColorID int
	// Light mode palette. Will be empty for IDs 0 to 6 inclusive, in which case a palette
	// containing a single color from the following colors should be used: red, orange,
	// violet, green, cyan, blue, pink for indexes 0 to 6.
	//
	// Use SetColors and GetColors helpers.
	Colors HelpPeerColorSetClass
	// Dark mode palette. Optional, defaults to the palette in colors (or the autogenerated
	// palette for IDs 0 to 6) if absent.
	//
	// Use SetDarkColors and GetDarkColors helpers.
	DarkColors HelpPeerColorSetClass
	// ChannelMinLevel field of HelpPeerColorOption.
	//
	// Use SetChannelMinLevel and GetChannelMinLevel helpers.
	ChannelMinLevel int
}

// HelpPeerColorOptionTypeID is TL type id of HelpPeerColorOption.
const HelpPeerColorOptionTypeID = 0xef8430ab

// Ensuring interfaces in compile-time for HelpPeerColorOption.
var (
	_ bin.Encoder     = &HelpPeerColorOption{}
	_ bin.Decoder     = &HelpPeerColorOption{}
	_ bin.BareEncoder = &HelpPeerColorOption{}
	_ bin.BareDecoder = &HelpPeerColorOption{}
)

func ( *HelpPeerColorOption) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Hidden == false) {
		return false
	}
	if !(.ColorID == 0) {
		return false
	}
	if !(.Colors == nil) {
		return false
	}
	if !(.DarkColors == nil) {
		return false
	}
	if !(.ChannelMinLevel == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *HelpPeerColorOption) () string {
	if  == nil {
		return "HelpPeerColorOption(nil)"
	}
	type  HelpPeerColorOption
	return fmt.Sprintf("HelpPeerColorOption%+v", (*))
}

// FillFrom fills HelpPeerColorOption from given interface.
func ( *HelpPeerColorOption) ( interface {
	() ( bool)
	() ( int)
	() ( HelpPeerColorSetClass,  bool)
	() ( HelpPeerColorSetClass,  bool)
	() ( int,  bool)
}) {
	.Hidden = .()
	.ColorID = .()
	if ,  := .();  {
		.Colors = 
	}

	if ,  := .();  {
		.DarkColors = 
	}

	if ,  := .();  {
		.ChannelMinLevel = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*HelpPeerColorOption) () uint32 {
	return HelpPeerColorOptionTypeID
}

// TypeName returns name of type in TL schema.
func (*HelpPeerColorOption) () string {
	return "help.peerColorOption"
}

// TypeInfo returns info about TL type.
func ( *HelpPeerColorOption) () tdp.Type {
	 := tdp.Type{
		Name: "help.peerColorOption",
		ID:   HelpPeerColorOptionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hidden",
			SchemaName: "hidden",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ColorID",
			SchemaName: "color_id",
		},
		{
			Name:       "Colors",
			SchemaName: "colors",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "DarkColors",
			SchemaName: "dark_colors",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ChannelMinLevel",
			SchemaName: "channel_min_level",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *HelpPeerColorOption) () {
	if !(.Hidden == false) {
		.Flags.Set(0)
	}
	if !(.Colors == nil) {
		.Flags.Set(1)
	}
	if !(.DarkColors == nil) {
		.Flags.Set(2)
	}
	if !(.ChannelMinLevel == 0) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *HelpPeerColorOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.peerColorOption#ef8430ab as nil")
	}
	.PutID(HelpPeerColorOptionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpPeerColorOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.peerColorOption#ef8430ab as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode help.peerColorOption#ef8430ab: field flags: %w", )
	}
	.PutInt(.ColorID)
	if .Flags.Has(1) {
		if .Colors == nil {
			return fmt.Errorf("unable to encode help.peerColorOption#ef8430ab: field colors is nil")
		}
		if  := .Colors.Encode();  != nil {
			return fmt.Errorf("unable to encode help.peerColorOption#ef8430ab: field colors: %w", )
		}
	}
	if .Flags.Has(2) {
		if .DarkColors == nil {
			return fmt.Errorf("unable to encode help.peerColorOption#ef8430ab: field dark_colors is nil")
		}
		if  := .DarkColors.Encode();  != nil {
			return fmt.Errorf("unable to encode help.peerColorOption#ef8430ab: field dark_colors: %w", )
		}
	}
	if .Flags.Has(3) {
		.PutInt(.ChannelMinLevel)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpPeerColorOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.peerColorOption#ef8430ab to nil")
	}
	if  := .ConsumeID(HelpPeerColorOptionTypeID);  != nil {
		return fmt.Errorf("unable to decode help.peerColorOption#ef8430ab: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpPeerColorOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.peerColorOption#ef8430ab to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode help.peerColorOption#ef8430ab: field flags: %w", )
		}
	}
	.Hidden = .Flags.Has(0)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.peerColorOption#ef8430ab: field color_id: %w", )
		}
		.ColorID = 
	}
	if .Flags.Has(1) {
		,  := DecodeHelpPeerColorSet()
		if  != nil {
			return fmt.Errorf("unable to decode help.peerColorOption#ef8430ab: field colors: %w", )
		}
		.Colors = 
	}
	if .Flags.Has(2) {
		,  := DecodeHelpPeerColorSet()
		if  != nil {
			return fmt.Errorf("unable to decode help.peerColorOption#ef8430ab: field dark_colors: %w", )
		}
		.DarkColors = 
	}
	if .Flags.Has(3) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.peerColorOption#ef8430ab: field channel_min_level: %w", )
		}
		.ChannelMinLevel = 
	}
	return nil
}

// SetHidden sets value of Hidden conditional field.
func ( *HelpPeerColorOption) ( bool) {
	if  {
		.Flags.Set(0)
		.Hidden = true
	} else {
		.Flags.Unset(0)
		.Hidden = false
	}
}

// GetHidden returns value of Hidden conditional field.
func ( *HelpPeerColorOption) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetColorID returns value of ColorID field.
func ( *HelpPeerColorOption) () ( int) {
	if  == nil {
		return
	}
	return .ColorID
}

// SetColors sets value of Colors conditional field.
func ( *HelpPeerColorOption) ( HelpPeerColorSetClass) {
	.Flags.Set(1)
	.Colors = 
}

// GetColors returns value of Colors conditional field and
// boolean which is true if field was set.
func ( *HelpPeerColorOption) () ( HelpPeerColorSetClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Colors, true
}

// SetDarkColors sets value of DarkColors conditional field.
func ( *HelpPeerColorOption) ( HelpPeerColorSetClass) {
	.Flags.Set(2)
	.DarkColors = 
}

// GetDarkColors returns value of DarkColors conditional field and
// boolean which is true if field was set.
func ( *HelpPeerColorOption) () ( HelpPeerColorSetClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .DarkColors, true
}

// SetChannelMinLevel sets value of ChannelMinLevel conditional field.
func ( *HelpPeerColorOption) ( int) {
	.Flags.Set(3)
	.ChannelMinLevel = 
}

// GetChannelMinLevel returns value of ChannelMinLevel conditional field and
// boolean which is true if field was set.
func ( *HelpPeerColorOption) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .ChannelMinLevel, true
}