/*
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.xf = null;
            this.xg = null;
            this.xo = false;
            this.xb = null;
            this.triangulationStatusChanged = null;
            this.xr = null;
            this.xc = null;
            this.xd = null;
            this.xe = null;
        }
        o8() {
            super.o8();
            this.w8 = null;
            this.w9 = null;
        }
        ku(a, b) {
            let c = this.ni(b);
            if (c == ScatterTriangulationSeries.$$p[8]) {
                return this.kv(a, b, this.ya);
            }
            if (c == ScatterTriangulationSeries.$$p[12]) {
                return this.kv(a, b, this.yi);
            }
            return super.ku(a, b);
        }
        mi(a) {
            let b = this.ni(a);
            if (b == ScatterTriangulationSeries.$$p[8]) {
                return this.ya;
            }
            if (b == ScatterTriangulationSeries.$$p[12]) {
                return this.yi;
            }
            return super.mi(a);
        }
        get xl() {
            return this.xf;
        }
        set xl(a) {
            let b = this.xl != a;
            if (b) {
                let c = this.xl;
                this.xf = a;
                this.raisePropertyChanged("XColumn", c, this.xl);
            }
        }
        get xm() {
            return this.xg;
        }
        set xm(a) {
            let b = this.xm != a;
            if (b) {
                let c = this.xm;
                this.xg = a;
                this.raisePropertyChanged("YColumn", c, this.xm);
            }
        }
        rz(a) {
            let b = this.dp != null && this.xn == null && this.xr == null && this.xl != null && this.xm != null && this.xl.count >= 3 && this.xm.count >= 3 && !this.xo;
            if (b) {
                this.ym();
                this.xo = true;
            }
        }
        ym() {
            this.xb = new Triangulator(this.dp.count, this.xl, this.xm);
            let a = this.xb;
            a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.yn));
            this.xb.y();
        }
        yk() {
            if (this.xb == null) {
                return;
            }
            this.xb.r();
            let a = this.xb;
            a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.yn));
            this.xb = null;
        }
        yn(a, b) {
            if (this.triangulationStatusChanged != null) {
                this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
            }
            if (b.currentStatus >= 100) {
                if (this.xb == null) {
                    return;
                }
                let c = this.xb;
                c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.yn));
                this.xr = this.xb.n();
                this.xb = null;
                let d = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.xr;
                    return $ret;
                })());
                this.xi = this.xh(d, "v1");
                this.xj = this.xh(d, "v2");
                this.xk = this.xh(d, "v3");
                this.ry(false);
            }
        }
        xh(a, b) {
            if (b == null) {
                return a.registerColumnInt(null, null, false);
            }
            let c = null;
            let d = SeriesViewer.c7(b, this.coercionMethods);
            c = d.a;
            return a.registerColumnInt(b, c, this.expectFunctions);
        }
        rg(a, b, c, d) {
            super.rg(a, b, c, d);
            switch (b) {
                case ScatterTriangulationSeries.$$p[6]:
                case ScatterTriangulationSeries.$$p[10]:
                case ScatterTriangulationSeries.$$p[7]:
                case ScatterTriangulationSeries.$$p[11]:
                    this.ql();
                    break;
                case "FastItemsSource":
                    let e = typeCast(IFastItemsSource_$type, c);
                    if (e != null) {
                        e.deregisterColumn(this.xl);
                        e.deregisterColumn(this.xm);
                        this.xl = null;
                        this.xm = null;
                    }
                    this.yl();
                    let f = typeCast(IFastItemsSource_$type, d);
                    if (f != null) {
                        this.xl = this.dl(this.ya);
                        this.xm = this.dl(this.yi);
                    }
                    this.ry(this.gh && c != null);
                    break;
                case ScatterTriangulationSeries.$$p[8]:
                    if (this.dp != null) {
                        this.dp.deregisterColumn(this.xl);
                        this.xl = this.dl(this.ya);
                    }
                    this.yl();
                    this.ry(false);
                    this.qr();
                    break;
                case ScatterTriangulationSeries.$$p[12]:
                    if (this.dp != null) {
                        this.dp.deregisterColumn(this.xm);
                        this.xm = this.dl(this.yi);
                    }
                    this.yl();
                    this.ry(false);
                    this.qr();
                    break;
                case ScatterTriangulationSeries.$$p[5]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).cq(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).du(this);
                    }
                    if ((this.w8 != null && !this.w8.d2()) || (d == null && c != null)) {
                        this.ry(false);
                    }
                    this.qr();
                    break;
                case ScatterTriangulationSeries.$$p[9]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).cq(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).du(this);
                    }
                    if ((this.w9 != null && !this.w9.d2()) || (d == null && c != null)) {
                        this.ry(false);
                    }
                    this.qr();
                    break;
                case ScatterTriangulationSeries.$$p[4]:
                    if (this.trianglesSource != null) {
                        this.yk();
                        this.xn = ((() => {
                            let $ret = new FastItemsSource();
                            $ret.e = this.trianglesSource;
                            return $ret;
                        })());
                    }
                    else {
                        this.xn = null;
                    }
                    break;
                case ScatterTriangulationSeries.$$p[0]:
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.xi);
                        g.deregisterColumn(this.xj);
                        g.deregisterColumn(this.xk);
                        this.xi = null;
                        this.xj = null;
                        this.xk = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.xi = this.xh(h, this.xy);
                        this.xj = this.xh(h, this.x0);
                        this.xk = this.xh(h, this.x2);
                    }
                    this.ry(false);
                    this.qr();
                    break;
                case ScatterTriangulationSeries.$$p[1]:
                    if (this.xn != null) {
                        this.xn.deregisterColumn(this.xi);
                        this.xi = this.xh(this.xn, this.xy);
                    }
                    this.ry(false);
                    this.qr();
                    break;
                case ScatterTriangulationSeries.$$p[2]:
                    if (this.xn != null) {
                        this.xn.deregisterColumn(this.xj);
                        this.xj = this.xh(this.xn, this.x0);
                    }
                    this.ry(false);
                    this.qr();
                    break;
                case ScatterTriangulationSeries.$$p[3]:
                    if (this.xn != null) {
                        this.xn.deregisterColumn(this.xk);
                        this.xk = this.xh(this.xn, this.x2);
                    }
                    this.ry(false);
                    this.qr();
                    break;
                case "XColumn":
                    if (this.w8 != null) {
                        this.w8.d2();
                    }
                    break;
                case "YColumn":
                    if (this.w9 != null) {
                        this.w9.d2();
                    }
                    break;
            }
        }
        xq(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        xp(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        hf(a, b, c) {
            return super.hf(a, b, c) && this.dp != null && this.w8 != null && this.w9 != null && this.w8.b0 != null && this.w9.b0 != null && a.width > 0 && a.height > 0 && this.xi != null && this.xi.count > 0 && this.xj != null && this.xj.count > 0 && this.xk != null && this.xk.count > 0 && this.xl != null && this.xl.count > 0 && this.xm != null && this.xm.count > 0;
        }
        yl() {
            if (this.trianglesSource == null) {
                this.xr = null;
                this.xi = null;
                this.xj = null;
                this.xk = null;
                this.xo = false;
            }
        }
        qh() {
            super.qh();
            if (this.w8 != null) {
                this.w8.k2();
            }
            if (this.w9 != null) {
                this.w9.k2();
            }
        }
        ph(a, b, c, d) {
            super.ph(a, b, c, d);
            this.yl();
            this.ry(false);
        }
        ay(a) {
            if (a != null && a == this.w8 && this.xl != null) {
                return new AxisRange(this.xl.minimum, this.xl.maximum);
            }
            if (a != null && a == this.w9 && this.xm != null) {
                return new AxisRange(this.xm.minimum, this.xm.maximum);
            }
            return null;
        }
        sz(a, b) {
            this.ry(false);
        }
        sy(a, b) {
            this.ry(false);
        }
        get xi() {
            return this.xc;
        }
        set xi(a) {
            let b = this.xi != a;
            if (b) {
                let c = this.xi;
                this.xc = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.xi);
            }
        }
        get xj() {
            return this.xd;
        }
        set xj(a) {
            let b = this.xj != a;
            if (b) {
                let c = this.xj;
                this.xd = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.xj);
            }
        }
        get xk() {
            return this.xe;
        }
        set xk(a) {
            let b = this.xk != a;
            if (b) {
                let c = this.xk;
                this.xe = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.xk);
            }
        }
        get_fy() {
            return true;
        }
        get_fm() {
            return true;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.kr(c);
            let e = d == null ? NaN : this.iz(d, "XMemberPath");
            let f = d == null ? NaN : this.iz(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.q = "X";
            g.r = this.ya != null ? this.ya : "X";
            g.s = this.x6 != null ? this.x6 : "X:";
            g.t = this.x8 != null ? this.x8 : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.q = "Y";
            h.r = this.yi != null ? this.yi : "Y";
            h.s = this.ye != null ? this.ye : "Y:";
            h.t = this.yg != null ? this.yg : "";
            let i = new DataLegendSeriesContext();
            i.e = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.h = this.mh();
            return i;
        }
    }
    ScatterTriangulationSeries.$t = markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:xn:yo', [IFastItemsSource_$type, null], 'TriangleVertexMemberPath1:xy:yq', [2, null], 'TriangleVertexMemberPath2:x0:yr', [2, null], 'TriangleVertexMemberPath3:x2:ys', [2, null], 'TrianglesSource::yp', [IEnumerable_$type, null], 'XAxis:w8:yt', [NumericXAxis.$, null], 'XMemberAsLegendLabel:x6:yu', [2, null], 'XMemberAsLegendUnit:x8:yv', [2, null], 'XMemberPath:ya:yw', [2, null], 'YAxis:w9:yx', [NumericYAxis.$, null], 'YMemberAsLegendLabel:ye:yy', [2, null], 'YMemberAsLegendUnit:yg:yz', [2, null], 'YMemberPath:yi:y0', [2, null]]);
    return ScatterTriangulationSeries;
})();
