/*
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 { MarkerSeries } from "./MarkerSeries";
import { ISupportsErrorBars_$type } from "./ISupportsErrorBars";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { ScatterAxisInfoCache } from "./ScatterAxisInfoCache";
import { NumericXAxis } from "./NumericXAxis";
import { DependencyProperty } from "igniteui-angular-core/ES2015/DependencyProperty";
import { NumericYAxis } from "./NumericYAxis";
import { Series } from "./Series";
import { TrendLineType_$type } from "igniteui-angular-core/ES2015/TrendLineType";
import { Brush } from "igniteui-angular-core/ES2015/Brush";
import { PenLineCap_$type } from "igniteui-angular-core/ES2015/PenLineCap";
import { DoubleCollection } from "igniteui-angular-core/ES2015/DoubleCollection";
import { CollisionAvoidanceType_$type } from "./CollisionAvoidanceType";
import { ScatterErrorBarSettings } from "./ScatterErrorBarSettings";
import { ScatterFrame } from "./ScatterFrame";
import { Base, Type, enumGetBox, Number_$type, typeCast, fromEnum, Point_$type, markType, PointUtil, runOn } from "igniteui-angular-core/ES2015/type";
import { List$1 } from "igniteui-angular-core/ES2015/List$1";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-angular-core/ES2015/Rect";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { IFastItemsSource_$type } from "igniteui-angular-core/ES2015/IFastItemsSource";
import { Clipper } from "igniteui-angular-core/ES2015/Clipper";
import { OwnedPoint } from "./OwnedPoint";
import { Dictionary$2 } from "igniteui-angular-core/ES2015/Dictionary$2";
import { AxisRange } from "./AxisRange";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { ScatterTrendLineManager } from "./ScatterTrendLineManager";
import { ErrorBarsHelper } from "./ErrorBarsHelper";
import { PathGeometry } from "igniteui-angular-core/ES2015/PathGeometry";
import { HashPool$2 } from "igniteui-angular-core/ES2015/HashPool$2";
import { PropertyMetadata } from "igniteui-angular-core/ES2015/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-angular-core/ES2015/number";
import { Path } from "igniteui-angular-core/ES2015/Path";
import { DataTemplateMeasureInfo } from "igniteui-angular-core/ES2015/DataTemplateMeasureInfo";
import { Size } from "igniteui-angular-core/ES2015/Size";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { stringIsNullOrEmpty } from "igniteui-angular-core/ES2015/string";
/**
 * @hidden
 */
