"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = BlockSelector;
require("core-js/modules/es.array.flat.js");
require("core-js/modules/es.array.unscopables.flat.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/web.dom-collections.iterator.js");
var _styleModule = _interopRequireDefault(require("./style.module.css"));
var _ontouchcog = require("../assets/blocks/ontouchcog.svg");
var _forward = require("../assets/blocks/forward.svg");
var _backward = require("../assets/blocks/backward.svg");
var _jump = require("../assets/blocks/jump.svg");
var _carousel = _interopRequireDefault(require("./carousel"));
var _wheelFrame = _interopRequireDefault(require("./wheel-frame"));
var _react = require("react");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const repeat = (n, array) => {
  /* Repeats every element in the array until the array length = n */
  return Array(n).fill(array).flat().slice(0, n);
};
const posterItems = repeat(12, [{
  icon: _forward.ReactComponent,
  block: "moveforward",
  execute: async () => true
}, {
  icon: _backward.ReactComponent,
  block: "movebackward",
  execute: async () => true
}, {
  icon: _jump.ReactComponent,
  block: "jump",
  execute: async () => true
}]);
const staticBlockItems = repeat(12, [{
  icon: _ontouchcog.ReactComponent,
  block: "ontouchcog",
  execute: async () => true
}]);
function BlockSelector(_ref) {
  let {
    gameRef
  } = _ref;
  const [hasBeenInteracted, setHasBeenInteracted] = (0, _react.useState)(false);
  const onBlockChange = item => {
    if (!gameRef.current) return;
    const scene = gameRef.current.scene;
    if (!scene) return;
    scene.currentlySectedBlock = item;
  };
  const clickHandler = () => {
    setHasBeenInteracted(true);
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: [_styleModule.default.blockSelector, hasBeenInteracted ? "" : _styleModule.default.uninteracted].join(" "),
    onClick: clickHandler,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: _styleModule.default.carouselContainer,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_wheelFrame.default, {
        Carusel: _carousel.default,
        onFrontPosterChange: item => {},
        posterItems: staticBlockItems,
        isStatic: true
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: _styleModule.default.carouselContainer,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_wheelFrame.default, {
        Carusel: _carousel.default,
        onFrontPosterChange: onBlockChange,
        posterItems: posterItems
      })
    })]
  });
}