"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.layerTransparencyChanged = exports.areMapsSame = exports.areViewsCloseToEqual = void 0;
var number_1 = require("./number");
var array_1 = require("./array");
/**
 * Determines if the given IMapView instances are equal or close to it
 *
 * @export
 * @param {(IMapView | undefined)} view
 * @param {(IMapView | undefined)} otherView
 * @returns {boolean}
 */
function areViewsCloseToEqual(view, otherView) {
    if (view && otherView) {
        var basePartsEqual = (0, number_1.areNumbersEqual)(view.x, otherView.x) &&
            (0, number_1.areNumbersEqual)(view.y, otherView.y) &&
            (0, number_1.areNumbersEqual)(view.scale, otherView.scale);
        if (view.resolution != null && otherView.resolution != null) {
            return basePartsEqual && (0, number_1.areNumbersEqual)(view.resolution, otherView.resolution);
        }
        else {
            if ((view.resolution == null && otherView.resolution != null) || (view.resolution != null && otherView.resolution == null)) {
                return false;
            }
            else {
                return basePartsEqual;
            }
        }
    }
    else {
        return false;
    }
}
exports.areViewsCloseToEqual = areViewsCloseToEqual;
/**
 * Indicates if the given runtime map instances are the same or have the same name
 *
 * @export
 * @param {RuntimeMap} map
 * @param {RuntimeMap} other
 * @returns {boolean}
 */
function areMapsSame(map, other) {
    if (map != other) {
        return map.Name == other.Name;
    }
    return true;
}
exports.areMapsSame = areMapsSame;
/**
 * Indicates if the given layer transparency sets are different
 * @param set
 * @param other
 */
function layerTransparencyChanged(set, other) {
    if ((!set && other) || (set && !other)) {
        return true;
    }
    var s = set !== null && set !== void 0 ? set : {};
    var o = other !== null && other !== void 0 ? other : {};
    var setLayers = Object.keys(s);
    var otherLayers = Object.keys(o);
    if ((0, array_1.areArraysDifferent)(setLayers, otherLayers))
        return true;
    for (var _i = 0, setLayers_1 = setLayers; _i < setLayers_1.length; _i++) {
        var name_1 = setLayers_1[_i];
        if (s[name_1] != o[name_1]) {
            return true;
        }
    }
    return false;
}
exports.layerTransparencyChanged = layerTransparencyChanged;
//# sourceMappingURL=viewer-state.js.map