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

'use strict';

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

var helper = require('../_chunks/dep-c3e1ffac.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var popup_index = require('../popup/index.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var selectInput_props = require('./props.js');
var selectInput_useSingle = require('./useSingle.js');
var selectInput_useMultiple = require('./useMultiple.js');
var selectInput_useOverlayInnerStyle = require('./useOverlayInnerStyle.js');
require('../utils/map-props.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('vue');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../popup/popup.js');
require('@babel/runtime/helpers/typeof');
require('@popperjs/core');
require('../utils/dom.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../utils/helper.js');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/camelCase');
require('../_common/js/utils/set-style.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-7c884501.js');
require('dayjs');
require('../utils/mixins.js');
require('../utils/event.js');
require('../popup/props.js');
require('../popup/container.js');
require('lodash/isFunction');
require('../popup/utils.js');
require('../popup/trigger.js');
require('../popup/plugin.js');
require('lodash/kebabCase');
require('lodash/isObject');
require('lodash/pick');
require('../input/index.js');
require('../input/input.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@ldesign/icons-vue');
require('../_common/js/utils/helper.js');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('lodash/isArray');
require('../_common/js/log/log.js');
require('../input/props.js');
require('../input/input-group.js');
require('../loading/index.js');
require('../loading/directive.js');
require('lodash/mapKeys');
require('lodash/isEqual');
require('../loading/plugin.js');
require('../config.js');
require('../loading/loading.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../hooks/tnode.js');
require('lodash/isEmpty');
require('../hooks/render-tnode.js');
require('../hooks/useConfig.js');
require('../hooks/useDefaultValue.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.js');
require('../hooks/useGlobalIcon.js');
require('../tag-input/props.js');
require('../tag-input/hooks/useTagScroll.js');
require('../tag-input/useTagList.js');
require('../tag/index.js');
require('../tag/tag.js');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../tag/check-tag-props.js');
require('../hooks/useVModel.js');
require('../tag-input/hooks/useHover.js');
require('../tag-input/hooks/useDragSorter.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

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__default["default"](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 _SelectInput = VueCompositionAPI.defineComponent({
  name: "TSelectInput",
  props: _objectSpread(_objectSpread({}, selectInput_props["default"]), {}, {
    updateScrollTop: {
      type: Function
    }
  }),
  setup: function setup(props2, context) {
    var selectInputRef = VueCompositionAPI.ref();
    var _useConfig = configProvider_useConfig.useConfig("classPrefix"),
      classPrefix = _useConfig.classPrefix;
    var _toRefs = VueCompositionAPI.toRefs(props2),
      multiple = _toRefs.multiple,
      value = _toRefs.value,
      popupVisible = _toRefs.popupVisible,
      borderless = _toRefs.borderless;
    var _useSingle = selectInput_useSingle["default"](props2, context),
      commonInputProps = _useSingle.commonInputProps,
      singleInputValue = _useSingle.singleInputValue,
      onInnerClear = _useSingle.onInnerClear,
      renderSelectSingle = _useSingle.renderSelectSingle;
    var _useMultiple = selectInput_useMultiple["default"](props2, context),
      multipleInputValue = _useMultiple.multipleInputValue,
      renderSelectMultiple = _useMultiple.renderSelectMultiple;
    var _useOverlayInnerStyle = selectInput_useOverlayInnerStyle["default"](props2, {
        afterHidePopup: onInnerBlur
      }),
      tOverlayInnerStyle = _useOverlayInnerStyle.tOverlayInnerStyle,
      innerPopupVisible = _useOverlayInnerStyle.innerPopupVisible,
      onInnerPopupVisibleChange = _useOverlayInnerStyle.onInnerPopupVisibleChange;
    function onInnerBlur(ctx) {
      var _props2$onBlur;
      var inputValue = props2.multiple ? multipleInputValue.value : singleInputValue.value;
      var params = {
        e: ctx.e,
        inputValue: inputValue
      };
      (_props2$onBlur = props2.onBlur) === null || _props2$onBlur === void 0 ? void 0 : _props2$onBlur.call(props2, props2.value, params);
      context.emit("blur", props2.value, params);
    }
    var classes = VueCompositionAPI.computed(function () {
      var _popupVisible$value, _ref;
      return ["".concat(classPrefix.value, "-select-input"), (_ref = {}, _defineProperty__default["default"](_ref, "".concat(classPrefix.value, "-select-input--borderless"), borderless.value), _defineProperty__default["default"](_ref, "".concat(classPrefix.value, "-select-input--multiple"), multiple.value), _defineProperty__default["default"](_ref, "".concat(classPrefix.value, "-select-input--popup-visible"), (_popupVisible$value = popupVisible.value) !== null && _popupVisible$value !== void 0 ? _popupVisible$value : innerPopupVisible.value), _defineProperty__default["default"](_ref, "".concat(classPrefix.value, "-select-input--empty"), Array.isArray(value.value) ? !value.value.length : !value.value), _ref)];
    });
    return {
      selectInputRef: selectInputRef,
      innerPopupVisible: innerPopupVisible,
      commonInputProps: commonInputProps,
      tOverlayInnerStyle: tOverlayInnerStyle,
      classes: classes,
      onInnerClear: onInnerClear,
      renderSelectSingle: renderSelectSingle,
      renderSelectMultiple: renderSelectMultiple,
      onInnerPopupVisibleChange: onInnerPopupVisibleChange,
      classPrefix: classPrefix
    };
  },
  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_index.Popup, helper.helper([{
      "ref": "selectInputPopupRef",
      "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,
        "disabled": this.disabled
      },
      "scopedSlots": _objectSpread(_objectSpread({}, this.$scopedSlots), {}, {
        content: this.$scopedSlots.panel
      }),
      "key": this.multiple ? "multiple" : "single"
    }, {
      "on": {
        "visible-change": this.onInnerPopupVisibleChange
      }
    }, {}, {
      "props": _objectSpread(_objectSpread({}, this.popupProps), {}, {
        overlayInnerStyle: this.tOverlayInnerStyle
      })
    }, {
      "attrs": {
        "updateScrollTop": this.updateScrollTop
      }
    }]), [this.multiple ? this.renderSelectMultiple({
      commonInputProps: this.commonInputProps,
      onInnerClear: this.onInnerClear,
      popupVisible: visibleProps.visible
    }, h) : this.renderSelectSingle(h, visibleProps.visible)]);
    var tipsNode = utils_renderTnode.renderTNodeJSX(this, "tips");
    return h("div", {
      "ref": "selectInputRef",
      "class": this.classes
    }, [mainContent, tipsNode && h("div", {
      "class": "".concat(this.classPrefix, "-input__tips ").concat(this.classPrefix, "-input__tips--").concat(this.status || "normal")
    }, [tipsNode])]);
  }
});

exports["default"] = _SelectInput;
//# sourceMappingURL=select-input.js.map
