/*
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 * as tslib_1 from "tslib";
import { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { IEnumerable_$type, Type, runOn, delegateCombine, delegateRemove, typeCast, markType } from "igniteui-react-core/ES5/type";
import { NumericXAxis } from "./NumericXAxis";
import { NumericYAxis } from "./NumericYAxis";
import { IFastItemsSource_$type } from "igniteui-react-core/ES5/IFastItemsSource";
import { Triangulator } from "igniteui-react-core/ES5/Triangulator";
import { TriangulationStatusEventArgs } from "igniteui-react-core/ES5/TriangulationStatusEventArgs";
import { FastItemsSource } from "igniteui-react-core/ES5/FastItemsSource";
import { SeriesViewer } from "./SeriesViewer";
import { Axis } from "./Axis";
import { AxisRange } from "./AxisRange";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
var ScatterTriangulationSeries = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterTriangulationSeries, _super);
    function ScatterTriangulationSeries() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.ly = null;
        _this.lz = null;
        _this.l7 = false;
        _this.lu = null;
        _this.triangulationStatusChanged = null;
        _this.ma = null;
        _this.lv = null;
        _this.lw = null;
        _this.lx = null;
        return _this;
    }
    ScatterTriangulationSeries.prototype.hm = function () {
        _super.prototype.hm.call(this);
        this.lr = null;
        this.ls = null;
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l4", {
        get: function () {
            return this.ly;
        },
        set: function (a) {
            var b = this.l4 != a;
            if (b) {
                var c = this.l4;
                this.ly = a;
                this.raisePropertyChanged("XColumn", c, this.l4);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l5", {
        get: function () {
            return this.lz;
        },
        set: function (a) {
            var b = this.l5 != a;
            if (b) {
                var c = this.l5;
                this.lz = a;
                this.raisePropertyChanged("YColumn", c, this.l5);
            }
        },
        enumerable: true,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.i5 = function (a) {
        var b = this.bz != null && this.l6 == null && this.ma == null && this.l4 != null && this.l5 != null && this.l4.count >= 3 && this.l5.count >= 3 && !this.l7;
        if (b) {
            this.mx();
            this.l7 = true;
        }
    };
    ScatterTriangulationSeries.prototype.mx = function () {
        this.lu = new Triangulator(this.bz.count, this.l4, this.l5);
        var a = this.lu;
        a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.my));
        this.lu.y();
    };
    ScatterTriangulationSeries.prototype.mv = function () {
        if (this.lu == null) {
            return;
        }
        this.lu.r();
        var a = this.lu;
        a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.my));
        this.lu = null;
    };
    ScatterTriangulationSeries.prototype.my = function (a, b) {
        var _this = this;
        if (this.triangulationStatusChanged != null) {
            this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
        }
        if (b.currentStatus >= 100) {
            if (this.lu == null) {
                return;
            }
            var c = this.lu;
            c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.my));
            this.ma = this.lu.n();
            this.lu = null;
            var d = ((function () {
                var $ret = new FastItemsSource();
                $ret.e = _this.ma;
                return $ret;
            })());
            this.l1 = this.l0(d, "v1");
            this.l2 = this.l0(d, "v2");
            this.l3 = this.l0(d, "v3");
            this.i4(false);
        }
    };
    ScatterTriangulationSeries.prototype.l0 = function (a, b) {
        if (b == null) {
            return a.registerColumnInt(null, null, false);
        }
        var c = null;
        var d = SeriesViewer.bb(b, this.coercionMethods);
        c = d.a;
        return a.registerColumnInt(b, c, this.expectFunctions);
    };
    ScatterTriangulationSeries.prototype.ir = function (a, b, c, d) {
        var _this = this;
        _super.prototype.ir.call(this, a, b, c, d);
        switch (b) {
            case "FastItemsSource":
                var e = typeCast(IFastItemsSource_$type, c);
                if (e != null) {
                    e.deregisterColumn(this.l4);
                    e.deregisterColumn(this.l5);
                    this.l4 = null;
                    this.l5 = null;
                }
                this.mw();
                var f = typeCast(IFastItemsSource_$type, d);
                if (f != null) {
                    this.l4 = this.bw(this.mp);
                    this.l5 = this.bw(this.mt);
                }
                this.i4(false);
                break;
            case ScatterTriangulationSeries.$$p[6]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.l4);
                    this.l4 = this.bw(this.mp);
                }
                this.mw();
                this.i4(false);
                this.ib();
                break;
            case ScatterTriangulationSeries.$$p[8]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.l5);
                    this.l5 = this.bw(this.mt);
                }
                this.mw();
                this.i4(false);
                this.ib();
                break;
            case ScatterTriangulationSeries.$$p[5]:
                if (c != null) {
                    (typeCast(Axis.$, c)).bv(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).ch(this);
                }
                if ((this.lr != null && !this.lr.ck()) || (d == null && c != null)) {
                    this.i4(false);
                }
                this.ib();
                break;
            case ScatterTriangulationSeries.$$p[7]:
                if (c != null) {
                    (typeCast(Axis.$, c)).bv(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).ch(this);
                }
                if ((this.ls != null && !this.ls.ck()) || (d == null && c != null)) {
                    this.i4(false);
                }
                this.ib();
                break;
            case ScatterTriangulationSeries.$$p[1]:
                if (this.trianglesSource != null) {
                    this.mv();
                    this.l6 = ((function () {
                        var $ret = new FastItemsSource();
                        $ret.e = _this.trianglesSource;
                        return $ret;
                    })());
                }
                else {
                    this.l6 = null;
                }
                break;
            case ScatterTriangulationSeries.$$p[0]:
                var g = typeCast(IFastItemsSource_$type, c);
                if (g != null) {
                    g.deregisterColumn(this.l1);
                    g.deregisterColumn(this.l2);
                    g.deregisterColumn(this.l3);
                    this.l1 = null;
                    this.l2 = null;
                    this.l3 = null;
                }
                var h = typeCast(IFastItemsSource_$type, d);
                if (h != null) {
                    this.l1 = this.l0(h, this.mh);
                    this.l2 = this.l0(h, this.mj);
                    this.l3 = this.l0(h, this.ml);
                }
                this.i4(false);
                this.ib();
                break;
            case ScatterTriangulationSeries.$$p[2]:
                if (this.l6 != null) {
                    this.l6.deregisterColumn(this.l1);
                    this.l1 = this.l0(this.l6, this.mh);
                }
                this.i4(false);
                this.ib();
                break;
            case ScatterTriangulationSeries.$$p[3]:
                if (this.l6 != null) {
                    this.l6.deregisterColumn(this.l2);
                    this.l2 = this.l0(this.l6, this.mj);
                }
                this.i4(false);
                this.ib();
                break;
            case ScatterTriangulationSeries.$$p[4]:
                if (this.l6 != null) {
                    this.l6.deregisterColumn(this.l3);
                    this.l3 = this.l0(this.l6, this.ml);
                }
                this.i4(false);
                this.ib();
                break;
            case "XColumn":
                if (this.lr != null) {
                    this.lr.ck();
                }
                break;
            case "YColumn":
                if (this.ls != null) {
                    this.ls.ck();
                }
                break;
        }
    };
    ScatterTriangulationSeries.prototype.l9 = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.l8 = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.du = function (a, b, c) {
        return _super.prototype.du.call(this, a, b, c) && this.bz != null && this.lr != null && this.ls != null && this.lr.bf != null && this.ls.bf != null && a.width > 0 && a.height > 0 && this.l1 != null && this.l1.count > 0 && this.l2 != null && this.l2.count > 0 && this.l3 != null && this.l3.count > 0 && this.l4 != null && this.l4.count > 0 && this.l5 != null && this.l5.count > 0;
    };
    ScatterTriangulationSeries.prototype.mw = function () {
        if (this.trianglesSource == null) {
            this.ma = null;
            this.l1 = null;
            this.l2 = null;
            this.l3 = null;
            this.l7 = false;
        }
    };
    ScatterTriangulationSeries.prototype.h3 = function () {
        _super.prototype.h3.call(this);
        if (this.lr != null) {
            this.lr.gz();
        }
        if (this.ls != null) {
            this.ls.gz();
        }
    };
    ScatterTriangulationSeries.prototype.hr = function (a, b, c, d) {
        _super.prototype.hr.call(this, a, b, c, d);
        this.mw();
        this.i4(false);
    };
    ScatterTriangulationSeries.prototype.an = function (a) {
        if (a != null && a == this.lr && this.l4 != null) {
            return new AxisRange(this.l4.minimum, this.l4.maximum);
        }
        if (a != null && a == this.ls && this.l5 != null) {
            return new AxisRange(this.l5.minimum, this.l5.maximum);
        }
        return null;
    };
    ScatterTriangulationSeries.prototype.jk = function (a, b) {
        this.i4(false);
    };
    ScatterTriangulationSeries.prototype.jj = function (a, b) {
        this.i4(false);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l1", {
        get: function () {
            return this.lv;
        },
        set: function (a) {
            var b = this.l1 != a;
            if (b) {
                var c = this.l1;
                this.lv = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.l1);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l2", {
        get: function () {
            return this.lw;
        },
        set: function (a) {
            var b = this.l2 != a;
            if (b) {
                var c = this.l2;
                this.lw = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.l2);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l3", {
        get: function () {
            return this.lx;
        },
        set: function (a) {
            var b = this.l3 != a;
            if (b) {
                var c = this.l3;
                this.lx = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.l3);
            }
        },
        enumerable: true,
        configurable: true
    });
    ScatterTriangulationSeries.$t = markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    return ScatterTriangulationSeries;
}(Series));
export { ScatterTriangulationSeries };
Type.dep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:l6:mz', [IFastItemsSource_$type, null], 'TrianglesSource::m0', [IEnumerable_$type, null], 'TriangleVertexMemberPath1:mh:m1', [2, null], 'TriangleVertexMemberPath2:mj:m2', [2, null], 'TriangleVertexMemberPath3:ml:m3', [2, null], 'XAxis:lr:m4', [NumericXAxis.$, null], 'XMemberPath:mp:m5', [2, null], 'YAxis:ls:m6', [NumericYAxis.$, null], 'YMemberPath:mt:m7', [2, null]]);
