// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// PageBlockUnsupported represents TL type `pageBlockUnsupported#13567e8a`.
// Unsupported IV element
//
// See https://core.telegram.org/constructor/pageBlockUnsupported for reference.
type PageBlockUnsupported struct {
}

// PageBlockUnsupportedTypeID is TL type id of PageBlockUnsupported.
const PageBlockUnsupportedTypeID = 0x13567e8a

// construct implements constructor of PageBlockClass.
func (p PageBlockUnsupported) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockUnsupported{}
)

func (p *PageBlockUnsupported) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockUnsupported) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockUnsupported",
		ID:   PageBlockUnsupportedTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockUnsupported) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockUnsupported#13567e8a as nil")
	}
	b.PutID(PageBlockUnsupportedTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockUnsupported) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockUnsupported#13567e8a as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockUnsupported) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockUnsupported#13567e8a to nil")
	}
	if err := b.ConsumeID(PageBlockUnsupportedTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockUnsupported#13567e8a: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockUnsupported) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockUnsupported#13567e8a to nil")
	}
	return nil
}

// PageBlockTitle represents TL type `pageBlockTitle#70abc3fd`.
// Title
//
// See https://core.telegram.org/constructor/pageBlockTitle for reference.
type PageBlockTitle struct {
	// Title
	Text RichTextClass
}

// PageBlockTitleTypeID is TL type id of PageBlockTitle.
const PageBlockTitleTypeID = 0x70abc3fd

// construct implements constructor of PageBlockClass.
func (p PageBlockTitle) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockTitle{}
)

func (p *PageBlockTitle) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockTitle from given interface.
func (p *PageBlockTitle) FillFrom(from interface {
	GetText() (value RichTextClass)
}) {
	p.Text = from.GetText()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockTitle) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockTitle",
		ID:   PageBlockTitleTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockTitle) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockTitle#70abc3fd as nil")
	}
	b.PutID(PageBlockTitleTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockTitle) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockTitle#70abc3fd as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockTitle#70abc3fd: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockTitle#70abc3fd: field text: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockTitle) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockTitle#70abc3fd to nil")
	}
	if err := b.ConsumeID(PageBlockTitleTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockTitle#70abc3fd: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockTitle) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockTitle#70abc3fd to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockTitle#70abc3fd: field text: %w", err)
		}
		p.Text = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockTitle) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// PageBlockSubtitle represents TL type `pageBlockSubtitle#8ffa9a1f`.
// Subtitle
//
// See https://core.telegram.org/constructor/pageBlockSubtitle for reference.
type PageBlockSubtitle struct {
	// Text
	Text RichTextClass
}

// PageBlockSubtitleTypeID is TL type id of PageBlockSubtitle.
const PageBlockSubtitleTypeID = 0x8ffa9a1f

// construct implements constructor of PageBlockClass.
func (p PageBlockSubtitle) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockSubtitle{}
)

func (p *PageBlockSubtitle) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockSubtitle from given interface.
func (p *PageBlockSubtitle) FillFrom(from interface {
	GetText() (value RichTextClass)
}) {
	p.Text = from.GetText()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockSubtitle) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockSubtitle",
		ID:   PageBlockSubtitleTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockSubtitle) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockSubtitle#8ffa9a1f as nil")
	}
	b.PutID(PageBlockSubtitleTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockSubtitle) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockSubtitle#8ffa9a1f as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockSubtitle#8ffa9a1f: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockSubtitle#8ffa9a1f: field text: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockSubtitle) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockSubtitle#8ffa9a1f to nil")
	}
	if err := b.ConsumeID(PageBlockSubtitleTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockSubtitle#8ffa9a1f: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockSubtitle) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockSubtitle#8ffa9a1f to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockSubtitle#8ffa9a1f: field text: %w", err)
		}
		p.Text = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockSubtitle) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// PageBlockAuthorDate represents TL type `pageBlockAuthorDate#baafe5e0`.
// Author and date of creation of article
//
// See https://core.telegram.org/constructor/pageBlockAuthorDate for reference.
type PageBlockAuthorDate struct {
	// Author name
	Author RichTextClass
	// Date of publication
	PublishedDate int
}

// PageBlockAuthorDateTypeID is TL type id of PageBlockAuthorDate.
const PageBlockAuthorDateTypeID = 0xbaafe5e0

// construct implements constructor of PageBlockClass.
func (p PageBlockAuthorDate) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockAuthorDate{}
)

func (p *PageBlockAuthorDate) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Author == nil) {
		return false
	}
	if !(p.PublishedDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockAuthorDate from given interface.
func (p *PageBlockAuthorDate) FillFrom(from interface {
	GetAuthor() (value RichTextClass)
	GetPublishedDate() (value int)
}) {
	p.Author = from.GetAuthor()
	p.PublishedDate = from.GetPublishedDate()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockAuthorDate) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockAuthorDate",
		ID:   PageBlockAuthorDateTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Author",
			SchemaName: "author",
		},
		{
			Name:       "PublishedDate",
			SchemaName: "published_date",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockAuthorDate) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockAuthorDate#baafe5e0 as nil")
	}
	b.PutID(PageBlockAuthorDateTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockAuthorDate) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockAuthorDate#baafe5e0 as nil")
	}
	if p.Author == nil {
		return fmt.Errorf("unable to encode pageBlockAuthorDate#baafe5e0: field author is nil")
	}
	if err := p.Author.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockAuthorDate#baafe5e0: field author: %w", err)
	}
	b.PutInt(p.PublishedDate)
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockAuthorDate) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockAuthorDate#baafe5e0 to nil")
	}
	if err := b.ConsumeID(PageBlockAuthorDateTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockAuthorDate#baafe5e0: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockAuthorDate) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockAuthorDate#baafe5e0 to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockAuthorDate#baafe5e0: field author: %w", err)
		}
		p.Author = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockAuthorDate#baafe5e0: field published_date: %w", err)
		}
		p.PublishedDate = value
	}
	return nil
}

// GetAuthor returns value of Author field.
func (p *PageBlockAuthorDate) GetAuthor() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Author
}

// GetPublishedDate returns value of PublishedDate field.
func (p *PageBlockAuthorDate) GetPublishedDate() (value int) {
	if p == nil {
		return
	}
	return p.PublishedDate
}

// PageBlockHeader represents TL type `pageBlockHeader#bfd064ec`.
// Page header
//
// See https://core.telegram.org/constructor/pageBlockHeader for reference.
type PageBlockHeader struct {
	// Contents
	Text RichTextClass
}

// PageBlockHeaderTypeID is TL type id of PageBlockHeader.
const PageBlockHeaderTypeID = 0xbfd064ec

// construct implements constructor of PageBlockClass.
func (p PageBlockHeader) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockHeader{}
)

func (p *PageBlockHeader) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockHeader from given interface.
func (p *PageBlockHeader) FillFrom(from interface {
	GetText() (value RichTextClass)
}) {
	p.Text = from.GetText()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockHeader) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockHeader",
		ID:   PageBlockHeaderTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockHeader) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockHeader#bfd064ec as nil")
	}
	b.PutID(PageBlockHeaderTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockHeader) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockHeader#bfd064ec as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockHeader#bfd064ec: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockHeader#bfd064ec: field text: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockHeader) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockHeader#bfd064ec to nil")
	}
	if err := b.ConsumeID(PageBlockHeaderTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockHeader#bfd064ec: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockHeader) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockHeader#bfd064ec to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockHeader#bfd064ec: field text: %w", err)
		}
		p.Text = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockHeader) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// PageBlockSubheader represents TL type `pageBlockSubheader#f12bb6e1`.
// Subheader
//
// See https://core.telegram.org/constructor/pageBlockSubheader for reference.
type PageBlockSubheader struct {
	// Subheader
	Text RichTextClass
}

// PageBlockSubheaderTypeID is TL type id of PageBlockSubheader.
const PageBlockSubheaderTypeID = 0xf12bb6e1

// construct implements constructor of PageBlockClass.
func (p PageBlockSubheader) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockSubheader{}
)

func (p *PageBlockSubheader) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockSubheader from given interface.
func (p *PageBlockSubheader) FillFrom(from interface {
	GetText() (value RichTextClass)
}) {
	p.Text = from.GetText()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockSubheader) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockSubheader",
		ID:   PageBlockSubheaderTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockSubheader) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockSubheader#f12bb6e1 as nil")
	}
	b.PutID(PageBlockSubheaderTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockSubheader) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockSubheader#f12bb6e1 as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockSubheader#f12bb6e1: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockSubheader#f12bb6e1: field text: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockSubheader) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockSubheader#f12bb6e1 to nil")
	}
	if err := b.ConsumeID(PageBlockSubheaderTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockSubheader#f12bb6e1: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockSubheader) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockSubheader#f12bb6e1 to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockSubheader#f12bb6e1: field text: %w", err)
		}
		p.Text = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockSubheader) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// PageBlockParagraph represents TL type `pageBlockParagraph#467a0766`.
// A paragraph
//
// See https://core.telegram.org/constructor/pageBlockParagraph for reference.
type PageBlockParagraph struct {
	// Text
	Text RichTextClass
}

// PageBlockParagraphTypeID is TL type id of PageBlockParagraph.
const PageBlockParagraphTypeID = 0x467a0766

// construct implements constructor of PageBlockClass.
func (p PageBlockParagraph) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockParagraph{}
)

func (p *PageBlockParagraph) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockParagraph from given interface.
func (p *PageBlockParagraph) FillFrom(from interface {
	GetText() (value RichTextClass)
}) {
	p.Text = from.GetText()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockParagraph) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockParagraph",
		ID:   PageBlockParagraphTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockParagraph) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockParagraph#467a0766 as nil")
	}
	b.PutID(PageBlockParagraphTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockParagraph) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockParagraph#467a0766 as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockParagraph#467a0766: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockParagraph#467a0766: field text: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockParagraph) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockParagraph#467a0766 to nil")
	}
	if err := b.ConsumeID(PageBlockParagraphTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockParagraph#467a0766: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockParagraph) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockParagraph#467a0766 to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockParagraph#467a0766: field text: %w", err)
		}
		p.Text = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockParagraph) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// PageBlockPreformatted represents TL type `pageBlockPreformatted#c070d93e`.
