/*
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/ES2015/DependencyProperty";
import { Style } from "igniteui-angular-core/ES2015/Style";
import { MarkerType_$type } from "./MarkerType";
import { DataTemplate } from "igniteui-angular-core/ES2015/DataTemplate";
import { Brush } from "igniteui-angular-core/ES2015/Brush";
import { CollisionAvoidanceType_$type } from "./CollisionAvoidanceType";
import { Rect } from "igniteui-angular-core/ES2015/Rect";
import { ScalerParams } from "./ScalerParams";
import { Type, Base, enumGetBox, typeCast, fromEnum, markType, PointUtil, runOn } from "igniteui-angular-core/ES2015/type";
import { Dictionary$2 } from "igniteui-angular-core/ES2015/Dictionary$2";
import { OwnedPoint } from "./OwnedPoint";
import { ShapeSeriesViewBase } from "./ShapeSeriesViewBase";
import { MarkerSeries } from "./MarkerSeries";
import { DataContext } from "igniteui-angular-core/ES2015/DataContext";
import { Marker } from "./Marker";
import { HashPool$2 } from "igniteui-angular-core/ES2015/HashPool$2";
import { List$1 } from "igniteui-angular-core/ES2015/List$1";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { RectUtil } from "igniteui-angular-core/ES2015/RectUtil";
import { PropertyMetadata } from "igniteui-angular-core/ES2015/PropertyMetadata";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { DataTemplateMeasureInfo } from "igniteui-angular-core/ES2015/DataTemplateMeasureInfo";
import { Size } from "igniteui-angular-core/ES2015/Size";
import { DataTemplatePassInfo } from "igniteui-angular-core/ES2015/DataTemplatePassInfo";
import { DataTemplateRenderInfo } from "igniteui-angular-core/ES2015/DataTemplateRenderInfo";
import { MarkerVisualData } from "./MarkerVisualData";
import { isNaN_, isInfinity } from "igniteui-angular-core/ES2015/number";
import { stringIsNullOrEmpty } from "igniteui-angular-core/ES2015/string";
/**
 * @hidden
 */
