// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// WebPageEmpty represents TL type `webPageEmpty#211a1788`.
// No preview is available for the webpage
//
// See https://core.telegram.org/constructor/webPageEmpty for reference.
type WebPageEmpty struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Preview ID
	ID int64
	// URL of the webpage.
	//
	// Use SetURL and GetURL helpers.
	URL string
}

// WebPageEmptyTypeID is TL type id of WebPageEmpty.
const WebPageEmptyTypeID = 0x211a1788

// construct implements constructor of WebPageClass.
func ( WebPageEmpty) () WebPageClass { return & }

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

	_ WebPageClass = &WebPageEmpty{}
)

func ( *WebPageEmpty) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.URL == "") {
		return false
	}

	return true
}

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

// FillFrom fills WebPageEmpty from given interface.
func ( *WebPageEmpty) ( interface {
	() ( int64)
	() ( string,  bool)
}) {
	.ID = .()
	if ,  := .();  {
		.URL = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *WebPageEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "webPageEmpty",
		ID:   WebPageEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "URL",
			SchemaName: "url",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *WebPageEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webPageEmpty#211a1788 as nil")
	}
	.PutID(WebPageEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WebPageEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webPageEmpty#211a1788 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode webPageEmpty#211a1788: field flags: %w", )
	}
	.PutLong(.ID)
	if .Flags.Has(0) {
		.PutString(.URL)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WebPageEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode webPageEmpty#211a1788 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode webPageEmpty#211a1788: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode webPageEmpty#211a1788: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPageEmpty#211a1788: field url: %w", )
		}
		.URL = 
	}
	return nil
}

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

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

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

// WebPagePending represents TL type `webPagePending#b0d13e47`.
// A preview of the webpage is currently being generated
//
// See https://core.telegram.org/constructor/webPagePending for reference.
type WebPagePending struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// ID of preview
	ID int64
	// URL of the webpage
	//
	// Use SetURL and GetURL helpers.
	URL string
	// When was the processing started
	Date int
}

// WebPagePendingTypeID is TL type id of WebPagePending.
const WebPagePendingTypeID = 0xb0d13e47

// construct implements constructor of WebPageClass.
func ( WebPagePending) () WebPageClass { return & }

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

	_ WebPageClass = &WebPagePending{}
)

func ( *WebPagePending) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.URL == "") {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills WebPagePending from given interface.
func ( *WebPagePending) ( interface {
	() ( int64)
	() ( string,  bool)
	() ( int)
}) {
	.ID = .()
	if ,  := .();  {
		.URL = 
	}

	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *WebPagePending) () tdp.Type {
	 := tdp.Type{
		Name: "webPagePending",
		ID:   WebPagePendingTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "URL",
			SchemaName: "url",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *WebPagePending) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webPagePending#b0d13e47 as nil")
	}
	.PutID(WebPagePendingTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WebPagePending) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webPagePending#b0d13e47 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode webPagePending#b0d13e47: field flags: %w", )
	}
	.PutLong(.ID)
	if .Flags.Has(0) {
		.PutString(.URL)
	}
	.PutInt(.Date)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WebPagePending) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode webPagePending#b0d13e47 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode webPagePending#b0d13e47: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode webPagePending#b0d13e47: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPagePending#b0d13e47: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode webPagePending#b0d13e47: field date: %w", )
		}
		.Date = 
	}
	return nil
}

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

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

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

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

