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

// DialogFilter represents TL type `dialogFilter#7438f7e8`.
// Dialog filter AKA folder¹
//
// Links:
//  1. https://core.telegram.org/api/folders
//
// See https://core.telegram.org/constructor/dialogFilter for reference.
type DialogFilter struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to include all contacts in this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	Contacts bool
	// Whether to include all non-contacts in this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	NonContacts bool
	// Whether to include all groups in this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	Groups bool
	// Whether to include all channels in this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	Broadcasts bool
	// Whether to include all bots in this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	Bots bool
	// Whether to exclude muted chats from this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	ExcludeMuted bool
	// Whether to exclude read chats from this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	ExcludeRead bool
	// Whether to exclude archived chats from this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	ExcludeArchived bool
	// Folder¹ ID
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	ID int
	// Folder¹ name
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	Title string
	// Emoji to use as icon for the folder.
	//
	// Use SetEmoticon and GetEmoticon helpers.
	Emoticon string
	// Pinned chats, folders¹ can have unlimited pinned chats
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	PinnedPeers []InputPeerClass
	// Include the following chats in this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	IncludePeers []InputPeerClass
	// Exclude the following chats from this folder¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	ExcludePeers []InputPeerClass
}

// DialogFilterTypeID is TL type id of DialogFilter.
const DialogFilterTypeID = 0x7438f7e8

// construct implements constructor of DialogFilterClass.
func ( DialogFilter) () DialogFilterClass { return & }

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

	_ DialogFilterClass = &DialogFilter{}
)

func ( *DialogFilter) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Contacts == false) {
		return false
	}
	if !(.NonContacts == false) {
		return false
	}
	if !(.Groups == false) {
		return false
	}
	if !(.Broadcasts == false) {
		return false
	}
	if !(.Bots == false) {
		return false
	}
	if !(.ExcludeMuted == false) {
		return false
	}
	if !(.ExcludeRead == false) {
		return false
	}
	if !(.ExcludeArchived == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Emoticon == "") {
		return false
	}
	if !(.PinnedPeers == nil) {
		return false
	}
	if !(.IncludePeers == nil) {
		return false
	}
	if !(.ExcludePeers == nil) {
		return false
	}

	return true
}

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

