/*
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 { 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.ql = null;
            this.qn = null;
            this.rw = 0;
            this.qp = false;
            this.rb = Defaults.aq.o;
            this.ra = Defaults.aq.n;
            this.q9 = Defaults.aq.m;
            this.q8 = Defaults.aq.l;
            this.q7 = Defaults.ap.o;
            this.q6 = Defaults.ap.n;
            this.q5 = Defaults.ap.m;
            this.q4 = Defaults.ap.l;
            this.qd = null;
            this.qi = null;
            this.qj = null;
            this.qe = null;
            this.qg = null;
            this.qr = false;
            this.rx = 0;
            this.rz = 0;
            this.rt = 0;
            this.rs = 0;
            this.progressiveLoadStatusChanged = null;
            this.qw = null;
            this.q2 = 0;
            this.q1 = 0;
            this.q3 = 0;
            this.ri = 0;
            this.rg = 0;
            this.rh = 0;
            this.rj = 0;
            this.rl = 0;
            this.rn = 0;
            this.rm = 0;
            this.rk = 0;
            this.qy = 0;
            this.qz = 0;
            this.q0 = 0;
            this.qx = 0;
            this.rv = 0;
            this.ru = 0;
            this.qa = null;
            this.ry = 0;
            this.qq = false;
            this._itemIndexes = null;
            this.qb = null;
            this.p8 = null;
            this.qk = null;
            this.ab = HighDensityScatterSeries.$;
            this.em = false;
        }
        get_d6() {
            return true;
        }
        gw() {
            if (!isNaN_(this.gv)) {
                return super.gw();
            }
            return Defaults.q;
        }
        get_ed() {
            return true;
        }
        get qm() {
            return this.ql;
        }
        set qm(a) {
            if (this.ql != a) {
                let b = this.qm;
                this.ql = a;
                this.raisePropertyChanged("XColumn", b, this.qm);
            }
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.hv(c);
            let e = d == null ? NaN : this.gd(d, "XMemberPath");
            let f = d == null ? NaN : this.gd(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.p = "X";
            g.q = this.si != null ? this.si : "X";
            g.r = this.se != null ? this.se : "X:";
            g.s = this.sg != null ? this.sg : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.p = "Y";
            h.q = this.sq != null ? this.sq : "Y";
            h.r = this.sm != null ? this.sm : "Y:";
            h.s = this.so != null ? this.so : "";
            let i = new DataLegendSeriesContext();
            i.f = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.b = this.av();
            return i;
        }
        hy(a, b) {
            let c = this.js(b);
            if (c == HighDensityScatterSeries.$$p[10]) {
                return this.hz(a, b, this.si);
            }
            if (c == HighDensityScatterSeries.$$p[14]) {
                return this.hz(a, b, this.sq);
            }
            return super.hy(a, b);
        }
        get qo() {
            return this.qn;
        }
        set qo(a) {
            if (this.qn != a) {
                let b = this.qo;
                this.qn = a;
                this.raisePropertyChanged("YColumn", b, this.qo);
            }
        }
        s5() {
            if (this.qd == null) {
                return;
            }
            this.qd.s();
            let a = this.qd;
            a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.ss));
            this.qd = null;
        }
        l7(a, b, c, d) {
            super.l7(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    if (this.cd != null) {
                        let e = this.getEffectiveViewport1(this.b0);
                        this.qq = !e.isEmpty;
                    }
                    break;
                case "FastItemsSource":
                    this.s5();
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.qm);
                        c.deregisterColumn(this.qo);
                        this.qm = null;
                        this.qo = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.qm = this.ch(this.si);
                        this.qo = this.ch(this.sq);
                    }
                    if ((this.qh != null && !this.qh.c0()) || (this.qf != null && !this.qf.c0())) {
                        this.ml(false);
                    }
                    this.lt();
                    break;
                case HighDensityScatterSeries.$$p[7]:
                    let f = this.qe;
                    this.qe = this.qf;
                    this.s5();
                    if (f != null) {
                        f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.sv));
                    }
                    if (this.qe != null) {
                        let g = this.qe;
                        g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.sv));
                    }
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    if ((this.qf != null && !this.qf.c0()) || (d == null && c != null)) {
                        this.ml(false);
                    }
                    break;
                case HighDensityScatterSeries.$$p[11]:
                    let h = this.qg;
                    this.qg = this.qh;
                    this.s5();
                    if (h != null) {
                        h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.sv));
                    }
                    if (this.qg != null) {
                        let i = this.qg;
                        i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.sv));
                    }
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    if ((this.qh != null && !this.qh.c0()) || (d == null && c != null)) {
                        this.ml(false);
                    }
                    break;
                case "MouseOverEnabled":
                    this.qr = this.em;
                    this.ml(false);
                    break;
                case HighDensityScatterSeries.$$p[10]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.qm);
                        this.qm = this.ch(this.si);
                    }
                    break;
                case "XColumn":
                    this.s5();
                    if (this.qf != null && !this.qf.c0()) {
                        this.ml(false);
                    }
                    this.lt();
                    break;
                case HighDensityScatterSeries.$$p[14]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.qo);
                        this.qo = this.ch(this.sq);
                    }
                    break;
                case "YColumn":
                    this.s5();
                    if (this.qh != null && !this.qh.c0()) {
                        this.ml(false);
                    }
                    this.lt();
                    break;
                case HighDensityScatterSeries.$$p[6]:
                    this.s5();
                    this.ml(false);
                    this.ls();
                    break;
                case HighDensityScatterSeries.$$p[3]:
                    this.ml(false);
                    this.ls();
                    break;
                case HighDensityScatterSeries.$$p[1]:
                    this.ml(false);
                    this.ls();
                    break;
                case HighDensityScatterSeries.$$p[0]:
                case HighDensityScatterSeries.$$p[2]:
                    if (!this.qc.b1(this.to, this.tn)) {
                        return;
                    }
                    this.sz();
                    this.ml(false);
                    this.ls();
                    break;
                case HighDensityScatterSeries.$$p[4]:
                    this.rw = Math.max(typeGetValue(d) - 1, 0);
                    this.qp = this.rw > 0;
                    this.ml(false);
                    this.ls();
                    break;
                case HighDensityScatterSeries.$$p[5]:
                    this.ml(false);
                    this.ls();
                    break;
            }
        }
        sz() {
            this.q8 = this.to.l;
            this.rb = this.to.o;
            this.ra = this.to.n;
            this.q9 = this.to.m;
            this.q4 = this.tn.l;
            this.q7 = this.tn.o;
            this.q6 = this.tn.n;
            this.q5 = this.tn.m;
            this.pc = BrushUtil.g(truncate(this.q8), truncate(this.rb), truncate(this.ra), truncate(this.q9));
            this.o7 = BrushUtil.g(truncate(this.q4), truncate(this.q7), truncate(this.q6), truncate(this.q5));
        }
        qt(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        qs(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        sv(a, b) {
            this.s5();
            this.ml(false);
        }
        get rf() {
            return this.q7 - this.rb;
        }
        get re() {
            return this.q6 - this.ra;
        }
        get rd() {
            return this.q5 - this.q9;
        }
        get rc() {
            return this.q4 - this.q8;
        }
        fb(a, b, c) {
            let d = super.fb(a, b, c);
            if (this.qh == null || this.qf == null || this.qf.bh == null || this.qh.bh == null || this.qo == null || this.qm == null || this.qo.count < 1 || this.qm.count < 1 || this.qo.count != this.qm.count || this.qf.lv == this.qf.lu || this.qh.lv == this.qh.lu || this.p3.isEmpty) {
                d = false;
            }
            return d;
        }
        get r3() {
            return this.rx;
        }
        set r3(a) {
            let b = this.rx;
            this.rx = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.rx);
        }
        mm(a) {
            super.mm(a);
            this.sx(a, this.b0);
        }
        sx(a, b) {
            if (this.cx(b)) {
                return;
            }
            if (this.qd == null && !this.qv) {
                let c = new List$1(KDPointData.$, 2, this.qm.count);
                let d = this.qf;
                let e = this.qh;
                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.cg);
                let i = new ScalerParams(1, f, g, e.cg);
                let j;
                let k;
                for (let l = 0; l < this.qm.count; l++) {
                    j = d.ei(this.qm.item(l), h);
                    k = e.ei(this.qo.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.qu) {
                    this.rs = 1;
                    this.rt = truncate(logBase(c.count, 2)) + 3;
                    this.r3 = truncate(((this.rs / this.rt) * 100));
                    if (this.progressiveLoadStatusChanged != null) {
                        this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.r3));
                    }
                    this.qd = KDTree2D.b(c.toArray(), 1);
                    let m = this.qd;
                    m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.ss));
                    if (!this.qd.f(this.hb)) {
                        let n = this.qd;
                        n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.ss));
                    }
                    this.ls();
                }
                else {
                    let o = dateNow();
                    this.qd = new KDTree2D(0, c.toArray(), 1);
                    let p = dateNow();
                }
            }
            if (this.qu && !this.qv) {
                this.sy(b);
            }
            else {
                this.s0(b);
            }
        }
        k3(a, b, c, d) {
            super.k3(a, b, c, d);
            this.s5();
            let e = false;
            if (this.qf != null && !this.qf.c0()) {
                e = true;
            }
            if (this.qh != null && !this.qh.c0()) {
                e = true;
            }
            if (e) {
                this.ml(false);
            }
            this.lt();
        }
        su(a) {
            let b = a;
            let c = this.rv * this.ru;
            if (this.qr) {
                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;
                    }
                }
            }
        }
        s0(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.qi = new ScalerParams(0, b, c, this.qe.cg, g);
            this.qj = new ScalerParams(0, b, c, this.qg.cg, g);
            this.st(a);
            this.su(a);
            let h = this.rv * this.ru;
            if (this.qb == null || this.qb.length != h) {
                this.qb = new Array(h);
                this.p8 = new Array(h);
            }
            let i = this.qb.length;
            let j = this.qb;
            let k = this.p8;
            for (let l = 0; l < i; l++) {
                j[l] = 0;
                k[l] = 0;
            }
            this.rz = truncate(Math.round(this.fv));
            this.qa = f.by();
            let m = this.qa.length;
            let n = this.qa;
            for (let o = 0; o < m; o++) {
                n[o] = 0;
            }
            let p = this.rq;
            let q = this.rp;
            if (isNaN_(p) || isInfinity(p)) {
                p = 0;
            }
            if (isNaN_(q) || isInfinity(q)) {
                q = 50;
            }
            this.q2 = Math.min(p, q);
            this.q1 = Math.max(p, q);
            if (this.q2 < 0) {
                this.q2 = 0;
            }
            if (this.q1 < 0) {
                this.q1 = 0;
            }
            this.q3 = this.q1 - this.q2;
            if (this.qv) {
                this.sw(a);
            }
            else {
                this.s7(a);
            }
            f.b9();
            if (a.q) {
                this._itemIndexes = d;
                this.qc.ca();
            }
        }
        sy(a) {
            if (this.qd == null) {
                return;
            }
            this.s0(a);
        }
        ss(a, b) {
            this.qc.b8(() => {
                if (this.rs < this.rt - 1) {
                    this.rs++;
                }
                this.r3 = truncate(((this.rs / this.rt) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.r3));
                }
                this.sy(this.b0);
                this.ls();
                if (this.qd != null) {
                    if (!this.qd.f(this.hb)) {
                        let c = this.qd;
                        c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(this, this.ss));
                        this.r3 = 100;
                        if (this.progressiveLoadStatusChanged != null) {
                            this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.r3));
                        }
                    }
                }
            });
        }
        sw(a) {
            let b = arrayShallowClone(this.qm.asArray());
            this.qf.hm(boxArray$1(b), 0, b.length, this.qi);
            let c = arrayShallowClone(this.qo.asArray());
            this.ry = 0;
            let d = this.rw;
            let e = this.qp;
            let f = this.qb.length;
            this.qh.hm(boxArray$1(c), 0, c.length, this.qj);
            let g = 255 << 24 | truncate(this.rb) << 16 | truncate(this.ra) << 8 | truncate(this.q9);
            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.rv || j < 0 || j >= this.ru) {
                    continue;
                }
                if (e) {
                    let k = i - d;
                    let l = i + d;
                    l = l > (this.rv - 1) ? (this.rv - 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.rv) + o;
                            if (q < 0 || q > f - 1) {
                                continue;
                            }
                            this.qb[q] = this.qb[q] + 1;
                            this.p8[q] = 1;
                            this.ry++;
                            if (this.qr) {
                                this._itemIndexes[q] = h + 1;
                            }
                        }
                    }
                }
                else {
                    let r = (j * this.rv) + i;
                    this.qb[r] = this.qb[r] + 1;
                    this.p8[r] = 1;
                    this.ry++;
                    if (this.qr) {
                        this._itemIndexes[r] = h + 1;
                    }
                }
            }
            this.s1();
        }
        s7(a) {
            let b;
            let c;
            let d = a.getViewInfo(b, c);
            b = d.p0;
            c = d.p1;
            if (this.qd == null) {
                return;
            }
            if (this.qw == null) {
                this.qw = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
            }
            else {
                this.qw.clear();
            }
            let e = c.left;
            let f = c.right;
            let g = c.top;
            let h = c.bottom;
            this.rm = c.top;
            this.rk = c.height;
            this.rl = c.left;
            this.rn = c.width;
            this.ri = b.top;
            this.rg = b.height;
            this.rh = b.left;
            this.rj = b.width;
            let i = this.getEffectiveViewport1(a);
            this.qy = (i.left - this.rh) / this.rj;
            this.qz = (i.top - this.ri) / this.rg;
            let j = (i.right - this.rh) / this.rj;
            this.q0 = j - this.qy;
            let k = (i.bottom - this.ri) / this.rg;
            this.qx = k - this.qz;
            if (this.qq) {
                e = (e - this.qy) / this.q0;
                f = (f - this.qy) / this.q0;
                g = (g - this.qz) / this.qx;
                h = (h - this.qz) / this.qx;
            }
            let l = this.fv / b.width * c.width;
            let m = this.fv / 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.qd.t(this.qw, o, 0, 1, 0, 1);
            let p;
            this.ry = 0;
            for (let q = 0; q < this.qw.count; q++) {
                p = this.qw._inner[q];
                this.s2(p);
            }
            this.s1();
        }
        s2(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.s4(a.b, d, b, a.e);
            if (c > 0 && !b) {
                let e;
                for (let f = 0; f < c; f++) {
                    e = a.a[f];
                    this.s4(e, d, false, a.e);
                }
            }
            if (a.e != null) {
                a.e.a = false;
            }
        }
        eo(a) {
            let b = this.cd != null ? this.cd.s9 : Rect.empty;
            let c = this.cd != null ? this.cd.to : Rect.empty;
            let d = new Rect(0, 0, 0, 1, 1);
            let e = this.px(this.b0);
            let f = new ScalerParams(0, d, d, this.qf.cg, e);
            let g = new ScalerParams(0, d, d, this.qh.cg, e);
            let h = !b.isEmpty && !c.isEmpty && this.ck != null ? this.ck.indexOf(a) : -1;
            let i = this.qf != null && this.qm != null && h < this.qm.count ? this.qf.ei(this.qm.item(h), f) : NaN;
            let j = this.qh != null && this.qo != null && h < this.qo.count ? this.qh.ei(this.qo.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.b8 != null) {
                this.b8.au(this.cd, b, true);
            }
            return h >= 0;
        }
        s4(a, b, c, d) {
            let e = this.r1(b);
            let f = a.c;
            let g = this.rw;
            if (c) {
                let h = d.d;
                let i = d.b;
                let j = d.e;
                let k = d.c;
                if (this.qq) {
                    h = this.qy + this.q0 * h;
                    i = this.qy + this.q0 * i;
                    j = this.qz + this.qx * j;
                    k = this.qz + this.qx * k;
                }
                let l = truncate((this.rh + this.rj * (h - this.rl) / this.rn));
                let m = truncate((this.rh + this.rj * (i - this.rl) / this.rn));
                let n = truncate((this.ri + this.rg * (j - this.rm) / this.rk));
                let o = truncate((this.ri + this.rg * (k - this.rm) / this.rk));
                l = truncate(Math.floor(l));
                m = truncate(Math.floor(m));
                n = truncate(Math.floor(n));
                o = truncate(Math.floor(o));
                if (this.qp) {
                    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.s3(f, s, t, q, r);
                    }
                }
            }
            else {
                let u = a.a;
                let v = a.b;
                if (this.qq) {
                    u = this.qy + this.q0 * u;
                    v = this.qz + this.qx * v;
                }
                let w = truncate((this.rh + this.rj * (u - this.rl) / this.rn));
                let x = truncate((this.ri + this.rg * (v - this.rm) / this.rk));
                w = truncate(Math.floor(w));
                x = truncate(Math.floor(x));
                if (this.qp) {
                    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.s3(f, af, ag, ad, ae);
                        }
                    }
                }
                else {
                    this.s3(f, w, x, b, 1);
                }
            }
        }
        r0(a, b) {
            return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.rb + a * this.rf))) << 16 | truncate(Math.floor(b * (this.ra + a * this.re))) << 8 | truncate(Math.floor(b * (this.q9 + a * this.rd)));
        }
        r1(a) {
            return 255 << 24 | truncate(Math.floor((this.rb + a * this.rf))) << 16 | truncate(Math.floor((this.ra + a * this.re))) << 8 | truncate(Math.floor((this.q9 + a * this.rd)));
        }
        ro(a) {
            return (a >> 24 & 255) / 255;
        }
        s3(a, b, c, d, e) {
            if (b < 0 || b >= this.rv || c < 0 || c >= this.ru) {
                return;
            }
            let f = (c * this.rv) + b;
            this.qb[f] = this.qb[f] + d;
            this.p8[f] = this.p8[f] + e;
            if (this.qr) {
                this._itemIndexes[f] = a + 1;
            }
            this.ry += truncate(d);
        }
        s1() {
            let a = 0;
            let b = 0;
            let c = this.q3;
            let d = this.q2;
            let e = this.q1;
            let f = this.qb.length;
            let g = this.qb;
            let h = this.p8;
            let i = this.qa;
            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.r0(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;
            }
        }
        st(a) {
            let b = a;
            b.b6();
        }
        bx() {
            return new HighDensityScatterSeriesView(this);
        }
        l2(a) {
            super.l2(a);
            this.qc = a;
        }
        ap(a) {
            if (a != null && a == this.qf && this.qm != null) {
                return new AxisRange(this.qm.minimum, this.qm.maximum);
            }
            if (a != null && a == this.qh && this.qo != null) {
                return new AxisRange(this.qo.minimum, this.qo.maximum);
            }
            return null;
        }
        m8(a, b) {
            if (this.cd != null) {
                let c = this.getEffectiveViewport1(this.b0);
                this.qq = !c.isEmpty;
            }
            this.ml(false);
        }
        m9(a, b) {
            this.ml(false);
        }
        hv(a) {
            if (!this.qr || this._itemIndexes == null || this.cd == null || this.ck == null || this._itemIndexes.length != (this.rv * this.ru)) {
                return null;
            }
            let b = this.cd.s9;
            let c = (a.x - b.left) / b.width;
            let d = (a.y - b.top) / b.height;
            let e = truncate(Math.round(this.p3.left + (this.p3.width * c)));
            let f = truncate(Math.round(this.p3.top + (this.p3.height * d)));
            let g = this.r4(e, f);
            if (g < 0 || g > this._itemIndexes.length - 1) {
                return null;
            }
            let h = this._itemIndexes[g] - 1;
            if (h < 0 || h > this.ck.count) {
                return null;
            }
            return this.ck.item(h);
        }
        r4(a, b) {
            let c = (this.rv * b) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            let d = 1;
            c = (this.rv * (b - d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rv * (b + d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rv * (b)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rv * (b)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rv * (b - d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rv * (b + d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rv * (b - d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rv * (b + d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            return 0;
        }
        s6(a, b, c) {
            this.qa = a;
            this.rv = b;
            this.ru = c;
        }
        get_e5() {
            return true;
        }
        set_e5(a) {
            super.set_e5(a);
        }
        k0(a, b) {
            super.k0(a, b);
            this.qc.b7();
            if (this.bz != null) {
                this.bz.b7();
            }
            this.ls();
        }
        mn(a, b) {
            super.mn(a, b);
            if (!this.e1) {
                this.b0.a2(b);
                return;
            }
            this.b0.a2(b);
            if (this.cx(this.bz)) {
                return;
            }
            let c = typeCast(HighDensityScatterSeriesView.$, this.bz);
            let d = new ScatterFrame();
            this.sx(false, c);
            this.e1 = false;
        }
        mk(a, b, c, d, e) {
            super.mk(a, b, c, d, e);
            let f = this.a6.a$h.item(d);
            let g = f;
            f.a1(c);
            if (this.cx(g)) {
                return;
            }
            if (this.qk == null) {
                this.qk = new ScatterFrame();
            }
            this.sx(false, f);
        }
        kx() {
            super.kx();
            this.qf = null;
            this.qh = null;
        }
    }
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:tn:s8', [Color.$, Defaults.ap], 'HeatMaximum:rp:s9', [1, 50], 'HeatMinimumColor:to:ta', [Color.$, Defaults.aq], 'HeatMinimum:rq:tb', [1, 0], 'PointExtent:r2:tc', [1, 1], 'ProgressiveLoad:qu:td', [0, true], 'UseBruteForce:qv:te', [0, false], 'XAxis:qf:tf', [NumericXAxis.$, null], 'XMemberAsLegendLabel:se:tg', [2, null], 'XMemberAsLegendUnit:sg:th', [2, null], 'XMemberPath:si:ti', [2, null], 'YAxis:qh:tj', [NumericYAxis.$, null], 'YMemberAsLegendLabel:sm:tk', [2, null], 'YMemberAsLegendUnit:so:tl', [2, null], 'YMemberPath:sq:tm', [2, null]]);
    return HighDensityScatterSeries;
})();
/**
 * @hidden
 */
