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

// ChatTheme represents TL type `chatTheme#c3dffc04`.
// A chat theme
//
// See https://core.telegram.org/constructor/chatTheme for reference.
type ChatTheme struct {
	// The emoji identifying the chat theme.
	Emoticon string
}

// ChatThemeTypeID is TL type id of ChatTheme.
const ChatThemeTypeID = 0xc3dffc04

// construct implements constructor of ChatThemeClass.
func ( ChatTheme) () ChatThemeClass { return & }

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

	_ ChatThemeClass = &ChatTheme{}
)

func ( *ChatTheme) () bool {
	if  == nil {
		return true
	}
	if !(.Emoticon == "") {
		return false
	}

	return true
}

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

// FillFrom fills ChatTheme from given interface.
func ( *ChatTheme) ( interface {
	() ( string)
}) {
	.Emoticon = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatTheme) () tdp.Type {
	 := tdp.Type{
		Name: "chatTheme",
		ID:   ChatThemeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Emoticon",
			SchemaName: "emoticon",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatTheme) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatTheme#c3dffc04 as nil")
	}
	.PutID(ChatThemeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatTheme) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatTheme#c3dffc04 as nil")
	}
	.PutString(.Emoticon)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatTheme) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatTheme#c3dffc04 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode chatTheme#c3dffc04: field emoticon: %w", )
		}
		.Emoticon = 
	}
	return nil
}

// GetEmoticon returns value of Emoticon field.
func ( *ChatTheme) () ( string) {
	if  == nil {
		return
	}
	return .Emoticon
}

// ChatThemeUniqueGift represents TL type `chatThemeUniqueGift#3458f9c8`.
// A chat theme based on a collectible gift »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/chatThemeUniqueGift for reference.
type ChatThemeUniqueGift struct {
	// The owned collectible gift on which this theme is based, as a starGiftUnique¹
	// constructor.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/starGiftUnique
	Gift StarGiftClass
	// Theme settings.
	ThemeSettings []ThemeSettings
}

// ChatThemeUniqueGiftTypeID is TL type id of ChatThemeUniqueGift.
const ChatThemeUniqueGiftTypeID = 0x3458f9c8

// construct implements constructor of ChatThemeClass.
func ( ChatThemeUniqueGift) () ChatThemeClass { return & }

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

	_ ChatThemeClass = &ChatThemeUniqueGift{}
)

func ( *ChatThemeUniqueGift) () bool {
	if  == nil {
		return true
	}
	if !(.Gift == nil) {
		return false
	}
	if !(.ThemeSettings == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ChatThemeUniqueGift from given interface.
func ( *ChatThemeUniqueGift) ( interface {
	() ( StarGiftClass)
	() ( []ThemeSettings)
}) {
	.Gift = .()
	.ThemeSettings = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatThemeUniqueGift) () tdp.Type {
	 := tdp.Type{
		Name: "chatThemeUniqueGift",
		ID:   ChatThemeUniqueGiftTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
		{
			Name:       "ThemeSettings",
			SchemaName: "theme_settings",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatThemeUniqueGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatThemeUniqueGift#3458f9c8 as nil")
	}
	.PutID(ChatThemeUniqueGiftTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatThemeUniqueGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatThemeUniqueGift#3458f9c8 as nil")
	}
	if .Gift == nil {
		return fmt.Errorf("unable to encode chatThemeUniqueGift#3458f9c8: field gift is nil")
	}
	if  := .Gift.Encode();  != nil {
		return fmt.Errorf("unable to encode chatThemeUniqueGift#3458f9c8: field gift: %w", )
	}
	.PutVectorHeader(len(.ThemeSettings))
	for ,  := range .ThemeSettings {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode chatThemeUniqueGift#3458f9c8: field theme_settings element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatThemeUniqueGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatThemeUniqueGift#3458f9c8 to nil")
	}
	{
		,  := DecodeStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode chatThemeUniqueGift#3458f9c8: field gift: %w", )
		}
		.Gift = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode chatThemeUniqueGift#3458f9c8: field theme_settings: %w", )
		}

		if  > 0 {
			.ThemeSettings = make([]ThemeSettings, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  ThemeSettings
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode chatThemeUniqueGift#3458f9c8: field theme_settings: %w", )
			}
			.ThemeSettings = append(.ThemeSettings, )
		}
	}
	return nil
}

// GetGift returns value of Gift field.
func ( *ChatThemeUniqueGift) () ( StarGiftClass) {
	if  == nil {
		return
	}
	return .Gift
}

// GetThemeSettings returns value of ThemeSettings field.
func ( *ChatThemeUniqueGift) () ( []ThemeSettings) {
	if  == nil {
		return
	}
	return .ThemeSettings
}

// ChatThemeClassName is schema name of ChatThemeClass.
const ChatThemeClassName = "ChatTheme"

// ChatThemeClass represents ChatTheme generic type.
//
// See https://core.telegram.org/type/ChatTheme for reference.
//
// Constructors:
//   - [ChatTheme]
//   - [ChatThemeUniqueGift]
//
// Example:
//
//	g, err := tg.DecodeChatTheme(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ChatTheme: // chatTheme#c3dffc04
//	case *tg.ChatThemeUniqueGift: // chatThemeUniqueGift#3458f9c8
//	default: panic(v)
//	}
type ChatThemeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChatThemeClass

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

// AsInput tries to map ChatTheme to InputChatTheme.
func ( *ChatTheme) () *InputChatTheme {
	 := new(InputChatTheme)
	.Emoticon = .GetEmoticon()

	return 
}

// DecodeChatTheme implements binary de-serialization for ChatThemeClass.
func ( *bin.Buffer) (ChatThemeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ChatThemeTypeID:
		// Decoding chatTheme#c3dffc04.
		 := ChatTheme{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatThemeClass: %w", )
		}
		return &, nil
	case ChatThemeUniqueGiftTypeID:
		// Decoding chatThemeUniqueGift#3458f9c8.
		 := ChatThemeUniqueGift{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatThemeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ChatThemeClass: %w", bin.NewUnexpectedID())
	}
}

// ChatTheme boxes the ChatThemeClass providing a helper.
type ChatThemeBox struct {
	ChatTheme ChatThemeClass
}

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

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