"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));

var _DialogTitle = _interopRequireDefault(require("@material-ui/core/DialogTitle"));

var _DialogContentText = _interopRequireDefault(require("@material-ui/core/DialogContentText"));

var _DialogContent = _interopRequireDefault(require("@material-ui/core/DialogContent"));

var _DialogActions = _interopRequireDefault(require("@material-ui/core/DialogActions"));

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

var _Button = _interopRequireDefault(require("@material-ui/core/Button"));

var _Help = _interopRequireDefault(require("@material-ui/icons/Help"));

var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));

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

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

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var RawHelpButton = function RawHelpButton(_ref) {
  var onClick = _ref.onClick,
      classes = _ref.classes;
  return /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
    classes: {
      label: classes.icon
    },
    onClick: onClick
  }, /*#__PURE__*/_react["default"].createElement(_Help["default"], null));
};

RawHelpButton.propTypes = {
  onClick: _propTypes["default"].func,
  classes: _propTypes["default"].object.isRequired
};
var HelpButton = (0, _styles.withStyles)(function (theme) {
  return {
    icon: {
      '&:hover': {
        color: theme.palette.grey[300]
      }
    }
  };
})(RawHelpButton);
exports.HelpButton = HelpButton;

var HelpDialog = function HelpDialog(_ref2) {
  var open = _ref2.open,
      onClose = _ref2.onClose,
      children = _ref2.children,
      title = _ref2.title;
  return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
    open: open,
    onRequestClose: onClose
  }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, title), /*#__PURE__*/_react["default"].createElement(_DialogContent["default"], null, /*#__PURE__*/_react["default"].createElement(_DialogContentText["default"], null, children)), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
    onClick: onClose,
    color: "primary"
  }, "OK")));
};

exports.HelpDialog = HelpDialog;
HelpDialog.propTypes = {
  open: _propTypes["default"].bool,
  onClose: _propTypes["default"].func,
  children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired,
  title: _propTypes["default"].string.isRequired
};

var Help = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(Help, _React$Component);

  var _super = _createSuper(Help);

  function Help(props) {
    var _this;

    (0, _classCallCheck2["default"])(this, Help);
    _this = _super.call(this, props);
    _this.state = {
      open: false
    };
    return _this;
  }

  (0, _createClass2["default"])(Help, [{
    key: "render",
    value: function render() {
      var _this2 = this;

      var _this$props = this.props,
          children = _this$props.children,
          title = _this$props.title;
      return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(HelpButton, {
        color: "accent",
        onClick: function onClick() {
          return _this2.setState({
            open: true
          });
        }
      }), /*#__PURE__*/_react["default"].createElement(HelpDialog, {
        open: this.state.open,
        title: title,
        onClose: function onClose() {
          return _this2.setState({
            open: false
          });
        }
      }, children));
    }
  }]);
  return Help;
}(_react["default"].Component);

(0, _defineProperty2["default"])(Help, "propTypes", {
  children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired,
  title: _propTypes["default"].string
});
var _default = Help;
exports["default"] = _default;
//# sourceMappingURL=help.js.map