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

// StoryItemDeleted represents TL type `storyItemDeleted#51e6ee4f`.
// Represents a previously active story, that was deleted
//
// See https://core.telegram.org/constructor/storyItemDeleted for reference.
type StoryItemDeleted struct {
	// Story ID
	ID int
}

// StoryItemDeletedTypeID is TL type id of StoryItemDeleted.
const StoryItemDeletedTypeID = 0x51e6ee4f

// construct implements constructor of StoryItemClass.
func ( StoryItemDeleted) () StoryItemClass { return & }

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

	_ StoryItemClass = &StoryItemDeleted{}
)

func ( *StoryItemDeleted) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StoryItemDeleted from given interface.
func ( *StoryItemDeleted) ( interface {
	() ( int)
}) {
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoryItemDeleted) () tdp.Type {
	 := tdp.Type{
		Name: "storyItemDeleted",
		ID:   StoryItemDeletedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoryItemDeleted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyItemDeleted#51e6ee4f as nil")
	}
	.PutID(StoryItemDeletedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoryItemDeleted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyItemDeleted#51e6ee4f as nil")
	}
	.PutInt(.ID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoryItemDeleted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode storyItemDeleted#51e6ee4f to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storyItemDeleted#51e6ee4f: field id: %w", )
		}
		.ID = 
	}
	return nil
}

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

// StoryItemSkipped represents TL type `storyItemSkipped#ffadc913`.
// Represents an active story, whose full information was omitted for space and
// performance reasons; use stories.getStoriesByID¹ to fetch full info about the skipped
// story when and if needed.
//
// Links:
//  1. https://core.telegram.org/method/stories.getStoriesByID
//
// See https://core.telegram.org/constructor/storyItemSkipped for reference.
type StoryItemSkipped struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this story can only be viewed by our close friends, see here »¹ for more
	// info
	//
	// Links:
	//  1) https://core.telegram.org/api/privacy
	CloseFriends bool
	// Story ID
	ID int
	// When was the story posted.
	Date int
	// When does the story expire.
	ExpireDate int
}

// StoryItemSkippedTypeID is TL type id of StoryItemSkipped.
const StoryItemSkippedTypeID = 0xffadc913

// construct implements constructor of StoryItemClass.
func ( StoryItemSkipped) () StoryItemClass { return & }

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

	_ StoryItemClass = &StoryItemSkipped{}
)

func ( *StoryItemSkipped) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.CloseFriends == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.ExpireDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StoryItemSkipped from given interface.
func ( *StoryItemSkipped) ( interface {
	() ( bool)
	() ( int)
	() ( int)
	() ( int)
}) {
	.CloseFriends = .()
	.ID = .()
	.Date = .()
	.ExpireDate = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoryItemSkipped) () tdp.Type {
	 := tdp.Type{
		Name: "storyItemSkipped",
		ID:   StoryItemSkippedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "CloseFriends",
			SchemaName: "close_friends",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "ExpireDate",
			SchemaName: "expire_date",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StoryItemSkipped) () {
	if !(.CloseFriends == false) {
		.Flags.Set(8)
	}
}

// Encode implements bin.Encoder.
func ( *StoryItemSkipped) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyItemSkipped#ffadc913 as nil")
	}
	.PutID(StoryItemSkippedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoryItemSkipped) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyItemSkipped#ffadc913 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode storyItemSkipped#ffadc913: field flags: %w", )
	}
	.PutInt(.ID)
	.PutInt(.Date)
	.PutInt(.ExpireDate)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoryItemSkipped) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode storyItemSkipped#ffadc913 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode storyItemSkipped#ffadc913: field flags: %w", )
		}
	}
	.CloseFriends = .Flags.Has(8)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storyItemSkipped#ffadc913: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storyItemSkipped#ffadc913: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storyItemSkipped#ffadc913: field expire_date: %w", )
		}
		.ExpireDate = 
	}
	return nil
}

