import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
//#region src/components/booking/forms/format.ts
const changeFormValues = ({ clientId, values, forms }) => {
	let _values = {};
	for (let form of forms || []) {
		let value = values[form.form_id] || [];
		if (form.data_range === "customer") _values[form.form_id] = [];
		else _values[form.form_id] = value;
	}
	return _values;
};
const sortFormValues = (list, clientId) => {
	return (list || []).sort((a, b) => {
		var _a$customer, _b$customer, _b$customer2, _a$customer2;
		if ((a === null || a === void 0 || (_a$customer = a.customer) === null || _a$customer === void 0 ? void 0 : _a$customer.id) === clientId && (b === null || b === void 0 || (_b$customer = b.customer) === null || _b$customer === void 0 ? void 0 : _b$customer.id) !== clientId) return -1;
		else if ((b === null || b === void 0 || (_b$customer2 = b.customer) === null || _b$customer2 === void 0 ? void 0 : _b$customer2.id) === clientId && (a === null || a === void 0 || (_a$customer2 = a.customer) === null || _a$customer2 === void 0 ? void 0 : _a$customer2.id) !== clientId) return 1;
		else {
			var _a$customer3, _b$customer3;
			return (a === null || a === void 0 || (_a$customer3 = a.customer) === null || _a$customer3 === void 0 ? void 0 : _a$customer3.id) - (b === null || b === void 0 || (_b$customer3 = b.customer) === null || _b$customer3 === void 0 ? void 0 : _b$customer3.id);
		}
	});
};
const formatAddFormValues = ({ clientId, value, data_range }) => {
	let _value = [...value];
	if (data_range === "customer") _value = _value.map((d) => {
		return _objectSpread2(_objectSpread2({}, d), {}, { client_id: clientId });
	});
	_value = sortFormValues(_value, clientId);
	return _value;
};
//#endregion
export { changeFormValues, formatAddFormValues, sortFormValues };