// Preformatted (<pre> text)
//
// See https://core.telegram.org/constructor/pageBlockPreformatted for reference.
type PageBlockPreformatted struct {
	// Text
	Text RichTextClass
	// Programming language of preformatted text
	Language string
}

// PageBlockPreformattedTypeID is TL type id of PageBlockPreformatted.
const PageBlockPreformattedTypeID = 0xc070d93e

// construct implements constructor of PageBlockClass.
func (p PageBlockPreformatted) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockPreformatted{}
)

func (p *PageBlockPreformatted) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}
	if !(p.Language == "") {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockPreformatted from given interface.
func (p *PageBlockPreformatted) FillFrom(from interface {
	GetText() (value RichTextClass)
	GetLanguage() (value string)
}) {
	p.Text = from.GetText()
	p.Language = from.GetLanguage()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockPreformatted) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockPreformatted",
		ID:   PageBlockPreformattedTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
		{
			Name:       "Language",
			SchemaName: "language",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockPreformatted) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockPreformatted#c070d93e as nil")
	}
	b.PutID(PageBlockPreformattedTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockPreformatted) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockPreformatted#c070d93e as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockPreformatted#c070d93e: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockPreformatted#c070d93e: field text: %w", err)
	}
	b.PutString(p.Language)
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockPreformatted) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockPreformatted#c070d93e to nil")
	}
	if err := b.ConsumeID(PageBlockPreformattedTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockPreformatted) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockPreformatted#c070d93e to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: field text: %w", err)
		}
		p.Text = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: field language: %w", err)
		}
		p.Language = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockPreformatted) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// GetLanguage returns value of Language field.
func (p *PageBlockPreformatted) GetLanguage() (value string) {
	if p == nil {
		return
	}
	return p.Language
}

// PageBlockFooter represents TL type `pageBlockFooter#48870999`.
// Page footer
//
// See https://core.telegram.org/constructor/pageBlockFooter for reference.
type PageBlockFooter struct {
	// Contents
	Text RichTextClass
}

// PageBlockFooterTypeID is TL type id of PageBlockFooter.
const PageBlockFooterTypeID = 0x48870999

// construct implements constructor of PageBlockClass.
func (p PageBlockFooter) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockFooter{}
)

func (p *PageBlockFooter) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockFooter from given interface.
func (p *PageBlockFooter) FillFrom(from interface {
	GetText() (value RichTextClass)
}) {
	p.Text = from.GetText()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockFooter) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockFooter",
		ID:   PageBlockFooterTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockFooter) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockFooter#48870999 as nil")
	}
	b.PutID(PageBlockFooterTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockFooter) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockFooter#48870999 as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockFooter#48870999: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockFooter#48870999: field text: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockFooter) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockFooter#48870999 to nil")
	}
	if err := b.ConsumeID(PageBlockFooterTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockFooter#48870999: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockFooter) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockFooter#48870999 to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockFooter#48870999: field text: %w", err)
		}
		p.Text = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockFooter) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// PageBlockDivider represents TL type `pageBlockDivider#db20b188`.
// An empty block separating a page
//
// See https://core.telegram.org/constructor/pageBlockDivider for reference.
type PageBlockDivider struct {
}

// PageBlockDividerTypeID is TL type id of PageBlockDivider.
const PageBlockDividerTypeID = 0xdb20b188

// construct implements constructor of PageBlockClass.
func (p PageBlockDivider) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockDivider{}
)

func (p *PageBlockDivider) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockDivider) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockDivider",
		ID:   PageBlockDividerTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockDivider) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockDivider#db20b188 as nil")
	}
	b.PutID(PageBlockDividerTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockDivider) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockDivider#db20b188 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockDivider) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockDivider#db20b188 to nil")
	}
	if err := b.ConsumeID(PageBlockDividerTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockDivider#db20b188: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockDivider) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockDivider#db20b188 to nil")
	}
	return nil
}

// PageBlockAnchor represents TL type `pageBlockAnchor#ce0d37b0`.
// Link to section within the page itself (like <a href="#target">anchor</a>)
//
// See https://core.telegram.org/constructor/pageBlockAnchor for reference.
type PageBlockAnchor struct {
	// Name of target section
	Name string
}

// PageBlockAnchorTypeID is TL type id of PageBlockAnchor.
const PageBlockAnchorTypeID = 0xce0d37b0

// construct implements constructor of PageBlockClass.
func (p PageBlockAnchor) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockAnchor{}
)

func (p *PageBlockAnchor) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Name == "") {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockAnchor from given interface.
func (p *PageBlockAnchor) FillFrom(from interface {
	GetName() (value string)
}) {
	p.Name = from.GetName()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockAnchor) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockAnchor",
		ID:   PageBlockAnchorTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Name",
			SchemaName: "name",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockAnchor) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockAnchor#ce0d37b0 as nil")
	}
	b.PutID(PageBlockAnchorTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockAnchor) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockAnchor#ce0d37b0 as nil")
	}
	b.PutString(p.Name)
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockAnchor) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockAnchor#ce0d37b0 to nil")
	}
	if err := b.ConsumeID(PageBlockAnchorTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockAnchor#ce0d37b0: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockAnchor) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockAnchor#ce0d37b0 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockAnchor#ce0d37b0: field name: %w", err)
		}
		p.Name = value
	}
	return nil
}

// GetName returns value of Name field.
func (p *PageBlockAnchor) GetName() (value string) {
	if p == nil {
		return
	}
	return p.Name
}

// PageBlockList represents TL type `pageBlockList#e4e88011`.
// Unordered list of IV blocks
//
// See https://core.telegram.org/constructor/pageBlockList for reference.
type PageBlockList struct {
	// List of blocks in an IV page
	Items []PageListItemClass
}

// PageBlockListTypeID is TL type id of PageBlockList.
const PageBlockListTypeID = 0xe4e88011

// construct implements constructor of PageBlockClass.
func (p PageBlockList) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockList{}
)

func (p *PageBlockList) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Items == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockList from given interface.
func (p *PageBlockList) FillFrom(from interface {
	GetItems() (value []PageListItemClass)
}) {
	p.Items = from.GetItems()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockList) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockList",
		ID:   PageBlockListTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Items",
			SchemaName: "items",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockList) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockList#e4e88011 as nil")
	}
	b.PutID(PageBlockListTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockList) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockList#e4e88011 as nil")
	}
	b.PutVectorHeader(len(p.Items))
	for idx, v := range p.Items {
		if v == nil {
			return fmt.Errorf("unable to encode pageBlockList#e4e88011: field items element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode pageBlockList#e4e88011: field items element with index %d: %w", idx, err)
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockList) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockList#e4e88011 to nil")
	}
	if err := b.ConsumeID(PageBlockListTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockList#e4e88011: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockList) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockList#e4e88011 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockList#e4e88011: field items: %w", err)
		}

		if headerLen > 0 {
			p.Items = make([]PageListItemClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePageListItem(b)
			if err != nil {
				return fmt.Errorf("unable to decode pageBlockList#e4e88011: field items: %w", err)
			}
			p.Items = append(p.Items, value)
		}
	}
	return nil
}

// GetItems returns value of Items field.
func (p *PageBlockList) GetItems() (value []PageListItemClass) {
	if p == nil {
		return
	}
	return p.Items
}

// MapItems returns field Items wrapped in PageListItemClassArray helper.
func (p *PageBlockList) MapItems() (value PageListItemClassArray) {
	return PageListItemClassArray(p.Items)
}

// PageBlockBlockquote represents TL type `pageBlockBlockquote#263d7c26`.
// Quote (equivalent to the HTML <blockquote>)
//
// See https://core.telegram.org/constructor/pageBlockBlockquote for reference.
type PageBlockBlockquote struct {
	// Quote contents
	Text RichTextClass
	// Caption
	Caption RichTextClass
}

// PageBlockBlockquoteTypeID is TL type id of PageBlockBlockquote.
const PageBlockBlockquoteTypeID = 0x263d7c26

// construct implements constructor of PageBlockClass.
func (p PageBlockBlockquote) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockBlockquote{}
)

func (p *PageBlockBlockquote) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}
	if !(p.Caption == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockBlockquote from given interface.
func (p *PageBlockBlockquote) FillFrom(from interface {
	GetText() (value RichTextClass)
	GetCaption() (value RichTextClass)
}) {
	p.Text = from.GetText()
	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockBlockquote) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockBlockquote",
		ID:   PageBlockBlockquoteTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockBlockquote) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockBlockquote#263d7c26 as nil")
	}
	b.PutID(PageBlockBlockquoteTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockBlockquote) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockBlockquote#263d7c26 as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockBlockquote#263d7c26: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockBlockquote#263d7c26: field text: %w", err)
	}
	if p.Caption == nil {
		return fmt.Errorf("unable to encode pageBlockBlockquote#263d7c26: field caption is nil")
	}
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockBlockquote#263d7c26: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockBlockquote) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockBlockquote#263d7c26 to nil")
	}
	if err := b.ConsumeID(PageBlockBlockquoteTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockBlockquote#263d7c26: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockBlockquote) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockBlockquote#263d7c26 to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockBlockquote#263d7c26: field text: %w", err)
		}
		p.Text = value
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockBlockquote#263d7c26: field caption: %w", err)
		}
		p.Caption = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockBlockquote) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// GetCaption returns value of Caption field.
func (p *PageBlockBlockquote) GetCaption() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Caption
}

// PageBlockPullquote represents TL type `pageBlockPullquote#4f4456d3`.
// Pullquote
//
// See https://core.telegram.org/constructor/pageBlockPullquote for reference.
type PageBlockPullquote struct {
	// Text
	Text RichTextClass
	// Caption
	Caption RichTextClass
}

// PageBlockPullquoteTypeID is TL type id of PageBlockPullquote.
const PageBlockPullquoteTypeID = 0x4f4456d3