// FillFrom fills DialogFilter from given interface.
func ( *DialogFilter) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int)
	() ( string)
	() ( string,  bool)
	() ( []InputPeerClass)
	() ( []InputPeerClass)
	() ( []InputPeerClass)
}) {
	.Contacts = .()
	.NonContacts = .()
	.Groups = .()
	.Broadcasts = .()
	.Bots = .()
	.ExcludeMuted = .()
	.ExcludeRead = .()
	.ExcludeArchived = .()
	.ID = .()
	.Title = .()
	if ,  := .();  {
		.Emoticon = 
	}

	.PinnedPeers = .()
	.IncludePeers = .()
	.ExcludePeers = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *DialogFilter) () tdp.Type {
	 := tdp.Type{
		Name: "dialogFilter",
		ID:   DialogFilterTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Contacts",
			SchemaName: "contacts",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "NonContacts",
			SchemaName: "non_contacts",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Groups",
			SchemaName: "groups",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Broadcasts",
			SchemaName: "broadcasts",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Bots",
			SchemaName: "bots",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "ExcludeMuted",
			SchemaName: "exclude_muted",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "ExcludeRead",
			SchemaName: "exclude_read",
			Null:       !.Flags.Has(12),
		},
		{
			Name:       "ExcludeArchived",
			SchemaName: "exclude_archived",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Emoticon",
			SchemaName: "emoticon",
			Null:       !.Flags.Has(25),
		},
		{
			Name:       "PinnedPeers",
			SchemaName: "pinned_peers",
		},
		{
			Name:       "IncludePeers",
			SchemaName: "include_peers",
		},
		{
			Name:       "ExcludePeers",
			SchemaName: "exclude_peers",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *DialogFilter) () {
	if !(.Contacts == false) {
		.Flags.Set(0)
	}
	if !(.NonContacts == false) {
		.Flags.Set(1)
	}
	if !(.Groups == false) {
		.Flags.Set(2)
	}
	if !(.Broadcasts == false) {
		.Flags.Set(3)
	}
	if !(.Bots == false) {
		.Flags.Set(4)
	}
	if !(.ExcludeMuted == false) {
		.Flags.Set(11)
	}
	if !(.ExcludeRead == false) {
		.Flags.Set(12)
	}
	if !(.ExcludeArchived == false) {
		.Flags.Set(13)
	}
	if !(.Emoticon == "") {
		.Flags.Set(25)
	}
}

// Encode implements bin.Encoder.
func ( *DialogFilter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialogFilter#7438f7e8 as nil")
	}
	.PutID(DialogFilterTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DialogFilter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialogFilter#7438f7e8 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode dialogFilter#7438f7e8: field flags: %w", )
	}
	.PutInt(.ID)
	.PutString(.Title)
	if .Flags.Has(25) {
		.PutString(.Emoticon)
	}
	.PutVectorHeader(len(.PinnedPeers))
	for ,  := range .PinnedPeers {
		if  == nil {
			return fmt.Errorf("unable to encode dialogFilter#7438f7e8: field pinned_peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode dialogFilter#7438f7e8: field pinned_peers element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.IncludePeers))
	for ,  := range .IncludePeers {
		if  == nil {
			return fmt.Errorf("unable to encode dialogFilter#7438f7e8: field include_peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode dialogFilter#7438f7e8: field include_peers element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.ExcludePeers))
	for ,  := range .ExcludePeers {
		if  == nil {
			return fmt.Errorf("unable to encode dialogFilter#7438f7e8: field exclude_peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode dialogFilter#7438f7e8: field exclude_peers element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DialogFilter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode dialogFilter#7438f7e8 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field flags: %w", )
		}
	}
	.Contacts = .Flags.Has(0)
	.NonContacts = .Flags.Has(1)
	.Groups = .Flags.Has(2)
	.Broadcasts = .Flags.Has(3)
	.Bots = .Flags.Has(4)
	.ExcludeMuted = .Flags.Has(11)
	.ExcludeRead = .Flags.Has(12)
	.ExcludeArchived = .Flags.Has(13)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(25) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field emoticon: %w", )
		}
		.Emoticon = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field pinned_peers: %w", )
		}

		if  > 0 {
			.PinnedPeers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field pinned_peers: %w", )
			}
			.PinnedPeers = append(.PinnedPeers, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field include_peers: %w", )
		}

		if  > 0 {
			.IncludePeers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field include_peers: %w", )
			}
			.IncludePeers = append(.IncludePeers, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field exclude_peers: %w", )
		}

		if  > 0 {
			.ExcludePeers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode dialogFilter#7438f7e8: field exclude_peers: %w", )
			}
			.ExcludePeers = append(.ExcludePeers, )
		}
	}
	return nil
}

// SetContacts sets value of Contacts conditional field.
func ( *DialogFilter) ( bool) {
	if  {
		.Flags.Set(0)
		.Contacts = true
	} else {
		.Flags.Unset(0)
		.Contacts = false
	}
}

// GetContacts returns value of Contacts conditional field.
func ( *DialogFilter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetNonContacts sets value of NonContacts conditional field.
func ( *DialogFilter) ( bool) {
	if  {
		.Flags.Set(1)
		.NonContacts = true
	} else {
		.Flags.Unset(1)
		.NonContacts = false
	}
}

// GetNonContacts returns value of NonContacts conditional field.
func ( *DialogFilter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetGroups sets value of Groups conditional field.
func ( *DialogFilter) ( bool) {
	if  {
		.Flags.Set(2)
		.Groups = true
	} else {
		.Flags.Unset(2)
		.Groups = false
	}
}

// GetGroups returns value of Groups conditional field.
func ( *DialogFilter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetBroadcasts sets value of Broadcasts conditional field.
func ( *DialogFilter) ( bool) {
	if  {
		.Flags.Set(3)
		.Broadcasts = true
	} else {
		.Flags.Unset(3)
		.Broadcasts = false
	}
}

// GetBroadcasts returns value of Broadcasts conditional field.
func ( *DialogFilter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetBots sets value of Bots conditional field.
func ( *DialogFilter) ( bool) {
	if  {
		.Flags.Set(4)
		.Bots = true
	} else {
		.Flags.Unset(4)
		.Bots = false
	}
}

// GetBots returns value of Bots conditional field.
func ( *DialogFilter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetExcludeMuted sets value of ExcludeMuted conditional field.
func ( *DialogFilter) ( bool) {
	if  {
		.Flags.Set(11)
		.ExcludeMuted = true
	} else {
		.Flags.Unset(11)
		.ExcludeMuted = false
	}
}

// GetExcludeMuted returns value of ExcludeMuted conditional field.
func ( *DialogFilter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(11)
}

// SetExcludeRead sets value of ExcludeRead conditional field.
func ( *DialogFilter) ( bool) {
	if  {
		.Flags.Set(12)
		.ExcludeRead = true
	} else {
		.Flags.Unset(12)
		.ExcludeRead = false
	}
}

// GetExcludeRead returns value of ExcludeRead conditional field.
func ( *DialogFilter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(12)
}

// SetExcludeArchived sets value of ExcludeArchived conditional field.
func ( *DialogFilter) ( bool) {
	if  {
		.Flags.Set(13)
		.ExcludeArchived = true
	} else {
		.Flags.Unset(13)
		.ExcludeArchived = false
	}
}

// GetExcludeArchived returns value of ExcludeArchived conditional field.
func ( *DialogFilter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(13)
}

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

// GetTitle returns value of Title field.
func ( *DialogFilter) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// SetEmoticon sets value of Emoticon conditional field.
func ( *DialogFilter) ( string) {
	.Flags.Set(25)
	.Emoticon = 
}

// GetEmoticon returns value of Emoticon conditional field and
// boolean which is true if field was set.
func ( *DialogFilter) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(25) {
		return , false
	}
	return .Emoticon, true
}

// GetPinnedPeers returns value of PinnedPeers field.
func ( *DialogFilter) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .PinnedPeers
}

// GetIncludePeers returns value of IncludePeers field.
func ( *DialogFilter) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .IncludePeers
}

// GetExcludePeers returns value of ExcludePeers field.
func ( *DialogFilter) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .ExcludePeers
}

// MapPinnedPeers returns field PinnedPeers wrapped in InputPeerClassArray helper.
func ( *DialogFilter) () ( InputPeerClassArray) {
	return InputPeerClassArray(.PinnedPeers)
}

// MapIncludePeers returns field IncludePeers wrapped in InputPeerClassArray helper.
func ( *DialogFilter) () ( InputPeerClassArray) {
	return InputPeerClassArray(.IncludePeers)
}

// MapExcludePeers returns field ExcludePeers wrapped in InputPeerClassArray helper.
func ( *DialogFilter) () ( InputPeerClassArray) {
	return InputPeerClassArray(.ExcludePeers)
}

// DialogFilterDefault represents TL type `dialogFilterDefault#363293ae`.
// Used only when reordering folders to indicate the default (all chats) folder.
//
// See https://core.telegram.org/constructor/dialogFilterDefault for reference.
type DialogFilterDefault struct {
}

// DialogFilterDefaultTypeID is TL type id of DialogFilterDefault.
const DialogFilterDefaultTypeID = 0x363293ae

// construct implements constructor of DialogFilterClass.
func ( DialogFilterDefault) () DialogFilterClass { return & }

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

	_ DialogFilterClass = &DialogFilterDefault{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *DialogFilterDefault) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialogFilterDefault#363293ae as nil")
	}
	.PutID(DialogFilterDefaultTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DialogFilterDefault) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialogFilterDefault#363293ae as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DialogFilterDefault) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode dialogFilterDefault#363293ae to nil")
	}
	return nil
}

