/*
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 { CategorySeries } from "./CategorySeries";
import { IIsCategoryBased_$type } from "./IIsCategoryBased";
import { IHasSingleValueCategory_$type } from "./IHasSingleValueCategory";
import { IHasCategoryTrendline_$type } from "./IHasCategoryTrendline";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { IAnchoredCategorySeriesInteractionManager_$type } from "./IAnchoredCategorySeriesInteractionManager";
import { DVContainer } from "igniteui-react-core";
import { enumGetBox, typeCast, Point_$type, markType, markDep } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { Series } from "./Series";
import { TrendLineType_$type } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { PenLineCap_$type } from "igniteui-react-core";
import { DoubleCollection } from "igniteui-react-core";
import { CategoryFrame } from "./CategoryFrame";
import { ICategoryScaler_$type } from "./ICategoryScaler";
import { IScaler_$type } from "./IScaler";
import { CategorySeriesView } from "./CategorySeriesView";
import { CategorySeriesMarkerCollisionAvoidance_$type } from "./CategorySeriesMarkerCollisionAvoidance";
import { ConsolidatedItemHitTestBehavior_$type } from "./ConsolidatedItemHitTestBehavior";
import { CategoryFramePreparer } from "./CategoryFramePreparer";
import { Rect } from "igniteui-react-core";
import { ISortingAxis_$type } from "./ISortingAxis";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { NumericAxisBase } from "./NumericAxisBase";
import { CategoryBucketCalculator } from "./CategoryBucketCalculator";
import { AxisRange } from "./AxisRange";
import { NumericYAxis } from "./NumericYAxis";
import { ScalerParams } from "./ScalerParams";
import { CategoryMarkerManager } from "./CategoryMarkerManager";
import { CollisionAvoider } from "./CollisionAvoider";
import { NonCollisionAvoider } from "./NonCollisionAvoider";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
/**
 * @hidden
 */