// construct implements constructor of PageBlockClass.
func (p PageBlockPullquote) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockPullquote{}
)

func (p *PageBlockPullquote) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}
	if !(p.Caption == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockPullquote from given interface.
func (p *PageBlockPullquote) FillFrom(from interface {
	GetText() (value RichTextClass)
	GetCaption() (value RichTextClass)
}) {
	p.Text = from.GetText()
	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockPullquote) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockPullquote",
		ID:   PageBlockPullquoteTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockPullquote) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockPullquote#4f4456d3 as nil")
	}
	b.PutID(PageBlockPullquoteTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockPullquote) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockPullquote#4f4456d3 as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockPullquote#4f4456d3: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockPullquote#4f4456d3: field text: %w", err)
	}
	if p.Caption == nil {
		return fmt.Errorf("unable to encode pageBlockPullquote#4f4456d3: field caption is nil")
	}
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockPullquote#4f4456d3: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockPullquote) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockPullquote#4f4456d3 to nil")
	}
	if err := b.ConsumeID(PageBlockPullquoteTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockPullquote#4f4456d3: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockPullquote) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockPullquote#4f4456d3 to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockPullquote#4f4456d3: field text: %w", err)
		}
		p.Text = value
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockPullquote#4f4456d3: field caption: %w", err)
		}
		p.Caption = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockPullquote) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// GetCaption returns value of Caption field.
func (p *PageBlockPullquote) GetCaption() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Caption
}

// PageBlockPhoto represents TL type `pageBlockPhoto#1759c560`.
// A photo
//
// See https://core.telegram.org/constructor/pageBlockPhoto for reference.
type PageBlockPhoto struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Photo ID
	PhotoID int64
	// Caption
	Caption PageCaption
	// HTTP URL of page the photo leads to when clicked
	//
	// Use SetURL and GetURL helpers.
	URL string
	// ID of preview of the page the photo leads to when clicked
	//
	// Use SetWebpageID and GetWebpageID helpers.
	WebpageID int64
}

// PageBlockPhotoTypeID is TL type id of PageBlockPhoto.
const PageBlockPhotoTypeID = 0x1759c560

// construct implements constructor of PageBlockClass.
func (p PageBlockPhoto) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockPhoto{}
)

func (p *PageBlockPhoto) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Flags.Zero()) {
		return false
	}
	if !(p.PhotoID == 0) {
		return false
	}
	if !(p.Caption.Zero()) {
		return false
	}
	if !(p.URL == "") {
		return false
	}
	if !(p.WebpageID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockPhoto from given interface.
func (p *PageBlockPhoto) FillFrom(from interface {
	GetPhotoID() (value int64)
	GetCaption() (value PageCaption)
	GetURL() (value string, ok bool)
	GetWebpageID() (value int64, ok bool)
}) {
	p.PhotoID = from.GetPhotoID()
	p.Caption = from.GetCaption()
	if val, ok := from.GetURL(); ok {
		p.URL = val
	}

	if val, ok := from.GetWebpageID(); ok {
		p.WebpageID = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockPhoto) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockPhoto",
		ID:   PageBlockPhotoTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "PhotoID",
			SchemaName: "photo_id",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
		{
			Name:       "URL",
			SchemaName: "url",
			Null:       !p.Flags.Has(0),
		},
		{
			Name:       "WebpageID",
			SchemaName: "webpage_id",
			Null:       !p.Flags.Has(0),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (p *PageBlockPhoto) SetFlags() {
	if !(p.URL == "") {
		p.Flags.Set(0)
	}
	if !(p.WebpageID == 0) {
		p.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func (p *PageBlockPhoto) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockPhoto#1759c560 as nil")
	}
	b.PutID(PageBlockPhotoTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockPhoto) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockPhoto#1759c560 as nil")
	}
	p.SetFlags()
	if err := p.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockPhoto#1759c560: field flags: %w", err)
	}
	b.PutLong(p.PhotoID)
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockPhoto#1759c560: field caption: %w", err)
	}
	if p.Flags.Has(0) {
		b.PutString(p.URL)
	}
	if p.Flags.Has(0) {
		b.PutLong(p.WebpageID)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockPhoto) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockPhoto#1759c560 to nil")
	}
	if err := b.ConsumeID(PageBlockPhotoTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockPhoto#1759c560: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockPhoto) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockPhoto#1759c560 to nil")
	}
	{
		if err := p.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockPhoto#1759c560: field flags: %w", err)
		}
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockPhoto#1759c560: field photo_id: %w", err)
		}
		p.PhotoID = value
	}
	{
		if err := p.Caption.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockPhoto#1759c560: field caption: %w", err)
		}
	}
	if p.Flags.Has(0) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockPhoto#1759c560: field url: %w", err)
		}
		p.URL = value
	}
	if p.Flags.Has(0) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockPhoto#1759c560: field webpage_id: %w", err)
		}
		p.WebpageID = value
	}
	return nil
}

// GetPhotoID returns value of PhotoID field.
func (p *PageBlockPhoto) GetPhotoID() (value int64) {
	if p == nil {
		return
	}
	return p.PhotoID
}

// GetCaption returns value of Caption field.
func (p *PageBlockPhoto) GetCaption() (value PageCaption) {
	if p == nil {
		return
	}
	return p.Caption
}

// SetURL sets value of URL conditional field.
func (p *PageBlockPhoto) SetURL(value string) {
	p.Flags.Set(0)
	p.URL = value
}

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

// SetWebpageID sets value of WebpageID conditional field.
func (p *PageBlockPhoto) SetWebpageID(value int64) {
	p.Flags.Set(0)
	p.WebpageID = value
}

// GetWebpageID returns value of WebpageID conditional field and
// boolean which is true if field was set.
func (p *PageBlockPhoto) GetWebpageID() (value int64, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(0) {
		return value, false
	}
	return p.WebpageID, true
}

// PageBlockVideo represents TL type `pageBlockVideo#7c8fe7b6`.
// Video
//
// See https://core.telegram.org/constructor/pageBlockVideo for reference.
type PageBlockVideo struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the video is set to autoplay
	Autoplay bool
	// Whether the video is set to loop
	Loop bool
	// Video ID
	VideoID int64
	// Caption
	Caption PageCaption
}

// PageBlockVideoTypeID is TL type id of PageBlockVideo.
const PageBlockVideoTypeID = 0x7c8fe7b6

// construct implements constructor of PageBlockClass.
func (p PageBlockVideo) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockVideo{}
)

func (p *PageBlockVideo) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Flags.Zero()) {
		return false
	}
	if !(p.Autoplay == false) {
		return false
	}
	if !(p.Loop == false) {
		return false
	}
	if !(p.VideoID == 0) {
		return false
	}
	if !(p.Caption.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockVideo from given interface.
func (p *PageBlockVideo) FillFrom(from interface {
	GetAutoplay() (value bool)
	GetLoop() (value bool)
	GetVideoID() (value int64)
	GetCaption() (value PageCaption)
}) {
	p.Autoplay = from.GetAutoplay()
	p.Loop = from.GetLoop()
	p.VideoID = from.GetVideoID()
	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockVideo) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockVideo",
		ID:   PageBlockVideoTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Autoplay",
			SchemaName: "autoplay",
			Null:       !p.Flags.Has(0),
		},
		{
			Name:       "Loop",
			SchemaName: "loop",
			Null:       !p.Flags.Has(1),
		},
		{
			Name:       "VideoID",
			SchemaName: "video_id",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (p *PageBlockVideo) SetFlags() {
	if !(p.Autoplay == false) {
		p.Flags.Set(0)
	}
	if !(p.Loop == false) {
		p.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func (p *PageBlockVideo) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockVideo#7c8fe7b6 as nil")
	}
	b.PutID(PageBlockVideoTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockVideo) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockVideo#7c8fe7b6 as nil")
	}
	p.SetFlags()
	if err := p.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockVideo#7c8fe7b6: field flags: %w", err)
	}
	b.PutLong(p.VideoID)
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockVideo#7c8fe7b6: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockVideo) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockVideo#7c8fe7b6 to nil")
	}
	if err := b.ConsumeID(PageBlockVideoTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockVideo#7c8fe7b6: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockVideo) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockVideo#7c8fe7b6 to nil")
	}
	{
		if err := p.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockVideo#7c8fe7b6: field flags: %w", err)
		}
	}
	p.Autoplay = p.Flags.Has(0)
	p.Loop = p.Flags.Has(1)
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockVideo#7c8fe7b6: field video_id: %w", err)
		}
		p.VideoID = value
	}
	{
		if err := p.Caption.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockVideo#7c8fe7b6: field caption: %w", err)
		}
	}
	return nil
}

// SetAutoplay sets value of Autoplay conditional field.
func (p *PageBlockVideo) SetAutoplay(value bool) {
	if value {
		p.Flags.Set(0)
		p.Autoplay = true
	} else {
		p.Flags.Unset(0)
		p.Autoplay = false
	}
}

// GetAutoplay returns value of Autoplay conditional field.
func (p *PageBlockVideo) GetAutoplay() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(0)
}

// SetLoop sets value of Loop conditional field.
func (p *PageBlockVideo) SetLoop(value bool) {
	if value {
		p.Flags.Set(1)
		p.Loop = true
	} else {
		p.Flags.Unset(1)
		p.Loop = false
	}
}

// GetLoop returns value of Loop conditional field.
func (p *PageBlockVideo) GetLoop() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(1)
}

// GetVideoID returns value of VideoID field.
func (p *PageBlockVideo) GetVideoID() (value int64) {
	if p == nil {
		return
	}
	return p.VideoID
}

// GetCaption returns value of Caption field.
func (p *PageBlockVideo) GetCaption() (value PageCaption) {
	if p == nil {
		return
	}
	return p.Caption
}

// PageBlockCover represents TL type `pageBlockCover#39f23300`.
// A page cover
//
// See https://core.telegram.org/constructor/pageBlockCover for reference.
type PageBlockCover struct {
	// Cover
	Cover PageBlockClass
}

// PageBlockCoverTypeID is TL type id of PageBlockCover.
const PageBlockCoverTypeID = 0x39f23300