// SetCloseFriends sets value of CloseFriends conditional field.
func ( *StoryItemSkipped) ( bool) {
	if  {
		.Flags.Set(8)
		.CloseFriends = true
	} else {
		.Flags.Unset(8)
		.CloseFriends = false
	}
}

// GetCloseFriends returns value of CloseFriends conditional field.
func ( *StoryItemSkipped) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(8)
}

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

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

// GetExpireDate returns value of ExpireDate field.
func ( *StoryItemSkipped) () ( int) {
	if  == nil {
		return
	}
	return .ExpireDate
}

// StoryItem represents TL type `storyItem#af6365a1`.
// Represents a story¹.
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// See https://core.telegram.org/constructor/storyItem for reference.
type StoryItem struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this story is pinned on the user's profile
	Pinned bool
	// Whether this story is public and can be viewed by everyone
	Public bool
	// Whether this story can only be viewed by our close friends, see here »¹ for more
	// info
	//
	// Links:
	//  1) https://core.telegram.org/api/privacy
	CloseFriends bool
	// Full information about this story was omitted for space and performance reasons; use
	// stories.getStoriesByID¹ to fetch full info about this story when and if needed.
	//
	// Links:
	//  1) https://core.telegram.org/method/stories.getStoriesByID
	Min bool
	// Whether this story is protected¹ and thus cannot be forwarded; clients should also
	// prevent users from saving attached media (i.e. videos should only be streamed, photos
	// should be kept in RAM, et cetera).
	//
	// Links:
	//  1) https://telegram.org/blog/protected-content-delete-by-date-and-more
	Noforwards bool
	// Indicates whether the story was edited.
	Edited bool
	// Whether this story can only be viewed by our contacts
	Contacts bool
	// Whether this story can only be viewed by a select list of our contacts
	SelectedContacts bool
	// indicates whether we sent this story.
	Out bool
	// ID of the story.
	ID int
	// When was the story posted.
	Date int
	// For reposted stories »¹, contains info about the original story.
	//
	// Links:
	//  1) https://core.telegram.org/api/stories#reposting-stories
	//
	// Use SetFwdFrom and GetFwdFrom helpers.
	FwdFrom StoryFwdHeader
	// When does the story expire.
	ExpireDate int
	// Story caption.
	//
	// Use SetCaption and GetCaption helpers.
	Caption string
	// Message entities for styled text¹
	//
	// Links:
	//  1) https://core.telegram.org/api/entities
	//
	// Use SetEntities and GetEntities helpers.
	Entities []MessageEntityClass
	// Story media.
	Media MessageMediaClass
	// List of media areas, see here »¹ for more info on media areas.
	//
	// Links:
	//  1) https://core.telegram.org/api/stories#media-areas
	//
	// Use SetMediaAreas and GetMediaAreas helpers.
	MediaAreas []MediaAreaClass
	// Privacy rules¹ indicating who can and can't view this story
	//
	// Links:
	//  1) https://core.telegram.org/api/privacy
	//
	// Use SetPrivacy and GetPrivacy helpers.
	Privacy []PrivacyRuleClass
	// View date and reaction information
	//
	// Use SetViews and GetViews helpers.
	Views StoryViews
	// The reaction we sent.
	//
	// Use SetSentReaction and GetSentReaction helpers.
	SentReaction ReactionClass
}

// StoryItemTypeID is TL type id of StoryItem.
const StoryItemTypeID = 0xaf6365a1

// construct implements constructor of StoryItemClass.
func ( StoryItem) () StoryItemClass { return & }

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

	_ StoryItemClass = &StoryItem{}
)

