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

// WallPaperSettings represents TL type `wallPaperSettings#372efcd0`.
// Wallpaper¹ rendering information.
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/constructor/wallPaperSettings for reference.
type WallPaperSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// For image wallpapers »¹: if set, the JPEG must be downscaled to fit in 450x450
	// square and then box-blurred with radius 12.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#image-wallpapers
	Blur bool
	// If set, the background needs to be slightly moved when the device is rotated.
	Motion bool
	// Used for solid »¹, gradient »² and freeform gradient »³ fills.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#solid-fill
	//  2) https://core.telegram.org/api/wallpapers#gradient-fill
	//  3) https://core.telegram.org/api/wallpapers#freeform-gradient-fill
	//
	// Use SetBackgroundColor and GetBackgroundColor helpers.
	BackgroundColor int
	// Used for gradient »¹ and freeform gradient »² fills.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#gradient-fill
	//  2) https://core.telegram.org/api/wallpapers#freeform-gradient-fill
	//
	// Use SetSecondBackgroundColor and GetSecondBackgroundColor helpers.
	SecondBackgroundColor int
	// Used for freeform gradient »¹ fills.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#freeform-gradient-fill
	//
	// Use SetThirdBackgroundColor and GetThirdBackgroundColor helpers.
	ThirdBackgroundColor int
	// Used for freeform gradient »¹ fills.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#freeform-gradient-fill
	//
	// Use SetFourthBackgroundColor and GetFourthBackgroundColor helpers.
	FourthBackgroundColor int
	// Used for pattern wallpapers »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#pattern-wallpapers
	//
	// Use SetIntensity and GetIntensity helpers.
	Intensity int
	// Clockwise rotation angle of the gradient, in degrees; 0-359. Should be always
	// divisible by 45.
	//
	// Use SetRotation and GetRotation helpers.
	Rotation int
	// Emoticon field of WallPaperSettings.
	//
	// Use SetEmoticon and GetEmoticon helpers.
	Emoticon string
}

// WallPaperSettingsTypeID is TL type id of WallPaperSettings.
const WallPaperSettingsTypeID = 0x372efcd0

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

func ( *WallPaperSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Blur == false) {
		return false
	}
	if !(.Motion == false) {
		return false
	}
	if !(.BackgroundColor == 0) {
		return false
	}
	if !(.SecondBackgroundColor == 0) {
		return false
	}
	if !(.ThirdBackgroundColor == 0) {
		return false
	}
	if !(.FourthBackgroundColor == 0) {
		return false
	}
	if !(.Intensity == 0) {
		return false
	}
	if !(.Rotation == 0) {
		return false
	}
	if !(.Emoticon == "") {
		return false
	}

	return true
}

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

