"use strict";
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.autoAdjustColumnsSize = exports.getNewColumnStates = exports.generateBindables = void 0;
var aurelia_framework_1 = require("aurelia-framework");
function generateBindables(names, bindingModeToUse) {
    return function (target, key, descriptor) {
        var behaviorResource = aurelia_framework_1.metadata.getOrCreateOwn(aurelia_framework_1.metadata.resource, aurelia_framework_1.HtmlBehaviorResource, target);
        var nameOrConfigOrTargets = names.map(function (name) {
            var nameOrConfigOrTarget = {
                name: name
            };
            if (bindingModeToUse) {
                nameOrConfigOrTarget["defaultBindingMode"] = bindingModeToUse;
            }
            return nameOrConfigOrTarget;
        });
        nameOrConfigOrTargets.forEach(function (nameOrConfigOrTarget) {
            var prop = new aurelia_framework_1.BindableProperty(nameOrConfigOrTarget);
            prop.registerWith(target, behaviorResource, descriptor);
        });
    };
}
exports.generateBindables = generateBindables;
;
function getNewColumnStates(gridOptions, newStates) {
    var e_1, _a;
    var columnDefs = gridOptions.api.getColumnDefs();
    var currentStates = gridOptions.columnApi.getColumnState();
    var resultStates = [];
    var _loop_1 = function (currentState) {
        if (!newStates.some(function (n) { return n.colId == currentState.colId; })) {
            var colDef = columnDefs.find(function (x) { return x.colId == currentState.colId; });
            if ((colDef === null || colDef === void 0 ? void 0 : colDef.viewMovable) === false) {
                resultStates.push(currentState);
            }
        }
    };
    try {
        for (var currentStates_1 = __values(currentStates), currentStates_1_1 = currentStates_1.next(); !currentStates_1_1.done; currentStates_1_1 = currentStates_1.next()) {
            var currentState = currentStates_1_1.value;
            _loop_1(currentState);
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (currentStates_1_1 && !currentStates_1_1.done && (_a = currentStates_1.return)) _a.call(currentStates_1);
        }
        finally { if (e_1) throw e_1.error; }
    }
    resultStates.push.apply(resultStates, __spreadArray([], __read(newStates.filter(function (c) { return !resultStates.some(function (n) { return n.colId == c.colId; }); })), false));
    return resultStates;
}
exports.getNewColumnStates = getNewColumnStates;
function autoAdjustColumnsSize(gridOptions) {
    if (gridOptions.adjustColumns === true) {
        gridOptions.api.sizeColumnsToFit();
    }
    else {
        gridOptions.columnApi.autoSizeAllColumns();
    }
}
exports.autoAdjustColumnsSize = autoAdjustColumnsSize;

//# sourceMappingURL=agUtils.js.map