// construct implements constructor of PageBlockClass.
func (p PageBlockCover) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockCover{}
)

func (p *PageBlockCover) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Cover == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockCover from given interface.
func (p *PageBlockCover) FillFrom(from interface {
	GetCover() (value PageBlockClass)
}) {
	p.Cover = from.GetCover()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockCover) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockCover",
		ID:   PageBlockCoverTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Cover",
			SchemaName: "cover",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockCover) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockCover#39f23300 as nil")
	}
	b.PutID(PageBlockCoverTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockCover) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockCover#39f23300 as nil")
	}
	if p.Cover == nil {
		return fmt.Errorf("unable to encode pageBlockCover#39f23300: field cover is nil")
	}
	if err := p.Cover.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockCover#39f23300: field cover: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockCover) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockCover#39f23300 to nil")
	}
	if err := b.ConsumeID(PageBlockCoverTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockCover#39f23300: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockCover) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockCover#39f23300 to nil")
	}
	{
		value, err := DecodePageBlock(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockCover#39f23300: field cover: %w", err)
		}
		p.Cover = value
	}
	return nil
}

// GetCover returns value of Cover field.
func (p *PageBlockCover) GetCover() (value PageBlockClass) {
	if p == nil {
		return
	}
	return p.Cover
}

// PageBlockEmbed represents TL type `pageBlockEmbed#a8718dc5`.
// An embedded webpage
//
// See https://core.telegram.org/constructor/pageBlockEmbed for reference.
type PageBlockEmbed struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the block should be full width
	FullWidth bool
	// Whether scrolling should be allowed
	AllowScrolling bool
	// Web page URL, if available
	//
	// Use SetURL and GetURL helpers.
	URL string
	// HTML-markup of the embedded page
	//
	// Use SetHTML and GetHTML helpers.
	HTML string
	// Poster photo, if available
	//
	// Use SetPosterPhotoID and GetPosterPhotoID helpers.
	PosterPhotoID int64
	// Block width, if known
	//
	// Use SetW and GetW helpers.
	W int
	// Block height, if known
	//
	// Use SetH and GetH helpers.
	H int
	// Caption
	Caption PageCaption
}

// PageBlockEmbedTypeID is TL type id of PageBlockEmbed.
const PageBlockEmbedTypeID = 0xa8718dc5

// construct implements constructor of PageBlockClass.
func (p PageBlockEmbed) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockEmbed{}
)

func (p *PageBlockEmbed) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Flags.Zero()) {
		return false
	}
	if !(p.FullWidth == false) {
		return false
	}
	if !(p.AllowScrolling == false) {
		return false
	}
	if !(p.URL == "") {
		return false
	}
	if !(p.HTML == "") {
		return false
	}
	if !(p.PosterPhotoID == 0) {
		return false
	}
	if !(p.W == 0) {
		return false
	}
	if !(p.H == 0) {
		return false
	}
	if !(p.Caption.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockEmbed from given interface.
func (p *PageBlockEmbed) FillFrom(from interface {
	GetFullWidth() (value bool)
	GetAllowScrolling() (value bool)
	GetURL() (value string, ok bool)
	GetHTML() (value string, ok bool)
	GetPosterPhotoID() (value int64, ok bool)
	GetW() (value int, ok bool)
	GetH() (value int, ok bool)
	GetCaption() (value PageCaption)
}) {
	p.FullWidth = from.GetFullWidth()
	p.AllowScrolling = from.GetAllowScrolling()
	if val, ok := from.GetURL(); ok {
		p.URL = val
	}

	if val, ok := from.GetHTML(); ok {
		p.HTML = val
	}

	if val, ok := from.GetPosterPhotoID(); ok {
		p.PosterPhotoID = val
	}

	if val, ok := from.GetW(); ok {
		p.W = val
	}

	if val, ok := from.GetH(); ok {
		p.H = val
	}

	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockEmbed) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockEmbed",
		ID:   PageBlockEmbedTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "FullWidth",
			SchemaName: "full_width",
			Null:       !p.Flags.Has(0),
		},
		{
			Name:       "AllowScrolling",
			SchemaName: "allow_scrolling",
			Null:       !p.Flags.Has(3),
		},
		{
			Name:       "URL",
			SchemaName: "url",
			Null:       !p.Flags.Has(1),
		},
		{
			Name:       "HTML",
			SchemaName: "html",
			Null:       !p.Flags.Has(2),
		},
		{
			Name:       "PosterPhotoID",
			SchemaName: "poster_photo_id",
			Null:       !p.Flags.Has(4),
		},
		{
			Name:       "W",
			SchemaName: "w",
			Null:       !p.Flags.Has(5),
		},
		{
			Name:       "H",
			SchemaName: "h",
			Null:       !p.Flags.Has(5),
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (p *PageBlockEmbed) SetFlags() {
	if !(p.FullWidth == false) {
		p.Flags.Set(0)
	}
	if !(p.AllowScrolling == false) {
		p.Flags.Set(3)
	}
	if !(p.URL == "") {
		p.Flags.Set(1)
	}
	if !(p.HTML == "") {
		p.Flags.Set(2)
	}
	if !(p.PosterPhotoID == 0) {
		p.Flags.Set(4)
	}
	if !(p.W == 0) {
		p.Flags.Set(5)
	}
	if !(p.H == 0) {
		p.Flags.Set(5)
	}
}

// Encode implements bin.Encoder.
func (p *PageBlockEmbed) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockEmbed#a8718dc5 as nil")
	}
	b.PutID(PageBlockEmbedTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockEmbed) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockEmbed#a8718dc5 as nil")
	}
	p.SetFlags()
	if err := p.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockEmbed#a8718dc5: field flags: %w", err)
	}
	if p.Flags.Has(1) {
		b.PutString(p.URL)
	}
	if p.Flags.Has(2) {
		b.PutString(p.HTML)
	}
	if p.Flags.Has(4) {
		b.PutLong(p.PosterPhotoID)
	}
	if p.Flags.Has(5) {
		b.PutInt(p.W)
	}
	if p.Flags.Has(5) {
		b.PutInt(p.H)
	}
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockEmbed#a8718dc5: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockEmbed) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockEmbed#a8718dc5 to nil")
	}
	if err := b.ConsumeID(PageBlockEmbedTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockEmbed#a8718dc5: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockEmbed) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockEmbed#a8718dc5 to nil")
	}
	{
		if err := p.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbed#a8718dc5: field flags: %w", err)
		}
	}
	p.FullWidth = p.Flags.Has(0)
	p.AllowScrolling = p.Flags.Has(3)
	if p.Flags.Has(1) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbed#a8718dc5: field url: %w", err)
		}
		p.URL = value
	}
	if p.Flags.Has(2) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbed#a8718dc5: field html: %w", err)
		}
		p.HTML = value
	}
	if p.Flags.Has(4) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbed#a8718dc5: field poster_photo_id: %w", err)
		}
		p.PosterPhotoID = value
	}
	if p.Flags.Has(5) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbed#a8718dc5: field w: %w", err)
		}
		p.W = value
	}
	if p.Flags.Has(5) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbed#a8718dc5: field h: %w", err)
		}
		p.H = value
	}
	{
		if err := p.Caption.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbed#a8718dc5: field caption: %w", err)
		}
	}
	return nil
}

// SetFullWidth sets value of FullWidth conditional field.
func (p *PageBlockEmbed) SetFullWidth(value bool) {
	if value {
		p.Flags.Set(0)
		p.FullWidth = true
	} else {
		p.Flags.Unset(0)
		p.FullWidth = false
	}
}

// GetFullWidth returns value of FullWidth conditional field.
func (p *PageBlockEmbed) GetFullWidth() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(0)
}

// SetAllowScrolling sets value of AllowScrolling conditional field.
func (p *PageBlockEmbed) SetAllowScrolling(value bool) {
	if value {
		p.Flags.Set(3)
		p.AllowScrolling = true
	} else {
		p.Flags.Unset(3)
		p.AllowScrolling = false
	}
}

// GetAllowScrolling returns value of AllowScrolling conditional field.
func (p *PageBlockEmbed) GetAllowScrolling() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(3)
}

// SetURL sets value of URL conditional field.
func (p *PageBlockEmbed) SetURL(value string) {
	p.Flags.Set(1)
	p.URL = value
}

// GetURL returns value of URL conditional field and
// boolean which is true if field was set.
func (p *PageBlockEmbed) GetURL() (value string, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(1) {
		return value, false
	}
	return p.URL, true
}

// SetHTML sets value of HTML conditional field.
func (p *PageBlockEmbed) SetHTML(value string) {
	p.Flags.Set(2)
	p.HTML = value
}

// GetHTML returns value of HTML conditional field and
// boolean which is true if field was set.
func (p *PageBlockEmbed) GetHTML() (value string, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(2) {
		return value, false
	}
	return p.HTML, true
}

// SetPosterPhotoID sets value of PosterPhotoID conditional field.
func (p *PageBlockEmbed) SetPosterPhotoID(value int64) {
	p.Flags.Set(4)
	p.PosterPhotoID = value
}

// GetPosterPhotoID returns value of PosterPhotoID conditional field and
// boolean which is true if field was set.
func (p *PageBlockEmbed) GetPosterPhotoID() (value int64, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(4) {
		return value, false
	}
	return p.PosterPhotoID, true
}

// SetW sets value of W conditional field.
func (p *PageBlockEmbed) SetW(value int) {
	p.Flags.Set(5)
	p.W = value
}

// GetW returns value of W conditional field and
// boolean which is true if field was set.
func (p *PageBlockEmbed) GetW() (value int, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(5) {
		return value, false
	}
	return p.W, true
}

// SetH sets value of H conditional field.
func (p *PageBlockEmbed) SetH(value int) {
	p.Flags.Set(5)
	p.H = value
}

// GetH returns value of H conditional field and
// boolean which is true if field was set.
func (p *PageBlockEmbed) GetH() (value int, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(5) {
		return value, false
	}
	return p.H, true
}

// GetCaption returns value of Caption field.
func (p *PageBlockEmbed) GetCaption() (value PageCaption) {
	if p == nil {
		return
	}
	return p.Caption
}

