import _omit from "lodash/fp/omit";
import _find from "lodash/fp/find";
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import ResourceMiniature from '../../atom/resource-miniature';
import ResourcePlayer from '../../molecule/resource-player';
import style from './style.css';
const hideResources = resources => !resources || resources.length < 2;
const Resources = ({
  resources,
  className
}) => {
  if (hideResources(resources)) {
    return null;
  }
  return /*#__PURE__*/React.createElement("div", {
    className: style.resourcesList
  }, resources.map(resource => /*#__PURE__*/React.createElement(ResourceMiniature, _extends({}, _omit('ref', resource), {
    key: resource._id
  }))));
};
Resources.propTypes = process.env.NODE_ENV !== "production" ? {
  resources: PropTypes.arrayOf(PropTypes.shape(_omit('ref', ResourceMiniature.propTypes))),
  className: PropTypes.string
} : {};
const ResourceBrowser = props => {
  const {
    resources,
    className,
    overlay
  } = props;
  const selectedResource = _find(({
    selected
  }) => selected, resources);
  return /*#__PURE__*/React.createElement("div", {
    "data-name": "resourceBrowser",
    className: classnames(style.defaultStyle, className)
  }, /*#__PURE__*/React.createElement("div", {
    className: style.resourcePlayerWrapper
  }, selectedResource ? /*#__PURE__*/React.createElement(ResourcePlayer, {
    overlay: overlay,
    className: style.resourcePlayer,
    resource: selectedResource
  }) : null), /*#__PURE__*/React.createElement(Resources, {
    resources: resources,
    className: className
  }));
};
ResourceBrowser.propTypes = process.env.NODE_ENV !== "production" ? {
  className: PropTypes.string,
  resources: Resources.propTypes.resources,
  overlay: ResourcePlayer.propTypes.overlay
} : {};
export default ResourceBrowser;
//# sourceMappingURL=index.js.map