/*
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-angular-core";
import { NumericYAxis } from "./NumericYAxis";
import { Color } from "igniteui-angular-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-angular-core";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { TestRandomness } from "igniteui-angular-core";
import { DefaultRandomnessSource } from "igniteui-angular-core";
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-angular-core";
import { truncate, isNaN_, isInfinity, logBase, intDivide } from "igniteui-angular-core";
import { boxArray$1, arrayShallowClone } from "igniteui-angular-core";
import { dateNow } from "igniteui-angular-core";
import { RenderingContext } from "igniteui-angular-core";
import { CanvasViewRenderer } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
/**
 * @hidden
 */
export let HighDensityScatterSeries = /*@__PURE__*/ (() => {
    class HighDensityScatterSeries extends Series {
        constructor() {
            super();
            this.xb = null;
            this.xd = null;
            this.yn = 0;
            this.xg = false;
            this.x2 = Defaults.aq.o;
            this.x1 = Defaults.aq.n;
            this.x0 = Defaults.aq.m;
            this.xz = Defaults.aq.l;
            this.xy = Defaults.ap.o;
            this.xx = Defaults.ap.n;
            this.xw = Defaults.ap.m;
            this.xv = Defaults.ap.l;
            this.w3 = null;
            this.w8 = null;
            this.w9 = null;
            this.w4 = null;
            this.w6 = null;
            this.xi = false;
            this.yo = 0;
            this.yq = 0;
            this.yk = 0;
            this.yj = 0;
            this.progressiveLoadStatusChanged = null;
            this.xn = null;
            this.xt = 0;
            this.xs = 0;
            this.xu = 0;
            this.x9 = 0;
            this.x7 = 0;
            this.x8 = 0;
            this.ya = 0;
            this.yc = 0;
            this.ye = 0;
            this.yd = 0;
            this.yb = 0;
            this.xp = 0;
            this.xq = 0;
            this.xr = 0;
            this.xo = 0;
            this.ym = 0;
            this.yl = 0;
            this.w0 = null;
            this.yp = 0;
            this.xh = false;
            this._itemIndexes = null;
            this.w1 = null;
            this.wy = null;
            this.xa = null;
            this.ab = HighDensityScatterSeries.$;
            this.f8 = false;
        }
        bj() {
            return new HighDensityScatterSeries();
        }
        get_fo() {
            return true;
        }
        jk() {
            if (!isNaN_(this.jj)) {
                return super.jk();
            }
            return Defaults.q;
        }
        get_fw() {
            return true;
        }
        get xc() {
            return this.xb;
        }
        set xc(a) {
            if (this.xb != a) {
                let b = this.xc;
                this.xb = a;
                this.raisePropertyChanged("XColumn", b, this.xc);
            }
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.kn(c);
            let e = d == null ? NaN : this.ix(d, "XMemberPath");
            let f = d == null ? NaN : this.ix(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.q = "X";
            g.r = this.y9 != null ? this.y9 : "X";
            g.s = this.y5 != null ? this.y5 : "X:";
            g.t = this.y7 != null ? this.y7 : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.q = "Y";
            h.r = this.zh != null ? this.zh : "Y";
            h.s = this.zd != null ? this.zd : "Y:";
            h.t = this.zf != null ? this.zf : "";
            let i = new DataLegendSeriesContext();
            i.e = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.h = this.mc();
            return i;
        }
        kq(a, b) {
            let c = this.nd(b);
            if (c == HighDensityScatterSeries.$$p[10]) {
                return this.kr(a, b, this.y9);
            }
            if (c == HighDensityScatterSeries.$$p[14]) {
                return this.kr(a, b, this.zh);
            }
            return super.kq(a, b);
        }
        md(a) {
            let b = this.nd(a);
            if (b == HighDensityScatterSeries.$$p[10]) {
                return this.y9;
            }
            if (b == HighDensityScatterSeries.$$p[14]) {
                return this.zh;
            }
            return super.md(a);
        }
        get xe() {
            return this.xd;
        }
        set xe(a) {
            if (this.xd != a) {
                let b = this.xe;
                this.xd = a;
                this.raisePropertyChanged("YColumn", b, this.xe);
            }
        }
        zw() {
            if (this.w3 == null) {
                return;
            }
            this.w3.t();
            let a = this.w3;
            a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.zj));
            this.w3 = null;
        }
        q9(a, b, c, d) {
            super.q9(a, b, c, d);
            switch (b) {
                case HighDensityScatterSeries.$$p[8]:
                case HighDensityScatterSeries.$$p[12]:
                case HighDensityScatterSeries.$$p[9]:
                case HighDensityScatterSeries.$$p[13]:
                    this.qf();
                    break;
                case "SeriesViewer":
                    if (this.db != null) {
                        let e = this.getEffectiveViewport1(this.cv);
                        this.xh = !e.isEmpty;
                    }
                    break;
                case "FastItemsSource":
                    this.zw();
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.xc);
                        c.deregisterColumn(this.xe);
                        this.xc = null;
                        this.xe = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.xc = this.dk(this.y9);
                        this.xe = this.dk(this.zh);
                    }
                    if ((this.w7 != null && !this.w7.c1()) || (this.w5 != null && !this.w5.c1())) {
                        this.rr(this.gg && c != null);
                    }
                    this.qm();
                    break;
                case HighDensityScatterSeries.$$p[7]:
                    let f = this.w4;
                    this.w4 = this.w5;
                    this.zw();
                    if (f != null) {
                        f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.zm));
                    }
                    if (this.w4 != null) {
                        let g = this.w4;
                        g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.zm));
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if ((this.w5 != null && !this.w5.c1()) || (d == null && c != null)) {
                        this.rr(false);
                    }
                    break;
                case HighDensityScatterSeries.$$p[11]:
                    let h = this.w6;
                    this.w6 = this.w7;
                    this.zw();
                    if (h != null) {
                        h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.zm));
                    }
                    if (this.w6 != null) {
                        let i = this.w6;
                        i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.zm));
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if ((this.w7 != null && !this.w7.c1()) || (d == null && c != null)) {
                        this.rr(false);
                    }
                    break;
                case "MouseOverEnabled":
                    this.xi = this.f8;
                    this.rr(false);
                    break;
                case HighDensityScatterSeries.$$p[10]:
                    if (this.dn != null) {
                        this.dn.deregisterColumn(this.xc);
                        this.xc = this.dk(this.y9);
                    }
                    break;
                case "XColumn":
                    this.zw();
                    if (this.w5 != null && !this.w5.c1()) {
                        this.rr(false);
                    }
                    this.qm();
                    break;
                case HighDensityScatterSeries.$$p[14]:
                    if (this.dn != null) {
                        this.dn.deregisterColumn(this.xe);
                        this.xe = this.dk(this.zh);
                    }
                    break;
                case "YColumn":
                    this.zw();
                    if (this.w7 != null && !this.w7.c1()) {
                        this.rr(false);
                    }
                    this.qm();
                    break;
                case HighDensityScatterSeries.$$p[6]:
                    this.zw();
                    this.rr(false);
                    this.ql();
                    break;
                case HighDensityScatterSeries.$$p[3]:
                    this.rr(false);
                    this.ql();
                    break;
                case HighDensityScatterSeries.$$p[1]:
                    this.rr(false);
                    this.ql();
                    break;
                case HighDensityScatterSeries.$$p[0]:
                case HighDensityScatterSeries.$$p[2]:
                    if (!this.w2.b4(this.aaf, this.aae)) {
                        return;
                    }
                    this.zq();
                    this.rr(false);
                    this.ql();
                    break;
                case HighDensityScatterSeries.$$p[4]:
                    this.yn = Math.max(typeGetValue(d) - 1, 0);
                    this.xg = this.yn > 0;
                    this.rr(false);
                    this.ql();
                    break;
                case HighDensityScatterSeries.$$p[5]:
                    this.rr(false);
                    this.ql();
                    break;
            }
        }
        zq() {
            this.xz = this.aaf.l;
            this.x2 = this.aaf.o;
            this.x1 = this.aaf.n;
            this.x0 = this.aaf.m;
            this.xv = this.aae.l;
            this.xy = this.aae.o;
            this.xx = this.aae.n;
            this.xw = this.aae.m;
            this.vv = BrushUtil.h(truncate(this.xz), truncate(this.x2), truncate(this.x1), truncate(this.x0));
            this.vf = BrushUtil.h(truncate(this.xv), truncate(this.xy), truncate(this.xx), truncate(this.xw));
        }
        xk(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        xj(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        zm(a, b) {
            this.zw();
            this.rr(false);
        }
        get x6() {
            return this.xy - this.x2;
        }
        get x5() {
            return this.xx - this.x1;
        }
        get x4() {
            return this.xw - this.x0;
        }
        get x3() {
            return this.xv - this.xz;
        }
        he(a, b, c) {
            let d = super.he(a, b, c);
            if (this.w7 == null || this.w5 == null || this.w5.bi == null || this.w7.bi == null || this.xe == null || this.xc == null || this.xe.count < 1 || this.xc.count < 1 || this.xe.count != this.xc.count || this.w5.l4 == this.w5.l3 || this.w7.l4 == this.w7.l3 || this.ws.isEmpty) {
                d = false;
            }
            return d;
        }
        get yu() {
            return this.yo;
        }
        set yu(a) {
            let b = this.yo;
            this.yo = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.yo);
        }
        rs(a) {
            super.rs(a);
            this.zo(a, this.cv);
        }
        xf() {
            if (TestRandomness.instance.testRandomnessSource != null) {
                return TestRandomness.instance.testRandomnessSource;
            }
            return new DefaultRandomnessSource(0);
        }
        zo(a, b) {
            if (this.d5(b)) {
                return;
            }
            if (this.w3 == null && !this.xm) {
                let c = new List$1(KDPointData.$, 2, this.xc.count);
                let d = this.w5;
                let e = this.w7;
                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.xc.count; l++) {
                    j = d.el(this.xc.item(l), h);
                    k = e.el(this.xe.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.xl) {
                    this.yj = 1;
                    this.yk = truncate(logBase(c.count, 2)) + 3;
                    this.yu = truncate(((this.yj / this.yk) * 100));
                    if (this.progressiveLoadStatusChanged != null) {
                        this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yu));
                    }
                    this.w3 = KDTree2D.b(c.toArray(), 1, this.xf());
                    let m = this.w3;
                    m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.zj));
                    if (!this.w3.h(this.jz)) {
                        let n = this.w3;
                        n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.zj));
                    }
                    this.ql();
                }
                else {
                    let o = dateNow();
                    this.w3 = new KDTree2D(0, c.toArray(), 1, this.xf());
                    let p = dateNow();
                }
            }
            if (this.xl && !this.xm) {
                this.zp(b);
            }
            else {
                this.zr(b);
            }
        }
        pb(a, b, c, d) {
            super.pb(a, b, c, d);
            this.zw();
            let e = false;
            if (this.w5 != null && !this.w5.c1()) {
                e = true;
            }
            if (this.w7 != null && !this.w7.c1()) {
                e = true;
            }
            if (e) {
                this.rr(false);
            }
            this.qm();
        }
        zl(a) {
            let b = a;
            let c = this.ym * this.yl;
            if (this.xi) {
                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;
                    }
                }
            }
        }
        zr(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.w8 = new ScalerParams(0, b, c, this.w4.ch, g);
            this.w9 = new ScalerParams(0, b, c, this.w6.ch, g);
            this.zk(a);
            this.zl(a);
            let h = this.ym * this.yl;
            if (this.w1 == null || this.w1.length != h) {
                this.w1 = new Array(h);
                this.wy = new Array(h);
            }
            let i = this.w1.length;
            let j = this.w1;
            let k = this.wy;
            for (let l = 0; l < i; l++) {
                j[l] = 0;
                k[l] = 0;
            }
            this.yq = truncate(Math.round(this.id));
            this.w0 = f.b1();
            let m = this.w0.length;
            let n = this.w0;
            for (let o = 0; o < m; o++) {
                n[o] = 0;
            }
            let p = this.yh;
            let q = this.yg;
            if (isNaN_(p) || isInfinity(p)) {
                p = 0;
            }
            if (isNaN_(q) || isInfinity(q)) {
                q = 50;
            }
            this.xt = Math.min(p, q);
            this.xs = Math.max(p, q);
            if (this.xt < 0) {
                this.xt = 0;
            }
            if (this.xs < 0) {
                this.xs = 0;
            }
            this.xu = this.xs - this.xt;
            if (this.xm) {
                this.zn(a);
            }
            else {
                this.zy(a);
            }
            f.cc();
            if (a.q) {
                this._itemIndexes = d;
                this.w2.cd();
            }
        }
        zp(a) {
            if (this.w3 == null) {
                return;
            }
            this.zr(a);
        }
        zj(a, b) {
            this.w2.cb(() => {
                if (this.yj < this.yk - 1) {
                    this.yj++;
                }
                this.yu = truncate(((this.yj / this.yk) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yu));
                }
                this.zp(this.cv);
                this.ql();
                if (this.w3 != null) {
                    if (!this.w3.h(this.jz)) {
                        let c = this.w3;
                        c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(this, this.zj));
                        this.yu = 100;
                        if (this.progressiveLoadStatusChanged != null) {
                            this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yu));
                        }
                    }
                }
            });
        }
        zn(a) {
            let b = arrayShallowClone(this.xc.asArray());
            this.w5.hq(boxArray$1(b), 0, b.length, this.w8);
            let c = arrayShallowClone(this.xe.asArray());
            this.yp = 0;
            let d = this.yn;
            let e = this.xg;
            let f = this.w1.length;
            this.w7.hq(boxArray$1(c), 0, c.length, this.w9);
            let g = 255 << 24 | truncate(this.x2) << 16 | truncate(this.x1) << 8 | truncate(this.x0);
            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.ym || j < 0 || j >= this.yl) {
                    continue;
                }
                if (e) {
                    let k = i - d;
                    let l = i + d;
                    l = l > (this.ym - 1) ? (this.ym - 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.ym) + o;
                            if (q < 0 || q > f - 1) {
                                continue;
                            }
                            this.w1[q] = this.w1[q] + 1;
                            this.wy[q] = 1;
                            this.yp++;
                            if (this.xi) {
                                this._itemIndexes[q] = h + 1;
                            }
                        }
                    }
                }
                else {
                    let r = (j * this.ym) + i;
                    this.w1[r] = this.w1[r] + 1;
                    this.wy[r] = 1;
                    this.yp++;
                    if (this.xi) {
                        this._itemIndexes[r] = h + 1;
                    }
                }
            }
            this.zs();
        }
        zy(a) {
            let b;
            let c;
            let d = a.getViewInfo(b, c);
            b = d.p0;
            c = d.p1;
            if (this.w3 == null) {
                return;
            }
            if (this.xn == null) {
                this.xn = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
            }
            else {
                this.xn.clear();
            }
            let e = c.left;
            let f = c.right;
            let g = c.top;
            let h = c.bottom;
            this.yd = c.top;
            this.yb = c.height;
            this.yc = c.left;
            this.ye = c.width;
            this.x9 = b.top;
            this.x7 = b.height;
            this.x8 = b.left;
            this.ya = b.width;
            let i = this.getEffectiveViewport1(a);
            this.xp = (i.left - this.x8) / this.ya;
            this.xq = (i.top - this.x9) / this.x7;
            let j = (i.right - this.x8) / this.ya;
            this.xr = j - this.xp;
            let k = (i.bottom - this.x9) / this.x7;
            this.xo = k - this.xq;
            if (this.xh) {
                e = (e - this.xp) / this.xr;
                f = (f - this.xp) / this.xr;
                g = (g - this.xq) / this.xo;
                h = (h - this.xq) / this.xo;
            }
            let l = this.id / b.width * c.width;
            let m = this.id / 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.w3.u(this.xn, o, 0, 1, 0, 1);
            let p;
            this.yp = 0;
            for (let q = 0; q < this.xn.count; q++) {
                p = this.xn._inner[q];
                this.zt(p);
            }
            this.zs();
        }
        zt(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.zv(a.b, d, b, a.e);
            if (c > 0 && !b) {
                let e;
                for (let f = 0; f < c; f++) {
                    e = a.a[f];
                    this.zv(e, d, false, a.e);
                }
            }
            if (a.e != null) {
                a.e.a = false;
            }
        }
        gd(a) {
            let b = this.db != null ? this.db.v4 : Rect.empty;
            let c = this.db != null ? this.db.wk : Rect.empty;
            let d = new Rect(0, 0, 0, 1, 1);
            let e = this.wl(this.cv);
            let f = new ScalerParams(0, d, d, this.w5.ch, e);
            let g = new ScalerParams(0, d, d, this.w7.ch, e);
            let h = !b.isEmpty && !c.isEmpty && this.dn != null ? this.dn.indexOf(a) : -1;
            let i = this.w5 != null && this.xc != null && h < this.xc.count ? this.w5.el(this.xc.item(h), f) : NaN;
            let j = this.w7 != null && this.xe != null && h < this.xe.count ? this.w7.el(this.xe.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.c3 != null) {
                this.c3.au(this.db, b, true);
            }
            return h >= 0;
        }
        zv(a, b, c, d) {
            let e = this.ys(b);
            let f = a.c;
            let g = this.yn;
            if (c) {
                let h = d.d;
                let i = d.b;
                let j = d.e;
                let k = d.c;
                if (this.xh) {
                    h = this.xp + this.xr * h;
                    i = this.xp + this.xr * i;
                    j = this.xq + this.xo * j;
                    k = this.xq + this.xo * k;
                }
                let l = truncate((this.x8 + this.ya * (h - this.yc) / this.ye));
                let m = truncate((this.x8 + this.ya * (i - this.yc) / this.ye));
                let n = truncate((this.x9 + this.x7 * (j - this.yd) / this.yb));
                let o = truncate((this.x9 + this.x7 * (k - this.yd) / this.yb));
                l = truncate(Math.floor(l));
                m = truncate(Math.floor(m));
                n = truncate(Math.floor(n));
                o = truncate(Math.floor(o));
                if (this.xg) {
                    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.zu(f, s, t, q, r);
                    }
                }
            }
            else {
                let u = a.a;
                let v = a.b;
                if (this.xh) {
                    u = this.xp + this.xr * u;
                    v = this.xq + this.xo * v;
                }
                let w = truncate((this.x8 + this.ya * (u - this.yc) / this.ye));
                let x = truncate((this.x9 + this.x7 * (v - this.yd) / this.yb));
                w = truncate(Math.floor(w));
                x = truncate(Math.floor(x));
                if (this.xg) {
                    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.zu(f, af, ag, ad, ae);
                        }
                    }
                }
                else {
                    this.zu(f, w, x, b, 1);
                }
            }
        }
        yr(a, b) {
            return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.x2 + a * this.x6))) << 16 | truncate(Math.floor(b * (this.x1 + a * this.x5))) << 8 | truncate(Math.floor(b * (this.x0 + a * this.x4)));
        }
        ys(a) {
            return 255 << 24 | truncate(Math.floor((this.x2 + a * this.x6))) << 16 | truncate(Math.floor((this.x1 + a * this.x5))) << 8 | truncate(Math.floor((this.x0 + a * this.x4)));
        }
        yf(a) {
            return (a >> 24 & 255) / 255;
        }
        zu(a, b, c, d, e) {
            if (b < 0 || b >= this.ym || c < 0 || c >= this.yl) {
                return;
            }
            let f = (c * this.ym) + b;
            this.w1[f] = this.w1[f] + d;
            this.wy[f] = this.wy[f] + e;
            if (this.xi) {
                this._itemIndexes[f] = a + 1;
            }
            this.yp += truncate(d);
        }
        zs() {
            let a = 0;
            let b = 0;
            let c = this.xu;
            let d = this.xt;
            let e = this.xs;
            let f = this.w1.length;
            let g = this.w1;
            let h = this.wy;
            let i = this.w0;
            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.yr(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;
            }
        }
        zk(a) {
            let b = a;
            b.b9();
        }
        cs() {
            return new HighDensityScatterSeriesView(this);
        }
        q1(a) {
            super.q1(a);
            this.w2 = a;
        }
        ay(a) {
            if (a != null && a == this.w5 && this.xc != null) {
                return new AxisRange(this.xc.minimum, this.xc.maximum);
            }
            if (a != null && a == this.w7 && this.xe != null) {
                return new AxisRange(this.xe.minimum, this.xe.maximum);
            }
            return null;
        }
        sq(a, b) {
            if (this.db != null) {
                let c = this.getEffectiveViewport1(this.cv);
                this.xh = !c.isEmpty;
            }
            this.rr(false);
        }
        sr(a, b) {
            this.rr(false);
        }
        kn(a) {
            if (!this.xi || this._itemIndexes == null || this.db == null || this.dn == null || this._itemIndexes.length != (this.ym * this.yl)) {
                return null;
            }
            let b = this.db.v4;
            let c = (a.x - b.left) / b.width;
            let d = (a.y - b.top) / b.height;
            let e = truncate(Math.round(this.ws.left + (this.ws.width * c)));
            let f = truncate(Math.round(this.ws.top + (this.ws.height * d)));
            let g = this.yv(e, f);
            if (g < 0 || g > this._itemIndexes.length - 1) {
                return null;
            }
            let h = this._itemIndexes[g] - 1;
            if (h < 0 || h > this.dn.count) {
                return null;
            }
            return this.dn.item(h);
        }
        yv(a, b) {
            let c = (this.ym * b) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            let d = 1;
            c = (this.ym * (b - d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.ym * (b + d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.ym * (b)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.ym * (b)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.ym * (b - d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.ym * (b + d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.ym * (b - d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.ym * (b + d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            return 0;
        }
        zx(a, b, c) {
            this.w0 = a;
            this.ym = b;
            this.yl = c;
        }
        get_g7() {
            return true;
        }
        set_g7(a) {
            super.set_g7(a);
        }
        o5(a, b) {
            super.o5(a, b);
            this.w2.ca();
            if (this.cu != null) {
                this.cu.ca();
            }
            this.ql();
        }
        rt(a, b) {
            super.rt(a, b);
            if (!this.g0) {
                this.cv.a4(b);
                return;
            }
            this.cv.a4(b);
            if (this.d5(this.cu)) {
                return;
            }
            let c = typeCast(HighDensityScatterSeriesView.$, this.cu);
            let d = new ScatterFrame();
            this.zo(false, c);
            this.g0 = false;
        }
        rq(a, b, c, d, e) {
            super.rq(a, b, c, d, e);
            let f = this.ba.a$j.item(d);
            let g = f;
            f.a3(c);
            if (this.d5(g)) {
                return;
            }
            if (this.xa == null) {
                this.xa = new ScatterFrame();
            }
            this.zo(false, f);
        }
        o2() {
            super.o2();
            this.w5 = null;
            this.w7 = null;
        }
    }
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:aae:zz', [Color.$, Defaults.ap], 'HeatMaximum:yg:z0', [1, 50], 'HeatMinimumColor:aaf:z1', [Color.$, Defaults.aq], 'HeatMinimum:yh:z2', [1, 0], 'PointExtent:yt:z3', [1, 1], 'ProgressiveLoad:xl:z4', [0, true], 'UseBruteForce:xm:z5', [0, false], 'XAxis:w5:z6', [NumericXAxis.$, null], 'XMemberAsLegendLabel:y5:z7', [2, null], 'XMemberAsLegendUnit:y7:z8', [2, null], 'XMemberPath:y9:z9', [2, null], 'YAxis:w7:aaa', [NumericYAxis.$, null], 'YMemberAsLegendLabel:zd:aab', [2, null], 'YMemberAsLegendUnit:zf:aac', [2, null], 'YMemberPath:zh:aad', [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.aaf = Defaults.aq;
                this.b2.aae = Defaults.ap;
                this.b2.vf = Defaults.al;
                this.b2.vv = Defaults.ak;
            }
        }
        cd() {
            this.b2.zx(this.b0, this.b8, this.b7);
        }
        b9() {
            if (this.b5 == null) {
                this.b5 = this.e.jz.createElement("canvas");
                let a = this.e.jz.get2DCanvasContext(this.b5);
                this.b3 = new RenderingContext(new CanvasViewRenderer(), a);
            }
            let b;
            if (this.p) {
                b = this.bx;
            }
            else {
                b = this.e.db.v9();
            }
            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.zx(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.jz != null) {
                this.e.jz.setTimeout(a, 0);
            }
            else {
                window.setTimeout(a, 0);
            }
        }
        a8(a, b) {
            super.a8(a, b);
            if (b) {
                if (!this.b2.f8) {
                    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.bc.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.bc.exportSeriesPixelsData(a, b, this.b8, this.b7);
        }
    }
    HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
})();
