/*
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 { __extends } from "tslib";
import { StackedColumnBucketCalculator } from "./StackedColumnBucketCalculator";
import { StackedSeriesBase } from "./StackedSeriesBase";
import { ColumnFragment } from "./ColumnFragment";
import { ScalerParams } from "./ScalerParams";
import { typeCast, markType } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var Stacked100ColumnBucketCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(Stacked100ColumnBucketCalculator, _super);
    function Stacked100ColumnBucketCalculator(a) {
        return _super.call(this, a) || this;
    }
    Stacked100ColumnBucketCalculator.prototype.getBucket = function (a) {
        return _super.prototype.getBucket.call(this, a);
    };
    Stacked100ColumnBucketCalculator.prototype.getBucket1 = function (a, b, c, d, e, f) {
        var g = typeCast(StackedSeriesBase.$, this.c.cy);
        var h = [NaN, NaN, NaN];
        var i = typeCast(ColumnFragment.$, a);
        if (i == null || i.logicalSeriesLink == null) {
            return h;
        }
        var j = g.getEffectiveViewport1(this.c);
        var k = a.valueColumn.item(c);
        var l = 0;
        var m = NaN;
        var n = NaN;
        var o = Number.NEGATIVE_INFINITY;
        var p = Number.POSITIVE_INFINITY;
        var q = 0;
        var r = Math.min(g.aar != null ? g.aar.length : 0, g.aaq != null ? g.aaq.length : 0);
        var s = c * this.d;
        var t = Math.min(s + this.d - 1, r - 1);
        if (s <= t) {
            for (var u = s; u <= t; ++u) {
                k = a.valueColumn.item(u);
                q = Math.abs(g.aar[u]) + g.aaq[u];
                if (k < l) {
                    p = Math.min(p, (i.logicalSeriesLink.a8._inner[u] + k) / q * 100);
                    o = Math.max(o, i.logicalSeriesLink.a8._inner[u] / q * 100);
                }
                else {
                    p = Math.min(p, i.logicalSeriesLink.a7._inner[u] / q * 100);
                    o = Math.max(o, (i.logicalSeriesLink.a7._inner[u] + k) / q * 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, i.fragmentYAxis.ch, j);
        h = [f.f._inner[b - this.e][0], i.fragmentYAxis.el(n, v), i.fragmentYAxis.el(m, v)];
        return h;
    };
    Stacked100ColumnBucketCalculator.$t = markType(Stacked100ColumnBucketCalculator, 'Stacked100ColumnBucketCalculator', StackedColumnBucketCalculator.$);
    return Stacked100ColumnBucketCalculator;
}(StackedColumnBucketCalculator));
export { Stacked100ColumnBucketCalculator };
