"use strict";

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

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

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

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

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

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

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

function toVideoProps(_ref) {
  var color = _ref.color,
      height = _ref.height,
      metalness = _ref.metalness,
      opacity = _ref.opacity,
      repeat = _ref.repeat,
      roughness = _ref.roughness,
      segmentsHeight = _ref.segmentsHeight,
      segmentsWidth = _ref.segmentsWidth,
      shader = _ref.shader,
      side = _ref.side,
      src = _ref.src,
      transparent = _ref.transparent,
      width = _ref.width;
  return {
    color: color,
    height: height,
    metalness: metalness,
    opacity: opacity,
    repeat: repeat && new _components.Vec2(repeat).toString(),
    roughness: roughness,
    'segments-height': segmentsHeight,
    'segments-width': segmentsWidth,
    shader: shader,
    side: side,
    src: src,
    transparent: transparent,
    width: width
  };
}
/**
 * The video primitive plays a video as a texture on a flat plane.
 *
 * @see https://aframe.io/docs/1.3.0/primitives/a-video.html
 *
 * @example
 * ```tsx
 * <Scene>
 *   <Assets>
 *     <video
 *       id="penguin-sledding"
 *       autoplay
 *       loop="true"
 *       src="penguin-sledding.mp4"
 *     />
 *   </Assets>
 *
 *   // Using the asset management system.
 *   <Video
 *     src="#penguin-sledding"
 *     width={16}
 *     height={9}
 *     position={{ x: 0, y: 0, z: -20 }}
 *   />
 *
 *   // Defining the URL inline. Not recommended but more comfortable for web developers.
 *   <Video
 *     src="airbending.mp4"
 *   />
 * </Scene>
 * ```
 */


var Video = function Video(props) {
  var videoKeys = ['color', 'height', 'metalness', 'opacity', 'repeat', 'roughness', 'segmentsHeight', 'segmentsWidth', 'shader', 'side', 'src', 'transparent', 'width'];
  var children = props.children;
  return /*#__PURE__*/_react.default.createElement(_EventListener.default, (0, _extends2.default)({
    primitive: "a-video"
  }, (0, _core.toProps)(props, videoKeys), toVideoProps(props)), children);
};

exports.Video = Video;