// PageBlockEmbedPost represents TL type `pageBlockEmbedPost#f259a80b`.
// An embedded post
//
// See https://core.telegram.org/constructor/pageBlockEmbedPost for reference.
type PageBlockEmbedPost struct {
	// Web page URL
	URL string
	// ID of generated webpage preview
	WebpageID int64
	// ID of the author's photo
	AuthorPhotoID int64
	// Author name
	Author string
	// Creation date
	Date int
	// Post contents
	Blocks []PageBlockClass
	// Caption
	Caption PageCaption
}

// PageBlockEmbedPostTypeID is TL type id of PageBlockEmbedPost.
const PageBlockEmbedPostTypeID = 0xf259a80b

// construct implements constructor of PageBlockClass.
func (p PageBlockEmbedPost) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockEmbedPost{}
)

func (p *PageBlockEmbedPost) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.URL == "") {
		return false
	}
	if !(p.WebpageID == 0) {
		return false
	}
	if !(p.AuthorPhotoID == 0) {
		return false
	}
	if !(p.Author == "") {
		return false
	}
	if !(p.Date == 0) {
		return false
	}
	if !(p.Blocks == nil) {
		return false
	}
	if !(p.Caption.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockEmbedPost from given interface.
func (p *PageBlockEmbedPost) FillFrom(from interface {
	GetURL() (value string)
	GetWebpageID() (value int64)
	GetAuthorPhotoID() (value int64)
	GetAuthor() (value string)
	GetDate() (value int)
	GetBlocks() (value []PageBlockClass)
	GetCaption() (value PageCaption)
}) {
	p.URL = from.GetURL()
	p.WebpageID = from.GetWebpageID()
	p.AuthorPhotoID = from.GetAuthorPhotoID()
	p.Author = from.GetAuthor()
	p.Date = from.GetDate()
	p.Blocks = from.GetBlocks()
	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockEmbedPost) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockEmbedPost",
		ID:   PageBlockEmbedPostTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "WebpageID",
			SchemaName: "webpage_id",
		},
		{
			Name:       "AuthorPhotoID",
			SchemaName: "author_photo_id",
		},
		{
			Name:       "Author",
			SchemaName: "author",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Blocks",
			SchemaName: "blocks",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockEmbedPost) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockEmbedPost#f259a80b as nil")
	}
	b.PutID(PageBlockEmbedPostTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockEmbedPost) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockEmbedPost#f259a80b as nil")
	}
	b.PutString(p.URL)
	b.PutLong(p.WebpageID)
	b.PutLong(p.AuthorPhotoID)
	b.PutString(p.Author)
	b.PutInt(p.Date)
	b.PutVectorHeader(len(p.Blocks))
	for idx, v := range p.Blocks {
		if v == nil {
			return fmt.Errorf("unable to encode pageBlockEmbedPost#f259a80b: field blocks element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode pageBlockEmbedPost#f259a80b: field blocks element with index %d: %w", idx, err)
		}
	}
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockEmbedPost#f259a80b: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockEmbedPost) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockEmbedPost#f259a80b to nil")
	}
	if err := b.ConsumeID(PageBlockEmbedPostTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockEmbedPost) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockEmbedPost#f259a80b to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: field url: %w", err)
		}
		p.URL = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: field webpage_id: %w", err)
		}
		p.WebpageID = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: field author_photo_id: %w", err)
		}
		p.AuthorPhotoID = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: field author: %w", err)
		}
		p.Author = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: field date: %w", err)
		}
		p.Date = value
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: field blocks: %w", err)
		}

		if headerLen > 0 {
			p.Blocks = make([]PageBlockClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePageBlock(b)
			if err != nil {
				return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: field blocks: %w", err)
			}
			p.Blocks = append(p.Blocks, value)
		}
	}
	{
		if err := p.Caption.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockEmbedPost#f259a80b: field caption: %w", err)
		}
	}
	return nil
}

// GetURL returns value of URL field.
func (p *PageBlockEmbedPost) GetURL() (value string) {
	if p == nil {
		return
	}
	return p.URL
}

// GetWebpageID returns value of WebpageID field.
func (p *PageBlockEmbedPost) GetWebpageID() (value int64) {
	if p == nil {
		return
	}
	return p.WebpageID
}

// GetAuthorPhotoID returns value of AuthorPhotoID field.
func (p *PageBlockEmbedPost) GetAuthorPhotoID() (value int64) {
	if p == nil {
		return
	}
	return p.AuthorPhotoID
}

// GetAuthor returns value of Author field.
func (p *PageBlockEmbedPost) GetAuthor() (value string) {
	if p == nil {
		return
	}
	return p.Author
}

// GetDate returns value of Date field.
func (p *PageBlockEmbedPost) GetDate() (value int) {
	if p == nil {
		return
	}
	return p.Date
}

// GetBlocks returns value of Blocks field.
func (p *PageBlockEmbedPost) GetBlocks() (value []PageBlockClass) {
	if p == nil {
		return
	}
	return p.Blocks
}

// GetCaption returns value of Caption field.
func (p *PageBlockEmbedPost) GetCaption() (value PageCaption) {
	if p == nil {
		return
	}
	return p.Caption
}

// MapBlocks returns field Blocks wrapped in PageBlockClassArray helper.
func (p *PageBlockEmbedPost) MapBlocks() (value PageBlockClassArray) {
	return PageBlockClassArray(p.Blocks)
}

// PageBlockCollage represents TL type `pageBlockCollage#65a0fa4d`.
// Collage of media
//
// See https://core.telegram.org/constructor/pageBlockCollage for reference.
type PageBlockCollage struct {
	// Media elements
	Items []PageBlockClass
	// Caption
	Caption PageCaption
}

// PageBlockCollageTypeID is TL type id of PageBlockCollage.
const PageBlockCollageTypeID = 0x65a0fa4d

// construct implements constructor of PageBlockClass.
func (p PageBlockCollage) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockCollage{}
)

func (p *PageBlockCollage) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Items == nil) {
		return false
	}
	if !(p.Caption.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockCollage from given interface.
func (p *PageBlockCollage) FillFrom(from interface {
	GetItems() (value []PageBlockClass)
	GetCaption() (value PageCaption)
}) {
	p.Items = from.GetItems()
	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockCollage) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockCollage",
		ID:   PageBlockCollageTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Items",
			SchemaName: "items",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockCollage) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockCollage#65a0fa4d as nil")
	}
	b.PutID(PageBlockCollageTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockCollage) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockCollage#65a0fa4d as nil")
	}
	b.PutVectorHeader(len(p.Items))
	for idx, v := range p.Items {
		if v == nil {
			return fmt.Errorf("unable to encode pageBlockCollage#65a0fa4d: field items element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode pageBlockCollage#65a0fa4d: field items element with index %d: %w", idx, err)
		}
	}
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockCollage#65a0fa4d: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockCollage) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockCollage#65a0fa4d to nil")
	}
	if err := b.ConsumeID(PageBlockCollageTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockCollage#65a0fa4d: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockCollage) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockCollage#65a0fa4d to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockCollage#65a0fa4d: field items: %w", err)
		}

		if headerLen > 0 {
			p.Items = make([]PageBlockClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePageBlock(b)
			if err != nil {
				return fmt.Errorf("unable to decode pageBlockCollage#65a0fa4d: field items: %w", err)
			}
			p.Items = append(p.Items, value)
		}
	}
	{
		if err := p.Caption.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockCollage#65a0fa4d: field caption: %w", err)
		}
	}
	return nil
}

// GetItems returns value of Items field.
func (p *PageBlockCollage) GetItems() (value []PageBlockClass) {
	if p == nil {
		return
	}
	return p.Items
}

// GetCaption returns value of Caption field.
func (p *PageBlockCollage) GetCaption() (value PageCaption) {
	if p == nil {
		return
	}
	return p.Caption
}

// MapItems returns field Items wrapped in PageBlockClassArray helper.
func (p *PageBlockCollage) MapItems() (value PageBlockClassArray) {
	return PageBlockClassArray(p.Items)
}

// PageBlockSlideshow represents TL type `pageBlockSlideshow#31f9590`.
// Slideshow
//
// See https://core.telegram.org/constructor/pageBlockSlideshow for reference.
type PageBlockSlideshow struct {
	// Slideshow items
	Items []PageBlockClass
	// Caption
	Caption PageCaption
}

// PageBlockSlideshowTypeID is TL type id of PageBlockSlideshow.
const PageBlockSlideshowTypeID = 0x31f9590

// construct implements constructor of PageBlockClass.
func (p PageBlockSlideshow) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockSlideshow{}
)

func (p *PageBlockSlideshow) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Items == nil) {
		return false
	}
	if !(p.Caption.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockSlideshow from given interface.
func (p *PageBlockSlideshow) FillFrom(from interface {
	GetItems() (value []PageBlockClass)
	GetCaption() (value PageCaption)
}) {
	p.Items = from.GetItems()
	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockSlideshow) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockSlideshow",
		ID:   PageBlockSlideshowTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Items",
			SchemaName: "items",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockSlideshow) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockSlideshow#31f9590 as nil")
	}
	b.PutID(PageBlockSlideshowTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockSlideshow) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockSlideshow#31f9590 as nil")
	}
	b.PutVectorHeader(len(p.Items))
	for idx, v := range p.Items {
		if v == nil {
			return fmt.Errorf("unable to encode pageBlockSlideshow#31f9590: field items element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode pageBlockSlideshow#31f9590: field items element with index %d: %w", idx, err)
		}
	}
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockSlideshow#31f9590: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockSlideshow) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockSlideshow#31f9590 to nil")
	}
	if err := b.ConsumeID(PageBlockSlideshowTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockSlideshow#31f9590: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockSlideshow) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockSlideshow#31f9590 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockSlideshow#31f9590: field items: %w", err)
		}

		if headerLen > 0 {
			p.Items = make([]PageBlockClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePageBlock(b)
			if err != nil {
				return fmt.Errorf("unable to decode pageBlockSlideshow#31f9590: field items: %w", err)
			}
			p.Items = append(p.Items, value)
		}
	}
	{
		if err := p.Caption.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockSlideshow#31f9590: field caption: %w", err)
		}
	}
	return nil
}

