/*
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 { FinancialSeries } from "./FinancialSeries";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { TrendLineType_$type } from "igniteui-react-core/ES5/TrendLineType";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { Brush } from "igniteui-react-core/ES5/Brush";
import { PenLineCap_$type } from "igniteui-react-core/ES5/PenLineCap";
import { DoubleCollection } from "igniteui-react-core/ES5/DoubleCollection";
import { PriceDisplayType_$type } from "./PriceDisplayType";
import { Type, enumGetBox, EnumUtil, typeCast, fromEnum, runOn, Point_$type, markType } from "igniteui-react-core/ES5/type";
import { CategoryFrame } from "./CategoryFrame";
import { ISortingAxis_$type } from "./ISortingAxis";
import { FinancialSeriesView } from "./FinancialSeriesView";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { RectUtil } from "igniteui-react-core/ES5/RectUtil";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { AxisRange } from "./AxisRange";
import { ScalerParams } from "./ScalerParams";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { Pool$1 } from "igniteui-react-core/ES5/Pool$1";
import { Path } from "igniteui-react-core/ES5/Path";
import { PathGeometry } from "igniteui-react-core/ES5/PathGeometry";
import { PathFigure } from "igniteui-react-core/ES5/PathFigure";
import { LineSegment } from "igniteui-react-core/ES5/LineSegment";
import { GeometryGroup } from "igniteui-react-core/ES5/GeometryGroup";
import { LineGeometry } from "igniteui-react-core/ES5/LineGeometry";
import { RectangleGeometry } from "igniteui-react-core/ES5/RectangleGeometry";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { truncate, isNaN_ } from "igniteui-react-core/ES5/number";
import { boxArray$1 } from "igniteui-react-core/ES5/array";
import { FinancialPriceBucketCalculator } from "./FinancialPriceBucketCalculator";
import { Extensions } from "igniteui-react-core/ES5/Extensions";
var FinancialPriceSeries = /** @class */ (function (_super) {
    tslib_1.__extends(FinancialPriceSeries, _super);
    function FinancialPriceSeries() {
        var _this = _super.call(this) || this;
        _this.ab = FinancialPriceSeries.$;
        _this.lz = new CategoryFrame(5);
        _this.l1 = new CategoryFrame(5);
        _this.ly = new CategoryFrame(5);
        return _this;
    }
    FinancialPriceSeries.prototype.bf = function () {
        return new FinancialPriceSeriesView(this);
    };
    FinancialPriceSeries.prototype.ii = function (a) {
        _super.prototype.ii.call(this, a);
        this.o7 = a;
    };
    Object.defineProperty(FinancialPriceSeries.prototype, "pr", {
        get: function () {
            return this.c(FinancialPriceSeries.ph);
        },
        set: function (a) {
            this.h(FinancialPriceSeries.ph, a);
        },
        enumerable: true,
        configurable: true
    });
    FinancialPriceSeries.prototype.ho = function (a, b, c, d) {
        _super.prototype.ho.call(this, a, b, c, d);
        if (this.lw != null && typeCast(ISortingAxis_$type, this.lw) !== null) {
            this.lw.i$i();
        }
        this.o7.bs.e(this.eo);
        if (this.o7.b2) {
            this.o7.b0.g$e(a, b, c, d);
        }
        if (this.mg != null) {
            this.mg.ck();
        }
        this.i1(true);
    };
    FinancialPriceSeries.prototype.bd = function () {
        if (this.be == 0) {
            return 1;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    FinancialPriceSeries.prototype.li = function (a) {
        if (this.ly == null || this.ly.f.count == 0) {
            return Rect.empty;
        }
        var b = this.k4(a);
        var c = this.bi.bq;
        var d = this.bi.bp;
        var e = this.getEffectiveViewport1(this.bi);
        var f = this.aj(this.lw, this.ly.f, this.nr(this.bi), this.nt(this.bi), a, true);
        var g = f[0];
        var h = f[1];
        var i = Math.abs(b.x - g[0]);
        var j = Math.abs(b.x - h[0]);
        var k = this.o9(this.mc, e);
        k = Math.max(k, 3);
        var l = (k - 1) / 2;
        if (i < j) {
            var m = g[0] - l;
            var n = g[0];
            var o = g[0] + l;
            var p = g[1];
            var q = g[2];
            var r = g[3];
            var s = g[4];
            var t = Math.min(Math.min(Math.min(p, q), r), s);
            var u = Math.max(Math.max(Math.max(p, q), r), s);
            return new Rect(0, m, t, Math.abs(o - m), u - t);
        }
        else {
            var v = h[0] - l;
            var w = h[0];
            var x = h[0] + l;
            var y = h[1];
            var z = h[2];
            var aa = h[3];
            var ab = h[4];
            var ac = Math.min(Math.min(Math.min(y, z), aa), ab);
            var ad = Math.max(Math.max(Math.max(y, z), aa), ab);
            return new Rect(0, v, ac, Math.abs(x - v), ad - ac);
        }
    };
    FinancialPriceSeries.prototype.o6 = function (a, b) {
        var c = a[0] - b;
        var d = a[0];
        var e = a[0] + b;
        var f = a[1];
        var g = a[2];
        var h = a[3];
        var i = a[4];
        var j = Math.min(Math.min(Math.min(f, g), h), i);
        var k = Math.max(Math.max(Math.max(f, g), h), i);
        var l = Math.min(g, h);
        var m = Math.max(g, h);
        var n = Math.min(f, i);
        var o = Math.max(f, i);
        if (this.o8 == 1) {
            var p = new Array(3);
            var q = new Rect(0, c, f, b, 0);
            var r = new Rect(0, d, i, b, 0);
            var s = new Rect(0, d, l, 0, m - l);
            p[0] = q;
            p[1] = r;
            p[2] = s;
            return p;
        }
        else {
            var t = new Array(2);
            var u = new Rect(0, d, l, 0, m - l);
            var v = new Rect(0, c, n, b * 2, o - n);
            t[0] = u;
            t[1] = v;
            return t;
        }
    };
    FinancialPriceSeries.prototype.ak = function (a) {
        var b = new List$1(Rect.$, 0);
        var c = this.k4(a);
        var d = this.bi.bq;
        var e = this.bi.bp;
        var f = this.getEffectiveViewport1(this.bi);
        var g = this.aj(this.lw, this.ly.f, this.nr(this.bi), this.nt(this.bi), a, true);
        var h = g[0];
        var i = g[1];
        var j = Math.abs(c.x - h[0]);
        var k = Math.abs(c.x - i[0]);
        var l = this.o9(this.mc, f);
        l = Math.max(l, 3);
        var m = (l - 1) / 2;
        if (j < k) {
            return this.o6(h, m);
        }
        else {
            return this.o6(i, m);
        }
    };
    FinancialPriceSeries.prototype.de = function (a, b) {
        if (this.dh(a, b)) {
            return true;
        }
        return false;
    };
    FinancialPriceSeries.prototype.dh = function (a, b) {
        var c = this.lj(a);
        if (c.isEmpty) {
            return false;
        }
        var d = RectUtil.r(c, (this.es / 2) + this.d9(b));
        if (d.containsPoint(a)) {
            var e = this.al(a);
            if (e != null) {
                for (var f = 0; f < e.length; f++) {
                    var g = e[f];
                    var h = RectUtil.r(g, (this.es / 2) + this.d9(b));
                    if (h.containsPoint(a)) {
                        return true;
                    }
                }
            }
        }
        return false;
    };
    FinancialPriceSeries.prototype.io = function (a, b, c, d) {
        switch (b) {
            case FinancialSeries.$$p[9]:
                this.o7.b8();
                break;
            case "TrendLineType":
                var e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                if (e != 0) {
                    this.o7.b0 = CategoryTrendLineManagerFactory.a(this.o7.b0, this.lw, this.jl, this, this.b2);
                }
                break;
        }
        _super.prototype.io.call(this, a, b, c, d);
        if (this.o7.b2 && this.o7.b0 != null && this.o7.b0.g$b(a, b, c, d)) {
            this.i1(false);
            this.h8();
        }
        switch (b) {
            case FinancialPriceSeries.$$p[0]:
                if (this.jl != null) {
                    this.pg();
                    this.ly.w();
                    this.on(this.ly, this.o7);
                }
                this.h8();
                break;
            case "TrendLineBrush":
                this.jc();
                break;
            case "TrendLineType":
                this.h8();
                break;
            case FinancialSeries.$$p[5]:
            case FinancialPriceSeries.$$p[1]:
                this.ik();
                break;
        }
    };
    FinancialPriceSeries.prototype.pg = function () {
        this.o7.cc();
        if (this.bh != null) {
            this.bh.cc();
        }
    };
    FinancialPriceSeries.prototype.an = function (a) {
        if (a != null && a == this.mg && this.mm != null && !isNaN_(this.mm.minimum) && this.mk != null && !isNaN_(this.mk.maximum)) {
            return new AxisRange(this.mm.minimum, this.mk.maximum);
        }
        return null;
    };
    FinancialPriceSeries.prototype.ao = function () {
        if (this.mm == null || this.mk == null) {
            return null;
        }
        var a = new ScalerParams(0, this.bs.mk, this.bs.mx, this.lw.b8, this.getEffectiveViewport());
        var b = (this.lw.dw(this.bs.mx.left, a));
        var c = (this.lw.dw(this.bs.mx.right, a));
        var d = null;
        if (this.lw.cc) {
            d = this.lw;
            b = d.i$f(b);
            c = d.i$f(c);
        }
        else {
            b = Math.floor(b);
            c = Math.ceil(c);
        }
        b = Math.max(0, Math.min(this.mm.count - 1, b));
        c = Math.max(0, Math.min(this.mm.count - 1, c));
        var e = 1.7976931348623157E+308;
        var f = -1.7976931348623157E+308;
        for (var g = truncate(b); g <= truncate(c); g++) {
            var h = g;
            if (d != null) {
                h = d.i$b._inner[g];
            }
            e = Math.min(e, this.mm.item(h));
            f = Math.max(f, this.mk.item(h));
        }
        return new AxisRange(e, f);
    };
    FinancialPriceSeries.prototype.ec = function () {
        return this.mo == null || this.mo.count == 0 ? NaN : this.mo.item(0);
    };
    FinancialPriceSeries.prototype.c6 = function (a) {
        var b = this.bz != null ? this.bz.indexOf(a) : -1;
        var c = this.bi.bq;
        c = c.copy();
        var d = this.bi.bp;
        var e = new Rect(0, 0, 0, 1, 1);
        var f = this.lg(this.bi);
        if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
            if (this.lw != null) {
                var g = new ScalerParams(0, e, e, this.lw.b8, f);
                var h = this.lw.dt(b, g);
                if (h < c.left + 0.1 * c.width) {
                    h = h + 0.4 * c.width;
                }
                if (h > c.right - 0.1 * c.width) {
                    h = h - 0.4 * c.width;
                }
                c.x = h - 0.5 * c.width;
            }
            if (this.mg != null && this.mm != null && this.mk != null && b < this.mm.count && b < this.mk.count) {
                var i = new ScalerParams(0, e, e, this.mg.b8, f);
                var j = this.mg.dt(this.mm.item(b), i);
                var k = this.mg.dt(this.mk.item(b), i);
                if (!isNaN_(j) && !isNaN_(k)) {
                    var l = Math.abs(j - k);
                    if (c.height < l) {
                        c.height = l;
                        c.y = Math.min(j, k);
                    }
                    else {
                        if (j < c.top + 0.1 * c.height) {
                            j = j + 0.4 * c.height;
                        }
                        if (j > c.bottom - 0.1 * c.height) {
                            j = j - 0.4 * c.height;
                        }
                        c.y = j - 0.5 * c.height;
                    }
                }
            }
            this.bn.ap(this.bs, c, true);
        }
        return b >= 0;
    };
    FinancialPriceSeries.prototype.dt = function (a, b, c) {
        var d = _super.prototype.dt.call(this, a, b, c);
        if (this.mo == null || this.mi == null || this.mk == null || this.mm == null) {
            d = false;
        }
        return d;
    };
    FinancialPriceSeries.prototype.ol = function (a, b) {
        var _this = this;
        _super.prototype.ol.call(this, a, b);
        var c = b.bq;
        var d = b.bp;
        var e = this.getEffectiveViewport1(b);
        var f = this.lw;
        var g = this.mg;
        var h = new ScalerParams(0, c, d, f.b8, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, g.b8, e);
            $ret.b = _this.ec();
            return $ret;
        })());
        a.f.clear();
        a.m.clear();
        a.p.clear();
        var j = 0;
        var k = typeCast(ISortingAxis_$type, this.lw);
        if (k != null && (k.i$b == null || k.i$b.count != this.bz.count)) {
            return;
        }
        j = this.nl(c, d, e);
        var l = typeCast(FinancialPriceSeriesView.$, b);
        if (this.trendLineType != 0) {
            var m = new Array(this.bz.count);
            var n = 0;
            try {
                for (var _a = tslib_1.__values(fromEnum(this.nc)), _b = _a.next(); !_b.done; _b = _a.next()) {
                    var o = _b.value;
                    m[n] = o;
                    n++;
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
                }
                finally { if (e_1) throw e_1.error; }
            }
            if (this.o7.b2) {
                this.o7.b0.prepareLineCore(a.p, this.trendLineType, boxArray$1(m), this.trendLinePeriod, function (p) { return _this.lw.dt(p, h); }, function (p) { return _this.mg.dt(p, i); }, ((function () {
                    var $ret = new TrendResolutionParams();
                    $ret.c = b.bs.b;
                    $ret.d = b.bs.c;
                    $ret.e = b.bs.d;
                    $ret.a = j;
                    $ret.b = _this.eo;
                    $ret.f = d;
                    return $ret;
                })()));
            }
        }
        var p = this.lw.dw(2, h) - this.lw.dw(1, h);
        for (var q = b.bs.c; q <= b.bs.d; ++q) {
            var r = void 0;
            if (k == null) {
                r = b.bs.getBucket(q);
            }
            else {
                var s = k.i$b._inner[q];
                var t = k.i$d(s);
                var u = this.mo.item(s);
                var v = this.mk.item(s);
                var w = this.mm.item(s);
                var x = this.mi.item(s);
                var y = u;
                var z = v;
                var aa = w;
                var ab = x;
                var ac = t;
                while (q < b.bs.d) {
                    s = k.i$b._inner[q + 1];
                    ac = k.i$d(s);
                    if (ac - t > p * this.eo) {
                        break;
                    }
                    q++;
                    z = Math.max(z, this.mk.item(s));
                    aa = Math.min(aa, this.mm.item(s));
                    ab = this.mi.item(s);
                }
                var ad = NaN;
                if (!isNaN_(t)) {
                    ad = this.lw.dt(t, h);
                }
                r = [ad, y, z, aa, ab];
            }
            if (!isNaN_(r[0])) {
                if (this.lw != null && typeCast(ISortingAxis_$type, this.lw) !== null) {
                    r[0] = r[0] + j;
                }
                else {
                    r[0] = f.dt(r[0], h) + j;
                }
                r[1] = g.dt(r[1], i);
                r[2] = g.dt(r[2], i);
                r[3] = g.dt(r[3], i);
                r[4] = g.dt(r[4], i);
                a.f.add(r);
            }
        }
        return;
        var e_1, _c;
    };
    FinancialPriceSeries.prototype.hl = function (a, b) {
        _super.prototype.hl.call(this, a, b);
        var c = typeCast(FinancialPriceSeriesView.$, b);
        c.b6();
        if (a) {
            c.b1.count = 0;
        }
        if (c.b2 && c.b0 != null) {
            c.b0.g$d();
        }
    };
    FinancialPriceSeries.prototype.get_my = function () {
        return true;
    };
    Object.defineProperty(FinancialPriceSeries.prototype, "my", {
        get: function () {
            return this.get_my();
        },
        enumerable: true,
        configurable: true
    });
    FinancialPriceSeries.prototype.on = function (a, b) {
        _super.prototype.on.call(this, a, b);
        if (this.lw == null || this.mg == null) {
            return;
        }
        var c = false;
        if (b.bv(a)) {
            c = true;
            b.bx(a);
        }
        this.l4.x(this, this.m2(), this.lw, runOn(this, this.lo), this.nr(b), this.nt(b));
        var d = false;
        var e = this.l4.c;
        if (e != null) {
            d = true;
        }
        var f = typeCast(FinancialPriceSeriesView.$, b);
        f.b5();
        f.b3 = false;
        if (f.b2) {
            f.b0.g$d();
        }
        if (this.trendLineType != 0) {
            f.b0.g$g(a.p);
        }
        if (d) {
            this.pf(a, b, c);
        }
        else {
            f.b1.count = 0;
            this.pe(a, b);
        }
    };
    FinancialPriceSeries.prototype.eb = function () {
        var a = this.getEffectiveViewport1(this.bi);
        return this.o9(this.mc, a);
    };
    FinancialPriceSeries.prototype.pf = function (a, b, c) {
        var d = this.o8;
        var e = this.getEffectiveViewport1(b);
        var f = this.o9(b, e);
        var g = (f - 1) / 2;
        var h = typeCast(FinancialPriceSeriesView.$, b);
        h.b3 = true;
        var i = a.f;
        var j = 0;
        var k = this.bz.count;
        var l = this.lw;
        var m = new ScalerParams(0, b.bq, b.bp, l.b8, e);
        var n = this.kr;
        var o = this.o0;
        if (o == null) {
            o = n;
        }
        var p = this.ks;
        var q = this.ps;
        if (q == null) {
            q = p;
        }
        var _loop_1 = function (r) {
            var s = i._inner[r][0] - g;
            var t = i._inner[r][0];
            var u = i._inner[r][0] + g;
            var v = i._inner[r][1];
            var w = i._inner[r][2];
            var x = i._inner[r][3];
            var y = i._inner[r][4];
            if (isNaN_(v) || isNaN_(w) || isNaN_(x) || isNaN_(y)) {
                return "continue";
            }
            var z = h.b1.item(j);
            j++;
            var aa = v < y;
            var ab = new PathGeometry();
            if (c) {
                switch (d) {
                    case 0:
                        if (aa) {
                            var ac = v;
                            v = y;
                            y = ac;
                        }
                        var ad = new PathFigure();
                        ad._startPoint = { $type: Point_$type, x: t, y: x };
                        ad._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: v };
                            return $ret;
                        })()));
                        var ae = new PathFigure();
                        ae._startPoint = { $type: Point_$type, x: s, y: y };
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: y };
                            return $ret;
                        })()));
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: v };
                            return $ret;
                        })()));
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: s, y: v };
                            return $ret;
                        })()));
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: s, y: y };
                            return $ret;
                        })()));
                        var af = new PathFigure();
                        af._startPoint = { $type: Point_$type, x: t, y: y };
                        af._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: w };
                            return $ret;
                        })()));
                        ab.b.add(ad);
                        ab.b.add(ae);
                        ab.b.add(af);
                        break;
                    case 1:
                        var ag = new PathFigure();
                        ag._startPoint = { $type: Point_$type, x: s, y: v };
                        ag._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: v };
                            return $ret;
                        })()));
                        var ah = new PathFigure();
                        ah._startPoint = { $type: Point_$type, x: t, y: x };
                        ah._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: w };
                            return $ret;
                        })()));
                        var ai = new PathFigure();
                        ai._startPoint = { $type: Point_$type, x: t, y: y };
                        ai._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: y };
                            return $ret;
                        })()));
                        ab.b.add(ag);
                        ab.b.add(ah);
                        ab.b.add(ai);
                        break;
                }
            }
            if (aa) {
                this_1.l4.al = o;
                this_1.l4.ah = o;
                this_1.l4.am = this_1.l4.ai = q;
                this_1.l4.f = true;
            }
            else {
                this_1.l4.al = n;
                this_1.l4.ah = n;
                this_1.l4.am = this_1.l4.ai = p;
                this_1.l4.f = false;
            }
            this_1.ok(i, r, k, l, m, b.n);
            if (d == 1) {
                this_1.l4.ae(z, true, false, false, false);
            }
            else {
                this_1.l4.ae(z, false, false, false, false);
            }
            if (c) {
                z.aj = ab;
            }
        };
        var this_1 = this;
        for (var r = 0; r < i.count; ++r) {
            _loop_1(r);
        }
        h.b1.count = j;
        h.b7();
    };
    FinancialPriceSeries.prototype.o9 = function (a, b) {
        var c = this.lw.jj(a.bq, a.bp, b);
        c = Math.max(c, this.eo * 0.9);
        c = Math.max(c, 3);
        return c;
    };
    FinancialPriceSeries.prototype.pe = function (a, b) {
        var c = this.o8;
        var d = this.getEffectiveViewport1(b);
        var e = this.o9(b, d);
        var f = (e - 1) / 2;
        var g = typeCast(FinancialPriceSeriesView.$, b);
        var h = g.cf();
        var i = g.ce();
        var j = a.f;
        var _loop_2 = function (k) {
            var l = j._inner[k][0] - f;
            var m = j._inner[k][0];
            var n = j._inner[k][0] + f;
            var o = j._inner[k][1];
            var p = j._inner[k][2];
            var q = j._inner[k][3];
            var r = j._inner[k][4];
            if (isNaN_(o) || isNaN_(p) || isNaN_(q) || isNaN_(r)) {
                return "continue";
            }
            var s = o < r;
            var t = s ? i : h;
            switch (c) {
                case 0:
                    if (s) {
                        var u = o;
                        o = r;
                        r = u;
                    }
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: m, y: q };
                        $ret.b = { $type: Point_$type, x: m, y: o };
                        return $ret;
                    })()));
                    t.c.add(((function () {
                        var $ret = new RectangleGeometry();
                        $ret.d = new Rect(0, l, r, n - l, o - r);
                        return $ret;
                    })()));
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: m, y: r };
                        $ret.b = { $type: Point_$type, x: m, y: p };
                        return $ret;
                    })()));
                    break;
                case 1:
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: l, y: o };
                        $ret.b = { $type: Point_$type, x: m, y: o };
                        return $ret;
                    })()));
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: m, y: q };
                        $ret.b = { $type: Point_$type, x: m, y: p };
                        return $ret;
                    })()));
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: m, y: r };
                        $ret.b = { $type: Point_$type, x: n, y: r };
                        return $ret;
                    })()));
                    break;
            }
        };
        for (var k = 0; k < j.count; ++k) {
            _loop_2(k);
        }
    };
    FinancialPriceSeries.prototype.fm = function (a, b) {
        if (this.o7.b2 && a == this.o7.b0.g$j) {
            return null;
        }
        return _super.prototype.fm.call(this, a, b);
    };
    FinancialPriceSeries.prototype.jc = function () {
        _super.prototype.jc.call(this);
        if (this.fb < 0) {
            return;
        }
        this.o7.cd();
    };
    FinancialPriceSeries.prototype.hu = function (a) {
        _super.prototype.hu.call(this, a);
        if (this.o7.b2) {
            this.a2.exportTrendlineData(this, a, this.o7.b0.g$j);
        }
    };
    FinancialPriceSeries.prototype.i6 = function (a, b) {
        _super.prototype.i6.call(this, a, b);
        this.ps = b;
    };
    FinancialPriceSeries.ph = DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, new PropertyMetadata(2, null, function (a, b) { return a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue); }));
    FinancialPriceSeries.$t = markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    return FinancialPriceSeries;
}(FinancialSeries));
export { FinancialPriceSeries };
Type.dep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['DisplayType:o8:pi', [PriceDisplayType_$type, enumGetBox(PriceDisplayType_$type, 0)], 'NegativeOutline:ps:pj', [Brush.$, null], 'TrendLineType::pp', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::po', [1, 1.5], 'TrendLinePeriod::pn', [1, 7], 'TrendLineBrush::pk', [Brush.$, null], 'TrendLineZIndex:pb:pq', [1, 1001], 'TrendLineDashArray:pt:pl', [DoubleCollection.$], 'TrendLineDashCap:pu:pm', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
var FinancialPriceSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(FinancialPriceSeriesView, _super);
    function FinancialPriceSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.by = null;
        _this.b1 = null;
        _this.b4 = null;
        _this.ci = ((function () {
            var $ret = new Path();
            $ret.aj = new GeometryGroup();
            return $ret;
        })());
        _this.ch = ((function () {
            var $ret = new Path();
            $ret.aj = new GeometryGroup();
            return $ret;
        })());
        _this.bz = null;
        _this.cg = new Path();
        _this.b3 = false;
        _this.by = a;
        _this.b4 = new List$1(Path.$, 0);
        _this.b1 = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.cj);
            $ret.activate = runOn(_this, _this.b9);
            $ret.disactivate = runOn(_this, _this.cb);
            $ret.destroy = runOn(_this, _this.ca);
            return $ret;
        })());
        return _this;
    }
    FinancialPriceSeriesView.prototype.cj = function () {
        var a = new Path();
        this.b4.add(a);
        a._visibility = 1;
        return a;
    };
    FinancialPriceSeriesView.prototype.b9 = function (a) {
        a._visibility = 0;
    };
    FinancialPriceSeriesView.prototype.cb = function (a) {
        a._visibility = 1;
    };
    FinancialPriceSeriesView.prototype.ca = function (a) {
        this.b4.remove(a);
    };
    FinancialPriceSeriesView.prototype.bt = function () {
        return new FinancialPriceBucketCalculator(this);
    };
    FinancialPriceSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        if (!this.n) {
            this.bu.o0 = ((function () {
                var $ret = new Brush();
                $ret.fill = "#C62828";
                return $ret;
            })());
            this.by.ps = this.bu.o0;
            this.bu.eo = 5;
            this.bu.es = 1;
        }
    };
    Object.defineProperty(FinancialPriceSeriesView.prototype, "b0", {
        get: function () {
            if (this.bz == null) {
                this.bz = CategoryTrendLineManagerFactory.a(this.bz, this.e.ap(), this.e.jl, this.e, this.e.b2);
            }
            return this.bz;
        },
        set: function (a) {
            this.bz = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialPriceSeriesView.prototype, "b2", {
        get: function () {
            return this.bz != null;
        },
        enumerable: true,
        configurable: true
    });
    FinancialPriceSeriesView.prototype.cc = function () {
        if (this.by.o8 == 1) {
            this.ci._stroke = this.e.kr;
        }
        else {
            this.ci._stroke = this.e.ks;
        }
        if (this.by.o8 == 1) {
            this.ch._stroke = this.bu.o0;
        }
        else {
            this.ch._stroke = this.by.ps;
        }
    };
    FinancialPriceSeriesView.prototype.b6 = function () {
        this.an();
        this.b1.count = 0;
        this.b5();
    };
    FinancialPriceSeriesView.prototype.b5 = function () {
        var a = typeCast(GeometryGroup.$, this.ci.aj);
        var b = typeCast(GeometryGroup.$, this.ch.aj);
        Extensions.d(a);
        Extensions.d(b);
    };
    FinancialPriceSeriesView.prototype.cf = function () {
        this.an();
        return typeCast(GeometryGroup.$, this.ci.aj);
    };
    FinancialPriceSeriesView.prototype.ce = function () {
        this.an();
        return typeCast(GeometryGroup.$, this.ch.aj);
    };
    FinancialPriceSeriesView.prototype.cd = function () {
        this.by.pr = null;
        if (this.by.trendLineBrush != null) {
            this.by.pr = this.by.trendLineBrush;
        }
        else {
            this.by.pr = this.by.kr;
        }
    };
    FinancialPriceSeriesView.prototype.a8 = function () {
        _super.prototype.a8.call(this);
        this.ci.ac = this.e.es;
        this.ci.ai = this.e.kz;
        this.ci.ad = this.e.k0;
        if (this.by.o8 == 1) {
            this.ci._stroke = this.e.kr;
        }
        else {
            this.ci._stroke = this.e.ks;
            this.ci._fill = this.e.kr;
        }
        this.ch.ac = this.e.es;
        this.ch.ai = this.e.kz;
        this.ch.ad = this.e.k0;
        if (this.by.o8 == 1) {
            this.ch._stroke = this.bu.o0;
        }
        else {
            this.ch._stroke = this.by.ps;
            this.ch._fill = this.bu.o0;
        }
    };
    FinancialPriceSeriesView.prototype.a9 = function () {
        _super.prototype.a9.call(this);
        var a = this.bk();
        this.ci.ac = this.e.es + 3;
        if (this.by.o8 == 1) {
            this.ci._stroke = a;
        }
        else {
            this.ci._stroke = a;
            this.ci._fill = a;
        }
        this.ch.ac = this.e.es + 3;
        if (this.by.o8 == 1) {
            this.ch._stroke = a;
        }
        else {
            this.ch._stroke = a;
            this.ch._fill = a;
        }
    };
    FinancialPriceSeriesView.prototype.z = function (a) {
        return this.b4._inner[a];
    };
    FinancialPriceSeriesView.prototype.y = function (a) {
        var b = this.b4._inner[a];
        this.cg._visibility = b._visibility;
        this.cg.aj = b.aj;
        var c = this.bl(a);
        this.cg._fill = c;
        this.cg._stroke = c;
        this.cg.ac = this.e.es + 3;
        return this.cg;
    };
    FinancialPriceSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            if (this.b3) {
                for (var c = 0; c < this.b4.count; c++) {
                    var d = this.x(c, b);
                    if (d._visibility == 0) {
                        a.s(d);
                    }
                }
            }
            else {
                a.s(this.ci);
                a.s(this.ch);
            }
        }
    };
    FinancialPriceSeriesView.prototype.a2 = function (a, b) {
        if (a.d) {
            if (this.by.trendLineType != 0 && !b) {
                var c = this.b0.g$j;
                c.ac = this.by.trendLineThickness;
                c._stroke = this.by.pr;
                c.ai = this.by.pt;
                c.ad = this.by.pu;
                a.u(c);
            }
        }
        _super.prototype.a2.call(this, a, b);
    };
    FinancialPriceSeriesView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        this.e.a2.exportPathData(a, this.ci, "positivePathShape", ["Positive", "Main"]);
        this.e.a2.exportPathData(a, this.ch, "negativePathShape", ["Negative"]);
    };
    FinancialPriceSeriesView.prototype.b7 = function () {
        this.an();
    };
    FinancialPriceSeriesView.prototype.b8 = function () {
        if (this.b2) {
            this.bz = CategoryTrendLineManagerFactory.a(this.bz, this.e.ap(), this.e.jl, this.e, this.e.b2);
        }
    };
    FinancialPriceSeriesView.$t = markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
}(FinancialSeriesView));
export { FinancialPriceSeriesView };
/*<BeginStatics Name="Infragistics.Controls.Charts.FinancialPriceSeries" />*/
/*<EndStatics Name="Infragistics.Controls.Charts.FinancialPriceSeries" />*/
