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

// AvailableReaction represents TL type `availableReaction#c077ec01`.
// Animations associated with a message reaction
//
// See https://core.telegram.org/constructor/availableReaction for reference.
type AvailableReaction struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If not set, the reaction can be added to new messages and enabled in chats.
	Inactive bool
	// Whether this reaction can only be used by Telegram Premium users
	Premium bool
	// Reaction emoji
	Reaction string
	// Reaction description
	Title string
	// Static icon for the reaction
	StaticIcon DocumentClass
	// The animated sticker to show when the user opens the reaction dropdown
	AppearAnimation DocumentClass
	// The animated sticker to show when the user hovers over the reaction
	SelectAnimation DocumentClass
	// The animated sticker to show when the reaction is chosen and activated
	ActivateAnimation DocumentClass
	// The background effect (still an animated sticker) to play under the activate_animation
	// when the reaction is chosen and activated
	EffectAnimation DocumentClass
	// The animation that plays around the button when you press an existing reaction (played
	// together with center_icon).
	//
	// Use SetAroundAnimation and GetAroundAnimation helpers.
	AroundAnimation DocumentClass
	// The animation of the emoji inside the button when you press an existing reaction
	// (played together with around_animation).
	//
	// Use SetCenterIcon and GetCenterIcon helpers.
	CenterIcon DocumentClass
}

// AvailableReactionTypeID is TL type id of AvailableReaction.
const AvailableReactionTypeID = 0xc077ec01

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

func ( *AvailableReaction) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Inactive == false) {
		return false
	}
	if !(.Premium == false) {
		return false
	}
	if !(.Reaction == "") {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.StaticIcon == nil) {
		return false
	}
	if !(.AppearAnimation == nil) {
		return false
	}
	if !(.SelectAnimation == nil) {
		return false
	}
	if !(.ActivateAnimation == nil) {
		return false
	}
	if !(.EffectAnimation == nil) {
		return false
	}
	if !(.AroundAnimation == nil) {
		return false
	}
	if !(.CenterIcon == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AvailableReaction from given interface.
func ( *AvailableReaction) ( interface {
	() ( bool)
	() ( bool)
	() ( string)
	() ( string)
	() ( DocumentClass)
	() ( DocumentClass)
	() ( DocumentClass)
	() ( DocumentClass)
	() ( DocumentClass)
	() ( DocumentClass,  bool)
	() ( DocumentClass,  bool)
}) {
	.Inactive = .()
	.Premium = .()
	.Reaction = .()
	.Title = .()
	.StaticIcon = .()
	.AppearAnimation = .()
	.SelectAnimation = .()
	.ActivateAnimation = .()
	.EffectAnimation = .()
	if ,  := .();  {
		.AroundAnimation = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *AvailableReaction) () tdp.Type {
	 := tdp.Type{
		Name: "availableReaction",
		ID:   AvailableReactionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Inactive",
			SchemaName: "inactive",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Premium",
			SchemaName: "premium",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Reaction",
			SchemaName: "reaction",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "StaticIcon",
			SchemaName: "static_icon",
		},
		{
			Name:       "AppearAnimation",
			SchemaName: "appear_animation",
		},
		{
			Name:       "SelectAnimation",
			SchemaName: "select_animation",
		},
		{
			Name:       "ActivateAnimation",
			SchemaName: "activate_animation",
		},
		{
			Name:       "EffectAnimation",
			SchemaName: "effect_animation",
		},
		{
			Name:       "AroundAnimation",
			SchemaName: "around_animation",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "CenterIcon",
			SchemaName: "center_icon",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AvailableReaction) () {
	if !(.Inactive == false) {
		.Flags.Set(0)
	}
	if !(.Premium == false) {
		.Flags.Set(2)
	}
	if !(.AroundAnimation == nil) {
		.Flags.Set(1)
	}
	if !(.CenterIcon == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AvailableReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode availableReaction#c077ec01 as nil")
	}
	.PutID(AvailableReactionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AvailableReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode availableReaction#c077ec01 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field flags: %w", )
	}
	.PutString(.Reaction)
	.PutString(.Title)
	if .StaticIcon == nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field static_icon is nil")
	}
	if  := .StaticIcon.Encode();  != nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field static_icon: %w", )
	}
	if .AppearAnimation == nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field appear_animation is nil")
	}
	if  := .AppearAnimation.Encode();  != nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field appear_animation: %w", )
	}
	if .SelectAnimation == nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field select_animation is nil")
	}
	if  := .SelectAnimation.Encode();  != nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field select_animation: %w", )
	}
	if .ActivateAnimation == nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field activate_animation is nil")
	}
	if  := .ActivateAnimation.Encode();  != nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field activate_animation: %w", )
	}
	if .EffectAnimation == nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field effect_animation is nil")
	}
	if  := .EffectAnimation.Encode();  != nil {
		return fmt.Errorf("unable to encode availableReaction#c077ec01: field effect_animation: %w", )
	}
	if .Flags.Has(1) {
		if .AroundAnimation == nil {
			return fmt.Errorf("unable to encode availableReaction#c077ec01: field around_animation is nil")
		}
		if  := .AroundAnimation.Encode();  != nil {
			return fmt.Errorf("unable to encode availableReaction#c077ec01: field around_animation: %w", )
		}
	}
	if .Flags.Has(1) {
		if .CenterIcon == nil {
			return fmt.Errorf("unable to encode availableReaction#c077ec01: field center_icon is nil")
		}
		if  := .CenterIcon.Encode();  != nil {
			return fmt.Errorf("unable to encode availableReaction#c077ec01: field center_icon: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AvailableReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode availableReaction#c077ec01 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field flags: %w", )
		}
	}
	.Inactive = .Flags.Has(0)
	.Premium = .Flags.Has(2)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field reaction: %w", )
		}
		.Reaction = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field title: %w", )
		}
		.Title = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field static_icon: %w", )
		}
		.StaticIcon = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field appear_animation: %w", )
		}
		.AppearAnimation = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field select_animation: %w", )
		}
		.SelectAnimation = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field activate_animation: %w", )
		}
		.ActivateAnimation = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field effect_animation: %w", )
		}
		.EffectAnimation = 
	}
	if .Flags.Has(1) {
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field around_animation: %w", )
		}
		.AroundAnimation = 
	}
	if .Flags.Has(1) {
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode availableReaction#c077ec01: field center_icon: %w", )
		}
		.CenterIcon = 
	}
	return nil
}