// GetItems returns value of Items field.
func (p *PageBlockSlideshow) GetItems() (value []PageBlockClass) {
	if p == nil {
		return
	}
	return p.Items
}

// GetCaption returns value of Caption field.
func (p *PageBlockSlideshow) GetCaption() (value PageCaption) {
	if p == nil {
		return
	}
	return p.Caption
}

// MapItems returns field Items wrapped in PageBlockClassArray helper.
func (p *PageBlockSlideshow) MapItems() (value PageBlockClassArray) {
	return PageBlockClassArray(p.Items)
}

// PageBlockChannel represents TL type `pageBlockChannel#ef1751b5`.
// Reference to a telegram channel
//
// See https://core.telegram.org/constructor/pageBlockChannel for reference.
type PageBlockChannel struct {
	// The channel/supergroup/chat
	Channel ChatClass
}

// PageBlockChannelTypeID is TL type id of PageBlockChannel.
const PageBlockChannelTypeID = 0xef1751b5

// construct implements constructor of PageBlockClass.
func (p PageBlockChannel) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockChannel{}
)

func (p *PageBlockChannel) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Channel == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockChannel from given interface.
func (p *PageBlockChannel) FillFrom(from interface {
	GetChannel() (value ChatClass)
}) {
	p.Channel = from.GetChannel()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockChannel) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockChannel",
		ID:   PageBlockChannelTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockChannel) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockChannel#ef1751b5 as nil")
	}
	b.PutID(PageBlockChannelTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockChannel) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockChannel#ef1751b5 as nil")
	}
	if p.Channel == nil {
		return fmt.Errorf("unable to encode pageBlockChannel#ef1751b5: field channel is nil")
	}
	if err := p.Channel.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockChannel#ef1751b5: field channel: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockChannel) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockChannel#ef1751b5 to nil")
	}
	if err := b.ConsumeID(PageBlockChannelTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockChannel#ef1751b5: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockChannel) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockChannel#ef1751b5 to nil")
	}
	{
		value, err := DecodeChat(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockChannel#ef1751b5: field channel: %w", err)
		}
		p.Channel = value
	}
	return nil
}

// GetChannel returns value of Channel field.
func (p *PageBlockChannel) GetChannel() (value ChatClass) {
	if p == nil {
		return
	}
	return p.Channel
}

// PageBlockAudio represents TL type `pageBlockAudio#804361ea`.
// Audio
//
// See https://core.telegram.org/constructor/pageBlockAudio for reference.
type PageBlockAudio struct {
	// Audio ID (to be fetched from the container page¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/constructor/page
	AudioID int64
	// Audio caption
	Caption PageCaption
}

// PageBlockAudioTypeID is TL type id of PageBlockAudio.
const PageBlockAudioTypeID = 0x804361ea

// construct implements constructor of PageBlockClass.
func (p PageBlockAudio) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockAudio{}
)

func (p *PageBlockAudio) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.AudioID == 0) {
		return false
	}
	if !(p.Caption.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockAudio from given interface.
func (p *PageBlockAudio) FillFrom(from interface {
	GetAudioID() (value int64)
	GetCaption() (value PageCaption)
}) {
	p.AudioID = from.GetAudioID()
	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockAudio) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockAudio",
		ID:   PageBlockAudioTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "AudioID",
			SchemaName: "audio_id",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockAudio) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockAudio#804361ea as nil")
	}
	b.PutID(PageBlockAudioTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockAudio) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockAudio#804361ea as nil")
	}
	b.PutLong(p.AudioID)
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockAudio#804361ea: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockAudio) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockAudio#804361ea to nil")
	}
	if err := b.ConsumeID(PageBlockAudioTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockAudio#804361ea: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockAudio) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockAudio#804361ea to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockAudio#804361ea: field audio_id: %w", err)
		}
		p.AudioID = value
	}
	{
		if err := p.Caption.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockAudio#804361ea: field caption: %w", err)
		}
	}
	return nil
}

// GetAudioID returns value of AudioID field.
func (p *PageBlockAudio) GetAudioID() (value int64) {
	if p == nil {
		return
	}
	return p.AudioID
}

// GetCaption returns value of Caption field.
func (p *PageBlockAudio) GetCaption() (value PageCaption) {
	if p == nil {
		return
	}
	return p.Caption
}

// PageBlockKicker represents TL type `pageBlockKicker#1e148390`.
// Kicker
//
// See https://core.telegram.org/constructor/pageBlockKicker for reference.
type PageBlockKicker struct {
	// Contents
	Text RichTextClass
}

// PageBlockKickerTypeID is TL type id of PageBlockKicker.
const PageBlockKickerTypeID = 0x1e148390

// construct implements constructor of PageBlockClass.
func (p PageBlockKicker) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockKicker{}
)

func (p *PageBlockKicker) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Text == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockKicker from given interface.
func (p *PageBlockKicker) FillFrom(from interface {
	GetText() (value RichTextClass)
}) {
	p.Text = from.GetText()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockKicker) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockKicker",
		ID:   PageBlockKickerTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockKicker) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockKicker#1e148390 as nil")
	}
	b.PutID(PageBlockKickerTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockKicker) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockKicker#1e148390 as nil")
	}
	if p.Text == nil {
		return fmt.Errorf("unable to encode pageBlockKicker#1e148390: field text is nil")
	}
	if err := p.Text.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockKicker#1e148390: field text: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockKicker) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockKicker#1e148390 to nil")
	}
	if err := b.ConsumeID(PageBlockKickerTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockKicker#1e148390: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockKicker) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockKicker#1e148390 to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockKicker#1e148390: field text: %w", err)
		}
		p.Text = value
	}
	return nil
}

// GetText returns value of Text field.
func (p *PageBlockKicker) GetText() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Text
}

// PageBlockTable represents TL type `pageBlockTable#bf4dea82`.
// Table
//
// See https://core.telegram.org/constructor/pageBlockTable for reference.
type PageBlockTable struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Does the table have a visible border?
	Bordered bool
	// Is the table striped?
	Striped bool
	// Title
	Title RichTextClass
	// Table rows
	Rows []PageTableRow
}

// PageBlockTableTypeID is TL type id of PageBlockTable.
const PageBlockTableTypeID = 0xbf4dea82

// construct implements constructor of PageBlockClass.
func (p PageBlockTable) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockTable{}
)

func (p *PageBlockTable) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Flags.Zero()) {
		return false
	}
	if !(p.Bordered == false) {
		return false
	}
	if !(p.Striped == false) {
		return false
	}
	if !(p.Title == nil) {
		return false
	}
	if !(p.Rows == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockTable from given interface.
func (p *PageBlockTable) FillFrom(from interface {
	GetBordered() (value bool)
	GetStriped() (value bool)
	GetTitle() (value RichTextClass)
	GetRows() (value []PageTableRow)
}) {
	p.Bordered = from.GetBordered()
	p.Striped = from.GetStriped()
	p.Title = from.GetTitle()
	p.Rows = from.GetRows()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockTable) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockTable",
		ID:   PageBlockTableTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Bordered",
			SchemaName: "bordered",
			Null:       !p.Flags.Has(0),
		},
		{
			Name:       "Striped",
			SchemaName: "striped",
			Null:       !p.Flags.Has(1),
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Rows",
			SchemaName: "rows",
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (p *PageBlockTable) SetFlags() {
	if !(p.Bordered == false) {
		p.Flags.Set(0)
	}
	if !(p.Striped == false) {
		p.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func (p *PageBlockTable) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockTable#bf4dea82 as nil")
	}
	b.PutID(PageBlockTableTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockTable) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockTable#bf4dea82 as nil")
	}
	p.SetFlags()
	if err := p.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockTable#bf4dea82: field flags: %w", err)
	}
	if p.Title == nil {
		return fmt.Errorf("unable to encode pageBlockTable#bf4dea82: field title is nil")
	}
	if err := p.Title.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockTable#bf4dea82: field title: %w", err)
	}
	b.PutVectorHeader(len(p.Rows))
	for idx, v := range p.Rows {
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode pageBlockTable#bf4dea82: field rows element with index %d: %w", idx, err)
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockTable) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockTable#bf4dea82 to nil")
	}
	if err := b.ConsumeID(PageBlockTableTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockTable#bf4dea82: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockTable) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockTable#bf4dea82 to nil")
	}
	{
		if err := p.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockTable#bf4dea82: field flags: %w", err)
		}
	}
	p.Bordered = p.Flags.Has(0)
	p.Striped = p.Flags.Has(1)
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockTable#bf4dea82: field title: %w", err)
		}
		p.Title = value
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockTable#bf4dea82: field rows: %w", err)
		}

		if headerLen > 0 {
			p.Rows = make([]PageTableRow, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			var value PageTableRow
			if err := value.Decode(b); err != nil {
				return fmt.Errorf("unable to decode pageBlockTable#bf4dea82: field rows: %w", err)
			}
			p.Rows = append(p.Rows, value)
		}
	}
	return nil
}

// SetBordered sets value of Bordered conditional field.
func (p *PageBlockTable) SetBordered(value bool) {
	if value {
		p.Flags.Set(0)
		p.Bordered = true
	} else {
		p.Flags.Unset(0)
		p.Bordered = false
	}
}

// GetBordered returns value of Bordered conditional field.
func (p *PageBlockTable) GetBordered() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(0)
}

// SetStriped sets value of Striped conditional field.
func (p *PageBlockTable) SetStriped(value bool) {
	if value {
		p.Flags.Set(1)
		p.Striped = true
	} else {
		p.Flags.Unset(1)
		p.Striped = false
	}
}

// GetStriped returns value of Striped conditional field.
func (p *PageBlockTable) GetStriped() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(1)
}

// GetTitle returns value of Title field.
func (p *PageBlockTable) GetTitle() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Title
}

// GetRows returns value of Rows field.
func (p *PageBlockTable) GetRows() (value []PageTableRow) {
	if p == nil {
		return
	}
	return p.Rows
}