// DialogFilterChatlist represents TL type `dialogFilterChatlist#d64a04a8`.
// A folder imported using a chat folder deep link »¹.
//
// Links:
//  1. https://core.telegram.org/api/links#chat-folder-links
//
// See https://core.telegram.org/constructor/dialogFilterChatlist for reference.
type DialogFilterChatlist struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the current user has created some chat folder deep links »¹ to share the
	// folder as well.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#chat-folder-links
	HasMyInvites bool
	// ID of the folder
	ID int
	// Name of the folder
	Title string
	// Emoji to use as icon for the folder.
	//
	// Use SetEmoticon and GetEmoticon helpers.
	Emoticon string
	// Pinned chats, folders¹ can have unlimited pinned chats
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	PinnedPeers []InputPeerClass
	// Chats to include in the folder
	IncludePeers []InputPeerClass
}

// DialogFilterChatlistTypeID is TL type id of DialogFilterChatlist.
const DialogFilterChatlistTypeID = 0xd64a04a8

// construct implements constructor of DialogFilterClass.
func ( DialogFilterChatlist) () DialogFilterClass { return & }

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

	_ DialogFilterClass = &DialogFilterChatlist{}
)

func ( *DialogFilterChatlist) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.HasMyInvites == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Emoticon == "") {
		return false
	}
	if !(.PinnedPeers == nil) {
		return false
	}
	if !(.IncludePeers == nil) {
		return false
	}

	return true
}

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

