"use strict";

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

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

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

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

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

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 _react = _interopRequireDefault(require("react"));

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

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

var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));

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 ToolMenu = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(ToolMenu, _React$Component);

  var _super = _createSuper(ToolMenu);

  function ToolMenu() {
    var _this;

    (0, _classCallCheck2["default"])(this, ToolMenu);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeRadioValue", function (event) {
      var _this$props = _this.props,
          gssLineData = _this$props.gssLineData,
          onChange = _this$props.onChange;
      var oldSelectedTool = gssLineData.selectedTool;
      gssLineData.selectedTool = event.target.value;
      onChange(gssLineData, oldSelectedTool);
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "lineTypeChange", function (line, type) {
      var _this$props2 = _this.props,
          gssLineData = _this$props2.gssLineData,
          onChange = _this$props2.onChange;
      var oldSelectedTool = gssLineData.selectedTool;
      gssLineData["line".concat(line)].lineType = type;
      onChange(gssLineData, oldSelectedTool);
    });
    return _this;
  }

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

      var _this$props3 = this.props,
          classes = _this$props3.classes,
          gssLineData = _this$props3.gssLineData,
          disabled = _this$props3.disabled;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.selectLineRadioGroup
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.radioFieldOuter
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.radioFieldInner
      }, /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
        name: 'select-line-radio-buttons',
        onChange: this.onChangeRadioValue,
        value: 'lineA',
        disabled: !!disabled,
        checked: gssLineData.selectedTool === 'lineA',
        className: classes.lineTypeRadio
      }), /*#__PURE__*/_react["default"].createElement(_core.Typography, {
        className: classes.lineNameFont
      }, "Line A")), /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.radioFieldButtons
      }, gssLineData.lineA.lineType === 'Solid' ? /*#__PURE__*/_react["default"].createElement(_core.Button, {
        size: 'small',
        variant: 'contained',
        color: 'primary',
        onClick: function onClick() {
          return _this2.lineTypeChange('A', 'Solid');
        },
        className: disabled ? classes.lineTypeButtonLeftSelectedDisabled : classes.lineTypeButtonLeftSelected
      }, "\u2714 Solid") : /*#__PURE__*/_react["default"].createElement(_core.Button, {
        size: 'small',
        variant: 'contained',
        disabled: !!disabled,
        onClick: function onClick() {
          return _this2.lineTypeChange('A', 'Solid');
        },
        className: disabled ? classes.lineTypeButtonLeftUnSelectedDisabled : classes.lineTypeButtonLeftUnSelected
      }, "Solid"), gssLineData.lineA.lineType === 'Dashed' ? /*#__PURE__*/_react["default"].createElement(_core.Button, {
        size: 'small',
        variant: 'contained',
        color: 'primary',
        onClick: function onClick() {
          return _this2.lineTypeChange('A', 'Dashed');
        },
        className: disabled ? classes.lineTypeButtonRightSelectedDisabled : classes.lineTypeButtonRightSelected
      }, "\u2714 Dashed") : /*#__PURE__*/_react["default"].createElement(_core.Button, {
        size: 'small',
        variant: 'contained',
        disabled: !!disabled,
        onClick: function onClick() {
          return _this2.lineTypeChange('A', 'Dashed');
        },
        className: disabled ? classes.lineTypeButtonRightUnSelectedDisabled : classes.lineTypeButtonRightUnSelected
      }, "Dashed"))), gssLineData.numberOfLines === 2 ? /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.radioFieldOuter
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.radioFieldInner
      }, /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
        name: 'select-line-radio-buttons',
        onChange: this.onChangeRadioValue,
        value: 'lineB',
        disabled: !!disabled,
        checked: gssLineData.selectedTool === 'lineB',
        className: classes.lineTypeRadio
      }), /*#__PURE__*/_react["default"].createElement(_core.Typography, {
        className: classes.lineNameFont
      }, "Line B")), /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.radioFieldButtons
      }, gssLineData.lineB.lineType === 'Solid' ? /*#__PURE__*/_react["default"].createElement(_core.Button, {
        size: 'small',
        variant: 'contained',
        color: 'primary',
        onClick: function onClick() {
          return _this2.lineTypeChange('B', 'Solid');
        },
        className: disabled ? classes.lineTypeButtonLeftSelectedDisabled : classes.lineTypeButtonLeftSelected
      }, "\u2714 Solid") : /*#__PURE__*/_react["default"].createElement(_core.Button, {
        size: 'small',
        variant: 'contained',
        disabled: !!disabled,
        onClick: function onClick() {
          return _this2.lineTypeChange('B', 'Solid');
        },
        className: disabled ? classes.lineTypeButtonLeftUnSelectedDisabled : classes.lineTypeButtonLeftUnSelected
      }, "Solid"), gssLineData.lineB.lineType === 'Dashed' ? /*#__PURE__*/_react["default"].createElement(_core.Button, {
        size: 'small',
        variant: 'contained',
        color: 'primary',
        onClick: function onClick() {
          return _this2.lineTypeChange('B', 'Dashed');
        },
        className: disabled ? classes.lineTypeButtonRightSelectedDisabled : classes.lineTypeButtonRightSelected
      }, "\u2714 Dashed") : /*#__PURE__*/_react["default"].createElement(_core.Button, {
        size: 'small',
        variant: 'contained',
        disabled: !!disabled,
        onClick: function onClick() {
          return _this2.lineTypeChange('B', 'Dashed');
        },
        className: disabled ? classes.lineTypeButtonRightUnSelectedDisabled : classes.lineTypeButtonRightUnSelected
      }, "Dashed"))) : null, /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.radioFieldOuter
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.radioFieldInner
      }, /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
        name: 'select-line-radio-buttons',
        onChange: this.onChangeRadioValue,
        value: 'solutionSet',
        disabled: !!disabled,
        checked: gssLineData.selectedTool === 'solutionSet',
        className: classes.lineTypeRadio
      }), /*#__PURE__*/_react["default"].createElement(_core.Typography, {
        className: classes.lineNameFont
      }, "Solution Set"))));
    }
  }]);
  return ToolMenu;
}(_react["default"].Component);

