"use strict";

exports.__esModule = true;
exports["default"] = void 0;

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

var _reactRedux = require("react-redux");

var _main = require("../../store/rom/main");

require("./style.css");

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 Tutorial = function Tutorial(props) {
  var videoRef = (0, _react.useRef)(null);

  var _useState = (0, _react.useState)(true),
      close = _useState[0],
      setClose = _useState[1];

  var dispatch = (0, _reactRedux.useDispatch)();

  var onSkipTutorial = function onSkipTutorial() {
    setClose(false);
    dispatch((0, _main.toggleTutorial)(false));
    localStorage.setItem('watchedTutorial', true);
  };

  useEffect(function () {
    videoRef.current.currentTime = 0;
    videoRef.current.load();

    videoRef.current.onended = function () {
      props.onSkipTutorial();
    };
  }, [props.onSkipTutorial]);
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "tutorial " + (close ? 'closed' : '')
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "tutorial-container"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "tutorial-video " + (close ? 'closed' : '')
  }, /*#__PURE__*/_react["default"].createElement("video", {
    id: "video",
    className: "tutorial-video",
    ref: videoRef,
    autoPlay: true,
    preload: "metadata",
    src: "https://risecxlibrary.blob.core.windows.net/coach/tutorial.mp4",
    type: "video/mp4"
  }), /*#__PURE__*/_react["default"].createElement("button", {
    className: "btn-outline",
    onClick: onSkipTutorial
  }, "SKIP TUTORIAL"))));
};

var _default = (0, _react.memo)(Tutorial);

exports["default"] = _default;
module.exports = exports.default;