"use strict";

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

exports.__esModule = true;
exports.Box = void 0;

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

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

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

var _components = require("../components");

var _core = require("../core");

var _EventListener = _interopRequireDefault(require("../event/EventListener"));

var _excluded = ["children", "onClick"];

function toBoxProps(_ref) {
  var ambientOcclusionMap = _ref.ambientOcclusionMap,
      ambientOcclusionMapIntensity = _ref.ambientOcclusionMapIntensity,
      ambientOcclusionTextureOffset = _ref.ambientOcclusionTextureOffset,
      ambientOcclusionTextureRepeat = _ref.ambientOcclusionTextureRepeat,
      color = _ref.color,
      depth = _ref.depth,
      displacementBias = _ref.displacementBias,
      displacementMap = _ref.displacementMap,
      displacementScale = _ref.displacementScale,
      displacementTextureOffset = _ref.displacementTextureOffset,
      displacementTextureRepeat = _ref.displacementTextureRepeat,
      envMap = _ref.envMap,
      fog = _ref.fog,
      height = _ref.height,
      metalness = _ref.metalness,
      normalMap = _ref.normalMap,
      normalScale = _ref.normalScale,
      normalTextureOffset = _ref.normalTextureOffset,
      normalTextureRepeat = _ref.normalTextureRepeat,
      repeat = _ref.repeat,
      roughness = _ref.roughness,
      segmentsDepth = _ref.segmentsDepth,
      segmentsHeight = _ref.segmentsHeight,
      segmentsWidth = _ref.segmentsWidth,
      sphericalEnvMap = _ref.sphericalEnvMap,
      src = _ref.src,
      width = _ref.width,
      wireframe = _ref.wireframe,
      wireframeLinewidth = _ref.wireframeLinewidth;
  return {
    'ambient-occlusion-map': ambientOcclusionMap,
    'ambient-occlusion-map-intensity': ambientOcclusionMapIntensity,
    'ambient-occlusion-texture-offset': ambientOcclusionTextureOffset && new _components.Vec2(ambientOcclusionTextureOffset).toString(),
    'ambient-occlusion-texture-repeat': ambientOcclusionTextureRepeat && new _components.Vec2(ambientOcclusionTextureRepeat).toString(),
    color: color,
    depth: depth,
    'displacement-bias': displacementBias,
    'displacement-map': displacementMap,
    'displacement-scale': displacementScale,
    'displacement-texture-offset': displacementTextureOffset && new _components.Vec2(displacementTextureOffset).toString(),
    'displacement-texture-repeat': displacementTextureRepeat && new _components.Vec2(displacementTextureRepeat).toString(),
    'env-map': envMap,
    fog: fog,
    height: height,
    metalness: metalness,
    'normal-map': normalMap,
    'normal-scale': normalScale,
    'normal-texture-offset': normalTextureOffset && new _components.Vec2(normalTextureOffset).toString(),
    'normal-texture-repeat': normalTextureRepeat && new _components.Vec2(normalTextureRepeat).toString(),
    repeat: repeat && new _components.Vec2(repeat).toString(),
    roughness: roughness,
    'segments-depth': segmentsDepth,
    'segments-height': segmentsHeight,
    'segments-width': segmentsWidth,
    'spherical-env-map': sphericalEnvMap,
    src: src,
    width: width,
    wireframe: wireframe,
    'wireframe-linewidth': wireframeLinewidth
  };
}
/**
 * The box primitive creates shapes such as boxes, cubes, or walls.
 *
 * @see https://aframe.io/docs/1.3.0/primitives/a-box.html
 *
 * @example
 *
 * ```tsx
 * <Assets>
 *   <img id="texture" src="texture.png" />
 * </Assets>
 *
 * // Basic box.
 * <Box color="tomato" depth={2} height={4} width={0.5} />
 *
 * // Textured box.
 * <Box src="#texture" />
 * ```
 */


var Box = function Box(props) {
  var boxProps = ['ambientOcclusionMap', 'ambientOcclusionMapIntensity', 'ambientOcclusionTextureOffset', 'ambientOcclusionTextureRepeat', 'color', 'depth', 'displacementBias', 'displacementMap', 'displacementScale', 'displacementTextureOffset', 'displacementTextureRepeat', 'envMap', 'fog', 'height', 'metalness', 'normalMap', 'normalScale', 'normalTextureOffset', 'normalTextureRepeat', 'repeat', 'roughness', 'segmentsDepth', 'segmentsHeight', 'segmentsWidth', 'sphericalEnvMap', 'src', 'width', 'wireframe', 'wireframeLinewidth'];
  var children = props.children,
      onClick = props.onClick,
      restProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
  return /*#__PURE__*/_react.default.createElement(_EventListener.default, (0, _extends2.default)({
    primitive: "a-box",
    events: {
      click: function click() {
        return onClick && onClick();
      }
    }
  }, (0, _core.toProps)(restProps, boxProps), toBoxProps(restProps)), children);
};

exports.Box = Box;