"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");

var _Loading = _interopRequireDefault(require("../../components/Loading"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

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 SplashPage = function SplashPage() {
  var _useSelector = (0, _reactRedux.useSelector)(function (state) {
    return {
      loading: state.rom.main.loading
    };
  }),
      loading = _useSelector.loading;

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

  var dispatch = (0, _reactRedux.useDispatch)();
  var onToggleSplash = (0, _react.useCallback)(function (e) {
    dispatch((0, _main.toggleSplash)());
  }, [dispatch]);

  var onPreAssessment = function onPreAssessment() {
    dispatch((0, _main.goToAssessment)());
  };

  var onToggleTutorial = (0, _react.useCallback)(function (e) {
    dispatch((0, _main.toggleTutorial)(true));
  }, [dispatch]);

  var onWeeklyAssessment = function onWeeklyAssessment() {
    dispatch((0, _main.goToWeeklyAssessment)());
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "splash " + (close ? 'closed' : '')
  }, loading ? /*#__PURE__*/_react["default"].createElement(_Loading["default"], null) : /*#__PURE__*/_react["default"].createElement("div", {
    className: "container"
  }, /*#__PURE__*/_react["default"].createElement("h2", {
    className: "splash-subtitle"
  }, "What would you like to do?"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "splash-actions"
  }, /*#__PURE__*/_react["default"].createElement("button", {
    className: "btn-outline",
    onClick: onToggleTutorial
  }, "TUTORIAL"), /*#__PURE__*/_react["default"].createElement("button", {
    className: "btn-outline",
    onClick: onPreAssessment
  }, "PAIN-Assessment")), /*#__PURE__*/_react["default"].createElement("button", {
    className: "btn-solid-green",
    onClick: onToggleSplash
  }, "Skip")));
};

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

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