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

// StatsMegagroupStats represents TL type `stats.megagroupStats#ef7ff916`.
// Supergroup statisticsĀ¹
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// See https://core.telegram.org/constructor/stats.megagroupStats for reference.
type StatsMegagroupStats struct {
	// Period in consideration
	Period StatsDateRangeDays
	// Member count change for period in consideration
	Members StatsAbsValueAndPrev
	// Message number change for period in consideration
	Messages StatsAbsValueAndPrev
	// Number of users that viewed messages, for range in consideration
	Viewers StatsAbsValueAndPrev
	// Number of users that posted messages, for range in consideration
	Posters StatsAbsValueAndPrev
	// Supergroup growth graph (absolute subscriber count)
	GrowthGraph StatsGraphClass
	// Members growth (relative subscriber count)
	MembersGraph StatsGraphClass
	// New members by source graph
	NewMembersBySourceGraph StatsGraphClass
	// Subscriber language graph (pie chart)
	LanguagesGraph StatsGraphClass
	// Message activity graph (stacked bar graph, message type)
	MessagesGraph StatsGraphClass
	// Group activity graph (deleted, modified messages, blocked users)
	ActionsGraph StatsGraphClass
	// Activity per hour graph (absolute)
	TopHoursGraph StatsGraphClass
	// Activity per day of week graph (absolute)
	WeekdaysGraph StatsGraphClass
	// Info about most active group members
	TopPosters []StatsGroupTopPoster
	// Info about most active group admins
	TopAdmins []StatsGroupTopAdmin
	// Info about most active group inviters
	TopInviters []StatsGroupTopInviter
	// Info about users mentioned in statistics
	Users []UserClass
}

// StatsMegagroupStatsTypeID is TL type id of StatsMegagroupStats.
const StatsMegagroupStatsTypeID = 0xef7ff916

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

