/*
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 { 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_ } from "igniteui-react-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
/**
 * @hidden
 */
export let AnchoredCategorySeries = /*@__PURE__*/ (() => {
    class AnchoredCategorySeries extends CategorySeries {
        constructor() {
            super();
            this.pf = null;
            this.pj = false;
            this.ph = null;
            this.pc = null;
            this.pm = null;
            this.no = new CategoryFramePreparer(1, this, this.ns, this, this, this.ns.cn);
        }
        get pg() {
            if (this.pf == null) {
                this.pf = DVContainer.instance.createInstance(IAnchoredCategorySeriesInteractionManager_$type, () => this.b2.n);
            }
            return this.pf;
        }
        getHostReferenceValue() {
            return this.eh();
        }
        bf() {
            let a = new AnchoredCategorySeriesView(this);
            return a;
        }
        i2(a) {
            super.i2(a);
            this.pb = a;
        }
        fs(a, b) {
            let c = this.g2(b);
            if (c == AnchoredCategorySeries.$$p[2]) {
                return this.ft(a, b, this.pq);
            }
            return super.fs(a, b);
        }
        get valueColumn() {
            return this.ph;
        }
        set valueColumn(a) {
            if (this.ph != a) {
                let b = this.ph;
                this.ph = a;
                if (!this.pj) {
                    this.raisePropertyChanged("ValueColumn", b, this.ph);
                }
            }
        }
        get p8() {
            return this.c(AnchoredCategorySeries.px);
        }
        set p8(a) {
            this.h(AnchoredCategorySeries.px, a);
        }
        c9(a) {
            let b = new Rect(0, 0, 0, 1, 1);
            let c = this.fetchXAxis();
            let d = this.fetchYAxis();
            let e = this.l2(this.bi);
            let f = c != null ? this.no.r(typeCast(ICategoryScaler_$type, c), b, b, e) : 0;
            return this.pg.c$a(this, this.valueColumn, c, d, f, a);
        }
        o8(a, b, c) {
            if (b < a || a < 0 || a > this.valueColumn.count || b < 0 || b > this.valueColumn.count || c == null) {
                return null;
            }
            let d = new Array((b - a) + 1);
            let e = c.cf;
            let f = null;
            if (e) {
                f = c.i$b;
            }
            for (let g = a; g <= b; g++) {
                let h = g;
                if (e) {
                    h = f._inner[h];
                }
                d[g - a] = this.bz.item(g);
            }
            return d;
        }
        i7(a, b, c, d) {
            super.i7(a, b, c, d);
            if (this.pb.cz && this.pb.cy.g$b(a, b, c, d)) {
                this.jl(false);
                this.it();
            }
            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.bw(this.pq);
                    }
                    let e = typeCast(NumericAxisBase.$, this.fetchYAxis());
                    if (e != null && !e.cn()) {
                        this.pb.cn.g(this.eu);
                        this.jl(false);
                    }
                    break;
                case AnchoredCategorySeries.$$p[2]:
                    if (this.bz != null) {
                        this.bz.deregisterColumn(this.valueColumn);
                        this.valueColumn = this.bw(this.pq);
                    }
                    this.pm = this.pq;
                    break;
                case "ValueColumn":
                    if (this.pb.cz) {
                        this.pb.cy.g$i();
                    }
                    let f = typeCast(NumericAxisBase.$, this.fetchYAxis());
                    if (f != null && !f.cn()) {
                        this.pb.cn.g(this.eu);
                        this.jl(false);
                    }
                    this.pw();
                    this.jy();
                    break;
                case "TrendLineBrush":
                    this.jw();
                    break;
                case "ErrorBarSettings":
                    this.jl(false);
                    break;
                case "TrendLineType":
                    this.it();
                    break;
                case AnchoredCategorySeries.$$p[1]:
                    this.jl(false);
                    break;
            }
        }
        an(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;
        }
        h6(a, b, c, d) {
            switch (a) {
                case 4:
                case 1:
                case 0:
                    this.pb.cn.g(this.eu);
                    break;
            }
            if (this.pb.cz) {
                this.pb.cy.g$e(a, b, c, d);
            }
            this.pw();
            this.jy();
        }
        oj() {
            return this.pk(this.ns);
        }
        pk(a) {
            let b = 0;
            let c = a.bs;
            let d = a.br;
            let e = this.getEffectiveViewport1(a);
            let f = typeCast(NumericYAxis.$, this.fetchYAxis());
            if (!c.isEmpty && !d.isEmpty && f != null) {
                let g = new ScalerParams(0, c, d, f.ca, e);
                if (f.ch) {
                    g.b = this.eh();
                }
                b = f.dy(f.km, g);
            }
            return b;
        }
        pv(a, b, c) {
            let d = this.pk(c);
            if (a.count > 0) {
                let 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 });
            }
        }
        o9(a, b, c, d) {
            return this.pa(a, b, c, d, false);
        }
        pa(a, b, c, d, e) {
            return CategorySeries.ne(a, b, c, d, e);
        }
        dw(a, b, c) {
            let d = super.dw(a, b, c);
            let e = c;
            if (this.valueColumn == null || this.valueColumn.count == 0 || e.cn.d < 1) {
                d = false;
            }
            return d;
        }
        h3(a, b) {
            super.h3(a, b);
            let c = b;
            c.ct();
            if (c.cz) {
                c.cy.g$d();
            }
        }
        oy(a, b) {
            super.oy(a, b);
            this.np(b).d(a, b);
        }
        o1(a, b) {
            super.o1(a, b);
            let c = typeCast(AnchoredCategorySeriesView.$, b);
            c.b0 = true;
            if (c.cz) {
                c.cy.g$g(a.p);
            }
            if (this.md()) {
                CategoryMarkerManager.b(this, a.m, b.cq, this.mf);
                this.ov(b, a);
                b.cj();
            }
            this.ps(a, b);
        }
        jk(a, b, c, d, e) {
            super.jk(a, b, c, d, e);
            let f = this.a0.a$h.item(d);
            let g = f;
            g.cn.g(this.eu);
            f.ay(c);
            if (this.cc(g)) {
                return;
            }
            if (this.pc == null) {
                this.pc = new CategoryFrame(3);
            }
            this.pc.u();
            this.oy(this.pc, g);
            this.o1(this.pc, g);
        }
        ps(a, b) {
        }
        jw() {
            super.jw();
            if (this.fh < 0) {
                return;
            }
            this.pb.c3();
            if (this.trendLineBrush != null) {
                this.pb.c1();
            }
            else {
                this.pb.c0();
            }
        }
        fv(a, b) {
            if (this.pb.cz && a == this.pb.cy.g$j) {
                return null;
            }
            return super.fv(a, b);
        }
        get currentCategoryMode() {
            return this.preferredCategoryMode(typeCast(CategoryAxisBase.$, this.nj()));
        }
        get scaler() {
            return typeCast(ICategoryScaler_$type, this.nj());
        }
        get yScaler() {
            return typeCast(IScaler_$type, this.n3());
        }
        get bucketizer() {
            return this.pb.cn;
        }
        get currentMode2Index() {
            return this.om();
        }
        provideCollisionDetector() {
            if (this.pd == 1) {
                return new CollisionAvoider();
            }
            return NonCollisionAvoider.b;
        }
        get trendlinePreparer() {
            return this.pb.cz ? this.pb.cy : null;
        }
        ic(a) {
            super.ic(a);
            if (this.pb.cz) {
                this.a2.exportTrendlineData(this, a, this.pb.cy.g$j);
            }
        }
        fp(a) {
            let b = this.fetchXAxis();
            let c = this.fetchYAxis();
            return this.pg.c$b(this, a, this.ok(this.bi), this.valueColumn, b, c, this.pe == 1, (d) => super.fp(d));
        }
        get mayContainUnknowns() {
            return this.valueColumn == null || this.valueColumn.mayContainUnknowns;
        }
        eh() {
            return Series.ei(this.valueColumn, typeCast(ISortingAxis_$type, this.fetchXAxis()));
        }
        ao(a) {
            if (a.isEmpty && this.bs != null) {
                a = this.bs.n2;
            }
            if (this.valueColumn == null) {
                return null;
            }
            let b = this.l0(this.bi);
            let c = this.nj();
            let d = new ScalerParams(0, a, this.bs.oh, c.ca, this.getEffectiveViewport());
            let e = (c.d1(b.left, d));
            let f = (c.d1(b.right, d));
            let g = null;
            if (c.cf) {
                g = c;
                e = g.i$f(e);
                f = g.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));
            let h = 1.7976931348623157E+308;
            let i = -1.7976931348623157E+308;
            for (let j = truncate(e); j <= truncate(f); j++) {
                let k = j;
                if (g != null) {
                    k = g.i$b._inner[j];
                }
                h = Math.min(h, this.valueColumn.item(k));
                i = Math.max(i, this.valueColumn.item(k));
            }
            return new AxisRange(h, i);
        }
        pw() {
            this.d8 = this.valueColumn == null || this.valueColumn.count == 0 ? NaN : this.valueColumn.item(this.valueColumn.count - 1);
        }
        get useHighMarkerFidelity() {
            return this.of;
        }
    }
    AnchoredCategorySeries.$t = /*@__PURE__*/ markType(AnchoredCategorySeries, 'AnchoredCategorySeries', CategorySeries.$, [IIsCategoryBased_$type, IHasSingleValueCategory_$type, IHasCategoryTrendline_$type, ITrendLineSeries_$type]);
    AnchoredCategorySeries.px = /*@__PURE__*/ DependencyProperty.i("ActualTrendLineBrush", Brush.$, AnchoredCategorySeries.$, /*@__PURE__*/ new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
    AnchoredCategorySeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, AnchoredCategorySeries, 'raisePropertyChanged', ['ConsolidatedItemHitTestBehavior:pe:py', [ConsolidatedItemHitTestBehavior_$type, /*@__PURE__*/ enumGetBox(ConsolidatedItemHitTestBehavior_$type, 0)], 'MarkerCollisionAvoidance:pd:pz', [CategorySeriesMarkerCollisionAvoidance_$type, /*@__PURE__*/ enumGetBox(CategorySeriesMarkerCollisionAvoidance_$type, 1)], 'ValueMemberPath:pq:p7', [2, null], 'TrendLineType::p5', [TrendLineType_$type, /*@__PURE__*/ enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::p4', [1, 1.5], 'TrendLinePeriod::p3', [1, 7], 'TrendLineBrush::p0', [Brush.$, null], 'TrendLineZIndex:pl:p6', [1, 1001], 'TrendLineDashArray:p9:p1', [DoubleCollection.$], 'TrendLineDashCap:qa:p2', [PenLineCap_$type, /*@__PURE__*/ enumGetBox(PenLineCap_$type, 0)]]);
    return AnchoredCategorySeries;
})();
/**
 * @hidden
 */
export let AnchoredCategoryBucketCalculator = /*@__PURE__*/ (() => {
    class AnchoredCategoryBucketCalculator extends CategoryBucketCalculator {
        constructor(a) {
            super(a);
            this.i = null;
            this.h = null;
            this.j = 0;
            this.i = a;
        }
        getBucketWithoutUnknowns(a) {
            let b = this.h;
            let c = this.j;
            let d = a * this.d;
            let e = d + this.d - 1;
            let f = c - 1;
            d = d < f ? d : f;
            e = e < f ? e : f;
            let g = 1.7976931348623157E+308;
            let h = -1.7976931348623157E+308;
            let i = true;
            for (let j = d; j <= e; ++j) {
                let 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];
        }
        getBucket(a) {
            let b = this.h;
            let c = this.j;
            let d = a * this.d;
            let e = d + this.d - 1;
            let f = c - 1;
            d = d < f ? d : f;
            e = e < f ? e : f;
            let g = 0;
            let h = 0;
            let i = true;
            for (let j = d; j <= e; ++j) {
                let 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];
        }
        cacheValues() {
            this.j = this.i.cw.valueColumn.count;
            this.h = this.i.cw.valueColumn.asArray();
        }
        unCacheValues() {
            this.h = null;
        }
    }
    AnchoredCategoryBucketCalculator.$t = /*@__PURE__*/ markType(AnchoredCategoryBucketCalculator, 'AnchoredCategoryBucketCalculator', CategoryBucketCalculator.$);
    return AnchoredCategoryBucketCalculator;
})();
/**
 * @hidden
 */
export let AnchoredCategorySeriesView = /*@__PURE__*/ (() => {
    class AnchoredCategorySeriesView extends CategorySeriesView {
        constructor(a) {
            super(a);
            this.cw = null;
            this.cx = null;
            this.cw = a;
        }
        get cy() {
            if (this.cx == null) {
                this.cx = CategoryTrendLineManagerFactory.a(this.cx, this.e.ap(), this.e.j5, this.e, this.e.b2);
            }
            return this.cx;
        }
        set cy(a) {
            this.cx = a;
        }
        get cz() {
            return this.cx != null;
        }
        c3() {
            this.cw.p8 = null;
        }
        c1() {
            this.cw.p8 = this.cw.trendLineBrush;
        }
        c0() {
            this.cw.p8 = this.cw.lb;
        }
        co() {
            return new AnchoredCategoryBucketCalculator(this);
        }
        c2() {
            this.cn.cacheValues();
        }
        c4() {
            this.cn.unCacheValues();
        }
        c5(a) {
            let b = this.cq.item(a);
            return this.cm(b);
        }
        a2(a, b) {
            if (a.d) {
                if (this.cw.trendLineType != 0 && !b) {
                    let c = this.cy.g$j;
                    c.ac = this.cw.trendLineThickness;
                    c._stroke = this.cw.p8;
                    c.ai = this.cw.p9;
                    c.ad = this.cw.qa;
                    a.u(c);
                }
            }
            super.a2(a, b);
        }
        getDefaultTooltipTemplate() {
            return this.cw.pg.c$c(this.e, this.cw.pq);
        }
    }
    AnchoredCategorySeriesView.$t = /*@__PURE__*/ markType(AnchoredCategorySeriesView, 'AnchoredCategorySeriesView', CategorySeriesView.$);
    return AnchoredCategorySeriesView;
})();
//# sourceMappingURL=AnchoredCategorySeries_combined.js.map