// PageBlockOrderedList represents TL type `pageBlockOrderedList#9a8ae1e1`.
// Ordered list of IV blocks
//
// See https://core.telegram.org/constructor/pageBlockOrderedList for reference.
type PageBlockOrderedList struct {
	// List items
	Items []PageListOrderedItemClass
}

// PageBlockOrderedListTypeID is TL type id of PageBlockOrderedList.
const PageBlockOrderedListTypeID = 0x9a8ae1e1

// construct implements constructor of PageBlockClass.
func (p PageBlockOrderedList) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockOrderedList{}
)

func (p *PageBlockOrderedList) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Items == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockOrderedList from given interface.
func (p *PageBlockOrderedList) FillFrom(from interface {
	GetItems() (value []PageListOrderedItemClass)
}) {
	p.Items = from.GetItems()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockOrderedList) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockOrderedList",
		ID:   PageBlockOrderedListTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Items",
			SchemaName: "items",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockOrderedList) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockOrderedList#9a8ae1e1 as nil")
	}
	b.PutID(PageBlockOrderedListTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockOrderedList) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockOrderedList#9a8ae1e1 as nil")
	}
	b.PutVectorHeader(len(p.Items))
	for idx, v := range p.Items {
		if v == nil {
			return fmt.Errorf("unable to encode pageBlockOrderedList#9a8ae1e1: field items element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode pageBlockOrderedList#9a8ae1e1: field items element with index %d: %w", idx, err)
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockOrderedList) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockOrderedList#9a8ae1e1 to nil")
	}
	if err := b.ConsumeID(PageBlockOrderedListTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockOrderedList#9a8ae1e1: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockOrderedList) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockOrderedList#9a8ae1e1 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockOrderedList#9a8ae1e1: field items: %w", err)
		}

		if headerLen > 0 {
			p.Items = make([]PageListOrderedItemClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePageListOrderedItem(b)
			if err != nil {
				return fmt.Errorf("unable to decode pageBlockOrderedList#9a8ae1e1: field items: %w", err)
			}
			p.Items = append(p.Items, value)
		}
	}
	return nil
}

// GetItems returns value of Items field.
func (p *PageBlockOrderedList) GetItems() (value []PageListOrderedItemClass) {
	if p == nil {
		return
	}
	return p.Items
}

// MapItems returns field Items wrapped in PageListOrderedItemClassArray helper.
func (p *PageBlockOrderedList) MapItems() (value PageListOrderedItemClassArray) {
	return PageListOrderedItemClassArray(p.Items)
}

// PageBlockDetails represents TL type `pageBlockDetails#76768bed`.
// A collapsible details block
//
// See https://core.telegram.org/constructor/pageBlockDetails for reference.
type PageBlockDetails struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the block is open by default
	Open bool
	// Block contents
	Blocks []PageBlockClass
	// Always visible heading for the block
	Title RichTextClass
}

// PageBlockDetailsTypeID is TL type id of PageBlockDetails.
const PageBlockDetailsTypeID = 0x76768bed

// construct implements constructor of PageBlockClass.
func (p PageBlockDetails) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockDetails{}
)

func (p *PageBlockDetails) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Flags.Zero()) {
		return false
	}
	if !(p.Open == false) {
		return false
	}
	if !(p.Blocks == nil) {
		return false
	}
	if !(p.Title == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockDetails from given interface.
func (p *PageBlockDetails) FillFrom(from interface {
	GetOpen() (value bool)
	GetBlocks() (value []PageBlockClass)
	GetTitle() (value RichTextClass)
}) {
	p.Open = from.GetOpen()
	p.Blocks = from.GetBlocks()
	p.Title = from.GetTitle()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockDetails) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockDetails",
		ID:   PageBlockDetailsTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Open",
			SchemaName: "open",
			Null:       !p.Flags.Has(0),
		},
		{
			Name:       "Blocks",
			SchemaName: "blocks",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (p *PageBlockDetails) SetFlags() {
	if !(p.Open == false) {
		p.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func (p *PageBlockDetails) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockDetails#76768bed as nil")
	}
	b.PutID(PageBlockDetailsTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockDetails) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockDetails#76768bed as nil")
	}
	p.SetFlags()
	if err := p.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockDetails#76768bed: field flags: %w", err)
	}
	b.PutVectorHeader(len(p.Blocks))
	for idx, v := range p.Blocks {
		if v == nil {
			return fmt.Errorf("unable to encode pageBlockDetails#76768bed: field blocks element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode pageBlockDetails#76768bed: field blocks element with index %d: %w", idx, err)
		}
	}
	if p.Title == nil {
		return fmt.Errorf("unable to encode pageBlockDetails#76768bed: field title is nil")
	}
	if err := p.Title.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockDetails#76768bed: field title: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockDetails) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockDetails#76768bed to nil")
	}
	if err := b.ConsumeID(PageBlockDetailsTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockDetails#76768bed: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockDetails) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockDetails#76768bed to nil")
	}
	{
		if err := p.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockDetails#76768bed: field flags: %w", err)
		}
	}
	p.Open = p.Flags.Has(0)
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockDetails#76768bed: field blocks: %w", err)
		}

		if headerLen > 0 {
			p.Blocks = make([]PageBlockClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePageBlock(b)
			if err != nil {
				return fmt.Errorf("unable to decode pageBlockDetails#76768bed: field blocks: %w", err)
			}
			p.Blocks = append(p.Blocks, value)
		}
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockDetails#76768bed: field title: %w", err)
		}
		p.Title = value
	}
	return nil
}

// SetOpen sets value of Open conditional field.
func (p *PageBlockDetails) SetOpen(value bool) {
	if value {
		p.Flags.Set(0)
		p.Open = true
	} else {
		p.Flags.Unset(0)
		p.Open = false
	}
}

// GetOpen returns value of Open conditional field.
func (p *PageBlockDetails) GetOpen() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(0)
}

// GetBlocks returns value of Blocks field.
func (p *PageBlockDetails) GetBlocks() (value []PageBlockClass) {
	if p == nil {
		return
	}
	return p.Blocks
}

// GetTitle returns value of Title field.
func (p *PageBlockDetails) GetTitle() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Title
}

// MapBlocks returns field Blocks wrapped in PageBlockClassArray helper.
func (p *PageBlockDetails) MapBlocks() (value PageBlockClassArray) {
	return PageBlockClassArray(p.Blocks)
}

// PageBlockRelatedArticles represents TL type `pageBlockRelatedArticles#16115a96`.
// Related articles
//
// See https://core.telegram.org/constructor/pageBlockRelatedArticles for reference.
type PageBlockRelatedArticles struct {
	// Title
	Title RichTextClass
	// Related articles
	Articles []PageRelatedArticle
}

// PageBlockRelatedArticlesTypeID is TL type id of PageBlockRelatedArticles.
const PageBlockRelatedArticlesTypeID = 0x16115a96

// construct implements constructor of PageBlockClass.
func (p PageBlockRelatedArticles) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockRelatedArticles{}
)

func (p *PageBlockRelatedArticles) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Title == nil) {
		return false
	}
	if !(p.Articles == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockRelatedArticles from given interface.
func (p *PageBlockRelatedArticles) FillFrom(from interface {
	GetTitle() (value RichTextClass)
	GetArticles() (value []PageRelatedArticle)
}) {
	p.Title = from.GetTitle()
	p.Articles = from.GetArticles()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockRelatedArticles) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockRelatedArticles",
		ID:   PageBlockRelatedArticlesTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Articles",
			SchemaName: "articles",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockRelatedArticles) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockRelatedArticles#16115a96 as nil")
	}
	b.PutID(PageBlockRelatedArticlesTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockRelatedArticles) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockRelatedArticles#16115a96 as nil")
	}
	if p.Title == nil {
		return fmt.Errorf("unable to encode pageBlockRelatedArticles#16115a96: field title is nil")
	}
	if err := p.Title.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockRelatedArticles#16115a96: field title: %w", err)
	}
	b.PutVectorHeader(len(p.Articles))
	for idx, v := range p.Articles {
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode pageBlockRelatedArticles#16115a96: field articles element with index %d: %w", idx, err)
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockRelatedArticles) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockRelatedArticles#16115a96 to nil")
	}
	if err := b.ConsumeID(PageBlockRelatedArticlesTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockRelatedArticles#16115a96: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockRelatedArticles) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockRelatedArticles#16115a96 to nil")
	}
	{
		value, err := DecodeRichText(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockRelatedArticles#16115a96: field title: %w", err)
		}
		p.Title = value
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockRelatedArticles#16115a96: field articles: %w", err)
		}

		if headerLen > 0 {
			p.Articles = make([]PageRelatedArticle, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			var value PageRelatedArticle
			if err := value.Decode(b); err != nil {
				return fmt.Errorf("unable to decode pageBlockRelatedArticles#16115a96: field articles: %w", err)
			}
			p.Articles = append(p.Articles, value)
		}
	}
	return nil
}

// GetTitle returns value of Title field.
func (p *PageBlockRelatedArticles) GetTitle() (value RichTextClass) {
	if p == nil {
		return
	}
	return p.Title
}

// GetArticles returns value of Articles field.
func (p *PageBlockRelatedArticles) GetArticles() (value []PageRelatedArticle) {
	if p == nil {
		return
	}
	return p.Articles
}

// PageBlockMap represents TL type `pageBlockMap#a44f3ef6`.
// A map
//
// See https://core.telegram.org/constructor/pageBlockMap for reference.
type PageBlockMap struct {
	// Location of the map center
	Geo GeoPointClass
	// Map zoom level; 13-20
	Zoom int
	// Map width in pixels before applying scale; 16-102
	W int
	// Map height in pixels before applying scale; 16-1024
	H int
	// Caption
	Caption PageCaption
}

// PageBlockMapTypeID is TL type id of PageBlockMap.
const PageBlockMapTypeID = 0xa44f3ef6

// construct implements constructor of PageBlockClass.
func (p PageBlockMap) construct() PageBlockClass { return &p }

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

	_ PageBlockClass = &PageBlockMap{}
)

