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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var dayjs = require('dayjs');
var customParseFormat = require('../../_chunks/dep-b7fa06da.js');
var _common_js_timePicker_const = require('../../_common/js/time-picker/const.js');
var button_button = require('../../button/button.js');
var hooks_useConfig = require('../../hooks/useConfig.js');
var timePicker_panel_props = require('./props.js');
var timePicker_panel_singlePanel = require('./single-panel.js');
var configProvider_useConfig = require('../../config-provider/useConfig.js');
require('../../_chunks/dep-f4db2590.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../../loading/index.js');
require('../../utils/withInstall.js');
require('../../loading/directive.js');
require('../../loading/plugin.js');
require('../../utils/dom.js');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isArray');
require('../../utils/easing.js');
require('../../loading/loading.js');
require('@babel/runtime/helpers/slicedToArray');
require('../../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../hooks/useTeleport.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../_common/js/loading/circle-adapter.js');
require('../../_common/js/utils/set-style.js');
require('../../_common/js/utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
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('../../hooks/useRipple.js');
require('../../utils/set-style.js');
require('../../hooks/useKeepAnimation.js');
require('../../form/hooks.js');
require('../../hooks/tnode.js');
require('../../button/props.js');
require('lodash/isBoolean');
require('../props.js');
require('lodash/debounce');
require('lodash/range');
require('lodash/padStart');
require('../../_common/js/time-picker/utils.js');

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

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 _TimePickerPanel = vue.defineComponent({
  name: "TTimePickerPanel",
  props: _objectSpread(_objectSpread({}, timePicker_panel_props.panelProps()), {}, {
    isFooterDisplay: Boolean,
    handleConfirmClick: Function,
    onChange: Function
  }),
  setup: function setup(props) {
    var panelClassName = hooks_useConfig.usePrefixClass("time-picker__panel");
    var _toRefs = vue.toRefs(props),
      steps = _toRefs.steps,
      isFooterDisplay = _toRefs.isFooterDisplay,
      isShowPanel = _toRefs.isShowPanel;
    var triggerScroll = vue.ref(false);
    var panelRef = vue.ref();
    var _useConfig = configProvider_useConfig.useConfig("timePicker"),
      globalConfig = _useConfig.globalConfig;
    var showNowTimeBtn = vue.computed(function () {
      return !!steps.value.filter(function (v) {
        return v > 1;
      }).length;
    });
    var defaultValue = vue.computed(function () {
      var isStepsSet = showNowTimeBtn.value;
      if (props.value) return dayjs__default["default"](props.value, props.format);
      if (isStepsSet) return dayjs__default["default"]().hour(0).minute(0).second(0);
      return dayjs__default["default"]();
    });
    var panelColUpdate = function panelColUpdate() {
      vue.nextTick(function () {
        triggerScroll.value = true;
      });
    };
    var resetTriggerScroll = function resetTriggerScroll() {
      triggerScroll.value = false;
    };
    vue.onMounted(function () {
      panelColUpdate();
    });
    vue.watch(function () {
      return isShowPanel.value;
    }, function () {
      panelColUpdate();
    });
    return function () {
      return vue.createVNode("div", {
        "class": panelClassName.value
      }, [vue.createVNode("div", {
        "class": "".concat(panelClassName.value, "-section-body")
      }, [vue.createVNode(timePicker_panel_singlePanel["default"], vue.mergeProps(props, {
        "ref": panelRef,
        "format": props.format || _common_js_timePicker_const.DEFAULT_FORMAT,
        "steps": props.steps || _common_js_timePicker_const.DEFAULT_STEPS,
        "value": props.value,
        "triggerScroll": triggerScroll.value,
        "onChange": props.onChange,
        "resetTriggerScroll": resetTriggerScroll,
        "isShowPanel": props.isShowPanel
      }), null)]), isFooterDisplay.value ? vue.createVNode("div", {
        "class": "".concat(panelClassName.value, "-section-footer")
      }, [vue.createVNode(button_button["default"], {
        "theme": "primary",
        "variant": "base",
        "onClick": function onClick() {
          return props.handleConfirmClick(defaultValue.value);
        },
        "size": "small"
      }, {
        "default": function _default() {
          return [globalConfig.value.confirm];
        }
      }), !showNowTimeBtn.value ? vue.createVNode(button_button["default"], {
        "theme": "primary",
        "variant": "text",
        "size": "small",
        "onClick": function onClick() {
          return props.onChange(dayjs__default["default"]().format(props.format));
        }
      }, {
        "default": function _default() {
          return [globalConfig.value.now];
        }
      }) : null]) : null]);
    };
  }
});

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