/*
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.ua = null;
            this.ub = null;
            this.uj = false;
            this.t6 = null;
            this.triangulationStatusChanged = null;
            this.um = null;
            this.t7 = null;
            this.t8 = null;
            this.t9 = null;
        }
        nh() {
            super.nh();
            this.t3 = null;
            this.t4 = null;
        }
        jv(a, b) {
            let c = this.lw(b);
            if (c == ScatterTriangulationSeries.$$p[8]) {
                return this.jw(a, b, this.u5);
            }
            if (c == ScatterTriangulationSeries.$$p[12]) {
                return this.jw(a, b, this.vd);
            }
            return super.jv(a, b);
        }
        get ug() {
            return this.ua;
        }
        set ug(a) {
            let b = this.ug != a;
            if (b) {
                let c = this.ug;
                this.ua = a;
                this.raisePropertyChanged("XColumn", c, this.ug);
            }
        }
        get uh() {
            return this.ub;
        }
        set uh(a) {
            let b = this.uh != a;
            if (b) {
                let c = this.uh;
                this.ub = a;
                this.raisePropertyChanged("YColumn", c, this.uh);
            }
        }
        ps(a) {
            let b = this.c7 != null && this.ui == null && this.um == null && this.ug != null && this.uh != null && this.ug.count >= 3 && this.uh.count >= 3 && !this.uj;
            if (b) {
                this.vh();
                this.uj = true;
            }
        }
        vh() {
            this.t6 = new Triangulator(this.c7.count, this.ug, this.uh);
            let a = this.t6;
            a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.vi));
            this.t6.y();
        }
        vf() {
            if (this.t6 == null) {
                return;
            }
            this.t6.r();
            let a = this.t6;
            a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.vi));
            this.t6 = null;
        }
        vi(a, b) {
            if (this.triangulationStatusChanged != null) {
                this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
            }
            if (b.currentStatus >= 100) {
                if (this.t6 == null) {
                    return;
                }
                let c = this.t6;
                c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.vi));
                this.um = this.t6.n();
                this.t6 = null;
                let d = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.um;
                    return $ret;
                })());
                this.ud = this.uc(d, "v1");
                this.ue = this.uc(d, "v2");
                this.uf = this.uc(d, "v3");
                this.pr(false);
            }
        }
        uc(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);
        }
        pa(a, b, c, d) {
            super.pa(a, b, c, d);
            switch (b) {
                case "FastItemsSource":
                    let e = typeCast(IFastItemsSource_$type, c);
                    if (e != null) {
                        e.deregisterColumn(this.ug);
                        e.deregisterColumn(this.uh);
                        this.ug = null;
                        this.uh = null;
                    }
                    this.vg();
                    let f = typeCast(IFastItemsSource_$type, d);
                    if (f != null) {
                        this.ug = this.c4(this.u5);
                        this.uh = this.c4(this.vd);
                    }
                    this.pr(this.fr && c != null);
                    break;
                case ScatterTriangulationSeries.$$p[8]:
                    if (this.c7 != null) {
                        this.c7.deregisterColumn(this.ug);
                        this.ug = this.c4(this.u5);
                    }
                    this.vg();
                    this.pr(false);
                    this.om();
                    break;
                case ScatterTriangulationSeries.$$p[12]:
                    if (this.c7 != null) {
                        this.c7.deregisterColumn(this.uh);
                        this.uh = this.c4(this.vd);
                    }
                    this.vg();
                    this.pr(false);
                    this.om();
                    break;
                case ScatterTriangulationSeries.$$p[5]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).b0(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).ct(this);
                    }
                    if ((this.t3 != null && !this.t3.c1()) || (d == null && c != null)) {
                        this.pr(false);
                    }
                    this.om();
                    break;
                case ScatterTriangulationSeries.$$p[9]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).b0(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).ct(this);
                    }
                    if ((this.t4 != null && !this.t4.c1()) || (d == null && c != null)) {
                        this.pr(false);
                    }
                    this.om();
                    break;
                case ScatterTriangulationSeries.$$p[4]:
                    if (this.trianglesSource != null) {
                        this.vf();
                        this.ui = ((() => {
                            let $ret = new FastItemsSource();
                            $ret.e = this.trianglesSource;
                            return $ret;
                        })());
                    }
                    else {
                        this.ui = null;
                    }
                    break;
                case ScatterTriangulationSeries.$$p[0]:
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.ud);
                        g.deregisterColumn(this.ue);
                        g.deregisterColumn(this.uf);
                        this.ud = null;
                        this.ue = null;
                        this.uf = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.ud = this.uc(h, this.ut);
                        this.ue = this.uc(h, this.uv);
                        this.uf = this.uc(h, this.ux);
                    }
                    this.pr(false);
                    this.om();
                    break;
                case ScatterTriangulationSeries.$$p[1]:
                    if (this.ui != null) {
                        this.ui.deregisterColumn(this.ud);
                        this.ud = this.uc(this.ui, this.ut);
                    }
                    this.pr(false);
                    this.om();
                    break;
                case ScatterTriangulationSeries.$$p[2]:
                    if (this.ui != null) {
                        this.ui.deregisterColumn(this.ue);
                        this.ue = this.uc(this.ui, this.uv);
                    }
                    this.pr(false);
                    this.om();
                    break;
                case ScatterTriangulationSeries.$$p[3]:
                    if (this.ui != null) {
                        this.ui.deregisterColumn(this.uf);
                        this.uf = this.uc(this.ui, this.ux);
                    }
                    this.pr(false);
                    this.om();
                    break;
                case "XColumn":
                    if (this.t3 != null) {
                        this.t3.c1();
                    }
                    break;
                case "YColumn":
                    if (this.t4 != null) {
                        this.t4.c1();
                    }
                    break;
            }
        }
        ul(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        uk(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        gm(a, b, c) {
            return super.gm(a, b, c) && this.c7 != null && this.t3 != null && this.t4 != null && this.t3.bi != null && this.t4.bi != null && a.width > 0 && a.height > 0 && this.ud != null && this.ud.count > 0 && this.ue != null && this.ue.count > 0 && this.uf != null && this.uf.count > 0 && this.ug != null && this.ug.count > 0 && this.uh != null && this.uh.count > 0;
        }
        vg() {
            if (this.trianglesSource == null) {
                this.um = null;
                this.ud = null;
                this.ue = null;
                this.uf = null;
                this.uj = false;
            }
        }
        oc() {
            super.oc();
            if (this.t3 != null) {
                this.t3.h7();
            }
            if (this.t4 != null) {
                this.t4.h7();
            }
        }
        np(a, b, c, d) {
            super.np(a, b, c, d);
            this.vg();
            this.pr(false);
        }
        aq(a) {
            if (a != null && a == this.t3 && this.ug != null) {
                return new AxisRange(this.ug.minimum, this.ug.maximum);
            }
            if (a != null && a == this.t4 && this.uh != null) {
                return new AxisRange(this.uh.minimum, this.uh.maximum);
            }
            return null;
        }
        qp(a, b) {
            this.pr(false);
        }
        qo(a, b) {
            this.pr(false);
        }
        get ud() {
            return this.t7;
        }
        set ud(a) {
            let b = this.ud != a;
            if (b) {
                let c = this.ud;
                this.t7 = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.ud);
            }
        }
        get ue() {
            return this.t8;
        }
        set ue(a) {
            let b = this.ue != a;
            if (b) {
                let c = this.ue;
                this.t8 = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.ue);
            }
        }
        get uf() {
            return this.t9;
        }
        set uf(a) {
            let b = this.uf != a;
            if (b) {
                let c = this.uf;
                this.t9 = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.uf);
            }
        }
        get_fb() {
            return true;
        }
        get_ez() {
            return true;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.js(c);
            let e = d == null ? NaN : this.h2(d, "XMemberPath");
            let f = d == null ? NaN : this.h2(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.p = "X";
            g.q = this.u5 != null ? this.u5 : "X";
            g.r = this.u1 != null ? this.u1 : "X:";
            g.s = this.u3 != null ? this.u3 : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.p = "Y";
            h.q = this.vd != null ? this.vd : "Y";
            h.r = this.u9 != null ? this.u9 : "Y:";
            h.s = this.vb != null ? this.vb : "";
            let i = new DataLegendSeriesContext();
            i.f = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.b = this.aw();
            return i;
        }
    }
    ScatterTriangulationSeries.$t = /*@__PURE__*/ markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:ui:vj', [IFastItemsSource_$type, null], 'TriangleVertexMemberPath1:ut:vl', [2, null], 'TriangleVertexMemberPath2:uv:vm', [2, null], 'TriangleVertexMemberPath3:ux:vn', [2, null], 'TrianglesSource::vk', [IEnumerable_$type, null], 'XAxis:t3:vo', [NumericXAxis.$, null], 'XMemberAsLegendLabel:u1:vp', [2, null], 'XMemberAsLegendUnit:u3:vq', [2, null], 'XMemberPath:u5:vr', [2, null], 'YAxis:t4:vs', [NumericYAxis.$, null], 'YMemberAsLegendLabel:u9:vt', [2, null], 'YMemberAsLegendUnit:vb:vu', [2, null], 'YMemberPath:vd:vv', [2, null]]);
    return ScatterTriangulationSeries;
})();
