/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

import { defineComponent, computed } from '@vue/composition-api';
import { usePrefixClass } from '../hooks/useConfig.js';
import '../config-provider/useConfig.js';
import '../config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../_chunks/dep-67ff4010.js';
import '../config-provider/type.js';

var _HighlightOption = defineComponent({
  name: "HighlightOption",
  props: {
    content: String,
    keyword: String
  },
  setup: function setup(props) {
    var classPrefix = usePrefixClass();
    var words = computed(function () {
      var _content$match;
      var content = props.content,
        keyword = props.keyword;
      if (!content) return {
        list: []
      };
      if (typeof content !== "string" || !keyword) return {
        list: [content]
      };
      var regExp = new RegExp(keyword, "i");
      var splitKeyword = (_content$match = content.match(regExp)) === null || _content$match === void 0 ? void 0 : _content$match[0];
      return {
        list: content.split(splitKeyword),
        keyword: splitKeyword
      };
    });
    return {
      words: words,
      classPrefix: classPrefix
    };
  },
  render: function render() {
    var _this = this;
    var h = arguments[0];
    var _this$words = this.words,
      list = _this$words.list,
      keyword = _this$words.keyword;
    return h("div", {
      "class": "".concat(this.classPrefix, "-select-option__highlight-item")
    }, [list.map(function (item, index) {
      if (!index) return item;
      return [h("b", {
        "class": "".concat(_this.classPrefix, "-is-highlight"),
        "key": item + keyword
      }, [keyword]), item];
    })]);
  }
});

export { _HighlightOption as default };
//# sourceMappingURL=highlight-option.js.map
