const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_index = require("./form/index.js");
//#region src/components/eftpos/const.ts
let Eftpos = /* @__PURE__ */ function(Eftpos) {
	Eftpos["Payo"] = "payo";
	Eftpos["Tyro"] = "tyro";
	Eftpos["Windcave"] = "windcave";
	Eftpos["Stripe"] = "stripe";
	Eftpos["Linkly"] = "linkly";
	Eftpos["Huifu"] = "huifu";
	Eftpos["MX51"] = "mx51";
	Eftpos["AdyenPos"] = "adyenpos";
	Eftpos["AdyenAlipay"] = "adyenalipay";
	Eftpos["AdyenWechat"] = "adyenwechat";
	return Eftpos;
}({});
/** 需要设置商家参数的厂商类型 */
const TYPES_WITH_MERCHANT_SETTINGS = new Set([Eftpos.Windcave, Eftpos.AdyenPos]);
let DeviceEnum = /* @__PURE__ */ function(DeviceEnum) {
	/** 新增 */
	DeviceEnum["Add"] = "add";
	/** 编辑 */
	DeviceEnum["Edit"] = "edit";
	/** 重新链接 */
	DeviceEnum["Repair"] = "repair";
	return DeviceEnum;
}({});
/**
* @title: 获取表单结果数据
* @description: 获取表单结果数据
* @param {any} list 表单配置信息
* @return {*} 表单结果信息
* @Author: hongbing.wang
* @Date: 2024-08-19 11:10
*/
const getDefaultValue = (list) => {
	return list.reduce((target, item) => {
		if (Array.isArray(item.children) && item.children.length) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, target), {}, { [item.__sourceName]: getDefaultValue(item.children) });
		if (!item.Component) return target;
		const ComponentName = item.Component;
		if (require_index.helpMapping[ComponentName]) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, target), require_index.helpMapping[ComponentName].getCommDefaultVal(item));
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, target), {}, { [item.__sourceName]: item.input.defaultValue });
	}, {});
};
/**
* @title: 构建通用表单配置信息,构建动态表单
* @description: 
* @param {any} field : array 字段信息 value 结果信息,name 上级字段信息用于嵌套, getComm  : 获取字段组件配置信息
* @return form 表单配置信息
* @Author: hongbing.wang
* @Date: 2024-08-19 11:11
*/
function getCommByFields(_x2) {
	return _getCommByFields.apply(this, arguments);
}
function _getCommByFields() {
	_getCommByFields = require_asyncToGenerator._asyncToGenerator(function* ({ field, value, name = [], getComm }) {
		return (yield Promise.all(field.map(function() {
			var _ref = require_asyncToGenerator._asyncToGenerator(function* (item) {
				if (typeof item === "string") {
					const commConfig = yield getComm(value ? {
						field: item,
						value: value[item]
					} : { field: item }, value);
					if (!commConfig) return;
					if (Array.isArray(commConfig)) return commConfig.map((item) => {
						const helpFn = require_index.helpMapping[item.Component];
						if (helpFn) return helpFn.getCommName(item, name);
						item.__sourceName = item.name;
						item.name = name.length > 0 ? [...name, item.name] : item.name;
						return item;
					});
					const helpFn = require_index.helpMapping[commConfig.Component];
					if (helpFn) return helpFn.getCommName(commConfig, name);
					commConfig.__sourceName = commConfig.name;
					commConfig.name = name.length > 0 ? [...name, commConfig.name] : commConfig.name;
					return commConfig;
				}
				const children = yield getCommByFields({
					field: item.children,
					value,
					name: [...name || [], item.name],
					getComm
				});
				return {
					name: name.length > 0 ? [...name, item.name] : item.name,
					__sourceName: item.name,
					children
				};
			});
			return function(_x) {
				return _ref.apply(this, arguments);
			};
		}()))).flat().filter(Boolean);
	});
	return _getCommByFields.apply(this, arguments);
}
//#endregion
exports.DeviceEnum = DeviceEnum;
exports.Eftpos = Eftpos;
exports.TYPES_WITH_MERCHANT_SETTINGS = TYPES_WITH_MERCHANT_SETTINGS;
exports.getCommByFields = getCommByFields;
exports.getDefaultValue = getDefaultValue;
