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

'use strict';

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

var helper = require('../../chunks/helper.js');
var iconsVue = require('@ldesign/icons-vue');
var components_tooltip_index = require('../tooltip/index.js');
var utils_dom = require('../../utils/dom.js');
var components_configProvider_configReceiver = require('../config-provider/config-receiver.js');
var utils_mixins = require('../../utils/mixins.js');
var components_breadcrumb_props = require('./props.js');
require('../../utils/map-props.js');
require('vue');
require('../../utils/with-install.js');
require('lodash');
require('../../config.js');
require('../tooltip/tooltip.js');
require('lodash/isFunction');
require('../popup/props.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../../chunks/set-style.js');
require('../../utils/render-node.js');
require('../../utils/helper.js');
require('lodash/camelCase');
require('../popup/container.js');
require('raf');
require('lodash/isString');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../utils/easing.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../tooltip/props.js');

const localLBreadcrumbOrigin = {
  separator: "",
  theme: "light",
  $slots: {
    separator: ""
  },
  maxItemWidth: void 0
};
var _BreadcrumbItem = utils_mixins["default"](components_configProvider_configReceiver.getClassPrefixMixins("breadcrumb"), components_configProvider_configReceiver.getGlobalIconMixins()).extend({
  name: "LBreadcrumbItem",
  props: {
    ...components_breadcrumb_props.BreadcrumbItemProps
  },
  inject: ["LBreadcrumb"],
  data() {
    return {
      localTBreadcrumb: localLBreadcrumbOrigin,
      themeClassName: "",
      $router: null,
      isCutOff: false
    };
  },
  components: {
    LTooltip: components_tooltip_index.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 = utils_dom.isNodeOverflow(this.$refs.breadcrumbText);
  },
  beforeUpdate() {
    this.isCutOff = utils_dom.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
    } = this.useGlobalIcon({
      ChevronRightIcon: iconsVue.ChevronRightIcon
    });
    const {
      separator
    } = localTBreadcrumb;
    const separatorSlot = localTBreadcrumb.$slots.separator;
    const separatorPropContent = typeof separator === "function" ? separator() : separator;
    const separatorContent = separatorPropContent || separatorSlot || h(ChevronRightIcon);
    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.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])]);
  }
});

exports["default"] = _BreadcrumbItem;
//# sourceMappingURL=breadcrumb-item.js.map
