const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let ahooks = require("ahooks");
require("./index.less");
//#region src/components/virtual-keyboard/Keyboard/index.tsx
const list = [
	"1",
	"2",
	"3",
	"4",
	"5",
	"6",
	"7",
	"8",
	"9",
	"0",
	"+",
	"ok"
];
const defaultArr = [];
const Keyboard = (props) => {
	const { items = defaultArr, className, style, onChange, rightItems, keydown = true } = props;
	const contentRef = (0, react.useRef)(null);
	const size = (0, ahooks.useSize)(contentRef);
	(0, 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 || onChange === void 0 || onChange(key);
	});
	const getHeight = (0, ahooks.useMemoizedFn)((itemSize = 1) => {
		return ((size === null || size === void 0 ? void 0 : size.width) || 0) / 4 * itemSize + (itemSize - 1) * 7;
	});
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("virtual-keyboard-wrap", className),
		style
	}, /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("virtual-keyboard-content"),
		ref: contentRef
	}, items.map((item) => {
		var _item$style;
		return /* @__PURE__ */ react.default.createElement("div", {
			className: "virtual-keyboard-item",
			style: item.style
		}, /* @__PURE__ */ react.default.createElement(antd.Button, {
			id: `virtual-keyboard-${item.value}`,
			key: item.value,
			type: item.type,
			className: "virtual-keyboard-item-button",
			style: { color: item.type === "primary" ? "#fff" : ((_item$style = item.style) === null || _item$style === void 0 ? void 0 : _item$style.color) || void 0 },
			disabled: item.disabled,
			onClick: (e) => {
				onChange === null || onChange === void 0 || onChange(item.value);
			}
		}, item.label));
	})), rightItems && /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("virtual-keyboard-content", "virtual-keyboard-right"),
		style: { flex: `0 0 calc((100% - 21px) / 4 * 1)` }
	}, rightItems === null || rightItems === void 0 ? void 0 : rightItems.map((item) => {
		var _item$style2, _item$style3;
		return /* @__PURE__ */ react.default.createElement("div", {
			className: "virtual-keyboard-item",
			style: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item.style || {}), {}, { height: getHeight(item.size) })
		}, /* @__PURE__ */ react.default.createElement(antd.Button, {
			id: `virtual-keyboard-${item.value}`,
			key: item.value,
			type: item.type,
			className: "virtual-keyboard-item-button",
			style: require_objectSpread2._objectSpread2({
				fontSize: ((_item$style2 = item.style) === null || _item$style2 === void 0 ? void 0 : _item$style2.fontSize) || 25,
				color: item.type === "primary" ? "#fff" : ((_item$style3 = item.style) === null || _item$style3 === void 0 ? void 0 : _item$style3.color) || void 0
			}, item.type === "primary" ? item.style || {} : {}),
			disabled: item.disabled,
			onClick: (e) => {
				onChange === null || onChange === void 0 || onChange(item.value);
			}
		}, item.label));
	})));
};
var Keyboard_default = react.default.memo(Keyboard);
//#endregion
exports.default = Keyboard_default;
