import { DIRECTIONS, ORIENTATIONS, } from './primitives.js';
export var ConfigType;
(function (ConfigType) {
    ConfigType["Boolean"] = "boolean";
    ConfigType["NullableBoolean"] = "nullableBoolean";
    ConfigType["Number"] = "number";
    ConfigType["NullableNumber"] = "nullableNumber";
    ConfigType["String"] = "string";
    ConfigType["Color"] = "color";
    ConfigType["Comparison"] = "comparison";
    ConfigType["Direction"] = "direction";
    ConfigType["DirectionToggle"] = "directionToggle";
    ConfigType["Orientation"] = "orientation";
    ConfigType["OrientationToggle"] = "orientationToggle";
    ConfigType["Tile"] = "tile";
    ConfigType["Grid"] = "grid";
    ConfigType["NullableGrid"] = "nullableGrid";
    ConfigType["Icon"] = "icon";
    ConfigType["ControlLines"] = "controlLines";
    ConfigType["NullableNote"] = "nullableNote";
})(ConfigType || (ConfigType = {}));
/**
 * Compare two config values for equality, using an appropriate method for the config type.
 *
 * @param type The type of the config.
 * @param a The first value to compare.
 * @param b The second value to compare.
 * @returns Whether the two values are equal.
 */
export function configEquals(type, a, b) {
    if (type === ConfigType.ControlLines) {
        const aLines = a;
        const bLines = b;
        if (aLines.length !== bLines.length)
            return false;
        return aLines.every((line, i) => line.equals(bLines[i]));
    }
    if (type === ConfigType.Tile || type === ConfigType.Grid) {
        return a.equals(b);
    }
    if (type === ConfigType.NullableGrid) {
        if (a === null && b === null)
            return true;
        if (a === null || b === null)
            return false;
        return a.equals(b);
    }
    if (type === ConfigType.DirectionToggle) {
        return DIRECTIONS.every(dir => a[dir] === b[dir]);
    }
    if (type === ConfigType.OrientationToggle) {
        return ORIENTATIONS.every(dir => a[dir] === b[dir]);
    }
    return a === b;
}
