"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const event = require("../../../constants/event.js");
const constants$1 = require("../../time-picker/src/constants.js");
const picker = require("../../time-picker/src/common/picker.js");
const constants = require("../../date-picker-panel/src/constants.js");
const index = require("../../date-picker-panel/index.js");
const props = require("./props.js");
const Vue = require("vue");
function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !Vue.isVNode(s);
}
var date_picker_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElDatePicker",
  install: null,
  props: props.datePickerProps,
  emits: [event.UPDATE_MODEL_EVENT],
  setup(props2, { expose, emit, slots }) {
    Vue.provide(constants.ROOT_PICKER_IS_DEFAULT_FORMAT_INJECTION_KEY, Vue.computed(() => {
      return !props2.format;
    }));
    Vue.provide(constants$1.PICKER_POPPER_OPTIONS_INJECTION_KEY, Vue.reactive(Vue.toRef(props2, "popperOptions")));
    const commonPicker = Vue.ref();
    expose({
      focus: () => {
        var _a;
        (_a = commonPicker.value) == null ? void 0 : _a.focus();
      },
      blur: () => {
        var _a;
        (_a = commonPicker.value) == null ? void 0 : _a.blur();
      },
      handleOpen: () => {
        var _a;
        (_a = commonPicker.value) == null ? void 0 : _a.handleOpen();
      },
      handleClose: () => {
        var _a;
        (_a = commonPicker.value) == null ? void 0 : _a.handleClose();
      }
    });
    const onModelValueUpdated = (val) => {
      emit(event.UPDATE_MODEL_EVENT, val);
    };
    return () => {
      const format = props2.format ?? (constants$1.DEFAULT_FORMATS_DATEPICKER[props2.type] || constants$1.DEFAULT_FORMATS_DATE);
      return Vue.createVNode(picker.default, Vue.mergeProps(props2, {
        "format": format,
        "type": props2.type,
        "ref": commonPicker,
        "onUpdate:modelValue": onModelValueUpdated
      }), {
        default: (scopedProps) => Vue.createVNode(index.ElDatePickerPanel, Vue.mergeProps({
          "disabled": props2.disabled,
          "editable": props2.editable,
          "border": false
        }, scopedProps), _isSlot(slots) ? slots : { default: () => [slots] }),
        "range-separator": slots["range-separator"]
      });
    };
  }
});
exports.default = date_picker_default;