export class ScatterPolygonSeries extends ShapeSeriesBase {
    constructor() {
        super();
        this.m7 = null;
        this.m4 = new ScalerParams(1, ScatterPolygonSeries.n3, ScatterPolygonSeries.n3, false);
        this.m5 = new ScalerParams(1, ScatterPolygonSeries.n3, ScatterPolygonSeries.n3, false);
        this.ab = ScatterPolygonSeries.$;
    }
    l9() {
        return this.m9();
    }
    mq(a) {
        let b = a;
        b.cn(this.n5);
        b.co(this.m8);
        super.mq(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.m4 = new ScalerParams(1, d, c, this.ly.b8);
        this.m4.c = f;
        this.m5 = new ScalerParams(1, d, c, this.l0.b8);
        this.m5.c = f;
        if (c.width < 1 || c.height < 1) {
            return;
        }
        this.m7 = ((() => {
            let $ret = new ShapeAxisInfoCache();
            $ret.a = this.ly;
            $ret.b = this.l0;
            $ret.e = this.ly.b8;
            $ret.f = this.l0.b8;
            $ret.d = this.bz;
            $ret.c = this.l3;
            return $ret;
        })());
        if (this.m9()) {
            let g = new Dictionary$2(Base.$, OwnedPoint.$, 0);
            b.c4.l(g, 400, d, c, this.er);
            b.c4.j(g, false);
        }
    }
    m9() {
        return this.nm != null && ((this.m3 != 1 && this.m3 != 0) || this.nn != null);
    }
    bf() {
        return new ScatterPolygonSeriesView(this);
    }
    im(a) {
        super.im(a);
        this.m6 = a;
    }
    get_hasMarkers() {
        return true;
    }
    ky() {
        return this.nz;
    }
    kz() {
        return this.n0;
    }
    jr() {
        return this.nm;
    }
    jg() {
        super.jg();
        if (this.nn != null) {
            this.m6.dc();
        }
        else {
            let a = MarkerSeries.lu(this, this.m3);
            let b = MarkerSeries.l2(a);
            if (b == null) {
                this.nm = MarkerSeries.md;
            }
            else {
                this.m6.c9(b);
            }
        }
        if (this.n1 != null) {
            this.m6.da();
        }
        else {
            this.nz = this.bs == null ? null : this.bs.ma(this.fe);
        }
        if (this.n2 != null) {
            this.m6.db();
        }
        else {
            this.n0 = this.bs == null ? null : this.bs.mb(this.fe);
        }
    }
    is(a, b, c, d) {
        super.is(a, b, c, d);
        switch (b) {
            case ScatterPolygonSeries.$$p[3]:
            case ScatterPolygonSeries.$$p[8]:
            case ScatterPolygonSeries.$$p[5]:
            case ScatterPolygonSeries.$$p[7]:
                this.jg();
                this.i5(false);
                break;
            case ScatterPolygonSeries.$$p[2]:
                if (c == MarkerSeries.md || d == MarkerSeries.md || (c == null || d != null)) {
                    this.m6.de();
                    this.i5(false);
                }
                this.i5(false);
                this.ic();
                break;
            case ScatterPolygonSeries.$$p[9]:
                this.m6.cn(this.n5);
                this.i5(false);
                this.ic();
                break;
            case ScatterPolygonSeries.$$p[10]:
                this.m6.co(this.m8);
                this.i5(false);
                this.ic();
                break;
            case ScatterPolygonSeries.$$p[4]:
                this.i5(false);
                this.ic();
                break;
        }
    }
    ar(a, b) {
        let c = this.m6.c1(a);
        let d = null;
        if (c != null) {
            d = c.content;
        }
        if (d != null) {
            return d;
        }
        return super.ar(a, b);
    }
    nl(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.ly;
        let e = new ScalerParams(1, this.bs.mq, this.lq, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        let f = this.l0;
        let g = new ScalerParams(1, this.bs.mq, this.lq, f.b8);
        g.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.m6.dd((h) => {
            if (h._visibility == 0) {
                let i = new SeriesPointOfInterest();
                let j = h.n;
                let k = h.o;
                if (j < this.lq.left || j > this.lq.right || k < this.lq.top || k > this.lq.bottom) {
                    return;
                }
                i.b = d.dw(j, e);
                i.c = f.dw(k, g);
                i.a = h.content;
                a.add(i);
            }
        });
        return true;
    }
    m1(a, b, c, d, e) {
        if (c == null || c.length != this.m7.d.count) {
            c = new Array(this.m7.d.count);
            for (let f = 0; f < this.m7.d.count; f++) {
                c[f] = PointUtil.create();
            }
        }
        let g = ((() => {
            let $ret = new ScalerParams(1, d, e, this.ly.b8);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let h = ((() => {
            let $ret = new ScalerParams(1, d, e, this.l0.b8);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let i = this.m7.a.dw(g.d.left, g);
        let j = this.m7.a.dw(g.d.right, g);
        let k = this.m7.b.dw(h.d.bottom, h);
        let l = this.m7.b.dw(h.d.top, h);
        if (this.m7.e) {
            let m = i;
            i = j;
            j = m;
        }
        if (this.m7.f) {
            let n = k;
            k = l;
            l = n;
        }
        let o = this.m7;
        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.m7.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;
    }
    m0(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.n3 = new Rect(0, 0, 0, 1, 1);
Type.dep(DependencyProperty, PropertyMetadata, ScatterPolygonSeries, 'raisePropertyChanged', ['ActualMarkerBrush:nz:no', [Brush.$], 'ActualMarkerOutline:n0:np', [Brush.$], 'ActualMarkerTemplate:nm:nq', [DataTemplate.$, null], 'MarkerBrush:n1:nr', [Brush.$], 'MarkerCollisionAvoidance:m2:ns', [CollisionAvoidanceType_$type, enumGetBox(CollisionAvoidanceType_$type, 0)], 'MarkerOutline:n2:nt', [Brush.$], 'MarkerStyle:n4:nu', [Style.$], 'MarkerTemplate:nn:nv', [DataTemplate.$, null], 'MarkerType:m3:nw', [MarkerType_$type, enumGetBox(MarkerType_$type, 1)], 'ShapeStyle:n5:nx', [Style.$, null], 'ShapeStyleSelector:m8:ny', [StyleSelector.$, null]]);
/**
 * @hidden
 */
export class ScatterPolygonSeriesView extends ShapeSeriesViewBase {
    constructor(a) {
        super(a);
        this.c0 = null;
        this.cz = null;
        this.c5 = null;
        this.c3 = null;
        this.c7 = false;
        this.c6 = null;
        this.c8 = null;
        this.dl = null;
        this.c5 = a;
        this.c6 = new HashPool$2(Base.$, Marker.$);
        this.c8 = new List$1(Marker.$, 0);
        this.df(this.c6);
        this.c3 = new NumericMarkerManager(1, (b) => this.c6.item(b), (b) => this.c5.m7.d.item(b), runOn(this, this.dj), runOn(this, this.cy), runOn(this, this.cx), () => this.c5.m2);
        this.c3.q = runOn(this, this.dm);
    }
    ap() {
        super.ap();
        if (!this.n) {
            this.e.bj = 8;
        }
    }
    get c4() {
        return this.c3;
    }
    dj(a) {
        this.c5.nl(a, this.c6);
    }
    cy() {
        this.c0 = this.c5.m1(this, this.c6, this.c0, this.bs, this.br);
        return this.c0;
    }
    cx() {
        this.cz = this.c5.m0(this.c6, this.cz);
        return this.cz;
    }
    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.aj = b;
    }
    dd(a) {
        this.c6.f(a);
    }
    df(a) {
        a.create = runOn(this, this.c2);
        a.destroy = runOn(this, this.dh);
        a.activate = runOn(this, this.dg);
        a.disactivate = runOn(this, this.di);
    }
    c2() {
        let a = new Marker();
        if (!this.c7) {
            a.content = ((() => {
                let $ret = new DataContext();
                $ret.series = this.e;
                return $ret;
            })());
        }
        a.ah = this.e.nm;
        this.c8.add(a);
        return a;
    }
    dh(a) {
        a.content = null;
        this.c8.remove(a);
    }
    dg(a) {
        a._visibility = 0;
    }
    di(a) {
        if (a.content != null) {
            (typeCast(DataContext.$, a.content)).item = null;
        }
        a._visibility = 1;
    }
    dk(a) {
        this.c7 = a;
    }
    be(a, b) {
        super.be(a, b);
        let c = a;
        let d = c.content;
        if (d != null) {
            if (this.c5.nz != null) {
                d.actualItemBrush = this.c5.nz;
            }
            else {
                d.actualItemBrush = this.by.kv;
            }
            if (this.c5.nz != null) {
                d.outline = this.c5.n0;
            }
            else {
                d.outline = this.by.kw;
            }
            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.c5.nm != null && this.c5.nm.passStarting != null) {
            this.c5.nm.passStarting(c);
        }
        for (let j = 0; j < this.c8.count; j++) {
            let k = this.c8._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.c5.nm != null && this.c5.nm.passCompleted != null) {
            this.c5.nm.passCompleted(c);
        }
    }
    dc() {
        this.c5.nm = null;
        this.c5.nm = this.c5.nn;
    }
    da() {
        this.c5.nz = null;
        this.c5.nz = this.c5.n1;
    }
    db() {
        this.c5.n0 = null;
        this.c5.n0 = this.c5.n2;
    }
    c9(a) {
        switch (a) {
            case "CircleMarkerTemplate":
                this.c5.nm = this.c5.bs.kn;
                break;
            case "TriangleMarkerTemplate":
                this.c5.nm = this.c5.bs.kw;
                break;
            case "PyramidMarkerTemplate":
                this.c5.nm = this.c5.bs.kt;
                break;
            case "SquareMarkerTemplate":
                this.c5.nm = this.c5.bs.ku;
                break;
            case "DiamondMarkerTemplate":
                this.c5.nm = this.c5.bs.ko;
                break;
            case "PentagonMarkerTemplate":
                this.c5.nm = this.c5.bs.kr;
                break;
            case "HexagonMarkerTemplate":
                this.c5.nm = this.c5.bs.kp;
                break;
            case "TetragramMarkerTemplate":
                this.c5.nm = this.c5.bs.kr;
                break;
            case "PentagramMarkerTemplate":
                this.c5.nm = this.c5.bs.ks;
                break;
            case "HexagramMarkerTemplate":
                this.c5.nm = this.c5.bs.kq;
                break;
        }
    }
    de() {
        for (let a of fromEnum(this.c8)) {
            a.ah = this.c5.nm;
        }
        this.an();
    }
    dm(a) {
        if (this.dl == null) {
            this.dl = new DataTemplateMeasureInfo();
            this.dl.context = this.h.g();
        }
        this.dl.width = a.width;
        this.dl.height = a.height;
        this.dl.data = a.content;
        let b = a.ah;
        if (b.measure != null) {
            b.measure(this.dl);
        }
        return new Size(1, this.dl.width, this.dl.height);
    }
    c1(a) {
        let b;
        let c;
        let d;
        let e;
        for (let f = this.c8.count - 1; f >= 0; f--) {
            let g = this.c8._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.c6.c)) {
            let d = this.c6.item(c);
            if (d._visibility != 1) {
                let e = typeCast(ScatterPolygonSeries.$, this.e);
                let f = this.e.a2.getMarkerVisualData(e, d, e.nm);
                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.c5.fs + "</span><br/>";
        a += "</div>";
        return a;
    }
}
ScatterPolygonSeriesView.$t = markType(ScatterPolygonSeriesView, 'ScatterPolygonSeriesView', ShapeSeriesViewBase.$);
//# sourceMappingURL=ScatterPolygonSeries_combined.js.map