/**
 * ldesign v0.4.6
 * (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 VueCompositionAPI = require('@vue/composition-api');
var dayjs = require('dayjs');
var customParseFormat = require('../_chunks/dep-6e3fbdd7.js');
var iconsVue = require('@ldesign/icons-vue');
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 hooks_useConfig = require('../hooks/useConfig.js');
var hooks_useGlobalIcon = require('../hooks/useGlobalIcon.js');
var timePicker_panel_timePickerPanel = require('./panel/time-picker-panel.js');
var timePicker_props = require('./props.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
require('../_chunks/dep-7c884501.js');
require('../utils/withInstall.js');
require('vue');
require('lodash/capitalize');
require('../select-input/select-input.js');
require('../_chunks/dep-c3e1ffac.js');
require('../popup/index.js');
require('../utils/map-props.js');
require('@babel/runtime/helpers/objectWithoutProperties');
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/render-tnode.js');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/helper.js');
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('../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('../select-input/props.js');
require('../select-input/useSingle.js');
require('lodash/isObject');
require('lodash/pick');
require('../input/index.js');
require('../input/input.js');
require('@babel/runtime/helpers/toConsumableArray');
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/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('../utils/ripple.js');
require('../button/props.js');
require('./panel/single-panel.js');
require('lodash/debounce');
require('lodash/range');
require('lodash/padStart');
require('./panel/props.js');

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 = VueCompositionAPI.defineComponent({
  name: "TTimePicker",
  props: _objectSpread({}, timePicker_props["default"]),
  setup: function setup(props2, ctx) {
    var _useConfig = configProvider_useConfig.useConfig("classPrefix"),
      classPrefix = _useConfig.classPrefix;
    var componentName = hooks_useConfig.usePrefixClass("time-picker");
    var _useGlobalIcon = hooks_useGlobalIcon.useGlobalIcon({
        TimeIcon: iconsVue.TimeIcon
      }),
      TimeIcon = _useGlobalIcon.TimeIcon;
    var currentValue = VueCompositionAPI.ref("");
    var isShowPanel = VueCompositionAPI.ref(false);
    var _useConfig2 = configProvider_useConfig.useConfig("timePicker"),
      global = _useConfig2.global;
    var _toRefs = VueCompositionAPI.toRefs(props2),
      value = _toRefs.value;
    var _useVModel = hooks_useVModel["default"](value, props2.defaultValue, props2.onChange, "change"),
      _useVModel2 = _slicedToArray__default["default"](_useVModel, 2),
      innerValue = _useVModel2[0],
      setInnerValue = _useVModel2[1];
    var inputClasses = VueCompositionAPI.computed(function () {
      return ["".concat(componentName.value, "__group"), _defineProperty__default["default"]({}, "".concat(classPrefix.value, "-is-focused"), isShowPanel.value)];
    });
    var handleShowPopup = function handleShowPopup(visible, context) {
      isShowPanel.value = visible;
      if (visible) {
        var _props2$onOpen;
        (_props2$onOpen = props2.onOpen) === null || _props2$onOpen === void 0 ? void 0 : _props2$onOpen.call(props2, context);
        ctx.emit("open", context);
      } else {
        var _props2$onClose;
        (_props2$onClose = props2.onClose) === null || _props2$onClose === void 0 ? void 0 : _props2$onClose.call(props2, context);
        ctx.emit("close", 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 (props2.allowInput) {
        var isValidTime = _common_js_timePicker_utils.validateInputValue(currentValue.value, props2.format);
        if (isValidTime) setInnerValue(_common_js_timePicker_utils.formatInputValue(currentValue.value, props2.format));
      }
      (_props2$onBlur = props2.onBlur) === null || _props2$onBlur === void 0 ? void 0 : _props2$onBlur.call(props2, {
        value: value2,
        e: e
      });
      ctx.emit("blur", {
        value: value2,
        e: e
      });
    };
    var handleClickConfirm = function handleClickConfirm() {
      var isValidTime = _common_js_timePicker_utils.validateInputValue(currentValue.value, props2.format);
      if (isValidTime) setInnerValue(currentValue.value);
      isShowPanel.value = false;
    };
    var handlePanelChange = function handlePanelChange(v) {
      currentValue.value = v;
    };
    var handleOnFocus = function handleOnFocus(context) {
      var _props2$onFocus;
      (_props2$onFocus = props2.onFocus) === null || _props2$onFocus === void 0 ? void 0 : _props2$onFocus.call(props2, context);
      ctx.emit("focus", context);
    };
    var handleOnPick = function handleOnPick(v, e) {
      var _props2$onPick;
      (_props2$onPick = props2.onPick) === null || _props2$onPick === void 0 ? void 0 : _props2$onPick.call(props2, v, {
        e: e
      });
      ctx.emit("pick", v, {
        e: e
      });
    };
    VueCompositionAPI.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 {
      handleClickConfirm: handleClickConfirm,
      handlePanelChange: handlePanelChange,
      handleInputBlur: handleInputBlur,
      handleInputChange: handleInputChange,
      handleClear: handleClear,
      handleShowPopup: handleShowPopup,
      handleOnFocus: handleOnFocus,
      handleOnPick: handleOnPick,
      inputClasses: inputClasses,
      componentName: componentName,
      innerValue: innerValue,
      isShowPanel: isShowPanel,
      global: global,
      currentValue: currentValue,
      TimeIcon: TimeIcon
    };
  },
  render: function render() {
    var _this$innerValue,
      _this$innerValue2,
      _this = this;
    var h = arguments[0];
    var TimeIcon = this.TimeIcon;
    return h("div", {
      "class": this.componentName
    }, [h(selectInput_index.SelectInput, {
      "props": _objectSpread({}, {
        onFocus: this.handleOnFocus,
        onClear: this.handleClear,
        onBlur: this.handleInputBlur,
        onInputChange: this.handleInputChange,
        disabled: this.disabled,
        clearable: this.clearable,
        allowInput: this.allowInput,
        "class": this.inputClasses,
        suffixIcon: function suffixIcon() {
          return h(TimeIcon);
        },
        popupVisible: this.isShowPanel,
        placeholder: !this.innerValue ? this.placeholder || this.global.placeholder : void 0,
        value: this.isShowPanel ? this.currentValue : (_this$innerValue = this.innerValue) !== null && _this$innerValue !== void 0 ? _this$innerValue : void 0,
        inputValue: this.isShowPanel ? this.currentValue : (_this$innerValue2 = this.innerValue) !== null && _this$innerValue2 !== void 0 ? _this$innerValue2 : void 0,
        inputProps: _objectSpread(_objectSpread({}, this.inputProps), {}, {
          size: this.size
        }),
        status: this.status,
        tips: this.tips,
        panel: function panel() {
          return h(timePicker_panel_timePickerPanel["default"], {
            "props": _objectSpread({}, {
              steps: _this.steps,
              format: _this.format,
              value: _this.currentValue,
              isFooterDisplay: true,
              isShowPanel: _this.isShowPanel,
              disableTime: _this.disableTime,
              onChange: _this.handlePanelChange,
              onPick: _this.handleOnPick,
              hideDisabledTime: _this.hideDisabledTime,
              handleConfirmClick: _this.handleClickConfirm,
              presets: _this.presets
            })
          });
        },
        popupProps: _objectSpread({
          overlayInnerStyle: {
            width: "auto",
            padding: 0
          },
          onVisibleChange: this.handleShowPopup
        }, this.popupProps)
      })
    })]);
  }
});

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