func ( *StoryItem) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Pinned == false) {
		return false
	}
	if !(.Public == false) {
		return false
	}
	if !(.CloseFriends == false) {
		return false
	}
	if !(.Min == false) {
		return false
	}
	if !(.Noforwards == false) {
		return false
	}
	if !(.Edited == false) {
		return false
	}
	if !(.Contacts == false) {
		return false
	}
	if !(.SelectedContacts == false) {
		return false
	}
	if !(.Out == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.FwdFrom.Zero()) {
		return false
	}
	if !(.ExpireDate == 0) {
		return false
	}
	if !(.Caption == "") {
		return false
	}
	if !(.Entities == nil) {
		return false
	}
	if !(.Media == nil) {
		return false
	}
	if !(.MediaAreas == nil) {
		return false
	}
	if !(.Privacy == nil) {
		return false
	}
	if !(.Views.Zero()) {
		return false
	}
	if !(.SentReaction == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StoryItem from given interface.
func ( *StoryItem) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int)
	() ( int)
	() ( StoryFwdHeader,  bool)
	() ( int)
	() ( string,  bool)
	() ( []MessageEntityClass,  bool)
	() ( MessageMediaClass)
	() ( []MediaAreaClass,  bool)
	() ( []PrivacyRuleClass,  bool)
	() ( StoryViews,  bool)
	() ( ReactionClass,  bool)
}) {
	.Pinned = .()
	.Public = .()
	.CloseFriends = .()
	.Min = .()
	.Noforwards = .()
	.Edited = .()
	.Contacts = .()
	.SelectedContacts = .()
	.Out = .()
	.ID = .()
	.Date = .()
	if ,  := .();  {
		.FwdFrom = 
	}

	.ExpireDate = .()
	if ,  := .();  {
		.Caption = 
	}

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

	.Media = .()
	if ,  := .();  {
		.MediaAreas = 
	}

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *StoryItem) () tdp.Type {
	 := tdp.Type{
		Name: "storyItem",
		ID:   StoryItemTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pinned",
			SchemaName: "pinned",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Public",
			SchemaName: "public",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "CloseFriends",
			SchemaName: "close_friends",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "Min",
			SchemaName: "min",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "Noforwards",
			SchemaName: "noforwards",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Edited",
			SchemaName: "edited",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "Contacts",
			SchemaName: "contacts",
			Null:       !.Flags.Has(12),
		},
		{
			Name:       "SelectedContacts",
			SchemaName: "selected_contacts",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "Out",
			SchemaName: "out",
			Null:       !.Flags.Has(16),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "FwdFrom",
			SchemaName: "fwd_from",
			Null:       !.Flags.Has(17),
		},
		{
			Name:       "ExpireDate",
			SchemaName: "expire_date",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Entities",
			SchemaName: "entities",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
		{
			Name:       "MediaAreas",
			SchemaName: "media_areas",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "Privacy",
			SchemaName: "privacy",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Views",
			SchemaName: "views",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "SentReaction",
			SchemaName: "sent_reaction",
			Null:       !.Flags.Has(15),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StoryItem) () {
	if !(.Pinned == false) {
		.Flags.Set(5)
	}
	if !(.Public == false) {
		.Flags.Set(7)
	}
	if !(.CloseFriends == false) {
		.Flags.Set(8)
	}
	if !(.Min == false) {
		.Flags.Set(9)
	}
	if !(.Noforwards == false) {
		.Flags.Set(10)
	}
	if !(.Edited == false) {
		.Flags.Set(11)
	}
	if !(.Contacts == false) {
		.Flags.Set(12)
	}
	if !(.SelectedContacts == false) {
		.Flags.Set(13)
	}
	if !(.Out == false) {
		.Flags.Set(16)
	}
	if !(.FwdFrom.Zero()) {
		.Flags.Set(17)
	}
	if !(.Caption == "") {
		.Flags.Set(0)
	}
	if !(.Entities == nil) {
		.Flags.Set(1)
	}
	if !(.MediaAreas == nil) {
		.Flags.Set(14)
	}
	if !(.Privacy == nil) {
		.Flags.Set(2)
	}
	if !(.Views.Zero()) {
		.Flags.Set(3)
	}
	if !(.SentReaction == nil) {
		.Flags.Set(15)
	}
}

// Encode implements bin.Encoder.
func ( *StoryItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyItem#af6365a1 as nil")
	}
	.PutID(StoryItemTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoryItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyItem#af6365a1 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode storyItem#af6365a1: field flags: %w", )
	}
	.PutInt(.ID)
	.PutInt(.Date)
	if .Flags.Has(17) {
		if  := .FwdFrom.Encode();  != nil {
			return fmt.Errorf("unable to encode storyItem#af6365a1: field fwd_from: %w", )
		}
	}
	.PutInt(.ExpireDate)
	if .Flags.Has(0) {
		.PutString(.Caption)
	}
	if .Flags.Has(1) {
		.PutVectorHeader(len(.Entities))
		for ,  := range .Entities {
			if  == nil {
				return fmt.Errorf("unable to encode storyItem#af6365a1: field entities element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode storyItem#af6365a1: field entities element with index %d: %w", , )
			}
		}
	}
	if .Media == nil {
		return fmt.Errorf("unable to encode storyItem#af6365a1: field media is nil")
	}
	if  := .Media.Encode();  != nil {
		return fmt.Errorf("unable to encode storyItem#af6365a1: field media: %w", )
	}
	if .Flags.Has(14) {
		.PutVectorHeader(len(.MediaAreas))
		for ,  := range .MediaAreas {
			if  == nil {
				return fmt.Errorf("unable to encode storyItem#af6365a1: field media_areas element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode storyItem#af6365a1: field media_areas element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(2) {
		.PutVectorHeader(len(.Privacy))
		for ,  := range .Privacy {
			if  == nil {
				return fmt.Errorf("unable to encode storyItem#af6365a1: field privacy element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode storyItem#af6365a1: field privacy element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(3) {
		if  := .Views.Encode();  != nil {
			return fmt.Errorf("unable to encode storyItem#af6365a1: field views: %w", )
		}
	}
	if .Flags.Has(15) {
		if .SentReaction == nil {
			return fmt.Errorf("unable to encode storyItem#af6365a1: field sent_reaction is nil")
		}
		if  := .SentReaction.Encode();  != nil {
			return fmt.Errorf("unable to encode storyItem#af6365a1: field sent_reaction: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoryItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode storyItem#af6365a1 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field flags: %w", )
		}
	}
	.Pinned = .Flags.Has(5)
	.Public = .Flags.Has(7)
	.CloseFriends = .Flags.Has(8)
	.Min = .Flags.Has(9)
	.Noforwards = .Flags.Has(10)
	.Edited = .Flags.Has(11)
	.Contacts = .Flags.Has(12)
	.SelectedContacts = .Flags.Has(13)
	.Out = .Flags.Has(16)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field date: %w", )
		}
		.Date = 
	}
	if .Flags.Has(17) {
		if  := .FwdFrom.Decode();  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field fwd_from: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field expire_date: %w", )
		}
		.ExpireDate = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field caption: %w", )
		}
		.Caption = 
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field entities: %w", )
		}

		if  > 0 {
			.Entities = make([]MessageEntityClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessageEntity()
			if  != nil {
				return fmt.Errorf("unable to decode storyItem#af6365a1: field entities: %w", )
			}
			.Entities = append(.Entities, )
		}
	}
	{
		,  := DecodeMessageMedia()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field media: %w", )
		}
		.Media = 
	}
	if .Flags.Has(14) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field media_areas: %w", )
		}

		if  > 0 {
			.MediaAreas = make([]MediaAreaClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMediaArea()
			if  != nil {
				return fmt.Errorf("unable to decode storyItem#af6365a1: field media_areas: %w", )
			}
			.MediaAreas = append(.MediaAreas, )
		}
	}
	if .Flags.Has(2) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field privacy: %w", )
		}

		if  > 0 {
			.Privacy = make([]PrivacyRuleClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodePrivacyRule()
			if  != nil {
				return fmt.Errorf("unable to decode storyItem#af6365a1: field privacy: %w", )
			}
			.Privacy = append(.Privacy, )
		}
	}
	if .Flags.Has(3) {
		if  := .Views.Decode();  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field views: %w", )
		}
	}
	if .Flags.Has(15) {
		,  := DecodeReaction()
		if  != nil {
			return fmt.Errorf("unable to decode storyItem#af6365a1: field sent_reaction: %w", )
		}
		.SentReaction = 
	}
	return nil
}

