import _extends from "@babel/runtime/helpers/esm/extends";
import React from 'react';
import { toProps } from '../core';
import EventListener from '../event/EventListener';

function toSoundProps(_ref) {
  var autoplay = _ref.autoplay,
      loop = _ref.loop,
      on = _ref.on,
      src = _ref.src,
      volume = _ref.volume;
  return {
    autoplay: autoplay,
    loop: loop,
    on: on,
    src: src,
    volume: volume
  };
}
/**
 * The sound primitive wraps the [sound component](https://aframe.io/docs/1.3.0/components/sound.html).
 *
 * @see https://aframe.io/docs/1.3.0/primitives/a-sound.html
 *
 * @example
 * ```tsx
 * <Scene>
 *   <Sound
 *     src="src: url(click.mp3)"
 *     autoplay={true}
 *     position={{ x: 0, y: 2, z: 5 }}
 *   />
 * </Scene>
 * ```
 */


export var Sound = function Sound(props) {
  var volumeKeys = ['autoplay', 'loop', 'on', 'src', 'volume'];
  var children = props.children;
  return /*#__PURE__*/React.createElement(EventListener, _extends({
    primitive: "a-sound"
  }, toProps(props, volumeKeys), toSoundProps(props)), children);
};