/*
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 { ShapeSeriesBase } from "./ShapeSeriesBase";
import { ShapeAxisInfoCache } from "./ShapeAxisInfoCache";
import { StyleSelector } from "./StyleSelector";
import { DependencyProperty } from "igniteui-angular-core";
import { Style } from "igniteui-angular-core";
import { MarkerType_$type } from "./MarkerType";
import { DataTemplate } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { CollisionAvoidanceType_$type } from "./CollisionAvoidanceType";
import { Rect } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { Base, enumGetBox, typeCast, fromEnum, markType, markDep, PointUtil, runOn } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { OwnedPoint } from "./OwnedPoint";
import { ShapeSeriesViewBase } from "./ShapeSeriesViewBase";
import { MarkerSeries } from "./MarkerSeries";
import { DataContext } from "igniteui-angular-core";
import { Marker } from "./Marker";
import { HashPool$2 } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { RectUtil } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { DataTemplateMeasureInfo } from "igniteui-angular-core";
import { Size } from "igniteui-angular-core";
import { DataTemplatePassInfo } from "igniteui-angular-core";
import { DataTemplateRenderInfo } from "igniteui-angular-core";
import { MarkerVisualData } from "./MarkerVisualData";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { stringIsNullOrEmpty } from "igniteui-angular-core";
/**
 * @hidden
 */
