import { extend, mergeData } from '../../vue';
import { NAME_CARD_HEADER } from '../../constants/components';
import { PROP_TYPE_STRING, PROP_TYPE_ARRAY_OBJECT_STRING } from '../../constants/props';
import { htmlOrText } from '../../utils/html';
import { sortKeys } from '../../utils/object';
import { makePropsConfigurable, copyProps, prefixPropName, makeProp } from '../../utils/props';
import { props as props$1 } from '../../mixins/card';

// --- Props ---

const props = makePropsConfigurable(sortKeys({
  ...copyProps(props$1, prefixPropName.bind(null, 'header')),
  header: makeProp(PROP_TYPE_STRING),
  headerClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
  headerHtml: makeProp(PROP_TYPE_STRING)
}), NAME_CARD_HEADER);

// --- Main component ---

// @vue/component
const BCardHeader = /*#__PURE__*/extend({
  name: NAME_CARD_HEADER,
  functional: true,
  props,
  render(h, _ref) {
    let {
      props,
      data,
      children
    } = _ref;
    const {
      headerBgVariant,
      headerBorderVariant,
      headerTextVariant
    } = props;
    return h(props.headerTag, mergeData(data, {
      staticClass: 'card-header',
      class: [props.headerClass, {
        [`bg-${headerBgVariant}`]: headerBgVariant,
        [`border-${headerBorderVariant}`]: headerBorderVariant,
        [`text-${headerTextVariant}`]: headerTextVariant
      }],
      domProps: children ? {} : htmlOrText(props.headerHtml, props.header)
    }), children);
  }
});

export { BCardHeader, props };