export class ScatterBase extends MarkerSeries {
    constructor() {
        super();
        this.m3 = null;
        this.nb = null;
        this.nd = null;
        this.ou = null;
        this.ov = null;
        this.m8 = null;
        this.na = null;
        this.m7 = null;
        this.m9 = null;
        this.m6 = null;
        this.m9 = new ScatterFrame();
        this.ov = Rect.empty;
        this.ou = Rect.empty;
    }
    bf() {
        return new ScatterBaseView(this);
    }
    ht() {
        super.ht();
        this.xAxis = null;
        this.yAxis = null;
    }
    it(a) {
        super.it(a);
        this.m4 = a;
    }
    get_c4() {
        return true;
    }
    ag() {
        return [this.xAxis, this.yAxis];
    }
    fs(a, b) {
        let c = this.gu(b);
        if (c == ScatterBase.$$p[4]) {
            return this.ft(a, b, this.nq);
        }
        if (c == ScatterBase.$$p[6]) {
            return this.ft(a, b, this.nu);
        }
        return null;
    }
    ch(a, b, c) {
        if (!this.hasMarkers) {
            return false;
        }
        let d = this.xAxis;
        let e = new ScalerParams(1, this.bs.mq, this.lx, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        let f = this.yAxis;
        let g = new ScalerParams(1, this.bs.mq, this.lx, f.b8);
        g.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.lz.cc((h) => {
            if (h._visibility == 0) {
                let i = new SeriesPointOfInterest();
                let j = h.n;
                let k = h.o;
                if (j < this.lx.left || j > this.lx.right || k < this.lx.top || k > this.lx.bottom) {
                    return;
                }
                i.b = d.dy(j, e);
                i.c = f.dy(k, g);
                i.a = h.content;
                a.add(i);
            }
        });
        return true;
    }
    bd() {
        if (this.be == 0) {
            if (this.nj <= 2000) {
                return 1;
            }
            else {
                return super.bd();
            }
        }
        else {
            return super.bd();
        }
    }
    lv(a) {
        if (!this.hasMarkers || !this.l2()) {
            return Rect.empty;
        }
        let b = this.lz.bv(this.lf(a));
        if (b != null) {
            return this.lz.cm(b);
        }
        return Rect.empty;
    }
    dh(a, b) {
        if (this.l3(a, b)) {
            return true;
        }
        return false;
    }
    get nc() {
        return this.nb;
    }
    set nc(a) {
        if (this.nb != a) {
            let b = this.nc;
            this.nb = a;
            this.raisePropertyChanged("XColumn", b, this.nc);
        }
    }
    get ne() {
        return this.nd;
    }
    set ne(a) {
        if (this.nd != a) {
            let b = this.ne;
            this.nd = a;
            this.raisePropertyChanged("YColumn", b, this.ne);
        }
    }
    get or() {
        return this.c(ScatterBase.oc);
    }
    set or(a) {
        this.h(ScatterBase.oc, a);
    }
    get GetErrorBarsXAxis() {
        return this.xAxis;
    }
    get GetErrorBarsYAxis() {
        return this.yAxis;
    }
    ia() {
        super.ia();
        if (this.xAxis != null) {
            this.xAxis.g5(false);
        }
        if (this.yAxis != null) {
            this.yAxis.g5(false);
        }
    }
    iy(a, b, c, d) {
        super.iy(a, b, c, d);
        if (this.m4.ct.g$b(a, b, c, d)) {
            this.jc(false);
            this.ij();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.nc);
                    c.deregisterColumn(this.ne);
                    this.nc = null;
                    this.ne = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.nc = this.bw(this.nq);
                    this.ne = this.bw(this.nu);
                }
                if ((this.yAxis != null && !this.yAxis.ck()) || (this.xAxis != null && !this.xAxis.ck())) {
                    this.jc(false);
                }
                break;
            case ScatterBase.$$p[3]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if ((this.xAxis != null && !this.xAxis.ck()) || (d == null && c != null)) {
                    this.jc(false);
                }
                this.ij();
                break;
            case ScatterBase.$$p[5]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if ((this.yAxis != null && !this.yAxis.ck()) || (d == null && c != null)) {
                    this.jc(false);
                }
                this.ij();
                break;
            case ScatterBase.$$p[4]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.nc);
                    this.nc = this.bw(this.nq);
                }
                break;
            case "XColumn":
                this.m4.ct.g$i();
                if (this.xAxis != null && !this.xAxis.ck()) {
                    this.jc(false);
                }
                break;
            case ScatterBase.$$p[6]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.ne);
                    this.ne = this.bw(this.nu);
                }
                break;
            case "YColumn":
                this.m4.ct.g$i();
                if (this.yAxis != null && !this.yAxis.ck()) {
                    this.jc(false);
                }
                break;
            case ScatterBase.$$p[1]:
                this.jc(false);
                this.ij();
                break;
            case ScatterBase.$$p[2]:
                this.jc(false);
                this.ij();
                break;
            case "TransitionProgress":
                this.na.c(this.ez, this.m8, this.m7);
                this.nw();
                try {
                    if (this.cc(this.bi)) {
                        return;
                    }
                    if ((Math.round(this.ez * 100000) / 100000) == 1) {
                        this.oa(this.m7, this.m4);
                    }
                    else {
                        this.oa(this.na, this.m4);
                    }
                    if (this.bs != null) {
                        this.bs.jj(this);
                    }
                }
                finally {
                    this.ob();
                }
                break;
            case "TrendLineBrush":
                this.jn();
                break;
            case ScatterBase.$$p[0]:
                if (this.m5 != null) {
                    this.m5.r = this;
                }
                this.jc(false);
                this.ij();
                break;
            case "TrendLineType":
                this.ij();
                break;
        }
    }
    ng(a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    nf(a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    ob() {
        this.ou = Rect.empty;
        this.ov = Rect.empty;
    }
    nw() {
        let a = this.getViewInfo(this.ou, this.ov);
        this.ou = a.p0;
        this.ov = a.p1;
    }
    nh(a, b) {
        if (b != 3) {
            return true;
        }
        if (a == null) {
            return true;
        }
        if (this.nq == a || this.nu == a) {
            return true;
        }
        return false;
    }
    hy(a, b, c, d) {
        let e = false;
        if (!this.nh(d, a)) {
            return;
        }
        this.m4.ct.g$e(a, b, c, d);
        if (this.xAxis != null && !this.xAxis.ck()) {
            e = true;
        }
        if (this.yAxis != null && !this.yAxis.ck()) {
            e = true;
        }
        if (e) {
            this.jc(true);
        }
    }
    n4(a) {
        this.n5(a, null);
    }
    n5(a, b) {
        let c = this.nc != null ? this.nc.count : 0;
        let d = this.ne != null ? this.ne.count : 0;
        let e = Math.min(c, d);
        if (e <= this.nj) {
            a.m.clear();
            let f = new List$1(OwnedPoint.$, 0);
            for (let g of fromEnum(a.u.values)) {
                f.add(g);
            }
            let h = this.bz;
            f.aa((i, j) => {
                let k = h.indexOf(i.a);
                let l = h.indexOf(j.a);
                if (k < l) {
                    return -1;
                }
                if (k > l) {
                    return 1;
                }
                return 0;
            });
            if (b != null) {
                b.i = a.m;
            }
            for (let i of fromEnum(f)) {
                if (h.indexOf(i.a) >= 0) {
                    if (b != null) {
                        b.j(i.c);
                    }
                    else {
                        a.m.add({ $type: Point_$type, x: i.c.x, y: i.c.y });
                    }
                }
            }
        }
    }
    an(a) {
        if (a != null && a == this.xAxis && this.nc != null) {
            return new AxisRange(this.nc.minimum, this.nc.maximum);
        }
        if (a != null && a == this.yAxis && this.ne != null) {
            return new AxisRange(this.ne.minimum, this.ne.maximum);
        }
        return null;
    }
    fp(a) {
        return null;
    }
    e8(a) {
        return -1;
    }
    c9(a) {
        let b = this.bs != null ? this.bs.mq : Rect.empty;
        b = b.copy();
        let c = this.bs != null ? this.bs.m3 : Rect.empty;
        let d = new Rect(0, 0, 0, 1, 1);
        let e = this.lr(this.bi);
        let f = new ScalerParams(0, d, d, this.xAxis.b8, e);
        let g = ((() => {
            let $ret = new ScalerParams(0, d, d, this.yAxis.b8, e);
            $ret.b = this.eh();
            return $ret;
        })());
        let h = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        let i = this.xAxis != null && this.nc != null && h < this.nc.count ? this.xAxis.dv(this.nc.item(h), f) : NaN;
        let j = this.yAxis != null && this.ne != null && h < this.ne.count ? this.yAxis.dv(this.ne.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.bn != null) {
            this.bn.ap(this.bs, b, true);
        }
        return h >= 0;
    }
    jr(a, b) {
        this.jc(false);
    }
    js(a, b) {
        this.jc(false);
    }
    nx(a, b, c, d, e) {
        b.g = new Dictionary$2(Base.$, OwnedPoint.$, 1, c);
        let f = this.getEffectiveViewport1(a);
        let g = this.bz;
        let h;
        let i;
        let j = ((() => {
            let $ret = new ScalerParams(0, d, e, this.m3.d, f);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let k = ((() => {
            let $ret = new ScalerParams(0, d, e, this.m3.e, f);
            $ret.c = this.getEffectiveViewport1(a);
            $ret.b = this.eh();
            return $ret;
        })());
        for (let l = 0; l < c; l++) {
            h = this.nc.item(l);
            i = this.ne.item(l);
            let m = { $type: Point_$type, x: this.m3.a.dv(h, j), y: this.m3.b.dv(i, k) };
            if (!isInfinity(m.x) && !isInfinity(m.y)) {
                let n = g.item(l);
                if (!b.g.containsKey(n)) {
                    let o = { $type: Point_$type, x: h, y: i };
                    let p = { $type: Point_$type, x: m.x, y: m.y };
                    b.g.addItem(n, ((() => {
                        let $ret = new OwnedPoint();
                        $ret.a = n;
                        $ret.b = o;
                        $ret.c = p;
                        return $ret;
                    })()));
                }
            }
        }
    }
    n1(a, b) {
        a.j.clear();
        a.n.clear();
        a.h.clear();
        a.l.clear();
        a.i.clear();
        a.k.clear();
        let c = Math.min(this.nc != null ? this.nc.count : 0, this.ne != null ? this.ne.count : 0);
        let d = b.bs;
        let e = b.br;
        let f = this.getEffectiveViewport1(b);
        let g = new ScalerParams(0, d, e, this.xAxis.b8, f);
        g.c = this.getEffectiveViewport1(b);
        let h = ((() => {
            let $ret = new ScalerParams(0, d, e, this.yAxis.b8, f);
            $ret.b = this.eh();
            return $ret;
        })());
        ;
        h.c = this.getEffectiveViewport1(b);
        if (c < 1) {
            return;
        }
        this.m3 = ((() => {
            let $ret = new ScatterAxisInfoCache();
            $ret.a = this.xAxis;
            $ret.b = this.yAxis;
            $ret.d = this.xAxis.b8;
            $ret.e = this.yAxis.b8;
            $ret.c = this.bz;
            return $ret;
        })());
        let i = b;
        if (c <= this.nj) {
            this.nx(i, a, c, d, e);
        }
        if (this.l2()) {
            b.cr.l(a.j, this.nj, d, e, this.eu);
        }
        let j = ((() => {
            let $ret = new Clipper(0, e, false);
            $ret.i = a.n;
            return $ret;
        })());
        let k = this.lp(b);
        let l = this.xAxis.dy(k.left, g);
        let m = this.xAxis.dy(k.right, g);
        b.ct.p(a.n, this.trendLineType, this.nc, this.ne, this.trendLinePeriod, (n) => this.xAxis.dv(n, g), (n) => this.yAxis.dv(n, h), ((() => {
            let $ret = new TrendResolutionParams();
            $ret.b = this.eu;
            $ret.f = e;
            $ret.g = d;
            return $ret;
        })()), j, l, m);
        this.nz(a, b);
    }
    hv(a, b) {
        super.hv(a, b);
        let c = b;
        c.c0(a);
    }
    oa(a, b) {
        let c = b.br;
        this.m3 = ((() => {
            let $ret = new ScatterAxisInfoCache();
            $ret.a = this.xAxis;
            $ret.b = this.yAxis;
            $ret.d = this.xAxis.b8;
            $ret.e = this.yAxis.b8;
            return $ret;
        })());
        if (this.l2()) {
            b.cr.j(a.j, this.l4);
        }
        b.cj();
        let d = ((() => {
            let $ret = new Clipper(1, NaN, c.bottom, NaN, c.top, false);
            $ret.i = b.ct.g$j.aj;
            return $ret;
        })());
        b.ct.g$h(a.n, d);
        this.n7(a, b);
    }
    nz(a, b) {
        let c = new ErrorBarsHelper(this, b);
        if (this.m5 == null) {
            return;
        }
        let d = this.m5.u;
        let e = this.m5.v;
        let f = 0;
        let g = 0;
        let h = 0;
        let i = 0;
        for (let j of fromEnum(a.j.keys)) {
            let k = a.j.item(j);
            if (d != null) {
                switch (d.getCalculatorType()) {
                    case 1:
                        let l = this.n2(k, c, d, h, i, true);
                        h = l.p3;
                        i = l.p4;
                        break;
                    case 0:
                        let m = this.n0(k, c, d, h, i, true);
                        h = m.p3;
                        i = m.p4;
                        break;
                    case 2:
                        let n = this.ny(k, c, d, j, h, i, true);
                        h = n.p4;
                        i = n.p5;
                        break;
                    case 3:
                        let o = this.n3(c, d, f, h, i, true);
                        f = o.p2;
                        h = o.p3;
                        i = o.p4;
                        break;
                    case 4:
                        let p = this.n0(k, c, d, h, i, true);
                        h = p.p3;
                        i = p.p4;
                        break;
                }
                ;
                let q = new OwnedPoint();
                q.c = c.l(d, this.m3.a, k.c, f);
                ;
                q.a = k.a;
                a.h.addItem(j, q);
                a.i.addItem(j, [h, i]);
            }
            if (e != null) {
                switch (e.getCalculatorType()) {
                    case 1:
                        let r = this.n2(k, c, e, h, i, false);
                        h = r.p3;
                        i = r.p4;
                        break;
                    case 0:
                        let s = this.n0(k, c, e, h, i, false);
                        h = s.p3;
                        i = s.p4;
                        break;
                    case 2:
                        let t = this.ny(k, c, e, j, h, i, false);
                        h = t.p4;
                        i = t.p5;
                        break;
                    case 3:
                        let u = this.n3(c, e, g, h, i, false);
                        g = u.p2;
                        h = u.p3;
                        i = u.p4;
                        break;
                    case 4:
                        let v = this.n0(k, c, e, h, i, false);
                        h = v.p3;
                        i = v.p4;
                        break;
                }
                ;
                let w = new OwnedPoint();
                w.c = c.m(e, this.m3.b, k.c, g);
                ;
                w.a = k.a;
                a.l.addItem(j, w);
                a.k.addItem(j, [h, i]);
            }
        }
    }
    n2(a, b, c, d, e, f) {
        if (f) {
            let g;
            let h, i;
            i = this.m3.a;
            if (this.m5.s == 0) {
                g = a.c.x;
                h = this.m3.a;
            }
            else {
                g = a.c.y;
                h = this.m3.b;
            }
            let j = b.f(g, c, h, i, d, e);
            d = j.p4;
            e = j.p5;
        }
        else {
            let k;
            let l, m;
            m = this.m3.b;
            if (this.m5.t == 0) {
                k = a.c.x;
                l = this.m3.a;
            }
            else {
                k = a.c.y;
                l = this.m3.b;
            }
            let n = b.f(k, c, l, m, d, e);
            d = n.p4;
            e = n.p5;
        }
        return {
            p3: d,
            p4: e
        };
    }
    n0(a, b, c, d, e, f) {
        if (f) {
            let g = b.j(a.c.x, c, this.m3.a, d, e);
            d = g.p3;
            e = g.p4;
        }
        else {
            let h = b.j(a.c.y, c, this.m3.b, d, e);
            d = h.p3;
            e = h.p4;
        }
        return {
            p3: d,
            p4: e
        };
    }
    ny(a, b, c, d, e, f, g) {
        let h = c.getItemColumn();
        let i = this.bz.indexOf(d);
        if (h != null && i < h.count) {
            let j = h.item(i);
            if (g) {
                let k = b.h(a.c.x, j, this.m3.a, e, f);
                e = k.p3;
                f = k.p4;
            }
            else {
                let l = b.h(a.c.y, j, this.m3.b, e, f);
                e = l.p3;
                f = l.p4;
            }
        }
        else {
            e = f = NaN;
        }
        return {
            p4: e,
            p5: f
        };
    }
    n3(a, b, c, d, e, f) {
        let g = a.i(b, c);
        c = g.p1;
        if (f) {
            let h = a.k(c, b, this.m3.a, d, e);
            d = h.p3;
            e = h.p4;
        }
        else {
            let i = a.k(c, b, this.m3.b, d, e);
            d = i.p3;
            e = i.p4;
        }
        return {
            p2: c,
            p3: d,
            p4: e
        };
    }
    n7(a, b) {
        if (!b.l() || this.m5 == null) {
            b.c1();
            return;
        }
        this.n8(a, b);
        this.n9(a, b);
    }
    n8(a, b) {
        b.cy();
        let c = new ErrorBarsHelper(this, b);
        let d = new PathGeometry();
        let e = this.m5.u;
        for (let f of fromEnum(a.j.keys)) {
            if (e != null && a.i.containsKey(f)) {
                let g = a.i.item(f)[0];
                let h = a.i.item(f)[1];
                if (!isNaN_(g) && !isNaN_(h)) {
                    let i = a.h.item(f).c;
                    if (this.m5.o == 1 || this.m5.o == 2) {
                        c.d(d, i, g, true);
                    }
                    if (this.m5.o == 1 || this.m5.o == 3) {
                        c.d(d, i, h, false);
                    }
                }
            }
        }
        b.c2(d);
    }
    n9(a, b) {
        b.cz();
        let c = new ErrorBarsHelper(this, b);
        let d = new PathGeometry();
        let e = this.m5.v;
        for (let f of fromEnum(a.j.keys)) {
            if (e != null && a.k.containsKey(f)) {
                let g = a.k.item(f)[0];
                let h = a.k.item(f)[1];
                if (!isNaN_(g) && !isNaN_(h)) {
                    let i = a.l.item(f).c;
                    if (this.m5.p == 1 || this.m5.p == 2) {
                        c.e(d, i, g, true);
                    }
                    if (this.m5.p == 1 || this.m5.p == 3) {
                        c.e(d, i, h, false);
                    }
                }
            }
        }
    }
    dw(a, b, c) {
        let d = true;
        if (!super.dw(a, b, c) || b.isEmpty || a.isEmpty || this.xAxis == null || this.yAxis == null || this.xAxis.bf == null || this.yAxis.bf == null || this.nc == null || this.ne == null || this.nc.count == 0 || this.ne.count == 0 || this.bz == null || this.bz.count != this.nc.count || this.bz.count != this.ne.count || this.xAxis.bf == null || this.yAxis.bf == null || this.xAxis.j3 == this.xAxis.j2 || this.yAxis.j3 == this.yAxis.j2) {
            d = false;
        }
        return d;
    }
    getViewInfo(a, b) {
        if (!this.ou.isEmpty && !this.ov.isEmpty) {
            a = this.ou;
            b = this.ov;
            return {
                p0: a,
                p1: b
            };
        }
        a = this.bi.br;
        b = this.bi.bs;
        return {
            p0: a,
            p1: b
        };
    }
    jd(a) {
        this.nw();
        try {
            if (this.cc(this.bi)) {
                return;
            }
            if (this.bz != null && this.bz.count > this.nj) {
                a = false;
            }
            if (this.da(a) && !this.de) {
                let b = this.m8;
                if (this.ca()) {
                    if (this.bt.g) {
                        this.bt.t();
                    }
                    this.m8 = this.na;
                    this.na = b;
                }
                else {
                    this.m8 = this.m7;
                    this.m7 = b;
                }
                this.n1(this.m7, this.m4);
                this.jk();
            }
            else {
                if (!this.de) {
                    this.n1(this.m7, this.m4);
                }
                this.oa(this.m7, this.m4);
            }
        }
        finally {
            this.ob();
        }
    }
    jn() {
        super.jn();
        if (this.fh < 0) {
            return;
        }
        this.m4.c5();
    }
    je(a, b) {
        super.je(a, b);
        if (!this.dl) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        let c = typeCast(ScatterBaseView.$, this.bh);
        if (!this.df) {
            this.m9 = new ScatterFrame();
            this.n1(this.m9, c);
        }
        this.df = false;
        this.oa(this.m9, c);
        this.dl = false;
    }
    jb(a, b, c, d, e) {
        super.jb(a, b, c, d, e);
        let f = this.a0.a$h.item(d);
        let g = f;
        f.ay(c);
        if (this.cc(g)) {
            return;
        }
        if (this.m6 == null) {
            this.m6 = new ScatterFrame();
        }
        this.n1(this.m6, g);
        this.oa(this.m6, g);
    }
    n6(a, b) {
        let c = new List$1(Base.$, 0);
        for (let d of fromEnum(b.c)) {
            if (!a.containsKey(d)) {
                c.add1(d);
            }
        }
        for (let e of fromEnum(c)) {
            b.g(e);
        }
    }
    mz(a, b, c, d, e) {
        if (c == null || c.length != this.m3.c.count) {
            c = new Array(this.m3.c.count);
            for (let f = 0; f < this.m3.c.count; f++) {
                c[f] = PointUtil.create();
            }
        }
        let g = this.getEffectiveViewport1(a);
        let h = ((() => {
            let $ret = new ScalerParams(0, d, e, this.xAxis.b8, g);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let i = ((() => {
            let $ret = new ScalerParams(0, d, e, this.yAxis.b8, g);
            $ret.c = this.getEffectiveViewport1(a);
            $ret.b = this.eh();
            return $ret;
        })());
        let j = this.lp(a);
        let k = this.m3.a.dy(j.left, h);
        let l = this.m3.a.dy(j.right, h);
        let m = this.m3.b.dy(j.bottom, i);
        let n = this.m3.b.dy(j.top, i);
        if (this.m3.d) {
            let o = k;
            k = l;
            l = o;
        }
        if (this.m3.e) {
            let p = m;
            m = n;
            n = p;
        }
        let q = this.m3;
        let r = q.a;
        let s = q.b;
        let t;
        let u;
        let v = this.nc;
        let w = this.ne;
        for (let x = 0; x < this.m3.c.count; x++) {
            t = v.item(x);
            u = w.item(x);
            if (t >= k && t <= l && u >= m && u <= n) {
                c[x].x = r.dv(t, h);
                c[x].y = s.dv(u, i);
            }
            else {
                c[x].x = NaN;
                c[x].y = NaN;
            }
        }
        return c;
    }
    ni(a, b) {
        if (b == null) {
            b = new List$1(Number_$type, 2, a.e);
        }
        else {
            b.clear();
        }
        let c = 0;
        let d = this.bz;
        for (let e of fromEnum(a.c)) {
            b.add(d.indexOf(e));
        }
        return b;
    }
    h4(a) {
        super.h4(a);
        this.a2.exportTrendlineData(this, a, this.m4.ct.g$j);
    }
    eh() {
        return Series.ei(this.ne, null);
    }
}
ScatterBase.$t = markType(ScatterBase, 'ScatterBase', MarkerSeries.$, [ISupportsErrorBars_$type, ITrendLineSeries_$type]);
ScatterBase.oc = DependencyProperty.i("ActualTrendLineBrush", Brush.$, ScatterBase.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
Type.dep(DependencyProperty, PropertyMetadata, ScatterBase, 'raisePropertyChanged', ['ErrorBarSettings:m5:od', [ScatterErrorBarSettings.$, null], 'MarkerCollisionAvoidance:m0:oe', [CollisionAvoidanceType_$type, enumGetBox(CollisionAvoidanceType_$type, 0)], 'MaximumMarkers:nj:of', [1, 400], 'XAxis::on', [NumericXAxis.$, null], 'XMemberPath:nq:oo', [2, null], 'YAxis::op', [NumericYAxis.$, null], 'YMemberPath:nu:oq', [2, null], 'TrendLineType::ol', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ok', [1, 1.5], 'TrendLinePeriod::oj', [1, 7], 'TrendLineBrush::og', [Brush.$, null], 'TrendLineZIndex:nk:om', [1, 1001], 'TrendLineDashArray:os:oh', [DoubleCollection.$], 'TrendLineDashCap:ot:oi', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
/**
 * @hidden
 */
export class ScatterBaseView extends MarkerSeriesView {
    constructor(a) {
        super(a);
        this.cr = null;
        this.cp = null;
        this.cs = null;
        this.cx = null;
        this.c7 = null;
        this.c8 = null;
        this.ct = null;
        this.c6 = null;
        this.cu = null;
        this.cs = a;
        this.cu = new HashPool$2(Base.$, Marker.$);
        this.ce(this.cu);
        this.ct = new ScatterTrendLineManager();
    }
    ap() {
        super.ap();
        this.cr = this.cq();
        this.c7 = new Path();
        this.c8 = new Path();
        if (!this.n) {
            this.cs.nj = 2000;
        }
    }
    c9(a) {
        if (this.c6 == null) {
            this.c6 = new DataTemplateMeasureInfo();
            this.c6.context = this.h.g();
        }
        this.c6.width = a.width;
        this.c6.height = a.height;
        this.c6.data = a.content;
        let b = a.ah;
        if (b.measure != null) {
            b.measure(this.c6);
        }
        return new Size(1, this.c6.width, this.c6.height);
    }
    cq() {
        let a = new NumericMarkerManager(1, (b) => this.cu.item(b), (b) => this.cs.m3.c.item(b), runOn(this, this.c4), runOn(this, this.cn), runOn(this, this.cv), () => this.cs.m0);
        a.q = runOn(this, this.c9);
        return a;
    }
    c4(a) {
        this.cs.n6(a, this.cu);
    }
    cw() {
        return this.b1;
    }
    co() {
        return this.cp;
    }
    cn() {
        this.cp = this.cs.mz(this, this.cu, this.cp, this.bs, this.br);
        return this.cp;
    }
    cv() {
        this.cx = this.cs.ni(this.cu, this.cx);
        return this.cx;
    }
    cy() {
    }
    c2(a) {
    }
    cz() {
    }
    c3(a) {
    }
    c5() {
        if (this.cs.trendLineBrush != null) {
            this.cs.or = this.cs.trendLineBrush;
        }
        else {
            this.cs.or = this.cs.k2;
        }
    }
    cc(a) {
        this.cu.f(a);
    }
    c1() {
    }
    a2(a, b) {
        super.a2(a, b);
        if (a.d) {
            if (this.cs.trendLineType != 0 && !b) {
                let c = this.ct.g$j;
                c.ac = this.cs.trendLineThickness;
                c._stroke = this.cs.or;
                c.ai = this.cs.os;
                c.ad = this.cs.ot;
                a.u(c);
            }
        }
    }
    c0(a) {
        if (a) {
            this.c1();
            this.cu.clear();
        }
        this.ct.g$d();
        this.an();
    }
    getDefaultTooltipTemplate() {
        let a = "<div class='ui-chart-default-tooltip-content'><span";
        let b = this.e.a0.a$q(this.e);
        if (!stringIsNullOrEmpty(b)) {
            a += " style='color:" + b + "'";
        }
        a += ">" + this.cs.fx + "</span><br/><span>" + "x: </span><span class='ui-priority-primary'>${item." + this.cs.nq + "}</span><br/><span>" + "y: </span><span class='ui-priority-primary'>${item." + this.cs.nu + "}</span></div>";
        return a;
    }
}
ScatterBaseView.$t = markType(ScatterBaseView, 'ScatterBaseView', MarkerSeriesView.$);
//# sourceMappingURL=ScatterBase_combined.js.map