// WebPage represents TL type `webPage#e89c45b2`.
// Webpage preview
//
// See https://core.telegram.org/constructor/webPage for reference.
type WebPage struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the size of the media in the preview can be changed.
	HasLargeMedia bool
	// Preview ID
	ID int64
	// URL of previewed webpage
	URL string
	// Webpage URL to be displayed to the user
	DisplayURL string
	// Hash for pagination, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int
	// Type of the web page. Can be: article, photo, audio, video, document, profile, app, or
	// something else
	//
	// Use SetType and GetType helpers.
	Type string
	// Short name of the site (e.g., Google Docs, App Store)
	//
	// Use SetSiteName and GetSiteName helpers.
	SiteName string
	// Title of the content
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// Content description
	//
	// Use SetDescription and GetDescription helpers.
	Description string
	// Image representing the content
	//
	// Use SetPhoto and GetPhoto helpers.
	Photo PhotoClass
	// URL to show in the embedded preview
	//
	// Use SetEmbedURL and GetEmbedURL helpers.
	EmbedURL string
	// MIME type of the embedded preview, (e.g., text/html or video/mp4)
	//
	// Use SetEmbedType and GetEmbedType helpers.
	EmbedType string
	// Width of the embedded preview
	//
	// Use SetEmbedWidth and GetEmbedWidth helpers.
	EmbedWidth int
	// Height of the embedded preview
	//
	// Use SetEmbedHeight and GetEmbedHeight helpers.
	EmbedHeight int
	// Duration of the content, in seconds
	//
	// Use SetDuration and GetDuration helpers.
	Duration int
	// Author of the content
	//
	// Use SetAuthor and GetAuthor helpers.
	Author string
	// Preview of the content as a media file
	//
	// Use SetDocument and GetDocument helpers.
	Document DocumentClass
	// Page contents in instant viewĀ¹ format
	//
	// Links:
	//  1) https://instantview.telegram.org
	//
	// Use SetCachedPage and GetCachedPage helpers.
	CachedPage Page
	// Webpage attributes
	//
	// Use SetAttributes and GetAttributes helpers.
	Attributes []WebPageAttributeClass
}

// WebPageTypeID is TL type id of WebPage.
const WebPageTypeID = 0xe89c45b2

// construct implements constructor of WebPageClass.
func ( WebPage) () WebPageClass { return & }

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

	_ WebPageClass = &WebPage{}
)

func ( *WebPage) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.HasLargeMedia == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.URL == "") {
		return false
	}
	if !(.DisplayURL == "") {
		return false
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Type == "") {
		return false
	}
	if !(.SiteName == "") {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}
	if !(.EmbedURL == "") {
		return false
	}
	if !(.EmbedType == "") {
		return false
	}
	if !(.EmbedWidth == 0) {
		return false
	}
	if !(.EmbedHeight == 0) {
		return false
	}
	if !(.Duration == 0) {
		return false
	}
	if !(.Author == "") {
		return false
	}
	if !(.Document == nil) {
		return false
	}
	if !(.CachedPage.Zero()) {
		return false
	}
	if !(.Attributes == nil) {
		return false
	}

	return true
}

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

