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

// InputWalletNew represents TL type `inputWalletNew#63a440dc`.
//
// See https://core.telegram.org/constructor/inputWalletNew for reference.
type InputWalletNew struct {
}

// InputWalletNewTypeID is TL type id of InputWalletNew.
const InputWalletNewTypeID = 0x63a440dc

// construct implements constructor of InputWalletReplacementClass.
func ( InputWalletNew) () InputWalletReplacementClass { return & }

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

	_ InputWalletReplacementClass = &InputWalletNew{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputWalletNew) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputWalletNew#63a440dc as nil")
	}
	.PutID(InputWalletNewTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputWalletNew) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputWalletNew#63a440dc as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputWalletNew) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputWalletNew#63a440dc to nil")
	}
	return nil
}

// InputWalletImported represents TL type `inputWalletImported#66a66a3b`.
//
// See https://core.telegram.org/constructor/inputWalletImported for reference.
type InputWalletImported struct {
	// Flags field of InputWalletImported.
	Flags bin.Fields
	// PublicKey field of InputWalletImported.
	PublicKey []byte
	// AnchorPublicKey field of InputWalletImported.
	//
	// Use SetAnchorPublicKey and GetAnchorPublicKey helpers.
	AnchorPublicKey []byte
	// Proof field of InputWalletImported.
	Proof WalletOwnershipProof
}

// InputWalletImportedTypeID is TL type id of InputWalletImported.
const InputWalletImportedTypeID = 0x66a66a3b

// construct implements constructor of InputWalletReplacementClass.
func ( InputWalletImported) () InputWalletReplacementClass { return & }

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

	_ InputWalletReplacementClass = &InputWalletImported{}
)

func ( *InputWalletImported) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.PublicKey == nil) {
		return false
	}
	if !(.AnchorPublicKey == nil) {
		return false
	}
	if !(.Proof.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills InputWalletImported from given interface.
func ( *InputWalletImported) ( interface {
	() ( []byte)
	() ( []byte,  bool)
	() ( WalletOwnershipProof)
}) {
	.PublicKey = .()
	if ,  := .();  {
		.AnchorPublicKey = 
	}

	.Proof = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputWalletImported) () tdp.Type {
	 := tdp.Type{
		Name: "inputWalletImported",
		ID:   InputWalletImportedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PublicKey",
			SchemaName: "public_key",
		},
		{
			Name:       "AnchorPublicKey",
			SchemaName: "anchor_public_key",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Proof",
			SchemaName: "proof",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputWalletImported) () {
	if !(.AnchorPublicKey == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *InputWalletImported) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputWalletImported#66a66a3b as nil")
	}
	.PutID(InputWalletImportedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputWalletImported) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputWalletImported#66a66a3b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputWalletImported#66a66a3b: field flags: %w", )
	}
	.PutBytes(.PublicKey)
	if .Flags.Has(0) {
		.PutBytes(.AnchorPublicKey)
	}
	if  := .Proof.Encode();  != nil {
		return fmt.Errorf("unable to encode inputWalletImported#66a66a3b: field proof: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputWalletImported) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputWalletImported#66a66a3b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputWalletImported#66a66a3b: field flags: %w", )
		}
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputWalletImported#66a66a3b: field public_key: %w", )
		}
		.PublicKey = 
	}
	if .Flags.Has(0) {
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputWalletImported#66a66a3b: field anchor_public_key: %w", )
		}
		.AnchorPublicKey = 
	}
	{
		if  := .Proof.Decode();  != nil {
			return fmt.Errorf("unable to decode inputWalletImported#66a66a3b: field proof: %w", )
		}
	}
	return nil
}

// GetPublicKey returns value of PublicKey field.
func ( *InputWalletImported) () ( []byte) {
	if  == nil {
		return
	}
	return .PublicKey
}

// SetAnchorPublicKey sets value of AnchorPublicKey conditional field.
func ( *InputWalletImported) ( []byte) {
	.Flags.Set(0)
	.AnchorPublicKey = 
}

// GetAnchorPublicKey returns value of AnchorPublicKey conditional field and
// boolean which is true if field was set.
func ( *InputWalletImported) () ( []byte,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .AnchorPublicKey, true
}

// GetProof returns value of Proof field.
func ( *InputWalletImported) () ( WalletOwnershipProof) {
	if  == nil {
		return
	}
	return .Proof
}

// InputWalletReplacementClassName is schema name of InputWalletReplacementClass.
const InputWalletReplacementClassName = "InputWalletReplacement"

// InputWalletReplacementClass represents InputWalletReplacement generic type.
//
// See https://core.telegram.org/type/InputWalletReplacement for reference.
//
// Constructors:
//   - [InputWalletNew]
//   - [InputWalletImported]
//
// Example:
//
//	g, err := tg.DecodeInputWalletReplacement(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputWalletNew: // inputWalletNew#63a440dc
//	case *tg.InputWalletImported: // inputWalletImported#66a66a3b
//	default: panic(v)
//	}
type InputWalletReplacementClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputWalletReplacementClass

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

// DecodeInputWalletReplacement implements binary de-serialization for InputWalletReplacementClass.
func ( *bin.Buffer) (InputWalletReplacementClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputWalletNewTypeID:
		// Decoding inputWalletNew#63a440dc.
		 := InputWalletNew{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputWalletReplacementClass: %w", )
		}
		return &, nil
	case InputWalletImportedTypeID:
		// Decoding inputWalletImported#66a66a3b.
		 := InputWalletImported{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputWalletReplacementClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputWalletReplacementClass: %w", bin.NewUnexpectedID())
	}
}

// InputWalletReplacement boxes the InputWalletReplacementClass providing a helper.
type InputWalletReplacementBox struct {
	InputWalletReplacement InputWalletReplacementClass
}

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

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