/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-b6ac6e96.js';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed } from '@vue/composition-api';
import isArray from 'lodash/isArray';
import isFunction from 'lodash/isFunction';
import { Tree } from '../tree/index.js';
import { SelectInput } from '../select-input/index.js';
import FakeArrow from '../common-components/fake-arrow.js';
import { useTNodeJSX, useTNodeDefault } from '../hooks/tnode.js';
import props from './props.js';
import useTreeSelect from './useTreeSelect.js';
import '../utils/map-props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'vue';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import '../tree/td-tree.js';
import 'lodash/upperFirst';
import '../hooks/useConfig.js';
import '../config-provider/useConfig.js';
import '../config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-2cb61c79.js';
import 'dayjs';
import '../utils/render-tnode.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../tree/props.js';
import '../tree/hooks/useTreeStore.js';
import 'lodash/pick';
import '../_common/js/tree/tree-store.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import 'lodash/isNumber';
import 'lodash/isString';
import 'lodash/difference';
import 'lodash/isPlainObject';
import 'mitt';
import '../_common/js/tree/tree-node.js';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/regenerator';
import 'lodash/isNull';
import 'lodash/uniqueId';
import 'lodash/isNil';
import 'lodash/get';
import '../_common/js/log/log.js';
import '../_common/js/tree/tree-node-model.js';
import 'lodash/isUndefined';
import 'lodash/isBoolean';
import 'lodash/omit';
import '../tree/hooks/useTreeStyles.js';
import '../tree/hooks/useTreeState.js';
import '../tree/hooks/useTreeAction.js';
import '../tree/util.js';
import '../tree/hooks/useTreeScroll.js';
import '../hooks/useVirtualScrollNew.js';
import '@babel/runtime/helpers/slicedToArray';
import '../hooks/useResizeObserver.js';
import '../tree/hooks/useTreeNodes.js';
import '../tree/tree-item.js';
import '../config-provider/config-receiver.js';
import '../utils/ripple.js';
import '../_common/js/utils/set-style.js';
import '../config.js';
import '../tree/hooks/useTreeItem.js';
import '../hooks/useLazyLoad.js';
import '../_common/js/utils/observe.js';
import '../tree/hooks/useItemEvents.js';
import '../tree/hooks/useRenderIcon.js';
import '@ldesign/icons-vue';
import '../hooks/useGlobalIcon.js';
import '../loading/index.js';
import '../loading/directive.js';
import 'lodash/isObject';
import 'lodash/mapKeys';
import 'lodash/isEqual';
import '../loading/plugin.js';
import '../utils/dom.js';
import 'raf';
import '../utils/easing.js';
import '../loading/loading.js';
import '../utils/transfer-dom.js';
import '../utils/mixins.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/helper.js';
import '../tree/hooks/useRenderLabel.js';
import '../checkbox/index.js';
import '../checkbox/group.js';
import 'lodash/intersection';
import '../utils/event.js';
import '../utils/helper.js';
import '../checkbox/checkbox.js';
import '../checkbox/props.js';
import '../checkbox/checkbox-group-props.js';
import '../tree/hooks/useRenderLine.js';
import '../tree/hooks/useRenderOperations.js';
import '../tree/hooks/useDraggable.js';
import 'lodash/throttle';
import '../tree/hooks/useTreeEvents.js';
import '../tree/hooks/useDragHandle.js';
import '../select-input/select-input.js';
import '../popup/index.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../popup/props.js';
import '../popup/container.js';
import '../popup/utils.js';
import '../popup/trigger.js';
import '../popup/plugin.js';
import '../select-input/props.js';
import '../select-input/useSingle.js';
import '../input/index.js';
import '../input/input.js';
import '../input/props.js';
import '../input/input-group.js';
import '../hooks/useDefaultValue.js';
import '../select-input/useMultiple.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/useTagScroll.js';
import '../tag-input/useTagList.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/check-tag-props.js';
import '../hooks/useVModel.js';
import '../tag-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.js';
import 'lodash/isEmpty';
import '../hooks/render-tnode.js';
import '../select-input/useOverlayInnerStyle.js';
import '../hooks/useFormDisabled.js';
import './utils.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _TreeSelect = defineComponent({
  name: "TTreeSelect",
  props: _objectSpread({}, props),
  setup: function setup(props2, context) {
    var renderTNodeJSX = useTNodeJSX();
    var renderDefaultTNode = useTNodeDefault();
    var treeSelectInfo = useTreeSelect(props2, context);
    var dropdownInnerSize = treeSelectInfo.dropdownInnerSize,
      treeSelectValue = treeSelectInfo.treeSelectValue;
    var multiLimitDisabled = computed(function () {
      return props2.multiple && !!props2.max && isArray(treeSelectValue.value) && props2.max <= treeSelectValue.value.length;
    });
    return _objectSpread(_objectSpread({}, treeSelectInfo), {}, {
      dropdownInnerSize: dropdownInnerSize,
      multiLimitDisabled: multiLimitDisabled,
      renderTNodeJSX: renderTNodeJSX,
      renderDefaultTNode: renderDefaultTNode
    });
  },
  methods: {
    renderSuffixIcon: function renderSuffixIcon() {
      var _ref;
      var h = this.$createElement;
      return h(FakeArrow, {
        "attrs": {
          "isActive": this.innerVisible,
          "disabled": this.disabled,
          "overlayClassName": (_ref = {}, _defineProperty(_ref, "".concat(this.classPrefix, "-fake-arrow--highlight"), this.innerVisible), _defineProperty(_ref, "".concat(this.classPrefix, "-fake-arrow--disable"), this.disabled), _ref)
        }
      });
    },
    renderLabel: function renderLabel() {
      var h = this.$createElement;
      var label = this.renderTNodeJSX("label");
      var prefixIcon = this.renderTNodeJSX("prefixIcon");
      if (label && prefixIcon) {
        return h("div", [label, prefixIcon]);
      }
      return label || prefixIcon;
    },
    getTreePanel: function getTreePanel() {
      var _this = this;
      var h = this.$createElement;
      return h("div", {
        "class": ["".concat(this.classPrefix, "-select__dropdown-inner"), "".concat(this.classPrefix, "-select__dropdown-inner--size-").concat(this.dropdownInnerSize)]
      }, [this.loading && !this.tDisabled ? h("p", {
        "class": ["".concat(this.classPrefix, "-select__loading-tips"), "".concat(this.classPrefix, "-select__right-icon-polyfill")]
      }, [this.renderDefaultTNode("loadingText", {
        defaultNode: h("div", {
          "class": "".concat(this.classPrefix, "-select__empty")
        }, [this.global.loadingText])
      })]) : null, !this.loading ? h(Tree, helper([{
        "ref": "treeRef"
      }, {
        "props": _objectSpread({
          keys: this.tKeys,
          value: _toConsumableArray(this.multipleChecked),
          actived: this.singleActivated,
          hover: true,
          data: this.data,
          activable: !this.multiple,
          checkable: this.multiple,
          disabled: this.tDisabled || this.multiLimitDisabled,
          size: this.size,
          filter: this.filterByText,
          icon: !this.filterByText,
          activeMultiple: this.multiple,
          onExpand: this.treeNodeExpand,
          onLoad: this.treeNodeLoad,
          onChange: this.treeNodeChange,
          onActive: this.treeNodeActive,
          expandOnClickNode: true,
          empty: function empty() {
            return _this.renderDefaultTNode("empty", {
              defaultNode: h("div", {
                "class": "".concat(_this.classPrefix, "-select__empty")
              }, [_this.global.empty])
            });
          }
        }, this.treeProps)
      }])) : null]);
    },
    renderCollapsedItems: function renderCollapsedItems() {
      var selectedNodeInfo = this.nodeInfo || [];
      var value = Array.isArray(selectedNodeInfo) ? selectedNodeInfo : [selectedNodeInfo];
      return this.renderTNodeJSX("collapsedItems", {
        params: {
          value: value,
          collapsedSelectedItems: value.slice(this.minCollapsedNum),
          count: value.length - this.minCollapsedNum
        }
      });
    }
  },
  render: function render() {
    var _this2 = this;
    var h = arguments[0];
    var slots = this.$scopedSlots;
    return h(SelectInput, {
      "scopedSlots": {
        tips: slots.tips,
        suffix: slots.suffix
      },
      "class": "".concat(this.classPrefix, "-tree-select"),
      "props": _objectSpread({}, _objectSpread({
        keys: this.tKeys,
        value: this.nodeInfo,
        inputValue: this.innerInputValue,
        popupVisible: this.innerVisible,
        disabled: this.tDisabled,
        multiple: this.multiple,
        loading: this.loading,
        clearable: this.clearable,
        autofocus: this.autofocus,
        autoWidth: this.autoWidth,
        borderless: this.borderless,
        readonly: this.readonly,
        placeholder: this.inputPlaceholder,
        status: this.status,
        tips: this.tips,
        suffix: this.suffix,
        allowInput: Boolean(this.filterable || isFunction(this.filter) || this.$listeners.search || this.onSearch),
        minCollapsedNum: this.minCollapsedNum,
        collapsedItems: this.renderCollapsedItems,
        popupProps: _objectSpread({
          overlayClassName: this.popupClass
        }, this.popupProps),
        inputProps: _objectSpread({
          size: this.size
        }, this.inputProps),
        tagInputProps: {
          size: this.size
        },
        tagProps: _objectSpread({
          maxWidth: 300
        }, this.tagProps),
        label: this.renderLabel,
        suffixIcon: this.renderSuffixIcon,
        onClear: this.clear,
        onBlur: this.onInnerBlur,
        onFocus: this.onInnerFocus,
        onInputChange: this.inputChange,
        onTagChange: this.tagChange,
        onEnter: this.onInnerEnter,
        onPopupVisibleChange: this.onInnerPopupVisibleChange,
        valueDisplay: function valueDisplay() {
          var _ref2;
          return _this2.renderTNodeJSX("valueDisplay", {
            params: _this2.multiple ? {
              value: _this2.nodeInfo,
              onClose: function onClose(value, context) {
                _this2.tagChange(value, context);
              }
            } : {
              value: _this2.nodeInfo || (_ref2 = {}, _defineProperty(_ref2, _this2.tKeys.label, ""), _defineProperty(_ref2, _this2.tKeys.value, void 0), _ref2)
            }
          });
        },
        panel: this.getTreePanel
      }, this.selectInputProps))
    });
  }
});

export { _TreeSelect as default };
//# sourceMappingURL=tree-select.js.map
