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

// StoriesStealthMode represents TL type `storiesStealthMode#712e27fd`.
// Information about the current stealth modeĀ¹ session.
//
// Links:
//  1. https://core.telegram.org/api/stories#stealth-mode
//
// See https://core.telegram.org/constructor/storiesStealthMode for reference.
type StoriesStealthMode struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The date up to which stealth mode will be active.
	//
	// Use SetActiveUntilDate and GetActiveUntilDate helpers.
	ActiveUntilDate int
	// The date starting from which the user will be allowed to re-enable stealth mode again.
	//
	// Use SetCooldownUntilDate and GetCooldownUntilDate helpers.
	CooldownUntilDate int
}

// StoriesStealthModeTypeID is TL type id of StoriesStealthMode.
const StoriesStealthModeTypeID = 0x712e27fd

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

func ( *StoriesStealthMode) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ActiveUntilDate == 0) {
		return false
	}
	if !(.CooldownUntilDate == 0) {
		return false
	}

	return true
}

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *StoriesStealthMode) () tdp.Type {
	 := tdp.Type{
		Name: "storiesStealthMode",
		ID:   StoriesStealthModeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ActiveUntilDate",
			SchemaName: "active_until_date",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "CooldownUntilDate",
			SchemaName: "cooldown_until_date",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StoriesStealthMode) () {
	if !(.ActiveUntilDate == 0) {
		.Flags.Set(0)
	}
	if !(.CooldownUntilDate == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *StoriesStealthMode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storiesStealthMode#712e27fd as nil")
	}
	.PutID(StoriesStealthModeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesStealthMode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storiesStealthMode#712e27fd as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode storiesStealthMode#712e27fd: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.ActiveUntilDate)
	}
	if .Flags.Has(1) {
		.PutInt(.CooldownUntilDate)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesStealthMode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode storiesStealthMode#712e27fd to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode storiesStealthMode#712e27fd: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storiesStealthMode#712e27fd: field active_until_date: %w", )
		}
		.ActiveUntilDate = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storiesStealthMode#712e27fd: field cooldown_until_date: %w", )
		}
		.CooldownUntilDate = 
	}
	return nil
}

// SetActiveUntilDate sets value of ActiveUntilDate conditional field.
func ( *StoriesStealthMode) ( int) {
	.Flags.Set(0)
	.ActiveUntilDate = 
}

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

// SetCooldownUntilDate sets value of CooldownUntilDate conditional field.
func ( *StoriesStealthMode) ( int) {
	.Flags.Set(1)
	.CooldownUntilDate = 
}

// GetCooldownUntilDate returns value of CooldownUntilDate conditional field and
// boolean which is true if field was set.
func ( *StoriesStealthMode) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .CooldownUntilDate, true
}