// 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{}
)

// ThemeSettings represents TL type `themeSettings#fa58b6d4`.
// Theme settings
//
// See https://core.telegram.org/constructor/themeSettings for reference.
type ThemeSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, the freeform gradient fill needs to be animated on every sent message.
	MessageColorsAnimated bool
	// Base theme
	BaseTheme BaseThemeClass
	// Accent color, ARGB format
	AccentColor int
	// Accent color of outgoing messages in ARGB format
	//
	// Use SetOutboxAccentColor and GetOutboxAccentColor helpers.
	OutboxAccentColor int
	// The fill to be used as a background for outgoing messages, in RGB24 format. If just
	// one or two equal colors are provided, describes a solid fill of a background. If two
	// different colors are provided, describes the top and bottom colors of a 0-degree
	// gradient.If three or four colors are provided, describes a freeform gradient fill of a
	// background.
	//
	// Use SetMessageColors and GetMessageColors helpers.
	MessageColors []int
	// Wallpaper¹
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers
	//
	// Use SetWallpaper and GetWallpaper helpers.
	Wallpaper WallPaperClass
}

// ThemeSettingsTypeID is TL type id of ThemeSettings.
const ThemeSettingsTypeID = 0xfa58b6d4

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

func ( *ThemeSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.MessageColorsAnimated == false) {
		return false
	}
	if !(.BaseTheme == nil) {
		return false
	}
	if !(.AccentColor == 0) {
		return false
	}
	if !(.OutboxAccentColor == 0) {
		return false
	}
	if !(.MessageColors == nil) {
		return false
	}
	if !(.Wallpaper == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ThemeSettings from given interface.
func ( *ThemeSettings) ( interface {
	() ( bool)
	() ( BaseThemeClass)
	() ( int)
	() ( int,  bool)
	() ( []int,  bool)
	() ( WallPaperClass,  bool)
}) {
	.MessageColorsAnimated = .()
	.BaseTheme = .()
	.AccentColor = .()
	if ,  := .();  {
		.OutboxAccentColor = 
	}

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

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

}

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

// TypeName returns name of type in TL schema.
func (*ThemeSettings) () string {
	return "themeSettings"
}

// TypeInfo returns info about TL type.
func ( *ThemeSettings) () tdp.Type {
	 := tdp.Type{
		Name: "themeSettings",
		ID:   ThemeSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MessageColorsAnimated",
			SchemaName: "message_colors_animated",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "BaseTheme",
			SchemaName: "base_theme",
		},
		{
			Name:       "AccentColor",
			SchemaName: "accent_color",
		},
		{
			Name:       "OutboxAccentColor",
			SchemaName: "outbox_accent_color",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "MessageColors",
			SchemaName: "message_colors",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Wallpaper",
			SchemaName: "wallpaper",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ThemeSettings) () {
	if !(.MessageColorsAnimated == false) {
		.Flags.Set(2)
	}
	if !(.OutboxAccentColor == 0) {
		.Flags.Set(3)
	}
	if !(.MessageColors == nil) {
		.Flags.Set(0)
	}
	if !(.Wallpaper == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *ThemeSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode themeSettings#fa58b6d4 as nil")
	}
	.PutID(ThemeSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ThemeSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode themeSettings#fa58b6d4 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode themeSettings#fa58b6d4: field flags: %w", )
	}
	if .BaseTheme == nil {
		return fmt.Errorf("unable to encode themeSettings#fa58b6d4: field base_theme is nil")
	}
	if  := .BaseTheme.Encode();  != nil {
		return fmt.Errorf("unable to encode themeSettings#fa58b6d4: field base_theme: %w", )
	}
	.PutInt(.AccentColor)
	if .Flags.Has(3) {
		.PutInt(.OutboxAccentColor)
	}
	if .Flags.Has(0) {
		.PutVectorHeader(len(.MessageColors))
		for ,  := range .MessageColors {
			.PutInt()
		}
	}
	if .Flags.Has(1) {
		if .Wallpaper == nil {
			return fmt.Errorf("unable to encode themeSettings#fa58b6d4: field wallpaper is nil")
		}
		if  := .Wallpaper.Encode();  != nil {
			return fmt.Errorf("unable to encode themeSettings#fa58b6d4: field wallpaper: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ThemeSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode themeSettings#fa58b6d4 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode themeSettings#fa58b6d4: field flags: %w", )
		}
	}
	.MessageColorsAnimated = .Flags.Has(2)
	{
		,  := DecodeBaseTheme()
		if  != nil {
			return fmt.Errorf("unable to decode themeSettings#fa58b6d4: field base_theme: %w", )
		}
		.BaseTheme = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode themeSettings#fa58b6d4: field accent_color: %w", )
		}
		.AccentColor = 
	}
	if .Flags.Has(3) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode themeSettings#fa58b6d4: field outbox_accent_color: %w", )
		}
		.OutboxAccentColor = 
	}
	if .Flags.Has(0) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode themeSettings#fa58b6d4: field message_colors: %w", )
		}

		if  > 0 {
			.MessageColors = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode themeSettings#fa58b6d4: field message_colors: %w", )
			}
			.MessageColors = append(.MessageColors, )
		}
	}
	if .Flags.Has(1) {
		,  := DecodeWallPaper()
		if  != nil {
			return fmt.Errorf("unable to decode themeSettings#fa58b6d4: field wallpaper: %w", )
		}
		.Wallpaper = 
	}
	return nil
}

// SetMessageColorsAnimated sets value of MessageColorsAnimated conditional field.
func ( *ThemeSettings) ( bool) {
	if  {
		.Flags.Set(2)
		.MessageColorsAnimated = true
	} else {
		.Flags.Unset(2)
		.MessageColorsAnimated = false
	}
}

// GetMessageColorsAnimated returns value of MessageColorsAnimated conditional field.
func ( *ThemeSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetBaseTheme returns value of BaseTheme field.
func ( *ThemeSettings) () ( BaseThemeClass) {
	if  == nil {
		return
	}
	return .BaseTheme
}

// GetAccentColor returns value of AccentColor field.
func ( *ThemeSettings) () ( int) {
	if  == nil {
		return
	}
	return .AccentColor
}

// SetOutboxAccentColor sets value of OutboxAccentColor conditional field.
func ( *ThemeSettings) ( int) {
	.Flags.Set(3)
	.OutboxAccentColor = 
}

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

// SetMessageColors sets value of MessageColors conditional field.
func ( *ThemeSettings) ( []int) {
	.Flags.Set(0)
	.MessageColors = 
}

// GetMessageColors returns value of MessageColors conditional field and
// boolean which is true if field was set.
func ( *ThemeSettings) () ( []int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .MessageColors, true
}

// SetWallpaper sets value of Wallpaper conditional field.
func ( *ThemeSettings) ( WallPaperClass) {
	.Flags.Set(1)
	.Wallpaper = 
}

// GetWallpaper returns value of Wallpaper conditional field and
// boolean which is true if field was set.
func ( *ThemeSettings) () ( WallPaperClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Wallpaper, true
}