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

// VideoSize represents TL type `videoSize#de33b094`.
// An animated profile picture¹ in MPEG4 format
//
// Links:
//  1. https://core.telegram.org/api/files#animated-profile-pictures
//
// See https://core.telegram.org/constructor/videoSize for reference.
type VideoSize struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// u for animated profile pictures, and v for trimmed and downscaled video previews
	Type string
	// Video width
	W int
	// Video height
	H int
	// File size
	Size int
	// Timestamp that should be shown as static preview to the user (seconds)
	//
	// Use SetVideoStartTs and GetVideoStartTs helpers.
	VideoStartTs float64
}

// VideoSizeTypeID is TL type id of VideoSize.
const VideoSizeTypeID = 0xde33b094

// construct implements constructor of VideoSizeClass.
func ( VideoSize) () VideoSizeClass { return & }

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

	_ VideoSizeClass = &VideoSize{}
)

func ( *VideoSize) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Type == "") {
		return false
	}
	if !(.W == 0) {
		return false
	}
	if !(.H == 0) {
		return false
	}
	if !(.Size == 0) {
		return false
	}
	if !(.VideoStartTs == 0) {
		return false
	}

	return true
}

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

// FillFrom fills VideoSize from given interface.
func ( *VideoSize) ( interface {
	() ( string)
	() ( int)
	() ( int)
	() ( int)
	() ( float64,  bool)
}) {
	.Type = .()
	.W = .()
	.H = .()
	.Size = .()
	if ,  := .();  {
		.VideoStartTs = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *VideoSize) () tdp.Type {
	 := tdp.Type{
		Name: "videoSize",
		ID:   VideoSizeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Type",
			SchemaName: "type",
		},
		{
			Name:       "W",
			SchemaName: "w",
		},
		{
			Name:       "H",
			SchemaName: "h",
		},
		{
			Name:       "Size",
			SchemaName: "size",
		},
		{
			Name:       "VideoStartTs",
			SchemaName: "video_start_ts",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *VideoSize) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode videoSize#de33b094 as nil")
	}
	.PutID(VideoSizeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *VideoSize) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode videoSize#de33b094 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode videoSize#de33b094: field flags: %w", )
	}
	.PutString(.Type)
	.PutInt(.W)
	.PutInt(.H)
	.PutInt(.Size)
	if .Flags.Has(0) {
		.PutDouble(.VideoStartTs)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *VideoSize) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode videoSize#de33b094 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode videoSize#de33b094: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode videoSize#de33b094: field type: %w", )
		}
		.Type = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode videoSize#de33b094: field w: %w", )
		}
		.W = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode videoSize#de33b094: field h: %w", )
		}
		.H = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode videoSize#de33b094: field size: %w", )
		}
		.Size = 
	}
	if .Flags.Has(0) {
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode videoSize#de33b094: field video_start_ts: %w", )
		}
		.VideoStartTs = 
	}
	return nil
}

// GetType returns value of Type field.
func ( *VideoSize) () ( string) {
	if  == nil {
		return
	}
	return .Type
}

// GetW returns value of W field.
func ( *VideoSize) () ( int) {
	if  == nil {
		return
	}
	return .W
}

// GetH returns value of H field.
func ( *VideoSize) () ( int) {
	if  == nil {
		return
	}
	return .H
}

// GetSize returns value of Size field.
func ( *VideoSize) () ( int) {
	if  == nil {
		return
	}
	return .Size
}

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

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

// VideoSizeEmojiMarkup represents TL type `videoSizeEmojiMarkup#f85c413c`.
// An animated profile picture¹ based on a custom emoji sticker².
//
// Links:
//  1. https://core.telegram.org/api/files#animated-profile-pictures
//  2. https://core.telegram.org/api/custom-emoji
//
// See https://core.telegram.org/constructor/videoSizeEmojiMarkup for reference.
type VideoSizeEmojiMarkup struct {
	// Custom emoji ID¹: the custom emoji sticker is shown at the center of the profile
	// picture and occupies at most 67% of it.
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	EmojiID int64
	// 1, 2, 3 or 4 RBG-24 colors used to generate a solid (1), gradient (2) or freeform
	// gradient (3, 4) background, similar to how fill wallpapers¹ are generated. The
	// rotation angle for gradient backgrounds is 0.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#fill-types
	BackgroundColors []int
}

