import { extend, mergeData } from '../../vue';
import { NAME_BREADCRUMB_LINK } from '../../constants/components';
import { PROP_TYPE_STRING } from '../../constants/props';
import { htmlOrText } from '../../utils/html';
import { sortKeys, omit } from '../../utils/object';
import { makePropsConfigurable, makeProp, pluckProps } from '../../utils/props';
import { props as props$1, BLink } from '../link/link';

// --- Props ---

const props = makePropsConfigurable(sortKeys({
  ...omit(props$1, ['event', 'routerTag']),
  ariaCurrent: makeProp(PROP_TYPE_STRING, 'location'),
  html: makeProp(PROP_TYPE_STRING),
  text: makeProp(PROP_TYPE_STRING)
}), NAME_BREADCRUMB_LINK);

// --- Main component ---

// @vue/component
const BBreadcrumbLink = /*#__PURE__*/extend({
  name: NAME_BREADCRUMB_LINK,
  functional: true,
  props,
  render(h, _ref) {
    let {
      props: suppliedProps,
      data,
      children
    } = _ref;
    const {
      active
    } = suppliedProps;
    const tag = active ? 'span' : BLink;
    const componentData = {
      attrs: {
        'aria-current': active ? suppliedProps.ariaCurrent : null
      },
      props: pluckProps(props, suppliedProps)
    };
    if (!children) {
      componentData.domProps = htmlOrText(suppliedProps.html, suppliedProps.text);
    }
    return h(tag, mergeData(data, componentData), children);
  }
});

export { BBreadcrumbLink, props };
