// 套餐比较两个对象是否相等
export function isObjectEqual(obj1, obj2) {
	if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) {
		return obj1 === obj2;
	}
	const keys1 = Object.keys(obj1);
	const keys2 = Object.keys(obj2);
	if (keys1.length !== keys2.length) {
		return false;
	}
	for (const key of keys1) {
		if (Array.isArray(obj1[key]) && Array.isArray(obj2[key])) {
			if (!isArrayEqual(obj1[key], obj2[key])) {
				return false;
			}
		} else if (!isObjectEqual(obj1[key], obj2[key])) {
			return false;
		}
	}
	return true;
}

// 比较两个数组是否相等（忽略顺序）
export function isArrayEqual(arr1, arr2) {
	if (arr1.length !== arr2.length) {
		return false;
	}
	const usedIndices = new Array(arr2.length).fill(false);
	for (const item1 of arr1) {
		let found = false;
		for (let i = 0; i < arr2.length; i++) {
			if (!usedIndices[i] && isObjectEqual(item1, arr2[i])) {
				usedIndices[i] = true;
				found = true;
				break;
			}
		}
		if (!found) {
			return false;
		}
	}
	return true;
}