import _TimePicker from "antd/es/time-picker";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["bordered", "value", "format", "style"];
import * as React from 'react';
import { useState, useEffect } from 'react';
import moment from 'moment';
import { LocalFormat } from "./localHelper";
import "./index.less";
var antTimePicker = function antTimePicker(_ref) {
  var bordered = _ref.bordered,
    value = _ref.value,
    format = _ref.format,
    style = _ref.style,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _useState = useState(''),
    ID = _useState[0],
    setID = _useState[1];
  useEffect(function () {
    setID("antTimePicker_" + uuid());
  }, []);
  useEffect(function () {
    var antPicker = document.getElementById(ID);
    if (style) {
      var _antPicker$getElement, _antPicker$getElement2, _antPicker$getElement3, _antPicker$getElement4, _antPicker$getElement5;
      antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement === void 0 ? void 0 : _antPicker$getElement.style.setProperty('--bg-color', style.color);
      antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement2 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement2 === void 0 ? void 0 : _antPicker$getElement2.style.setProperty('color', style.color, 'important');
      antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement3 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement3 === void 0 ? void 0 : _antPicker$getElement3.style.setProperty('font-size', style.fontSize, 'important');
      antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement4 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement4 === void 0 ? void 0 : _antPicker$getElement4.style.setProperty('font-weight', style.fontWeight, 'important');
      antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement5 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement5 === void 0 ? void 0 : _antPicker$getElement5.style.setProperty('line-height', style.lineHeight, 'important');
    }
  }, [style, ID]);
  return /*#__PURE__*/React.createElement("div", {
    className: "ant-time-picker",
    id: ID,
    style: {
      display: 'inline-block'
    }
  }, /*#__PURE__*/React.createElement(_TimePicker, _extends({
    style: style,
    format: format,
    locale: LocalFormat.getDefinedChineseLocal(),
    value: value ? moment(value, format) : undefined,
    bordered: !bordered
  }, otherProps)));
};
antTimePicker.displayName = 'antTimePicker';
export default antTimePicker;
export function uuid() {
  return (Math.random() * 1e6 >> 0).toString(36);
}