package telegram

import (
	

	

	
)

func ( *Client) ( context.Context,  int) (*tg.AuthExportedAuthorization, error) {
	,  := .tg.AuthExportAuthorization(, )
	if  != nil {
		return nil, errors.Wrapf(, "export auth to %d", )
	}

	return , nil
}

// AuthTransferHandler is a function that is called during authorization transfer.
//
// The fn callback should be serialized by user id via external locking.
// You can call [Client.Self] to acquire current user id.
//
// The fn callback must return fn error if any.
type AuthTransferHandler func(ctx context.Context, client *Client, fn func(context.Context) error) error

func ( context.Context,  *Client,  func(context.Context) error) error {
	return ()
}

// transfer exports current authorization and imports it to another DC.
// See https://core.telegram.org/api/datacenter#authorization-transfer.
func ( *Client) ( context.Context,  *tg.Client,  int) (tg.AuthAuthorizationClass, error) {
	var  tg.AuthAuthorizationClass
	if  := .onTransfer(, , func( context.Context) error {
		,  := .exportAuth(, )
		if  != nil {
			return errors.Wrapf(, "export to %d", )
		}

		 := &tg.AuthImportAuthorizationRequest{}
		.FillFrom()
		,  := .AuthImportAuthorization(, )
		if  != nil {
			return errors.Wrapf(, "import from %d", )
		}

		 = 
		return nil
	});  != nil {
		return nil, errors.Wrap(, "onTransfer")
	}
	return , nil
}