exports.ToolMenu = ToolMenu;
(0, _defineProperty2["default"])(ToolMenu, "propTypes", {
  classes: _propTypes["default"].object,
  gssLineData: _propTypes["default"].object,
  disabled: _propTypes["default"].bool,
  onChange: _propTypes["default"].func
});

var styles = function styles(theme) {
  return {
    radioButtonClass: {},
    selectLineRadioGroup: {
      display: 'flex',
      flexWrap: 'wrap',
      flexDirection: 'row'
    },
    radioFieldInner: {
      display: 'flex',
      flexWrap: 'wrap',
      flexDirection: 'row',
      alignItems: 'center'
    },
    radioFieldOuter: {
      display: 'flex',
      flexWrap: 'wrap',
      flexDirection: 'column'
    },
    radioFieldButtons: {
      display: 'flex',
      flexWrap: 'wrap',
      flexDirection: 'row',
      padding: '0 .9rem'
    },
    lineTypeText: {
      marginLeft: '.7rem'
    },
    lineNameFont: {
      fontWeight: 'bold',
      padding: '0 5px 0 0'
    },
    lineTypeButtonLeftSelected: {
      textTransform: 'none',
      border: '1px solid #3E4EB1',
      borderRadius: '0',
      backgroundColor: '#3E4EB1 !important',
      borderTopLeftRadius: '4px',
      borderBottomLeftRadius: '4px',
      color: '#FFFFFF !important'
    },
    lineTypeButtonLeftUnSelected: {
      textTransform: 'none',
      border: '1px solid #3E4EB1',
      borderRadius: '0',
      backgroundColor: '#FFFFFF !important',
      borderTopLeftRadius: '4px',
      borderBottomLeftRadius: '4px',
      color: '#3E4EB1 !important'
    },
    lineTypeButtonRightSelected: {
      textTransform: 'none',
      border: '1px solid #3E4EB1',
      borderRadius: '0',
      backgroundColor: '#3E4EB1 !important',
      borderTopRightRadius: '4px',
      borderBottomRightRadius: '4px',
      color: '#FFFFFF !important'
    },
    lineTypeButtonRightUnSelected: {
      textTransform: 'none',
      border: '1px solid #3E4EB1',
      borderRadius: '0',
      backgroundColor: '#FFFFFF !important',
      borderTopRightRadius: '4px',
      borderBottomRightRadius: '4px',
      color: '#3E4EB1 !important'
    },
    lineTypeRadio: {
      color: '#000000 !important'
    },
    lineTypeButtonLeftSelectedDisabled: {
      textTransform: 'none',
      border: '1px solid #3E4EB1',
      borderRadius: '0',
      backgroundColor: '#3E4EB1 !important',
      borderTopLeftRadius: '4px',
      borderBottomLeftRadius: '4px',
      color: '#FFFFFF !important',
      cursor: 'default',
      pointerEvents: 'none'
    },
    lineTypeButtonLeftUnSelectedDisabled: {
      textTransform: 'none',
      border: '1px solid #3E4EB1',
      borderRadius: '0',
      backgroundColor: '#FFFFFF !important',
      borderTopLeftRadius: '4px',
      borderBottomLeftRadius: '4px',
      color: '#3E4EB1 !important',
      cursor: 'default',
      pointerEvents: 'none'
    },
    lineTypeButtonRightSelectedDisabled: {
      textTransform: 'none',
      border: '1px solid #3E4EB1',
      borderRadius: '0',
      backgroundColor: '#3E4EB1 !important',
      borderTopRightRadius: '4px',
      borderBottomRightRadius: '4px',
      color: '#FFFFFF !important',
      cursor: 'default',
      pointerEvents: 'none'
    },
    lineTypeButtonRightUnSelectedDisabled: {
      textTransform: 'none',
      border: '1px solid #3E4EB1',
      borderRadius: '0',
      backgroundColor: '#FFFFFF !important',
      borderTopRightRadius: '4px',
      borderBottomRightRadius: '4px',
      color: '#3E4EB1 !important',
      cursor: 'default',
      pointerEvents: 'none'
    }
  };
};

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

exports["default"] = _default;
//# sourceMappingURL=tool-menu.js.map