

const require_objectEquality = require('./objectEquality.js');

//#region src/utils/deepEquality.ts
function deepEquality(x, y) {
	const isXSimpleEqualY = simpleEqual(x, y);
	if (isXSimpleEqualY !== void 0) return isXSimpleEqualY;
	if (!(x instanceof Map) || !(y instanceof Map)) return require_objectEquality.areObjectsEqual(x, y);
	const xMap = x;
	const yMap = y;
	if (!equalsIgnoreOrder(Array.from(xMap.keys()), Array.from(yMap.keys()))) return false;
	return Array.from(xMap.entries()).every(([key, xVal]) => deepEquality(xVal, yMap.get(key)));
}
/**
* @note This will only work for primitive array equality
*/
function equalsIgnoreOrder(a, b) {
	if (a.length !== b.length) return false;
	return a.every((k) => b.includes(k));
}
/**
* @note This will only work for primitive array equality
*/
function equalsWithOrder(lhs, rhs) {
	if (lhs.length !== rhs.length) return false;
	return lhs.every((k, i) => k === rhs[i]);
}
function simpleEqual(x, y) {
	if (x === y) return true;
	if ((x === null || x === void 0) && (y === null || y === void 0)) return x === y;
	if (x.constructor !== y.constructor) return false;
	if (x instanceof Function) return x === y;
	if (x instanceof RegExp) return x === y;
	if (x.valueOf && y.valueOf && x.valueOf() === y.valueOf()) return true;
	if (x instanceof Date || y instanceof Date) return false;
}

//#endregion
exports.deepEquality = deepEquality;
exports.equalsIgnoreOrder = equalsIgnoreOrder;
exports.equalsWithOrder = equalsWithOrder;