text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = void 0;
  
  var _classnames = _interopRequireDefault(require("classnames"));
  
  var _react = _interopRequireDefault(require("react"));
  
  var _router = require("../../../../router");
  
  var _defaultStyle = _interopRequireDefault(require("part:@sanity/components/menus/default-style"));
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  class DefaultMenuItem extends _react.default.Component {
    constructor() {
      super(...arguments);
  
      _defineProperty(this, "handleClick", event => {
        event.stopPropagation();
        this.props.onAction(event, this.props.item);
      });
  
      _defineProperty(this, "handleFocus", event => {
        this.props.onFocus(event, this.props.item);
      });
  
      _defineProperty(this, "renderLinkChildren", () => {
        var item = this.props.item;
        var Icon = item.icon,
            title = item.title;
        return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, Icon && /*#__PURE__*/_react.default.createElement("span", {
          className: _defaultStyle.default.iconContainer
        }, /*#__PURE__*/_react.default.createElement(Icon, {
          className: _defaultStyle.default.icon
        })), title);
      });
  
      _defineProperty(this, "renderIntentLink", () => {
        var _this$props = this.props,
            danger = _this$props.danger,
            item = _this$props.item;
        var intent = item.intent; // @todo: is this what we want?
  
        if (!intent) return null;
        return /*#__PURE__*/_react.default.createElement(_router.IntentLink, {
          onClick: this.handleClick,
          className: danger ? _defaultStyle.default.dangerLink : _defaultStyle.default.link,
          onFocus: this.handleFocus,
          tabIndex: 0,
          intent: intent.type,
          params: intent.params
        }, this.renderLinkChildren());
      });
  
      _defineProperty(this, "renderFunctionLink", () => {
        var _this$props2 = this.props,
            isDisabled = _this$props2.isDisabled,
            danger = _this$props2.danger;
        return /*#__PURE__*/_react.default.createElement("a", {
          onClick: isDisabled ? undefined : this.handleClick,
          className: danger ? _defaultStyle.default.dangerLink : _defaultStyle.default.link,
          onFocus: this.handleFocus,
          tabIndex: 0
        }, this.renderLinkChildren());
      });
    }
  
    render() {
      var _this$props3 = this.props,
          classNameProp = _this$props3.className,
          isDisabled = _this$props3.isDisabled,
          isFocused = _this$props3.isFocused,
          item = _this$props3.item;
      var intent = item.intent;
      var className = (0, _classnames.default)(classNameProp, isFocused ? _defaultStyle.default.focusedItem : _defaultStyle.default.item, isDisabled && _defaultStyle.default.isDisabled);
      return /*#__PURE__*/_react.default.createElement("li", {
        className: className
      }, intent ? this.renderIntentLink() : this.renderFunctionLink());
    }
  
  }
  
  var _default = DefaultMenuItem;
  exports.default = _default;