var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/virtual-keyboard/Keyboard/index.tsx
var Keyboard_exports = {};
__export(Keyboard_exports, {
  default: () => Keyboard_default
});
module.exports = __toCommonJS(Keyboard_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_index = require("./index.less");
var import_classnames = __toESM(require("classnames"));
var import_ahooks = require("ahooks");
var list = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "+", "ok"];
var defaultArr = [];
var Keyboard = (props) => {
  const {
    items = defaultArr,
    className,
    style,
    onChange,
    rightItems,
    keydown = true
  } = props;
  const contentRef = (0, import_react.useRef)(null);
  const size = (0, import_ahooks.useSize)(contentRef);
  (0, import_ahooks.useEventListener)("keydown", (ev) => {
    console.log("ev", ev);
    if (!keydown) {
      return;
    }
    let key = ev.key;
    if (key === "Enter") {
      key = "ok";
    }
    if (key === "keydown") {
      key = "+";
    }
    if (list.includes(key)) {
      onChange == null ? void 0 : onChange(key);
    }
  });
  const getHeight = (0, import_ahooks.useMemoizedFn)((itemSize = 1) => {
    return ((size == null ? void 0 : size.width) || 0) / 4 * itemSize + (itemSize - 1) * 7;
  });
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("virtual-keyboard-wrap", className),
      style
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_classnames.default)("virtual-keyboard-content"), ref: contentRef }, items.map((item) => {
      var _a;
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "virtual-keyboard-item", style: item.style }, /* @__PURE__ */ import_react.default.createElement(
        import_antd.Button,
        {
          id: `virtual-keyboard-${item.value}`,
          key: item.value,
          type: item.type,
          className: "virtual-keyboard-item-button",
          style: {
            color: item.type === "primary" ? "#fff" : ((_a = item.style) == null ? void 0 : _a.color) || void 0
          },
          disabled: item.disabled,
          onClick: (e) => {
            onChange == null ? void 0 : onChange(item.value);
          }
        },
        item.label
      ));
    })),
    rightItems && /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          "virtual-keyboard-content",
          "virtual-keyboard-right"
        ),
        style: { flex: `0 0 calc((100% - 21px) / 4 * 1)` }
      },
      rightItems == null ? void 0 : rightItems.map((item) => {
        var _a, _b;
        return /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            className: "virtual-keyboard-item",
            style: {
              ...item.style || {},
              height: getHeight(item.size)
            }
          },
          /* @__PURE__ */ import_react.default.createElement(
            import_antd.Button,
            {
              id: `virtual-keyboard-${item.value}`,
              key: item.value,
              type: item.type,
              className: "virtual-keyboard-item-button",
              style: {
                fontSize: ((_a = item.style) == null ? void 0 : _a.fontSize) || 25,
                color: item.type === "primary" ? "#fff" : ((_b = item.style) == null ? void 0 : _b.color) || void 0,
                ...item.type === "primary" ? item.style || {} : {}
              },
              disabled: item.disabled,
              onClick: (e) => {
                onChange == null ? void 0 : onChange(item.value);
              }
            },
            item.label
          )
        );
      })
    )
  );
};
var Keyboard_default = import_react.default.memo(Keyboard);
