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

// BotAppSettings represents TL type `botAppSettings#c99b1950`.
// Mini app »¹ settings
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//
// See https://core.telegram.org/constructor/botAppSettings for reference.
type BotAppSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// SVG placeholder logo, compressed using the same format used for vector thumbnails »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/files#vector-thumbnails
	//
	// Use SetPlaceholderPath and GetPlaceholderPath helpers.
	PlaceholderPath []byte
	// Default light mode background color
	//
	// Use SetBackgroundColor and GetBackgroundColor helpers.
	BackgroundColor int
	// Default dark mode background color
	//
	// Use SetBackgroundDarkColor and GetBackgroundDarkColor helpers.
	BackgroundDarkColor int
	// Default light mode header color
	//
	// Use SetHeaderColor and GetHeaderColor helpers.
	HeaderColor int
	// Default dark mode header color
	//
	// Use SetHeaderDarkColor and GetHeaderDarkColor helpers.
	HeaderDarkColor int
}

// BotAppSettingsTypeID is TL type id of BotAppSettings.
const BotAppSettingsTypeID = 0xc99b1950

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

func ( *BotAppSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.PlaceholderPath == nil) {
		return false
	}
	if !(.BackgroundColor == 0) {
		return false
	}
	if !(.BackgroundDarkColor == 0) {
		return false
	}
	if !(.HeaderColor == 0) {
		return false
	}
	if !(.HeaderDarkColor == 0) {
		return false
	}

	return true
}

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

// FillFrom fills BotAppSettings from given interface.
func ( *BotAppSettings) ( interface {
	() ( []byte,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
}) {
	if ,  := .();  {
		.PlaceholderPath = 
	}

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *BotAppSettings) () tdp.Type {
	 := tdp.Type{
		Name: "botAppSettings",
		ID:   BotAppSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PlaceholderPath",
			SchemaName: "placeholder_path",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "BackgroundColor",
			SchemaName: "background_color",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "BackgroundDarkColor",
			SchemaName: "background_dark_color",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "HeaderColor",
			SchemaName: "header_color",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "HeaderDarkColor",
			SchemaName: "header_dark_color",
			Null:       !.Flags.Has(4),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *BotAppSettings) () {
	if !(.PlaceholderPath == nil) {
		.Flags.Set(0)
	}
	if !(.BackgroundColor == 0) {
		.Flags.Set(1)
	}
	if !(.BackgroundDarkColor == 0) {
		.Flags.Set(2)
	}
	if !(.HeaderColor == 0) {
		.Flags.Set(3)
	}
	if !(.HeaderDarkColor == 0) {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *BotAppSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botAppSettings#c99b1950 as nil")
	}
	.PutID(BotAppSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotAppSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botAppSettings#c99b1950 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode botAppSettings#c99b1950: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutBytes(.PlaceholderPath)
	}
	if .Flags.Has(1) {
		.PutInt(.BackgroundColor)
	}
	if .Flags.Has(2) {
		.PutInt(.BackgroundDarkColor)
	}
	if .Flags.Has(3) {
		.PutInt(.HeaderColor)
	}
	if .Flags.Has(4) {
		.PutInt(.HeaderDarkColor)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotAppSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botAppSettings#c99b1950 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode botAppSettings#c99b1950: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode botAppSettings#c99b1950: field placeholder_path: %w", )
		}
		.PlaceholderPath = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode botAppSettings#c99b1950: field background_color: %w", )
		}
		.BackgroundColor = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode botAppSettings#c99b1950: field background_dark_color: %w", )
		}
		.BackgroundDarkColor = 
	}
	if .Flags.Has(3) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode botAppSettings#c99b1950: field header_color: %w", )
		}
		.HeaderColor = 
	}
	if .Flags.Has(4) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode botAppSettings#c99b1950: field header_dark_color: %w", )
		}
		.HeaderDarkColor = 
	}
	return nil
}

// SetPlaceholderPath sets value of PlaceholderPath conditional field.
func ( *BotAppSettings) ( []byte) {
	.Flags.Set(0)
	.PlaceholderPath = 
}

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

// SetBackgroundColor sets value of BackgroundColor conditional field.
func ( *BotAppSettings) ( int) {
	.Flags.Set(1)
	.BackgroundColor = 
}

// GetBackgroundColor returns value of BackgroundColor conditional field and
// boolean which is true if field was set.
func ( *BotAppSettings) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .BackgroundColor, true
}

// SetBackgroundDarkColor sets value of BackgroundDarkColor conditional field.
func ( *BotAppSettings) ( int) {
	.Flags.Set(2)
	.BackgroundDarkColor = 
}

// GetBackgroundDarkColor returns value of BackgroundDarkColor conditional field and
// boolean which is true if field was set.
func ( *BotAppSettings) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .BackgroundDarkColor, true
}

// SetHeaderColor sets value of HeaderColor conditional field.
func ( *BotAppSettings) ( int) {
	.Flags.Set(3)
	.HeaderColor = 
}

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

// SetHeaderDarkColor sets value of HeaderDarkColor conditional field.
func ( *BotAppSettings) ( int) {
	.Flags.Set(4)
	.HeaderDarkColor = 
}

// GetHeaderDarkColor returns value of HeaderDarkColor conditional field and
// boolean which is true if field was set.
func ( *BotAppSettings) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .HeaderDarkColor, true
}