"use strict";

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

exports.__esModule = true;
exports.default = void 0;
exports.toProps = toProps;

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

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

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

var _propParser = _interopRequireDefault(require("../utils/propParser"));

function toProps(props, removalKeys) {
  var defaultKeys = ['id', 'className', 'children', 'animation', 'camera', 'cursor', 'daydreamControls', 'gearvrControls', 'genericTrackedControllerControls', 'geometry', 'gltfModel', 'handControls', 'handTrackingControls', 'hpMixedRealityControls', 'laserControls', 'layer', 'light', 'line', 'link', 'lookControls', 'magicleapControls', 'material', 'objModel', 'oculusGoControls', 'oculusTouchControls', 'position', 'raycaster', 'rotation', 'scale', 'shadow', 'sound', 'text', 'trackedControlsWebVR', 'trackedControlsWebXR', 'trackedControls', 'valveIndexControls', 'visible', 'viveControls', 'viveFocusControls', 'wasdControls', 'windowsMotionControls'];
  var animationKeys = Object.keys(props).filter(function (key) {
    return key.includes('animation__');
  });
  var animationProps = animationKeys.reduce(function (acc, key) {
    var _ref;

    return (0, _extends3.default)({}, acc, props[key] && (_ref = {}, _ref[key] = new _components.Animation(props[key]).toString(), _ref));
  }, {});
  var extraKeys = Object.keys(props).filter(function (key) {
    return !defaultKeys.includes(key) && !key.includes('animation__');
  });
  var extraProps = (removalKeys ? extraKeys.filter(function (key) {
    return !removalKeys.includes(key);
  }) : extraKeys).reduce(function (acc, key) {
    var _extends2;

    return (0, _extends3.default)({}, acc, (_extends2 = {}, _extends2[key] = (0, _propParser.default)(props[key]), _extends2));
  }, {});
  var id = props.id,
      className = props.className,
      animation = props.animation,
      camera = props.camera,
      cursor = props.cursor,
      daydreamControls = props.daydreamControls,
      gearvrControls = props.gearvrControls,
      genericTrackedControllerControls = props.genericTrackedControllerControls,
      geometry = props.geometry,
      gltfModel = props.gltfModel,
      handControls = props.handControls,
      handTrackingControls = props.handTrackingControls,
      hpMixedRealityControls = props.hpMixedRealityControls,
      laserControls = props.laserControls,
      layer = props.layer,
      light = props.light,
      line = props.line,
      link = props.link,
      lookControls = props.lookControls,
      magicleapControls = props.magicleapControls,
      material = props.material,
      objModel = props.objModel,
      oculusGoControls = props.oculusGoControls,
      oculusTouchControls = props.oculusTouchControls,
      position = props.position,
      raycaster = props.raycaster,
      rotation = props.rotation,
      scale = props.scale,
      shadow = props.shadow,
      sound = props.sound,
      text = props.text,
      trackedControlsWebVR = props.trackedControlsWebVR,
      trackedControlsWebXR = props.trackedControlsWebXR,
      trackedControls = props.trackedControls,
      valveIndexControls = props.valveIndexControls,
      visible = props.visible,
      viveControls = props.viveControls,
      viveFocusControls = props.viveFocusControls,
      wasdControls = props.wasdControls,
      windowsMotionControls = props.windowsMotionControls;
  return (0, _extends3.default)({}, id && {
    id: id
  }, className && {
    class: className
  }, animation && {
    animation: new _components.Animation(animation).toString()
  }, camera && {
    camera: new _components.Camera(camera).toString()
  }, cursor && {
    cursor: new _components.Cursor(cursor).toString()
  }, daydreamControls && {
    'daydream-controls': new _components.DaydreamControls(daydreamControls).toString()
  }, gearvrControls && {
    'gearvr-controls': new _components.GearvrControls(gearvrControls).toString()
  }, genericTrackedControllerControls && {
    'generic-tracked-controller-controls': new _components.GenericTrackedControllerControls(genericTrackedControllerControls).toString()
  }, geometry && {
    geometry: new _components.Geometry(geometry).toString()
  }, gltfModel && {
    'gltf-model': new _components.GLTFModel(gltfModel).toString()
  }, handControls && {
    'hand-controls': new _components.HandControls(handControls).toString()
  }, handTrackingControls && {
    'hand-tracking-controls': new _components.HandTrackingControls(handTrackingControls).toString()
  }, hpMixedRealityControls && {
    'hp-mixed-reality-controls': new _components.HpMixedRealityControls(hpMixedRealityControls).toString()
  }, laserControls && {
    'laser-controls': new _components.LaserControls(laserControls).toString()
  }, layer && {
    layer: new _components.Layer(layer).toString()
  }, light && {
    light: new _components.Light(light).toString()
  }, line && {
    line: new _components.Line(line).toString()
  }, link && {
    link: new _components.Link(link).toString()
  }, lookControls && {
    'look-controls': new _components.LookControls(lookControls).toString()
  }, magicleapControls && {
    'magicleap-controls': new _components.MagicleapControls(magicleapControls).toString()
  }, material && {
    material: new _components.Material(material).toString()
  }, objModel && {
    'obj-model': new _components.ObjModel(objModel).toString()
  }, oculusGoControls && {
    'oculus-go-controls': new _components.OculusGoControls(oculusGoControls).toString()
  }, oculusTouchControls && {
    'oculus-touch-controls': new _components.OculusTouchControls(oculusTouchControls).toString()
  }, position && {
    position: new _components.Position(position).toString()
  }, raycaster && {
    raycaster: new _components.Raycaster(raycaster).toString()
  }, rotation && {
    rotation: new _components.Rotation(rotation).toString()
  }, scale && {
    scale: new _components.Scale(scale).toString()
  }, shadow && {
    shadow: new _components.Shadow(shadow).toString()
  }, sound && {
    sound: new _components.Sound(sound).toString()
  }, text && {
    text: new _components.Text(text).toString()
  }, trackedControlsWebVR && {
    'tracked-controls-webvr': new _components.TrackedControlsWebVR(trackedControlsWebVR).toString()
  }, trackedControlsWebXR && {
    'tracked-controls-webxr': new _components.TrackedControlsWebXR(trackedControlsWebXR).toString()
  }, trackedControls && {
    'tracked-controls': new _components.TrackedControls(trackedControls).toString()
  }, valveIndexControls && {
    'valve-index-controls': new _components.ValveIndexControls(valveIndexControls).toString()
  }, {
    visible: visible !== undefined ? new _components.Visible(visible).toString() : undefined
  }, viveControls && {
    'vive-controls': new _components.ViveControls(viveControls).toString()
  }, viveFocusControls && {
    'vive-focus-controls': new _components.ViveFocusControls(viveFocusControls).toString()
  }, wasdControls && {
    'wasd-controls': new _components.WASDControls(wasdControls).toString()
  }, windowsMotionControls && {
    'windows-motion-controls': new _components.WindowsMotionControls(windowsMotionControls).toString()
  }, animationProps, extraProps);
}
/**
 * A-Frame represents an entity via the `<a-entity>` element. As defined in the [entity-component-system pattern](https://aframe.io/docs/1.3.0/introduction/entity-component-system.html),
 * entities are placeholder objects to which we plug in components to provide them
 * appearance, behavior, and functionality.
 *
 * In A-Frame, entities are inherently attached with the
 * [position](https://aframe.io/docs/1.3.0/components/position.html),
 * [rotation](https://aframe.io/docs/1.3.0/components/rotation.html), and
 * [scale](https://aframe.io/docs/1.3.0/components/scale.html) components.
 *
 * @see https://aframe.io/docs/1.3.0/core/entity.html
 */


var Entity = function Entity(props) {
  var children = props.children;
  return /*#__PURE__*/_react.default.createElement("a-entity", toProps(props), children);
};

var _default = Entity;
exports.default = _default;