"use strict";

require("core-js/modules/web.dom-collections.iterator.js");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Loader = Loader;

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

var _drei = require("@react-three/drei");

var _styledComponents = _interopRequireWildcard(require("styled-components"));

var _reactLottie = _interopRequireDefault(require("react-lottie"));

var _LoadingScreen = _interopRequireDefault(require("./LoadingScreen"));

var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;

const _excluded = ["modelConfig", "color", "isOpen", "visibleUI"];

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; }

function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

const defaultOptions = {
  loop: true,
  autoplay: true
};

function Loader(_ref) {
  let {
    modelConfig,
    color,
    isOpen,
    visibleUI
  } = _ref,
      props = _objectWithoutProperties(_ref, _excluded);

  const {
    active,
    progress
  } = (0, _drei.useProgress)();
  return /*#__PURE__*/_react.default.createElement("group", {
    name: "hudGroup"
  }, visibleUI !== "profile" && /*#__PURE__*/_react.default.createElement(_drei.Html, {
    style: {
      width: '100%',
      height: '100%'
    },
    wrapperClass: "loadingScreen"
  }, /*#__PURE__*/_react.default.createElement(LoadBox, {
    bg: props === null || props === void 0 ? void 0 : props.bg
  }, /*#__PURE__*/_react.default.createElement(_reactLottie.default, {
    options: _objectSpread(_objectSpread({}, defaultOptions), {}, {
      animationData: _LoadingScreen.default
    }),
    height: window.height / 10,
    width: window.width / 10,
    style: {
      margin: "none"
    }
  }), /*#__PURE__*/_react.default.createElement(TextLoad, {
    color: color
  }, "TELEPORT TO SCENES ", Math.floor(progress), "%"))));
}

const PlayerImg = _styledComponents.default.img(_templateObject || (_templateObject = _taggedTemplateLiteral(["\nposition: fixed;\nbottom:30%;\n"])));

const LoadBox = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\nposition: absolute;\ntop: 0;\nleft: 0;\nright: 0;\nbottom: 0;\nbackground-position: center;\nbackground-repeat: no-repeat;\nbackground-size: cover;\nbackground-color: #fff;\ndisplay: flex;\njustify-content: center;\nalign-items: center;\nflex-direction: column;\nfont-family: sans-serif;\nz-index:99;\n", ""])), props => props.bg && (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["background-image:url('", "');"])), props.bg));

const TextLoad = _styledComponents.default.h1(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\npadding:10px;\nfont-family: \"DB HelvethaicaMon X Reg\";\ncolor:#000;\nfont-size: 5vw;\n", ""])), props => props.color && (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["color:", ";"])), props.color));

const TextLoadAnimate = _styledComponents.default.h1(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\npadding:10px;\nfont-family: 'db_bold';\ncolor:#000;\nfont-size: 3vw;\nanimation: breathing;\nanimation-duration: 3s;\nanimation-timing-function: ease-in-and-out;\nanimation-delay: 0;\nanimation-iteration-count: infinite;\nanimation-direction: alternate;\n\n@-webkit-keyframes breathing {\n  0% {\n    -webkit-transform: scale(0.9);\n    transform: scale(0.9);\n  }\n\n  25% {\n    -webkit-transform: scale(1);\n    transform: scale(1);\n  }\n\n  60% {\n    -webkit-transform: scale(0.9);\n    transform: scale(0.9);\n  }\n\n  100% {\n    -webkit-transform: scale(0.9);\n    transform: scale(0.9);\n  }\n}\n\n@keyframes breathing {\n  0% {\n    -webkit-transform: scale(0.8);\n    -ms-transform: scale(0.8);\n    transform: scale(0.8);\n  }\n\n  100% {\n    -webkit-transform: scale(1);\n    -ms-transform: scale(1);\n    transform: scale(1);\n  }\n}\n", ""])), props => props.color && (0, _styledComponents.css)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["color:", ";"])), props.color));