/*
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, __values } from "tslib";
import { Base, typeCast, markType, Array_$type, Number_$type, Point_$type, enumGetBox, runOn, fromEnum, markDep } from "igniteui-angular-core";
import { IBucketizer_$type } from "./IBucketizer";
import { ArgumentNullException } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { ISortingAxis_$type } from "./ISortingAxis";
import { ScalerParams } from "./ScalerParams";
import { Series } from "./Series";
import { truncate, intDivide, isNaN_, isInfinity } from "igniteui-angular-core";
import { FramePreparer } from "./FramePreparer";
import { IIsCategoryBased_$type } from "./IIsCategoryBased";
import { List$1 } from "igniteui-angular-core";
import { ISupportsMarkers_$type } from "./ISupportsMarkers";
import { IProvidesViewport_$type } from "./IProvidesViewport";
import { ISupportsErrorBars_$type } from "./ISupportsErrorBars";
import { CategoryFrame } from "./CategoryFrame";
import { PreparationParams } from "./PreparationParams";
import { IDateTimeAxis_$type } from "./IDateTimeAxis";
import { NumericAxisBase } from "./NumericAxisBase";
import { IHasCategoryTrendline_$type } from "./IHasCategoryTrendline";
import { IHasSingleValueCategory_$type } from "./IHasSingleValueCategory";
import { DefaultCategoryTrendlineHost } from "./DefaultCategoryTrendlineHost";
import { DefaultSingleValueProvider } from "./DefaultSingleValueProvider";
import { SingleValuesHolder } from "./SingleValuesHolder";
import { MarkerSeries } from "./MarkerSeries";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { ICategorySeriesInteractionManager_$type } from "./ICategorySeriesInteractionManager";
import { DVContainer } from "igniteui-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { CategoryTransitionInMode_$type } from "./CategoryTransitionInMode";
import { HighlightingInfo } from "./HighlightingInfo";
import { CategoryTransitionSourceFramePreparer } from "./CategoryTransitionSourceFramePreparer";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { CategorySeriesRenderManager } from "./CategorySeriesRenderManager";
import { Pool$1 } from "igniteui-angular-core";
import { Clipper } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { round10N } from "igniteui-angular-core";
/**
 * @hidden
 */
var CategoryBucketCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CategoryBucketCalculator, _super);
    function CategoryBucketCalculator(a) {
        var _this = _super.call(this) || this;
        _this.c = null;
        _this.e = 0;
        _this.f = 0;
        _this.d = 0;
        if (a == null) {
            throw new ArgumentNullException(0, "view");
        }
        _this.c = a;
        _this.e = -1;
        _this.d = 0;
        return _this;
    }
    CategoryBucketCalculator.prototype.getBucket = function (a) {
        return null;
    };
    CategoryBucketCalculator.prototype.getBucketWithoutUnknowns = function (a) {
        return this.getBucket(a);
    };
    CategoryBucketCalculator.prototype.getErrorBucket = function (a, b) {
        return NaN;
    };
    CategoryBucketCalculator.prototype.g = function (a) {
        var b = this.c.bv;
        var c = this.c.bu;
        var d = this.c.ct;
        var e = typeCast(CategoryAxisBase.$, d.fetchXAxis());
        var f = d.ck;
        if (b.isEmpty || c.isEmpty || e == null || f == null || f.count == 0) {
            this.d = 0;
            return;
        }
        var g = d.getEffectiveViewport1(this.c);
        var h = d.pv(this.c);
        var i = typeCast(ISortingAxis_$type, e);
        if (i == null || i.i$b == null) {
            var j = new ScalerParams(0, b, c, e.cg, g);
            var k = Math.floor(e.el(h.left, j));
            var l = Math.ceil(e.el(h.right, j));
            if (e.cg) {
                l = Math.ceil(e.el(h.left, j));
                k = Math.floor(e.el(h.right, j));
            }
            l = Math.min(l, e.lf - 1);
            var m = Math.floor((l - k + 1) * a / h.width);
            this.d = truncate(Math.max(1, m));
            this.e = truncate(Math.max(0, Math.floor(k / this.d) - 1));
            this.f = truncate(Math.ceil(l / this.d));
        }
        else {
            this.e = i.i$e(b, c, g, h);
            this.f = i.i$g(b, c, g, h);
            this.d = 1;
        }
    };
    CategoryBucketCalculator.prototype.getBucketInfo = function (a, b, c, d) {
        a = this.e;
        b = this.f;
        c = this.d;
        d = this.c.ct.fv;
        return {
            p0: a,
            p1: b,
            p2: c,
            p3: d
        };
    };
    CategoryBucketCalculator.prototype.cacheValues = function () {
    };
    CategoryBucketCalculator.prototype.unCacheValues = function () {
    };
    CategoryBucketCalculator.$t = markType(CategoryBucketCalculator, 'CategoryBucketCalculator', Base.$, [IBucketizer_$type]);
    return CategoryBucketCalculator;
}(Base));
export { CategoryBucketCalculator };
/**
 * @hidden
 */