// SetPinned sets value of Pinned conditional field.
func ( *StoryItem) ( bool) {
	if  {
		.Flags.Set(5)
		.Pinned = true
	} else {
		.Flags.Unset(5)
		.Pinned = false
	}
}

// GetPinned returns value of Pinned conditional field.
func ( *StoryItem) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetPublic sets value of Public conditional field.
func ( *StoryItem) ( bool) {
	if  {
		.Flags.Set(7)
		.Public = true
	} else {
		.Flags.Unset(7)
		.Public = false
	}
}

// GetPublic returns value of Public conditional field.
func ( *StoryItem) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetCloseFriends sets value of CloseFriends conditional field.
func ( *StoryItem) ( bool) {
	if  {
		.Flags.Set(8)
		.CloseFriends = true
	} else {
		.Flags.Unset(8)
		.CloseFriends = false
	}
}

// GetCloseFriends returns value of CloseFriends conditional field.
func ( *StoryItem) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(8)
}

// SetMin sets value of Min conditional field.
func ( *StoryItem) ( bool) {
	if  {
		.Flags.Set(9)
		.Min = true
	} else {
		.Flags.Unset(9)
		.Min = false
	}
}

// GetMin returns value of Min conditional field.
func ( *StoryItem) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(9)
}

// SetNoforwards sets value of Noforwards conditional field.
func ( *StoryItem) ( bool) {
	if  {
		.Flags.Set(10)
		.Noforwards = true
	} else {
		.Flags.Unset(10)
		.Noforwards = false
	}
}

