import d from "../../../../@babel/runtime/helpers/esm/extends.mjs";
import E from "../../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import T from "../../../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import $ from "../../../../classnames/index.mjs";
import * as n from "react";
import { createKeyDownHandler as p } from "../../utils/uiUtil.mjs";
import I from "./TimeBody.mjs";
import K from "./TimeHeader.mjs";
var N = function(r) {
  return r.filter(function(o) {
    return o !== !1;
  }).length;
};
function O(e) {
  var r = e.generateConfig, o = e.format, w = o === void 0 ? "HH:mm:ss" : o, a = e.prefixCls, C = e.active, x = e.operationRef, R = e.showHour, h = e.showMinute, H = e.showSecond, c = e.use12Hours, g = c === void 0 ? !1 : c, y = e.onSelect, S = e.value, m = "".concat(a, "-time-panel"), i = n.useRef(), _ = n.useState(-1), l = T(_, 2), f = l[0], t = l[1], s = N([R, h, H, g]);
  return x.current = {
    onKeyDown: function(B) {
      return p(B, {
        onLeftRight: function(u) {
          t((f + u + s) % s);
        },
        onUpDown: function(u) {
          f === -1 ? t(0) : i.current && i.current.onUpDown(u);
        },
        onEnter: function() {
          y(S || r.getNow(), "key"), t(-1);
        }
      });
    },
    onBlur: function() {
      t(-1);
    }
  }, /* @__PURE__ */ n.createElement("div", {
    className: $(m, E({}, "".concat(m, "-active"), C))
  }, /* @__PURE__ */ n.createElement(K, d({}, e, {
    format: w,
    prefixCls: a
  })), /* @__PURE__ */ n.createElement(I, d({}, e, {
    prefixCls: a,
    activeColumnIndex: f,
    operationRef: i
  })));
}
export {
  O as default
};
