/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-37d5b9c4.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, toRefs, computed } from '@vue/composition-api';
import { Popup } from '../popup/index.js';
import { prefix } from '../config.js';
import props from './props.js';
import useSingle from './useSingle.js';
import useMultiple from './useMultiple.js';
import useOverlayStyle from './useOverlayStyle.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/typeof';
import 'vue';
import '@popperjs/core';
import '../utils/classnames.js';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/render-tnode.js';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';
import '../_common/js/utils/set-style.js';
import '../popup/props.js';
import '../popup/container.js';
import '../utils/map-props.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../popup/type.js';
import 'lodash/isObject';
import 'lodash/pick';
import '../input/index.js';
import '../input/addon.js';
import '../input/input.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'tdesign-icons-vue';
import 'lodash/kebabCase';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.js';
import '../utils/mixins.js';
import '../utils/event.js';
import '../input/props.js';
import '../input/input-group.js';
import '../input/type.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/helper.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../hooks/tnode.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import '../hooks/render-tnode.js';
import '../config-provider/index.js';
import '../config-provider/config-provider.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import '../hooks/useDefaultValue.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/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 '../tag/type.js';
import '../hooks/useVModel.js';
import '../tag-input/useHover.js';
import '../tag-input/type.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 BASE_CLASS_BORDERLESS = "".concat(prefix, "-select-input--borderless");
var BASE_CLASS_MULTIPLE = "".concat(prefix, "-select-input--multiple");
var BASE_CLASS_POPUP_VISIBLE = "".concat(prefix, "-select-input--popup-visible");
var BASE_CLASS_EMPTY = "".concat(prefix, "-select-input--empty");
var _SelectInput = defineComponent({
  name: "TSelectInput",
  props: _objectSpread({}, props),
  setup: function setup(props2, context) {
    var selectInputRef = ref();
    var selectInputWrapRef = ref();

    var _toRefs = toRefs(props2),
        multiple = _toRefs.multiple,
        value = _toRefs.value,
        popupVisible = _toRefs.popupVisible,
        borderless = _toRefs.borderless;

    var _useSingle = useSingle(props2, context),
        commonInputProps = _useSingle.commonInputProps,
        onInnerClear = _useSingle.onInnerClear,
        renderSelectSingle = _useSingle.renderSelectSingle;

    var _useMultiple = useMultiple(props2, context),
        renderSelectMultiple = _useMultiple.renderSelectMultiple;

    var _useOverlayStyle = useOverlayStyle(props2),
        tOverlayStyle = _useOverlayStyle.tOverlayStyle,
        innerPopupVisible = _useOverlayStyle.innerPopupVisible,
        onInnerPopupVisibleChange = _useOverlayStyle.onInnerPopupVisibleChange;

    var popupClasses = computed(function () {
      var _popupVisible$value, _ref;

      return [(_ref = {}, _defineProperty(_ref, BASE_CLASS_BORDERLESS, borderless.value), _defineProperty(_ref, BASE_CLASS_MULTIPLE, multiple.value), _defineProperty(_ref, BASE_CLASS_POPUP_VISIBLE, (_popupVisible$value = popupVisible.value) !== null && _popupVisible$value !== void 0 ? _popupVisible$value : innerPopupVisible.value), _defineProperty(_ref, BASE_CLASS_EMPTY, value.value instanceof Array ? !value.value.length : !value.value), _ref)];
    });
    return {
      selectInputWrapRef: selectInputWrapRef,
      innerPopupVisible: innerPopupVisible,
      commonInputProps: commonInputProps,
      tOverlayStyle: tOverlayStyle,
      selectInputRef: selectInputRef,
      popupClasses: popupClasses,
      onInnerClear: onInnerClear,
      renderSelectSingle: renderSelectSingle,
      renderSelectMultiple: renderSelectMultiple,
      onInnerPopupVisibleChange: onInnerPopupVisibleChange
    };
  },
  render: function render(h) {
    var _this$popupVisible, _this$popupProps, _this$popupVisible2;

    var visibleProps = {
      visible: (_this$popupVisible = this.popupVisible) !== null && _this$popupVisible !== void 0 ? _this$popupVisible : this.innerPopupVisible
    };
    var mainContent = h(Popup, helper([{
      "ref": "selectInputRef",
      "class": this.popupClasses,
      "attrs": {
        "trigger": ((_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.trigger) || "click",
        "placement": "bottom-left",
        "visible": (_this$popupVisible2 = this.popupVisible) !== null && _this$popupVisible2 !== void 0 ? _this$popupVisible2 : this.innerPopupVisible,
        "content": this.panel,
        "hideEmptyPopup": true
      },
      "scopedSlots": _objectSpread(_objectSpread({}, this.$scopedSlots), {}, {
        content: this.$scopedSlots.panel
      })
    }, {
      "on": {
        "visible-change": this.onInnerPopupVisibleChange
      }
    }, {}, {
      "props": _objectSpread(_objectSpread({}, this.popupProps), {}, {
        overlayStyle: this.tOverlayStyle
      })
    }]), [this.multiple ? this.renderSelectMultiple({
      commonInputProps: this.commonInputProps,
      onInnerClear: this.onInnerClear,
      popupVisible: visibleProps.visible
    }, h) : this.renderSelectSingle(h, visibleProps.visible)]);
    if (!this.tips) return mainContent;
    return h("div", {
      "ref": "selectInputWrapRef",
      "class": "".concat(prefix, "-select-input__wrap")
    }, [mainContent, h("div", {
      "class": "".concat(prefix, "-input__tips ").concat(prefix, "-input__tips--").concat(this.status || "normal")
    }, [this.tips])]);
  }
});

export { _SelectInput as default };
//# sourceMappingURL=select-input.js.map