// FillFrom fills DialogFilterChatlist from given interface.
func ( *DialogFilterChatlist) ( interface {
	() ( bool)
	() ( int)
	() ( string)
	() ( string,  bool)
	() ( []InputPeerClass)
	() ( []InputPeerClass)
}) {
	.HasMyInvites = .()
	.ID = .()
	.Title = .()
	if ,  := .();  {
		.Emoticon = 
	}

	.PinnedPeers = .()
	.IncludePeers = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *DialogFilterChatlist) () tdp.Type {
	 := tdp.Type{
		Name: "dialogFilterChatlist",
		ID:   DialogFilterChatlistTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "HasMyInvites",
			SchemaName: "has_my_invites",
			Null:       !.Flags.Has(26),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Emoticon",
			SchemaName: "emoticon",
			Null:       !.Flags.Has(25),
		},
		{
			Name:       "PinnedPeers",
			SchemaName: "pinned_peers",
		},
		{
			Name:       "IncludePeers",
			SchemaName: "include_peers",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *DialogFilterChatlist) () {
	if !(.HasMyInvites == false) {
		.Flags.Set(26)
	}
	if !(.Emoticon == "") {
		.Flags.Set(25)
	}
}

// Encode implements bin.Encoder.
func ( *DialogFilterChatlist) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialogFilterChatlist#d64a04a8 as nil")
	}
	.PutID(DialogFilterChatlistTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DialogFilterChatlist) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialogFilterChatlist#d64a04a8 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode dialogFilterChatlist#d64a04a8: field flags: %w", )
	}
	.PutInt(.ID)
	.PutString(.Title)
	if .Flags.Has(25) {
		.PutString(.Emoticon)
	}
	.PutVectorHeader(len(.PinnedPeers))
	for ,  := range .PinnedPeers {
		if  == nil {
			return fmt.Errorf("unable to encode dialogFilterChatlist#d64a04a8: field pinned_peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode dialogFilterChatlist#d64a04a8: field pinned_peers element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.IncludePeers))
	for ,  := range .IncludePeers {
		if  == nil {
			return fmt.Errorf("unable to encode dialogFilterChatlist#d64a04a8: field include_peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode dialogFilterChatlist#d64a04a8: field include_peers element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DialogFilterChatlist) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode dialogFilterChatlist#d64a04a8 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode dialogFilterChatlist#d64a04a8: field flags: %w", )
		}
	}
	.HasMyInvites = .Flags.Has(26)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilterChatlist#d64a04a8: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilterChatlist#d64a04a8: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(25) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilterChatlist#d64a04a8: field emoticon: %w", )
		}
		.Emoticon = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilterChatlist#d64a04a8: field pinned_peers: %w", )
		}

		if  > 0 {
			.PinnedPeers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode dialogFilterChatlist#d64a04a8: field pinned_peers: %w", )
			}
			.PinnedPeers = append(.PinnedPeers, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFilterChatlist#d64a04a8: field include_peers: %w", )
		}

		if  > 0 {
			.IncludePeers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode dialogFilterChatlist#d64a04a8: field include_peers: %w", )
			}
			.IncludePeers = append(.IncludePeers, )
		}
	}
	return nil
}