// FillFrom fills WallPaperSettings from given interface.
func ( *WallPaperSettings) ( interface {
	() ( bool)
	() ( bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( string,  bool)
}) {
	.Blur = .()
	.Motion = .()
	if ,  := .();  {
		.BackgroundColor = 
	}

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

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

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *WallPaperSettings) () tdp.Type {
	 := tdp.Type{
		Name: "wallPaperSettings",
		ID:   WallPaperSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Blur",
			SchemaName: "blur",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Motion",
			SchemaName: "motion",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "BackgroundColor",
			SchemaName: "background_color",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "SecondBackgroundColor",
			SchemaName: "second_background_color",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "ThirdBackgroundColor",
			SchemaName: "third_background_color",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "FourthBackgroundColor",
			SchemaName: "fourth_background_color",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Intensity",
			SchemaName: "intensity",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Rotation",
			SchemaName: "rotation",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "Emoticon",
			SchemaName: "emoticon",
			Null:       !.Flags.Has(7),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *WallPaperSettings) () {
	if !(.Blur == false) {
		.Flags.Set(1)
	}
	if !(.Motion == false) {
		.Flags.Set(2)
	}
	if !(.BackgroundColor == 0) {
		.Flags.Set(0)
	}
	if !(.SecondBackgroundColor == 0) {
		.Flags.Set(4)
	}
	if !(.ThirdBackgroundColor == 0) {
		.Flags.Set(5)
	}
	if !(.FourthBackgroundColor == 0) {
		.Flags.Set(6)
	}
	if !(.Intensity == 0) {
		.Flags.Set(3)
	}
	if !(.Rotation == 0) {
		.Flags.Set(4)
	}
	if !(.Emoticon == "") {
		.Flags.Set(7)
	}
}

// Encode implements bin.Encoder.
func ( *WallPaperSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallPaperSettings#372efcd0 as nil")
	}
	.PutID(WallPaperSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WallPaperSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallPaperSettings#372efcd0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode wallPaperSettings#372efcd0: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.BackgroundColor)
	}
	if .Flags.Has(4) {
		.PutInt(.SecondBackgroundColor)
	}
	if .Flags.Has(5) {
		.PutInt(.ThirdBackgroundColor)
	}
	if .Flags.Has(6) {
		.PutInt(.FourthBackgroundColor)
	}
	if .Flags.Has(3) {
		.PutInt(.Intensity)
	}
	if .Flags.Has(4) {
		.PutInt(.Rotation)
	}
	if .Flags.Has(7) {
		.PutString(.Emoticon)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WallPaperSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallPaperSettings#372efcd0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode wallPaperSettings#372efcd0: field flags: %w", )
		}
	}
	.Blur = .Flags.Has(1)
	.Motion = .Flags.Has(2)
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode wallPaperSettings#372efcd0: field background_color: %w", )
		}
		.BackgroundColor = 
	}
	if .Flags.Has(4) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode wallPaperSettings#372efcd0: field second_background_color: %w", )
		}
		.SecondBackgroundColor = 
	}
	if .Flags.Has(5) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode wallPaperSettings#372efcd0: field third_background_color: %w", )
		}
		.ThirdBackgroundColor = 
	}
	if .Flags.Has(6) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode wallPaperSettings#372efcd0: field fourth_background_color: %w", )
		}
		.FourthBackgroundColor = 
	}
	if .Flags.Has(3) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode wallPaperSettings#372efcd0: field intensity: %w", )
		}
		.Intensity = 
	}
	if .Flags.Has(4) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode wallPaperSettings#372efcd0: field rotation: %w", )
		}
		.Rotation = 
	}
	if .Flags.Has(7) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode wallPaperSettings#372efcd0: field emoticon: %w", )
		}
		.Emoticon = 
	}
	return nil
}

// SetBlur sets value of Blur conditional field.
func ( *WallPaperSettings) ( bool) {
	if  {
		.Flags.Set(1)
		.Blur = true
	} else {
		.Flags.Unset(1)
		.Blur = false
	}
}

// GetBlur returns value of Blur conditional field.
func ( *WallPaperSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetMotion sets value of Motion conditional field.
func ( *WallPaperSettings) ( bool) {
	if  {
		.Flags.Set(2)
		.Motion = true
	} else {
		.Flags.Unset(2)
		.Motion = false
	}
}

// GetMotion returns value of Motion conditional field.
func ( *WallPaperSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

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

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

// SetSecondBackgroundColor sets value of SecondBackgroundColor conditional field.
func ( *WallPaperSettings) ( int) {
	.Flags.Set(4)
	.SecondBackgroundColor = 
}

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

// SetThirdBackgroundColor sets value of ThirdBackgroundColor conditional field.
func ( *WallPaperSettings) ( int) {
	.Flags.Set(5)
	.ThirdBackgroundColor = 
}

// GetThirdBackgroundColor returns value of ThirdBackgroundColor conditional field and
// boolean which is true if field was set.
func ( *WallPaperSettings) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .ThirdBackgroundColor, true
}

// SetFourthBackgroundColor sets value of FourthBackgroundColor conditional field.
func ( *WallPaperSettings) ( int) {
	.Flags.Set(6)
	.FourthBackgroundColor = 
}

// GetFourthBackgroundColor returns value of FourthBackgroundColor conditional field and
// boolean which is true if field was set.
func ( *WallPaperSettings) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .FourthBackgroundColor, true
}

// SetIntensity sets value of Intensity conditional field.
func ( *WallPaperSettings) ( int) {
	.Flags.Set(3)
	.Intensity = 
}

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

// SetRotation sets value of Rotation conditional field.
func ( *WallPaperSettings) ( int) {
	.Flags.Set(4)
	.Rotation = 
}

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

// SetEmoticon sets value of Emoticon conditional field.
func ( *WallPaperSettings) ( string) {
	.Flags.Set(7)
	.Emoticon = 
}

// GetEmoticon returns value of Emoticon conditional field and
// boolean which is true if field was set.
func ( *WallPaperSettings) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(7) {
		return , false
	}
	return .Emoticon, true
}