text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
      value: true
  });
  
  var _extends2 = require('babel-runtime/helpers/extends');
  
  var _extends3 = _interopRequireDefault(_extends2);
  
  var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
  
  var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  
  var _createClass2 = require('babel-runtime/helpers/createClass');
  
  var _createClass3 = _interopRequireDefault(_createClass2);
  
  var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
  
  var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
  
  var _inherits2 = require('babel-runtime/helpers/inherits');
  
  var _inherits3 = _interopRequireDefault(_inherits2);
  
  var _react = require('react');
  
  var _react2 = _interopRequireDefault(_react);
  
  var _core = require('@aws-amplify/core');
  
  var _auth = require('@aws-amplify/auth');
  
  var _auth2 = _interopRequireDefault(_auth);
  
  var _AuthPiece2 = require('./AuthPiece');
  
  var _AuthPiece3 = _interopRequireDefault(_AuthPiece2);
  
  var _AmplifyTheme = require('../AmplifyTheme');
  
  var _AmplifyTheme2 = _interopRequireDefault(_AmplifyTheme);
  
  var _AmplifyUI = require('../AmplifyUI');
  
  var _qrcode = require('qrcode.react');
  
  var _qrcode2 = _interopRequireDefault(_qrcode);
  
  var _Widget = require('../Widget');
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  /*
   * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
   * the License. A copy of the License is located at
   *
   *     http://aws.amazon.com/apache2.0/
   *
   * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
   * and limitations under the License.
   */
  
  var logger = new _core.ConsoleLogger('TOTPSetup');
  
  var TOTPSetup = function (_AuthPiece) {
      (0, _inherits3.default)(TOTPSetup, _AuthPiece);
  
      function TOTPSetup(props) {
          (0, _classCallCheck3.default)(this, TOTPSetup);
  
          var _this = (0, _possibleConstructorReturn3.default)(this, (TOTPSetup.__proto__ || Object.getPrototypeOf(TOTPSetup)).call(this, props));
  
          _this._validAuthStates = ['TOTPSetup'];
          _this.onTOTPEvent = _this.onTOTPEvent.bind(_this);
          _this.checkContact = _this.checkContact.bind(_this);
          return _this;
      }
  
      (0, _createClass3.default)(TOTPSetup, [{
          key: 'checkContact',
          value: function checkContact(user) {
              var _this2 = this;
  
              if (!_auth2.default || typeof _auth2.default.verifiedContact !== 'function') {
                  throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
              }
              _auth2.default.verifiedContact(user).then(function (data) {
                  if (!_core.JS.isEmpty(data.verified)) {
                      _this2.changeState('signedIn', user);
                  } else {
                      user = Object.assign(user, data);
                      _this2.changeState('verifyContact', user);
                  }
              });
          }
      }, {
          key: 'onTOTPEvent',
          value: function onTOTPEvent(event, data, user) {
              logger.debug('on totp event', event, data);
              //const user = this.props.authData;
              if (event === 'Setup TOTP') {
                  if (data === 'SUCCESS') {
                      this.checkContact(user);
                  }
              }
          }
      }, {
          key: 'showComponent',
          value: function showComponent(theme) {
              var hide = this.props.hide;
  
              if (hide && hide.includes(TOTPSetup)) {
                  return null;
              }
  
              return _react2.default.createElement(_Widget.TOTPSetupComp, (0, _extends3.default)({}, this.props, { onTOTPEvent: this.onTOTPEvent }));
          }
      }]);
      return TOTPSetup;
  }(_AuthPiece3.default);
  
  exports.default = TOTPSetup;