// FillFrom fills WebPage from given interface.
func ( *WebPage) ( interface {
	() ( bool)
	() ( int64)
	() ( string)
	() ( string)
	() ( int)
	() ( string,  bool)
	() ( string,  bool)
	() ( string,  bool)
	() ( string,  bool)
	() ( PhotoClass,  bool)
	() ( string,  bool)
	() ( string,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( string,  bool)
	() ( DocumentClass,  bool)
	() ( Page,  bool)
	() ( []WebPageAttributeClass,  bool)
}) {
	.HasLargeMedia = .()
	.ID = .()
	.URL = .()
	.DisplayURL = .()
	.Hash = .()
	if ,  := .();  {
		.Type = 
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *WebPage) () tdp.Type {
	 := tdp.Type{
		Name: "webPage",
		ID:   WebPageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "HasLargeMedia",
			SchemaName: "has_large_media",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "DisplayURL",
			SchemaName: "display_url",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Type",
			SchemaName: "type",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "SiteName",
			SchemaName: "site_name",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Description",
			SchemaName: "description",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "EmbedURL",
			SchemaName: "embed_url",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "EmbedType",
			SchemaName: "embed_type",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "EmbedWidth",
			SchemaName: "embed_width",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "EmbedHeight",
			SchemaName: "embed_height",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "Author",
			SchemaName: "author",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "Document",
			SchemaName: "document",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "CachedPage",
			SchemaName: "cached_page",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Attributes",
			SchemaName: "attributes",
			Null:       !.Flags.Has(12),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *WebPage) () {
	if !(.HasLargeMedia == false) {
		.Flags.Set(13)
	}
	if !(.Type == "") {
		.Flags.Set(0)
	}
	if !(.SiteName == "") {
		.Flags.Set(1)
	}
	if !(.Title == "") {
		.Flags.Set(2)
	}
	if !(.Description == "") {
		.Flags.Set(3)
	}
	if !(.Photo == nil) {
		.Flags.Set(4)
	}
	if !(.EmbedURL == "") {
		.Flags.Set(5)
	}
	if !(.EmbedType == "") {
		.Flags.Set(5)
	}
	if !(.EmbedWidth == 0) {
		.Flags.Set(6)
	}
	if !(.EmbedHeight == 0) {
		.Flags.Set(6)
	}
	if !(.Duration == 0) {
		.Flags.Set(7)
	}
	if !(.Author == "") {
		.Flags.Set(8)
	}
	if !(.Document == nil) {
		.Flags.Set(9)
	}
	if !(.CachedPage.Zero()) {
		.Flags.Set(10)
	}
	if !(.Attributes == nil) {
		.Flags.Set(12)
	}
}

// Encode implements bin.Encoder.
func ( *WebPage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webPage#e89c45b2 as nil")
	}
	.PutID(WebPageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WebPage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webPage#e89c45b2 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode webPage#e89c45b2: field flags: %w", )
	}
	.PutLong(.ID)
	.PutString(.URL)
	.PutString(.DisplayURL)
	.PutInt(.Hash)
	if .Flags.Has(0) {
		.PutString(.Type)
	}
	if .Flags.Has(1) {
		.PutString(.SiteName)
	}
	if .Flags.Has(2) {
		.PutString(.Title)
	}
	if .Flags.Has(3) {
		.PutString(.Description)
	}
	if .Flags.Has(4) {
		if .Photo == nil {
			return fmt.Errorf("unable to encode webPage#e89c45b2: field photo is nil")
		}
		if  := .Photo.Encode();  != nil {
			return fmt.Errorf("unable to encode webPage#e89c45b2: field photo: %w", )
		}
	}
	if .Flags.Has(5) {
		.PutString(.EmbedURL)
	}
	if .Flags.Has(5) {
		.PutString(.EmbedType)
	}
	if .Flags.Has(6) {
		.PutInt(.EmbedWidth)
	}
	if .Flags.Has(6) {
		.PutInt(.EmbedHeight)
	}
	if .Flags.Has(7) {
		.PutInt(.Duration)
	}
	if .Flags.Has(8) {
		.PutString(.Author)
	}
	if .Flags.Has(9) {
		if .Document == nil {
			return fmt.Errorf("unable to encode webPage#e89c45b2: field document is nil")
		}
		if  := .Document.Encode();  != nil {
			return fmt.Errorf("unable to encode webPage#e89c45b2: field document: %w", )
		}
	}
	if .Flags.Has(10) {
		if  := .CachedPage.Encode();  != nil {
			return fmt.Errorf("unable to encode webPage#e89c45b2: field cached_page: %w", )
		}
	}
	if .Flags.Has(12) {
		.PutVectorHeader(len(.Attributes))
		for ,  := range .Attributes {
			if  == nil {
				return fmt.Errorf("unable to encode webPage#e89c45b2: field attributes element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode webPage#e89c45b2: field attributes element with index %d: %w", , )
			}
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WebPage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode webPage#e89c45b2 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field flags: %w", )
		}
	}
	.HasLargeMedia = .Flags.Has(13)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field display_url: %w", )
		}
		.DisplayURL = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field hash: %w", )
		}
		.Hash = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field type: %w", )
		}
		.Type = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field site_name: %w", )
		}
		.SiteName = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(3) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field description: %w", )
		}
		.Description = 
	}
	if .Flags.Has(4) {
		,  := DecodePhoto()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field photo: %w", )
		}
		.Photo = 
	}
	if .Flags.Has(5) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field embed_url: %w", )
		}
		.EmbedURL = 
	}
	if .Flags.Has(5) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field embed_type: %w", )
		}
		.EmbedType = 
	}
	if .Flags.Has(6) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field embed_width: %w", )
		}
		.EmbedWidth = 
	}
	if .Flags.Has(6) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field embed_height: %w", )
		}
		.EmbedHeight = 
	}
	if .Flags.Has(7) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field duration: %w", )
		}
		.Duration = 
	}
	if .Flags.Has(8) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field author: %w", )
		}
		.Author = 
	}
	if .Flags.Has(9) {
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field document: %w", )
		}
		.Document = 
	}
	if .Flags.Has(10) {
		if  := .CachedPage.Decode();  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field cached_page: %w", )
		}
	}
	if .Flags.Has(12) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode webPage#e89c45b2: field attributes: %w", )
		}

		if  > 0 {
			.Attributes = make([]WebPageAttributeClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeWebPageAttribute()
			if  != nil {
				return fmt.Errorf("unable to decode webPage#e89c45b2: field attributes: %w", )
			}
			.Attributes = append(.Attributes, )
		}
	}
	return nil
}

