/*
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 { 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
 */
export let HighDensityScatterSeries = /*@__PURE__*/ (() => {
    class HighDensityScatterSeries extends Series {
        bi() {
            return new HighDensityScatterSeries();
        }
        get_fm() {
            return true;
        }
        ji() {
            if (!isNaN_(this.jh)) {
                return super.ji();
            }
            return Defaults.q;
        }
        constructor() {
            super();
            this.w3 = null;
            this.w5 = null;
            this.ye = 0;
            this.w7 = false;
            this.xt = Defaults.aq.o;
            this.xs = Defaults.aq.n;
            this.xr = Defaults.aq.m;
            this.xq = Defaults.aq.l;
            this.xp = Defaults.ap.o;
            this.xo = Defaults.ap.n;
            this.xn = Defaults.ap.m;
            this.xm = Defaults.ap.l;
            this.wv = null;
            this.w0 = null;
            this.w1 = null;
            this.ww = null;
            this.wy = null;
            this.w9 = false;
            this.yf = 0;
            this.yh = 0;
            this.yb = 0;
            this.ya = 0;
            this.progressiveLoadStatusChanged = null;
            this.xe = null;
            this.xk = 0;
            this.xj = 0;
            this.xl = 0;
            this.x0 = 0;
            this.xy = 0;
            this.xz = 0;
            this.x1 = 0;
            this.x3 = 0;
            this.x5 = 0;
            this.x4 = 0;
            this.x2 = 0;
            this.xg = 0;
            this.xh = 0;
            this.xi = 0;
            this.xf = 0;
            this.yd = 0;
            this.yc = 0;
            this.ws = null;
            this.yg = 0;
            this.w8 = false;
            this._itemIndexes = null;
            this.wt = null;
            this.wq = null;
            this.w2 = null;
            this.ab = HighDensityScatterSeries.$;
            this.f6 = false;
        }
        get_fu() {
            return true;
        }
        get w4() {
            return this.w3;
        }
        set w4(a) {
            if (this.w3 != a) {
                let b = this.w4;
                this.w3 = a;
                this.raisePropertyChanged("XColumn", b, this.w4);
            }
        }
        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.y0 != null ? this.y0 : "X";
            g.s = this.yw != null ? this.yw : "X:";
            g.t = this.yy != null ? this.yy : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.q = "Y";
            h.r = this.y8 != null ? this.y8 : "Y";
            h.s = this.y4 != null ? this.y4 : "Y:";
            h.t = this.y6 != null ? this.y6 : "";
            let i = new DataLegendSeriesContext();
            i.e = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.h = this.ma();
            return i;
        }
        ko(a, b) {
            let c = this.nb(b);
            if (c == HighDensityScatterSeries.$$p[10]) {
                return this.kp(a, b, this.y0);
            }
            if (c == HighDensityScatterSeries.$$p[14]) {
                return this.kp(a, b, this.y8);
            }
            return super.ko(a, b);
        }
        mb(a) {
            let b = this.nb(a);
            if (b == HighDensityScatterSeries.$$p[10]) {
                return this.y0;
            }
            if (b == HighDensityScatterSeries.$$p[14]) {
                return this.y8;
            }
            return super.mb(a);
        }
        get w6() {
            return this.w5;
        }
        set w6(a) {
            if (this.w5 != a) {
                let b = this.w6;
                this.w5 = a;
                this.raisePropertyChanged("YColumn", b, this.w6);
            }
        }
        zn() {
            if (this.wv == null) {
                return;
            }
            this.wv.s();
            let a = this.wv;
            a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.za));
            this.wv = null;
        }
        q5(a, b, c, d) {
            super.q5(a, b, c, d);
            switch (b) {
                case HighDensityScatterSeries.$$p[8]:
                case HighDensityScatterSeries.$$p[12]:
                case HighDensityScatterSeries.$$p[9]:
                case HighDensityScatterSeries.$$p[13]:
                    this.qb();
                    break;
                case "SeriesViewer":
                    if (this.c9 != null) {
                        let e = this.getEffectiveViewport1(this.ct);
                        this.w8 = !e.isEmpty;
                    }
                    break;
                case "FastItemsSource":
                    this.zn();
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.w4);
                        c.deregisterColumn(this.w6);
                        this.w4 = null;
                        this.w6 = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.w4 = this.di(this.y0);
                        this.w6 = this.di(this.y8);
                    }
                    if ((this.wz != null && !this.wz.c1()) || (this.wx != null && !this.wx.c1())) {
                        this.rn(this.ge && c != null);
                    }
                    this.qi();
                    break;
                case HighDensityScatterSeries.$$p[7]:
                    let f = this.ww;
                    this.ww = this.wx;
                    this.zn();
                    if (f != null) {
                        f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.zd));
                    }
                    if (this.ww != null) {
                        let g = this.ww;
                        g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.zd));
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if ((this.wx != null && !this.wx.c1()) || (d == null && c != null)) {
                        this.rn(false);
                    }
                    break;
                case HighDensityScatterSeries.$$p[11]:
                    let h = this.wy;
                    this.wy = this.wz;
                    this.zn();
                    if (h != null) {
                        h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.zd));
                    }
                    if (this.wy != null) {
                        let i = this.wy;
                        i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.zd));
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if ((this.wz != null && !this.wz.c1()) || (d == null && c != null)) {
                        this.rn(false);
                    }
                    break;
                case "MouseOverEnabled":
                    this.w9 = this.f6;
                    this.rn(false);
                    break;
                case HighDensityScatterSeries.$$p[10]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.w4);
                        this.w4 = this.di(this.y0);
                    }
                    break;
                case "XColumn":
                    this.zn();
                    if (this.wx != null && !this.wx.c1()) {
                        this.rn(false);
                    }
                    this.qi();
                    break;
                case HighDensityScatterSeries.$$p[14]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.w6);
                        this.w6 = this.di(this.y8);
                    }
                    break;
                case "YColumn":
                    this.zn();
                    if (this.wz != null && !this.wz.c1()) {
                        this.rn(false);
                    }
                    this.qi();
                    break;
                case HighDensityScatterSeries.$$p[6]:
                    this.zn();
                    this.rn(false);
                    this.qh();
                    break;
                case HighDensityScatterSeries.$$p[3]:
                    this.rn(false);
                    this.qh();
                    break;
                case HighDensityScatterSeries.$$p[1]:
                    this.rn(false);
                    this.qh();
                    break;
                case HighDensityScatterSeries.$$p[0]:
                case HighDensityScatterSeries.$$p[2]:
                    if (!this.wu.b4(this.z6, this.z5)) {
                        return;
                    }
                    this.zh();
                    this.rn(false);
                    this.qh();
                    break;
                case HighDensityScatterSeries.$$p[4]:
                    this.ye = Math.max(typeGetValue(d) - 1, 0);
                    this.w7 = this.ye > 0;
                    this.rn(false);
                    this.qh();
                    break;
                case HighDensityScatterSeries.$$p[5]:
                    this.rn(false);
                    this.qh();
                    break;
            }
        }
        zh() {
            this.xq = this.z6.l;
            this.xt = this.z6.o;
            this.xs = this.z6.n;
            this.xr = this.z6.m;
            this.xm = this.z5.l;
            this.xp = this.z5.o;
            this.xo = this.z5.n;
            this.xn = this.z5.m;
            this.vp = BrushUtil.h(truncate(this.xq), truncate(this.xt), truncate(this.xs), truncate(this.xr));
            this.u9 = BrushUtil.h(truncate(this.xm), truncate(this.xp), truncate(this.xo), truncate(this.xn));
        }
        xb(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        xa(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        zd(a, b) {
            this.zn();
            this.rn(false);
        }
        get xx() {
            return this.xp - this.xt;
        }
        get xw() {
            return this.xo - this.xs;
        }
        get xv() {
            return this.xn - this.xr;
        }
        get xu() {
            return this.xm - this.xq;
        }
        hc(a, b, c) {
            let d = super.hc(a, b, c);
            if (this.wz == null || this.wx == null || this.wx.bi == null || this.wz.bi == null || this.w6 == null || this.w4 == null || this.w6.count < 1 || this.w4.count < 1 || this.w6.count != this.w4.count || this.wx.ly == this.wx.lx || this.wz.ly == this.wz.lx || this.wl.isEmpty) {
                d = false;
            }
            return d;
        }
        get yl() {
            return this.yf;
        }
        set yl(a) {
            let b = this.yf;
            this.yf = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.yf);
        }
        ro(a) {
            super.ro(a);
            this.zf(a, this.ct);
        }
        zf(a, b) {
            if (this.d3(b)) {
                return;
            }
            if (this.wv == null && !this.xd) {
                let c = new List$1(KDPointData.$, 2, this.w4.count);
                let d = this.wx;
                let e = this.wz;
                let f = new Rect(0, 0, 0, 1, 1);
                let g = new Rect(0, 0, 0, 1, 1);
                let h = new ScalerParams(1, f, g, d.ch);
                let i = new ScalerParams(1, f, g, e.ch);
                let j;
                let k;
                for (let l = 0; l < this.w4.count; l++) {
                    j = d.ek(this.w4.item(l), h);
                    k = e.ek(this.w6.item(l), i);
                    if (!isNaN_(j) && !isNaN_(k) && !isInfinity(j) && !isInfinity(k)) {
                        c.add(((() => {
                            let $ret = new KDPointData();
                            $ret.a = j;
                            $ret.b = k;
                            $ret.c = l;
                            return $ret;
                        })()));
                    }
                }
                if (this.xc) {
                    this.ya = 1;
                    this.yb = truncate(logBase(c.count, 2)) + 3;
                    this.yl = truncate(((this.ya / this.yb) * 100));
                    if (this.progressiveLoadStatusChanged != null) {
                        this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yl));
                    }
                    this.wv = KDTree2D.b(c.toArray(), 1);
                    let m = this.wv;
                    m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.za));
                    if (!this.wv.f(this.jx)) {
                        let n = this.wv;
                        n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.za));
                    }
                    this.qh();
                }
                else {
                    let o = dateNow();
                    this.wv = new KDTree2D(0, c.toArray(), 1);
                    let p = dateNow();
                }
            }
            if (this.xc && !this.xd) {
                this.zg(b);
            }
            else {
                this.zi(b);
            }
        }
        o9(a, b, c, d) {
            super.o9(a, b, c, d);
            this.zn();
            let e = false;
            if (this.wx != null && !this.wx.c1()) {
                e = true;
            }
            if (this.wz != null && !this.wz.c1()) {
                e = true;
            }
            if (e) {
                this.rn(false);
            }
            this.qi();
        }
        zc(a) {
            let b = a;
            let c = this.yd * this.yc;
            if (this.w9) {
                if (this._itemIndexes == null || this._itemIndexes.length != c) {
                    this._itemIndexes = new Array(c);
                    for (let d = 0; d < c; d++) {
                        this._itemIndexes[d] = 0;
                    }
                }
                else {
                    for (let e = 0; e < c; e++) {
                        this._itemIndexes[e] = 0;
                    }
                }
            }
        }
        zi(a) {
            let b;
            let c;
            let d = null;
            if (a.q) {
                d = this._itemIndexes;
            }
            let e = a.getViewInfo(c, b);
            c = e.p0;
            b = e.p1;
            let f = a;
            let g = this.getEffectiveViewport1(a);
            this.w0 = new ScalerParams(0, b, c, this.ww.ch, g);
            this.w1 = new ScalerParams(0, b, c, this.wy.ch, g);
            this.zb(a);
            this.zc(a);
            let h = this.yd * this.yc;
            if (this.wt == null || this.wt.length != h) {
                this.wt = new Array(h);
                this.wq = new Array(h);
            }
            let i = this.wt.length;
            let j = this.wt;
            let k = this.wq;
            for (let l = 0; l < i; l++) {
                j[l] = 0;
                k[l] = 0;
            }
            this.yh = truncate(Math.round(this.ib));
            this.ws = f.b1();
            let m = this.ws.length;
            let n = this.ws;
            for (let o = 0; o < m; o++) {
                n[o] = 0;
            }
            let p = this.x8;
            let q = this.x7;
            if (isNaN_(p) || isInfinity(p)) {
                p = 0;
            }
            if (isNaN_(q) || isInfinity(q)) {
                q = 50;
            }
            this.xk = Math.min(p, q);
            this.xj = Math.max(p, q);
            if (this.xk < 0) {
                this.xk = 0;
            }
            if (this.xj < 0) {
                this.xj = 0;
            }
            this.xl = this.xj - this.xk;
            if (this.xd) {
                this.ze(a);
            }
            else {
                this.zp(a);
            }
            f.cc();
            if (a.q) {
                this._itemIndexes = d;
                this.wu.cd();
            }
        }
        zg(a) {
            if (this.wv == null) {
                return;
            }
            this.zi(a);
        }
        za(a, b) {
            this.wu.cb(() => {
                if (this.ya < this.yb - 1) {
                    this.ya++;
                }
                this.yl = truncate(((this.ya / this.yb) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yl));
                }
                this.zg(this.ct);
                this.qh();
                if (this.wv != null) {
                    if (!this.wv.f(this.jx)) {
                        let c = this.wv;
                        c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(this, this.za));
                        this.yl = 100;
                        if (this.progressiveLoadStatusChanged != null) {
                            this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yl));
                        }
                    }
                }
            });
        }
        ze(a) {
            let b = arrayShallowClone(this.w4.asArray());
            this.wx.ho(boxArray$1(b), 0, b.length, this.w0);
            let c = arrayShallowClone(this.w6.asArray());
            this.yg = 0;
            let d = this.ye;
            let e = this.w7;
            let f = this.wt.length;
            this.wz.ho(boxArray$1(c), 0, c.length, this.w1);
            let g = 255 << 24 | truncate(this.xt) << 16 | truncate(this.xs) << 8 | truncate(this.xr);
            for (let h = 0; h < b.length; h++) {
                let i = truncate(b[h]);
                let j = truncate(c[h]);
                i = truncate(Math.floor(i));
                j = truncate(Math.floor(j));
                if (i < 0 || i >= this.yd || j < 0 || j >= this.yc) {
                    continue;
                }
                if (e) {
                    let k = i - d;
                    let l = i + d;
                    l = l > (this.yd - 1) ? (this.yd - 1) : l;
                    k = k < 0 ? 0 : k;
                    let m = j + d;
                    let n = j - d;
                    for (let o = k; o <= l; o++) {
                        for (let p = n; p <= m; p++) {
                            let q = (p * this.yd) + o;
                            if (q < 0 || q > f - 1) {
                                continue;
                            }
                            this.wt[q] = this.wt[q] + 1;
                            this.wq[q] = 1;
                            this.yg++;
                            if (this.w9) {
                                this._itemIndexes[q] = h + 1;
                            }
                        }
                    }
                }
                else {
                    let r = (j * this.yd) + i;
                    this.wt[r] = this.wt[r] + 1;
                    this.wq[r] = 1;
                    this.yg++;
                    if (this.w9) {
                        this._itemIndexes[r] = h + 1;
                    }
                }
            }
            this.zj();
        }
        zp(a) {
            let b;
            let c;
            let d = a.getViewInfo(b, c);
            b = d.p0;
            c = d.p1;
            if (this.wv == null) {
                return;
            }
            if (this.xe == null) {
                this.xe = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
            }
            else {
                this.xe.clear();
            }
            let e = c.left;
            let f = c.right;
            let g = c.top;
            let h = c.bottom;
            this.x4 = c.top;
            this.x2 = c.height;
            this.x3 = c.left;
            this.x5 = c.width;
            this.x0 = b.top;
            this.xy = b.height;
            this.xz = b.left;
            this.x1 = b.width;
            let i = this.getEffectiveViewport1(a);
            this.xg = (i.left - this.xz) / this.x1;
            this.xh = (i.top - this.x0) / this.xy;
            let j = (i.right - this.xz) / this.x1;
            this.xi = j - this.xg;
            let k = (i.bottom - this.x0) / this.xy;
            this.xf = k - this.xh;
            if (this.w8) {
                e = (e - this.xg) / this.xi;
                f = (f - this.xg) / this.xi;
                g = (g - this.xh) / this.xf;
                h = (h - this.xh) / this.xf;
            }
            let l = this.ib / b.width * c.width;
            let m = this.ib / b.height * c.height;
            let n = Math.min(l, m);
            let o = ((() => {
                let $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.wv.t(this.xe, o, 0, 1, 0, 1);
            let p;
            this.yg = 0;
            for (let q = 0; q < this.xe.count; q++) {
                p = this.xe._inner[q];
                this.zk(p);
            }
            this.zj();
        }
        zk(a) {
            if (a.g) {
                return;
            }
            let b = a.e != null && a.e.a;
            let c = a.a == null ? 0 : a.a.length;
            let d = (a.h - c) + 1;
            if (b && d > 0) {
            }
            else {
                d = 1;
            }
            this.zm(a.b, d, b, a.e);
            if (c > 0 && !b) {
                let e;
                for (let f = 0; f < c; f++) {
                    e = a.a[f];
                    this.zm(e, d, false, a.e);
                }
            }
            if (a.e != null) {
                a.e.a = false;
            }
        }
        gb(a) {
            let b = this.c9 != null ? this.c9.vl : Rect.empty;
            let c = this.c9 != null ? this.c9.v0 : Rect.empty;
            let d = new Rect(0, 0, 0, 1, 1);
            let e = this.wf(this.ct);
            let f = new ScalerParams(0, d, d, this.wx.ch, e);
            let g = new ScalerParams(0, d, d, this.wz.ch, e);
            let h = !b.isEmpty && !c.isEmpty && this.dl != null ? this.dl.indexOf(a) : -1;
            let i = this.wx != null && this.w4 != null && h < this.w4.count ? this.wx.ek(this.w4.item(h), f) : NaN;
            let j = this.wz != null && this.w6 != null && h < this.w6.count ? this.wz.ek(this.w6.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.c1 != null) {
                this.c1.au(this.c9, b, true);
            }
            return h >= 0;
        }
        zm(a, b, c, d) {
            let e = this.yj(b);
            let f = a.c;
            let g = this.ye;
            if (c) {
                let h = d.d;
                let i = d.b;
                let j = d.e;
                let k = d.c;
                if (this.w8) {
                    h = this.xg + this.xi * h;
                    i = this.xg + this.xi * i;
                    j = this.xh + this.xf * j;
                    k = this.xh + this.xf * k;
                }
                let l = truncate((this.xz + this.x1 * (h - this.x3) / this.x5));
                let m = truncate((this.xz + this.x1 * (i - this.x3) / this.x5));
                let n = truncate((this.x0 + this.xy * (j - this.x4) / this.x2));
                let o = truncate((this.x0 + this.xy * (k - this.x4) / this.x2));
                l = truncate(Math.floor(l));
                m = truncate(Math.floor(m));
                n = truncate(Math.floor(n));
                o = truncate(Math.floor(o));
                if (this.w7) {
                    l -= g;
                    m += g;
                    n -= g;
                    o += g;
                }
                let p = ((m - l) + 1) * ((o - n) + 1);
                let q = b / p;
                let r = q;
                for (let s = l; s <= m; s++) {
                    for (let t = n; t <= o; t++) {
                        this.zl(f, s, t, q, r);
                    }
                }
            }
            else {
                let u = a.a;
                let v = a.b;
                if (this.w8) {
                    u = this.xg + this.xi * u;
                    v = this.xh + this.xf * v;
                }
                let w = truncate((this.xz + this.x1 * (u - this.x3) / this.x5));
                let x = truncate((this.x0 + this.xy * (v - this.x4) / this.x2));
                w = truncate(Math.floor(w));
                x = truncate(Math.floor(x));
                if (this.w7) {
                    let y = w - g;
                    let z = w + g;
                    let aa = x + g;
                    let ab = x - g;
                    let ac = ((z - y) + 1) * ((aa - ab) + 1);
                    let ad = b / ac;
                    let ae = ad;
                    for (let af = y; af <= z; af++) {
                        for (let ag = ab; ag <= aa; ag++) {
                            this.zl(f, af, ag, ad, ae);
                        }
                    }
                }
                else {
                    this.zl(f, w, x, b, 1);
                }
            }
        }
        yi(a, b) {
            return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.xt + a * this.xx))) << 16 | truncate(Math.floor(b * (this.xs + a * this.xw))) << 8 | truncate(Math.floor(b * (this.xr + a * this.xv)));
        }
        yj(a) {
            return 255 << 24 | truncate(Math.floor((this.xt + a * this.xx))) << 16 | truncate(Math.floor((this.xs + a * this.xw))) << 8 | truncate(Math.floor((this.xr + a * this.xv)));
        }
        x6(a) {
            return (a >> 24 & 255) / 255;
        }
        zl(a, b, c, d, e) {
            if (b < 0 || b >= this.yd || c < 0 || c >= this.yc) {
                return;
            }
            let f = (c * this.yd) + b;
            this.wt[f] = this.wt[f] + d;
            this.wq[f] = this.wq[f] + e;
            if (this.w9) {
                this._itemIndexes[f] = a + 1;
            }
            this.yg += truncate(d);
        }
        zj() {
            let a = 0;
            let b = 0;
            let c = this.xl;
            let d = this.xk;
            let e = this.xj;
            let f = this.wt.length;
            let g = this.wt;
            let h = this.wq;
            let i = this.ws;
            let j = NaN;
            let k = NaN;
            let l = 0;
            let m = 0;
            for (let 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.yi(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;
            }
        }
        zb(a) {
            let b = a;
            b.b9();
        }
        cq() {
            return new HighDensityScatterSeriesView(this);
        }
        qx(a) {
            super.qx(a);
            this.wu = a;
        }
        ax(a) {
            if (a != null && a == this.wx && this.w4 != null) {
                return new AxisRange(this.w4.minimum, this.w4.maximum);
            }
            if (a != null && a == this.wz && this.w6 != null) {
                return new AxisRange(this.w6.minimum, this.w6.maximum);
            }
            return null;
        }
        sk(a, b) {
            if (this.c9 != null) {
                let c = this.getEffectiveViewport1(this.ct);
                this.w8 = !c.isEmpty;
            }
            this.rn(false);
        }
        sl(a, b) {
            this.rn(false);
        }
        kl(a) {
            if (!this.w9 || this._itemIndexes == null || this.c9 == null || this.dl == null || this._itemIndexes.length != (this.yd * this.yc)) {
                return null;
            }
            let b = this.c9.vl;
            let c = (a.x - b.left) / b.width;
            let d = (a.y - b.top) / b.height;
            let e = truncate(Math.round(this.wl.left + (this.wl.width * c)));
            let f = truncate(Math.round(this.wl.top + (this.wl.height * d)));
            let g = this.ym(e, f);
            if (g < 0 || g > this._itemIndexes.length - 1) {
                return null;
            }
            let h = this._itemIndexes[g] - 1;
            if (h < 0 || h > this.dl.count) {
                return null;
            }
            return this.dl.item(h);
        }
        ym(a, b) {
            let c = (this.yd * b) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            let d = 1;
            c = (this.yd * (b - d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yd * (b + d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yd * (b)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yd * (b)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yd * (b - d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yd * (b + d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yd * (b - d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yd * (b + d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            return 0;
        }
        zo(a, b, c) {
            this.ws = a;
            this.yd = b;
            this.yc = c;
        }
        get_g5() {
            return true;
        }
        set_g5(a) {
            super.set_g5(a);
        }
        o3(a, b) {
            super.o3(a, b);
            this.wu.ca();
            if (this.cs != null) {
                this.cs.ca();
            }
            this.qh();
        }
        rp(a, b) {
            super.rp(a, b);
            if (!this.gy) {
                this.ct.a4(b);
                return;
            }
            this.ct.a4(b);
            if (this.d3(this.cs)) {
                return;
            }
            let c = typeCast(HighDensityScatterSeriesView.$, this.cs);
            let d = new ScatterFrame();
            this.zf(false, c);
            this.gy = false;
        }
        rm(a, b, c, d, e) {
            super.rm(a, b, c, d, e);
            let f = this.a9.a$j.item(d);
            let g = f;
            f.a3(c);
            if (this.d3(g)) {
                return;
            }
            if (this.w2 == null) {
                this.w2 = new ScatterFrame();
            }
            this.zf(false, f);
        }
        o0() {
            super.o0();
            this.wx = null;
            this.wz = null;
        }
    }
    HighDensityScatterSeries.$t = /*@__PURE__*/ markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:z5:zq', [Color.$, Defaults.ap], 'HeatMaximum:x7:zr', [1, 50], 'HeatMinimumColor:z6:zs', [Color.$, Defaults.aq], 'HeatMinimum:x8:zt', [1, 0], 'PointExtent:yk:zu', [1, 1], 'ProgressiveLoad:xc:zv', [0, true], 'UseBruteForce:xd:zw', [0, false], 'XAxis:wx:zx', [NumericXAxis.$, null], 'XMemberAsLegendLabel:yw:zy', [2, null], 'XMemberAsLegendUnit:yy:zz', [2, null], 'XMemberPath:y0:z0', [2, null], 'YAxis:wz:z1', [NumericYAxis.$, null], 'YMemberAsLegendLabel:y4:z2', [2, null], 'YMemberAsLegendUnit:y6:z3', [2, null], 'YMemberPath:y8:z4', [2, null]]);
    return HighDensityScatterSeries;
})();
/**
 * @hidden
 */
export let HighDensityScatterSeriesView = /*@__PURE__*/ (() => {
    class HighDensityScatterSeriesView extends SeriesView {
        constructor(a) {
            super(a);
            this.b2 = null;
            this.b0 = null;
            this.b8 = 0;
            this.b7 = 0;
            this.b5 = null;
            this.b6 = null;
            this.b3 = null;
            this.b2 = a;
        }
        au() {
            super.au();
            if (!this.q) {
                this.b2.z6 = Defaults.aq;
                this.b2.z5 = Defaults.ap;
                this.b2.u9 = Defaults.al;
                this.b2.vp = Defaults.ak;
            }
        }
        cd() {
            this.b2.zo(this.b0, this.b8, this.b7);
        }
        b9() {
            if (this.b5 == null) {
                this.b5 = this.e.jx.createElement("canvas");
                let a = this.e.jx.get2DCanvasContext(this.b5);
                this.b3 = new RenderingContext(new CanvasViewRenderer(), a);
            }
            let b;
            if (this.p) {
                b = this.bx;
            }
            else {
                b = this.e.c9.vq();
            }
            let c = truncate(Math.round(b.left));
            let d = truncate(Math.round(b.top));
            let e = truncate(Math.round(b.width));
            let f = truncate(Math.round(b.height));
            let g = this.b8;
            let 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);
                let imageDataArray_ = this.b6.data;
                this.b0 = imageDataArray_;
            }
            this.b2.zo(this.b0, this.b8, this.b7);
        }
        b1() {
            return this.b0;
        }
        cc() {
            let a = truncate(Math.round(this.bx.left));
            let b = truncate(Math.round(this.bx.left));
            let c = truncate(Math.round(this.bx.width));
            let d = truncate(Math.round(this.bx.height));
            this.b3.h().putImageData(this.b6, 0, 0);
            this.as();
        }
        cb(a) {
            if (this.e.jx != null) {
                this.e.jx.setTimeout(a, 0);
            }
            else {
                window.setTimeout(a, 0);
            }
        }
        a8(a, b) {
            super.a8(a, b);
            if (b) {
                if (!this.b2.f6) {
                    return;
                }
                let 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;
            }
            let d = truncate(Math.round(this.bx.left));
            let e = truncate(Math.round(this.bx.top));
            let f = truncate(Math.round(this.bx.width));
            let g = truncate(Math.round(this.bx.height));
            this.k.o(this.b5.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
        }
        b4(a, b) {
            return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
        }
        ca() {
            if (this.b0 != null) {
                for (let a = 0; a < this.b0.length; a++) {
                    this.b0[a] = 0;
                }
                this.cc();
            }
        }
        an(a) {
            super.an(a);
            if (this.b0 == null) {
                this.e.bb.exportSeriesPixelsData(a, null, this.b8, this.b7);
                return;
            }
            let b = new Array(intDivide(this.b0.length, 4));
            let c;
            for (let 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.bb.exportSeriesPixelsData(a, b, this.b8, this.b7);
        }
    }
    HighDensityScatterSeriesView.$t = /*@__PURE__*/ markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
})();
