/*
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 { Series } from "./Series";
import { DependencyProperty } from "igniteui-angular-core";
import { IEnumerable_$type, runOn, delegateCombine, delegateRemove, typeCast, Point_$type, markType, markDep } from "igniteui-angular-core";
import { NumericXAxis } from "./NumericXAxis";
import { NumericYAxis } from "./NumericYAxis";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { Triangulator } from "igniteui-angular-core";
import { TriangulationStatusEventArgs } from "igniteui-angular-core";
import { FastItemsSource } from "igniteui-angular-core";
import { SeriesViewer } from "./SeriesViewer";
import { Axis } from "./Axis";
import { AxisRange } from "./AxisRange";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
/**
 * @hidden
 */
export let ScatterTriangulationSeries = /*@__PURE__*/ (() => {
    class ScatterTriangulationSeries extends Series {
        constructor() {
            super(...arguments);
            this.qf = null;
            this.qg = null;
            this.qo = false;
            this.qb = null;
            this.triangulationStatusChanged = null;
            this.qr = null;
            this.qc = null;
            this.qd = null;
            this.qe = null;
        }
        kx() {
            super.kx();
            this.p8 = null;
            this.p9 = null;
        }
        hy(a, b) {
            let c = this.js(b);
            if (c == ScatterTriangulationSeries.$$p[8]) {
                return this.hz(a, b, this.ra);
            }
            if (c == ScatterTriangulationSeries.$$p[12]) {
                return this.hz(a, b, this.ri);
            }
            return super.hy(a, b);
        }
        get ql() {
            return this.qf;
        }
        set ql(a) {
            let b = this.ql != a;
            if (b) {
                let c = this.ql;
                this.qf = a;
                this.raisePropertyChanged("XColumn", c, this.ql);
            }
        }
        get qm() {
            return this.qg;
        }
        set qm(a) {
            let b = this.qm != a;
            if (b) {
                let c = this.qm;
                this.qg = a;
                this.raisePropertyChanged("YColumn", c, this.qm);
            }
        }
        mm(a) {
            let b = this.ck != null && this.qn == null && this.qr == null && this.ql != null && this.qm != null && this.ql.count >= 3 && this.qm.count >= 3 && !this.qo;
            if (b) {
                this.rm();
                this.qo = true;
            }
        }
        rm() {
            this.qb = new Triangulator(this.ck.count, this.ql, this.qm);
            let a = this.qb;
            a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.rn));
            this.qb.y();
        }
        rk() {
            if (this.qb == null) {
                return;
            }
            this.qb.r();
            let a = this.qb;
            a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.rn));
            this.qb = null;
        }
        rn(a, b) {
            if (this.triangulationStatusChanged != null) {
                this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
            }
            if (b.currentStatus >= 100) {
                if (this.qb == null) {
                    return;
                }
                let c = this.qb;
                c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.rn));
                this.qr = this.qb.n();
                this.qb = null;
                let d = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.qr;
                    return $ret;
                })());
                this.qi = this.qh(d, "v1");
                this.qj = this.qh(d, "v2");
                this.qk = this.qh(d, "v3");
                this.ml(false);
            }
        }
        qh(a, b) {
            if (b == null) {
                return a.registerColumnInt(null, null, false);
            }
            let c = null;
            let d = SeriesViewer.cg(b, this.coercionMethods);
            c = d.a;
            return a.registerColumnInt(b, c, this.expectFunctions);
        }
        l7(a, b, c, d) {
            super.l7(a, b, c, d);
            switch (b) {
                case "FastItemsSource":
                    let e = typeCast(IFastItemsSource_$type, c);
                    if (e != null) {
                        e.deregisterColumn(this.ql);
                        e.deregisterColumn(this.qm);
                        this.ql = null;
                        this.qm = null;
                    }
                    this.rl();
                    let f = typeCast(IFastItemsSource_$type, d);
                    if (f != null) {
                        this.ql = this.ch(this.ra);
                        this.qm = this.ch(this.ri);
                    }
                    this.ml(false);
                    break;
                case ScatterTriangulationSeries.$$p[8]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.ql);
                        this.ql = this.ch(this.ra);
                    }
                    this.rl();
                    this.ml(false);
                    this.ls();
                    break;
                case ScatterTriangulationSeries.$$p[12]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.qm);
                        this.qm = this.ch(this.ri);
                    }
                    this.rl();
                    this.ml(false);
                    this.ls();
                    break;
                case ScatterTriangulationSeries.$$p[5]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).bz(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).cs(this);
                    }
                    if ((this.p8 != null && !this.p8.c0()) || (d == null && c != null)) {
                        this.ml(false);
                    }
                    this.ls();
                    break;
                case ScatterTriangulationSeries.$$p[9]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).bz(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).cs(this);
                    }
                    if ((this.p9 != null && !this.p9.c0()) || (d == null && c != null)) {
                        this.ml(false);
                    }
                    this.ls();
                    break;
                case ScatterTriangulationSeries.$$p[1]:
                    if (this.trianglesSource != null) {
                        this.rk();
                        this.qn = ((() => {
                            let $ret = new FastItemsSource();
                            $ret.e = this.trianglesSource;
                            return $ret;
                        })());
                    }
                    else {
                        this.qn = null;
                    }
                    break;
                case ScatterTriangulationSeries.$$p[0]:
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.qi);
                        g.deregisterColumn(this.qj);
                        g.deregisterColumn(this.qk);
                        this.qi = null;
                        this.qj = null;
                        this.qk = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.qi = this.qh(h, this.qy);
                        this.qj = this.qh(h, this.q0);
                        this.qk = this.qh(h, this.q2);
                    }
                    this.ml(false);
                    this.ls();
                    break;
                case ScatterTriangulationSeries.$$p[2]:
                    if (this.qn != null) {
                        this.qn.deregisterColumn(this.qi);
                        this.qi = this.qh(this.qn, this.qy);
                    }
                    this.ml(false);
                    this.ls();
                    break;
                case ScatterTriangulationSeries.$$p[3]:
                    if (this.qn != null) {
                        this.qn.deregisterColumn(this.qj);
                        this.qj = this.qh(this.qn, this.q0);
                    }
                    this.ml(false);
                    this.ls();
                    break;
                case ScatterTriangulationSeries.$$p[4]:
                    if (this.qn != null) {
                        this.qn.deregisterColumn(this.qk);
                        this.qk = this.qh(this.qn, this.q2);
                    }
                    this.ml(false);
                    this.ls();
                    break;
                case "XColumn":
                    if (this.p8 != null) {
                        this.p8.c0();
                    }
                    break;
                case "YColumn":
                    if (this.p9 != null) {
                        this.p9.c0();
                    }
                    break;
            }
        }
        qq(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        qp(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        fb(a, b, c) {
            return super.fb(a, b, c) && this.ck != null && this.p8 != null && this.p9 != null && this.p8.bh != null && this.p9.bh != null && a.width > 0 && a.height > 0 && this.qi != null && this.qi.count > 0 && this.qj != null && this.qj.count > 0 && this.qk != null && this.qk.count > 0 && this.ql != null && this.ql.count > 0 && this.qm != null && this.qm.count > 0;
        }
        rl() {
            if (this.trianglesSource == null) {
                this.qr = null;
                this.qi = null;
                this.qj = null;
                this.qk = null;
                this.qo = false;
            }
        }
        li() {
            super.li();
            if (this.p8 != null) {
                this.p8.h6();
            }
            if (this.p9 != null) {
                this.p9.h6();
            }
        }
        k3(a, b, c, d) {
            super.k3(a, b, c, d);
            this.rl();
            this.ml(false);
        }
        ap(a) {
            if (a != null && a == this.p8 && this.ql != null) {
                return new AxisRange(this.ql.minimum, this.ql.maximum);
            }
            if (a != null && a == this.p9 && this.qm != null) {
                return new AxisRange(this.qm.minimum, this.qm.maximum);
            }
            return null;
        }
        m9(a, b) {
            this.ml(false);
        }
        m8(a, b) {
            this.ml(false);
        }
        get qi() {
            return this.qc;
        }
        set qi(a) {
            let b = this.qi != a;
            if (b) {
                let c = this.qi;
                this.qc = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.qi);
            }
        }
        get qj() {
            return this.qd;
        }
        set qj(a) {
            let b = this.qj != a;
            if (b) {
                let c = this.qj;
                this.qd = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.qj);
            }
        }
        get qk() {
            return this.qe;
        }
        set qk(a) {
            let b = this.qk != a;
            if (b) {
                let c = this.qk;
                this.qe = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.qk);
            }
        }
        get_ee() {
            return true;
        }
        get_d3() {
            return true;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.hv(c);
            let e = d == null ? NaN : this.gd(d, "XMemberPath");
            let f = d == null ? NaN : this.gd(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.p = "X";
            g.q = this.ra != null ? this.ra : "X";
            g.r = this.q6 != null ? this.q6 : "X:";
            g.s = this.q8 != null ? this.q8 : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.p = "Y";
            h.q = this.ri != null ? this.ri : "Y";
            h.r = this.re != null ? this.re : "Y:";
            h.s = this.rg != null ? this.rg : "";
            let i = new DataLegendSeriesContext();
            i.f = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.b = this.av();
            return i;
        }
    }
    ScatterTriangulationSeries.$t = markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:qn:ro', [IFastItemsSource_$type, null], 'TrianglesSource::rp', [IEnumerable_$type, null], 'TriangleVertexMemberPath1:qy:rq', [2, null], 'TriangleVertexMemberPath2:q0:rr', [2, null], 'TriangleVertexMemberPath3:q2:rs', [2, null], 'XAxis:p8:rt', [NumericXAxis.$, null], 'XMemberAsLegendLabel:q6:ru', [2, null], 'XMemberAsLegendUnit:q8:rv', [2, null], 'XMemberPath:ra:rw', [2, null], 'YAxis:p9:rx', [NumericYAxis.$, null], 'YMemberAsLegendLabel:re:ry', [2, null], 'YMemberAsLegendUnit:rg:rz', [2, null], 'YMemberPath:ri:r0', [2, null]]);
    return ScatterTriangulationSeries;
})();