// SetInactive sets value of Inactive conditional field.
func ( *AvailableReaction) ( bool) {
	if  {
		.Flags.Set(0)
		.Inactive = true
	} else {
		.Flags.Unset(0)
		.Inactive = false
	}
}

// GetInactive returns value of Inactive conditional field.
func ( *AvailableReaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetPremium sets value of Premium conditional field.
func ( *AvailableReaction) ( bool) {
	if  {
		.Flags.Set(2)
		.Premium = true
	} else {
		.Flags.Unset(2)
		.Premium = false
	}
}

// GetPremium returns value of Premium conditional field.
func ( *AvailableReaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetReaction returns value of Reaction field.
func ( *AvailableReaction) () ( string) {
	if  == nil {
		return
	}
	return .Reaction
}

// GetTitle returns value of Title field.
func ( *AvailableReaction) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// GetStaticIcon returns value of StaticIcon field.
func ( *AvailableReaction) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .StaticIcon
}

// GetAppearAnimation returns value of AppearAnimation field.
func ( *AvailableReaction) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .AppearAnimation
}

// GetSelectAnimation returns value of SelectAnimation field.
func ( *AvailableReaction) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .SelectAnimation
}

// GetActivateAnimation returns value of ActivateAnimation field.
func ( *AvailableReaction) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .ActivateAnimation
}

// GetEffectAnimation returns value of EffectAnimation field.
func ( *AvailableReaction) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .EffectAnimation
}

// SetAroundAnimation sets value of AroundAnimation conditional field.
func ( *AvailableReaction) ( DocumentClass) {
	.Flags.Set(1)
	.AroundAnimation = 
}

// GetAroundAnimation returns value of AroundAnimation conditional field and
// boolean which is true if field was set.
func ( *AvailableReaction) () ( DocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .AroundAnimation, true
}

// SetCenterIcon sets value of CenterIcon conditional field.
func ( *AvailableReaction) ( DocumentClass) {
	.Flags.Set(1)
	.CenterIcon = 
}

// GetCenterIcon returns value of CenterIcon conditional field and
// boolean which is true if field was set.
func ( *AvailableReaction) () ( DocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .CenterIcon, true
}

// GetStaticIconAsNotEmpty returns mapped value of StaticIcon field.
func ( *AvailableReaction) () (*Document, bool) {
	return .StaticIcon.AsNotEmpty()
}

// GetAppearAnimationAsNotEmpty returns mapped value of AppearAnimation field.
func ( *AvailableReaction) () (*Document, bool) {
	return .AppearAnimation.AsNotEmpty()
}

// GetSelectAnimationAsNotEmpty returns mapped value of SelectAnimation field.
func ( *AvailableReaction) () (*Document, bool) {
	return .SelectAnimation.AsNotEmpty()
}

// GetActivateAnimationAsNotEmpty returns mapped value of ActivateAnimation field.
func ( *AvailableReaction) () (*Document, bool) {
	return .ActivateAnimation.AsNotEmpty()
}

// GetEffectAnimationAsNotEmpty returns mapped value of EffectAnimation field.
func ( *AvailableReaction) () (*Document, bool) {
	return .EffectAnimation.AsNotEmpty()
}

// GetAroundAnimationAsNotEmpty returns mapped value of AroundAnimation conditional field and
// boolean which is true if field was set.
func ( *AvailableReaction) () (*Document, bool) {
	if ,  := .GetAroundAnimation();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// GetCenterIconAsNotEmpty returns mapped value of CenterIcon conditional field and
// boolean which is true if field was set.
func ( *AvailableReaction) () (*Document, bool) {
	if ,  := .GetCenterIcon();  {
		return .AsNotEmpty()
	}
	return nil, false
}