"use strict";

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

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

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

var _styles = require("@material-ui/core/styles");

var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));

var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));

var _CircularProgress = _interopRequireDefault(require("@material-ui/core/CircularProgress"));

var _HollowCard = _interopRequireDefault(require("subfirelib/ui/HollowCard"));

var _api = require("subfirelib/api");

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

// import FuzzyImageBackground from 'subfire/components/FuzzyImageBackground';
const styles = theme => ({
  card: {
    textAlign: 'center',
    color: 'black' // where is white coming from?

  },
  centerprogress: {
    height: 50,
    left: '50%',
    marginLeft: -25,
    marginTop: -50,
    position: 'absolute',
    top: '50%',
    width: 50
  }
});

const SubsonicLoadingCard = props => {
  // console.log(props);
  const {
    object,
    classes,
    top
  } = props;
  const {
    innerWidth,
    innerHeight
  } = window;
  let cellSize = innerWidth <= 600 ? innerWidth - 20 : Math.trunc(innerWidth / 2);
  cellSize = Math.min(cellSize, innerHeight - 100 - top); // load the one already loaded in the previous grid

  const artSize = innerWidth > 360 ? 170 : 164; // console.warn(object);

  const coverArt = object && (object.coverArt || object.id) ? _api.Subsonic.getCoverArtURL(object.coverArt || object.id, artSize) : _api.Subsonic.getCoverArtURL(-1, artSize);
  const loadingString = object && (object.name || object.title) ? object.name || object.title : "something. no really. we're loading something.";
  return /*#__PURE__*/_react.default.createElement("div", {
    style: {
      paddingTop: 25
    }
  }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
    container: true,
    spacing: 0
  }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
    item: true,
    sm: 3,
    xs: false
  }), /*#__PURE__*/_react.default.createElement(_Grid.default, {
    item: true,
    sm: 6,
    xs: 12
  }, /*#__PURE__*/_react.default.createElement(_HollowCard.default, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
    variant: "h4",
    className: classes.card
  }, "Loading..."), /*#__PURE__*/_react.default.createElement("div", {
    className: classes.card
  }, /*#__PURE__*/_react.default.createElement("img", {
    alt: "Loading...",
    src: coverArt,
    id: "the-loading-image",
    style: {
      width: cellSize,
      height: cellSize
    }
  }), /*#__PURE__*/_react.default.createElement(_CircularProgress.default, {
    className: classes.centerprogress,
    size: 50
  })), /*#__PURE__*/_react.default.createElement(_Typography.default, {
    variant: "h4",
    className: classes.card
  }, loadingString)))));
};
/*
<FuzzyImageBackground
  selector=".page-bg"
  image={coverArt}
  showBackground={true}
/>
*/


SubsonicLoadingCard.propTypes = {
  object: _propTypes.default.object,
  classes: _propTypes.default.any,
  top: _propTypes.default.number
};
SubsonicLoadingCard.defaultProps = {
  top: 0
};

var _default = (0, _styles.withStyles)(styles)(SubsonicLoadingCard);

exports.default = _default;