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

// AccountChatThemesNotModified represents TL type `account.chatThemesNotModified#e011e1c4`.
// The available chat themes were not modified
//
// See https://core.telegram.org/constructor/account.chatThemesNotModified for reference.
type AccountChatThemesNotModified struct {
}

// AccountChatThemesNotModifiedTypeID is TL type id of AccountChatThemesNotModified.
const AccountChatThemesNotModifiedTypeID = 0xe011e1c4

// construct implements constructor of AccountChatThemesClass.
func ( AccountChatThemesNotModified) () AccountChatThemesClass { return & }

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

	_ AccountChatThemesClass = &AccountChatThemesNotModified{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *AccountChatThemesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.chatThemesNotModified#e011e1c4 as nil")
	}
	.PutID(AccountChatThemesNotModifiedTypeID)
	return .EncodeBare()
}

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

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

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

// AccountChatThemes represents TL type `account.chatThemes#be098173`.
// Available chat themes¹
//
// Links:
//  1. https://core.telegram.org/api/themes#chat-themes
//
// See https://core.telegram.org/constructor/account.chatThemes for reference.
type AccountChatThemes struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Hash to pass to the method that returned this constructor, to avoid refetching the
	// result if it hasn't changed.
	Hash int64
	// Themes.
	Themes []ChatThemeClass
	// Chats mentioned in the themes field.
	Chats []ChatClass
	// Users mentioned in the themes field.
	Users []UserClass
	// Next offset for pagination.
	//
	// Use SetNextOffset and GetNextOffset helpers.
	NextOffset string
}

// AccountChatThemesTypeID is TL type id of AccountChatThemes.
const AccountChatThemesTypeID = 0xbe098173

// construct implements constructor of AccountChatThemesClass.
func ( AccountChatThemes) () AccountChatThemesClass { return & }

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

	_ AccountChatThemesClass = &AccountChatThemes{}
)

func ( *AccountChatThemes) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Themes == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.NextOffset == "") {
		return false
	}

	return true
}

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

// FillFrom fills AccountChatThemes from given interface.
func ( *AccountChatThemes) ( interface {
	() ( int64)
	() ( []ChatThemeClass)
	() ( []ChatClass)
	() ( []UserClass)
	() ( string,  bool)
}) {
	.Hash = .()
	.Themes = .()
	.Chats = .()
	.Users = .()
	if ,  := .();  {
		.NextOffset = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *AccountChatThemes) () tdp.Type {
	 := tdp.Type{
		Name: "account.chatThemes",
		ID:   AccountChatThemesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Themes",
			SchemaName: "themes",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "NextOffset",
			SchemaName: "next_offset",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountChatThemes) () {
	if !(.NextOffset == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountChatThemes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.chatThemes#be098173 as nil")
	}
	.PutID(AccountChatThemesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountChatThemes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.chatThemes#be098173 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.chatThemes#be098173: field flags: %w", )
	}
	.PutLong(.Hash)
	.PutVectorHeader(len(.Themes))
	for ,  := range .Themes {
		if  == nil {
			return fmt.Errorf("unable to encode account.chatThemes#be098173: field themes element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.chatThemes#be098173: field themes element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode account.chatThemes#be098173: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.chatThemes#be098173: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode account.chatThemes#be098173: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.chatThemes#be098173: field users element with index %d: %w", , )
		}
	}
	if .Flags.Has(0) {
		.PutString(.NextOffset)
	}
	return nil
}

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

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

		if  > 0 {
			.Themes = make([]ChatThemeClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChatTheme()
			if  != nil {
				return fmt.Errorf("unable to decode account.chatThemes#be098173: field themes: %w", )
			}
			.Themes = append(.Themes, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.chatThemes#be098173: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode account.chatThemes#be098173: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.chatThemes#be098173: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode account.chatThemes#be098173: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.chatThemes#be098173: field next_offset: %w", )
		}
		.NextOffset = 
	}
	return nil
}

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

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

// GetChats returns value of Chats field.
func ( *AccountChatThemes) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

// GetUsers returns value of Users field.
func ( *AccountChatThemes) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// SetNextOffset sets value of NextOffset conditional field.
func ( *AccountChatThemes) ( string) {
	.Flags.Set(0)
	.NextOffset = 
}

// GetNextOffset returns value of NextOffset conditional field and
// boolean which is true if field was set.
func ( *AccountChatThemes) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .NextOffset, true
}

// MapThemes returns field Themes wrapped in ChatThemeClassArray helper.
func ( *AccountChatThemes) () ( ChatThemeClassArray) {
	return ChatThemeClassArray(.Themes)
}

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *AccountChatThemes) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *AccountChatThemes) () ( UserClassArray) {
	return UserClassArray(.Users)
}

// AccountChatThemesClassName is schema name of AccountChatThemesClass.
const AccountChatThemesClassName = "account.ChatThemes"

// AccountChatThemesClass represents account.ChatThemes generic type.
//
// See https://core.telegram.org/type/account.ChatThemes for reference.
//
// Constructors:
//   - [AccountChatThemesNotModified]
//   - [AccountChatThemes]
//
// Example:
//
//	g, err := tg.DecodeAccountChatThemes(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AccountChatThemesNotModified: // account.chatThemesNotModified#e011e1c4
//	case *tg.AccountChatThemes: // account.chatThemes#be098173
//	default: panic(v)
//	}
type AccountChatThemesClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AccountChatThemesClass

	// 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 AccountChatThemesClass to AccountChatThemes.
	AsModified() (*AccountChatThemes, bool)
}

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

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

// DecodeAccountChatThemes implements binary de-serialization for AccountChatThemesClass.
func ( *bin.Buffer) (AccountChatThemesClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AccountChatThemesNotModifiedTypeID:
		// Decoding account.chatThemesNotModified#e011e1c4.
		 := AccountChatThemesNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountChatThemesClass: %w", )
		}
		return &, nil
	case AccountChatThemesTypeID:
		// Decoding account.chatThemes#be098173.
		 := AccountChatThemes{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountChatThemesClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AccountChatThemesClass: %w", bin.NewUnexpectedID())
	}
}

// AccountChatThemes boxes the AccountChatThemesClass providing a helper.
type AccountChatThemesBox struct {
	ChatThemes AccountChatThemesClass
}

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

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