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, RadioGroup } from "../group/index.js";
import surcharge_default, { getCommDefaultVal, getCommName } from "../surcharge/index.js";
import receipt_default, { getCommDefaultVal as getCommDefaultVal$1, getCommName as getCommName$1 } from "../receipt/index.js";
import deviceList_default from "../deviceList/index.js";
import React from "react";
import { Cascader, Checkbox, DatePicker, Form, Input, InputNumber, Radio, Select, Slider, Switch, TimePicker, Transfer, TreeSelect, Upload } from "antd";
//#region src/components/eftpos/form/index.tsx
const _excluded = ["__sourceName", "Component"], _excluded2 = ["input"], _excluded3 = ["input"];
const Mapping = {
	Input,
	InputNumber,
	Checkbox,
	"Checkbox.Group": CheckboxGroup,
	Radio,
	"Radio.Group": RadioGroup,
	"Radio.Button": Radio.Button,
	Cascader,
	DatePicker,
	Select,
	Slider,
	Switch,
	TimePicker,
	Transfer,
	TreeSelect,
	Upload
};
const CustomMapping = {
	Surcharge: surcharge_default,
	DeviceList: deviceList_default,
	Receipt: receipt_default
};
/**
* @title: 递归循环表单数据
* @Author: hongbing.wang
* @Date: 2024-08-20 13:21
*/
const CustomFormItem = ({ formItemList, level = 0, onChange }) => {
	return /* @__PURE__ */ React.createElement(React.Fragment, null, formItemList.map((_ref, index) => {
		let { __sourceName, Component } = _ref, item = _objectWithoutProperties(_ref, _excluded);
		if (Array.isArray(item.children)) return /* @__PURE__ */ React.createElement(CustomFormItem, {
			formItemList: item.children,
			onChange,
			key: item.name ? `${item.name}${level}` : `${Component}${index}${level}`,
			level: level + 1
		});
		if (typeof Component === "object") return /* @__PURE__ */ React.createElement(Component, _objectSpread2(_objectSpread2({}, item), {}, { key: `${item.name}${level}` }));
		if (Mapping[Component]) {
			const Comm = Mapping[Component];
			const { input } = item, formItemProps = _objectWithoutProperties(item, _excluded2);
			return /* @__PURE__ */ React.createElement(Form.Item, _objectSpread2(_objectSpread2({}, formItemProps), {}, { key: `${item.name}${level}` }), /* @__PURE__ */ React.createElement(Comm, input));
		}
		if (Mapping[Component]) {
			const Comm = Mapping[Component];
			const { input } = item, formItemProps = _objectWithoutProperties(item, _excluded3);
			return /* @__PURE__ */ React.createElement(Form.Item, _objectSpread2(_objectSpread2({}, formItemProps), {}, { key: `${item.name}${level}` }), /* @__PURE__ */ React.createElement(Comm, input));
		}
		if (CustomMapping[Component]) {
			const Comm = CustomMapping[Component];
			return /* @__PURE__ */ React.createElement(Comm, _objectSpread2(_objectSpread2({}, item), {}, { key: `${item.name}${level}` }));
		}
		throw TypeError(`pos物料库 输入组件类型 ${Component} 无法映射,请正确传入组件类型`);
	}));
};
const helpMapping = {
	Surcharge: {
		getCommName,
		getCommDefaultVal
	},
	Receipt: {
		getCommName: getCommName$1,
		getCommDefaultVal: getCommDefaultVal$1
	}
};
//#endregion
export { CustomFormItem as default, helpMapping };
