/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var VueCompositionAPI = require('@vue/composition-api');
var hooks_useConfig = require('../../hooks/useConfig.js');
require('../config-provider/useConfig.js');
require('../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../../chunks/zh_CN.js');

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

exports["default"] = _HighlightOption;
//# sourceMappingURL=highlight-option.js.map
