"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _styles = require("@material-ui/core/styles");
var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
var _Divider = _interopRequireDefault(require("./DataDisplay/Divider"));
var _dividerProps = _interopRequireDefault(require("./DataDisplay/dividerProps"));
var _Icon = _interopRequireDefault(require("./DataDisplay/Icon"));
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
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); }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var useMenuStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    menuItem: {
      fontFamily: theme.typography.fontFamily,
      textTransform: "none",
      color: theme.palette.text.primary,
      borderRadius: 0,
      "&:hover": {
        borderRadius: 0,
        boxShadow: "none",
        backgroundColor: theme.palette.primary.light
      },
      "&:focus, &:active, &.Mui-focusVisible": {
        borderRadius: 0,
        boxShadow: "none",
        outline: "none"
      }
    },
    menu: {
      border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.primary.main)
    },
    arrowIcon: {
      width: theme.spacing(1),
      height: theme.spacing(1)
    }
  };
});
var StyledMenu = function StyledMenu(props) {
  var classes = useMenuStyles();
  return /*#__PURE__*/_react.default.createElement(_Menu.default, _extends({
    elevation: 0,
    getContentAnchorEl: null,
    anchorOrigin: {
      vertical: "bottom",
      horizontal: "left"
    },
    transformOrigin: {
      vertical: "top",
      horizontal: "left"
    },
    classes: {
      paper: classes.menu
    }
  }, props));
};
__signature__(StyledMenu, "useMenuStyles{classes}", function () {
  return [useMenuStyles];
});
__signature__(StyledMenu, "useMenuStyles{classes}", function () {
  return [useMenuStyles];
});
var MenuButton = function MenuButton(_ref) {
  var _options$every;
  var options = _ref.options,
    label = _ref.label;
  var _React$useState = _react.default.useState(null),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    anchorEl = _React$useState2[0],
    setAnchorEl = _React$useState2[1];
  var classes = useMenuStyles();
  var handleClick = function handleClick(event) {
    setAnchorEl(event.currentTarget);
  };
  var handleClose = function handleClose() {
    setAnchorEl(null);
  };
  var dividerProps = new _dividerProps.default();
  dividerProps.set(_dividerProps.default.propNames.light, true);
  dividerProps.set(_dividerProps.default.propNames.variant, "middle");
  var allDisabled = (_options$every = options == null ? void 0 : options.every(function (o) {
    return o.disabled;
  })) != null ? _options$every : true;
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
    "aria-haspopup": "true",
    variant: "outlined",
    color: "primary",
    disabled: allDisabled,
    onClick: handleClick,
    endIcon: /*#__PURE__*/_react.default.createElement(_Icon.default, {
      id: "chevron-down",
      className: classes.arrowIcon
    })
  }, label), /*#__PURE__*/_react.default.createElement(StyledMenu, {
    anchorEl: anchorEl,
    open: Boolean(anchorEl),
    onClose: handleClose
  }, options == null ? void 0 : options.map(function (_ref2, index) {
    var key = _ref2.key,
      component = _ref2.component,
      disabled = _ref2.disabled,
      action = _ref2.action;
    return /*#__PURE__*/_react.default.createElement("div", {
      key: key
    }, /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
      onClick: function onClick() {
        handleClose();
        action == null || action();
      },
      disabled: disabled,
      classes: {
        root: classes.menuItem
      }
    }, component), index < options.length - 1 && /*#__PURE__*/_react.default.createElement(_Divider.default, {
      dividerProps: dividerProps
    }));
  })));
};
__signature__(MenuButton, "useState{[anchorEl, setAnchorEl](null)}\nuseMenuStyles{classes}", function () {
  return [useMenuStyles];
});
__signature__(MenuButton, "useState{[anchorEl, setAnchorEl](null)}\nuseMenuStyles{classes}", function () {
  return [useMenuStyles];
});
var _default = MenuButton;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useMenuStyles, "useMenuStyles", "/home/vsts/work/1/s/src/components/MaterialUI/MenuButtons.js");
  reactHotLoader.register(StyledMenu, "StyledMenu", "/home/vsts/work/1/s/src/components/MaterialUI/MenuButtons.js");
  reactHotLoader.register(MenuButton, "MenuButton", "/home/vsts/work/1/s/src/components/MaterialUI/MenuButtons.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/MenuButtons.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useMenuStyles, "useMenuStyles", "/home/vsts/work/1/s/src/components/MaterialUI/MenuButtons.js");
  reactHotLoader.register(StyledMenu, "StyledMenu", "/home/vsts/work/1/s/src/components/MaterialUI/MenuButtons.js");
  reactHotLoader.register(MenuButton, "MenuButton", "/home/vsts/work/1/s/src/components/MaterialUI/MenuButtons.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/MenuButtons.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();