var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { mapToCssModules, omit, pick, TransitionPropTypeKeys, TransitionTimeouts, tagPropType } from './Shared/helper.js';
import CEmbedObject from './CEmbedObject';

//component - CoreUI / CEmbed

var CEmbed = function CEmbed(props) {
  var Tag = props.tag,
      className = props.className,
      cssModule = props.cssModule,
      custom = props.custom,
      innerRef = props.innerRef,
      ratio = props.ratio,
      type = props.type,
      src = props.src,
      objectClassName = props.objectClassName,
      objectProps = props.objectProps,
      attributes = _objectWithoutProperties(props, ['tag', 'className', 'cssModule', 'custom', 'innerRef', 'ratio', 'type', 'src', 'objectClassName', 'objectProps']);

  //render

  var classes = mapToCssModules(classNames(className, ratio ? 'embed-responsive-' + ratio : null, 'embed-responsive'), cssModule);

  var objectClasses = mapToCssModules(classNames(objectClassName), cssModule);

  if (!custom) {
    return React.createElement(
      Tag,
      _extends({ className: classes }, attributes, { ref: innerRef }),
      React.createElement(CEmbedObject, _extends({}, objectProps, { className: objectClasses, type: type, src: src }))
    );
  }

  return React.createElement(Tag, _extends({ className: classes }, attributes, { ref: innerRef }));
};

CEmbed.propTypes = process.env.NODE_ENV !== "production" ? {
  tag: tagPropType,
  className: PropTypes.string,
  cssModule: PropTypes.object,
  custom: PropTypes.bool,
  //
  innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
  ratio: PropTypes.string,
  objectClassName: PropTypes.string,
  objectProps: PropTypes.object,
  ///
  type: PropTypes.string,
  src: PropTypes.string
} : {};

CEmbed.defaultProps = {
  tag: 'span',
  ratio: '16by9',
  type: 'iframe'
};

export default CEmbed;