import m from "../../../../@babel/runtime/helpers/esm/extends.mjs";
import * as C from "react";
import w from "./MonthHeader.mjs";
import D, { MONTH_COL_COUNT as Y } from "./MonthBody.mjs";
import { createKeyDownHandler as x } from "../../utils/uiUtil.mjs";
function k(e) {
  var u = e.prefixCls, d = e.operationRef, g = e.onViewDateChange, i = e.generateConfig, f = e.value, n = e.viewDate, l = e.onPanelChange, c = e.onSelect, v = "".concat(u, "-month-panel");
  d.current = {
    onKeyDown: function(t) {
      return x(t, {
        onLeftRight: function(r) {
          c(i.addMonth(f || n, r), "key");
        },
        onCtrlLeftRight: function(r) {
          c(i.addYear(f || n, r), "key");
        },
        onUpDown: function(r) {
          c(i.addMonth(f || n, r * Y), "key");
        },
        onEnter: function() {
          l("date", f || n);
        }
      });
    }
  };
  var h = function(t) {
    var o = i.addYear(n, t);
    g(o), l(null, o);
  };
  return /* @__PURE__ */ C.createElement("div", {
    className: v
  }, /* @__PURE__ */ C.createElement(w, m({}, e, {
    prefixCls: u,
    onPrevYear: function() {
      h(-1);
    },
    onNextYear: function() {
      h(1);
    },
    onYearClick: function() {
      l("year", n);
    }
  })), /* @__PURE__ */ C.createElement(D, m({}, e, {
    prefixCls: u,
    onSelect: function(t) {
      c(t, "mouse"), l("date", t);
    }
  })));
}
export {
  k as default
};
