/*
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 { __extends } from "tslib";
import { Series } from "./Series";
import { NumericXAxis } from "./NumericXAxis";
import { DependencyProperty } from "igniteui-react-core";
import { NumericYAxis } from "./NumericYAxis";
import { Color } from "igniteui-react-core";
import { ScatterFrame } from "./ScatterFrame";
import { Defaults } from "./Defaults";
import { KDTree2D } from "./KDTree2D";
import { Point_$type, typeGetValue, runOn, delegateRemove, typeCast, delegateCombine, markType, markDep, toNullable } from "igniteui-react-core";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { SeriesView } from "./SeriesView";
import { KDPointData } from "./KDPointData";
import { ScalerParams } from "./ScalerParams";
import { ProgressiveLoadStatusEventArgs } from "./ProgressiveLoadStatusEventArgs";
import { SearchArgs } from "./SearchArgs";
import { KDTreeNode2D } from "./KDTreeNode2D";
import { AxisRange } from "./AxisRange";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity, logBase, intDivide } from "igniteui-react-core";
import { boxArray$1, arrayShallowClone } from "igniteui-react-core";
import { dateNow } from "igniteui-react-core";
import { RenderingContext } from "igniteui-react-core";
import { CanvasViewRenderer } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
/**
 * @hidden
 */
var HighDensityScatterSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(HighDensityScatterSeries, _super);
    function HighDensityScatterSeries() {
        var _this = _super.call(this) || this;
        _this.ue = null;
        _this.ug = null;
        _this.vp = 0;
        _this.ui = false;
        _this.u4 = Defaults.aq.o;
        _this.u3 = Defaults.aq.n;
        _this.u2 = Defaults.aq.m;
        _this.u1 = Defaults.aq.l;
        _this.u0 = Defaults.ap.o;
        _this.uz = Defaults.ap.n;
        _this.uy = Defaults.ap.m;
        _this.ux = Defaults.ap.l;
        _this.t6 = null;
        _this.ub = null;
        _this.uc = null;
        _this.t7 = null;
        _this.t9 = null;
        _this.uk = false;
        _this.vq = 0;
        _this.vs = 0;
        _this.vm = 0;
        _this.vl = 0;
        _this.progressiveLoadStatusChanged = null;
        _this.up = null;
        _this.uv = 0;
        _this.uu = 0;
        _this.uw = 0;
        _this.vb = 0;
        _this.u9 = 0;
        _this.va = 0;
        _this.vc = 0;
        _this.ve = 0;
        _this.vg = 0;
        _this.vf = 0;
        _this.vd = 0;
        _this.ur = 0;
        _this.us = 0;
        _this.ut = 0;
        _this.uq = 0;
        _this.vo = 0;
        _this.vn = 0;
        _this.t3 = null;
        _this.vr = 0;
        _this.uj = false;
        _this._itemIndexes = null;
        _this.t4 = null;
        _this.t1 = null;
        _this.ud = null;
        _this.ab = HighDensityScatterSeries.$;
        _this.fk = false;
        return _this;
    }
    HighDensityScatterSeries.prototype.get_e1 = function () {
        return true;
    };
    HighDensityScatterSeries.prototype.ip = function () {
        if (!isNaN_(this.io)) {
            return _super.prototype.ip.call(this);
        }
        return Defaults.q;
    };
    HighDensityScatterSeries.prototype.get_e9 = function () {
        return true;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "uf", {
        get: function () {
            return this.ue;
        },
        set: function (a) {
            if (this.ue != a) {
                var b = this.uf;
                this.ue = a;
                this.raisePropertyChanged("XColumn", b, this.uf);
            }
        },
        enumerable: false,
        configurable: true
    });
    HighDensityScatterSeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.jr(c);
        var e = d == null ? NaN : this.h1(d, "XMemberPath");
        var f = d == null ? NaN : this.h1(d, "YMemberPath");
        var g = new DataLegendSeriesValueInfo();
        g.l = e;
        g.a = 13;
        g.p = "X";
        g.q = this.wb != null ? this.wb : "X";
        g.r = this.v7 != null ? this.v7 : "X:";
        g.s = this.v9 != null ? this.v9 : "";
        var h = new DataLegendSeriesValueInfo();
        h.l = f;
        h.a = 14;
        h.p = "Y";
        h.q = this.wj != null ? this.wj : "Y";
        h.r = this.wf != null ? this.wf : "Y:";
        h.s = this.wh != null ? this.wh : "";
        var i = new DataLegendSeriesContext();
        i.f = ((function () {
            var $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
            $ret.add(g);
            $ret.add(h);
            return $ret;
        })());
        i.b = this.aw();
        return i;
    };
    HighDensityScatterSeries.prototype.ju = function (a, b) {
        var c = this.lv(b);
        if (c == HighDensityScatterSeries.$$p[10]) {
            return this.jv(a, b, this.wb);
        }
        if (c == HighDensityScatterSeries.$$p[14]) {
            return this.jv(a, b, this.wj);
        }
        return _super.prototype.ju.call(this, a, b);
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "uh", {
        get: function () {
            return this.ug;
        },
        set: function (a) {
            if (this.ug != a) {
                var b = this.uh;
                this.ug = a;
                this.raisePropertyChanged("YColumn", b, this.uh);
            }
        },
        enumerable: false,
        configurable: true
    });
    HighDensityScatterSeries.prototype.wy = function () {
        if (this.t6 == null) {
            return;
        }
        this.t6.s();
        var a = this.t6;
        a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.wl));
        this.t6 = null;
    };
    HighDensityScatterSeries.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (this.cy != null) {
                    var e = this.getEffectiveViewport1(this.cj);
                    this.uj = !e.isEmpty;
                }
                break;
            case "FastItemsSource":
                this.wy();
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.uf);
                    c.deregisterColumn(this.uh);
                    this.uf = null;
                    this.uh = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.uf = this.c3(this.wb);
                    this.uh = this.c3(this.wj);
                }
                if ((this.ua != null && !this.ua.c1()) || (this.t8 != null && !this.t8.c1())) {
                    this.pp(this.fq && c != null);
                }
                this.om();
                break;
            case HighDensityScatterSeries.$$p[7]:
                var f = this.t7;
                this.t7 = this.t8;
                this.wy();
                if (f != null) {
                    f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.wo));
                }
                if (this.t7 != null) {
                    var g = this.t7;
                    g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.wo));
                }
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                if ((this.t8 != null && !this.t8.c1()) || (d == null && c != null)) {
                    this.pp(false);
                }
                break;
            case HighDensityScatterSeries.$$p[11]:
                var h = this.t9;
                this.t9 = this.ua;
                this.wy();
                if (h != null) {
                    h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.wo));
                }
                if (this.t9 != null) {
                    var i = this.t9;
                    i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.wo));
                }
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                if ((this.ua != null && !this.ua.c1()) || (d == null && c != null)) {
                    this.pp(false);
                }
                break;
            case "MouseOverEnabled":
                this.uk = this.fk;
                this.pp(false);
                break;
            case HighDensityScatterSeries.$$p[10]:
                if (this.c6 != null) {
                    this.c6.deregisterColumn(this.uf);
                    this.uf = this.c3(this.wb);
                }
                break;
            case "XColumn":
                this.wy();
                if (this.t8 != null && !this.t8.c1()) {
                    this.pp(false);
                }
                this.om();
                break;
            case HighDensityScatterSeries.$$p[14]:
                if (this.c6 != null) {
                    this.c6.deregisterColumn(this.uh);
                    this.uh = this.c3(this.wj);
                }
                break;
            case "YColumn":
                this.wy();
                if (this.ua != null && !this.ua.c1()) {
                    this.pp(false);
                }
                this.om();
                break;
            case HighDensityScatterSeries.$$p[6]:
                this.wy();
                this.pp(false);
                this.ol();
                break;
            case HighDensityScatterSeries.$$p[3]:
                this.pp(false);
                this.ol();
                break;
            case HighDensityScatterSeries.$$p[1]:
                this.pp(false);
                this.ol();
                break;
            case HighDensityScatterSeries.$$p[0]:
            case HighDensityScatterSeries.$$p[2]:
                if (!this.t5.b4(this.xh, this.xg)) {
                    return;
                }
                this.ws();
                this.pp(false);
                this.ol();
                break;
            case HighDensityScatterSeries.$$p[4]:
                this.vp = Math.max(typeGetValue(d) - 1, 0);
                this.ui = this.vp > 0;
                this.pp(false);
                this.ol();
                break;
            case HighDensityScatterSeries.$$p[5]:
                this.pp(false);
                this.ol();
                break;
        }
    };
    HighDensityScatterSeries.prototype.ws = function () {
        this.u1 = this.xh.l;
        this.u4 = this.xh.o;
        this.u3 = this.xh.n;
        this.u2 = this.xh.m;
        this.ux = this.xg.l;
        this.u0 = this.xg.o;
        this.uz = this.xg.n;
        this.uy = this.xg.m;
        this.s2 = BrushUtil.h(truncate(this.u1), truncate(this.u4), truncate(this.u3), truncate(this.u2));
        this.sw = BrushUtil.h(truncate(this.ux), truncate(this.u0), truncate(this.uz), truncate(this.uy));
    };
    HighDensityScatterSeries.prototype.um = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.ul = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.wo = function (a, b) {
        this.wy();
        this.pp(false);
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "u8", {
        get: function () {
            return this.u0 - this.u4;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HighDensityScatterSeries.prototype, "u7", {
        get: function () {
            return this.uz - this.u3;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HighDensityScatterSeries.prototype, "u6", {
        get: function () {
            return this.uy - this.u2;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HighDensityScatterSeries.prototype, "u5", {
        get: function () {
            return this.ux - this.u1;
        },
        enumerable: false,
        configurable: true
    });
    HighDensityScatterSeries.prototype.gl = function (a, b, c) {
        var d = _super.prototype.gl.call(this, a, b, c);
        if (this.ua == null || this.t8 == null || this.t8.bi == null || this.ua.bi == null || this.uh == null || this.uf == null || this.uh.count < 1 || this.uf.count < 1 || this.uh.count != this.uf.count || this.t8.lx == this.t8.lw || this.ua.lx == this.ua.lw || this.tw.isEmpty) {
            d = false;
        }
        return d;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "vw", {
        get: function () {
            return this.vq;
        },
        set: function (a) {
            var b = this.vq;
            this.vq = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.vq);
        },
        enumerable: false,
        configurable: true
    });
    HighDensityScatterSeries.prototype.pq = function (a) {
        _super.prototype.pq.call(this, a);
        this.wq(a, this.cj);
    };
    HighDensityScatterSeries.prototype.wq = function (a, b) {
        if (this.dl(b)) {
            return;
        }
        if (this.t6 == null && !this.uo) {
            var c = new List$1(KDPointData.$, 2, this.uf.count);
            var d = this.t8;
            var e = this.ua;
            var f = new Rect(0, 0, 0, 1, 1);
            var g = new Rect(0, 0, 0, 1, 1);
            var h = new ScalerParams(1, f, g, d.ch);
            var i = new ScalerParams(1, f, g, e.ch);
            var j_1;
            var k_1;
            var _loop_1 = function (l) {
                j_1 = d.ej(this_1.uf.item(l), h);
                k_1 = e.ej(this_1.uh.item(l), i);
                if (!isNaN_(j_1) && !isNaN_(k_1) && !isInfinity(j_1) && !isInfinity(k_1)) {
                    c.add(((function () {
                        var $ret = new KDPointData();
                        $ret.a = j_1;
                        $ret.b = k_1;
                        $ret.c = l;
                        return $ret;
                    })()));
                }
            };
            var this_1 = this;
            for (var l = 0; l < this.uf.count; l++) {
                _loop_1(l);
            }
            if (this.un) {
                this.vl = 1;
                this.vm = truncate(logBase(c.count, 2)) + 3;
                this.vw = truncate(((this.vl / this.vm) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.vw));
                }
                this.t6 = KDTree2D.b(c.toArray(), 1);
                var m = this.t6;
                m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.wl));
                if (!this.t6.f(this.i4)) {
                    var n = this.t6;
                    n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.wl));
                }
                this.ol();
            }
            else {
                var o = dateNow();
                this.t6 = new KDTree2D(0, c.toArray(), 1);
                var p = dateNow();
            }
        }
        if (this.un && !this.uo) {
            this.wr(b);
        }
        else {
            this.wt(b);
        }
    };
    HighDensityScatterSeries.prototype.no = function (a, b, c, d) {
        _super.prototype.no.call(this, a, b, c, d);
        this.wy();
        var e = false;
        if (this.t8 != null && !this.t8.c1()) {
            e = true;
        }
        if (this.ua != null && !this.ua.c1()) {
            e = true;
        }
        if (e) {
            this.pp(false);
        }
        this.om();
    };
    HighDensityScatterSeries.prototype.wn = function (a) {
        var b = a;
        var c = this.vo * this.vn;
        if (this.uk) {
            if (this._itemIndexes == null || this._itemIndexes.length != c) {
                this._itemIndexes = new Array(c);
                for (var d = 0; d < c; d++) {
                    this._itemIndexes[d] = 0;
                }
            }
            else {
                for (var e = 0; e < c; e++) {
                    this._itemIndexes[e] = 0;
                }
            }
        }
    };
    HighDensityScatterSeries.prototype.wt = function (a) {
        var b;
        var c;
        var d = null;
        if (a.q) {
            d = this._itemIndexes;
        }
        var e = a.getViewInfo(c, b);
        c = e.p0;
        b = e.p1;
        var f = a;
        var g = this.getEffectiveViewport1(a);
        this.ub = new ScalerParams(0, b, c, this.t7.ch, g);
        this.uc = new ScalerParams(0, b, c, this.t9.ch, g);
        this.wm(a);
        this.wn(a);
        var h = this.vo * this.vn;
        if (this.t4 == null || this.t4.length != h) {
            this.t4 = new Array(h);
            this.t1 = new Array(h);
        }
        var i = this.t4.length;
        var j = this.t4;
        var k = this.t1;
        for (var l = 0; l < i; l++) {
            j[l] = 0;
            k[l] = 0;
        }
        this.vs = truncate(Math.round(this.hj));
        this.t3 = f.b1();
        var m = this.t3.length;
        var n = this.t3;
        for (var o = 0; o < m; o++) {
            n[o] = 0;
        }
        var p = this.vj;
        var q = this.vi;
        if (isNaN_(p) || isInfinity(p)) {
            p = 0;
        }
        if (isNaN_(q) || isInfinity(q)) {
            q = 50;
        }
        this.uv = Math.min(p, q);
        this.uu = Math.max(p, q);
        if (this.uv < 0) {
            this.uv = 0;
        }
        if (this.uu < 0) {
            this.uu = 0;
        }
        this.uw = this.uu - this.uv;
        if (this.uo) {
            this.wp(a);
        }
        else {
            this.w0(a);
        }
        f.cc();
        if (a.q) {
            this._itemIndexes = d;
            this.t5.cd();
        }
    };
    HighDensityScatterSeries.prototype.wr = function (a) {
        if (this.t6 == null) {
            return;
        }
        this.wt(a);
    };
    HighDensityScatterSeries.prototype.wl = function (a, b) {
        var _this = this;
        this.t5.cb(function () {
            if (_this.vl < _this.vm - 1) {
                _this.vl++;
            }
            _this.vw = truncate(((_this.vl / _this.vm) * 100));
            if (_this.progressiveLoadStatusChanged != null) {
                _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.vw));
            }
            _this.wr(_this.cj);
            _this.ol();
            if (_this.t6 != null) {
                if (!_this.t6.f(_this.i4)) {
                    var c = _this.t6;
                    c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(_this, _this.wl));
                    _this.vw = 100;
                    if (_this.progressiveLoadStatusChanged != null) {
                        _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.vw));
                    }
                }
            }
        });
    };
    HighDensityScatterSeries.prototype.wp = function (a) {
        var b = arrayShallowClone(this.uf.asArray());
        this.t8.hn(boxArray$1(b), 0, b.length, this.ub);
        var c = arrayShallowClone(this.uh.asArray());
        this.vr = 0;
        var d = this.vp;
        var e = this.ui;
        var f = this.t4.length;
        this.ua.hn(boxArray$1(c), 0, c.length, this.uc);
        var g = 255 << 24 | truncate(this.u4) << 16 | truncate(this.u3) << 8 | truncate(this.u2);
        for (var h = 0; h < b.length; h++) {
            var i = truncate(b[h]);
            var j = truncate(c[h]);
            i = truncate(Math.floor(i));
            j = truncate(Math.floor(j));
            if (i < 0 || i >= this.vo || j < 0 || j >= this.vn) {
                continue;
            }
            if (e) {
                var k = i - d;
                var l = i + d;
                l = l > (this.vo - 1) ? (this.vo - 1) : l;
                k = k < 0 ? 0 : k;
                var m = j + d;
                var n = j - d;
                for (var o = k; o <= l; o++) {
                    for (var p = n; p <= m; p++) {
                        var q = (p * this.vo) + o;
                        if (q < 0 || q > f - 1) {
                            continue;
                        }
                        this.t4[q] = this.t4[q] + 1;
                        this.t1[q] = 1;
                        this.vr++;
                        if (this.uk) {
                            this._itemIndexes[q] = h + 1;
                        }
                    }
                }
            }
            else {
                var r = (j * this.vo) + i;
                this.t4[r] = this.t4[r] + 1;
                this.t1[r] = 1;
                this.vr++;
                if (this.uk) {
                    this._itemIndexes[r] = h + 1;
                }
            }
        }
        this.wu();
    };
    HighDensityScatterSeries.prototype.w0 = function (a) {
        var b;
        var c;
        var d = a.getViewInfo(b, c);
        b = d.p0;
        c = d.p1;
        if (this.t6 == null) {
            return;
        }
        if (this.up == null) {
            this.up = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
        }
        else {
            this.up.clear();
        }
        var e = c.left;
        var f = c.right;
        var g = c.top;
        var h = c.bottom;
        this.vf = c.top;
        this.vd = c.height;
        this.ve = c.left;
        this.vg = c.width;
        this.vb = b.top;
        this.u9 = b.height;
        this.va = b.left;
        this.vc = b.width;
        var i = this.getEffectiveViewport1(a);
        this.ur = (i.left - this.va) / this.vc;
        this.us = (i.top - this.vb) / this.u9;
        var j = (i.right - this.va) / this.vc;
        this.ut = j - this.ur;
        var k = (i.bottom - this.vb) / this.u9;
        this.uq = k - this.us;
        if (this.uj) {
            e = (e - this.ur) / this.ut;
            f = (f - this.ur) / this.ut;
            g = (g - this.us) / this.uq;
            h = (h - this.us) / this.uq;
        }
        var l = this.hj / b.width * c.width;
        var m = this.hj / b.height * c.height;
        var n = Math.min(l, m);
        var o = ((function () {
            var $ret = new SearchArgs();
            $ret.c = e;
            $ret.a = f;
            $ret.d = g;
            $ret.b = h;
            $ret.e = l;
            $ret.f = m;
            $ret.g = 0x7FFFFFFF;
            return $ret;
        })());
        this.t6.t(this.up, o, 0, 1, 0, 1);
        var p;
        this.vr = 0;
        for (var q = 0; q < this.up.count; q++) {
            p = this.up._inner[q];
            this.wv(p);
        }
        this.wu();
    };
    HighDensityScatterSeries.prototype.wv = function (a) {
        if (a.g) {
            return;
        }
        var b = a.e != null && a.e.a;
        var c = a.a == null ? 0 : a.a.length;
        var d = (a.h - c) + 1;
        if (b && d > 0) {
        }
        else {
            d = 1;
        }
        this.wx(a.b, d, b, a.e);
        if (c > 0 && !b) {
            var e = void 0;
            for (var f = 0; f < c; f++) {
                e = a.a[f];
                this.wx(e, d, false, a.e);
            }
        }
        if (a.e != null) {
            a.e.a = false;
        }
    };
    HighDensityScatterSeries.prototype.fo = function (a) {
        var b = this.cy != null ? this.cy.tn : Rect.empty;
        var c = this.cy != null ? this.cy.t2 : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.tq(this.cj);
        var f = new ScalerParams(0, d, d, this.t8.ch, e);
        var g = new ScalerParams(0, d, d, this.ua.ch, e);
        var h = !b.isEmpty && !c.isEmpty && this.c6 != null ? this.c6.indexOf(a) : -1;
        var i = this.t8 != null && this.uf != null && h < this.uf.count ? this.t8.ej(this.uf.item(h), f) : NaN;
        var j = this.ua != null && this.uh != null && h < this.uh.count ? this.ua.ej(this.uh.item(h), g) : NaN;
        if (!isNaN_(i)) {
            if (i < b.left + 0.1 * b.width) {
                i = i + 0.4 * b.width;
                b.x = i - 0.5 * b.width;
            }
            if (i > b.right - 0.1 * b.width) {
                i = i - 0.4 * b.width;
                b.x = i - 0.5 * b.width;
            }
        }
        if (!isNaN_(j)) {
            if (j < b.top + 0.1 * b.height) {
                j = j + 0.4 * b.height;
                b.y = j - 0.5 * b.height;
            }
            if (j > b.bottom - 0.1 * b.height) {
                j = j - 0.4 * b.height;
                b.y = j - 0.5 * b.height;
            }
        }
        if (this.cr != null) {
            this.cr.au(this.cy, b, true);
        }
        return h >= 0;
    };
    HighDensityScatterSeries.prototype.wx = function (a, b, c, d) {
        var e = this.vu(b);
        var f = a.c;
        var g = this.vp;
        if (c) {
            var h = d.d;
            var i = d.b;
            var j = d.e;
            var k = d.c;
            if (this.uj) {
                h = this.ur + this.ut * h;
                i = this.ur + this.ut * i;
                j = this.us + this.uq * j;
                k = this.us + this.uq * k;
            }
            var l = truncate((this.va + this.vc * (h - this.ve) / this.vg));
            var m = truncate((this.va + this.vc * (i - this.ve) / this.vg));
            var n = truncate((this.vb + this.u9 * (j - this.vf) / this.vd));
            var o = truncate((this.vb + this.u9 * (k - this.vf) / this.vd));
            l = truncate(Math.floor(l));
            m = truncate(Math.floor(m));
            n = truncate(Math.floor(n));
            o = truncate(Math.floor(o));
            if (this.ui) {
                l -= g;
                m += g;
                n -= g;
                o += g;
            }
            var p = ((m - l) + 1) * ((o - n) + 1);
            var q = b / p;
            var r = q;
            for (var s = l; s <= m; s++) {
                for (var t = n; t <= o; t++) {
                    this.ww(f, s, t, q, r);
                }
            }
        }
        else {
            var u = a.a;
            var v = a.b;
            if (this.uj) {
                u = this.ur + this.ut * u;
                v = this.us + this.uq * v;
            }
            var w = truncate((this.va + this.vc * (u - this.ve) / this.vg));
            var x = truncate((this.vb + this.u9 * (v - this.vf) / this.vd));
            w = truncate(Math.floor(w));
            x = truncate(Math.floor(x));
            if (this.ui) {
                var y = w - g;
                var z = w + g;
                var aa = x + g;
                var ab = x - g;
                var ac = ((z - y) + 1) * ((aa - ab) + 1);
                var ad = b / ac;
                var ae = ad;
                for (var af = y; af <= z; af++) {
                    for (var ag = ab; ag <= aa; ag++) {
                        this.ww(f, af, ag, ad, ae);
                    }
                }
            }
            else {
                this.ww(f, w, x, b, 1);
            }
        }
    };
    HighDensityScatterSeries.prototype.vt = function (a, b) {
        return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.u4 + a * this.u8))) << 16 | truncate(Math.floor(b * (this.u3 + a * this.u7))) << 8 | truncate(Math.floor(b * (this.u2 + a * this.u6)));
    };
    HighDensityScatterSeries.prototype.vu = function (a) {
        return 255 << 24 | truncate(Math.floor((this.u4 + a * this.u8))) << 16 | truncate(Math.floor((this.u3 + a * this.u7))) << 8 | truncate(Math.floor((this.u2 + a * this.u6)));
    };
    HighDensityScatterSeries.prototype.vh = function (a) {
        return (a >> 24 & 255) / 255;
    };
    HighDensityScatterSeries.prototype.ww = function (a, b, c, d, e) {
        if (b < 0 || b >= this.vo || c < 0 || c >= this.vn) {
            return;
        }
        var f = (c * this.vo) + b;
        this.t4[f] = this.t4[f] + d;
        this.t1[f] = this.t1[f] + e;
        if (this.uk) {
            this._itemIndexes[f] = a + 1;
        }
        this.vr += truncate(d);
    };
    HighDensityScatterSeries.prototype.wu = function () {
        var a = 0;
        var b = 0;
        var c = this.uw;
        var d = this.uv;
        var e = this.uu;
        var f = this.t4.length;
        var g = this.t4;
        var h = this.t1;
        var i = this.t3;
        var j = NaN;
        var k = NaN;
        var l = 0;
        var m = 0;
        for (var n = 0; n < f; n++) {
            a = g[n];
            if (a != 0) {
                b = h[n];
                if (a >= e) {
                    a = 1;
                }
                else if (a <= d) {
                    a = 0;
                }
                else {
                    a = (a - d) / (c);
                }
                if (b > 1) {
                    b = 1;
                }
                if (b < 0.2) {
                    b = 0.2;
                }
                if (j != a || k != b) {
                    l = this.vt(a, b);
                    j = a;
                    k = b;
                }
                i[m] = l >> 16 & 255;
                i[m + 1] = l >> 8 & 255;
                i[m + 2] = l & 255;
                i[m + 3] = l >> 24 & 255;
            }
            m += 4;
        }
    };
    HighDensityScatterSeries.prototype.wm = function (a) {
        var b = a;
        b.b9();
    };
    HighDensityScatterSeries.prototype.cg = function () {
        return new HighDensityScatterSeriesView(this);
    };
    HighDensityScatterSeries.prototype.o0 = function (a) {
        _super.prototype.o0.call(this, a);
        this.t5 = a;
    };
    HighDensityScatterSeries.prototype.aq = function (a) {
        if (a != null && a == this.t8 && this.uf != null) {
            return new AxisRange(this.uf.minimum, this.uf.maximum);
        }
        if (a != null && a == this.ua && this.uh != null) {
            return new AxisRange(this.uh.minimum, this.uh.maximum);
        }
        return null;
    };
    HighDensityScatterSeries.prototype.qm = function (a, b) {
        if (this.cy != null) {
            var c = this.getEffectiveViewport1(this.cj);
            this.uj = !c.isEmpty;
        }
        this.pp(false);
    };
    HighDensityScatterSeries.prototype.qn = function (a, b) {
        this.pp(false);
    };
    HighDensityScatterSeries.prototype.jr = function (a) {
        if (!this.uk || this._itemIndexes == null || this.cy == null || this.c6 == null || this._itemIndexes.length != (this.vo * this.vn)) {
            return null;
        }
        var b = this.cy.tn;
        var c = (a.x - b.left) / b.width;
        var d = (a.y - b.top) / b.height;
        var e = truncate(Math.round(this.tw.left + (this.tw.width * c)));
        var f = truncate(Math.round(this.tw.top + (this.tw.height * d)));
        var g = this.vx(e, f);
        if (g < 0 || g > this._itemIndexes.length - 1) {
            return null;
        }
        var h = this._itemIndexes[g] - 1;
        if (h < 0 || h > this.c6.count) {
            return null;
        }
        return this.c6.item(h);
    };
    HighDensityScatterSeries.prototype.vx = function (a, b) {
        var c = (this.vo * b) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        var d = 1;
        c = (this.vo * (b - d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.vo * (b + d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.vo * (b)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.vo * (b)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.vo * (b - d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.vo * (b + d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.vo * (b - d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.vo * (b + d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        return 0;
    };
    HighDensityScatterSeries.prototype.wz = function (a, b, c) {
        this.t3 = a;
        this.vo = b;
        this.vn = c;
    };
    HighDensityScatterSeries.prototype.get_gf = function () {
        return true;
    };
    HighDensityScatterSeries.prototype.set_gf = function (a) {
        _super.prototype.set_gf.call(this, a);
    };
    HighDensityScatterSeries.prototype.nj = function (a, b) {
        _super.prototype.nj.call(this, a, b);
        this.t5.ca();
        if (this.ci != null) {
            this.ci.ca();
        }
        this.ol();
    };
    HighDensityScatterSeries.prototype.pr = function (a, b) {
        _super.prototype.pr.call(this, a, b);
        if (!this.f8) {
            this.cj.a4(b);
            return;
        }
        this.cj.a4(b);
        if (this.dl(this.ci)) {
            return;
        }
        var c = typeCast(HighDensityScatterSeriesView.$, this.ci);
        var d = new ScatterFrame();
        this.wq(false, c);
        this.f8 = false;
    };
    HighDensityScatterSeries.prototype.po = function (a, b, c, d, e) {
        _super.prototype.po.call(this, a, b, c, d, e);
        var f = this.a7.a$h.item(d);
        var g = f;
        f.a3(c);
        if (this.dl(g)) {
            return;
        }
        if (this.ud == null) {
            this.ud = new ScatterFrame();
        }
        this.wq(false, f);
    };
    HighDensityScatterSeries.prototype.ng = function () {
        _super.prototype.ng.call(this);
        this.t8 = null;
        this.ua = null;
    };
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:xg:w1', [Color.$, Defaults.ap], 'HeatMaximum:vi:w2', [1, 50], 'HeatMinimumColor:xh:w3', [Color.$, Defaults.aq], 'HeatMinimum:vj:w4', [1, 0], 'PointExtent:vv:w5', [1, 1], 'ProgressiveLoad:un:w6', [0, true], 'UseBruteForce:uo:w7', [0, false], 'XAxis:t8:w8', [NumericXAxis.$, null], 'XMemberAsLegendLabel:v7:w9', [2, null], 'XMemberAsLegendUnit:v9:xa', [2, null], 'XMemberPath:wb:xb', [2, null], 'YAxis:ua:xc', [NumericYAxis.$, null], 'YMemberAsLegendLabel:wf:xd', [2, null], 'YMemberAsLegendUnit:wh:xe', [2, null], 'YMemberPath:wj:xf', [2, null]]);
    return HighDensityScatterSeries;
}(Series));
export { HighDensityScatterSeries };
/**
 * @hidden
 */
var HighDensityScatterSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(HighDensityScatterSeriesView, _super);
    function HighDensityScatterSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.b2 = null;
        _this.b0 = null;
        _this.b8 = 0;
        _this.b7 = 0;
        _this.b5 = null;
        _this.b6 = null;
        _this.b3 = null;
        _this.b2 = a;
        return _this;
    }
    HighDensityScatterSeriesView.prototype.au = function () {
        _super.prototype.au.call(this);
        if (!this.q) {
            this.b2.xh = Defaults.aq;
            this.b2.xg = Defaults.ap;
            this.b2.sw = Defaults.al;
            this.b2.s2 = Defaults.ak;
        }
    };
    HighDensityScatterSeriesView.prototype.cd = function () {
        this.b2.wz(this.b0, this.b8, this.b7);
    };
    HighDensityScatterSeriesView.prototype.b9 = function () {
        if (this.b5 == null) {
            this.b5 = this.e.i4.createElement("canvas");
            var a = this.e.i4.get2DCanvasContext(this.b5);
            this.b3 = new RenderingContext(new CanvasViewRenderer(), a);
        }
        var b;
        if (this.p) {
            b = this.bx;
        }
        else {
            b = this.e.cy.ts();
        }
        var c = truncate(Math.round(b.left));
        var d = truncate(Math.round(b.top));
        var e = truncate(Math.round(b.width));
        var f = truncate(Math.round(b.height));
        var g = this.b8;
        var h = this.b7;
        this.b8 = e;
        this.b7 = f;
        if (g != this.b8 || h != this.b7 || this.b0 == null) {
            this.b5.setAttribute("width", e.toString());
            this.b5.setAttribute("height", f.toString());
            this.b6 = this.b3.h().getImageData(0, 0, e, f);
            var imageDataArray_ = this.b6.data;
            this.b0 = imageDataArray_;
        }
        this.b2.wz(this.b0, this.b8, this.b7);
    };
    HighDensityScatterSeriesView.prototype.b1 = function () {
        return this.b0;
    };
    HighDensityScatterSeriesView.prototype.cc = function () {
        var a = truncate(Math.round(this.bx.left));
        var b = truncate(Math.round(this.bx.left));
        var c = truncate(Math.round(this.bx.width));
        var d = truncate(Math.round(this.bx.height));
        this.b3.h().putImageData(this.b6, 0, 0);
        this.as();
    };
    HighDensityScatterSeriesView.prototype.cb = function (a) {
        if (this.e.i4 != null) {
            this.e.i4.setTimeout(a, 0);
        }
        else {
            window.setTimeout(a, 0);
        }
    };
    HighDensityScatterSeriesView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        if (b) {
            if (!this.b2.fk) {
                return;
            }
            var c = new Rectangle();
            c.n = this.bx.left;
            c.o = this.bx.top;
            c.width = this.bx.width;
            c.height = this.bx.height;
            c._fill = this.br();
            a.w(c);
            return;
        }
        if (this.b5 == null) {
            return;
        }
        var d = truncate(Math.round(this.bx.left));
        var e = truncate(Math.round(this.bx.top));
        var f = truncate(Math.round(this.bx.width));
        var g = truncate(Math.round(this.bx.height));
        this.k.o(this.b5.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
    };
    HighDensityScatterSeriesView.prototype.b4 = function (a, b) {
        return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
    };
    HighDensityScatterSeriesView.prototype.ca = function () {
        if (this.b0 != null) {
            for (var a = 0; a < this.b0.length; a++) {
                this.b0[a] = 0;
            }
            this.cc();
        }
    };
    HighDensityScatterSeriesView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
        if (this.b0 == null) {
            this.e.a9.exportSeriesPixelsData(a, null, this.b8, this.b7);
            return;
        }
        var b = new Array(intDivide(this.b0.length, 4));
        var c;
        for (var d = 0; d < intDivide(this.b0.length, 4); d++) {
            c = d * 4;
            b[d] = this.b0[c + 3] << 24 | this.b0[c] << 16 | this.b0[c + 1] << 8 | this.b0[c + 2];
        }
        this.e.a9.exportSeriesPixelsData(a, b, this.b8, this.b7);
    };
    HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
}(SeriesView));
export { HighDensityScatterSeriesView };
