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

'use strict';

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

var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var dayjs = require('dayjs');
var customParseFormat = require('../_chunks/dep-b7fa06da.js');
var iconsVueNext = require('@ldesign/icons-vue-next');
var selectInput_index = require('../select-input/index.js');
var _common_js_timePicker_utils = require('../_common/js/time-picker/utils.js');
var hooks_useVModel = require('../hooks/useVModel.js');
var form_hooks = require('../form/hooks.js');
var hooks_useConfig = require('../hooks/useConfig.js');
var hooks_useGlobalIcon = require('../hooks/useGlobalIcon.js');
var timePicker_props = require('./props.js');
var timePicker_panel_timePickerPanel = require('./panel/time-picker-panel.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
require('../_chunks/dep-f4db2590.js');
require('../utils/withInstall.js');
require('../select-input/select-input.js');
require('../popup/index.js');
require('../popup/popup.js');
require('@popperjs/core');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isObject');
require('../utils/dom.js');
require('lodash/isArray');
require('../utils/easing.js');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../_common/js/utils/set-style.js');
require('../popup/props.js');
require('../popup/container.js');
require('@babel/runtime/helpers/toConsumableArray');
require('lodash/isUndefined');
require('../hooks/useResizeObserver.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../select-input/props.js');
require('../select-input/useSingle.js');
require('lodash/pick');
require('../input/index.js');
require('../input/input.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../hooks/tnode.js');
require('../input/props.js');
require('../input/useInput.js');
require('../form/const.js');
require('../input/useLengthLimit.js');
require('lodash/isNumber');
require('../_common/js/log/log.js');
require('../_common/js/utils/helper.js');
require('lodash/isNull');
require('../input/useInputEventHandler.js');
require('../input/useInputWidth.js');
require('../input/input-group.js');
require('../input/input-group-props.js');
require('../loading/index.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../loading/loading.js');
require('../hooks/useTeleport.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../hooks/useDefaultValue.js');
require('../select-input/useMultiple.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.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('../tag-input/hooks/useHover.js');
require('../tag-input/hooks/useDragSorter.js');
require('../select-input/useOverlayInnerStyle.js');
require('../_common/js/time-picker/const.js');
require('../button/button.js');
require('../hooks/useRipple.js');
require('../utils/set-style.js');
require('../hooks/useKeepAnimation.js');
require('../button/props.js');
require('./panel/props.js');
require('lodash/isBoolean');
require('./panel/single-panel.js');
require('lodash/debounce');
require('lodash/range');
require('lodash/padStart');

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

var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);

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; }
dayjs__default["default"].extend(customParseFormat.customParseFormat);
var _TimePicker = vue.defineComponent({
  name: "TTimePicker",
  props: _objectSpread({}, timePicker_props["default"]),
  setup: function setup(props2) {
    var currentValue = vue.ref("");
    var isShowPanel = vue.ref(false);
    var _useConfig = configProvider_useConfig.useConfig("timePicker"),
      globalConfig = _useConfig.globalConfig;
    var _useGlobalIcon = hooks_useGlobalIcon.useGlobalIcon({
        TimeIcon: iconsVueNext.TimeIcon
      }),
      TimeIcon = _useGlobalIcon.TimeIcon;
    var _toRefs = vue.toRefs(props2),
      value = _toRefs.value,
      modelValue = _toRefs.modelValue;
    var _useVModel = hooks_useVModel["default"](value, modelValue, props2.defaultValue, props2.onChange),
      _useVModel2 = _slicedToArray__default["default"](_useVModel, 2),
      innerValue = _useVModel2[0],
      setInnerValue = _useVModel2[1];
    var disabled = form_hooks.useFormDisabled();
    var _toRefs2 = vue.toRefs(props2),
      allowInput = _toRefs2.allowInput,
      format = _toRefs2.format;
    var _useConfig2 = configProvider_useConfig.useConfig("classPrefix"),
      classPrefix = _useConfig2.classPrefix;
    var componentName = hooks_useConfig.usePrefixClass("time-picker");
    var inputClasses = vue.computed(function () {
      return ["".concat(componentName.value, "__group"), _defineProperty__default["default"]({}, "".concat(classPrefix.value, "-is-focused"), isShowPanel.value)];
    });
    var handleShowPopup = function handleShowPopup(visible, context) {
      var _props2$onOpen, _props2$onClose;
      isShowPanel.value = visible;
      visible ? (_props2$onOpen = props2.onOpen) === null || _props2$onOpen === void 0 ? void 0 : _props2$onOpen.call(props2, context) : (_props2$onClose = props2.onClose) === null || _props2$onClose === void 0 ? void 0 : _props2$onClose.call(props2, context);
    };
    var handleClear = function handleClear(context) {
      var e = context.e;
      e.stopPropagation();
      currentValue.value = null;
      setInnerValue(null);
    };
    var handleInputChange = function handleInputChange(value2) {
      currentValue.value = value2;
    };
    var handleInputBlur = function handleInputBlur(value2, _ref2) {
      var _props2$onBlur;
      var e = _ref2.e;
      if (allowInput.value) {
        var isValidTime = _common_js_timePicker_utils.validateInputValue(currentValue.value, format.value);
        if (isValidTime) setInnerValue(_common_js_timePicker_utils.formatInputValue(currentValue.value, format.value));
      }
      (_props2$onBlur = props2.onBlur) === null || _props2$onBlur === void 0 ? void 0 : _props2$onBlur.call(props2, {
        value: String(value2),
        e: e
      });
    };
    var handleClickConfirm = function handleClickConfirm() {
      var isValidTime = _common_js_timePicker_utils.validateInputValue(currentValue.value, format.value);
      if (isValidTime) setInnerValue(currentValue.value);
      isShowPanel.value = false;
    };
    var handlePanelChange = function handlePanelChange(v, e) {
      var _props2$onPick;
      currentValue.value = v;
      (_props2$onPick = props2.onPick) === null || _props2$onPick === void 0 ? void 0 : _props2$onPick.call(props2, v, {
        e: e
      });
    };
    vue.watch(function () {
      return isShowPanel.value;
    }, function () {
      var _innerValue$value;
      currentValue.value = isShowPanel.value ? (_innerValue$value = innerValue.value) !== null && _innerValue$value !== void 0 ? _innerValue$value : "" : "";
    });
    return function () {
      var _innerValue$value2, _innerValue$value3;
      return vue.createVNode("div", {
        "class": componentName.value
      }, [vue.createVNode(selectInput_index.SelectInput, {
        "onFocus": props2.onFocus,
        "onClear": handleClear,
        "disabled": disabled.value,
        "clearable": props2.clearable,
        "allowInput": allowInput.value,
        "className": inputClasses.value,
        "suffixIcon": function suffixIcon() {
          return vue.createVNode(TimeIcon, null, null);
        },
        "popupVisible": isShowPanel.value,
        "onInputChange": handleInputChange,
        "onBlur": handleInputBlur,
        "onPopupVisibleChange": handleShowPopup,
        "placeholder": !innerValue.value ? props2.placeholder || globalConfig.value.placeholder : void 0,
        "value": isShowPanel.value ? currentValue.value : (_innerValue$value2 = innerValue.value) !== null && _innerValue$value2 !== void 0 ? _innerValue$value2 : void 0,
        "inputValue": isShowPanel.value ? currentValue.value : (_innerValue$value3 = innerValue.value) !== null && _innerValue$value3 !== void 0 ? _innerValue$value3 : void 0,
        "inputProps": props2.inputProps,
        "popupProps": _objectSpread({
          overlayInnerStyle: {
            width: "auto",
            padding: 0
          }
        }, props2.popupProps),
        "status": props2.status,
        "tips": props2.tips,
        "panel": function panel() {
          return vue.createVNode(timePicker_panel_timePickerPanel["default"], {
            "steps": props2.steps,
            "format": format.value,
            "value": currentValue.value,
            "isFooterDisplay": true,
            "isShowPanel": isShowPanel.value,
            "disableTime": props2.disableTime,
            "onChange": handlePanelChange,
            "hideDisabledTime": props2.hideDisabledTime,
            "handleConfirmClick": handleClickConfirm
          }, null);
        }
      }, null)]);
    };
  }
});

exports["default"] = _TimePicker;
//# sourceMappingURL=time-picker.js.map