export let HighDensityScatterSeriesView = /*@__PURE__*/ (() => {
    class HighDensityScatterSeriesView extends SeriesView {
        constructor(a) {
            super(a);
            this.bz = null;
            this.bx = null;
            this.b5 = 0;
            this.b4 = 0;
            this.b2 = null;
            this.b3 = null;
            this.b0 = null;
            this.bz = a;
        }
        as() {
            super.as();
            if (!this.q) {
                this.bz.to = Defaults.aq;
                this.bz.tn = Defaults.ap;
                this.bz.o7 = Defaults.al;
                this.bz.pc = Defaults.ak;
            }
        }
        ca() {
            this.bz.s6(this.bx, this.b5, this.b4);
        }
        b6() {
            if (this.b2 == null) {
                this.b2 = this.e.hb.createElement("canvas");
                let a = this.e.hb.get2DCanvasContext(this.b2);
                this.b0 = new RenderingContext(new CanvasViewRenderer(), a);
            }
            let b;
            if (this.p) {
                b = this.bu;
            }
            else {
                b = this.e.cd.te();
            }
            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.b5;
            let h = this.b4;
            this.b5 = e;
            this.b4 = f;
            if (g != this.b5 || h != this.b4 || this.bx == null) {
                this.b2.setAttribute("width", e.toString());
                this.b2.setAttribute("height", f.toString());
                this.b3 = this.b0.h().getImageData(0, 0, e, f);
                let imageDataArray_ = this.b3.data;
                this.bx = imageDataArray_;
            }
            this.bz.s6(this.bx, this.b5, this.b4);
        }
        by() {
            return this.bx;
        }
        b9() {
            let a = truncate(Math.round(this.bu.left));
            let b = truncate(Math.round(this.bu.left));
            let c = truncate(Math.round(this.bu.width));
            let d = truncate(Math.round(this.bu.height));
            this.b0.h().putImageData(this.b3, 0, 0);
            this.aq();
        }
        b8(a) {
            if (this.e.hb != null) {
                this.e.hb.setTimeout(a, 0);
            }
            else {
                window.setTimeout(a, 0);
            }
        }
        a6(a, b) {
            super.a6(a, b);
            if (b) {
                if (!this.bz.em) {
                    return;
                }
                let c = new Rectangle();
                c.n = this.bu.left;
                c.o = this.bu.top;
                c.width = this.bu.width;
                c.height = this.bu.height;
                c._fill = this.bo();
                a.w(c);
                return;
            }
            if (this.b2 == null) {
                return;
            }
            let d = truncate(Math.round(this.bu.left));
            let e = truncate(Math.round(this.bu.top));
            let f = truncate(Math.round(this.bu.width));
            let g = truncate(Math.round(this.bu.height));
            this.k.o(this.b2.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
        }
        b1(a, b) {
            return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
        }
        b7() {
            if (this.bx != null) {
                for (let a = 0; a < this.bx.length; a++) {
                    this.bx[a] = 0;
                }
                this.b9();
            }
        }
        al(a) {
            super.al(a);
            if (this.bx == null) {
                this.e.a8.exportSeriesPixelsData(a, null, this.b5, this.b4);
                return;
            }
            let b = new Array(intDivide(this.bx.length, 4));
            let c;
            for (let d = 0; d < intDivide(this.bx.length, 4); d++) {
                c = d * 4;
                b[d] = this.bx[c + 3] << 24 | this.bx[c] << 16 | this.bx[c + 1] << 8 | this.bx[c + 2];
            }
            this.e.a8.exportSeriesPixelsData(a, b, this.b5, this.b4);
        }
    }
    HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
})();
