"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;
