"use strict";

exports.__esModule = true;
exports.default = void 0;

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

var _hooks = require("subfirelib/hooks");

var _reactRouterDom = require("react-router-dom");

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

var _BottomNavigation = _interopRequireDefault(require("@material-ui/core/BottomNavigation"));

var _BottomNavigationAction = _interopRequireDefault(require("@material-ui/core/BottomNavigationAction"));

var _icons = require("@material-ui/icons");

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

/* eslint react/prop-types: 0 */
// retired
const styles = {
  root: {
    width: '100%',
    position: 'relative',
    top: '0',
    backgroundColor: '#37474F'
  },
  icon: {
    color: '#FFF8E1'
  },
  narrow: {
    minWidth: 0
  }
};

function NavFooter(props) {
  const replaceValues = ['/radio', '/playlists/normal', '/playlists/all', '/artists', '/indexes', '/albums', '/bookmarks', '/podcasts'];
  const {
    classes
  } = props;
  const location = (0, _reactRouterDom.useLocation)();
  const history = (0, _reactRouterDom.useHistory)();
  const {
    stations
  } = (0, _hooks.usePlaylistsScanner)();

  const replaceOrPush = () => {
    let value = location.pathname;
    if (replaceValues.indexOf(value) > -1) return 'replace';
    return 'push';
  };

  const handleChange = (event, value) => {
    history[replaceOrPush()](value);
  };

  const handlePLClick = () => {
    if (location.pathname === '/playlists/normal') {
      history.replace('/playlists/all');
    }

    if (location.pathname === '/playlists/all') {
      history.replace('/playlists/normal');
    }
  };

  let value = location.pathname;
  let plValue = '/playlists/normal';
  let plLabel = 'Playlists';

  if (value === '/playlists/normal') {
    plValue = value = '/playlists/normal';
  }

  if (value === '/playlists/all') {
    plValue = value = '/playlists/all';
    plLabel = 'All Lists';
  }

  if (value.startsWith('/artist')) value = '/artists';
  if (value.startsWith('/directory')) value = '/indexes';
  let radio = null;
  if (stations.length) radio = /*#__PURE__*/_react.default.createElement(_BottomNavigationAction.default, {
    className: classes.icon,
    label: "Radio",
    value: "/radio",
    icon: /*#__PURE__*/_react.default.createElement(_icons.Radio, null)
  });
  return /*#__PURE__*/_react.default.createElement(_BottomNavigation.default, {
    value: value,
    onChange: handleChange,
    className: classes.root
  }, radio, /*#__PURE__*/_react.default.createElement(_BottomNavigationAction.default, {
    className: classes.icon,
    label: plLabel,
    value: plValue,
    onClick: handlePLClick,
    icon: /*#__PURE__*/_react.default.createElement(_icons.QueueMusic, null)
  }), /*#__PURE__*/_react.default.createElement(_BottomNavigationAction.default, {
    className: classes.icon,
    label: "Folders",
    value: "/indexes",
    icon: /*#__PURE__*/_react.default.createElement(_icons.FolderSpecial, null)
  }), /*#__PURE__*/_react.default.createElement(_BottomNavigationAction.default, {
    className: classes.icon,
    label: "Artists",
    value: "/artists",
    icon: /*#__PURE__*/_react.default.createElement(_icons.People, null)
  }), /*#__PURE__*/_react.default.createElement(_BottomNavigationAction.default, {
    className: classes.icon,
    label: "Albums",
    value: "/albums",
    icon: /*#__PURE__*/_react.default.createElement(_icons.Album, null)
  }));
}

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

exports.default = _default;