var CategoryFramePreparerBase = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CategoryFramePreparerBase, _super);
    function CategoryFramePreparerBase(a) {
        var _rest = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            _rest[_i - 1] = arguments[_i];
        }
        var _this = this;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    var c = _rest[0];
                    var d = [c, typeCast(ISupportsMarkers_$type, c), typeCast(IProvidesViewport_$type, c), typeCast(ISupportsErrorBars_$type, c), typeCast(IBucketizer_$type, c)];
                    {
                        var f = d[0];
                        var g = d[1];
                        var h = d[2];
                        var i = d[3];
                        var j = d[4];
                        _this = _super.call(this, 1, g, h, i) || this;
                        _this.g = null;
                        _this.h = null;
                        _this.m = false;
                        _this.o = new List$1(Array_$type, 0);
                        _this.p = new List$1(Number_$type, 0);
                        _this.n = new List$1(Number_$type, 0);
                        _this.h = f;
                        _this.g = j;
                    }
                }
                break;
            case 1:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = _rest[4];
                    _this = _super.call(this, 1, d, e, f) || this;
                    _this.g = null;
                    _this.h = null;
                    _this.m = false;
                    _this.o = new List$1(Array_$type, 0);
                    _this.p = new List$1(Number_$type, 0);
                    _this.n = new List$1(Number_$type, 0);
                    _this.h = c;
                    _this.g = g;
                }
                break;
        }
        return _this;
    }
    CategoryFramePreparerBase.prototype.i = function (a) {
        var b = new PreparationParams();
        b.f = this.h.useHighMarkerFidelity;
        b.b = this.h.scaler;
        b.c = this.h.yScaler;
        b.d = typeCast(ISortingAxis_$type, b.b);
        b.a = typeCast(CategoryFrame.$, a);
        if (b.a == null || b.b == null || b.c == null) {
            return null;
        }
        var c;
        var d;
        var e;
        var f;
        var g = this.g.getBucketInfo(c, d, e, f);
        c = g.p0;
        d = g.p1;
        e = g.p2;
        f = g.p3;
        b.i = c;
        b.j = d;
        b.h = e;
        b.g = f;
        if (b.j < b.i) {
            return null;
        }
        var h;
        var i;
        var j;
        var k = this.a.getViewInfo(i, h);
        i = k.p0;
        h = k.p1;
        j = this.a.getEffectiveViewport();
        b.m = h;
        b.l = i;
        b.k = j;
        if (Rect.l_op_Equality(b.m, Rect.empty) || Rect.l_op_Equality(b.l, Rect.empty)) {
            return null;
        }
        if (this.h != null && (typeCast(Series.$, this.h) !== null && this.h.dv) && this.g != null) {
            b.e = true;
        }
        return b;
    };
    CategoryFramePreparerBase.prototype.r = function (a, b, c, d) {
        return a.getSeriesOffset(b, c, d, this.h.currentMode2Index, this.h.currentCategoryMode);
    };
    CategoryFramePreparerBase.prototype.s = function (a) {
        return this.r(a.b, a.m, a.l, a.k);
    };
    CategoryFramePreparerBase.prototype.d = function (a, b) {
        var c = this.i(a);
        if (c == null || this.g == null) {
            return;
        }
        c.a.f.clear();
        c.a.k.clear();
        c.a.m.clear();
        c.a.p.clear();
        c.a.i.clear();
        c.a.h.clear();
        c.a.g.clear();
        var d = this.c.shouldDisplayMarkers;
        var e = false;
        var f = this.s(c);
        var g = this.j(c);
        if (c.d != null && c.d.i$b != null && c.d.i$b.count != g.e) {
            return;
        }
        if (c.d != null && c.d.i$a) {
            c.d.i$h();
        }
        this.g.cacheValues();
        if (this.m && c.d != null && c.d.i$b.count > 0) {
            var h = c.d.i$b._inner[c.i];
            this.z(g, h, true, c.e);
            while ((isNaN_(g.c) || isNaN_(g.d)) && c.i > 0) {
                c.i = c.i - 1;
                h = c.d.i$b._inner[c.i];
                this.z(g, h, true, c.e);
            }
            var i = c.d.i$b._inner[c.j];
            this.z(g, i, true, c.e);
            while ((isNaN_(g.c) || isNaN_(g.d)) && c.j < g.e - 1) {
                c.j = c.j + 1;
                i = c.d.i$b._inner[c.j];
                this.z(g, i, true, c.e);
            }
        }
        if (this.m && c.d == null) {
            var j = c.i;
            var k = this.g.getBucket(j);
            while ((isNaN_(k[1]) || isNaN_(k[2])) && c.i > 0) {
                c.i = c.i - 1;
                j = c.i;
                k = this.g.getBucket(j);
            }
            var l = c.j;
            k = this.g.getBucket(l);
            while ((isNaN_(k[1]) || isNaN_(k[2])) && c.j < (intDivide(g.e, c.h))) {
                c.j = c.j + 1;
                l = c.j;
                k = this.g.getBucket(l);
            }
        }
        this.w(c, g, f);
        var m = this.t(c, g, f, d, e);
        this.c.updateMarkerCount(m);
        this.v(typeCast(CategoryFrame.$, a), b);
        this.g.unCacheValues();
        return;
    };
    CategoryFramePreparerBase.prototype.v = function (a, b) {
    };
    Object.defineProperty(CategoryFramePreparerBase.prototype, "q", {
        get: function () {
            return this.o;
        },
        enumerable: false,
        configurable: true
    });
    CategoryFramePreparerBase.prototype.t = function (a, b, c, d, e) {
        var _this = this;
        var f = 0;
        var g = false;
        var h = null;
        var i = false;
        var j = a.d != null;
        var k = a.m;
        var l = a.l;
        var m = typeCast(NumericAxisBase.$, a.c) !== null && a.c.lh;
        var n = a.f;
        var o = this.h.mayContainUnknowns;
        var p = this.o;
        var q = this.n;
        var r = this.p;
        p.clear();
        q.clear();
        r.clear();
        var s = this.g;
        var t = this.h.provideCollisionDetector();
        var u = 0;
        var v = a.k;
        var w = new ScalerParams(0, k, l, a.b.j$a, v);
        var x = ((function () {
            var $ret = new ScalerParams(0, k, l, a.c.j$a, v);
            $ret.b = typeCast(Series.$, _this.h) !== null ? _this.h.ge() : NaN;
            return $ret;
        })());
        if (j) {
            u = a.b.j$c(2, w) - a.b.j$c(1, w);
            i = this.k();
        }
        var y = a.i;
        var z = a.j;
        var aa = a.a.f;
        var ab = typeCast(IDateTimeAxis_$type, a.b);
        if (ab != null) {
            ab.StartTimeCursor();
        }
        var _loop_1 = function (ac) {
            var ad = void 0;
            if (!j) {
                if (!o) {
                    ad = s.getBucketWithoutUnknowns(ac);
                }
                else {
                    ad = s.getBucket(ac);
                }
            }
            else {
                ad = ((function () { var ae = _this.f(a, ac, b, u, g, h, c); ac = ae.p1; g = ae.p4; h = ae.p5; return ae.ret; })());
            }
            var ae = !m || (m && ad[1] > 0);
            var af = ad[0];
            if (!j || !isNaN_(ad[0])) {
                aa.add(ad);
                if (g && i) {
                    if (h != null) {
                        aa.add(h);
                    }
                }
                if (d && ae) {
                    var ag = ac * a.h;
                    var ah = ag;
                    if (j && a.d.i$b != null && ag >= 0 && ag < a.d.i$b.count) {
                        ag = a.d.i$b._inner[ag];
                    }
                    var ai = new Array(ad.length);
                    ai[0] = ad[0];
                    ai[1] = ad[1];
                    ai[2] = ad[2];
                    if (n && ag < b.e) {
                        ai = new Array(ad.length);
                        ai[0] = af;
                        this_1.z(b, ag, true, a.e);
                        ai[1] = b.c;
                        ai[2] = b.d;
                    }
                    p.add(ai);
                    q.add(a.a.f.count - 1);
                    r.add(ag);
                }
            }
            out_ac_1 = ac;
        };
        var this_1 = this, out_ac_1;
        for (var ac = y; ac <= z; ++ac) {
            _loop_1(ac);
            ac = out_ac_1;
        }
        if (ab != null) {
            ab.ResetTimeCursor();
        }
        this.y(a, c, j, w, x, e, d);
        if (d) {
            var aj = p.count;
            var ak = void 0;
            for (var al = 0; al < aj; al++) {
                ak = p._inner[al];
                if (this.l(a.a, ak, t, Math.min(r._inner[al], b.e - 1), f, q._inner[al])) {
                    ++f;
                }
            }
        }
        return f;
    };
    CategoryFramePreparerBase.prototype.k = function () {
        if (typeCast(Series.$, this.h) !== null) {
            return this.h.de;
        }
        return false;
    };
    CategoryFramePreparerBase.prototype.f = function (a, b, c, d, e, f, g) {
        var h;
        f = null;
        e = false;
        var i = typeCast(CategorySeries.$, this.h);
        var j = a.l;
        var k = a.m;
        var l = a.k;
        var m = new ScalerParams(0, k, j, a.b.j$a, l);
        var n = new ScalerParams(0, k, j, a.c.j$a, l);
        var o = a.e;
        if (a.d == null || a.d.i$b == null || a.d.i$b.count == 0) {
            return {
                ret: [NaN, NaN, NaN],
                p1: b,
                p4: e,
                p5: f
            };
        }
        if (i != null && i.ck != null && i.ck.count < a.d.i$b.count) {
            return {
                ret: [NaN, NaN, NaN],
                p1: b,
                p4: e,
                p5: f
            };
        }
        var p = a.d.i$b._inner[b];
        var q = a.d.i$d(p);
        var r = q;
        this.z(c, p, false, o);
        while (b < a.j) {
            p = a.d.i$b._inner[b + 1];
            r = a.d.i$d(p);
            this.z(c, p, true, o);
            if (r - q >= d || isNaN_(c.c) || isNaN_(c.d)) {
                if (e) {
                    var s = a.d.i$b._inner[b];
                    this.z(c, s, true, o);
                    f = [a.b.j$b(q, m), c.c, c.d];
                }
                break;
            }
            if (!e && this.k()) {
                var t = a.d.i$b._inner[b];
                this.z(c, t, true, o);
                var u = [a.b.j$b(q, m), c.c, c.d];
                if (!isNaN_(u[0])) {
                    if (!isNaN_(u[1]) && !isNaN_(u[2])) {
                        if (a.d != null) {
                            u[0] = u[0] + g;
                        }
                        a.a.f.add(u);
                        e = true;
                    }
                    else {
                        break;
                    }
                }
            }
            b++;
            this.u(c, p, o);
        }
        var v = NaN;
        if (!isNaN_(q)) {
            v = a.b.j$b(q, m);
        }
        h = this.e(v, c);
        return {
            ret: h,
            p1: b,
            p4: e,
            p5: f
        };
    };
    CategoryFramePreparerBase.prototype.y = function (a, b, c, d, e, f, g) {
        var h = a.h;
        var i = a.a.f.count;
        var j = a.a.f;
        var k = this.o;
        var l = k.count;
        if (f) {
            var m = a.c.j$b(a.c.l5, e);
            a.c.j$e(a.a.k, 0, a.a.k.count, e);
            var n = a.a.k;
            var o = n.count;
            for (var p = 0; p < n.count; p++) {
                n._inner[p] = Math.abs(n._inner[p] - m);
            }
        }
    };
    CategoryFramePreparerBase.prototype.w = function (a, b, c) {
    };
    CategoryFramePreparerBase.$t = markType(CategoryFramePreparerBase, 'CategoryFramePreparerBase', FramePreparer.$);
    return CategoryFramePreparerBase;
}(FramePreparer));
export { CategoryFramePreparerBase };
/**
 * @hidden
 */