func (p *PageBlockMap) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Geo == nil) {
		return false
	}
	if !(p.Zoom == 0) {
		return false
	}
	if !(p.W == 0) {
		return false
	}
	if !(p.H == 0) {
		return false
	}
	if !(p.Caption.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PageBlockMap from given interface.
func (p *PageBlockMap) FillFrom(from interface {
	GetGeo() (value GeoPointClass)
	GetZoom() (value int)
	GetW() (value int)
	GetH() (value int)
	GetCaption() (value PageCaption)
}) {
	p.Geo = from.GetGeo()
	p.Zoom = from.GetZoom()
	p.W = from.GetW()
	p.H = from.GetH()
	p.Caption = from.GetCaption()
}

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

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

// TypeInfo returns info about TL type.
func (p *PageBlockMap) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "pageBlockMap",
		ID:   PageBlockMapTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Geo",
			SchemaName: "geo",
		},
		{
			Name:       "Zoom",
			SchemaName: "zoom",
		},
		{
			Name:       "W",
			SchemaName: "w",
		},
		{
			Name:       "H",
			SchemaName: "h",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (p *PageBlockMap) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockMap#a44f3ef6 as nil")
	}
	b.PutID(PageBlockMapTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PageBlockMap) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode pageBlockMap#a44f3ef6 as nil")
	}
	if p.Geo == nil {
		return fmt.Errorf("unable to encode pageBlockMap#a44f3ef6: field geo is nil")
	}
	if err := p.Geo.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockMap#a44f3ef6: field geo: %w", err)
	}
	b.PutInt(p.Zoom)
	b.PutInt(p.W)
	b.PutInt(p.H)
	if err := p.Caption.Encode(b); err != nil {
		return fmt.Errorf("unable to encode pageBlockMap#a44f3ef6: field caption: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PageBlockMap) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockMap#a44f3ef6 to nil")
	}
	if err := b.ConsumeID(PageBlockMapTypeID); err != nil {
		return fmt.Errorf("unable to decode pageBlockMap#a44f3ef6: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PageBlockMap) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode pageBlockMap#a44f3ef6 to nil")
	}
	{
		value, err := DecodeGeoPoint(b)
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockMap#a44f3ef6: field geo: %w", err)
		}
		p.Geo = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockMap#a44f3ef6: field zoom: %w", err)
		}
		p.Zoom = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockMap#a44f3ef6: field w: %w", err)
		}
		p.W = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode pageBlockMap#a44f3ef6: field h: %w", err)
		}
		p.H = value
	}
	{
		if err := p.Caption.Decode(b); err != nil {
			return fmt.Errorf("unable to decode pageBlockMap#a44f3ef6: field caption: %w", err)
		}
	}
	return nil
}

// GetGeo returns value of Geo field.
func (p *PageBlockMap) GetGeo() (value GeoPointClass) {
	if p == nil {
		return
	}
	return p.Geo
}

// GetZoom returns value of Zoom field.
func (p *PageBlockMap) GetZoom() (value int) {
	if p == nil {
		return
	}
	return p.Zoom
}

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

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

// GetCaption returns value of Caption field.
func (p *PageBlockMap) GetCaption() (value PageCaption) {
	if p == nil {
		return
	}
	return p.Caption
}

// PageBlockClassName is schema name of PageBlockClass.
const PageBlockClassName = "PageBlock"

// PageBlockClass represents PageBlock generic type.
//
// See https://core.telegram.org/type/PageBlock for reference.
//
// Example:
//
//	g, err := tg.DecodePageBlock(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PageBlockUnsupported: // pageBlockUnsupported#13567e8a
//	case *tg.PageBlockTitle: // pageBlockTitle#70abc3fd
//	case *tg.PageBlockSubtitle: // pageBlockSubtitle#8ffa9a1f
//	case *tg.PageBlockAuthorDate: // pageBlockAuthorDate#baafe5e0
//	case *tg.PageBlockHeader: // pageBlockHeader#bfd064ec
//	case *tg.PageBlockSubheader: // pageBlockSubheader#f12bb6e1
//	case *tg.PageBlockParagraph: // pageBlockParagraph#467a0766
//	case *tg.PageBlockPreformatted: // pageBlockPreformatted#c070d93e
//	case *tg.PageBlockFooter: // pageBlockFooter#48870999
//	case *tg.PageBlockDivider: // pageBlockDivider#db20b188
//	case *tg.PageBlockAnchor: // pageBlockAnchor#ce0d37b0
//	case *tg.PageBlockList: // pageBlockList#e4e88011
//	case *tg.PageBlockBlockquote: // pageBlockBlockquote#263d7c26
//	case *tg.PageBlockPullquote: // pageBlockPullquote#4f4456d3
//	case *tg.PageBlockPhoto: // pageBlockPhoto#1759c560
//	case *tg.PageBlockVideo: // pageBlockVideo#7c8fe7b6
//	case *tg.PageBlockCover: // pageBlockCover#39f23300
//	case *tg.PageBlockEmbed: // pageBlockEmbed#a8718dc5
//	case *tg.PageBlockEmbedPost: // pageBlockEmbedPost#f259a80b
//	case *tg.PageBlockCollage: // pageBlockCollage#65a0fa4d
//	case *tg.PageBlockSlideshow: // pageBlockSlideshow#31f9590
//	case *tg.PageBlockChannel: // pageBlockChannel#ef1751b5
//	case *tg.PageBlockAudio: // pageBlockAudio#804361ea
//	case *tg.PageBlockKicker: // pageBlockKicker#1e148390
//	case *tg.PageBlockTable: // pageBlockTable#bf4dea82
//	case *tg.PageBlockOrderedList: // pageBlockOrderedList#9a8ae1e1
//	case *tg.PageBlockDetails: // pageBlockDetails#76768bed
//	case *tg.PageBlockRelatedArticles: // pageBlockRelatedArticles#16115a96
//	case *tg.PageBlockMap: // pageBlockMap#a44f3ef6
//	default: panic(v)
//	}
type PageBlockClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PageBlockClass

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

// DecodePageBlock implements binary de-serialization for PageBlockClass.
func DecodePageBlock(buf *bin.Buffer) (PageBlockClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case PageBlockUnsupportedTypeID:
		// Decoding pageBlockUnsupported#13567e8a.
		v := PageBlockUnsupported{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockTitleTypeID:
		// Decoding pageBlockTitle#70abc3fd.
		v := PageBlockTitle{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockSubtitleTypeID:
		// Decoding pageBlockSubtitle#8ffa9a1f.
		v := PageBlockSubtitle{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockAuthorDateTypeID:
		// Decoding pageBlockAuthorDate#baafe5e0.
		v := PageBlockAuthorDate{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockHeaderTypeID:
		// Decoding pageBlockHeader#bfd064ec.
		v := PageBlockHeader{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockSubheaderTypeID:
		// Decoding pageBlockSubheader#f12bb6e1.
		v := PageBlockSubheader{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockParagraphTypeID:
		// Decoding pageBlockParagraph#467a0766.
		v := PageBlockParagraph{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockPreformattedTypeID:
		// Decoding pageBlockPreformatted#c070d93e.
		v := PageBlockPreformatted{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockFooterTypeID:
		// Decoding pageBlockFooter#48870999.
		v := PageBlockFooter{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockDividerTypeID:
		// Decoding pageBlockDivider#db20b188.
		v := PageBlockDivider{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockAnchorTypeID:
		// Decoding pageBlockAnchor#ce0d37b0.
		v := PageBlockAnchor{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockListTypeID:
		// Decoding pageBlockList#e4e88011.
		v := PageBlockList{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockBlockquoteTypeID:
		// Decoding pageBlockBlockquote#263d7c26.
		v := PageBlockBlockquote{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockPullquoteTypeID:
		// Decoding pageBlockPullquote#4f4456d3.
		v := PageBlockPullquote{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockPhotoTypeID:
		// Decoding pageBlockPhoto#1759c560.
		v := PageBlockPhoto{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockVideoTypeID:
		// Decoding pageBlockVideo#7c8fe7b6.
		v := PageBlockVideo{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockCoverTypeID:
		// Decoding pageBlockCover#39f23300.
		v := PageBlockCover{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockEmbedTypeID:
		// Decoding pageBlockEmbed#a8718dc5.
		v := PageBlockEmbed{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockEmbedPostTypeID:
		// Decoding pageBlockEmbedPost#f259a80b.
		v := PageBlockEmbedPost{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockCollageTypeID:
		// Decoding pageBlockCollage#65a0fa4d.
		v := PageBlockCollage{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockSlideshowTypeID:
		// Decoding pageBlockSlideshow#31f9590.
		v := PageBlockSlideshow{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockChannelTypeID:
		// Decoding pageBlockChannel#ef1751b5.
		v := PageBlockChannel{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockAudioTypeID:
		// Decoding pageBlockAudio#804361ea.
		v := PageBlockAudio{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockKickerTypeID:
		// Decoding pageBlockKicker#1e148390.
		v := PageBlockKicker{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockTableTypeID:
		// Decoding pageBlockTable#bf4dea82.
		v := PageBlockTable{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockOrderedListTypeID:
		// Decoding pageBlockOrderedList#9a8ae1e1.
		v := PageBlockOrderedList{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockDetailsTypeID:
		// Decoding pageBlockDetails#76768bed.
		v := PageBlockDetails{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockRelatedArticlesTypeID:
		// Decoding pageBlockRelatedArticles#16115a96.
		v := PageBlockRelatedArticles{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	case PageBlockMapTypeID:
		// Decoding pageBlockMap#a44f3ef6.
		v := PageBlockMap{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode PageBlockClass: %w", bin.NewUnexpectedID(id))
	}
}

// PageBlock boxes the PageBlockClass providing a helper.
type PageBlockBox struct {
	PageBlock PageBlockClass
}

// Decode implements bin.Decoder for PageBlockBox.
func (b *PageBlockBox) Decode(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("unable to decode PageBlockBox to nil")
	}
	v, err := DecodePageBlock(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.PageBlock = v
	return nil
}

// Encode implements bin.Encode for PageBlockBox.
func (b *PageBlockBox) Encode(buf *bin.Buffer) error {
	if b == nil || b.PageBlock == nil {
		return fmt.Errorf("unable to encode PageBlockClass as nil")
	}
	return b.PageBlock.Encode(buf)
}
