/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { h as helper } from '../../chunks/helper.js';
import { ChevronRightIcon } from '@ldesign/icons-vue';
import { Tooltip } from '../tooltip/index.js';
import { isNodeOverflow } from '../../utils/dom.js';
import { getClassPrefixMixins, getGlobalIconMixins } from '../config-provider/config-receiver.js';
import mixins from '../../utils/mixins.js';
import { BreadcrumbItemProps } from './props.js';
import '../../chunks/_commonjsHelpers.js';
import '../../utils/map-props.js';
import 'vue';
import '../../utils/with-install.js';
import 'lodash';
import '../../config.js';
import '../tooltip/tooltip.js';
import 'lodash/isFunction';
import '../popup/props.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../../chunks/set-style.js';
import '../../utils/render-node.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../popup/container.js';
import 'raf';
import 'lodash/isString';
import '../../chunks/index.js';
import '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-2e6815bd.js';
import '../../utils/easing.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../tooltip/props.js';
import '../tooltip/style/css.js';
import '../tooltip/type.js';

const localLBreadcrumbOrigin = {
  separator: "",
  theme: "light",
  $slots: {
    separator: ""
  },
  maxItemWidth: void 0
};
var _BreadcrumbItem = mixins(getClassPrefixMixins("breadcrumb"), getGlobalIconMixins()).extend({
  name: "LBreadcrumbItem",
  props: {
    ...BreadcrumbItemProps
  },
  inject: ["LBreadcrumb"],
  data() {
    return {
      localTBreadcrumb: localLBreadcrumbOrigin,
      themeClassName: "",
      $router: null,
      isCutOff: false
    };
  },
  components: {
    LTooltip: Tooltip
  },
  computed: {
    maxWithStyle() {
      const {
        localTBreadcrumb
      } = this;
      const {
        maxItemWidth
      } = localTBreadcrumb;
      const maxWith = this.maxWidth || maxItemWidth || "120";
      return {
        "max-width": `${maxWith}px`
      };
    }
  },
  watch: {
    LBreadcrumb: {
      immediate: true,
      handler(v) {
        this.localTBreadcrumb = v;
      }
    }
  },
  created() {
    const LBreadcrumb = this.localTBreadcrumb;
    this.themeClassName = LBreadcrumb.theme;
  },
  mounted() {
    this.isCutOff = isNodeOverflow(this.$refs.breadcrumbText);
  },
  beforeUpdate() {
    this.isCutOff = isNodeOverflow(this.$refs.breadcrumbText);
  },
  methods: {
    bindEvent() {
      const {
        to
      } = this;
      const router = this.router || this.$router;
      if (to && router) this.replace ? router.replace(to) : router.push(to);
    }
  },
  render() {
    const h = arguments[0];
    const {
      localTBreadcrumb,
      href,
      target,
      to,
      disabled
    } = this;
    const {
      ChevronRightIcon: ChevronRightIcon$1
    } = this.useGlobalIcon({
      ChevronRightIcon: ChevronRightIcon
    });
    const {
      separator
    } = localTBreadcrumb;
    const separatorSlot = localTBreadcrumb.$slots.separator;
    const separatorPropContent = typeof separator === "function" ? separator() : separator;
    const separatorContent = separatorPropContent || separatorSlot || h(ChevronRightIcon$1);
    const itemClass = [`${this.componentName}__item`, this.themeClassName];
    const textClass = [`${this.componentName}--text-overflow`];
    if (disabled) textClass.push(`${this.classPrefix}-is-disabled`);
    if (this.$listeners.click) textClass.push(`${this.classPrefix}-gestureClass`);
    const clickEvent = to && !disabled ? {
      on: {
        click: this.bindEvent
      }
    } : {};
    const textContent = h("span", {
      "ref": "breadcrumbText",
      "class": `${this.componentName}__inner`,
      "style": this.maxWithStyle
    }, [this.$slots.default]);
    let itemContent = h("span", helper([{
      "class": textClass,
      "on": {
        ...this.$listeners
      }
    }, clickEvent]), [textContent]);
    if (href && !disabled) {
      textClass.push(`${this.classPrefix}-link`);
      itemContent = h("a", {
        "class": textClass,
        "attrs": {
          "href": href,
          "target": target
        },
        "on": {
          ...this.$listeners
        }
      }, [textContent]);
    }
    return h("div", {
      "class": itemClass
    }, [this.isCutOff ? h("l-tooltip", {
      "attrs": {
        "content": () => this.$slots.default
      }
    }, [itemContent]) : itemContent, h("span", {
      "class": `${this.componentName}__separator`
    }, [separatorContent])]);
  }
});

export { _BreadcrumbItem as default };
//# sourceMappingURL=breadcrumb-item.js.map
