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

// AccountWebBrowserSettingsNotModified represents TL type `account.webBrowserSettingsNotModified#c31c8f4e`.
//
// See https://core.telegram.org/constructor/account.webBrowserSettingsNotModified for reference.
type AccountWebBrowserSettingsNotModified struct {
}

// AccountWebBrowserSettingsNotModifiedTypeID is TL type id of AccountWebBrowserSettingsNotModified.
const AccountWebBrowserSettingsNotModifiedTypeID = 0xc31c8f4e

// construct implements constructor of AccountWebBrowserSettingsClass.
func ( AccountWebBrowserSettingsNotModified) () AccountWebBrowserSettingsClass { return & }

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

	_ AccountWebBrowserSettingsClass = &AccountWebBrowserSettingsNotModified{}
)

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

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AccountWebBrowserSettingsNotModified) () string {
	return "account.webBrowserSettingsNotModified"
}

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

// Encode implements bin.Encoder.
func ( *AccountWebBrowserSettingsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.webBrowserSettingsNotModified#c31c8f4e as nil")
	}
	.PutID(AccountWebBrowserSettingsNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountWebBrowserSettingsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.webBrowserSettingsNotModified#c31c8f4e as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountWebBrowserSettingsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.webBrowserSettingsNotModified#c31c8f4e to nil")
	}
	return nil
}

// AccountWebBrowserSettings represents TL type `account.webBrowserSettings#79eb8cb3`.
//
// See https://core.telegram.org/constructor/account.webBrowserSettings for reference.
type AccountWebBrowserSettings struct {
	// Flags field of AccountWebBrowserSettings.
	Flags bin.Fields
	// OpenExternalBrowser field of AccountWebBrowserSettings.
	OpenExternalBrowser bool
	// DisplayCloseButton field of AccountWebBrowserSettings.
	DisplayCloseButton bool
	// ExternalExceptions field of AccountWebBrowserSettings.
	ExternalExceptions []WebDomainException
	// InappExceptions field of AccountWebBrowserSettings.
	InappExceptions []WebDomainException
	// Hash field of AccountWebBrowserSettings.
	Hash int64
}

// AccountWebBrowserSettingsTypeID is TL type id of AccountWebBrowserSettings.
const AccountWebBrowserSettingsTypeID = 0x79eb8cb3

// construct implements constructor of AccountWebBrowserSettingsClass.
func ( AccountWebBrowserSettings) () AccountWebBrowserSettingsClass { return & }

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

	_ AccountWebBrowserSettingsClass = &AccountWebBrowserSettings{}
)

