"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.SongList = void 0;

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _List = _interopRequireDefault(require("@material-ui/core/List"));

var _SongListItem = _interopRequireDefault(require("subfirelib/browsers/songs/SongListItem"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _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; }; return _extends.apply(this, arguments); }

const SongList = props => {
  const SongComponent = _SongListItem.default;
  const {
    style,
    classes,
    className,
    current,
    component = 'div',
    songs,
    coverSize = 22,
    songItemProperties,
    getCoverArtURL
  } = props;
  return /*#__PURE__*/_react.default.createElement(_List.default, {
    component: component,
    style: style,
    classes: classes,
    className: className
  }, songs.map((s, i) => {
    const song = { ...s,
      coverArtUrl: getCoverArtURL(s.id, coverSize),
      coverSize,
      idx: i
    };
    return /*#__PURE__*/_react.default.createElement(SongComponent, _extends({
      key: i
    }, songItemProperties, {
      song: song,
      isCurrent: song.id === (current === null || current === void 0 ? void 0 : current.id)
    }));
  }));
};

exports.SongList = SongList;
SongList.propTypes = {
  current: _propTypes.default.object,
  style: _propTypes.default.string,
  classes: _propTypes.default.string,
  className: _propTypes.default.string,
  component: _propTypes.default.any,
  coverSize: _propTypes.default.number,
  songs: _propTypes.default.array,
  songItemProperties: _propTypes.default.object,
  getCoverArtURL: _propTypes.default.func
};
var _default = SongList;
exports.default = _default;