/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { StackedBarBucketCalculator } from "./StackedBarBucketCalculator";
import { StackedBarSeries } from "./StackedBarSeries";
import { BarFragment } from "./BarFragment";
import { ScalerParams } from "./ScalerParams";
import { typeCast, markType } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var Stacked100BarBucketCalculator = /** @class */ (function (_super) {
    tslib_1.__extends(Stacked100BarBucketCalculator, _super);
    function Stacked100BarBucketCalculator(a) {
        return _super.call(this, a) || this;
    }
    Stacked100BarBucketCalculator.prototype.getBucket = function (a) {
        return _super.prototype.getBucket.call(this, a);
    };
    Stacked100BarBucketCalculator.prototype.getBucket1 = function (a, b, c, d, e, f) {
        var g = typeCast(StackedBarSeries.$, this.c.cp);
        var h = [NaN, NaN, NaN];
        var i = typeCast(BarFragment.$, a);
        if (i == null || i.logicalSeriesLink == null) {
            return h;
        }
        var j = a.valueColumn.item(c);
        var k = 0;
        var l = 0;
        var m = NaN;
        var n = NaN;
        var o = Number.NEGATIVE_INFINITY;
        var p = Number.POSITIVE_INFINITY;
        var q = g.getEffectiveViewport1(this.c);
        var r = Math.min(g.ow != null ? g.ow.length : 0, g.ov != null ? g.ov.length : 0);
        var s = c * this.d;
        var t = Math.min(s + this.d - 1, r - 1);
        for (var u = s; u <= t; ++u) {
            j = a.valueColumn.item(u);
            k = Math.abs(g.ow[u]) + g.ov[u];
            if (j < l) {
                p = Math.min(p, (i.logicalSeriesLink.ad._inner[u] + j) / k * 100);
                o = Math.max(o, i.logicalSeriesLink.ad._inner[u] / k * 100);
            }
            else {
                p = Math.min(p, i.logicalSeriesLink.ac._inner[u] / k * 100);
                o = Math.max(o, (i.logicalSeriesLink.ac._inner[u] + j) / k * 100);
            }
            if (!isNaN_(m)) {
                if (!isNaN_(p)) {
                    m = Math.min(m, p);
                    n = Math.max(n, p);
                }
                if (!isNaN_(o)) {
                    m = Math.min(m, o);
                    n = Math.max(n, o);
                }
            }
            else {
                m = p;
                n = o;
            }
        }
        var v = new ScalerParams(0, d, e, g.xAxis.b8, q);
        h = [f.f._inner[b - this.e][0], g.xAxis.dw(n, v), g.xAxis.dw(m, v)];
        return h;
    };
    Stacked100BarBucketCalculator.$t = markType(Stacked100BarBucketCalculator, 'Stacked100BarBucketCalculator', StackedBarBucketCalculator.$);
    return Stacked100BarBucketCalculator;
}(StackedBarBucketCalculator));
export { Stacked100BarBucketCalculator };
//# sourceMappingURL=Stacked100BarBucketCalculator.js.map