// GetNoforwards returns value of Noforwards conditional field.
func ( *StoryItem) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(10)
}

// SetEdited sets value of Edited conditional field.
func ( *StoryItem) ( bool) {
	if  {
		.Flags.Set(11)
		.Edited = true
	} else {
		.Flags.Unset(11)
		.Edited = false
	}
}

// GetEdited returns value of Edited conditional field.
func ( *StoryItem) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(11)
}

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

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

// SetSelectedContacts sets value of SelectedContacts conditional field.
func ( *StoryItem) ( bool) {
	if  {
		.Flags.Set(13)
		.SelectedContacts = true
	} else {
		.Flags.Unset(13)
		.SelectedContacts = false
	}
}

// GetSelectedContacts returns value of SelectedContacts conditional field.
func ( *StoryItem) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(13)
}

// SetOut sets value of Out conditional field.
func ( *StoryItem) ( bool) {
	if  {
		.Flags.Set(16)
		.Out = true
	} else {
		.Flags.Unset(16)
		.Out = false
	}
}

// GetOut returns value of Out conditional field.
func ( *StoryItem) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(16)
}

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

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

// SetFwdFrom sets value of FwdFrom conditional field.
func ( *StoryItem) ( StoryFwdHeader) {
	.Flags.Set(17)
	.FwdFrom = 
}

// GetFwdFrom returns value of FwdFrom conditional field and
// boolean which is true if field was set.
func ( *StoryItem) () ( StoryFwdHeader,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(17) {
		return , false
	}
	return .FwdFrom, true
}

// GetExpireDate returns value of ExpireDate field.
func ( *StoryItem) () ( int) {
	if  == nil {
		return
	}
	return .ExpireDate
}

// SetCaption sets value of Caption conditional field.
func ( *StoryItem) ( string) {
	.Flags.Set(0)
	.Caption = 
}

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

// SetEntities sets value of Entities conditional field.
func ( *StoryItem) ( []MessageEntityClass) {
	.Flags.Set(1)
	.Entities = 
}

// GetEntities returns value of Entities conditional field and
// boolean which is true if field was set.
func ( *StoryItem) () ( []MessageEntityClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Entities, true
}

