"use strict";

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

exports.__esModule = true;
exports.CommonListHighlight = void 0;

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

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

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

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

var _utils = require("../../list/utils");

var _Highlighter = require("../../Highlighter");

var CommonListHighlight =
/*#__PURE__*/
function (_React$Component) {
  (0, _inheritsLoose2.default)(CommonListHighlight, _React$Component);

  function CommonListHighlight() {
    return _React$Component.apply(this, arguments) || this;
  }

  var _proto = CommonListHighlight.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        listHighlightType = _this$props.listHighlightType,
        containsRichText = _this$props.containsRichText,
        title = _this$props.title,
        textHighlightPattern = _this$props.textHighlightPattern,
        textFilterPattern = _this$props.textFilterPattern;

    if (containsRichText || listHighlightType === _Highlighter.HIGHLIGHT_TYPE.BACKGROUND) {
      return _react.default.createElement(_Highlighter.Highlighter, {
        title: title,
        listHighlightType: listHighlightType,
        highlightRegexp: textHighlightPattern,
        filterRegexp: textFilterPattern
      }, this.props.children);
    }

    return (0, _utils.highlight)(textFilterPattern, this.props.children, title);
  };

  return CommonListHighlight;
}(_react.default.Component);

exports.CommonListHighlight = CommonListHighlight;
(0, _defineProperty2.default)(CommonListHighlight, "HIGHLIGHT_TYPE_BACKGROUND", _Highlighter.HIGHLIGHT_TYPE.BACKGROUND);
(0, _defineProperty2.default)(CommonListHighlight, "HIGHLIGHT_TYPE_BOLD", _Highlighter.HIGHLIGHT_TYPE.BOLD);
(0, _defineProperty2.default)(CommonListHighlight, "propTypes", {
  children: _propTypes.default.node,
  title: _propTypes.default.string,
  textHighlightPattern: _propTypes.default.object,
  textFilterPattern: _propTypes.default.object,
  listHighlightType: _propTypes.default.oneOf([_Highlighter.HIGHLIGHT_TYPE.BACKGROUND, _Highlighter.HIGHLIGHT_TYPE.BOLD]),
  containsRichText: _propTypes.default.bool
});
(0, _defineProperty2.default)(CommonListHighlight, "defaultProps", {
  children: null,
  title: null,
  textHighlightPattern: null,
  textFilterPattern: null,
  listHighlightType: _Highlighter.HIGHLIGHT_TYPE.BOLD,
  containsRichText: false
});