// VideoSizeEmojiMarkupTypeID is TL type id of VideoSizeEmojiMarkup.
const VideoSizeEmojiMarkupTypeID = 0xf85c413c

// construct implements constructor of VideoSizeClass.
func ( VideoSizeEmojiMarkup) () VideoSizeClass { return & }

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

	_ VideoSizeClass = &VideoSizeEmojiMarkup{}
)

func ( *VideoSizeEmojiMarkup) () bool {
	if  == nil {
		return true
	}
	if !(.EmojiID == 0) {
		return false
	}
	if !(.BackgroundColors == nil) {
		return false
	}

	return true
}

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

// FillFrom fills VideoSizeEmojiMarkup from given interface.
func ( *VideoSizeEmojiMarkup) ( interface {
	() ( int64)
	() ( []int)
}) {
	.EmojiID = .()
	.BackgroundColors = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *VideoSizeEmojiMarkup) () tdp.Type {
	 := tdp.Type{
		Name: "videoSizeEmojiMarkup",
		ID:   VideoSizeEmojiMarkupTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "EmojiID",
			SchemaName: "emoji_id",
		},
		{
			Name:       "BackgroundColors",
			SchemaName: "background_colors",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *VideoSizeEmojiMarkup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode videoSizeEmojiMarkup#f85c413c as nil")
	}
	.PutID(VideoSizeEmojiMarkupTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *VideoSizeEmojiMarkup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode videoSizeEmojiMarkup#f85c413c as nil")
	}
	.PutLong(.EmojiID)
	.PutVectorHeader(len(.BackgroundColors))
	for ,  := range .BackgroundColors {
		.PutInt()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *VideoSizeEmojiMarkup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode videoSizeEmojiMarkup#f85c413c to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode videoSizeEmojiMarkup#f85c413c: field emoji_id: %w", )
		}
		.EmojiID = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode videoSizeEmojiMarkup#f85c413c: field background_colors: %w", )
		}

		if  > 0 {
			.BackgroundColors = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode videoSizeEmojiMarkup#f85c413c: field background_colors: %w", )
			}
			.BackgroundColors = append(.BackgroundColors, )
		}
	}
	return nil
}

// GetEmojiID returns value of EmojiID field.
func ( *VideoSizeEmojiMarkup) () ( int64) {
	if  == nil {
		return
	}
	return .EmojiID
}

// GetBackgroundColors returns value of BackgroundColors field.
func ( *VideoSizeEmojiMarkup) () ( []int) {
	if  == nil {
		return
	}
	return .BackgroundColors
}

// VideoSizeStickerMarkup represents TL type `videoSizeStickerMarkup#da082fe`.
// An animated profile picture¹ based on a sticker².
//
// Links:
//  1. https://core.telegram.org/api/files#animated-profile-pictures
//  2. https://core.telegram.org/api/stickers
//
// See https://core.telegram.org/constructor/videoSizeStickerMarkup for reference.
type VideoSizeStickerMarkup struct {
	// Stickerset
	Stickerset InputStickerSetClass
	// Sticker ID
	StickerID int64
	// 1, 2, 3 or 4 RBG-24 colors used to generate a solid (1), gradient (2) or freeform
	// gradient (3, 4) background, similar to how fill wallpapers¹ are generated. The
	// rotation angle for gradient backgrounds is 0.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers#fill-types
	BackgroundColors []int
}

// VideoSizeStickerMarkupTypeID is TL type id of VideoSizeStickerMarkup.
const VideoSizeStickerMarkupTypeID = 0xda082fe

// construct implements constructor of VideoSizeClass.
func ( VideoSizeStickerMarkup) () VideoSizeClass { return & }

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

	_ VideoSizeClass = &VideoSizeStickerMarkup{}
)

func ( *VideoSizeStickerMarkup) () bool {
	if  == nil {
		return true
	}
	if !(.Stickerset == nil) {
		return false
	}
	if !(.StickerID == 0) {
		return false
	}
	if !(.BackgroundColors == nil) {
		return false
	}

	return true
}

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