// SetHasLargeMedia sets value of HasLargeMedia conditional field.
func ( *WebPage) ( bool) {
	if  {
		.Flags.Set(13)
		.HasLargeMedia = true
	} else {
		.Flags.Unset(13)
		.HasLargeMedia = false
	}
}

// GetHasLargeMedia returns value of HasLargeMedia conditional field.
func ( *WebPage) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(13)
}

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

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

// GetDisplayURL returns value of DisplayURL field.
func ( *WebPage) () ( string) {
	if  == nil {
		return
	}
	return .DisplayURL
}

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

// SetType sets value of Type conditional field.
func ( *WebPage) ( string) {
	.Flags.Set(0)
	.Type = 
}

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

// SetSiteName sets value of SiteName conditional field.
func ( *WebPage) ( string) {
	.Flags.Set(1)
	.SiteName = 
}

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

// SetTitle sets value of Title conditional field.
func ( *WebPage) ( string) {
	.Flags.Set(2)
	.Title = 
}

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

// SetDescription sets value of Description conditional field.
func ( *WebPage) ( string) {
	.Flags.Set(3)
	.Description = 
}

// GetDescription returns value of Description conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .Description, true
}

// SetPhoto sets value of Photo conditional field.
func ( *WebPage) ( PhotoClass) {
	.Flags.Set(4)
	.Photo = 
}

// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( PhotoClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .Photo, true
}

// SetEmbedURL sets value of EmbedURL conditional field.
func ( *WebPage) ( string) {
	.Flags.Set(5)
	.EmbedURL = 
}

// GetEmbedURL returns value of EmbedURL conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .EmbedURL, true
}

// SetEmbedType sets value of EmbedType conditional field.
func ( *WebPage) ( string) {
	.Flags.Set(5)
	.EmbedType = 
}

// GetEmbedType returns value of EmbedType conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .EmbedType, true
}

// SetEmbedWidth sets value of EmbedWidth conditional field.
func ( *WebPage) ( int) {
	.Flags.Set(6)
	.EmbedWidth = 
}

// GetEmbedWidth returns value of EmbedWidth conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .EmbedWidth, true
}

// SetEmbedHeight sets value of EmbedHeight conditional field.
func ( *WebPage) ( int) {
	.Flags.Set(6)
	.EmbedHeight = 
}

// GetEmbedHeight returns value of EmbedHeight conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .EmbedHeight, true
}

// SetDuration sets value of Duration conditional field.
func ( *WebPage) ( int) {
	.Flags.Set(7)
	.Duration = 
}

// GetDuration returns value of Duration conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(7) {
		return , false
	}
	return .Duration, true
}

// SetAuthor sets value of Author conditional field.
func ( *WebPage) ( string) {
	.Flags.Set(8)
	.Author = 
}

// GetAuthor returns value of Author conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .Author, true
}

// SetDocument sets value of Document conditional field.
func ( *WebPage) ( DocumentClass) {
	.Flags.Set(9)
	.Document = 
}

// GetDocument returns value of Document conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( DocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(9) {
		return , false
	}
	return .Document, true
}

// SetCachedPage sets value of CachedPage conditional field.
func ( *WebPage) ( Page) {
	.Flags.Set(10)
	.CachedPage = 
}

// GetCachedPage returns value of CachedPage conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( Page,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(10) {
		return , false
	}
	return .CachedPage, true
}

// SetAttributes sets value of Attributes conditional field.
func ( *WebPage) ( []WebPageAttributeClass) {
	.Flags.Set(12)
	.Attributes = 
}

// GetAttributes returns value of Attributes conditional field and
// boolean which is true if field was set.
func ( *WebPage) () ( []WebPageAttributeClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(12) {
		return , false
	}
	return .Attributes, true
}

// MapAttributes returns field Attributes wrapped in WebPageAttributeClassArray helper.
func ( *WebPage) () ( WebPageAttributeClassArray,  bool) {
	if !.Flags.Has(12) {
		return , false
	}
	return WebPageAttributeClassArray(.Attributes), true
}

// WebPageNotModified represents TL type `webPageNotModified#7311ca11`.
// The preview of the webpage hasn't changed
//
// See https://core.telegram.org/constructor/webPageNotModified for reference.
type WebPageNotModified struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Page view count
	//
	// Use SetCachedPageViews and GetCachedPageViews helpers.
	CachedPageViews int
}