func ( *AccountWebBrowserSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.OpenExternalBrowser == false) {
		return false
	}
	if !(.DisplayCloseButton == false) {
		return false
	}
	if !(.ExternalExceptions == nil) {
		return false
	}
	if !(.InappExceptions == nil) {
		return false
	}
	if !(.Hash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AccountWebBrowserSettings from given interface.
func ( *AccountWebBrowserSettings) ( interface {
	() ( bool)
	() ( bool)
	() ( []WebDomainException)
	() ( []WebDomainException)
	() ( int64)
}) {
	.OpenExternalBrowser = .()
	.DisplayCloseButton = .()
	.ExternalExceptions = .()
	.InappExceptions = .()
	.Hash = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountWebBrowserSettings) () string {
	return "account.webBrowserSettings"
}

// TypeInfo returns info about TL type.
func ( *AccountWebBrowserSettings) () tdp.Type {
	 := tdp.Type{
		Name: "account.webBrowserSettings",
		ID:   AccountWebBrowserSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "OpenExternalBrowser",
			SchemaName: "open_external_browser",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "DisplayCloseButton",
			SchemaName: "display_close_button",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "ExternalExceptions",
			SchemaName: "external_exceptions",
		},
		{
			Name:       "InappExceptions",
			SchemaName: "inapp_exceptions",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountWebBrowserSettings) () {
	if !(.OpenExternalBrowser == false) {
		.Flags.Set(0)
	}
	if !(.DisplayCloseButton == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AccountWebBrowserSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.webBrowserSettings#79eb8cb3 as nil")
	}
	.PutID(AccountWebBrowserSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountWebBrowserSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.webBrowserSettings#79eb8cb3 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.webBrowserSettings#79eb8cb3: field flags: %w", )
	}
	.PutVectorHeader(len(.ExternalExceptions))
	for ,  := range .ExternalExceptions {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.webBrowserSettings#79eb8cb3: field external_exceptions element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.InappExceptions))
	for ,  := range .InappExceptions {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.webBrowserSettings#79eb8cb3: field inapp_exceptions element with index %d: %w", , )
		}
	}
	.PutLong(.Hash)
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountWebBrowserSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.webBrowserSettings#79eb8cb3 to nil")
	}
	if  := .ConsumeID(AccountWebBrowserSettingsTypeID);  != nil {
		return fmt.Errorf("unable to decode account.webBrowserSettings#79eb8cb3: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountWebBrowserSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.webBrowserSettings#79eb8cb3 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.webBrowserSettings#79eb8cb3: field flags: %w", )
		}
	}
	.OpenExternalBrowser = .Flags.Has(0)
	.DisplayCloseButton = .Flags.Has(1)
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.webBrowserSettings#79eb8cb3: field external_exceptions: %w", )
		}

		if  > 0 {
			.ExternalExceptions = make([]WebDomainException, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  WebDomainException
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.webBrowserSettings#79eb8cb3: field external_exceptions: %w", )
			}
			.ExternalExceptions = append(.ExternalExceptions, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.webBrowserSettings#79eb8cb3: field inapp_exceptions: %w", )
		}

		if  > 0 {
			.InappExceptions = make([]WebDomainException, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  WebDomainException
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.webBrowserSettings#79eb8cb3: field inapp_exceptions: %w", )
			}
			.InappExceptions = append(.InappExceptions, )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode account.webBrowserSettings#79eb8cb3: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

// SetOpenExternalBrowser sets value of OpenExternalBrowser conditional field.
func ( *AccountWebBrowserSettings) ( bool) {
	if  {
		.Flags.Set(0)
		.OpenExternalBrowser = true
	} else {
		.Flags.Unset(0)
		.OpenExternalBrowser = false
	}
}

// GetOpenExternalBrowser returns value of OpenExternalBrowser conditional field.
func ( *AccountWebBrowserSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetDisplayCloseButton sets value of DisplayCloseButton conditional field.
func ( *AccountWebBrowserSettings) ( bool) {
	if  {
		.Flags.Set(1)
		.DisplayCloseButton = true
	} else {
		.Flags.Unset(1)
		.DisplayCloseButton = false
	}
}

// GetDisplayCloseButton returns value of DisplayCloseButton conditional field.
func ( *AccountWebBrowserSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetExternalExceptions returns value of ExternalExceptions field.
func ( *AccountWebBrowserSettings) () ( []WebDomainException) {
	if  == nil {
		return
	}
	return .ExternalExceptions
}

// GetInappExceptions returns value of InappExceptions field.
func ( *AccountWebBrowserSettings) () ( []WebDomainException) {
	if  == nil {
		return
	}
	return .InappExceptions
}

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

// AccountWebBrowserSettingsClassName is schema name of AccountWebBrowserSettingsClass.
const AccountWebBrowserSettingsClassName = "account.WebBrowserSettings"

// AccountWebBrowserSettingsClass represents account.WebBrowserSettings generic type.
//
// See https://core.telegram.org/type/account.WebBrowserSettings for reference.
//
// Constructors:
//   - [AccountWebBrowserSettingsNotModified]
//   - [AccountWebBrowserSettings]
//
// Example:
//
//	g, err := tg.DecodeAccountWebBrowserSettings(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AccountWebBrowserSettingsNotModified: // account.webBrowserSettingsNotModified#c31c8f4e
//	case *tg.AccountWebBrowserSettings: // account.webBrowserSettings#79eb8cb3
//	default: panic(v)
//	}
type AccountWebBrowserSettingsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AccountWebBrowserSettingsClass

	// 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 AccountWebBrowserSettingsClass to AccountWebBrowserSettings.
	AsModified() (*AccountWebBrowserSettings, bool)
}

// AsModified tries to map AccountWebBrowserSettingsNotModified to AccountWebBrowserSettings.
func ( *AccountWebBrowserSettingsNotModified) () (*AccountWebBrowserSettings, bool) {
	return nil, false
}

// AsModified tries to map AccountWebBrowserSettings to AccountWebBrowserSettings.
func ( *AccountWebBrowserSettings) () (*AccountWebBrowserSettings, bool) {
	return , true
}

// DecodeAccountWebBrowserSettings implements binary de-serialization for AccountWebBrowserSettingsClass.
func ( *bin.Buffer) (AccountWebBrowserSettingsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AccountWebBrowserSettingsNotModifiedTypeID:
		// Decoding account.webBrowserSettingsNotModified#c31c8f4e.
		 := AccountWebBrowserSettingsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountWebBrowserSettingsClass: %w", )
		}
		return &, nil
	case AccountWebBrowserSettingsTypeID:
		// Decoding account.webBrowserSettings#79eb8cb3.
		 := AccountWebBrowserSettings{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountWebBrowserSettingsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AccountWebBrowserSettingsClass: %w", bin.NewUnexpectedID())
	}
}

// AccountWebBrowserSettings boxes the AccountWebBrowserSettingsClass providing a helper.
type AccountWebBrowserSettingsBox struct {
	WebBrowserSettings AccountWebBrowserSettingsClass
}

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

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