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

// InputChatPhotoEmpty represents TL type `inputChatPhotoEmpty#1ca48f57`.
// Empty constructor, remove group photo.
//
// See https://core.telegram.org/constructor/inputChatPhotoEmpty for reference.
type InputChatPhotoEmpty struct {
}

// InputChatPhotoEmptyTypeID is TL type id of InputChatPhotoEmpty.
const InputChatPhotoEmptyTypeID = 0x1ca48f57

// construct implements constructor of InputChatPhotoClass.
func ( InputChatPhotoEmpty) () InputChatPhotoClass { return & }

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

	_ InputChatPhotoClass = &InputChatPhotoEmpty{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputChatPhotoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChatPhotoEmpty#1ca48f57 as nil")
	}
	.PutID(InputChatPhotoEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputChatPhotoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChatPhotoEmpty#1ca48f57 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputChatPhotoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputChatPhotoEmpty#1ca48f57 to nil")
	}
	return nil
}

// InputChatUploadedPhoto represents TL type `inputChatUploadedPhoto#bdcdaec0`.
// New photo to be set as group profile photo.
// The file, video and video_emoji_markup flags are mutually exclusive.
//
// See https://core.telegram.org/constructor/inputChatUploadedPhoto for reference.
type InputChatUploadedPhoto struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// File saved in parts using the method upload.saveFilePartĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/method/upload.saveFilePart
	//
	// Use SetFile and GetFile helpers.
	File InputFileClass
	// Square video for animated profile picture
	//
	// Use SetVideo and GetVideo helpers.
	Video InputFileClass
	// Floating point UNIX timestamp in seconds, indicating the frame of the video/sticker
	// that should be used as static preview; can only be used if video or video_emoji_markup
	// is set.
	//
	// Use SetVideoStartTs and GetVideoStartTs helpers.
	VideoStartTs float64
	// Animated sticker profile picture, must contain either a videoSizeEmojiMarkupĀ¹ or a
	// videoSizeStickerMarkupĀ² constructor.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/videoSizeEmojiMarkup
	//  2) https://core.telegram.org/constructor/videoSizeStickerMarkup
	//
	// Use SetVideoEmojiMarkup and GetVideoEmojiMarkup helpers.
	VideoEmojiMarkup VideoSizeClass
}

// InputChatUploadedPhotoTypeID is TL type id of InputChatUploadedPhoto.
const InputChatUploadedPhotoTypeID = 0xbdcdaec0

// construct implements constructor of InputChatPhotoClass.
func ( InputChatUploadedPhoto) () InputChatPhotoClass { return & }

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

	_ InputChatPhotoClass = &InputChatUploadedPhoto{}
)

func ( *InputChatUploadedPhoto) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.File == nil) {
		return false
	}
	if !(.Video == nil) {
		return false
	}
	if !(.VideoStartTs == 0) {
		return false
	}
	if !(.VideoEmojiMarkup == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputChatUploadedPhoto from given interface.
func ( *InputChatUploadedPhoto) ( interface {
	() ( InputFileClass,  bool)
	() ( InputFileClass,  bool)
	() ( float64,  bool)
	() ( VideoSizeClass,  bool)
}) {
	if ,  := .();  {
		.File = 
	}

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *InputChatUploadedPhoto) () tdp.Type {
	 := tdp.Type{
		Name: "inputChatUploadedPhoto",
		ID:   InputChatUploadedPhotoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "File",
			SchemaName: "file",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "VideoStartTs",
			SchemaName: "video_start_ts",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "VideoEmojiMarkup",
			SchemaName: "video_emoji_markup",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputChatUploadedPhoto) () {
	if !(.File == nil) {
		.Flags.Set(0)
	}
	if !(.Video == nil) {
		.Flags.Set(1)
	}
	if !(.VideoStartTs == 0) {
		.Flags.Set(2)
	}
	if !(.VideoEmojiMarkup == nil) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *InputChatUploadedPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChatUploadedPhoto#bdcdaec0 as nil")
	}
	.PutID(InputChatUploadedPhotoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputChatUploadedPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChatUploadedPhoto#bdcdaec0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputChatUploadedPhoto#bdcdaec0: field flags: %w", )
	}
	if .Flags.Has(0) {
		if .File == nil {
			return fmt.Errorf("unable to encode inputChatUploadedPhoto#bdcdaec0: field file is nil")
		}
		if  := .File.Encode();  != nil {
			return fmt.Errorf("unable to encode inputChatUploadedPhoto#bdcdaec0: field file: %w", )
		}
	}
	if .Flags.Has(1) {
		if .Video == nil {
			return fmt.Errorf("unable to encode inputChatUploadedPhoto#bdcdaec0: field video is nil")
		}
		if  := .Video.Encode();  != nil {
			return fmt.Errorf("unable to encode inputChatUploadedPhoto#bdcdaec0: field video: %w", )
		}
	}
	if .Flags.Has(2) {
		.PutDouble(.VideoStartTs)
	}
	if .Flags.Has(3) {
		if .VideoEmojiMarkup == nil {
			return fmt.Errorf("unable to encode inputChatUploadedPhoto#bdcdaec0: field video_emoji_markup is nil")
		}
		if  := .VideoEmojiMarkup.Encode();  != nil {
			return fmt.Errorf("unable to encode inputChatUploadedPhoto#bdcdaec0: field video_emoji_markup: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputChatUploadedPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputChatUploadedPhoto#bdcdaec0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputChatUploadedPhoto#bdcdaec0: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode inputChatUploadedPhoto#bdcdaec0: field file: %w", )
		}
		.File = 
	}
	if .Flags.Has(1) {
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode inputChatUploadedPhoto#bdcdaec0: field video: %w", )
		}
		.Video = 
	}
	if .Flags.Has(2) {
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode inputChatUploadedPhoto#bdcdaec0: field video_start_ts: %w", )
		}
		.VideoStartTs = 
	}
	if .Flags.Has(3) {
		,  := DecodeVideoSize()
		if  != nil {
			return fmt.Errorf("unable to decode inputChatUploadedPhoto#bdcdaec0: field video_emoji_markup: %w", )
		}
		.VideoEmojiMarkup = 
	}
	return nil
}

