/*
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.w2 = null;
            this.w4 = null;
            this.yd = 0;
            this.w6 = false;
            this.xs = Defaults.aq.o;
            this.xr = Defaults.aq.n;
            this.xq = Defaults.aq.m;
            this.xp = Defaults.aq.l;
            this.xo = Defaults.ap.o;
            this.xn = Defaults.ap.n;
            this.xm = Defaults.ap.m;
            this.xl = Defaults.ap.l;
            this.wu = null;
            this.wz = null;
            this.w0 = null;
            this.wv = null;
            this.wx = null;
            this.w8 = false;
            this.ye = 0;
            this.yg = 0;
            this.ya = 0;
            this.x9 = 0;
            this.progressiveLoadStatusChanged = null;
            this.xd = null;
            this.xj = 0;
            this.xi = 0;
            this.xk = 0;
            this.xz = 0;
            this.xx = 0;
            this.xy = 0;
            this.x0 = 0;
            this.x2 = 0;
            this.x4 = 0;
            this.x3 = 0;
            this.x1 = 0;
            this.xf = 0;
            this.xg = 0;
            this.xh = 0;
            this.xe = 0;
            this.yc = 0;
            this.yb = 0;
            this.wr = null;
            this.yf = 0;
            this.w7 = false;
            this._itemIndexes = null;
            this.ws = null;
            this.wp = null;
            this.w1 = null;
            this.ab = HighDensityScatterSeries.$;
            this.f6 = false;
        }
        get_fu() {
            return true;
        }
        get w3() {
            return this.w2;
        }
        set w3(a) {
            if (this.w2 != a) {
                let b = this.w3;
                this.w2 = a;
                this.raisePropertyChanged("XColumn", b, this.w3);
            }
        }
        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.yz != null ? this.yz : "X";
            g.s = this.yv != null ? this.yv : "X:";
            g.t = this.yx != null ? this.yx : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.q = "Y";
            h.r = this.y7 != null ? this.y7 : "Y";
            h.s = this.y3 != null ? this.y3 : "Y:";
            h.t = this.y5 != null ? this.y5 : "";
            let i = new DataLegendSeriesContext();
            i.e = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.h = this.l9();
            return i;
        }
        ko(a, b) {
            let c = this.na(b);
            if (c == HighDensityScatterSeries.$$p[10]) {
                return this.kp(a, b, this.yz);
            }
            if (c == HighDensityScatterSeries.$$p[14]) {
                return this.kp(a, b, this.y7);
            }
            return super.ko(a, b);
        }
        ma(a) {
            let b = this.na(a);
            if (b == HighDensityScatterSeries.$$p[10]) {
                return this.yz;
            }
            if (b == HighDensityScatterSeries.$$p[14]) {
                return this.y7;
            }
            return super.ma(a);
        }
        get w5() {
            return this.w4;
        }
        set w5(a) {
            if (this.w4 != a) {
                let b = this.w5;
                this.w4 = a;
                this.raisePropertyChanged("YColumn", b, this.w5);
            }
        }
        zm() {
            if (this.wu == null) {
                return;
            }
            this.wu.s();
            let a = this.wu;
            a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.y9));
            this.wu = null;
        }
        q4(a, b, c, d) {
            super.q4(a, b, c, d);
            switch (b) {
                case HighDensityScatterSeries.$$p[8]:
                case HighDensityScatterSeries.$$p[12]:
                case HighDensityScatterSeries.$$p[9]:
                case HighDensityScatterSeries.$$p[13]:
                    this.qa();
                    break;
                case "SeriesViewer":
                    if (this.c9 != null) {
                        let e = this.getEffectiveViewport1(this.ct);
                        this.w7 = !e.isEmpty;
                    }
                    break;
                case "FastItemsSource":
                    this.zm();
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.w3);
                        c.deregisterColumn(this.w5);
                        this.w3 = null;
                        this.w5 = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.w3 = this.di(this.yz);
                        this.w5 = this.di(this.y7);
                    }
                    if ((this.wy != null && !this.wy.c1()) || (this.ww != null && !this.ww.c1())) {
                        this.rm(this.ge && c != null);
                    }
                    this.qh();
                    break;
                case HighDensityScatterSeries.$$p[7]:
                    let f = this.wv;
                    this.wv = this.ww;
                    this.zm();
                    if (f != null) {
                        f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.zc));
                    }
                    if (this.wv != null) {
                        let g = this.wv;
                        g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.zc));
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if ((this.ww != null && !this.ww.c1()) || (d == null && c != null)) {
                        this.rm(false);
                    }
                    break;
                case HighDensityScatterSeries.$$p[11]:
                    let h = this.wx;
                    this.wx = this.wy;
                    this.zm();
                    if (h != null) {
                        h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.zc));
                    }
                    if (this.wx != null) {
                        let i = this.wx;
                        i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.zc));
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if ((this.wy != null && !this.wy.c1()) || (d == null && c != null)) {
                        this.rm(false);
                    }
                    break;
                case "MouseOverEnabled":
                    this.w8 = this.f6;
                    this.rm(false);
                    break;
                case HighDensityScatterSeries.$$p[10]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.w3);
                        this.w3 = this.di(this.yz);
                    }
                    break;
                case "XColumn":
                    this.zm();
                    if (this.ww != null && !this.ww.c1()) {
                        this.rm(false);
                    }
                    this.qh();
                    break;
                case HighDensityScatterSeries.$$p[14]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.w5);
                        this.w5 = this.di(this.y7);
                    }
                    break;
                case "YColumn":
                    this.zm();
                    if (this.wy != null && !this.wy.c1()) {
                        this.rm(false);
                    }
                    this.qh();
                    break;
                case HighDensityScatterSeries.$$p[6]:
                    this.zm();
                    this.rm(false);
                    this.qg();
                    break;
                case HighDensityScatterSeries.$$p[3]:
                    this.rm(false);
                    this.qg();
                    break;
                case HighDensityScatterSeries.$$p[1]:
                    this.rm(false);
                    this.qg();
                    break;
                case HighDensityScatterSeries.$$p[0]:
                case HighDensityScatterSeries.$$p[2]:
                    if (!this.wt.b4(this.z5, this.z4)) {
                        return;
                    }
                    this.zg();
                    this.rm(false);
                    this.qg();
                    break;
                case HighDensityScatterSeries.$$p[4]:
                    this.yd = Math.max(typeGetValue(d) - 1, 0);
                    this.w6 = this.yd > 0;
                    this.rm(false);
                    this.qg();
                    break;
                case HighDensityScatterSeries.$$p[5]:
                    this.rm(false);
                    this.qg();
                    break;
            }
        }
        zg() {
            this.xp = this.z5.l;
            this.xs = this.z5.o;
            this.xr = this.z5.n;
            this.xq = this.z5.m;
            this.xl = this.z4.l;
            this.xo = this.z4.o;
            this.xn = this.z4.n;
            this.xm = this.z4.m;
            this.vo = BrushUtil.h(truncate(this.xp), truncate(this.xs), truncate(this.xr), truncate(this.xq));
            this.u8 = BrushUtil.h(truncate(this.xl), truncate(this.xo), truncate(this.xn), truncate(this.xm));
        }
        xa(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        w9(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        zc(a, b) {
            this.zm();
            this.rm(false);
        }
        get xw() {
            return this.xo - this.xs;
        }
        get xv() {
            return this.xn - this.xr;
        }
        get xu() {
            return this.xm - this.xq;
        }
        get xt() {
            return this.xl - this.xp;
        }
        hc(a, b, c) {
            let d = super.hc(a, b, c);
            if (this.wy == null || this.ww == null || this.ww.bi == null || this.wy.bi == null || this.w5 == null || this.w3 == null || this.w5.count < 1 || this.w3.count < 1 || this.w5.count != this.w3.count || this.ww.ly == this.ww.lx || this.wy.ly == this.wy.lx || this.wk.isEmpty) {
                d = false;
            }
            return d;
        }
        get yk() {
            return this.ye;
        }
        set yk(a) {
            let b = this.ye;
            this.ye = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.ye);
        }
        rn(a) {
            super.rn(a);
            this.ze(a, this.ct);
        }
        ze(a, b) {
            if (this.d3(b)) {
                return;
            }
            if (this.wu == null && !this.xc) {
                let c = new List$1(KDPointData.$, 2, this.w3.count);
                let d = this.ww;
                let e = this.wy;
                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.w3.count; l++) {
                    j = d.ek(this.w3.item(l), h);
                    k = e.ek(this.w5.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.xb) {
                    this.x9 = 1;
                    this.ya = truncate(logBase(c.count, 2)) + 3;
                    this.yk = truncate(((this.x9 / this.ya) * 100));
                    if (this.progressiveLoadStatusChanged != null) {
                        this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yk));
                    }
                    this.wu = KDTree2D.b(c.toArray(), 1);
                    let m = this.wu;
                    m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.y9));
                    if (!this.wu.f(this.jx)) {
                        let n = this.wu;
                        n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.y9));
                    }
                    this.qg();
                }
                else {
                    let o = dateNow();
                    this.wu = new KDTree2D(0, c.toArray(), 1);
                    let p = dateNow();
                }
            }
            if (this.xb && !this.xc) {
                this.zf(b);
            }
            else {
                this.zh(b);
            }
        }
        o8(a, b, c, d) {
            super.o8(a, b, c, d);
            this.zm();
            let e = false;
            if (this.ww != null && !this.ww.c1()) {
                e = true;
            }
            if (this.wy != null && !this.wy.c1()) {
                e = true;
            }
            if (e) {
                this.rm(false);
            }
            this.qh();
        }
        zb(a) {
            let b = a;
            let c = this.yc * this.yb;
            if (this.w8) {
                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;
                    }
                }
            }
        }
        zh(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.wz = new ScalerParams(0, b, c, this.wv.ch, g);
            this.w0 = new ScalerParams(0, b, c, this.wx.ch, g);
            this.za(a);
            this.zb(a);
            let h = this.yc * this.yb;
            if (this.ws == null || this.ws.length != h) {
                this.ws = new Array(h);
                this.wp = new Array(h);
            }
            let i = this.ws.length;
            let j = this.ws;
            let k = this.wp;
            for (let l = 0; l < i; l++) {
                j[l] = 0;
                k[l] = 0;
            }
            this.yg = truncate(Math.round(this.ib));
            this.wr = f.b1();
            let m = this.wr.length;
            let n = this.wr;
            for (let o = 0; o < m; o++) {
                n[o] = 0;
            }
            let p = this.x7;
            let q = this.x6;
            if (isNaN_(p) || isInfinity(p)) {
                p = 0;
            }
            if (isNaN_(q) || isInfinity(q)) {
                q = 50;
            }
            this.xj = Math.min(p, q);
            this.xi = Math.max(p, q);
            if (this.xj < 0) {
                this.xj = 0;
            }
            if (this.xi < 0) {
                this.xi = 0;
            }
            this.xk = this.xi - this.xj;
            if (this.xc) {
                this.zd(a);
            }
            else {
                this.zo(a);
            }
            f.cc();
            if (a.q) {
                this._itemIndexes = d;
                this.wt.cd();
            }
        }
        zf(a) {
            if (this.wu == null) {
                return;
            }
            this.zh(a);
        }
        y9(a, b) {
            this.wt.cb(() => {
                if (this.x9 < this.ya - 1) {
                    this.x9++;
                }
                this.yk = truncate(((this.x9 / this.ya) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yk));
                }
                this.zf(this.ct);
                this.qg();
                if (this.wu != null) {
                    if (!this.wu.f(this.jx)) {
                        let c = this.wu;
                        c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(this, this.y9));
                        this.yk = 100;
                        if (this.progressiveLoadStatusChanged != null) {
                            this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yk));
                        }
                    }
                }
            });
        }
        zd(a) {
            let b = arrayShallowClone(this.w3.asArray());
            this.ww.ho(boxArray$1(b), 0, b.length, this.wz);
            let c = arrayShallowClone(this.w5.asArray());
            this.yf = 0;
            let d = this.yd;
            let e = this.w6;
            let f = this.ws.length;
            this.wy.ho(boxArray$1(c), 0, c.length, this.w0);
            let g = 255 << 24 | truncate(this.xs) << 16 | truncate(this.xr) << 8 | truncate(this.xq);
            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.yc || j < 0 || j >= this.yb) {
                    continue;
                }
                if (e) {
                    let k = i - d;
                    let l = i + d;
                    l = l > (this.yc - 1) ? (this.yc - 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.yc) + o;
                            if (q < 0 || q > f - 1) {
                                continue;
                            }
                            this.ws[q] = this.ws[q] + 1;
                            this.wp[q] = 1;
                            this.yf++;
                            if (this.w8) {
                                this._itemIndexes[q] = h + 1;
                            }
                        }
                    }
                }
                else {
                    let r = (j * this.yc) + i;
                    this.ws[r] = this.ws[r] + 1;
                    this.wp[r] = 1;
                    this.yf++;
                    if (this.w8) {
                        this._itemIndexes[r] = h + 1;
                    }
                }
            }
            this.zi();
        }
        zo(a) {
            let b;
            let c;
            let d = a.getViewInfo(b, c);
            b = d.p0;
            c = d.p1;
            if (this.wu == null) {
                return;
            }
            if (this.xd == null) {
                this.xd = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
            }
            else {
                this.xd.clear();
            }
            let e = c.left;
            let f = c.right;
            let g = c.top;
            let h = c.bottom;
            this.x3 = c.top;
            this.x1 = c.height;
            this.x2 = c.left;
            this.x4 = c.width;
            this.xz = b.top;
            this.xx = b.height;
            this.xy = b.left;
            this.x0 = b.width;
            let i = this.getEffectiveViewport1(a);
            this.xf = (i.left - this.xy) / this.x0;
            this.xg = (i.top - this.xz) / this.xx;
            let j = (i.right - this.xy) / this.x0;
            this.xh = j - this.xf;
            let k = (i.bottom - this.xz) / this.xx;
            this.xe = k - this.xg;
            if (this.w7) {
                e = (e - this.xf) / this.xh;
                f = (f - this.xf) / this.xh;
                g = (g - this.xg) / this.xe;
                h = (h - this.xg) / this.xe;
            }
            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.wu.t(this.xd, o, 0, 1, 0, 1);
            let p;
            this.yf = 0;
            for (let q = 0; q < this.xd.count; q++) {
                p = this.xd._inner[q];
                this.zj(p);
            }
            this.zi();
        }
        zj(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.zl(a.b, d, b, a.e);
            if (c > 0 && !b) {
                let e;
                for (let f = 0; f < c; f++) {
                    e = a.a[f];
                    this.zl(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.we(this.ct);
            let f = new ScalerParams(0, d, d, this.ww.ch, e);
            let g = new ScalerParams(0, d, d, this.wy.ch, e);
            let h = !b.isEmpty && !c.isEmpty && this.dl != null ? this.dl.indexOf(a) : -1;
            let i = this.ww != null && this.w3 != null && h < this.w3.count ? this.ww.ek(this.w3.item(h), f) : NaN;
            let j = this.wy != null && this.w5 != null && h < this.w5.count ? this.wy.ek(this.w5.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;
        }
        zl(a, b, c, d) {
            let e = this.yi(b);
            let f = a.c;
            let g = this.yd;
            if (c) {
                let h = d.d;
                let i = d.b;
                let j = d.e;
                let k = d.c;
                if (this.w7) {
                    h = this.xf + this.xh * h;
                    i = this.xf + this.xh * i;
                    j = this.xg + this.xe * j;
                    k = this.xg + this.xe * k;
                }
                let l = truncate((this.xy + this.x0 * (h - this.x2) / this.x4));
                let m = truncate((this.xy + this.x0 * (i - this.x2) / this.x4));
                let n = truncate((this.xz + this.xx * (j - this.x3) / this.x1));
                let o = truncate((this.xz + this.xx * (k - this.x3) / this.x1));
                l = truncate(Math.floor(l));
                m = truncate(Math.floor(m));
                n = truncate(Math.floor(n));
                o = truncate(Math.floor(o));
                if (this.w6) {
                    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.zk(f, s, t, q, r);
                    }
                }
            }
            else {
                let u = a.a;
                let v = a.b;
                if (this.w7) {
                    u = this.xf + this.xh * u;
                    v = this.xg + this.xe * v;
                }
                let w = truncate((this.xy + this.x0 * (u - this.x2) / this.x4));
                let x = truncate((this.xz + this.xx * (v - this.x3) / this.x1));
                w = truncate(Math.floor(w));
                x = truncate(Math.floor(x));
                if (this.w6) {
                    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.zk(f, af, ag, ad, ae);
                        }
                    }
                }
                else {
                    this.zk(f, w, x, b, 1);
                }
            }
        }
        yh(a, b) {
            return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.xs + a * this.xw))) << 16 | truncate(Math.floor(b * (this.xr + a * this.xv))) << 8 | truncate(Math.floor(b * (this.xq + a * this.xu)));
        }
        yi(a) {
            return 255 << 24 | truncate(Math.floor((this.xs + a * this.xw))) << 16 | truncate(Math.floor((this.xr + a * this.xv))) << 8 | truncate(Math.floor((this.xq + a * this.xu)));
        }
        x5(a) {
            return (a >> 24 & 255) / 255;
        }
        zk(a, b, c, d, e) {
            if (b < 0 || b >= this.yc || c < 0 || c >= this.yb) {
                return;
            }
            let f = (c * this.yc) + b;
            this.ws[f] = this.ws[f] + d;
            this.wp[f] = this.wp[f] + e;
            if (this.w8) {
                this._itemIndexes[f] = a + 1;
            }
            this.yf += truncate(d);
        }
        zi() {
            let a = 0;
            let b = 0;
            let c = this.xk;
            let d = this.xj;
            let e = this.xi;
            let f = this.ws.length;
            let g = this.ws;
            let h = this.wp;
            let i = this.wr;
            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.yh(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;
            }
        }
        za(a) {
            let b = a;
            b.b9();
        }
        cq() {
            return new HighDensityScatterSeriesView(this);
        }
        qw(a) {
            super.qw(a);
            this.wt = a;
        }
        ax(a) {
            if (a != null && a == this.ww && this.w3 != null) {
                return new AxisRange(this.w3.minimum, this.w3.maximum);
            }
            if (a != null && a == this.wy && this.w5 != null) {
                return new AxisRange(this.w5.minimum, this.w5.maximum);
            }
            return null;
        }
        sj(a, b) {
            if (this.c9 != null) {
                let c = this.getEffectiveViewport1(this.ct);
                this.w7 = !c.isEmpty;
            }
            this.rm(false);
        }
        sk(a, b) {
            this.rm(false);
        }
        kl(a) {
            if (!this.w8 || this._itemIndexes == null || this.c9 == null || this.dl == null || this._itemIndexes.length != (this.yc * this.yb)) {
                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.wk.left + (this.wk.width * c)));
            let f = truncate(Math.round(this.wk.top + (this.wk.height * d)));
            let g = this.yl(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);
        }
        yl(a, b) {
            let c = (this.yc * b) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            let d = 1;
            c = (this.yc * (b - d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yc * (b + d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yc * (b)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yc * (b)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yc * (b - d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yc * (b + d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yc * (b - d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yc * (b + d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            return 0;
        }
        zn(a, b, c) {
            this.wr = a;
            this.yc = b;
            this.yb = c;
        }
        get_g5() {
            return true;
        }
        set_g5(a) {
            super.set_g5(a);
        }
        o2(a, b) {
            super.o2(a, b);
            this.wt.ca();
            if (this.cs != null) {
                this.cs.ca();
            }
            this.qg();
        }
        ro(a, b) {
            super.ro(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.ze(false, c);
            this.gy = false;
        }
        rl(a, b, c, d, e) {
            super.rl(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.w1 == null) {
                this.w1 = new ScatterFrame();
            }
            this.ze(false, f);
        }
        oz() {
            super.oz();
            this.ww = null;
            this.wy = null;
        }
    }
    HighDensityScatterSeries.$t = /*@__PURE__*/ markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:z4:zp', [Color.$, Defaults.ap], 'HeatMaximum:x6:zq', [1, 50], 'HeatMinimumColor:z5:zr', [Color.$, Defaults.aq], 'HeatMinimum:x7:zs', [1, 0], 'PointExtent:yj:zt', [1, 1], 'ProgressiveLoad:xb:zu', [0, true], 'UseBruteForce:xc:zv', [0, false], 'XAxis:ww:zw', [NumericXAxis.$, null], 'XMemberAsLegendLabel:yv:zx', [2, null], 'XMemberAsLegendUnit:yx:zy', [2, null], 'XMemberPath:yz:zz', [2, null], 'YAxis:wy:z0', [NumericYAxis.$, null], 'YMemberAsLegendLabel:y3:z1', [2, null], 'YMemberAsLegendUnit:y5:z2', [2, null], 'YMemberPath:y7:z3', [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.z5 = Defaults.aq;
                this.b2.z4 = Defaults.ap;
                this.b2.u8 = Defaults.al;
                this.b2.vo = Defaults.ak;
            }
        }
        cd() {
            this.b2.zn(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.zn(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;
})();
