You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: qrlogin.go
    path of file: ./repos/td/telegram/auth/qrlogin
    
    the code of the file until where you have to start completion: // Package qrlogin provides QR login flow implementation.
//
// See https://core.telegram.org/api/qr-login.
package qrlogin

import (
	"context"
	"time"

	"github.com/go-faster/errors"

	"github.com/gotd/td/clock"
	"github.com/gotd/td/tg"
)

// QR implements Telegram QR login flow.
type QR struct {
	api     *tg.Client
	appID   int
	appHash string
	migrate func(ctx context.Context, dcID int) error
	clock   clock.Clock
}

// NewQR creates new QR
func NewQR(api *tg.Client, appID int, appHash string, opts Options) QR {
	opts.setDefaults()
	return QR{
		api:     api,
		appID:   appID,
		appHash: appHash,
		clock:   opts.Clock,
	
    
func (q QR) Import(ctx context.Context) (*tg.AuthAuthorization, error) {
	result, err := q.api.AuthExportLoginToken(ctx, &tg.AuthExportLoginTokenRequest{
		APIID:   q.appID,
		APIHash: q.appHash,
	})
	if err != nil {
		return nil, errors.Wrap(err, "import")
	}

	switch t := result.(type) {
	case *tg.AuthLoginTokenMigrateTo:
		if q.migrate == nil {
			return nil, &MigrationNeededError{
				MigrateTo: t,
			}
		}
		if err := q.migrate(ctx, t.DCID); err != nil {
			return nil, errors.Wrap(err, "migrate")
		}

		res, err := q.api.AuthImportLoginToken(ctx, t.Token)
		if err != nil {
			return nil, errors.Wrap(err, "import")
		}

		success, ok := res.(*tg.AuthLoginTokenSuccess)
		if !ok {
			return nil, errors.Errorf("unexpected type %T", res)
		}

		auth, ok := success.Authorization.(*tg.AuthAuthorization)
		if !ok {
			return nil, errors.Errorf("unexpected type %T", success.Authorization)
		}
		return auth, nil
	case *tg.AuthLoginTokenSuccess:
		auth, ok := t.Authorization.(*tg.AuthAuthorization)
		if !ok {
			return nil, errors.Errorf("unexpected type %T", t.Authorization)
		}
		return auth, nil
	default:
		return nil, errors.Errorf("unexpected type %T", result)
	}
}