/*
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-react-core";
import { IEnumerable_$type, runOn, delegateCombine, delegateRemove, typeCast, Point_$type, markType, markDep } from "igniteui-react-core";
import { NumericXAxis } from "./NumericXAxis";
import { NumericYAxis } from "./NumericYAxis";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { Triangulator } from "igniteui-react-core";
import { TriangulationStatusEventArgs } from "igniteui-react-core";
import { FastItemsSource } from "igniteui-react-core";
import { SeriesViewer } from "./SeriesViewer";
import { Axis } from "./Axis";
import { AxisRange } from "./AxisRange";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
/**
 * @hidden
 */
export let ScatterTriangulationSeries = /*@__PURE__*/ (() => {
    class ScatterTriangulationSeries extends Series {
        constructor() {
            super(...arguments);
            this.ww = null;
            this.wx = null;
            this.w5 = false;
            this.ws = null;
            this.triangulationStatusChanged = null;
            this.w8 = null;
            this.wt = null;
            this.wu = null;
            this.wv = null;
        }
        oz() {
            super.oz();
            this.wp = null;
            this.wq = null;
        }
        ko(a, b) {
            let c = this.na(b);
            if (c == ScatterTriangulationSeries.$$p[8]) {
                return this.kp(a, b, this.xr);
            }
            if (c == ScatterTriangulationSeries.$$p[12]) {
                return this.kp(a, b, this.xz);
            }
            return super.ko(a, b);
        }
        ma(a) {
            let b = this.na(a);
            if (b == ScatterTriangulationSeries.$$p[8]) {
                return this.xr;
            }
            if (b == ScatterTriangulationSeries.$$p[12]) {
                return this.xz;
            }
            return super.ma(a);
        }
        get w2() {
            return this.ww;
        }
        set w2(a) {
            let b = this.w2 != a;
            if (b) {
                let c = this.w2;
                this.ww = a;
                this.raisePropertyChanged("XColumn", c, this.w2);
            }
        }
        get w3() {
            return this.wx;
        }
        set w3(a) {
            let b = this.w3 != a;
            if (b) {
                let c = this.w3;
                this.wx = a;
                this.raisePropertyChanged("YColumn", c, this.w3);
            }
        }
        rn(a) {
            let b = this.dl != null && this.w4 == null && this.w8 == null && this.w2 != null && this.w3 != null && this.w2.count >= 3 && this.w3.count >= 3 && !this.w5;
            if (b) {
                this.x3();
                this.w5 = true;
            }
        }
        x3() {
            this.ws = new Triangulator(this.dl.count, this.w2, this.w3);
            let a = this.ws;
            a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.x4));
            this.ws.y();
        }
        x1() {
            if (this.ws == null) {
                return;
            }
            this.ws.r();
            let a = this.ws;
            a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.x4));
            this.ws = null;
        }
        x4(a, b) {
            if (this.triangulationStatusChanged != null) {
                this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
            }
            if (b.currentStatus >= 100) {
                if (this.ws == null) {
                    return;
                }
                let c = this.ws;
                c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.x4));
                this.w8 = this.ws.n();
                this.ws = null;
                let d = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.w8;
                    return $ret;
                })());
                this.wz = this.wy(d, "v1");
                this.w0 = this.wy(d, "v2");
                this.w1 = this.wy(d, "v3");
                this.rm(false);
            }
        }
        wy(a, b) {
            if (b == null) {
                return a.registerColumnInt(null, null, false);
            }
            let c = null;
            let d = SeriesViewer.cu(b, this.coercionMethods);
            c = d.a;
            return a.registerColumnInt(b, c, this.expectFunctions);
        }
        q4(a, b, c, d) {
            super.q4(a, b, c, d);
            switch (b) {
                case ScatterTriangulationSeries.$$p[6]:
                case ScatterTriangulationSeries.$$p[10]:
                case ScatterTriangulationSeries.$$p[7]:
                case ScatterTriangulationSeries.$$p[11]:
                    this.qa();
                    break;
                case "FastItemsSource":
                    let e = typeCast(IFastItemsSource_$type, c);
                    if (e != null) {
                        e.deregisterColumn(this.w2);
                        e.deregisterColumn(this.w3);
                        this.w2 = null;
                        this.w3 = null;
                    }
                    this.x2();
                    let f = typeCast(IFastItemsSource_$type, d);
                    if (f != null) {
                        this.w2 = this.di(this.xr);
                        this.w3 = this.di(this.xz);
                    }
                    this.rm(this.ge && c != null);
                    break;
                case ScatterTriangulationSeries.$$p[8]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.w2);
                        this.w2 = this.di(this.xr);
                    }
                    this.x2();
                    this.rm(false);
                    this.qg();
                    break;
                case ScatterTriangulationSeries.$$p[12]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.w3);
                        this.w3 = this.di(this.xz);
                    }
                    this.x2();
                    this.rm(false);
                    this.qg();
                    break;
                case ScatterTriangulationSeries.$$p[5]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).b0(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).ct(this);
                    }
                    if ((this.wp != null && !this.wp.c1()) || (d == null && c != null)) {
                        this.rm(false);
                    }
                    this.qg();
                    break;
                case ScatterTriangulationSeries.$$p[9]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).b0(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).ct(this);
                    }
                    if ((this.wq != null && !this.wq.c1()) || (d == null && c != null)) {
                        this.rm(false);
                    }
                    this.qg();
                    break;
                case ScatterTriangulationSeries.$$p[4]:
                    if (this.trianglesSource != null) {
                        this.x1();
                        this.w4 = ((() => {
                            let $ret = new FastItemsSource();
                            $ret.e = this.trianglesSource;
                            return $ret;
                        })());
                    }
                    else {
                        this.w4 = null;
                    }
                    break;
                case ScatterTriangulationSeries.$$p[0]:
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.wz);
                        g.deregisterColumn(this.w0);
                        g.deregisterColumn(this.w1);
                        this.wz = null;
                        this.w0 = null;
                        this.w1 = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.wz = this.wy(h, this.xf);
                        this.w0 = this.wy(h, this.xh);
                        this.w1 = this.wy(h, this.xj);
                    }
                    this.rm(false);
                    this.qg();
                    break;
                case ScatterTriangulationSeries.$$p[1]:
                    if (this.w4 != null) {
                        this.w4.deregisterColumn(this.wz);
                        this.wz = this.wy(this.w4, this.xf);
                    }
                    this.rm(false);
                    this.qg();
                    break;
                case ScatterTriangulationSeries.$$p[2]:
                    if (this.w4 != null) {
                        this.w4.deregisterColumn(this.w0);
                        this.w0 = this.wy(this.w4, this.xh);
                    }
                    this.rm(false);
                    this.qg();
                    break;
                case ScatterTriangulationSeries.$$p[3]:
                    if (this.w4 != null) {
                        this.w4.deregisterColumn(this.w1);
                        this.w1 = this.wy(this.w4, this.xj);
                    }
                    this.rm(false);
                    this.qg();
                    break;
                case "XColumn":
                    if (this.wp != null) {
                        this.wp.c1();
                    }
                    break;
                case "YColumn":
                    if (this.wq != null) {
                        this.wq.c1();
                    }
                    break;
            }
        }
        w7(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        w6(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        hc(a, b, c) {
            return super.hc(a, b, c) && this.dl != null && this.wp != null && this.wq != null && this.wp.bi != null && this.wq.bi != null && a.width > 0 && a.height > 0 && this.wz != null && this.wz.count > 0 && this.w0 != null && this.w0.count > 0 && this.w1 != null && this.w1.count > 0 && this.w2 != null && this.w2.count > 0 && this.w3 != null && this.w3.count > 0;
        }
        x2() {
            if (this.trianglesSource == null) {
                this.w8 = null;
                this.wz = null;
                this.w0 = null;
                this.w1 = null;
                this.w5 = false;
            }
        }
        p5() {
            super.p5();
            if (this.wp != null) {
                this.wp.h8();
            }
            if (this.wq != null) {
                this.wq.h8();
            }
        }
        o8(a, b, c, d) {
            super.o8(a, b, c, d);
            this.x2();
            this.rm(false);
        }
        ax(a) {
            if (a != null && a == this.wp && this.w2 != null) {
                return new AxisRange(this.w2.minimum, this.w2.maximum);
            }
            if (a != null && a == this.wq && this.w3 != null) {
                return new AxisRange(this.w3.minimum, this.w3.maximum);
            }
            return null;
        }
        sk(a, b) {
            this.rm(false);
        }
        sj(a, b) {
            this.rm(false);
        }
        get wz() {
            return this.wt;
        }
        set wz(a) {
            let b = this.wz != a;
            if (b) {
                let c = this.wz;
                this.wt = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.wz);
            }
        }
        get w0() {
            return this.wu;
        }
        set w0(a) {
            let b = this.w0 != a;
            if (b) {
                let c = this.w0;
                this.wu = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.w0);
            }
        }
        get w1() {
            return this.wv;
        }
        set w1(a) {
            let b = this.w1 != a;
            if (b) {
                let c = this.w1;
                this.wv = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.w1);
            }
        }
        get_fv() {
            return true;
        }
        get_fj() {
            return true;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.kl(c);
            let e = d == null ? NaN : this.iv(d, "XMemberPath");
            let f = d == null ? NaN : this.iv(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.q = "X";
            g.r = this.xr != null ? this.xr : "X";
            g.s = this.xn != null ? this.xn : "X:";
            g.t = this.xp != null ? this.xp : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.q = "Y";
            h.r = this.xz != null ? this.xz : "Y";
            h.s = this.xv != null ? this.xv : "Y:";
            h.t = this.xx != null ? this.xx : "";
            let i = new DataLegendSeriesContext();
            i.e = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.h = this.l9();
            return i;
        }
    }
    ScatterTriangulationSeries.$t = /*@__PURE__*/ markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:w4:x5', [IFastItemsSource_$type, null], 'TriangleVertexMemberPath1:xf:x7', [2, null], 'TriangleVertexMemberPath2:xh:x8', [2, null], 'TriangleVertexMemberPath3:xj:x9', [2, null], 'TrianglesSource::x6', [IEnumerable_$type, null], 'XAxis:wp:ya', [NumericXAxis.$, null], 'XMemberAsLegendLabel:xn:yb', [2, null], 'XMemberAsLegendUnit:xp:yc', [2, null], 'XMemberPath:xr:yd', [2, null], 'YAxis:wq:ye', [NumericYAxis.$, null], 'YMemberAsLegendLabel:xv:yf', [2, null], 'YMemberAsLegendUnit:xx:yg', [2, null], 'YMemberPath:xz:yh', [2, null]]);
    return ScatterTriangulationSeries;
})();