// WebPageNotModifiedTypeID is TL type id of WebPageNotModified.
const WebPageNotModifiedTypeID = 0x7311ca11

// construct implements constructor of WebPageClass.
func ( WebPageNotModified) () WebPageClass { return & }

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

	_ WebPageClass = &WebPageNotModified{}
)

func ( *WebPageNotModified) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.CachedPageViews == 0) {
		return false
	}

	return true
}

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

// FillFrom fills WebPageNotModified from given interface.
func ( *WebPageNotModified) ( interface {
	() ( int,  bool)
}) {
	if ,  := .();  {
		.CachedPageViews = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *WebPageNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "webPageNotModified",
		ID:   WebPageNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "CachedPageViews",
			SchemaName: "cached_page_views",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *WebPageNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webPageNotModified#7311ca11 as nil")
	}
	.PutID(WebPageNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WebPageNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webPageNotModified#7311ca11 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode webPageNotModified#7311ca11: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.CachedPageViews)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WebPageNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode webPageNotModified#7311ca11 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode webPageNotModified#7311ca11: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode webPageNotModified#7311ca11: field cached_page_views: %w", )
		}
		.CachedPageViews = 
	}
	return nil
}

// SetCachedPageViews sets value of CachedPageViews conditional field.
func ( *WebPageNotModified) ( int) {
	.Flags.Set(0)
	.CachedPageViews = 
}

// GetCachedPageViews returns value of CachedPageViews conditional field and
// boolean which is true if field was set.
func ( *WebPageNotModified) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .CachedPageViews, true
}

// WebPageClassName is schema name of WebPageClass.
const WebPageClassName = "WebPage"

// WebPageClass represents WebPage generic type.
//
// See https://core.telegram.org/type/WebPage for reference.
//
// Example:
//
//	g, err := tg.DecodeWebPage(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.WebPageEmpty: // webPageEmpty#211a1788
//	case *tg.WebPagePending: // webPagePending#b0d13e47
//	case *tg.WebPage: // webPage#e89c45b2
//	case *tg.WebPageNotModified: // webPageNotModified#7311ca11
//	default: panic(v)
//	}
type WebPageClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() WebPageClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// AsModified tries to map WebPageClass to ModifiedWebPage.
	AsModified() (ModifiedWebPage, bool)
}

// ModifiedWebPage represents Modified subset of WebPageClass.
type ModifiedWebPage interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() WebPageClass

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

	// Preview ID
	GetID() (value int64)
}

// AsModified tries to map WebPageEmpty to ModifiedWebPage.
func ( *WebPageEmpty) () (ModifiedWebPage, bool) {
	,  := (WebPageClass()).(ModifiedWebPage)
	return , 
}

// AsModified tries to map WebPagePending to ModifiedWebPage.
func ( *WebPagePending) () (ModifiedWebPage, bool) {
	,  := (WebPageClass()).(ModifiedWebPage)
	return , 
}

// AsModified tries to map WebPage to ModifiedWebPage.
func ( *WebPage) () (ModifiedWebPage, bool) {
	,  := (WebPageClass()).(ModifiedWebPage)
	return , 
}

// AsModified tries to map WebPageNotModified to ModifiedWebPage.
func ( *WebPageNotModified) () (ModifiedWebPage, bool) {
	,  := (WebPageClass()).(ModifiedWebPage)
	return , 
}

// DecodeWebPage implements binary de-serialization for WebPageClass.
func ( *bin.Buffer) (WebPageClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case WebPageEmptyTypeID:
		// Decoding webPageEmpty#211a1788.
		 := WebPageEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode WebPageClass: %w", )
		}
		return &, nil
	case WebPagePendingTypeID:
		// Decoding webPagePending#b0d13e47.
		 := WebPagePending{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode WebPageClass: %w", )
		}
		return &, nil
	case WebPageTypeID:
		// Decoding webPage#e89c45b2.
		 := WebPage{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode WebPageClass: %w", )
		}
		return &, nil
	case WebPageNotModifiedTypeID:
		// Decoding webPageNotModified#7311ca11.
		 := WebPageNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode WebPageClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode WebPageClass: %w", bin.NewUnexpectedID())
	}
}

// WebPage boxes the WebPageClass providing a helper.
type WebPageBox struct {
	WebPage WebPageClass
}

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

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