var AnchoredCategorySeries = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(AnchoredCategorySeries, _super);
    function AnchoredCategorySeries() {
        var _this = _super.call(this) || this;
        _this.rq = null;
        _this.ru = false;
        _this.rs = null;
        _this.rn = null;
        _this.ry = null;
        _this.pz = new CategoryFramePreparer(1, _this, _this.p3, _this, _this, _this.p3.cr);
        return _this;
    }
    Object.defineProperty(AnchoredCategorySeries.prototype, "rr", {
        get: function () {
            var _this = this;
            if (this.rq == null) {
                this.rq = DVContainer.instance.createInstance(IAnchoredCategorySeriesInteractionManager_$type, function () { return _this.cg.n; });
            }
            return this.rq;
        },
        enumerable: true,
        configurable: true
    });
    AnchoredCategorySeries.prototype.getHostReferenceValue = function () {
        return this.fa();
    };
    AnchoredCategorySeries.prototype.bp = function () {
        var a = new AnchoredCategorySeriesView(this);
        return a;
    };
    AnchoredCategorySeries.prototype.kk = function (a) {
        _super.prototype.kk.call(this, a);
        this.rm = a;
    };
    AnchoredCategorySeries.prototype.gt = function (a, b) {
        var c = this.ic(b);
        if (c == AnchoredCategorySeries.$$p[2]) {
            return this.gu(a, b, this.r2);
        }
        return _super.prototype.gt.call(this, a, b);
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "valueColumn", {
        get: function () {
            return this.rs;
        },
        set: function (a) {
            if (this.rs != a) {
                var b = this.rs;
                this.rs = a;
                if (!this.ru) {
                    this.raisePropertyChanged("ValueColumn", b, this.rs);
                }
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "sk", {
        get: function () {
            return this.c(AnchoredCategorySeries.r9);
        },
        set: function (a) {
            this.h(AnchoredCategorySeries.r9, a);
        },
        enumerable: true,
        configurable: true
    });
    AnchoredCategorySeries.prototype.dq = function (a) {
        var b = new Rect(0, 0, 0, 1, 1);
        var c = this.fetchXAxis();
        var d = this.fetchYAxis();
        var e = this.n0(this.bs);
        var f = c != null ? this.pz.r(typeCast(ICategoryScaler_$type, c), b, b, e) : 0;
        return this.rr.c$a(this, this.valueColumn, c, d, f, a);
    };
    AnchoredCategorySeries.prototype.rj = function (a, b, c) {
        if (b < a || a < 0 || a > this.valueColumn.count || b < 0 || b > this.valueColumn.count || c == null) {
            return null;
        }
        var d = new Array((b - a) + 1);
        var e = c.cf;
        var f = null;
        if (e) {
            f = c.i$b;
        }
        for (var g = a; g <= b; g++) {
            var h = g;
            if (e) {
                h = f._inner[h];
            }
            d[g - a] = this.cd.item(g);
        }
        return d;
    };
    AnchoredCategorySeries.prototype.kp = function (a, b, c, d) {
        _super.prototype.kp.call(this, a, b, c, d);
        if (this.rm.c3 && this.rm.c2.g$b(a, b, c, d)) {
            this.k3(false);
            this.ka();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.valueColumn);
                    this.valueColumn = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.valueColumn = this.ca(this.r2);
                }
                var e = typeCast(NumericAxisBase.$, this.fetchYAxis());
                if (e != null && !e.cn()) {
                    this.rm.cr.g(this.fq);
                    this.k3(false);
                }
                break;
            case AnchoredCategorySeries.$$p[2]:
                if (this.cd != null) {
                    this.cd.deregisterColumn(this.valueColumn);
                    this.valueColumn = this.ca(this.r2);
                }
                this.ry = this.r2;
                break;
            case "ValueColumn":
                if (this.rm.c3) {
                    this.rm.c2.g$i();
                }
                var f = typeCast(NumericAxisBase.$, this.fetchYAxis());
                if (f != null && !f.cn()) {
                    this.rm.cr.g(this.fq);
                    this.k3(false);
                }
                this.r8();
                this.lk();
                break;
            case "TrendLineBrush":
                this.lg();
                break;
            case "ErrorBarSettings":
                this.k3(false);
                break;
            case "TrendLineType":
                this.ka();
                break;
            case AnchoredCategorySeries.$$p[1]:
                this.k3(false);
                break;
        }
    };
    AnchoredCategorySeries.prototype.ao = function (a) {
        if (this.valueColumn == null || this.valueColumn.count == 0) {
            return null;
        }
        if (a == this.fetchXAxis()) {
            return new AxisRange(0, this.valueColumn.count - 1);
        }
        if (a == this.fetchYAxis()) {
            return new AxisRange(this.valueColumn.minimum, this.valueColumn.maximum);
        }
        return null;
    };
    AnchoredCategorySeries.prototype.jo = function (a, b, c, d) {
        switch (a) {
            case 4:
            case 1:
            case 0:
                this.rm.cr.g(this.fq);
                break;
        }
        if (this.rm.c3) {
            this.rm.c2.g$e(a, b, c, d);
        }
        this.r8();
        this.lk();
    };
    AnchoredCategorySeries.prototype.qt = function () {
        return this.rv(this.p3);
    };
    AnchoredCategorySeries.prototype.rv = function (a) {
        var b = 0;
        var c = a.bv;
        var d = a.bu;
        var e = this.getEffectiveViewport1(a);
        var f = typeCast(NumericYAxis.$, this.fetchYAxis());
        if (!c.isEmpty && !d.isEmpty && f != null) {
            var g = new ScalerParams(0, c, d, f.ca, e);
            if (f.ch) {
                g.b = this.fa();
            }
            b = f.dz(f.kn, g);
        }
        return b;
    };
    AnchoredCategorySeries.prototype.r7 = function (a, b, c) {
        var d = this.rv(c);
        if (a.count > 0) {
            var e = d;
            a.add({ $type: Point_$type, x: a._inner[a.count - 1].x, y: e });
            a.add({ $type: Point_$type, x: a._inner[0].x, y: e });
        }
    };
    AnchoredCategorySeries.prototype.rk = function (a, b, c, d) {
        return this.rl(a, b, c, d, false);
    };
    AnchoredCategorySeries.prototype.rl = function (a, b, c, d, e) {
        return CategorySeries.pp(a, b, c, d, e);
    };
    AnchoredCategorySeries.prototype.ec = function (a, b, c) {
        var d = _super.prototype.ec.call(this, a, b, c);
        var e = c;
        if (this.valueColumn == null || this.valueColumn.count == 0 || e.cr.d < 1) {
            d = false;
        }
        return d;
    };
    AnchoredCategorySeries.prototype.jl = function (a, b) {
        _super.prototype.jl.call(this, a, b);
        var c = b;
        c.cx();
        if (c.c3) {
            c.c2.g$d();
        }
    };
    AnchoredCategorySeries.prototype.q9 = function (a, b) {
        _super.prototype.q9.call(this, a, b);
        this.p0(b).d(a, b);
    };
    AnchoredCategorySeries.prototype.rc = function (a, b) {
        _super.prototype.rc.call(this, a, b);
        var c = typeCast(AnchoredCategorySeriesView.$, b);
        c.b3 = true;
        if (c.c3) {
            c.c2.g$g(a.p);
        }
        if (this.ok()) {
            CategoryMarkerManager.e(this, a.m, b.cu, this.om);
            this.q6(b, a);
            b.cm();
        }
        this.r4(a, b);
    };
    AnchoredCategorySeries.prototype.k2 = function (a, b, c, d, e) {
        _super.prototype.k2.call(this, a, b, c, d, e);
        var f = this.a3.a$h.item(d);
        var g = f;
        g.cr.g(this.fq);
        f.a1(c);
        if (this.cp(g)) {
            return;
        }
        if (this.rn == null) {
            this.rn = new CategoryFrame(3);
        }
        this.rn.u();
        this.q9(this.rn, g);
        this.rc(this.rn, g);
    };
    AnchoredCategorySeries.prototype.r4 = function (a, b) {
    };
    AnchoredCategorySeries.prototype.lg = function () {
        _super.prototype.lg.call(this);
        if (this.gi < 0) {
            return;
        }
        this.rm.c7();
        if (this.trendLineBrush != null) {
            this.rm.c5();
        }
        else {
            this.rm.c4();
        }
    };
    AnchoredCategorySeries.prototype.gw = function (a, b) {
        if (this.rm.c3 && a == this.rm.c2.g$j) {
            return null;
        }
        return _super.prototype.gw.call(this, a, b);
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "currentCategoryMode", {
        get: function () {
            return this.preferredCategoryMode(typeCast(CategoryAxisBase.$, this.pu()));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "scaler", {
        get: function () {
            return typeCast(ICategoryScaler_$type, this.pu());
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "yScaler", {
        get: function () {
            return typeCast(IScaler_$type, this.qe());
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "bucketizer", {
        get: function () {
            return this.rm.cr;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "currentMode2Index", {
        get: function () {
            return this.qx();
        },
        enumerable: true,
        configurable: true
    });
    AnchoredCategorySeries.prototype.provideCollisionDetector = function () {
        if (this.ro == 1) {
            return new CollisionAvoider();
        }
        return NonCollisionAvoider.b;
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "trendlinePreparer", {
        get: function () {
            return this.rm.c3 ? this.rm.c2 : null;
        },
        enumerable: true,
        configurable: true
    });
    AnchoredCategorySeries.prototype.jv = function (a) {
        _super.prototype.jv.call(this, a);
        if (this.rm.c3) {
            this.a5.exportTrendlineData(this, a, this.rm.c2.g$j);
        }
    };
    AnchoredCategorySeries.prototype.gq = function (a) {
        var _this = this;
        var b = this.fetchXAxis();
        var c = this.fetchYAxis();
        return this.rr.c$b(this, a, this.qu(this.bs), this.valueColumn, b, c, this.rp == 1, function (d) { return _super.prototype.gq.call(_this, d); });
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "mayContainUnknowns", {
        get: function () {
            return this.valueColumn == null || this.valueColumn.mayContainUnknowns;
        },
        enumerable: true,
        configurable: true
    });
    AnchoredCategorySeries.prototype.fa = function () {
        return Series.fb(this.valueColumn, typeCast(ISortingAxis_$type, this.fetchXAxis()));
    };
    AnchoredCategorySeries.prototype.get_rx = function () {
        return 0;
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "rx", {
        get: function () {
            return this.get_rx();
        },
        enumerable: true,
        configurable: true
    });
    AnchoredCategorySeries.prototype.ap = function (a) {
        if (a.isEmpty && this.b6 != null) {
            a = this.b6.os;
        }
        if (this.valueColumn == null) {
            return null;
        }
        var b = this.ny(this.bs);
        var c = this.pu();
        var d = new ScalerParams(0, a, this.b6.o7, c.ca, this.getEffectiveViewport());
        var e = (c.d2(b.left, d));
        var f = (c.d2(b.right, d));
        if (c.ca) {
            var g = e;
            e = f;
            f = g;
        }
        e -= this.rx;
        f += this.rx;
        var h = null;
        if (c.cf) {
            h = c;
            e = h.i$f(e);
            f = h.i$f(f);
        }
        else {
            e = Math.floor(e);
            f = Math.ceil(f);
        }
        if (isNaN_(e) || isNaN_(f)) {
            return null;
        }
        e = Math.max(0, Math.min(this.valueColumn.count - 1, e));
        f = Math.max(0, Math.min(this.valueColumn.count - 1, f));
        var i = 1.7976931348623157E+308;
        var j = -1.7976931348623157E+308;
        if (truncate(e) <= truncate(f)) {
            for (var k = truncate(e); k <= truncate(f); k++) {
                var l = k;
                if (h != null) {
                    l = h.i$b._inner[k];
                }
                var m = this.valueColumn.item(l);
                if (this.valueColumn.mayContainUnknowns) {
                    if (isInfinity(m) || isNaN_(m)) {
                        continue;
                    }
                }
                i = Math.min(i, m);
                j = Math.max(j, m);
            }
        }
        var n = new AxisRange(i, j);
        n = this.an(n, this.qe(), a);
        return n;
    };
    AnchoredCategorySeries.prototype.r8 = function () {
        this.e1 = this.valueColumn == null || this.valueColumn.count == 0 ? NaN : this.valueColumn.item(this.valueColumn.count - 1);
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.qp;
        },
        enumerable: true,
        configurable: true
    });
    AnchoredCategorySeries.$t = markType(AnchoredCategorySeries, 'AnchoredCategorySeries', CategorySeries.$, [IIsCategoryBased_$type, IHasSingleValueCategory_$type, IHasCategoryTrendline_$type, ITrendLineSeries_$type]);
    AnchoredCategorySeries.r9 = DependencyProperty.i("ActualTrendLineBrush", Brush.$, AnchoredCategorySeries.$, new PropertyMetadata(2, null, function (a, b) { return a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue); }));
    AnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, AnchoredCategorySeries, 'raisePropertyChanged', ['ConsolidatedItemHitTestBehavior:rp:sa', [ConsolidatedItemHitTestBehavior_$type, enumGetBox(ConsolidatedItemHitTestBehavior_$type, 0)], 'MarkerCollisionAvoidance:ro:sb', [CategorySeriesMarkerCollisionAvoidance_$type, enumGetBox(CategorySeriesMarkerCollisionAvoidance_$type, 1)], 'ValueMemberPath:r2:sj', [2, null], 'TrendLineType::sh', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::sg', [1, 1.5], 'TrendLinePeriod::sf', [1, 7], 'TrendLineBrush::sc', [Brush.$, null], 'TrendLineZIndex:rw:si', [1, 1001], 'TrendLineDashArray:sl:sd', [DoubleCollection.$], 'TrendLineDashCap:sm:se', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
    return AnchoredCategorySeries;
}(CategorySeries));
export { AnchoredCategorySeries };
/**
 * @hidden
 */
var AnchoredCategoryBucketCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(AnchoredCategoryBucketCalculator, _super);
    function AnchoredCategoryBucketCalculator(a) {
        var _this = _super.call(this, a) || this;
        _this.i = null;
        _this.h = null;
        _this.j = 0;
        _this.i = a;
        return _this;
    }
    AnchoredCategoryBucketCalculator.prototype.getBucketWithoutUnknowns = function (a) {
        var b = this.h;
        var c = this.j;
        var d = a * this.d;
        var e = d + this.d - 1;
        var f = c - 1;
        d = d < f ? d : f;
        e = e < f ? e : f;
        var g = 1.7976931348623157E+308;
        var h = -1.7976931348623157E+308;
        var i = true;
        for (var j = d; j <= e; ++j) {
            var k = b[j];
            g = g < k ? g : k;
            h = h > k ? h : k;
            i = false;
        }
        if (!i) {
            return [0.5 * (d + e), g, h];
        }
        return [0.5 * (d + e), NaN, NaN];
    };
    AnchoredCategoryBucketCalculator.prototype.getBucket = function (a) {
        var b = this.h;
        var c = this.j;
        var d = a * this.d;
        var e = d + this.d - 1;
        var f = c - 1;
        d = d < f ? d : f;
        e = e < f ? e : f;
        var g = 0;
        var h = 0;
        var i = true;
        for (var j = d; j <= e; ++j) {
            var k = b[j];
            if (!i) {
                if (!isNaN_(k)) {
                    g = g < k ? g : k;
                    h = h > k ? h : k;
                }
            }
            else {
                if (!isNaN_(k)) {
                    g = k;
                    h = k;
                    i = false;
                }
            }
        }
        if (!i) {
            return [0.5 * (d + e), g, h];
        }
        return [0.5 * (d + e), NaN, NaN];
    };
    AnchoredCategoryBucketCalculator.prototype.cacheValues = function () {
        this.j = this.i.c0.valueColumn.count;
        this.h = this.i.c0.valueColumn.asArray();
    };
    AnchoredCategoryBucketCalculator.prototype.unCacheValues = function () {
        this.h = null;
    };
    AnchoredCategoryBucketCalculator.$t = markType(AnchoredCategoryBucketCalculator, 'AnchoredCategoryBucketCalculator', CategoryBucketCalculator.$);
    return AnchoredCategoryBucketCalculator;
}(CategoryBucketCalculator));
export { AnchoredCategoryBucketCalculator };
/**
 * @hidden
 */
var AnchoredCategorySeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(AnchoredCategorySeriesView, _super);
    function AnchoredCategorySeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c0 = null;
        _this.c1 = null;
        _this.c0 = a;
        return _this;
    }
    Object.defineProperty(AnchoredCategorySeriesView.prototype, "c2", {
        get: function () {
            if (this.c1 == null) {
                this.c1 = CategoryTrendLineManagerFactory.a(this.c1, this.e.aq(), this.e.ls, this.e, this.e.cg);
            }
            return this.c1;
        },
        set: function (a) {
            this.c1 = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeriesView.prototype, "c3", {
        get: function () {
            return this.c1 != null;
        },
        enumerable: true,
        configurable: true
    });
    AnchoredCategorySeriesView.prototype.c7 = function () {
        this.c0.sk = null;
    };
    AnchoredCategorySeriesView.prototype.c5 = function () {
        this.c0.sk = this.c0.trendLineBrush;
    };
    AnchoredCategorySeriesView.prototype.c4 = function () {
        this.c0.sk = this.c0.m9;
    };
    AnchoredCategorySeriesView.prototype.cs = function () {
        return new AnchoredCategoryBucketCalculator(this);
    };
    AnchoredCategorySeriesView.prototype.c6 = function () {
        this.cr.cacheValues();
    };
    AnchoredCategorySeriesView.prototype.c8 = function () {
        this.cr.unCacheValues();
    };
    AnchoredCategorySeriesView.prototype.c9 = function (a) {
        var b = this.cu.item(a);
        return this.cp(b);
    };
    AnchoredCategorySeriesView.prototype.a5 = function (a, b) {
        if (a.d) {
            if (this.c0.trendLineType != 0 && !b) {
                var c = this.c2.g$j;
                c.ac = this.c0.trendLineThickness;
                c._stroke = this.c0.sk;
                c.ai = this.c0.sl;
                c.ad = this.c0.sm;
                a.u(c);
            }
        }
        _super.prototype.a5.call(this, a, b);
    };
    AnchoredCategorySeriesView.prototype.getDefaultTooltipTemplate = function () {
        return this.c0.rr.c$c(this.e, this.c0.r2);
    };
    AnchoredCategorySeriesView.$t = markType(AnchoredCategorySeriesView, 'AnchoredCategorySeriesView', CategorySeriesView.$);
    return AnchoredCategorySeriesView;
}(CategorySeriesView));
export { AnchoredCategorySeriesView };
//# sourceMappingURL=AnchoredCategorySeries_combined.js.map
