import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import { CheckboxGroup } from "../group/index.js";
import React, { useMemo } from "react";
import { Form } from "antd";
//#region src/components/eftpos/deviceList/index.tsx
const _excluded = ["input"], _excluded2 = ["input"];
const DeviceList = (props) => {
	const [form] = Form.useForm();
	const { list, onChange } = props;
	console.log(list);
	const onValuesChange = () => {
		onChange(Object.values(form.getFieldsValue()).flat());
	};
	const initialValues = useMemo(() => {
		return list.reduce((target, item) => {
			var _item$input, _item$input2;
			return _objectSpread2(_objectSpread2({}, target), {}, { [item.name]: (item === null || item === void 0 || (_item$input = item.input) === null || _item$input === void 0 ? void 0 : _item$input.value) || (item === null || item === void 0 || (_item$input2 = item.input) === null || _item$input2 === void 0 ? void 0 : _item$input2.defaultValue) });
		}, {});
	}, [list]);
	return /* @__PURE__ */ React.createElement(Form, {
		layout: "vertical",
		onValuesChange,
		form,
		initialValues
	}, list.map((_ref) => {
		let { input } = _ref, formItemProps = _objectWithoutProperties(_ref, _excluded);
		return /* @__PURE__ */ React.createElement(Form.Item, formItemProps, /* @__PURE__ */ React.createElement(CheckboxGroup, input));
	}));
};
var deviceList_default = (_ref2) => {
	let { input } = _ref2, formItemProps = _objectWithoutProperties(_ref2, _excluded2);
	return /* @__PURE__ */ React.createElement(Form.Item, formItemProps, /* @__PURE__ */ React.createElement(DeviceList, input));
};
//#endregion
export { deviceList_default as default };