var CategoryFramePreparer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CategoryFramePreparer, _super);
    function CategoryFramePreparer(a) {
        var _rest = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            _rest[_i - 1] = arguments[_i];
        }
        var _this = this;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    var c = _rest[0];
                    var d = [c, typeCast(ISupportsMarkers_$type, c), typeCast(IProvidesViewport_$type, c), typeCast(ISupportsErrorBars_$type, c), typeCast(IBucketizer_$type, c)];
                    {
                        var f = d[0];
                        var g = d[1];
                        var h = d[2];
                        var i = d[3];
                        var j = d[4];
                        _this = _super.call(this, 1, f, g, h, i, j) || this;
                        _this.aa = new DefaultCategoryTrendlineHost();
                        _this.ab = new DefaultSingleValueProvider();
                        _this.ac = null;
                        _this.ad = null;
                        _this.ac = _this.aa;
                        if (typeCast(IHasCategoryTrendline_$type, f) !== null) {
                            _this.ac = typeCast(IHasCategoryTrendline_$type, f);
                        }
                        _this.ad = _this.ab;
                        if (typeCast(IHasSingleValueCategory_$type, f) !== null) {
                            _this.ad = typeCast(IHasSingleValueCategory_$type, f);
                        }
                    }
                }
                break;
            case 1:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = _rest[4];
                    _this = _super.call(this, 1, c, d, e, f, g) || this;
                    _this.aa = new DefaultCategoryTrendlineHost();
                    _this.ab = new DefaultSingleValueProvider();
                    _this.ac = null;
                    _this.ad = null;
                    _this.ac = _this.aa;
                    if (typeCast(IHasCategoryTrendline_$type, c) !== null) {
                        _this.ac = typeCast(IHasCategoryTrendline_$type, c);
                    }
                    _this.ad = _this.ab;
                    if (typeCast(IHasSingleValueCategory_$type, c) !== null) {
                        _this.ad = typeCast(IHasSingleValueCategory_$type, c);
                    }
                }
                break;
        }
        return _this;
    }
    CategoryFramePreparer.prototype.l = function (a, b, c, d, e, f) {
        var g = b[0];
        var h = b[1];
        var i = new Rect(0, g - 5, h - 5, 11, 11);
        if (!isNaN_(g) && !isNaN_(h) && !isInfinity(g) && !isInfinity(h) && c.tryAdd(i)) {
            a.m.add({ $type: Point_$type, x: g, y: h });
            this.c.updateMarkerTemplate(e, d, f);
            return true;
        }
        return false;
    };
    CategoryFramePreparer.prototype.j = function (a) {
        var b = new SingleValuesHolder();
        var c = this.ad.valueColumn;
        b.f = c;
        return b;
    };
    CategoryFramePreparer.prototype.x = function (a, b, c, d, e, f) {
        if (d) {
            b[0] = b[0] + c;
        }
        else {
            b[0] = a.b.j$b(b[0], e) + c;
        }
        b[1] = a.c.j$b(b[1], f);
        if (a.h > 1 || d) {
            b[2] = a.c.j$b(b[2], f);
        }
        else {
            b[2] = b[1];
        }
    };
    CategoryFramePreparer.prototype.y = function (a, b, c, d, e, f, g) {
        _super.prototype.y.call(this, a, b, c, d, e, f, g);
        var h = a.h;
        var i = a.a.f.count;
        var j = a.a.f;
        var k = this.q;
        var l = k.count;
        var m = new List$1(Number_$type, 0);
        if (!c) {
            m.add(0);
        }
        var n = new List$1(Number_$type, 0);
        n.add(1);
        if (c || h > 1) {
            n.add(2);
        }
        a.b.j$d(j, m, 0, i, d);
        a.c.j$d(j, n, 0, i, e);
        for (var o = 0; o < i; o++) {
            j._inner[o][0] = j._inner[o][0] + b;
        }
        if (h == 1 && !c) {
            for (var p = 0; p < i; p++) {
                j._inner[p][2] = j._inner[p][1];
            }
        }
        if (g) {
            a.b.j$d(k, m, 0, l, d);
            a.c.j$d(k, n, 0, l, e);
            for (var q = 0; q < l; q++) {
                k._inner[q][0] = k._inner[q][0] + b;
            }
            if (h == 1 && !c) {
                for (var r = 0; r < l; r++) {
                    k._inner[r][2] = k._inner[r][1];
                }
            }
        }
    };
    CategoryFramePreparer.prototype.w = function (a, b, c) {
        if (this.ac.trendLineType == 0 || this.ac.trendlinePreparer == null || this.ac.trendLinePeriod < 1) {
            return;
        }
        this.ac.trendlinePreparer.prepareLine(this.ac, a, b, c);
    };
    CategoryFramePreparer.prototype.z = function (a, b, c, d) {
        var e = a;
        var f = e.f;
        var g = f.item(b);
        var h = g;
        if (d) {
            var i = this.g.getBucket(b);
            g = i[1];
            h = i[1];
        }
        if (c) {
            e.c = g;
            e.d = h;
        }
        else {
            e.a = g;
            e.b = h;
        }
    };
    CategoryFramePreparer.prototype.u = function (a, b, c) {
        var d = a;
        var e = d.f;
        if (b < e.count) {
            var f = void 0;
            if (c) {
                var g = this.g.getBucket(b);
                f = g[1];
            }
            else {
                f = e.item(b);
            }
            d.a = Math.min(d.a, f);
            d.b = Math.max(d.b, f);
        }
    };
    CategoryFramePreparer.prototype.e = function (a, b) {
        var c = b;
        return [a, c.a, c.b];
    };
    CategoryFramePreparer.$t = markType(CategoryFramePreparer, 'CategoryFramePreparer', CategoryFramePreparerBase.$);
    return CategoryFramePreparer;
}(CategoryFramePreparerBase));
export { CategoryFramePreparer };
/**
 * @hidden
 */
var CategorySeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CategorySeries, _super);
    function CategorySeries() {
        var _this = _super.call(this) || this;
        _this.ry = null;
        _this.sb = null;
        _this.sf = false;
        _this.se = false;
        _this.assigningCategoryStyle = null;
        _this.assigningCategoryMarkerStyle = null;
        _this.r9 = null;
        _this.sa = null;
        _this.rv = new CategoryFrame(3);
        _this.rx = new CategoryFrame(3);
        _this.rt = new CategoryFrame(3);
        _this.rw = new CategoryFrame(3);
        _this.r1 = null;
        _this.r5 = null;
        _this.r1 = new CategorySeriesRenderManager();
        _this.r5 = new CategoryTransitionSourceFramePreparer();
        _this.sf = false;
        _this.se = false;
        _this.ab = CategorySeries.$;
        return _this;
    }
    CategorySeries.prototype.bx = function () {
        var a = new CategorySeriesView(this);
        return a;
    };
    Object.defineProperty(CategorySeries.prototype, "sc", {
        get: function () {
            var _this = this;
            if (this.sb == null) {
                this.sb = DVContainer.instance.createInstance(ICategorySeriesInteractionManager_$type, function () { return _this.cn.n; });
            }
            return this.sb;
        },
        enumerable: false,
        configurable: true
    });
    CategorySeries.prototype.c1 = function (a, b, c, d) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var e = this.getEffectiveViewport1(this.b0);
        var f = this.rs();
        var g = new ScalerParams(1, this.cd.s9, this.p3, f.cg);
        g.c = e;
        var h = this.sd();
        var i = new ScalerParams(1, this.cd.s9, this.p3, h.cg);
        i.c = e;
        var j = this.cd.s9;
        var k = this.p3;
        var l = this.currentMode2Index;
        var m = 0;
        if (f.cd && f.cb) {
            m = f.getSeriesOffset(j, k, e, l, f.categoryMode);
        }
        a.clear();
        this.qg.cf(function (n) {
            if (n._visibility == 0) {
                var o = new SeriesPointOfInterest();
                var p = n.n;
                var q = n.o;
                if (p < _this.p3.left || p > _this.p3.right || q < _this.p3.top || q > _this.p3.bottom) {
                    return;
                }
                if (_this.isVertical) {
                    if (f.ca && !f.cd && f.categoryMode != 0) {
                        o.c = n.ak;
                    }
                    else {
                        o.c = f.el(q, g);
                    }
                    o.b = h.el(p, i);
                }
                else {
                    if (f.ca && !f.cd && f.categoryMode != 0) {
                        o.b = n.ak;
                    }
                    else {
                        o.b = f.el(p, g);
                    }
                    o.c = h.el(q, i);
                }
                o.a = n.content;
                if (b) {
                    if (_this.isVertical) {
                        if (c) {
                            o.d = _this.sx(o.b, d);
                        }
                        else {
                            var r = _this.gq(n);
                            if (!isNaN_(r)) {
                                o.d = _this.sx(r, d);
                            }
                            else {
                                o.d = _this.sx(o.b, d);
                            }
                        }
                    }
                    else {
                        if (c) {
                            o.d = _this.sx(o.c, d);
                        }
                        else {
                            var s = _this.gq(n);
                            if (!isNaN_(s)) {
                                o.d = _this.sx(s, d);
                            }
                            else {
                                o.d = _this.sx(o.c, d);
                            }
                        }
                    }
                }
                else {
                    o.d = f.gc(n.ak);
                }
                a.add(o);
            }
        });
        return true;
    };
    CategorySeries.prototype.sx = function (a, b) {
        if (b >= 0) {
            return round10N(a, b).toString();
        }
        else {
            return a.toString();
        }
    };
    CategorySeries.prototype.l2 = function (a) {
        _super.prototype.l2.call(this, a);
        this.r2 = a;
    };
    CategorySeries.prototype.preferredCategoryMode = function (a) {
        return 0;
    };
    Object.defineProperty(CategorySeries.prototype, "categoryAxis", {
        get: function () {
            return this.rs();
        },
        enumerable: false,
        configurable: true
    });
    CategorySeries.prototype.rs = function () {
        return this.fetchXAxis();
    };
    CategorySeries.prototype.sd = function () {
        return this.fetchYAxis();
    };
    CategorySeries.prototype.get_c6 = function () {
        return true;
    };
    CategorySeries.prototype.get_ek = function () {
        return this.sd() != null && this.sd().cg;
    };
    CategorySeries.prototype.get_dh = function () {
        return true;
    };
    CategorySeries.prototype.ac = function () {
        _super.prototype.ac.call(this);
        this.r2.cr.g(this.fv);
    };
    CategorySeries.prototype.sl = function () {
        return (this.assigningCategoryStyle != null && this.sf) || (this.bk != 1);
    };
    CategorySeries.prototype.sm = function () {
        return (this.assigningCategoryMarkerStyle != null && this.se) || (this.bk != 1);
    };
    CategorySeries.prototype.ta = function (a) {
        if (this.assigningCategoryStyle != null && this.sf) {
            this.assigningCategoryStyle(this, a);
        }
    };
    CategorySeries.prototype.s9 = function (a) {
        if (this.assigningCategoryMarkerStyle != null && this.se) {
            this.assigningCategoryMarkerStyle(this, a);
        }
    };
    CategorySeries.prototype.rm = function (a, b) {
        return null;
    };
    CategorySeries.prototype.k0 = function (a, b) {
        _super.prototype.k0.call(this, a, b);
        if (a) {
            this.s4(b);
        }
    };
    CategorySeries.prototype.bh = function () {
        var a = _super.prototype.bh.call(this);
        return a;
    };
    CategorySeries.prototype.li = function () {
        _super.prototype.li.call(this);
        var a = this.fetchXAxis();
        if (a != null) {
            a.h7(false);
        }
        var b = this.fetchYAxis();
        if (b != null) {
            b.h7(false);
        }
    };
    CategorySeries.prototype.m9 = function (a, b) {
        _super.prototype.m9.call(this, a, b);
        this.r2.cr.g(this.fv);
        this.ml(false);
    };
    CategorySeries.prototype.m8 = function (a, b) {
        if (this.e2 && this.g2 < 0.05 && (this.cd == null || !this.cd.et())) {
            this.e3 = true;
        }
        _super.prototype.m8.call(this, a, b);
        this.r2.cr.g(this.fv);
        this.ml(false);
    };
    CategorySeries.prototype.l7 = function (a, b, c, d) {
        _super.prototype.l7.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = this.fetchYAxis();
                var f = this.fetchXAxis();
                if (c != null && d == null) {
                    this.k4(f);
                    this.k4(e);
                }
                if (c == null && d != null) {
                    this.mc(f);
                    this.mc(e);
                }
                this.r2.cr.g(this.fv);
                this.ml(false);
                break;
            case "SyncLink":
                if (this.b8 != null && this.cd != null) {
                    this.r2.cr.g(this.fv);
                }
                this.ml(false);
                break;
            case "TransitionProgress":
                this.rx.c(this.g2, this.rv, this.rt);
                if (this.cx(this.b0)) {
                    return;
                }
                if (this.g2 == 1) {
                    this.rt.v();
                    this.tb(this.rt, this.r2);
                    if (this.e2) {
                        this.e2 = false;
                        this.k1();
                        this.ce.r = truncate(this.go());
                        this.ce.b = this.cf;
                    }
                }
                else {
                    this.tb(this.rx, this.r2);
                }
                if (this.cd != null) {
                    this.cd.oa(this);
                }
                break;
            case "ErrorBarSettings":
                this.ls();
                break;
            case CategorySeries.$$p[4]:
                this.ml(false);
                break;
            case CategorySeries.$$p[1]:
                this.sf = this.sh();
                this.ml(false);
                break;
            case CategorySeries.$$p[0]:
                this.se = this.sg();
                this.ml(false);
                break;
        }
    };
    CategorySeries.prototype.sh = function () {
        return this.sj;
    };
    CategorySeries.prototype.sg = function () {
        return this.si;
    };
    CategorySeries.prototype.sr = function (a) {
        return this.f9(a, this.fetchXAxis());
    };
    CategorySeries.prototype.get_ea = function () {
        return typeCast(ISortingAxis_$type, this.rs()) !== null;
    };
    CategorySeries.prototype.ar = function () {
        return this.rs();
    };
    CategorySeries.prototype.hh = function (a) {
        return this.sc.b$d(this, a);
    };
    CategorySeries.prototype.hv = function (a) {
        return this.sc.b$f(this, a);
    };
    CategorySeries.prototype.hf = function (a) {
        var b = truncate(Math.round(this.f7(a)));
        return b;
    };
    CategorySeries.prototype.f7 = function (a) {
        return this.sc.b$c(this, a);
    };
    CategorySeries.prototype.ax = function (a, b, c) {
        if (this.eg(this.bk) && !c) {
            var d = this.r8(a, b, this.sa);
            this.sa = d;
            return d;
        }
        else {
            var e = this.r6(a, b, this.sa);
            e.e = true;
            this.sa = e;
            return e;
        }
    };
    CategorySeries.prototype.get_dy = function () {
        return true;
    };
    CategorySeries.prototype.ky = function () {
        _super.prototype.ky.call(this);
        this.r9 = null;
        this.sa = null;
    };
    CategorySeries.prototype.aw = function (a, b, c) {
        if (this.c2 && this.eg(this.bk) && !c) {
            var d = this.r7(a, b, this.r9);
            this.r9 = d;
            return d;
        }
        else {
            var e = this.r6(a, b, this.r9);
            this.r9 = e;
            return e;
        }
    };
    CategorySeries.prototype.sq = function () {
        return this.r2.cu.a;
    };
    CategorySeries.prototype.r8 = function (a, b, c) {
        if (!this.qj()) {
            return null;
        }
        var d = this.ru();
        var e = this.sq();
        return this.sc.b$b(this, e, this.su(this.b0), this.st(this.b0), d.f, a, b, c);
    };
    CategorySeries.prototype.r7 = function (a, b, c) {
        var d = this.su(this.b0);
        var e = this.sv(this.b0);
        var f = this.st(this.b0);
        var g = this.ru();
        return this.sc.b$a(this, g.f, d, e, f, a, b, c);
    };
    CategorySeries.prototype.r6 = function (a, b, c) {
        var d = new HighlightingInfo();
        d.b = this;
        d.h = 0;
        d.g = this.ck != null ? this.ck.count - 1 : 0;
        d.d = true;
        if (c != null && c.h == d.h && c.g == d.g) {
            return c;
        }
        return d;
    };
    CategorySeries.prototype.ru = function () {
        var a = this.rt;
        if (this.cv()) {
            if (this.ce.g) {
                this.ce.t();
            }
            a = this.rx;
        }
        return a;
    };
    CategorySeries.prototype.s6 = function (a, b, c, d, e, f) {
        var g = this.bk != 1;
        this.r1.a1(this.r1.d, d.cm, a, b, c, d, e, f, true);
        this.r1.aa(this.ft);
        var h = this.r1.av;
        var i = null;
        var j = this.ck;
        var k = null;
        if (g && this.cd != null) {
            i = this.cd.a7.getHighlightingInfo(this, j, h.o, h.n, true);
            if (this.cd.a7.isCrossSeriesHighlight(this)) {
                k = this.cd.a7.getHighlightingInfo(this, j, h.o, h.n, true);
            }
            h.b = i;
        }
        h.f = f;
        this.s9(h);
        this.r1.y(this, i, f, g, h.m, this.cd.a7.totalHighlightingProgress);
    };
    CategorySeries.prototype.s7 = function (a, b, c, d, e, f) {
        var g = this.bk != 1;
        this.r1.a1(this.r1.b, d.cm, a, b, c, d, e, f, false);
        this.r1.ab(this.ft);
        var h = this.r1.aw;
        var i = null;
        var j = this.ck;
        if (g && this.cd != null) {
            i = this.cd.a7.getHighlightingInfo(this, j, h.o, h.n, false);
            h.b = i;
        }
        h.f = f;
        this.ta(h);
        this.r1.z(this, i, f, g, b < 0);
    };
    CategorySeries.prototype.fb = function (a, b, c) {
        var d = _super.prototype.fb.call(this, a, b, c);
        d = d && this.sp(this.fetchXAxis());
        d = d && this.sp(this.fetchYAxis());
        var e = c;
        if (!c.o() || b.isEmpty || a.isEmpty || this.ck == null) {
            d = false;
        }
        if (!d) {
            e.cr.d = 0;
        }
        return d;
    };
    CategorySeries.prototype.sp = function (a) {
        if (a == null || a.bh == null) {
            return false;
        }
        var b = typeCast(CategoryAxisBase.$, a);
        if (b != null) {
            if (b.itemsSource == null) {
                return false;
            }
            if (b.le < 1) {
                return false;
            }
        }
        else {
            var c = typeCast(NumericAxisBase.$, a);
            if (c != null) {
                return c.lv != c.lu;
            }
        }
        return true;
    };
    CategorySeries.prototype.es = function () {
        return this.sk;
    };
    CategorySeries.prototype.r3 = function () {
        return 12;
    };
    CategorySeries.prototype.k1 = function () {
        _super.prototype.k1.call(this);
        this.rv.v();
        this.rt.v();
        this.rx.v();
    };
    CategorySeries.prototype.mm = function (a) {
        _super.prototype.mm.call(this, a);
        this.r2.cr.g(this.fv);
        if (this.cx(this.b0)) {
            this.rt.y();
            this.rx.y();
            this.rv.y();
            return;
        }
        if (this.eu) {
            if (this.cv()) {
                if (this.ce.g) {
                    this.ce.t();
                }
                this.tb(this.rx, this.r2);
            }
            else {
                this.tb(this.rt, this.r2);
            }
            return;
        }
        if (this.ep(a)) {
            var b = this.rv;
            if (this.cv()) {
                if (this.ce.g) {
                    this.ce.t();
                }
                this.rv = this.rx;
                this.rx = b;
            }
            else {
                this.rv = this.rt;
                this.rt = b;
            }
            this.s8(this.rt, this.r2);
            if (this.e4) {
                this.ce.w();
                this.ce.r = truncate(this.gp());
                this.ce.b = this.cg != null ? this.cg : this.cf;
                this.r5.p(this.rv, this.rt, this.isVertical, this.fetchXAxis(), this.fetchYAxis(), this.r4, this.r3(), this.ca, this.b9(), runOn(this, this.ss), this.r2.bu);
            }
            this.kw();
            this.mu();
            if (this.e4) {
                this.e3 = false;
                this.e2 = true;
            }
        }
        else {
            this.s8(this.rt, this.r2);
            this.tb(this.rt, this.r2);
        }
    };
    CategorySeries.prototype.b9 = function () {
        return 3;
    };
    CategorySeries.prototype.ss = function () {
        if (this.isVertical) {
            return this.p3.left;
        }
        return this.p3.bottom;
    };
    CategorySeries.prototype.sw = function () {
        var e_1, _a;
        var a = 0;
        var b = this.fetchXAxis();
        try {
            for (var _b = __values(fromEnum(this.cd.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                if (c == this) {
                    return a;
                }
                var d = typeCast(CategorySeries.$, c);
                if (d != null) {
                    var e = typeCast(CategoryAxisBase.$, d.fetchXAxis());
                    if (e == b && d.preferredCategoryMode(e) == 2) {
                        a++;
                    }
                }
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        return -1;
    };
    Object.defineProperty(CategorySeries.prototype, "GetErrorBarsXAxis", {
        get: function () {
            return this.fetchXAxis();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CategorySeries.prototype, "GetErrorBarsYAxis", {
        get: function () {
            return this.fetchYAxis();
        },
        enumerable: false,
        configurable: true
    });
    CategorySeries.prototype.s5 = function (a, b) {
        this.r1.az(this, this.sm(), runOn(this, this.rm), this.st(a), this.su(a));
        var c = this.r1.d;
        var d = c != null;
        var e = this.rs();
        if (e == null) {
            return;
        }
        var f = this.getEffectiveViewport1(a);
        var g = new ScalerParams(0, a.bv, a.bu, e.cg, f);
        var h = this.ck == null ? 0 : this.ck.count;
        var i = a;
        var j = b.f;
        var k = i.cr.e;
        var l = i.cr.f;
        var m = i.cr.d;
        var n = k * m;
        for (var o = 0; o < a.cu.count; o++) {
            var p = a.cu.item(o);
            var q = p.content;
            if (d) {
                var r = p.al;
                this.s6(j, r, h, e, g, a.q);
            }
            this.r1.ac(p, q);
        }
    };
    CategorySeries.prototype.tb = function (a, b) {
        this.pu = a.aa;
        b.au();
    };
    CategorySeries.prototype.s8 = function (a, b) {
        a.u();
    };
    CategorySeries.prototype.st = function (a) {
        return a.cr.d;
    };
    CategorySeries.prototype.su = function (a) {
        return a.cr.e;
    };
    CategorySeries.prototype.sv = function (a) {
        return a.cr.f;
    };
    CategorySeries.prototype.s4 = function (a) {
        var b = a;
        b.cu.count = 0;
    };
    CategorySeries.prototype.mn = function (a, b) {
        _super.prototype.mn.call(this, a, b);
        if (!this.e1) {
            this.b0.a2(b);
            return;
        }
        var c = typeCast(CategorySeriesView.$, this.bz);
        c.cr.g(this.fv);
        this.b0.a2(b);
        if (this.cx(this.bz)) {
            return;
        }
        this.tc();
        this.e1 = false;
    };
    CategorySeries.prototype.tc = function () {
        var a = typeCast(CategorySeriesView.$, this.bz);
        if (!this.ev) {
            this.s8(this.rw, a);
        }
        this.ev = false;
        this.tb(this.rw, a);
    };
    CategorySeries.prototype.rz = function (a) {
        var b = typeCast(CategorySeriesView.$, a);
        if (b != null && b.q) {
            if (b.p) {
                return new CategoryFramePreparer(1, typeCast(IIsCategoryBased_$type, this), typeCast(ISupportsMarkers_$type, b), b, this, b.cr);
            }
            else {
                return new CategoryFramePreparer(1, typeCast(IIsCategoryBased_$type, this), typeCast(ISupportsMarkers_$type, b), this.cd.cu.o, this, b.cr);
            }
        }
        else {
            return this.ry;
        }
    };
    CategorySeries.prototype.an = function (a) {
        if (this.fetchXAxis() == a) {
            return this.fetchYAxis();
        }
        if (this.fetchYAxis() == a) {
            return this.fetchXAxis();
        }
        return null;
    };
    CategorySeries.prototype.ag = function () {
        return [this.fetchXAxis(), this.fetchYAxis()];
    };
    CategorySeries.rn = function (a, b, c, d, e) {
        var f = null;
        if (b > -1 && !d.isEmpty && !c.isEmpty) {
            var g = a._inner[0][0] < c.left - 2000 ? c.left - 10 : NaN;
            var h = c.bottom + 10;
            var i = a._inner[b][0] > c.right + 2000 ? c.right + 10 : NaN;
            var j = c.top - 10;
            f = new Clipper(1, g, h, i, j, e);
        }
        return f;
    };
    CategorySeries.$t = markType(CategorySeries, 'CategorySeries', MarkerSeries.$, [IHasCategoryModePreference_$type, ISupportsErrorBars_$type]);
    CategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, CategorySeries, 'raisePropertyChanged', ['IsCustomCategoryMarkerStyleAllowed:si:td', [0, false], 'IsCustomCategoryStyleAllowed:sj:te', [0, false], 'IsTransitionInEnabled:sk:tf', [0, false], 'TransitionInMode:r4:tg', [CategoryTransitionInMode_$type, enumGetBox(CategoryTransitionInMode_$type, 0)], 'UseHighMarkerFidelity:so:th', [0, false]]);
    return CategorySeries;
}(MarkerSeries));
export { CategorySeries };
/**
 * @hidden
 */
var CategorySeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CategorySeriesView, _super);
    function CategorySeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.ct = null;
        _this.cw = 0;
        _this.cr = null;
        _this.cu = null;
        _this.cw = -1;
        _this.ct = a;
        _this.cr = _this.cs();
        _this.cu = ((function () {
            var $ret = new Pool$1(Marker.$);
            $ret.create = runOn(_this, _this.b0);
            $ret.activate = runOn(_this, _this.cj);
            $ret.disactivate = runOn(_this, _this.cl);
            $ret.destroy = runOn(_this, _this.ck);
            return $ret;
        })());
        return _this;
    }
    CategorySeriesView.prototype.cv = function (a) {
        if (this.cw != a.t) {
            return true;
        }
        return false;
    };
    CategorySeriesView.prototype.cy = function (a) {
        this.cw = a.t;
    };
    CategorySeriesView.prototype.updateMarkerTemplate = function (a, b, c) {
        if (!this.b1.ql) {
            var d = this.cu.item(a);
            var e = d.content;
            e.item = this.e.ck.item(b);
            d.ak = b;
            d.al = c;
        }
    };
    CategorySeriesView.prototype.cs = function () {
        return new CategoryBucketCalculator(this);
    };
    Object.defineProperty(CategorySeriesView.prototype, "shouldDisplayMarkers", {
        get: function () {
            return this.ct.qj();
        },
        enumerable: false,
        configurable: true
    });
    CategorySeriesView.prototype.updateMarkerCount = function (a) {
        this.cu.count = a;
    };
    CategorySeriesView.prototype.cf = function (a) {
        this.cu.c(a);
    };
    CategorySeriesView.prototype.cx = function () {
    };
    CategorySeriesView.$t = markType(CategorySeriesView, 'CategorySeriesView', MarkerSeriesView.$, [ISupportsMarkers_$type]);
    return CategorySeriesView;
}(MarkerSeriesView));
export { CategorySeriesView };
