/*
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 { __extends, __values } from "tslib";
import { AnchoredRadialSeries } from "./AnchoredRadialSeries";
import { DependencyProperty } from "igniteui-angular-core";
import { Defaults } from "./Defaults";
import { Point_$type, runOn, typeCast, markType, markDep, fromEnum } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { RadialBaseView } from "./RadialBaseView";
import { List$1 } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { PolyLineSegment } from "igniteui-angular-core";
import { ViewportUtils } from "./ViewportUtils";
import { ChartSelection } from "./ChartSelection";
import { Clipper } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
/**
 * @hidden
 */
var RadialColumnSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialColumnSeries, _super);
    function RadialColumnSeries() {
        var _this = _super.call(this) || this;
        _this.ab = RadialColumnSeries.$;
        return _this;
    }
    RadialColumnSeries.prototype.bk = function () {
        return new RadialColumnSeries();
    };
    RadialColumnSeries.prototype.get_e1 = function () {
        return true;
    };
    RadialColumnSeries.prototype.get_fm = function () {
        return true;
    };
    RadialColumnSeries.prototype.jn = function () {
        if (!isNaN_(this.jm)) {
            return _super.prototype.jn.call(this);
        }
        return Defaults.h;
    };
    RadialColumnSeries.prototype.ct = function () {
        return new RadialColumnSeriesView(this);
    };
    RadialColumnSeries.prototype.q7 = function (a) {
        _super.prototype.q7.call(this, a);
        this.adx = a;
    };
    RadialColumnSeries.prototype.ac = function () {
        _super.prototype.ac.call(this);
        this.ry(false);
    };
    RadialColumnSeries.prototype.rg = function (a, b, c, d) {
        _super.prototype.rg.call(this, a, b, c, d);
        switch (b) {
            case RadialColumnSeries.$$p[0]:
            case RadialColumnSeries.$$p[1]:
                this.q9();
                break;
        }
    };
    RadialColumnSeries.prototype.preferredCategoryMode = function (a) {
        return a != null && a == this.y9 ? 2 : 0;
    };
    RadialColumnSeries.prototype.pb = function (a, b) {
        _super.prototype.pb.call(this, a, b);
        var c = b;
        if (a) {
            c.dj.count = 0;
        }
    };
    RadialColumnSeries.prototype.get_ef = function () {
        return true;
    };
    RadialColumnSeries.prototype.iy = function () {
        return this.y9.ou(this.cw.ca, this.cw.b9, this.getEffectiveViewport1(this.cw));
    };
    RadialColumnSeries.prototype.abk = function (a, b) {
        _super.prototype.abk.call(this, a, b);
        var c = a.h;
        var d = b.ca;
        var e = b.b9;
        var f = this.getEffectiveViewport1(b);
        var g = this.wt(b);
        var h = this.zf.or(e, d, f, g);
        var i = b;
        var j = this.zf;
        var k = Math.max(0, 0.5 * j.sa);
        k = Math.max(k, h.minLength * 0.9);
        var l = ViewportUtils.d(k, d, e, f);
        var m = this.y9.ou(d, e, f);
        var n = Math.max(0.1 * this.zf.sb, k);
        var o = this.zg.d(0, n, d, e, f);
        var p = this.zg.e(0, n, d, e, f);
        var q = this.zg.d(m, n, d, e, f);
        var r = this.zg.e(m, n, d, e, f);
        var s = Math.sqrt((o - q) * (o - q) + (p - r) * (p - r));
        var t = { $type: Point_$type, x: ViewportUtils.e(0.5, d, e, f), y: ViewportUtils.i(0.5, d, e, f) };
        var u = this.acg.count;
        this.zo.a2(this, this.z5(), runOn(this, this.yx), this.aae(b), this.aaf(b));
        this.zo.r = this.ady;
        this.zo.s = this.adz;
        this.zo.k = this.ady;
        this.zo.l = this.adz;
        var v = false;
        var w = this.zo.b;
        if (w != null) {
            v = true;
        }
        var x = this.y9;
        var y = new ScalerParams(1, b.ca, b.b9, x.df);
        y.c = this.getEffectiveViewport();
        for (var z = 0; z < c.count; ++z) {
            var aa = Math.min(a.h._inner[z][2], h.maxLength * 1.1);
            var ab = this.zg.d(a.h._inner[z][0], aa, d, e, f);
            var ac = this.zg.e(a.h._inner[z][0], aa, d, e, f);
            var ad = Math.sqrt((ab - t.x) * (ab - t.x) + (ac - t.y) * (ac - t.y));
            var ae = ad;
            var af = l;
            if (v) {
                this.add(c, z, u, x, y, b.t);
            }
            var ag = this.zo.k;
            var ah = this.zo.l;
            var ai = a.h._inner[z][0] - (Math.PI / 2);
            var aj = i.dj.item(z);
            var ak = 0 - (s / 2);
            var al = (s / 2);
            var am = Math.max(af, ae);
            var an = Math.min(af, ae);
            var ao = Math.cos(ai);
            var ap = Math.sin(ai);
            var aq = { $type: Point_$type, x: t.x + (ak * ao - am * ap), y: t.y + (ak * ap + am * ao) };
            var ar = { $type: Point_$type, x: t.x + (al * ao - am * ap), y: t.y + (al * ap + am * ao) };
            var as = { $type: Point_$type, x: t.x + (al * ao - an * ap), y: t.y + (al * ap + an * ao) };
            var at = { $type: Point_$type, x: t.x + (ak * ao - an * ap), y: t.y + (ak * ap + an * ao) };
            var au = new PathGeometry();
            var av = new PathFigure();
            av._startPoint = aq;
            av._isClosed = true;
            var aw = new PolyLineSegment();
            aw._points.add(ar);
            aw._points.add(as);
            aw._points.add(at);
            av._segments.add(aw);
            au.c.add(av);
            aj.an = au;
            this.zo.ad(aj, false, false, false, false);
        }
        i.dj.count = c.count;
        this.adx.dp();
    };
    RadialColumnSeries.prototype.ak = function (a, b) {
        var c = new List$1(ChartSelection.$, 0);
        this.qa(a, c, b);
        return c.toArray();
    };
    RadialColumnSeries.prototype.qa = function (a, b, c) {
        var _this = this;
        if (this.za == 0) {
            _super.prototype.qa.call(this, a, b, c);
            return;
        }
        var d = this.cw.ca;
        var e = this.cw.b9;
        var f = this.getEffectiveViewport1(this.cw);
        var g = this.dc.xu(this.w2, this.getEffectiveViewport(), d);
        var h = this.zf.or(e, d, f, g);
        var i = { $type: Point_$type, x: ViewportUtils.e(0.5, d, e, f), y: ViewportUtils.i(0.5, d, e, f) };
        var j = this.dc.xr(a);
        var k = new Clipper(1, j.left, j.bottom, j.right, j.top, true);
        var l = this.zf;
        var m = Math.max(0, 0.5 * l.sa);
        m = Math.max(m, h.minLength * 0.9);
        var n = ViewportUtils.d(m, d, e, f);
        var o = this.y9.ou(d, e, f);
        var p = Math.max(0.1 * this.zf.sb, m);
        var q = this.zg.d(0, p, d, e, f);
        var r = this.zg.e(0, p, d, e, f);
        var s = this.zg.d(o, p, d, e, f);
        var t = this.zg.e(o, p, d, e, f);
        var u = Math.sqrt((q - s) * (q - s) + (r - t) * (r - t));
        var v = this.y9 != null && this.y9.dj;
        var _loop_1 = function (w) {
            var x = typeCast(RadialBaseView.$, this_1.cw);
            var y = x.da.getBucket(w);
            var z = Math.min(this_1.zg.b.sh(y[2]), h.maxLength * 1.1);
            var aa = this_1.acr(this_1.y9, d, e, f);
            if (v) {
                aa = this_1.acq(w, this_1.y9, d, e, f);
                if (isNaN_(aa)) {
                    aa = 0;
                }
            }
            y[0] = this_1.y9.getScaledAngle(y[0]) + aa;
            var ab = this_1.zg.d(y[0], z, d, e, f);
            var ac = this_1.zg.e(y[0], z, d, e, f);
            var ad = Math.sqrt((ab - i.x) * (ab - i.x) + (ac - i.y) * (ac - i.y));
            var ae = ad;
            var af = n;
            var ag = y[0] - (Math.PI / 2);
            var ah = 0 - (u / 2);
            var ai = (u / 2);
            var aj = Math.max(af, ae);
            var ak = Math.min(af, ae);
            var al = Math.cos(ag);
            var am = Math.sin(ag);
            var an = { $type: Point_$type, x: i.x + (ah * al - aj * am), y: i.y + (ah * am + aj * al) };
            var ao = { $type: Point_$type, x: i.x + (ai * al - aj * am), y: i.y + (ai * am + aj * al) };
            var ap = { $type: Point_$type, x: i.x + (ai * al - ak * am), y: i.y + (ai * am + ak * al) };
            var aq = { $type: Point_$type, x: i.x + (ah * al - ak * am), y: i.y + (ah * am + ak * al) };
            var ar = new List$1(Point_$type, 0);
            k.i = ar;
            k.j(an);
            k.j(ao);
            k.j(ap);
            k.j(aq);
            k.i = null;
            if (ar == null || ar.count == 0) {
                return "continue";
            }
            if (c == 7 || c == 6) {
                b.add(((function () {
                    var $ret = new ChartSelection();
                    $ret.series = _this;
                    return $ret;
                })()));
                return { value: void 0 };
            }
            else if (c == 2 || c == 1) {
                b.add(((function () {
                    var $ret = new ChartSelection();
                    $ret.item = _this.dp.item(w);
                    return $ret;
                })()));
            }
            else {
                b.add(((function () {
                    var $ret = new ChartSelection();
                    $ret.item = _this.dp.item(w);
                    $ret.series = _this;
                    return $ret;
                })()));
            }
        };
        var this_1 = this;
        for (var w = 0; w < this.y9.o6; w++) {
            var state_1 = _loop_1(w);
            if (typeof state_1 === "object")
                return state_1.value;
        }
    };
    RadialColumnSeries.$t = markType(RadialColumnSeries, 'RadialColumnSeries', AnchoredRadialSeries.$);
    RadialColumnSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RadialColumnSeries, 'raisePropertyChanged', ['RadiusX:ady:ad2', [1, 0], 'RadiusY:adz:ad3', [1, 0]]);
    return RadialColumnSeries;
}(AnchoredRadialSeries));
export { RadialColumnSeries };
/**
 * @hidden
 */
var RadialColumnSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialColumnSeriesView, _super);
    function RadialColumnSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.di = null;
        _this.dj = null;
        _this.dk = null;
        _this.dr = new Path();
        _this.di = a;
        _this.dj = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.ds);
            $ret.activate = runOn(_this, _this.dl);
            $ret.disactivate = runOn(_this, _this.dn);
            $ret.destroy = runOn(_this, _this.dm);
            return $ret;
        })());
        return _this;
    }
    RadialColumnSeriesView.prototype.a4 = function () {
        _super.prototype.a4.call(this);
        this.dk = new List$1(Path.$, 0);
        if (!this.t) {
            this.c9.xk = Defaults.c;
            this.c9.jt = Defaults.i;
        }
    };
    RadialColumnSeriesView.prototype.ds = function () {
        var a = new Path();
        this.dk.add(a);
        a._visibility = 1;
        return a;
    };
    RadialColumnSeriesView.prototype.dl = function (a) {
        a._visibility = 0;
    };
    RadialColumnSeriesView.prototype.dn = function (a) {
        a._visibility = 1;
    };
    RadialColumnSeriesView.prototype.dm = function (a) {
        this.dk.remove(a);
    };
    RadialColumnSeriesView.prototype.dq = function (a, b, c, d, e, f) {
        this.a2();
    };
    RadialColumnSeriesView.prototype.bs = function (a, b) {
        _super.prototype.bs.call(this, a, b);
        var c = a;
    };
    RadialColumnSeriesView.prototype.bt = function (a, b) {
        _super.prototype.bt.call(this, a, b);
        var c = a;
    };
    RadialColumnSeriesView.prototype.ak = function (a) {
        return this.dk._inner[a];
    };
    RadialColumnSeriesView.prototype.aj = function (a) {
        var b = this.dk._inner[a];
        this.dr._visibility = b._visibility;
        this.dr.an = b.an;
        var c = this.b4(a);
        this.dr._fill = c;
        this.dr._stroke = c;
        this.dr.ad = this.f.ig + 3;
        return this.dr;
    };
    RadialColumnSeriesView.prototype.bj = function (a, b) {
        _super.prototype.bj.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.dk.count; c++) {
                var d = this.ai(c, b);
                this.br(d, c, b);
                a.t(d);
            }
        }
    };
    RadialColumnSeriesView.prototype.ax = function (a) {
        var e_1, _a;
        _super.prototype.ax.call(this, a);
        var b = 0;
        try {
            for (var _b = __values(fromEnum(this.dj.a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                this.f.bc.exportPathData(a, c, "column" + b, ["Main", "Fill"]);
                b++;
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
    };
    RadialColumnSeriesView.prototype.dp = function () {
        this.a2();
    };
    RadialColumnSeriesView.$t = markType(RadialColumnSeriesView, 'RadialColumnSeriesView', AnchoredRadialSeriesView.$);
    return RadialColumnSeriesView;
}(AnchoredRadialSeriesView));
export { RadialColumnSeriesView };