// SetHasMyInvites sets value of HasMyInvites conditional field.
func ( *DialogFilterChatlist) ( bool) {
	if  {
		.Flags.Set(26)
		.HasMyInvites = true
	} else {
		.Flags.Unset(26)
		.HasMyInvites = false
	}
}

// GetHasMyInvites returns value of HasMyInvites conditional field.
func ( *DialogFilterChatlist) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(26)
}

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

// GetTitle returns value of Title field.
func ( *DialogFilterChatlist) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// SetEmoticon sets value of Emoticon conditional field.
func ( *DialogFilterChatlist) ( string) {
	.Flags.Set(25)
	.Emoticon = 
}

// GetEmoticon returns value of Emoticon conditional field and
// boolean which is true if field was set.
func ( *DialogFilterChatlist) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(25) {
		return , false
	}
	return .Emoticon, true
}

// GetPinnedPeers returns value of PinnedPeers field.
func ( *DialogFilterChatlist) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .PinnedPeers
}

// GetIncludePeers returns value of IncludePeers field.
func ( *DialogFilterChatlist) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .IncludePeers
}

// MapPinnedPeers returns field PinnedPeers wrapped in InputPeerClassArray helper.
func ( *DialogFilterChatlist) () ( InputPeerClassArray) {
	return InputPeerClassArray(.PinnedPeers)
}

// MapIncludePeers returns field IncludePeers wrapped in InputPeerClassArray helper.
func ( *DialogFilterChatlist) () ( InputPeerClassArray) {
	return InputPeerClassArray(.IncludePeers)
}

// DialogFilterClassName is schema name of DialogFilterClass.
const DialogFilterClassName = "DialogFilter"

// DialogFilterClass represents DialogFilter generic type.
//
// See https://core.telegram.org/type/DialogFilter for reference.
//
// Example:
//
//	g, err := tg.DecodeDialogFilter(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.DialogFilter: // dialogFilter#7438f7e8
//	case *tg.DialogFilterDefault: // dialogFilterDefault#363293ae
//	case *tg.DialogFilterChatlist: // dialogFilterChatlist#d64a04a8
//	default: panic(v)
//	}
type DialogFilterClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() DialogFilterClass

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

// AsInputChatlist tries to map DialogFilter to InputChatlistDialogFilter.
func ( *DialogFilter) () *InputChatlistDialogFilter {
	 := new(InputChatlistDialogFilter)
	.FilterID = .GetID()

	return 
}

// DecodeDialogFilter implements binary de-serialization for DialogFilterClass.
func ( *bin.Buffer) (DialogFilterClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case DialogFilterTypeID:
		// Decoding dialogFilter#7438f7e8.
		 := DialogFilter{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DialogFilterClass: %w", )
		}
		return &, nil
	case DialogFilterDefaultTypeID:
		// Decoding dialogFilterDefault#363293ae.
		 := DialogFilterDefault{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DialogFilterClass: %w", )
		}
		return &, nil
	case DialogFilterChatlistTypeID:
		// Decoding dialogFilterChatlist#d64a04a8.
		 := DialogFilterChatlist{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DialogFilterClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode DialogFilterClass: %w", bin.NewUnexpectedID())
	}
}

// DialogFilter boxes the DialogFilterClass providing a helper.
type DialogFilterBox struct {
	DialogFilter DialogFilterClass
}

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

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