/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

import { h as helper } from '../../chunks/helper.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, toRefs, computed } from '@vue/composition-api';
import { Popup } from '../popup/index.js';
import props from './props.js';
import useSingle from './hooks/use-single.js';
import useMultiple from './hooks/use-multiple.js';
import useOverlayInnerStyle from './hooks/use-overlay-innerstyle.js';
import { useConfig } from '../config-provider/useConfig.js';
import '../../chunks/_commonjsHelpers.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/typeof';
import '@popperjs/core';
import '../../chunks/set-style.js';
import '../../utils/dom.js';
import 'vue';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-node.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../popup/props.js';
import '../popup/container.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/mixins.js';
import '../../utils/map-props.js';
import '../../utils/with-install.js';
import '../../config.js';
import '../popup/style';
import '../popup/type.js';
import 'lodash/isObject';
import 'lodash/pick';
import '../../hooks/lnode.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import '../../hooks/render-lnode.js';
import '../../hooks/use-config.js';
import '../../hooks/use-default-value.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 _SelectInput = defineComponent({
  name: "LSelectInput",
  components: {
    LPopup: Popup
  },
  props: _objectSpread(_objectSpread({}, props), {}, {
    updateScrollTop: {
      type: Function
    }
  }),
  setup: function setup(props2, context) {
    var selectInputRef = ref();
    var selectInputWrapRef = ref();

    var _useConfig = useConfig("classPrefix"),
        classPrefix = _useConfig.classPrefix;

    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 _useOverlayInnerStyle = useOverlayInnerStyle(props2),
        tOverlayInnerStyle = _useOverlayInnerStyle.tOverlayInnerStyle,
        innerPopupVisible = _useOverlayInnerStyle.innerPopupVisible,
        onInnerPopupVisibleChange = _useOverlayInnerStyle.onInnerPopupVisibleChange;

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

      return [(_ref = {}, _defineProperty(_ref, "".concat(classPrefix.value, "-select-input--borderless"), borderless.value), _defineProperty(_ref, "".concat(classPrefix.value, "-select-input--multiple"), multiple.value), _defineProperty(_ref, "".concat(classPrefix.value, "-select-input--popup-visible"), (_popupVisible$value = popupVisible.value) !== null && _popupVisible$value !== void 0 ? _popupVisible$value : innerPopupVisible.value), _defineProperty(_ref, "".concat(classPrefix.value, "-select-input--empty"), value.value instanceof Array ? !value.value.length : !value.value), _ref)];
    });
    return {
      selectInputWrapRef: selectInputWrapRef,
      innerPopupVisible: innerPopupVisible,
      commonInputProps: commonInputProps,
      tOverlayInnerStyle: tOverlayInnerStyle,
      selectInputRef: selectInputRef,
      popupClasses: popupClasses,
      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("l-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,
        "disabled": this.disabled
      },
      "scopedSlots": _objectSpread(_objectSpread({}, this.$scopedSlots), {}, {
        content: this.$scopedSlots.panel
      })
    }, {
      "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)]);
    if (!this.tips) return mainContent;
    return h("div", {
      "ref": "selectInputWrapRef",
      "class": "".concat(this.classPrefix, "-select-input__wrap")
    }, [mainContent, h("div", {
      "class": "".concat(this.classPrefix, "-input__tips ").concat(this.classPrefix, "-input__tips--").concat(this.status || "normal")
    }, [this.tips])]);
  }
});

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