/*
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 * as tslib_1 from "tslib";
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
 */
var ScatterPolygonSeries = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterPolygonSeries, _super);
    function ScatterPolygonSeries() {
        var _this = _super.call(this) || this;
        _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.$;
        return _this;
    }
    ScatterPolygonSeries.prototype.mh = function () {
        return this.nj();
    };
    ScatterPolygonSeries.prototype.mz = function (a) {
        var _this = this;
        var b = a;
        b.cn(this.of);
        b.co(this.ni);
        _super.prototype.mz.call(this, a);
        if (this.cc(a)) {
            return;
        }
        var c, d;
        var e = a.getViewInfo(c, d);
        c = e.p0;
        d = e.p1;
        var 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 = ((function () {
            var $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()) {
            var g = new Dictionary$2(Base.$, OwnedPoint.$, 0);
            b.c5.l(g, 400, d, c, this.eu);
            b.c5.j(g, false);
        }
    };
    ScatterPolygonSeries.prototype.nj = function () {
        return this.nw != null && ((this.nd != 1 && this.nd != 0) || this.nx != null);
    };
    ScatterPolygonSeries.prototype.bf = function () {
        return new ScatterPolygonSeriesView(this);
    };
    ScatterPolygonSeries.prototype.iu = function (a) {
        _super.prototype.iu.call(this, a);
        this.ng = a;
    };
    ScatterPolygonSeries.prototype.get_hasMarkers = function () {
        return true;
    };
    ScatterPolygonSeries.prototype.k6 = function () {
        return this.n9;
    };
    ScatterPolygonSeries.prototype.k7 = function () {
        return this.oa;
    };
    ScatterPolygonSeries.prototype.jz = function () {
        return this.nw;
    };
    ScatterPolygonSeries.prototype.jo = function () {
        _super.prototype.jo.call(this);
        if (this.nx != null) {
            this.ng.dd();
        }
        else {
            var a = MarkerSeries.l2(this, this.nd);
            var 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);
        }
    };
    ScatterPolygonSeries.prototype.iz = function (a, b, c, d) {
        _super.prototype.iz.call(this, 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;
        }
    };
    ScatterPolygonSeries.prototype.ar = function (a, b) {
        var c = this.ng.c2(a);
        var d = null;
        if (c != null) {
            d = c.content;
        }
        if (d != null) {
            return d;
        }
        return _super.prototype.ar.call(this, a, b);
    };
    ScatterPolygonSeries.prototype.nv = function (a, b) {
        var e_1, _a, e_2, _b;
        var c = new List$1(Base.$, 0);
        try {
            for (var _c = tslib_1.__values(fromEnum(b.c)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var d = _d.value;
                if (!a.containsKey(d)) {
                    c.add1(d);
                }
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
            }
            finally { if (e_1) throw e_1.error; }
        }
        try {
            for (var _e = tslib_1.__values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var e = _f.value;
                b.g(e);
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
            }
            finally { if (e_2) throw e_2.error; }
        }
    };
    ScatterPolygonSeries.prototype.ch = function (a, b, c) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var d = this.l6;
        var e = new ScalerParams(1, this.bs.mq, this.ly, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        var f = this.l8;
        var g = new ScalerParams(1, this.bs.mq, this.ly, f.b8);
        g.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.ng.de(function (h) {
            if (h._visibility == 0) {
                var i = new SeriesPointOfInterest();
                var j = h.n;
                var 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;
    };
    ScatterPolygonSeries.prototype.nb = function (a, b, c, d, e) {
        var _this = this;
        if (c == null || c.length != this.nh.d.count) {
            c = new Array(this.nh.d.count);
            for (var f = 0; f < this.nh.d.count; f++) {
                c[f] = PointUtil.create();
            }
        }
        var g = ((function () {
            var $ret = new ScalerParams(1, d, e, _this.l6.b8);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var h = ((function () {
            var $ret = new ScalerParams(1, d, e, _this.l8.b8);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var i = this.nh.a.dz(g.d.left, g);
        var j = this.nh.a.dz(g.d.right, g);
        var k = this.nh.b.dz(h.d.bottom, h);
        var l = this.nh.b.dz(h.d.top, h);
        if (this.nh.e) {
            var m = i;
            i = j;
            j = m;
        }
        if (this.nh.f) {
            var n = k;
            k = l;
            l = n;
        }
        var o = this.nh;
        var p = o.a;
        var q = o.b;
        var r;
        var s;
        var t = g.d.left;
        var u = g.d.right;
        var v = h.d.top;
        var w = h.d.bottom;
        for (var x = 0; x < this.nh.d.count; x++) {
            r = 0;
            s = 0;
            var y = null;
            var z = a.b3.tryGetValue(x, y);
            y = z.p1;
            if (y == null) {
                c[x].x = NaN;
                c[x].y = NaN;
            }
            else {
                var aa = y.c;
                var 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;
    };
    ScatterPolygonSeries.prototype.na = function (a, b) {
        var e_3, _a;
        if (b == null || b.length != a.e) {
            b = new Array(a.e);
        }
        var c = 0;
        var d = this.bz;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                b[c] = d.indexOf(e);
                c++;
            }
        }
        catch (e_3_1) { e_3 = { error: e_3_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_3) throw e_3.error; }
        }
        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]]);
    return ScatterPolygonSeries;
}(ShapeSeriesBase));
export { ScatterPolygonSeries };
/**
 * @hidden
 */
var ScatterPolygonSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterPolygonSeriesView, _super);
    function ScatterPolygonSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _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, function (b) { return _this.c7.item(b); }, function (b) { return _this.c6.nh.d.item(b); }, runOn(_this, _this.dk), runOn(_this, _this.cz), runOn(_this, _this.cy), function () { return _this.c6.nc; });
        _this.c4.q = runOn(_this, _this.dn);
        return _this;
    }
    ScatterPolygonSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        if (!this.n) {
            this.e.bj = 8;
        }
    };
    Object.defineProperty(ScatterPolygonSeriesView.prototype, "c5", {
        get: function () {
            return this.c4;
        },
        enumerable: true,
        configurable: true
    });
    ScatterPolygonSeriesView.prototype.dk = function (a) {
        this.c6.nv(a, this.c7);
    };
    ScatterPolygonSeriesView.prototype.cz = function () {
        this.c1 = this.c6.nb(this, this.c7, this.c1, this.bs, this.br);
        return this.c1;
    };
    ScatterPolygonSeriesView.prototype.cy = function () {
        this.c0 = this.c6.na(this.c7, this.c0);
        return this.c0;
    };
    ScatterPolygonSeriesView.prototype.cu = function (a, b) {
        return this.cv(a, b, true);
    };
    ScatterPolygonSeriesView.prototype.cc = function (a, b) {
        _super.prototype.cc.call(this, a, b);
        ShapeSeriesViewBase.cb(this, a, b);
    };
    ScatterPolygonSeriesView.prototype.ca = function (a, b) {
        var c = a;
        if (c == null) {
            return;
        }
        c.ak = b;
    };
    ScatterPolygonSeriesView.prototype.de = function (a) {
        this.c7.f(a);
    };
    ScatterPolygonSeriesView.prototype.dg = function (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);
    };
    ScatterPolygonSeriesView.prototype.c3 = function () {
        var _this = this;
        var a = new Marker();
        if (!this.c8) {
            a.content = ((function () {
                var $ret = new DataContext();
                $ret.series = _this.e;
                return $ret;
            })());
        }
        a.ah = this.e.nw;
        this.c9.add(a);
        return a;
    };
    ScatterPolygonSeriesView.prototype.di = function (a) {
        a.content = null;
        this.c9.remove(a);
    };
    ScatterPolygonSeriesView.prototype.dh = function (a) {
        a._visibility = 0;
    };
    ScatterPolygonSeriesView.prototype.dj = function (a) {
        if (a.content != null) {
            (typeCast(DataContext.$, a.content)).item = null;
        }
        a._visibility = 1;
    };
    ScatterPolygonSeriesView.prototype.dl = function (a) {
        this.c8 = a;
    };
    ScatterPolygonSeriesView.prototype.be = function (a, b) {
        _super.prototype.be.call(this, a, b);
        var c = a;
        var 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;
        }
    };
    ScatterPolygonSeriesView.prototype.bf = function (a, b) {
        _super.prototype.bf.call(this, a, b);
        var c = a;
        var d = this.bm(b);
        var e = c.content;
        if (e != null) {
            e.actualItemBrush = d;
            e.outline = d;
            e.thickness = 1 + 3;
        }
    };
    ScatterPolygonSeriesView.prototype.a2 = function (a, b) {
        _super.prototype.a2.call(this, a, b);
        var 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";
        var d = new DataTemplateRenderInfo();
        d.passInfo = c;
        d.isHitTestRender = b;
        var e = new DataTemplateMeasureInfo();
        e.passInfo = c;
        var f = false;
        var g = a.g();
        e.context = g;
        d.context = g;
        var h = 0;
        var i = 0;
        if (this.c6.nw != null && this.c6.nw.passStarting != null) {
            this.c6.nw.passStarting(c);
        }
        for (var j = 0; j < this.c9.count; j++) {
            var 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;
                var 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);
        }
    };
    ScatterPolygonSeriesView.prototype.dd = function () {
        this.c6.nw = null;
        this.c6.nw = this.c6.nx;
    };
    ScatterPolygonSeriesView.prototype.db = function () {
        this.c6.n9 = null;
        this.c6.n9 = this.c6.ob;
    };
    ScatterPolygonSeriesView.prototype.dc = function () {
        this.c6.oa = null;
        this.c6.oa = this.c6.oc;
    };
    ScatterPolygonSeriesView.prototype.da = function (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;
        }
    };
    ScatterPolygonSeriesView.prototype.df = function () {
        var e_4, _a;
        try {
            for (var _b = tslib_1.__values(fromEnum(this.c9)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var a = _c.value;
                a.ah = this.c6.nw;
            }
        }
        catch (e_4_1) { e_4 = { error: e_4_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_4) throw e_4.error; }
        }
        this.an();
    };
    ScatterPolygonSeriesView.prototype.dn = function (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;
        var b = a.ah;
        if (b.measure != null) {
            b.measure(this.dm);
        }
        return new Size(1, this.dm.width, this.dm.height);
    };
    ScatterPolygonSeriesView.prototype.c2 = function (a) {
        var b;
        var c;
        var d;
        var e;
        for (var f = this.c9.count - 1; f >= 0; f--) {
            var 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;
    };
    ScatterPolygonSeriesView.prototype.ai = function (a) {
        var e_5, _a;
        var b = a;
        _super.prototype.ai.call(this, b);
        try {
            for (var _b = tslib_1.__values(fromEnum(this.c7.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                var d = this.c7.item(c);
                if (d._visibility != 1) {
                    var e = typeCast(ScatterPolygonSeries.$, this.e);
                    var f = this.e.a2.getMarkerVisualData(e, d, e.nw);
                    b.markerShapes.add(typeCast(MarkerVisualData.$, f));
                }
            }
        }
        catch (e_5_1) { e_5 = { error: e_5_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_5) throw e_5.error; }
        }
    };
    ScatterPolygonSeriesView.prototype.getDefaultTooltipTemplate = function () {
        var a = "<div class='ui-chart-default-tooltip-content'><span";
        var 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.$);
    return ScatterPolygonSeriesView;
}(ShapeSeriesViewBase));
export { ScatterPolygonSeriesView };
//# sourceMappingURL=ScatterPolygonSeries_combined.js.map