func ( *StatsMegagroupStats) () bool {
	if  == nil {
		return true
	}
	if !(.Period.Zero()) {
		return false
	}
	if !(.Members.Zero()) {
		return false
	}
	if !(.Messages.Zero()) {
		return false
	}
	if !(.Viewers.Zero()) {
		return false
	}
	if !(.Posters.Zero()) {
		return false
	}
	if !(.GrowthGraph == nil) {
		return false
	}
	if !(.MembersGraph == nil) {
		return false
	}
	if !(.NewMembersBySourceGraph == nil) {
		return false
	}
	if !(.LanguagesGraph == nil) {
		return false
	}
	if !(.MessagesGraph == nil) {
		return false
	}
	if !(.ActionsGraph == nil) {
		return false
	}
	if !(.TopHoursGraph == nil) {
		return false
	}
	if !(.WeekdaysGraph == nil) {
		return false
	}
	if !(.TopPosters == nil) {
		return false
	}
	if !(.TopAdmins == nil) {
		return false
	}
	if !(.TopInviters == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StatsMegagroupStats from given interface.
func ( *StatsMegagroupStats) ( interface {
	() ( StatsDateRangeDays)
	() ( StatsAbsValueAndPrev)
	() ( StatsAbsValueAndPrev)
	() ( StatsAbsValueAndPrev)
	() ( StatsAbsValueAndPrev)
	() ( StatsGraphClass)
	() ( StatsGraphClass)
	() ( StatsGraphClass)
	() ( StatsGraphClass)
	() ( StatsGraphClass)
	() ( StatsGraphClass)
	() ( StatsGraphClass)
	() ( StatsGraphClass)
	() ( []StatsGroupTopPoster)
	() ( []StatsGroupTopAdmin)
	() ( []StatsGroupTopInviter)
	() ( []UserClass)
}) {
	.Period = .()
	.Members = .()
	.Messages = .()
	.Viewers = .()
	.Posters = .()
	.GrowthGraph = .()
	.MembersGraph = .()
	.NewMembersBySourceGraph = .()
	.LanguagesGraph = .()
	.MessagesGraph = .()
	.ActionsGraph = .()
	.TopHoursGraph = .()
	.WeekdaysGraph = .()
	.TopPosters = .()
	.TopAdmins = .()
	.TopInviters = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*StatsMegagroupStats) () string {
	return "stats.megagroupStats"
}

// TypeInfo returns info about TL type.
func ( *StatsMegagroupStats) () tdp.Type {
	 := tdp.Type{
		Name: "stats.megagroupStats",
		ID:   StatsMegagroupStatsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Period",
			SchemaName: "period",
		},
		{
			Name:       "Members",
			SchemaName: "members",
		},
		{
			Name:       "Messages",
			SchemaName: "messages",
		},
		{
			Name:       "Viewers",
			SchemaName: "viewers",
		},
		{
			Name:       "Posters",
			SchemaName: "posters",
		},
		{
			Name:       "GrowthGraph",
			SchemaName: "growth_graph",
		},
		{
			Name:       "MembersGraph",
			SchemaName: "members_graph",
		},
		{
			Name:       "NewMembersBySourceGraph",
			SchemaName: "new_members_by_source_graph",
		},
		{
			Name:       "LanguagesGraph",
			SchemaName: "languages_graph",
		},
		{
			Name:       "MessagesGraph",
			SchemaName: "messages_graph",
		},
		{
			Name:       "ActionsGraph",
			SchemaName: "actions_graph",
		},
		{
			Name:       "TopHoursGraph",
			SchemaName: "top_hours_graph",
		},
		{
			Name:       "WeekdaysGraph",
			SchemaName: "weekdays_graph",
		},
		{
			Name:       "TopPosters",
			SchemaName: "top_posters",
		},
		{
			Name:       "TopAdmins",
			SchemaName: "top_admins",
		},
		{
			Name:       "TopInviters",
			SchemaName: "top_inviters",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StatsMegagroupStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.megagroupStats#ef7ff916 as nil")
	}
	.PutID(StatsMegagroupStatsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsMegagroupStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.megagroupStats#ef7ff916 as nil")
	}
	if  := .Period.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field period: %w", )
	}
	if  := .Members.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field members: %w", )
	}
	if  := .Messages.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field messages: %w", )
	}
	if  := .Viewers.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field viewers: %w", )
	}
	if  := .Posters.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field posters: %w", )
	}
	if .GrowthGraph == nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field growth_graph is nil")
	}
	if  := .GrowthGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field growth_graph: %w", )
	}
	if .MembersGraph == nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field members_graph is nil")
	}
	if  := .MembersGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field members_graph: %w", )
	}
	if .NewMembersBySourceGraph == nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field new_members_by_source_graph is nil")
	}
	if  := .NewMembersBySourceGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field new_members_by_source_graph: %w", )
	}
	if .LanguagesGraph == nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field languages_graph is nil")
	}
	if  := .LanguagesGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field languages_graph: %w", )
	}
	if .MessagesGraph == nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field messages_graph is nil")
	}
	if  := .MessagesGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field messages_graph: %w", )
	}
	if .ActionsGraph == nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field actions_graph is nil")
	}
	if  := .ActionsGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field actions_graph: %w", )
	}
	if .TopHoursGraph == nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field top_hours_graph is nil")
	}
	if  := .TopHoursGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field top_hours_graph: %w", )
	}
	if .WeekdaysGraph == nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field weekdays_graph is nil")
	}
	if  := .WeekdaysGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field weekdays_graph: %w", )
	}
	.PutVectorHeader(len(.TopPosters))
	for ,  := range .TopPosters {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field top_posters element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.TopAdmins))
	for ,  := range .TopAdmins {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field top_admins element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.TopInviters))
	for ,  := range .TopInviters {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field top_inviters element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stats.megagroupStats#ef7ff916: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StatsMegagroupStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.megagroupStats#ef7ff916 to nil")
	}
	{
		if  := .Period.Decode();  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field period: %w", )
		}
	}
	{
		if  := .Members.Decode();  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field members: %w", )
		}
	}
	{
		if  := .Messages.Decode();  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field messages: %w", )
		}
	}
	{
		if  := .Viewers.Decode();  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field viewers: %w", )
		}
	}
	{
		if  := .Posters.Decode();  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field posters: %w", )
		}
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field growth_graph: %w", )
		}
		.GrowthGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field members_graph: %w", )
		}
		.MembersGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field new_members_by_source_graph: %w", )
		}
		.NewMembersBySourceGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field languages_graph: %w", )
		}
		.LanguagesGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field messages_graph: %w", )
		}
		.MessagesGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field actions_graph: %w", )
		}
		.ActionsGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field top_hours_graph: %w", )
		}
		.TopHoursGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field weekdays_graph: %w", )
		}
		.WeekdaysGraph = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field top_posters: %w", )
		}

		if  > 0 {
			.TopPosters = make([]StatsGroupTopPoster, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  StatsGroupTopPoster
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field top_posters: %w", )
			}
			.TopPosters = append(.TopPosters, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field top_admins: %w", )
		}

		if  > 0 {
			.TopAdmins = make([]StatsGroupTopAdmin, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  StatsGroupTopAdmin
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field top_admins: %w", )
			}
			.TopAdmins = append(.TopAdmins, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field top_inviters: %w", )
		}

		if  > 0 {
			.TopInviters = make([]StatsGroupTopInviter, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  StatsGroupTopInviter
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field top_inviters: %w", )
			}
			.TopInviters = append(.TopInviters, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode stats.megagroupStats#ef7ff916: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetPeriod returns value of Period field.
func ( *StatsMegagroupStats) () ( StatsDateRangeDays) {
	if  == nil {
		return
	}
	return .Period
}

// GetMembers returns value of Members field.
func ( *StatsMegagroupStats) () ( StatsAbsValueAndPrev) {
	if  == nil {
		return
	}
	return .Members
}

// GetMessages returns value of Messages field.
func ( *StatsMegagroupStats) () ( StatsAbsValueAndPrev) {
	if  == nil {
		return
	}
	return .Messages
}

// GetViewers returns value of Viewers field.
func ( *StatsMegagroupStats) () ( StatsAbsValueAndPrev) {
	if  == nil {
		return
	}
	return .Viewers
}

// GetPosters returns value of Posters field.
func ( *StatsMegagroupStats) () ( StatsAbsValueAndPrev) {
	if  == nil {
		return
	}
	return .Posters
}

// GetGrowthGraph returns value of GrowthGraph field.
func ( *StatsMegagroupStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .GrowthGraph
}

// GetMembersGraph returns value of MembersGraph field.
func ( *StatsMegagroupStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .MembersGraph
}

// GetNewMembersBySourceGraph returns value of NewMembersBySourceGraph field.
func ( *StatsMegagroupStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .NewMembersBySourceGraph
}

// GetLanguagesGraph returns value of LanguagesGraph field.
func ( *StatsMegagroupStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .LanguagesGraph
}

// GetMessagesGraph returns value of MessagesGraph field.
func ( *StatsMegagroupStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .MessagesGraph
}

// GetActionsGraph returns value of ActionsGraph field.
func ( *StatsMegagroupStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .ActionsGraph
}

// GetTopHoursGraph returns value of TopHoursGraph field.
func ( *StatsMegagroupStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .TopHoursGraph
}

// GetWeekdaysGraph returns value of WeekdaysGraph field.
func ( *StatsMegagroupStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .WeekdaysGraph
}

// GetTopPosters returns value of TopPosters field.
func ( *StatsMegagroupStats) () ( []StatsGroupTopPoster) {
	if  == nil {
		return
	}
	return .TopPosters
}

// GetTopAdmins returns value of TopAdmins field.
func ( *StatsMegagroupStats) () ( []StatsGroupTopAdmin) {
	if  == nil {
		return
	}
	return .TopAdmins
}

// GetTopInviters returns value of TopInviters field.
func ( *StatsMegagroupStats) () ( []StatsGroupTopInviter) {
	if  == nil {
		return
	}
	return .TopInviters
}

// GetUsers returns value of Users field.
func ( *StatsMegagroupStats) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *StatsMegagroupStats) () ( UserClassArray) {
	return UserClassArray(.Users)
}