/**
 * 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 VueCompositionAPI = require('@vue/composition-api');
var iconsVue = require('@ldesign/icons-vue');
var components_cascader_utils_helper = require('../utils/helper.js');
var components_cascader_utils_className = require('../utils/className.js');
var components_checkbox_index = require('../../checkbox/index.js');
var components_loading_index = require('../../loading/index.js');
var components_configProvider_configReceiver = require('../../config-provider/config-receiver.js');
var hooks_useConfig = require('../../../hooks/use-config.js');
var hooks_useGlobalIcon = require('../../../hooks/use-global-icon.js');
var utils_ripple = require('../../../utils/ripple.js');
require('lodash/isEmpty');
require('../../../utils/map-props.js');
require('vue');
require('../../../utils/with-install.js');
require('lodash');
require('../../../config.js');
require('../../checkbox/group.js');
require('lodash/intersection');
require('../../../chunks/log.js');
require('../../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../../utils/event.js');
require('../../../utils/helper.js');
require('lodash/camelCase');
require('../../../utils/mixins.js');
require('../../checkbox/checkbox.js');
require('../../../utils/render-node.js');
require('../../checkbox/props.js');
require('lodash/mergeWith');
require('../../config-provider/context.js');
require('../../../chunks/zh_CN.js');
require('../../loading/loading.js');
require('../../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../../utils/easing.js');
require('../../../utils/transfer-dom.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../../chunks/defineProperty-838e4192.js');
require('../../../chunks/set-style.js');
require('../../../chunks/helper2.js');
require('../../loading/plugin.js');
require('../../config-provider/useConfig.js');

const keepAnimationMixins = components_configProvider_configReceiver.getKeepAnimationMixins();
const props = {
  node: {
    type: Object,
    default() {
      return {};
    }
  },
  cascaderContext: {
    type: Object
  },
  onChange: Function,
  onClick: Function,
  onMouseenter: Function
};
var Item = VueCompositionAPI.defineComponent({
  components: {
    LLoading: components_loading_index.Loading,
    LCheckbox: components_checkbox_index.Checkbox
  },
  directives: {
    Ripple: utils_ripple["default"]
  },
  mixins: [keepAnimationMixins],
  props: {
    ...props
  },
  setup(props2) {
    const COMPONENT_NAME = hooks_useConfig.usePrefixClass("cascader__item");
    const classPrefix = hooks_useConfig.usePrefixClass();
    const {
      STATUS,
      SIZE
    } = hooks_useConfig.useCommonClassName();
    const {
      ChevronRightIcon
    } = hooks_useGlobalIcon.useGlobalIcon({
      ChevronRightIcon: iconsVue.ChevronRightIcon
    });
    const itemClass = VueCompositionAPI.computed(() => components_cascader_utils_className.getCascaderItemClass(classPrefix.value, props2.node, SIZE.value, STATUS.value, props2.cascaderContext));
    const iconClass = VueCompositionAPI.computed(() => components_cascader_utils_className.getCascaderItemIconClass(classPrefix.value, props2.node, STATUS.value, props2.cascaderContext));
    return {
      COMPONENT_NAME,
      ChevronRightIcon,
      iconClass,
      itemClass
    };
  },
  render() {
    const h = arguments[0];
    const {
      iconClass,
      cascaderContext,
      itemClass,
      node,
      COMPONENT_NAME,
      onChange,
      ChevronRightIcon
    } = this;
    function RenderLabelInner(node2, cascaderContext2) {
      const {
        inputVal
      } = cascaderContext2;
      const labelText = inputVal ? components_cascader_utils_helper.getFullPathLabel(node2) : node2.label;
      if (inputVal) {
        const texts = labelText.split(inputVal);
        const doms = [];
        for (let index = 0; index < texts.length; index++) {
          doms.push(h("span", {
            "key": index
          }, [texts[index]]));
          if (index === texts.length - 1) break;
          doms.push(h("span", {
            "key": `${index}filter`,
            "class": `${COMPONENT_NAME}-label--filter`
          }, [inputVal]));
        }
        return doms;
      }
      return labelText;
    }
    function RenderLabelContent(node2, cascaderContext2) {
      const label = RenderLabelInner(node2, cascaderContext2);
      const labelCont = h("span", {
        "attrs": {
          "title": cascaderContext2.inputVal ? components_cascader_utils_helper.getFullPathLabel(node2) : node2.label,
          "role": "label"
        },
        "class": [`${COMPONENT_NAME}-label`, `${COMPONENT_NAME}-label--ellipsis`]
      }, [label]);
      return labelCont;
    }
    function RenderCheckBox(node2, cascaderContext2) {
      const {
        checkProps,
        value,
        max,
        inputVal
      } = cascaderContext2;
      const label = RenderLabelInner(node2, cascaderContext2);
      return h("l-checkbox", helper.helper([{
        "attrs": {
          "checked": node2.checked,
          "indeterminate": node2.indeterminate,
          "disabled": node2.isDisabled() || value.length >= max && max !== 0,
          "name": String(node2.value),
          "title": inputVal ? components_cascader_utils_helper.getFullPathLabel(node2) : node2.label,
          "stopLabelTrigger": !!node2.children
        },
        "on": {
          "change": (vale, _ref) => {
            let {
              e
            } = _ref;
            e.stopPropagation();
            onChange();
          }
        }
      }, checkProps]), [label]);
    }
    return h("li", {
      "class": itemClass,
      "on": {
        "click": e => {
          e.stopPropagation();
          this.onClick();
        },
        "mouseenter": e => {
          e.stopPropagation();
          this.onMouseenter();
        }
      }
    }, [cascaderContext.multiple ? RenderCheckBox(node, cascaderContext) : RenderLabelContent(node, cascaderContext), node.children && (node.loading ? h("l-loading", {
      "class": iconClass,
      "attrs": {
        "size": "small"
      }
    }) : h(ChevronRightIcon, {
      "class": iconClass
    }))]);
  }
});

exports["default"] = Item;
//# sourceMappingURL=Item.js.map