// GetMedia returns value of Media field.
func ( *StoryItem) () ( MessageMediaClass) {
	if  == nil {
		return
	}
	return .Media
}

// SetMediaAreas sets value of MediaAreas conditional field.
func ( *StoryItem) ( []MediaAreaClass) {
	.Flags.Set(14)
	.MediaAreas = 
}

// GetMediaAreas returns value of MediaAreas conditional field and
// boolean which is true if field was set.
func ( *StoryItem) () ( []MediaAreaClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(14) {
		return , false
	}
	return .MediaAreas, true
}

// SetPrivacy sets value of Privacy conditional field.
func ( *StoryItem) ( []PrivacyRuleClass) {
	.Flags.Set(2)
	.Privacy = 
}

// GetPrivacy returns value of Privacy conditional field and
// boolean which is true if field was set.
func ( *StoryItem) () ( []PrivacyRuleClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Privacy, true
}

// SetViews sets value of Views conditional field.
func ( *StoryItem) ( StoryViews) {
	.Flags.Set(3)
	.Views = 
}

// GetViews returns value of Views conditional field and
// boolean which is true if field was set.
func ( *StoryItem) () ( StoryViews,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .Views, true
}

// SetSentReaction sets value of SentReaction conditional field.
func ( *StoryItem) ( ReactionClass) {
	.Flags.Set(15)
	.SentReaction = 
}

// GetSentReaction returns value of SentReaction conditional field and
// boolean which is true if field was set.
func ( *StoryItem) () ( ReactionClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(15) {
		return , false
	}
	return .SentReaction, true
}

// MapEntities returns field Entities wrapped in MessageEntityClassArray helper.
func ( *StoryItem) () ( MessageEntityClassArray,  bool) {
	if !.Flags.Has(1) {
		return , false
	}
	return MessageEntityClassArray(.Entities), true
}

// MapMediaAreas returns field MediaAreas wrapped in MediaAreaClassArray helper.
func ( *StoryItem) () ( MediaAreaClassArray,  bool) {
	if !.Flags.Has(14) {
		return , false
	}
	return MediaAreaClassArray(.MediaAreas), true
}

// MapPrivacy returns field Privacy wrapped in PrivacyRuleClassArray helper.
func ( *StoryItem) () ( PrivacyRuleClassArray,  bool) {
	if !.Flags.Has(2) {
		return , false
	}
	return PrivacyRuleClassArray(.Privacy), true
}

// StoryItemClassName is schema name of StoryItemClass.
const StoryItemClassName = "StoryItem"

// StoryItemClass represents StoryItem generic type.
//
// See https://core.telegram.org/type/StoryItem for reference.
//
// Example:
//
//	g, err := tg.DecodeStoryItem(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.StoryItemDeleted: // storyItemDeleted#51e6ee4f
//	case *tg.StoryItemSkipped: // storyItemSkipped#ffadc913
//	case *tg.StoryItem: // storyItem#af6365a1
//	default: panic(v)
//	}
type StoryItemClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StoryItemClass

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

	// Story ID
	GetID() (value int)
}

// DecodeStoryItem implements binary de-serialization for StoryItemClass.
func ( *bin.Buffer) (StoryItemClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case StoryItemDeletedTypeID:
		// Decoding storyItemDeleted#51e6ee4f.
		 := StoryItemDeleted{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StoryItemClass: %w", )
		}
		return &, nil
	case StoryItemSkippedTypeID:
		// Decoding storyItemSkipped#ffadc913.
		 := StoryItemSkipped{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StoryItemClass: %w", )
		}
		return &, nil
	case StoryItemTypeID:
		// Decoding storyItem#af6365a1.
		 := StoryItem{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StoryItemClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode StoryItemClass: %w", bin.NewUnexpectedID())
	}
}

// StoryItem boxes the StoryItemClass providing a helper.
type StoryItemBox struct {
	StoryItem StoryItemClass
}

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

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