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

// AccountThemesNotModified represents TL type `account.themesNotModified#f41eb622`.
// No new themes were installed
//
// See https://core.telegram.org/constructor/account.themesNotModified for reference.
type AccountThemesNotModified struct {
}

// AccountThemesNotModifiedTypeID is TL type id of AccountThemesNotModified.
const AccountThemesNotModifiedTypeID = 0xf41eb622

// construct implements constructor of AccountThemesClass.
func ( AccountThemesNotModified) () AccountThemesClass { return & }

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

	_ AccountThemesClass = &AccountThemesNotModified{}
)

func ( *AccountThemesNotModified) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AccountThemesNotModified) () string {
	return "account.themesNotModified"
}

// TypeInfo returns info about TL type.
func ( *AccountThemesNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "account.themesNotModified",
		ID:   AccountThemesNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountThemesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.themesNotModified#f41eb622 as nil")
	}
	.PutID(AccountThemesNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountThemesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.themesNotModified#f41eb622 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountThemesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.themesNotModified#f41eb622 to nil")
	}
	return nil
}

// AccountThemes represents TL type `account.themes#9a3d8c6d`.
// Installed themes
//
// See https://core.telegram.org/constructor/account.themes for reference.
type AccountThemes struct {
	// Hash for pagination, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
	// Themes
	Themes []Theme
}

// AccountThemesTypeID is TL type id of AccountThemes.
const AccountThemesTypeID = 0x9a3d8c6d

// construct implements constructor of AccountThemesClass.
func ( AccountThemes) () AccountThemesClass { return & }

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

	_ AccountThemesClass = &AccountThemes{}
)

func ( *AccountThemes) () bool {
	if  == nil {
		return true
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Themes == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountThemes from given interface.
func ( *AccountThemes) ( interface {
	() ( int64)
	() ( []Theme)
}) {
	.Hash = .()
	.Themes = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountThemes) () string {
	return "account.themes"
}

// TypeInfo returns info about TL type.
func ( *AccountThemes) () tdp.Type {
	 := tdp.Type{
		Name: "account.themes",
		ID:   AccountThemesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Themes",
			SchemaName: "themes",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountThemes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.themes#9a3d8c6d as nil")
	}
	.PutID(AccountThemesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountThemes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.themes#9a3d8c6d as nil")
	}
	.PutLong(.Hash)
	.PutVectorHeader(len(.Themes))
	for ,  := range .Themes {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.themes#9a3d8c6d: field themes element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountThemes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.themes#9a3d8c6d to nil")
	}
	if  := .ConsumeID(AccountThemesTypeID);  != nil {
		return fmt.Errorf("unable to decode account.themes#9a3d8c6d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountThemes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.themes#9a3d8c6d to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode account.themes#9a3d8c6d: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.themes#9a3d8c6d: field themes: %w", )
		}

		if  > 0 {
			.Themes = make([]Theme, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  Theme
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.themes#9a3d8c6d: field themes: %w", )
			}
			.Themes = append(.Themes, )
		}
	}
	return nil
}

// GetHash returns value of Hash field.
func ( *AccountThemes) () ( int64) {
	if  == nil {
		return
	}
	return .Hash
}

// GetThemes returns value of Themes field.
func ( *AccountThemes) () ( []Theme) {
	if  == nil {
		return
	}
	return .Themes
}

// AccountThemesClassName is schema name of AccountThemesClass.
const AccountThemesClassName = "account.Themes"

// AccountThemesClass represents account.Themes generic type.
//
// See https://core.telegram.org/type/account.Themes for reference.
//
// Example:
//
//	g, err := tg.DecodeAccountThemes(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AccountThemesNotModified: // account.themesNotModified#f41eb622
//	case *tg.AccountThemes: // account.themes#9a3d8c6d
//	default: panic(v)
//	}
type AccountThemesClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AccountThemesClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// AsModified tries to map AccountThemesClass to AccountThemes.
	AsModified() (*AccountThemes, bool)
}

// AsModified tries to map AccountThemesNotModified to AccountThemes.
func ( *AccountThemesNotModified) () (*AccountThemes, bool) {
	return nil, false
}

// AsModified tries to map AccountThemes to AccountThemes.
func ( *AccountThemes) () (*AccountThemes, bool) {
	return , true
}

// DecodeAccountThemes implements binary de-serialization for AccountThemesClass.
func ( *bin.Buffer) (AccountThemesClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AccountThemesNotModifiedTypeID:
		// Decoding account.themesNotModified#f41eb622.
		 := AccountThemesNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountThemesClass: %w", )
		}
		return &, nil
	case AccountThemesTypeID:
		// Decoding account.themes#9a3d8c6d.
		 := AccountThemes{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountThemesClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AccountThemesClass: %w", bin.NewUnexpectedID())
	}
}

// AccountThemes boxes the AccountThemesClass providing a helper.
type AccountThemesBox struct {
	Themes AccountThemesClass
}

// Decode implements bin.Decoder for AccountThemesBox.
func ( *AccountThemesBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode AccountThemesBox to nil")
	}
	,  := DecodeAccountThemes()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.Themes = 
	return nil
}

// Encode implements bin.Encode for AccountThemesBox.
func ( *AccountThemesBox) ( *bin.Buffer) error {
	if  == nil || .Themes == nil {
		return fmt.Errorf("unable to encode AccountThemesClass as nil")
	}
	return .Themes.Encode()
}