"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.LoadingScreen = void 0;

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));

var _react = _interopRequireWildcard(require("react"));

var _styles = require("@material-ui/core/styles");

var _core = require("@material-ui/core");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var useStyles = function useStyles(props) {
  return (0, _styles.makeStyles)(function (theme) {
    return {
      root: {
        position: 'absolute',
        left: '0',
        top: '0',
        width: '100%',
        height: '100%',
        display: 'flex',
        flexDirection: 'column',
        alignItems: 'center',
        justifyContent: 'center',
        fontSize: '55px',
        lineHeight: '60px'
      },
      loading: {
        display: 'flex',
        flexDirection: 'column',
        alignItems: 'center',
        padding: '5px',
        justifyContent: 'center',
        width: '350px',
        height: '100px'
      },
      logo: {
        animation: '$pulse 2s infinite linear'
      },
      "@keyframes pulse": {
        "0%": {
          opacity: 1
        },
        "50%": {
          opacity: 0.5
        },
        "100%": {
          opacity: 1
        }
      }
    };
  });
};

var emojisMap = ['💪', '💡', '🍆', '🔥', '😍', '👾', '🐉'];

var LoadingScreen = function LoadingScreen(props) {
  var _React$useState = _react.default.useState(null),
      _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
      time = _React$useState2[0],
      setTimer = _React$useState2[1];

  var classes = useStyles(props)();
  (0, _react.useEffect)(function () {
    var interval = setInterval(function () {
      setTimer(new Date());
    }, 200); // This is important, you must clear your interval when component unmounts

    return function () {
      return clearInterval(interval);
    };
  }, []); // [] is for to execute `useEffect` only once as `componentWillMount`

  var randomInt = function randomInt(min, max) {
    var rand = min - 0.5 + Math.random() * (max - min + 1);
    return Math.round(rand);
  };

  var Emoji = function Emoji() {
    return emojisMap[randomInt(0, emojisMap.length - 1)];
  };

  return /*#__PURE__*/_react.default.createElement(_core.Typography, {
    component: 'span'
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.root
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.loading
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.logo
  }, /*#__PURE__*/_react.default.createElement("strong", null, "\u043C\u0430\u0432\u043A\u0430 "), "\u0437\u043D\u043E"), /*#__PURE__*/_react.default.createElement("div", {
    style: {
      marginTop: '50px'
    }
  }, Emoji()))));
};

exports.LoadingScreen = LoadingScreen;
var _default = LoadingScreen;
exports.default = _default;