// FillFrom fills VideoSizeStickerMarkup from given interface.
func ( *VideoSizeStickerMarkup) ( interface {
	() ( InputStickerSetClass)
	() ( int64)
	() ( []int)
}) {
	.Stickerset = .()
	.StickerID = .()
	.BackgroundColors = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *VideoSizeStickerMarkup) () tdp.Type {
	 := tdp.Type{
		Name: "videoSizeStickerMarkup",
		ID:   VideoSizeStickerMarkupTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Stickerset",
			SchemaName: "stickerset",
		},
		{
			Name:       "StickerID",
			SchemaName: "sticker_id",
		},
		{
			Name:       "BackgroundColors",
			SchemaName: "background_colors",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *VideoSizeStickerMarkup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode videoSizeStickerMarkup#da082fe as nil")
	}
	.PutID(VideoSizeStickerMarkupTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *VideoSizeStickerMarkup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode videoSizeStickerMarkup#da082fe as nil")
	}
	if .Stickerset == nil {
		return fmt.Errorf("unable to encode videoSizeStickerMarkup#da082fe: field stickerset is nil")
	}
	if  := .Stickerset.Encode();  != nil {
		return fmt.Errorf("unable to encode videoSizeStickerMarkup#da082fe: field stickerset: %w", )
	}
	.PutLong(.StickerID)
	.PutVectorHeader(len(.BackgroundColors))
	for ,  := range .BackgroundColors {
		.PutInt()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *VideoSizeStickerMarkup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode videoSizeStickerMarkup#da082fe to nil")
	}
	{
		,  := DecodeInputStickerSet()
		if  != nil {
			return fmt.Errorf("unable to decode videoSizeStickerMarkup#da082fe: field stickerset: %w", )
		}
		.Stickerset = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode videoSizeStickerMarkup#da082fe: field sticker_id: %w", )
		}
		.StickerID = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode videoSizeStickerMarkup#da082fe: field background_colors: %w", )
		}

		if  > 0 {
			.BackgroundColors = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode videoSizeStickerMarkup#da082fe: field background_colors: %w", )
			}
			.BackgroundColors = append(.BackgroundColors, )
		}
	}
	return nil
}

// GetStickerset returns value of Stickerset field.
func ( *VideoSizeStickerMarkup) () ( InputStickerSetClass) {
	if  == nil {
		return
	}
	return .Stickerset
}

// GetStickerID returns value of StickerID field.
func ( *VideoSizeStickerMarkup) () ( int64) {
	if  == nil {
		return
	}
	return .StickerID
}

// GetBackgroundColors returns value of BackgroundColors field.
func ( *VideoSizeStickerMarkup) () ( []int) {
	if  == nil {
		return
	}
	return .BackgroundColors
}

// VideoSizeClassName is schema name of VideoSizeClass.
const VideoSizeClassName = "VideoSize"

// VideoSizeClass represents VideoSize generic type.
//
// See https://core.telegram.org/type/VideoSize for reference.
//
// Example:
//
//	g, err := tg.DecodeVideoSize(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.VideoSize: // videoSize#de33b094
//	case *tg.VideoSizeEmojiMarkup: // videoSizeEmojiMarkup#f85c413c
//	case *tg.VideoSizeStickerMarkup: // videoSizeStickerMarkup#da082fe
//	default: panic(v)
//	}
type VideoSizeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() VideoSizeClass

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

// DecodeVideoSize implements binary de-serialization for VideoSizeClass.
func ( *bin.Buffer) (VideoSizeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case VideoSizeTypeID:
		// Decoding videoSize#de33b094.
		 := VideoSize{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode VideoSizeClass: %w", )
		}
		return &, nil
	case VideoSizeEmojiMarkupTypeID:
		// Decoding videoSizeEmojiMarkup#f85c413c.
		 := VideoSizeEmojiMarkup{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode VideoSizeClass: %w", )
		}
		return &, nil
	case VideoSizeStickerMarkupTypeID:
		// Decoding videoSizeStickerMarkup#da082fe.
		 := VideoSizeStickerMarkup{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode VideoSizeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode VideoSizeClass: %w", bin.NewUnexpectedID())
	}
}

// VideoSize boxes the VideoSizeClass providing a helper.
type VideoSizeBox struct {
	VideoSize VideoSizeClass
}

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

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