export class ScatterPolygonSeries extends ShapeSeriesBase {
    constructor() {
        super();
        this.nh = null;
        this.ne = new ScalerParams(1, ScatterPolygonSeries.od, ScatterPolygonSeries.od, false);
        this.nf = new ScalerParams(1, ScatterPolygonSeries.od, ScatterPolygonSeries.od, false);
        this.ab = ScatterPolygonSeries.$;
    }
    mh() {
        return this.nj();
    }
    mz(a) {
        let b = a;
        b.cn(this.of);
        b.co(this.ni);
        super.mz(a);
        if (this.cc(a)) {
            return;
        }
        let c, d;
        let e = a.getViewInfo(c, d);
        c = e.p0;
        d = e.p1;
        let f = this.getEffectiveViewport1(a);
        this.ne = new ScalerParams(1, d, c, this.l6.b8);
        this.ne.c = f;
        this.nf = new ScalerParams(1, d, c, this.l8.b8);
        this.nf.c = f;
        if (c.width < 1 || c.height < 1) {
            return;
        }
        this.nh = ((() => {
            let $ret = new ShapeAxisInfoCache();
            $ret.a = this.l6;
            $ret.b = this.l8;
            $ret.e = this.l6.b8;
            $ret.f = this.l8.b8;
            $ret.d = this.bz;
            $ret.c = this.mb;
            return $ret;
        })());
        if (this.nj()) {
            let g = new Dictionary$2(Base.$, OwnedPoint.$, 0);
            b.c5.l(g, 400, d, c, this.eu);
            b.c5.j(g, false);
        }
    }
    nj() {
        return this.nw != null && ((this.nd != 1 && this.nd != 0) || this.nx != null);
    }
    bf() {
        return new ScatterPolygonSeriesView(this);
    }
    iu(a) {
        super.iu(a);
        this.ng = a;
    }
    get_hasMarkers() {
        return true;
    }
    k6() {
        return this.n9;
    }
    k7() {
        return this.oa;
    }
    jz() {
        return this.nw;
    }
    jo() {
        super.jo();
        if (this.nx != null) {
            this.ng.dd();
        }
        else {
            let a = MarkerSeries.l2(this, this.nd);
            let b = MarkerSeries.ma(a);
            if (b == null) {
                this.nw = MarkerSeries.ml;
            }
            else {
                this.ng.da(b);
            }
        }
        if (this.ob != null) {
            this.ng.db();
        }
        else {
            this.n9 = this.bs == null ? null : this.bs.ma(this.fh);
        }
        if (this.oc != null) {
            this.ng.dc();
        }
        else {
            this.oa = this.bs == null ? null : this.bs.mb(this.fh);
        }
    }
    iz(a, b, c, d) {
        super.iz(a, b, c, d);
        switch (b) {
            case ScatterPolygonSeries.$$p[3]:
            case ScatterPolygonSeries.$$p[8]:
            case ScatterPolygonSeries.$$p[5]:
            case ScatterPolygonSeries.$$p[7]:
                this.jo();
                this.jd(false);
                break;
            case ScatterPolygonSeries.$$p[2]:
                if (c == MarkerSeries.ml || d == MarkerSeries.ml || (c == null || d != null)) {
                    this.ng.df();
                    this.jd(false);
                }
                this.jd(false);
                this.ik();
                break;
            case ScatterPolygonSeries.$$p[9]:
                this.ng.cn(this.of);
                this.jd(false);
                this.ik();
                break;
            case ScatterPolygonSeries.$$p[10]:
                this.ng.co(this.ni);
                this.jd(false);
                this.ik();
                break;
            case ScatterPolygonSeries.$$p[4]:
                this.jd(false);
                this.ik();
                break;
        }
    }
    ar(a, b) {
        let c = this.ng.c2(a);
        let d = null;
        if (c != null) {
            d = c.content;
        }
        if (d != null) {
            return d;
        }
        return super.ar(a, b);
    }
    nv(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);
        }
    }
    ch(a, b, c) {
        if (!this.hasMarkers) {
            return false;
        }
        let d = this.l6;
        let e = new ScalerParams(1, this.bs.mq, this.ly, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        let f = this.l8;
        let g = new ScalerParams(1, this.bs.mq, this.ly, f.b8);
        g.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.ng.de((h) => {
            if (h._visibility == 0) {
                let i = new SeriesPointOfInterest();
                let j = h.n;
                let k = h.o;
                if (j < this.ly.left || j > this.ly.right || k < this.ly.top || k > this.ly.bottom) {
                    return;
                }
                i.b = d.dz(j, e);
                i.c = f.dz(k, g);
                i.a = h.content;
                a.add(i);
            }
        });
        return true;
    }
    nb(a, b, c, d, e) {
        if (c == null || c.length != this.nh.d.count) {
            c = new Array(this.nh.d.count);
            for (let f = 0; f < this.nh.d.count; f++) {
                c[f] = PointUtil.create();
            }
        }
        let g = ((() => {
            let $ret = new ScalerParams(1, d, e, this.l6.b8);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let h = ((() => {
            let $ret = new ScalerParams(1, d, e, this.l8.b8);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let i = this.nh.a.dz(g.d.left, g);
        let j = this.nh.a.dz(g.d.right, g);
        let k = this.nh.b.dz(h.d.bottom, h);
        let l = this.nh.b.dz(h.d.top, h);
        if (this.nh.e) {
            let m = i;
            i = j;
            j = m;
        }
        if (this.nh.f) {
            let n = k;
            k = l;
            l = n;
        }
        let o = this.nh;
        let p = o.a;
        let q = o.b;
        let r;
        let s;
        let t = g.d.left;
        let u = g.d.right;
        let v = h.d.top;
        let w = h.d.bottom;
        for (let x = 0; x < this.nh.d.count; x++) {
            r = 0;
            s = 0;
            let y = null;
            let z = a.b3.tryGetValue(x, y);
            y = z.p1;
            if (y == null) {
                c[x].x = NaN;
                c[x].y = NaN;
            }
            else {
                let aa = y.c;
                let ab = RectUtil.l(aa);
                r = ab.x;
                s = ab.y;
                if (r >= t && r <= u && s >= v && s <= w) {
                    c[x].x = r;
                    c[x].y = s;
                }
                else {
                    c[x].x = NaN;
                    c[x].y = NaN;
                }
            }
        }
        return c;
    }
    na(a, b) {
        if (b == null || b.length != a.e) {
            b = new Array(a.e);
        }
        let c = 0;
        let d = this.bz;
        for (let e of fromEnum(a.c)) {
            b[c] = d.indexOf(e);
            c++;
        }
        return b;
    }
}
ScatterPolygonSeries.$t = markType(ScatterPolygonSeries, 'ScatterPolygonSeries', ShapeSeriesBase.$);
ScatterPolygonSeries.od = new Rect(0, 0, 0, 1, 1);
ScatterPolygonSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterPolygonSeries, 'raisePropertyChanged', ['ActualMarkerBrush:n9:ny', [Brush.$], 'ActualMarkerOutline:oa:nz', [Brush.$], 'ActualMarkerTemplate:nw:n0', [DataTemplate.$, null], 'MarkerBrush:ob:n1', [Brush.$], 'MarkerCollisionAvoidance:nc:n2', [CollisionAvoidanceType_$type, enumGetBox(CollisionAvoidanceType_$type, 0)], 'MarkerOutline:oc:n3', [Brush.$], 'MarkerStyle:oe:n4', [Style.$], 'MarkerTemplate:nx:n5', [DataTemplate.$, null], 'MarkerType:nd:n6', [MarkerType_$type, enumGetBox(MarkerType_$type, 1)], 'ShapeStyle:of:n7', [Style.$, null], 'ShapeStyleSelector:ni:n8', [StyleSelector.$, null]]);
/**
 * @hidden
 */
export class ScatterPolygonSeriesView extends ShapeSeriesViewBase {
    constructor(a) {
        super(a);
        this.c1 = null;
        this.c0 = null;
        this.c6 = null;
        this.c4 = null;
        this.c8 = false;
        this.c7 = null;
        this.c9 = null;
        this.dm = null;
        this.c6 = a;
        this.c7 = new HashPool$2(Base.$, Marker.$);
        this.c9 = new List$1(Marker.$, 0);
        this.dg(this.c7);
        this.c4 = new NumericMarkerManager(1, (b) => this.c7.item(b), (b) => this.c6.nh.d.item(b), runOn(this, this.dk), runOn(this, this.cz), runOn(this, this.cy), () => this.c6.nc);
        this.c4.q = runOn(this, this.dn);
    }
    ap() {
        super.ap();
        if (!this.n) {
            this.e.bj = 8;
        }
    }
    get c5() {
        return this.c4;
    }
    dk(a) {
        this.c6.nv(a, this.c7);
    }
    cz() {
        this.c1 = this.c6.nb(this, this.c7, this.c1, this.bs, this.br);
        return this.c1;
    }
    cy() {
        this.c0 = this.c6.na(this.c7, this.c0);
        return this.c0;
    }
    cu(a, b) {
        return this.cv(a, b, true);
    }
    cc(a, b) {
        super.cc(a, b);
        ShapeSeriesViewBase.cb(this, a, b);
    }
    ca(a, b) {
        let c = a;
        if (c == null) {
            return;
        }
        c.ak = b;
    }
    de(a) {
        this.c7.f(a);
    }
    dg(a) {
        a.create = runOn(this, this.c3);
        a.destroy = runOn(this, this.di);
        a.activate = runOn(this, this.dh);
        a.disactivate = runOn(this, this.dj);
    }
    c3() {
        let a = new Marker();
        if (!this.c8) {
            a.content = ((() => {
                let $ret = new DataContext();
                $ret.series = this.e;
                return $ret;
            })());
        }
        a.ah = this.e.nw;
        this.c9.add(a);
        return a;
    }
    di(a) {
        a.content = null;
        this.c9.remove(a);
    }
    dh(a) {
        a._visibility = 0;
    }
    dj(a) {
        if (a.content != null) {
            (typeCast(DataContext.$, a.content)).item = null;
        }
        a._visibility = 1;
    }
    dl(a) {
        this.c8 = a;
    }
    be(a, b) {
        super.be(a, b);
        let c = a;
        let d = c.content;
        if (d != null) {
            if (this.c6.n9 != null) {
                d.actualItemBrush = this.c6.n9;
            }
            else {
                d.actualItemBrush = this.by.k3;
            }
            if (this.c6.n9 != null) {
                d.outline = this.c6.oa;
            }
            else {
                d.outline = this.by.k4;
            }
            d.thickness = 0.5;
        }
    }
    bf(a, b) {
        super.bf(a, b);
        let c = a;
        let d = this.bm(b);
        let e = c.content;
        if (e != null) {
            e.actualItemBrush = d;
            e.outline = d;
            e.thickness = 1 + 3;
        }
    }
    a2(a, b) {
        super.a2(a, b);
        let c = new DataTemplatePassInfo();
        c.isHitTestRender = b;
        c.context = a.g();
        c.viewportTop = this.br.top;
        c.viewportLeft = this.br.left;
        c.viewportWidth = this.br.width;
        c.viewportHeight = this.br.height;
        c.passID = "Markers";
        let d = new DataTemplateRenderInfo();
        d.passInfo = c;
        d.isHitTestRender = b;
        let e = new DataTemplateMeasureInfo();
        e.passInfo = c;
        let f = false;
        let g = a.g();
        e.context = g;
        d.context = g;
        let h = 0;
        let i = 0;
        if (this.c6.nw != null && this.c6.nw.passStarting != null) {
            this.c6.nw.passStarting(c);
        }
        for (let j = 0; j < this.c9.count; j++) {
            let k = this.c9._inner[j];
            if (k._visibility == 1) {
                continue;
            }
            this.bd(k, j, b);
            if (!f) {
                e.width = k.width;
                e.height = k.height;
                e.renderOffsetX = 0;
                e.renderOffsetY = 0;
                e.renderContext = a;
                let l = k.ah;
                if (l.measure != null) {
                    e.data = k.content;
                    l.measure(e);
                    f = e.isConstant;
                    if (f) {
                        h = e.width;
                        i = e.height;
                    }
                }
                d.availableWidth = e.width;
                d.availableHeight = e.height;
                d.renderOffsetX = e.renderOffsetX;
                d.renderOffsetY = e.renderOffsetY;
                d.renderContext = a;
            }
            else {
                d.availableWidth = h;
                d.availableHeight = i;
            }
            if (!isNaN_(k.width) && !isInfinity(k.width)) {
                d.availableWidth = k.width;
            }
            if (!isNaN_(k.height) && !isInfinity(k.height)) {
                d.availableHeight = k.height;
            }
            a.p(d, k);
            k.m = d.availableWidth;
            k.l = d.availableHeight;
            k.ai = d.renderOffsetX;
            k.aj = d.renderOffsetY;
        }
        if (this.c6.nw != null && this.c6.nw.passCompleted != null) {
            this.c6.nw.passCompleted(c);
        }
    }
    dd() {
        this.c6.nw = null;
        this.c6.nw = this.c6.nx;
    }
    db() {
        this.c6.n9 = null;
        this.c6.n9 = this.c6.ob;
    }
    dc() {
        this.c6.oa = null;
        this.c6.oa = this.c6.oc;
    }
    da(a) {
        switch (a) {
            case "CircleMarkerTemplate":
                this.c6.nw = this.c6.bs.kn;
                break;
            case "TriangleMarkerTemplate":
                this.c6.nw = this.c6.bs.kw;
                break;
            case "PyramidMarkerTemplate":
                this.c6.nw = this.c6.bs.kt;
                break;
            case "SquareMarkerTemplate":
                this.c6.nw = this.c6.bs.ku;
                break;
            case "DiamondMarkerTemplate":
                this.c6.nw = this.c6.bs.ko;
                break;
            case "PentagonMarkerTemplate":
                this.c6.nw = this.c6.bs.kr;
                break;
            case "HexagonMarkerTemplate":
                this.c6.nw = this.c6.bs.kp;
                break;
            case "TetragramMarkerTemplate":
                this.c6.nw = this.c6.bs.kr;
                break;
            case "PentagramMarkerTemplate":
                this.c6.nw = this.c6.bs.ks;
                break;
            case "HexagramMarkerTemplate":
                this.c6.nw = this.c6.bs.kq;
                break;
        }
    }
    df() {
        for (let a of fromEnum(this.c9)) {
            a.ah = this.c6.nw;
        }
        this.an();
    }
    dn(a) {
        if (this.dm == null) {
            this.dm = new DataTemplateMeasureInfo();
            this.dm.context = this.h.g();
        }
        this.dm.width = a.width;
        this.dm.height = a.height;
        this.dm.data = a.content;
        let b = a.ah;
        if (b.measure != null) {
            b.measure(this.dm);
        }
        return new Size(1, this.dm.width, this.dm.height);
    }
    c2(a) {
        let b;
        let c;
        let d;
        let e;
        for (let f = this.c9.count - 1; f >= 0; f--) {
            let g = this.c9._inner[f];
            if (g._visibility == 1 || g._opacity == 0) {
                continue;
            }
            b = (g.m / 2) + 3;
            c = (g.l / 2) + 3;
            d = g.ai;
            e = g.aj;
            if ((g.n + d) - b <= a.x && (g.n + d) + b >= a.x && (g.o + e) - c <= a.y && (g.o + e) + c >= a.y) {
                return g;
            }
        }
        return null;
    }
    ai(a) {
        let b = a;
        super.ai(b);
        for (let c of fromEnum(this.c7.c)) {
            let d = this.c7.item(c);
            if (d._visibility != 1) {
                let e = typeCast(ScatterPolygonSeries.$, this.e);
                let f = this.e.a2.getMarkerVisualData(e, d, e.nw);
                b.markerShapes.add(typeCast(MarkerVisualData.$, f));
            }
        }
    }
    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.c6.fx + "</span><br/>";
        a += "</div>";
        return a;
    }
}
ScatterPolygonSeriesView.$t = markType(ScatterPolygonSeriesView, 'ScatterPolygonSeriesView', ShapeSeriesViewBase.$);
//# sourceMappingURL=ScatterPolygonSeries_combined.js.map