import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(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; } }

import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import { settings } from '../../globals/js';
var prefix = settings.prefix;
/*
import {
  CheckmarkOutline32,
  WarningAlt32,
  Information32,
} from '@carbon/icons-react';
*/

import { CheckmarkGlyph, WarningAlt32, WarningSolidGlyph, InfoSolidGlyph } from '@wfp/icons-react';
var iconLookup = {
  warning: {
    icon: WarningAlt32
  },
  error: {
    icon: WarningSolidGlyph
  },
  info: {
    icon: InfoSolidGlyph
  },
  success: {
    icon: CheckmarkGlyph
  }
};
/**
 *  The Blockquote element indicates that the enclosed text is an extended quotation or information. It is rendered visually by a surrounding box. */

var Blockquote = /*#__PURE__*/function (_React$Component) {
  _inherits(Blockquote, _React$Component);

  var _super = _createSuper(Blockquote);

  function Blockquote(props) {
    var _this;

    _classCallCheck(this, Blockquote);

    _this = _super.call(this, props);

    _defineProperty(_assertThisInitialized(_this), "toggleBlockquote", function () {
      if (_this.props.toggleable) _this.setState({
        open: !_this.state.open
      });
    });

    _this.state = {
      open: false
    };
    return _this;
  }

  _createClass(Blockquote, [{
    key: "render",
    value:
    /*showInnerHtml = content => {
      return { __html: content };
    };*/
    function render() {
      var _classNames;

      var _this$props = this.props,
          actionButtons = _this$props.actionButtons,
          className = _this$props.className,
          contentClassName = _this$props.contentClassName,
          children = _this$props.children,
          error = _this$props.error,
          style = _this$props.style,
          title = _this$props.title,
          toggleable = _this$props.toggleable,
          icon = _this$props.icon,
          light = _this$props.light,
          code = _this$props.code,
          warning = _this$props.warning,
          withIcon = _this$props.withIcon,
          info = _this$props.info,
          kind = _this$props.kind;
      var blockquoteClass = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--blockquote"), true), _defineProperty(_classNames, "".concat(prefix, "--blockquote--toggleable"), toggleable), _defineProperty(_classNames, "".concat(prefix, "--blockquote--light"), light), _defineProperty(_classNames, "".concat(prefix, "--blockquote--code"), code), _defineProperty(_classNames, "".concat(prefix, "--blockquote--no-content"), !children), _defineProperty(_classNames, "".concat(prefix, "--blockquote--error"), kind === 'error' || error), _defineProperty(_classNames, "".concat(prefix, "--blockquote--warning"), kind === 'warning' || warning), _defineProperty(_classNames, "".concat(prefix, "--blockquote--success"), kind === 'success'), _defineProperty(_classNames, "".concat(prefix, "--blockquote--info"), kind === 'info' || info), _defineProperty(_classNames, "".concat(prefix, "--blockquote--with-icon"), withIcon || icon), _defineProperty(_classNames, "".concat(prefix, "--blockquote--toggle--open"), this.state.open), _defineProperty(_classNames, "".concat(className), className), _classNames));
      var blockquoteContentClass = classNames("".concat(prefix, "--blockquote__content"), _defineProperty({}, "".concat(className), contentClassName)); // @deprecated Only kind is allowed

      var lookup = warning || kind === 'warning' ? iconLookup['warning'] : error || kind === 'error' ? iconLookup['error'] : kind === 'success' ? iconLookup['success'] : iconLookup['info'];
      var Icon = lookup.icon;
      var iconElement = /*#__PURE__*/React.isValidElement(icon) ? /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefix, "--blockquote__icon ").concat(prefix, "--blockquote__icon--custom")
      }, icon) : withIcon || icon ? /*#__PURE__*/React.createElement(Icon, {
        width: 48,
        height: 48,
        description: "Blockquote Icon",
        className: "".concat(prefix, "--blockquote__icon")
      }) : null;
      return /*#__PURE__*/React.createElement("div", {
        className: blockquoteClass
      }, iconElement && /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefix, "--blockquote__icon-wrapper")
      }, iconElement), /*#__PURE__*/React.createElement("div", {
        className: blockquoteContentClass,
        style: style
      }, (title || toggleable) && /*#__PURE__*/React.createElement("div", {
        onClick: this.toggleBlockquote,
        onKeyDown: this.toggleBlockquote,
        className: "".concat(prefix, "--blockquote__title"),
        role: "button",
        tabIndex: 0
      }, title ? title : this.state.open ? 'Hide content' : 'Show content'), /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefix, "--blockquote__inside")
      }, children)), actionButtons && /*#__PURE__*/React.createElement("div", {
        className: "wfp--blockquote__action-buttons"
      }, actionButtons));
    }
  }]);

  return Blockquote;
}(React.Component);

Blockquote.propTypes = {
  /**
   * Specify a className of your `Blockquote`
   */
  className: PropTypes.string,

  /**
   * Specify the content of your `Blockquote`
   */
  children: PropTypes.node,

  /**
   * Show content formated as code
   */
  code: PropTypes.bool,

  /**
   * Display light version of Blockquote
   */
  light: PropTypes.bool,

  /**
   * Show options to show and hide the Blockquote when title is clicked
   */
  toggleable: PropTypes.bool,

  /**
   * Show title for Blockquote
   */
  title: PropTypes.node,

  /**
   * Specify the type of your Blockquote Options are `info` `error` `warning` `info`
   */
  kind: PropTypes.oneOf(['info', 'warning', 'error', 'success']),

  /**
   * Specify if an Icon should be displayed
   */
  withIcon: PropTypes.bool,

  /**
   * Specify a custom icon. Can be either a `Icon` object or React component
   */
  icon: PropTypes.oneOfType([PropTypes.node, PropTypes.object])
};
export default Blockquote;