// SetFile sets value of File conditional field.
func ( *InputChatUploadedPhoto) ( InputFileClass) {
	.Flags.Set(0)
	.File = 
}

// GetFile returns value of File conditional field and
// boolean which is true if field was set.
func ( *InputChatUploadedPhoto) () ( InputFileClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .File, true
}

// SetVideo sets value of Video conditional field.
func ( *InputChatUploadedPhoto) ( InputFileClass) {
	.Flags.Set(1)
	.Video = 
}

// GetVideo returns value of Video conditional field and
// boolean which is true if field was set.
func ( *InputChatUploadedPhoto) () ( InputFileClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Video, true
}

// SetVideoStartTs sets value of VideoStartTs conditional field.
func ( *InputChatUploadedPhoto) ( float64) {
	.Flags.Set(2)
	.VideoStartTs = 
}

// GetVideoStartTs returns value of VideoStartTs conditional field and
// boolean which is true if field was set.
func ( *InputChatUploadedPhoto) () ( float64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .VideoStartTs, true
}

// SetVideoEmojiMarkup sets value of VideoEmojiMarkup conditional field.
func ( *InputChatUploadedPhoto) ( VideoSizeClass) {
	.Flags.Set(3)
	.VideoEmojiMarkup = 
}

// GetVideoEmojiMarkup returns value of VideoEmojiMarkup conditional field and
// boolean which is true if field was set.
func ( *InputChatUploadedPhoto) () ( VideoSizeClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .VideoEmojiMarkup, true
}

// InputChatPhoto represents TL type `inputChatPhoto#8953ad37`.
// Existing photo to be set as a chat profile photo.
//
// See https://core.telegram.org/constructor/inputChatPhoto for reference.
type InputChatPhoto struct {
	// Existing photo
	ID InputPhotoClass
}

// InputChatPhotoTypeID is TL type id of InputChatPhoto.
const InputChatPhotoTypeID = 0x8953ad37

// construct implements constructor of InputChatPhotoClass.
func ( InputChatPhoto) () InputChatPhotoClass { return & }

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

	_ InputChatPhotoClass = &InputChatPhoto{}
)

func ( *InputChatPhoto) () bool {
	if  == nil {
		return true
	}
	if !(.ID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputChatPhoto from given interface.
func ( *InputChatPhoto) ( interface {
	() ( InputPhotoClass)
}) {
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputChatPhoto) () tdp.Type {
	 := tdp.Type{
		Name: "inputChatPhoto",
		ID:   InputChatPhotoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputChatPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChatPhoto#8953ad37 as nil")
	}
	.PutID(InputChatPhotoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputChatPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputChatPhoto#8953ad37 as nil")
	}
	if .ID == nil {
		return fmt.Errorf("unable to encode inputChatPhoto#8953ad37: field id is nil")
	}
	if  := .ID.Encode();  != nil {
		return fmt.Errorf("unable to encode inputChatPhoto#8953ad37: field id: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputChatPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputChatPhoto#8953ad37 to nil")
	}
	{
		,  := DecodeInputPhoto()
		if  != nil {
			return fmt.Errorf("unable to decode inputChatPhoto#8953ad37: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *InputChatPhoto) () ( InputPhotoClass) {
	if  == nil {
		return
	}
	return .ID
}

// InputChatPhotoClassName is schema name of InputChatPhotoClass.
const InputChatPhotoClassName = "InputChatPhoto"

// InputChatPhotoClass represents InputChatPhoto generic type.
//
// See https://core.telegram.org/type/InputChatPhoto for reference.
//
// Example:
//
//	g, err := tg.DecodeInputChatPhoto(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputChatPhotoEmpty: // inputChatPhotoEmpty#1ca48f57
//	case *tg.InputChatUploadedPhoto: // inputChatUploadedPhoto#bdcdaec0
//	case *tg.InputChatPhoto: // inputChatPhoto#8953ad37
//	default: panic(v)
//	}
type InputChatPhotoClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputChatPhotoClass

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

// DecodeInputChatPhoto implements binary de-serialization for InputChatPhotoClass.
func ( *bin.Buffer) (InputChatPhotoClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputChatPhotoEmptyTypeID:
		// Decoding inputChatPhotoEmpty#1ca48f57.
		 := InputChatPhotoEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputChatPhotoClass: %w", )
		}
		return &, nil
	case InputChatUploadedPhotoTypeID:
		// Decoding inputChatUploadedPhoto#bdcdaec0.
		 := InputChatUploadedPhoto{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputChatPhotoClass: %w", )
		}
		return &, nil
	case InputChatPhotoTypeID:
		// Decoding inputChatPhoto#8953ad37.
		 := InputChatPhoto{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputChatPhotoClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputChatPhotoClass: %w", bin.NewUnexpectedID())
	}
}

// InputChatPhoto boxes the InputChatPhotoClass providing a helper.
type InputChatPhotoBox struct {
	InputChatPhoto InputChatPhotoClass
}

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

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