/*
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 { FinancialSeries } from "./FinancialSeries";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { TrendLineType_$type } from "igniteui-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { PenLineCap_$type } from "igniteui-angular-core";
import { DoubleCollection } from "igniteui-angular-core";
import { PriceDisplayType_$type } from "./PriceDisplayType";
import { Series } from "./Series";
import { Defaults } from "./Defaults";
import { enumGetBox, EnumUtil, typeCast, fromEnum, runOn, Point_$type, markType, markDep } from "igniteui-angular-core";
import { CategoryFrame } from "./CategoryFrame";
import { ISortingAxis_$type } from "./ISortingAxis";
import { FinancialSeriesView } from "./FinancialSeriesView";
import { Rect } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { RectUtil } from "igniteui-angular-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { AxisRange } from "./AxisRange";
import { ScalerParams } from "./ScalerParams";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { Pool$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { PathGeometry } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { LineSegment } from "igniteui-angular-core";
import { GeometryGroup } from "igniteui-angular-core";
import { LineGeometry } from "igniteui-angular-core";
import { RectangleGeometry } from "igniteui-angular-core";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { truncate, isNaN_, isInfinity } from "igniteui-angular-core";
import { boxArray$1 } from "igniteui-angular-core";
import { round10N } from "igniteui-angular-core";
import { FinancialPriceBucketCalculator } from "./FinancialPriceBucketCalculator";
import { Extensions } from "igniteui-angular-core";
/**
 * @hidden
 */
var FinancialPriceSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinancialPriceSeries, _super);
    function FinancialPriceSeries() {
        var _this = _super.call(this) || this;
        _this.ab = FinancialPriceSeries.$;
        _this.qf = new CategoryFrame(5);
        _this.qh = new CategoryFrame(5);
        _this.qd = new CategoryFrame(5);
        return _this;
    }
    FinancialPriceSeries.prototype.get_ds = function () {
        return true;
    };
    FinancialPriceSeries.prototype.gu = function () {
        if (!isNaN_(this.gt)) {
            return _super.prototype.gu.call(this);
        }
        return Defaults.k;
    };
    FinancialPriceSeries.prototype.bx = function () {
        return new FinancialPriceSeriesView(this);
    };
    FinancialPriceSeries.prototype.ly = function (a) {
        _super.prototype.ly.call(this, a);
        this.tm = a;
    };
    Object.defineProperty(FinancialPriceSeries.prototype, "uu", {
        get: function () {
            return this.c(FinancialPriceSeries.uc);
        },
        set: function (a) {
            this.h(FinancialPriceSeries.uc, a);
        },
        enumerable: false,
        configurable: true
    });
    FinancialPriceSeries.prototype.k0 = function (a, b, c, d) {
        _super.prototype.k0.call(this, a, b, c, d);
        if (this.qb != null && typeCast(ISortingAxis_$type, this.qb) !== null) {
            this.qb.i$i();
        }
        this.tm.bx.e(this.ft);
        if (this.tm.b7) {
            this.tm.b5.g$e(a, b, c, d);
        }
        if (this.qx != null) {
            this.qx.c0();
        }
        this.mh(true);
    };
    FinancialPriceSeries.prototype.bp = function () {
        if (this.bq == 0) {
            return 1;
        }
        else {
            return _super.prototype.bp.call(this);
        }
    };
    FinancialPriceSeries.prototype.pu = function (a) {
        if (this.qd == null || this.qd.f.count == 0) {
            return Rect.empty;
        }
        var b = this.pg(a);
        var c = this.b0.bv;
        var d = this.b0.bu;
        var e = this.getEffectiveViewport1(this.b0);
        var f = this.aj(this.qb, this.qd.f, this.r8(this.b0), this.sa(this.b0), 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.to(this.qs, 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.tl = 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.tn == 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.pg(a);
        var d = this.b0.bv;
        var e = this.b0.bu;
        var f = this.getEffectiveViewport1(this.b0);
        var g = this.aj(this.qb, this.qd.f, this.r8(this.b0), this.sa(this.b0), 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.to(this.qs, f);
        l = Math.max(l, 3);
        var m = (l - 1) / 2;
        if (j < k) {
            return this.tl(h, m);
        }
        else {
            return this.tl(i, m);
        }
    };
    FinancialPriceSeries.prototype.ev = function (a, b) {
        if (this.ey(a, b)) {
            return true;
        }
        return false;
    };
    FinancialPriceSeries.prototype.ey = function (a, b) {
        var c = this.pv(a);
        if (c.isEmpty) {
            return false;
        }
        var d = RectUtil.r(c, (this.fu / 2) + this.f8(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.fu / 2) + this.f8(b));
                    if (h.containsPoint(a)) {
                        return true;
                    }
                }
            }
        }
        return false;
    };
    FinancialPriceSeries.prototype.l3 = function (a, b, c, d) {
        switch (b) {
            case FinancialSeries.$$p[9]:
                this.tm.cd();
                if (this.cd != null) {
                    this.cd.li();
                }
                break;
            case "TrendLineType":
                var e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                if (e != 0) {
                    this.tm.b5 = CategoryTrendLineManagerFactory.a(this.tm.b5, this.qb, this.m9, this, this.cn);
                }
                break;
        }
        _super.prototype.l3.call(this, a, b, c, d);
        if (this.tm.b7 && this.tm.b5 != null && this.tm.b5.g$b(a, b, c, d)) {
            this.mh(false);
            this.lo();
        }
        switch (b) {
            case FinancialPriceSeries.$$p[2]:
                if (this.m9 != null) {
                    this.ub();
                    this.mw();
                    this.qd.w();
                    this.s4(this.qd, this.tm);
                }
                this.lo();
                break;
            case "ActualHighlightingMode":
                this.mh(true);
                break;
            case "TrendLineBrush":
                this.mv();
                break;
            case "TrendLineType":
                this.lo();
                break;
            case FinancialSeries.$$p[5]:
            case FinancialPriceSeries.$$p[7]:
                this.l0();
                break;
        }
    };
    FinancialPriceSeries.prototype.ub = function () {
        this.tm.ch();
        if (this.bz != null) {
            this.bz.ch();
        }
    };
    FinancialPriceSeries.prototype.ap = function (a) {
        if (a != null && a == this.qx && this.q6 != null && !isNaN_(this.q6.minimum) && this.q5 != null && !isNaN_(this.q5.maximum)) {
            return new AxisRange(this.q6.minimum, this.q5.maximum);
        }
        return null;
    };
    FinancialPriceSeries.prototype.aq = function (a) {
        if (a.isEmpty && this.cd != null) {
            a = this.cd.sf;
        }
        if (this.q6 == null || this.q5 == null) {
            return null;
        }
        var b = this.pq(this.b0);
        var c = new ScalerParams(0, a, this.cd.su, this.qb.cg, this.getEffectiveViewport());
        var d = (this.qb.el(b.left, c));
        var e = (this.qb.el(b.right, c));
        if (this.qb.cg) {
            var f = d;
            d = e;
            e = f;
        }
        var g = null;
        if (this.qb.cm) {
            g = this.qb;
            d = g.i$f(d);
            e = g.i$f(e);
        }
        else {
            d = Math.floor(d);
            e = Math.ceil(e);
        }
        d = Math.max(0, Math.min(this.q6.count - 1, d));
        e = Math.max(0, Math.min(this.q6.count - 1, e));
        var h = 1.7976931348623157E+308;
        var i = -1.7976931348623157E+308;
        for (var j = truncate(d); j <= truncate(e); j++) {
            var k = j;
            if (g != null) {
                k = g.i$b._inner[j];
            }
            var l = this.q6.item(k);
            if (this.q6.mayContainUnknowns) {
                if (isInfinity(l) || isNaN_(l)) {
                    continue;
                }
            }
            var m = this.q5.item(k);
            if (this.q5.mayContainUnknowns) {
                if (isInfinity(m) || isNaN_(m)) {
                    continue;
                }
            }
            h = Math.min(h, l);
            i = Math.max(i, m);
        }
        var n = new AxisRange(h, i);
        n = this.ao(n, this.qx, a);
        return n;
    };
    FinancialPriceSeries.prototype.gc = function () {
        return Series.gd(this.q7, typeCast(ISortingAxis_$type, this.qb));
    };
    FinancialPriceSeries.prototype.en = function (a) {
        var b = this.ck != null ? this.ck.indexOf(a) : -1;
        var c = this.b0.bv;
        c = c.copy();
        var d = this.b0.bu;
        var e = new Rect(0, 0, 0, 1, 1);
        var f = this.ps(this.b0);
        if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
            if (this.qb != null) {
                var g = new ScalerParams(0, e, e, this.qb.cg, f);
                var h = this.qb.ei(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.qx != null && this.q6 != null && this.q5 != null && b < this.q6.count && b < this.q5.count) {
                var i = new ScalerParams(0, e, e, this.qx.cg, f);
                i.b = this.gc();
                var j = this.qx.ei(this.q6.item(b), i);
                var k = this.qx.ei(this.q5.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.b8.au(this.cd, c, true);
        }
        return b >= 0;
    };
    FinancialPriceSeries.prototype.e9 = function (a, b, c) {
        var d = _super.prototype.e9.call(this, a, b, c);
        if (this.q7 == null || this.q4 == null || this.q5 == null || this.q6 == null) {
            d = false;
        }
        return d;
    };
    FinancialPriceSeries.prototype.s2 = function (a, b) {
        var e_1, _a;
        var _this = this;
        _super.prototype.s2.call(this, a, b);
        var c = b.bv;
        var d = b.bu;
        var e = this.getEffectiveViewport1(b);
        var f = this.qb;
        var g = this.qx;
        var h = new ScalerParams(0, c, d, f.cg, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, g.cg, e);
            $ret.b = _this.gc();
            return $ret;
        })());
        a.f.clear();
        a.m.clear();
        a.p.clear();
        var j = 0;
        var k = typeCast(ISortingAxis_$type, this.qb);
        if (k != null && (k.i$b == null || k.i$b.count != this.ck.count)) {
            return;
        }
        j = this.r2(c, d, e);
        var l = typeCast(FinancialPriceSeriesView.$, b);
        var m = this.ft;
        if (this.trendLineType != 0) {
            var n = new Array(this.ck.count);
            var o = 0;
            try {
                for (var _b = __values(fromEnum(this.rt)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var p = _c.value;
                    n[o] = p;
                    o++;
                }
            }
            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;
                }
            }
            if (this.tm.b7) {
                this.tm.b5.prepareLineCore(a.p, this.trendLineType, boxArray$1(n), this.trendLinePeriod, function (q) { return _this.qb.ei(q, h); }, function (q) { return _this.qx.ei(q, i); }, ((function () {
                    var $ret = new TrendResolutionParams();
                    $ret.c = b.bx.b;
                    $ret.d = b.bx.c;
                    $ret.e = b.bx.d;
                    $ret.a = j;
                    $ret.b = m;
                    $ret.f = d;
                    return $ret;
                })()));
            }
        }
        var q = this.qb.el(2, h) - this.qb.el(1, h);
        for (var r = b.bx.c; r <= b.bx.d; ++r) {
            var s = void 0;
            if (k == null) {
                s = b.bx.getBucket(r);
            }
            else {
                var t = k.i$b._inner[r];
                var u = k.i$d(t);
                var v = this.q7.item(t);
                var w = this.q5.item(t);
                var x = this.q6.item(t);
                var y = this.q4.item(t);
                var z = v;
                var aa = w;
                var ab = x;
                var ac = y;
                var ad = u;
                while (r < b.bx.d) {
                    t = k.i$b._inner[r + 1];
                    ad = k.i$d(t);
                    if (ad - u > q * m) {
                        break;
                    }
                    r++;
                    aa = Math.max(aa, this.q5.item(t));
                    ab = Math.min(ab, this.q6.item(t));
                    ac = this.q4.item(t);
                }
                var ae = NaN;
                if (!isNaN_(u)) {
                    ae = this.qb.ei(u, h);
                }
                s = [ae, z, aa, ab, ac];
            }
            if (!isNaN_(s[0])) {
                if (k != null) {
                    s[0] = s[0] + j;
                }
                else {
                    s[0] = f.ei(s[0], h) + j;
                }
                s[1] = g.ei(s[1], i);
                s[2] = g.ei(s[2], i);
                s[3] = g.ei(s[3], i);
                s[4] = g.ei(s[4], i);
                a.f.add(s);
            }
        }
        return;
    };
    FinancialPriceSeries.prototype.kx = function (a, b) {
        _super.prototype.kx.call(this, a, b);
        var c = typeCast(FinancialPriceSeriesView.$, b);
        c.cb();
        if (a) {
            c.b6.count = 0;
        }
        if (c.b7 && c.b5 != null) {
            c.b5.g$d();
        }
    };
    FinancialPriceSeries.prototype.m4 = function (a, b) {
        _super.prototype.m4.call(this, a, b);
        if (this.cd != null) {
            this.cd.li();
        }
    };
    FinancialPriceSeries.prototype.p0 = function (a, b) {
        if (this.qb != null && this.qb.categoryMode == 0) {
            var c = this.getEffectiveViewport1(this.b0);
            var d = this.to(this.qs, c) / 2;
            return new Thickness(1, d, 0, d, 0);
        }
        return _super.prototype.p0.call(this, a, b);
    };
    FinancialPriceSeries.prototype.get_c2 = function () {
        return true;
    };
    FinancialPriceSeries.prototype.s4 = function (a, b) {
        _super.prototype.s4.call(this, a, b);
        if (this.qb == null || this.qx == null) {
            return;
        }
        var c = false;
        if (b.b0(a)) {
            c = true;
            b.b2(a);
        }
        this.qk.a0(this, this.rj(), runOn(this, this.p3), this.r8(b), this.sa(b));
        var d = false;
        var e = this.qk.b;
        if (e != null) {
            d = true;
        }
        var f = typeCast(FinancialPriceSeriesView.$, b);
        f.ca();
        f.b8 = false;
        if (f.b7) {
            f.b5.g$d();
        }
        if (this.trendLineType != 0) {
            f.b5.g$g(a.p);
        }
        if (d) {
            this.ua(a, b, c);
        }
        else {
            f.b6.count = 0;
            this.t9(a, b);
        }
    };
    FinancialPriceSeries.prototype.ga = function () {
        var a = this.getEffectiveViewport1(this.b0);
        return this.to(this.qs, a);
    };
    FinancialPriceSeries.prototype.ua = function (a, b, c) {
        var d = this.tn;
        var e = this.getEffectiveViewport1(b);
        var f = this.to(b, e);
        var g = (f - 1) / 2;
        var h = typeCast(FinancialPriceSeriesView.$, b);
        h.b8 = true;
        var i = a.f;
        var j = 0;
        var k = this.ck.count;
        var l = this.qb;
        var m = new ScalerParams(0, b.bv, b.bu, l.cg, e);
        var n = this.oy;
        var o = this.th;
        if (o == null) {
            o = n;
        }
        var p = this.o1;
        var q = this.uv;
        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.b6.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.c.add(ad);
                        ab.c.add(ae);
                        ab.c.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.c.add(ag);
                        ab.c.add(ah);
                        ab.c.add(ai);
                        break;
                }
            }
            if (aa) {
                this_1.qk.ak = o;
                this_1.qk.ag = o;
                this_1.qk.ah = q;
                this_1.qk.al = q;
                this_1.qk.f = true;
            }
            else {
                this_1.qk.ak = n;
                this_1.qk.ag = n;
                this_1.qk.ah = p;
                this_1.qk.al = p;
                this_1.qk.f = false;
            }
            this_1.s1(i, r, k, l, m, b.q);
            if (d == 1) {
                this_1.qk.ad(z, true, false, false, false);
            }
            else {
                this_1.qk.ad(z, false, false, false, false);
            }
            if (c) {
                z.ak = ab;
            }
        };
        var this_1 = this;
        for (var r = 0; r < i.count; ++r) {
            _loop_1(r);
        }
        h.b6.count = j;
        h.cc();
    };
    FinancialPriceSeries.prototype.to = function (a, b) {
        var c = this.qb.k3(a.bv, a.bu, b);
        c = Math.max(c, this.ft * 0.9);
        c = Math.max(c, 3);
        return c;
    };
    FinancialPriceSeries.prototype.t9 = function (a, b) {
        var c = this.tn;
        var d = this.getEffectiveViewport1(b);
        var e = this.to(b, d);
        var f = (e - 1) / 2;
        var g = typeCast(FinancialPriceSeriesView.$, b);
        var h = g.ck();
        var i = g.cj();
        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.d.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.d = { $type: Point_$type, x: m, y: q };
                        $ret.c = { $type: Point_$type, x: m, y: o };
                        return $ret;
                    })()));
                    t.d.add(((function () {
                        var $ret = new RectangleGeometry();
                        $ret.e = new Rect(0, l, r, n - l, o - r);
                        return $ret;
                    })()));
                    t.d.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.d = { $type: Point_$type, x: m, y: r };
                        $ret.c = { $type: Point_$type, x: m, y: p };
                        return $ret;
                    })()));
                    break;
                case 1:
                    t.d.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.d = { $type: Point_$type, x: l, y: o };
                        $ret.c = { $type: Point_$type, x: m, y: o };
                        return $ret;
                    })()));
                    t.d.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.d = { $type: Point_$type, x: m, y: q };
                        $ret.c = { $type: Point_$type, x: m, y: p };
                        return $ret;
                    })()));
                    t.d.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.d = { $type: Point_$type, x: m, y: r };
                        $ret.c = { $type: Point_$type, x: n, y: r };
                        return $ret;
                    })()));
                    break;
            }
        };
        for (var k = 0; k < j.count; ++k) {
            _loop_2(k);
        }
    };
    FinancialPriceSeries.prototype.hz = function (a, b) {
        if (this.tm.b7 && a == this.tm.b5.g$j) {
            return null;
        }
        return _super.prototype.hz.call(this, a, b);
    };
    FinancialPriceSeries.prototype.mv = function () {
        _super.prototype.mv.call(this);
        if (this.index < 0) {
            return;
        }
        this.tm.ci();
    };
    FinancialPriceSeries.prototype.k7 = function (a) {
        _super.prototype.k7.call(this, a);
        if (this.tm.b7) {
            this.a8.exportTrendlineData(this, a, this.tm.b5.g$j);
        }
    };
    FinancialPriceSeries.prototype.o9 = function () {
        return this.uv;
    };
    FinancialPriceSeries.prototype.mm = function (a, b) {
        _super.prototype.mm.call(this, a, b);
        this.uv = b;
    };
    FinancialPriceSeries.prototype.ba = function (a) {
        if (this.tn == 0) {
            return 3;
        }
        else if (this.tn == 1) {
            if (this.a9 == 1) {
                return 3;
            }
            return 2;
        }
        return a;
    };
    FinancialPriceSeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.gh(c, false, false);
        var e = this.gf(c, false, false);
        var f = new DataLegendSeriesValueInfo();
        f.a = 4;
        f.l = this.r3(c, false, false);
        f.p = this.sf != null ? this.sf : "Close";
        f.q = this.tr != null ? this.tr : "C:";
        f.r = this.tt != null ? this.tt : "";
        var g = new DataLegendSeriesValueInfo();
        g.l = this.r4(c, false, false);
        g.a = 3;
        g.p = this.sr != null ? this.sr : "Open";
        g.q = this.t5 != null ? this.t5 : "O:";
        g.r = this.t7 != null ? this.t7 : "";
        g.k = true;
        var h = new DataLegendSeriesValueInfo();
        h.l = (f.l - g.l) / g.l * 100;
        h.l = round10N(h.l, 1);
        h.a = 9;
        h.p = "Change";
        h.q = "";
        h.t = "";
        h.v = "+";
        h.u = "%";
        h.w = "%";
        h.r = null;
        h.c = false;
        h.k = true;
        h.e = false;
        h.f = true;
        h.h = false;
        h.g = false;
        h.d = false;
        h.n = 1;
        h.m = 1;
        g.x = h.l >= 0 ? this.oy : this.th;
        f.x = h.l >= 0 ? this.oy : this.th;
        h.x = h.l >= 0 ? this.oy : this.th;
        var i = new DataLegendSeriesValueInfo();
        i.l = e > d ? d : e;
        i.a = 1;
        i.p = this.sn != null ? this.sn : "Low";
        i.q = this.t0 != null ? this.t0 : "L:";
        i.r = this.t2 != null ? this.t2 : "";
        i.k = true;
        var j = new DataLegendSeriesValueInfo();
        j.l = e > d ? e : d;
        j.a = 2;
        j.p = this.si != null ? this.si : "High";
        j.q = this.tw != null ? this.tw : "H:";
        j.r = this.ty != null ? this.ty : "";
        j.k = true;
        var k = new DataLegendSeriesValueInfo();
        k.l = (j.l + i.l + f.l) / 3;
        k.l = round10N(k.l, 2);
        k.a = 5;
        k.p = "TypicalPrice";
        k.q = "TP:";
        k.r = "";
        k.k = true;
        var l = new DataLegendSeriesValueInfo();
        l.l = this.r5(c, false, false);
        l.a = 8;
        l.p = this.sv != null ? this.sv : "Volume";
        l.q = "VOL:";
        l.r = "";
        l.k = true;
        l.n = 0;
        l.m = 0;
        l.e = false;
        l.f = false;
        l.h = false;
        var m = new List$1(DataLegendSeriesValueInfo.$, 0);
        m.add(g);
        m.add(j);
        m.add(i);
        m.add(f);
        m.add(k);
        m.add(h);
        m.add(l);
        var n = new DataLegendSeriesContext();
        n.b = this.av();
        n.f = m;
        return n;
    };
    FinancialPriceSeries.$t = markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.uc = DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, new PropertyMetadata(2, null, function (a, b) { return a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue); }));
    FinancialPriceSeries.$$p = markDep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['CloseMemberAsLegendLabel:tr:ud', [2, null], 'CloseMemberAsLegendUnit:tt:ue', [2, null], 'DisplayType:tn:uf', [PriceDisplayType_$type, enumGetBox(PriceDisplayType_$type, 0)], 'HighMemberAsLegendLabel:tw:ug', [2, null], 'HighMemberAsLegendUnit:ty:uh', [2, null], 'LowMemberAsLegendLabel:t0:ui', [2, null], 'LowMemberAsLegendUnit:t2:uj', [2, null], 'NegativeOutline:uv:uk', [Brush.$, null], 'OpenMemberAsLegendLabel:t5:ul', [2, null], 'OpenMemberAsLegendUnit:t7:um', [2, null], 'TrendLineType::us', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ur', [1, 1.5], 'TrendLinePeriod::uq', [1, 7], 'TrendLineBrush::un', [Brush.$, null], 'TrendLineZIndex:tq:ut', [1, 1001], 'TrendLineDashArray:uw:uo', [DoubleCollection.$], 'TrendLineDashCap:ux:up', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
    return FinancialPriceSeries;
}(FinancialSeries));
export { FinancialPriceSeries };
/**
 * @hidden
 */
var FinancialPriceSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinancialPriceSeriesView, _super);
    function FinancialPriceSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.b3 = null;
        _this.b6 = null;
        _this.b9 = null;
        _this.cn = ((function () {
            var $ret = new Path();
            $ret.ak = new GeometryGroup();
            return $ret;
        })());
        _this.cm = ((function () {
            var $ret = new Path();
            $ret.ak = new GeometryGroup();
            return $ret;
        })());
        _this.b4 = null;
        _this.cl = new Path();
        _this.b8 = false;
        _this.b3 = a;
        _this.b9 = new List$1(Path.$, 0);
        _this.b6 = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.co);
            $ret.activate = runOn(_this, _this.ce);
            $ret.disactivate = runOn(_this, _this.cg);
            $ret.destroy = runOn(_this, _this.cf);
            return $ret;
        })());
        return _this;
    }
    FinancialPriceSeriesView.prototype.co = function () {
        var a = new Path();
        this.b9.add(a);
        a._visibility = 1;
        return a;
    };
    FinancialPriceSeriesView.prototype.ce = function (a) {
        a._visibility = 0;
    };
    FinancialPriceSeriesView.prototype.cg = function (a) {
        a._visibility = 1;
    };
    FinancialPriceSeriesView.prototype.cf = function (a) {
        this.b9.remove(a);
    };
    FinancialPriceSeriesView.prototype.by = function () {
        return new FinancialPriceBucketCalculator(this);
    };
    FinancialPriceSeriesView.prototype.as = function () {
        _super.prototype.as.call(this);
        if (!this.q) {
            this.b3.tn = Defaults.g;
            this.b3.th = Defaults.ah;
            this.b3.uv = Defaults.ai;
            this.b3.gz = Defaults.l;
            this.b3.o7 = this.b3.o1;
        }
    };
    Object.defineProperty(FinancialPriceSeriesView.prototype, "b5", {
        get: function () {
            if (this.b4 == null) {
                this.b4 = CategoryTrendLineManagerFactory.a(this.b4, this.e.ar(), this.e.m9, this.e, this.e.cn);
            }
            return this.b4;
        },
        set: function (a) {
            this.b4 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialPriceSeriesView.prototype, "b7", {
        get: function () {
            return this.b4 != null;
        },
        enumerable: false,
        configurable: true
    });
    FinancialPriceSeriesView.prototype.ch = function () {
        if (this.b3.tn == 1) {
            this.cn._stroke = this.e.oy;
        }
        else {
            this.cn._stroke = this.e.o1;
        }
        if (this.b3.tn == 1) {
            this.cm._stroke = this.bz.th;
        }
        else {
            this.cm._stroke = this.b3.uv;
        }
    };
    FinancialPriceSeriesView.prototype.cb = function () {
        this.aq();
        this.b6.count = 0;
        this.ca();
    };
    FinancialPriceSeriesView.prototype.ca = function () {
        var a = typeCast(GeometryGroup.$, this.cn.ak);
        var b = typeCast(GeometryGroup.$, this.cm.ak);
        Extensions.d(a);
        Extensions.d(b);
    };
    FinancialPriceSeriesView.prototype.ck = function () {
        this.aq();
        return typeCast(GeometryGroup.$, this.cn.ak);
    };
    FinancialPriceSeriesView.prototype.cj = function () {
        this.aq();
        return typeCast(GeometryGroup.$, this.cm.ak);
    };
    FinancialPriceSeriesView.prototype.ci = function () {
        this.b3.uu = null;
        if (this.b3.trendLineBrush != null) {
            this.b3.uu = this.b3.trendLineBrush;
        }
        else {
            this.b3.uu = this.b3.oy;
        }
    };
    FinancialPriceSeriesView.prototype.bb = function () {
        _super.prototype.bb.call(this);
        this.cn.ac = this.e.fu;
        this.cn.ai = this.e.pb;
        this.cn.ad = this.e.pc;
        if (this.b3.tn == 1) {
            this.cn._stroke = this.e.oy;
        }
        else {
            this.cn._stroke = this.e.o1;
            this.cn._fill = this.e.oy;
        }
        this.cm.ac = this.e.fu;
        this.cm.ai = this.e.pb;
        this.cm.ad = this.e.pc;
        if (this.b3.tn == 1) {
            this.cm._stroke = this.bz.th;
        }
        else {
            this.cm._stroke = this.b3.uv;
            this.cm._fill = this.bz.th;
        }
    };
    FinancialPriceSeriesView.prototype.bc = function () {
        _super.prototype.bc.call(this);
        var a = this.bo();
        this.cn.ac = this.e.fu + 3;
        if (this.b3.tn == 1) {
            this.cn._stroke = a;
        }
        else {
            this.cn._stroke = a;
            this.cn._fill = a;
        }
        this.cm.ac = this.e.fu + 3;
        if (this.b3.tn == 1) {
            this.cm._stroke = a;
        }
        else {
            this.cm._stroke = a;
            this.cm._fill = a;
        }
    };
    FinancialPriceSeriesView.prototype.ac = function (a) {
        return this.b9._inner[a];
    };
    FinancialPriceSeriesView.prototype.ab = function (a) {
        var b = this.b9._inner[a];
        this.cl._visibility = b._visibility;
        this.cl.ak = b.ak;
        var c = this.bp(a);
        this.cl._fill = c;
        this.cl._stroke = c;
        this.cl.ac = this.e.fu + 3;
        return this.cl;
    };
    FinancialPriceSeriesView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d) {
            if (this.b8) {
                for (var c = 0; c < this.b9.count; c++) {
                    var d = this.aa(c, b);
                    if (d._visibility == 0) {
                        a.s(d);
                    }
                }
            }
            else {
                a.s(this.cn);
                a.s(this.cm);
            }
        }
    };
    FinancialPriceSeriesView.prototype.a5 = function (a, b) {
        if (a.d) {
            if (this.b3.trendLineType != 0 && !b) {
                var c = this.b5.g$j;
                c.ac = this.b3.trendLineThickness;
                c._stroke = this.b3.uu;
                c.ai = this.b3.uw;
                c.ad = this.b3.ux;
                a.u(c);
            }
        }
        _super.prototype.a5.call(this, a, b);
    };
    FinancialPriceSeriesView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        if (this.b3.rj()) {
            for (var b = 0; b < this.b9.count; b++) {
                var c = this.b9._inner[b];
                if (c._fill == this.b3.th) {
                    this.e.a8.exportPathData(a, c, "negativePathShape" + b, ["Negative"]);
                }
                else {
                    this.e.a8.exportPathData(a, c, "positivePathShape" + b, ["Positive", "Main"]);
                }
            }
        }
        else {
            this.e.a8.exportPathData(a, this.cn, "positivePathShape", ["Positive", "Main"]);
            this.e.a8.exportPathData(a, this.cm, "negativePathShape", ["Negative"]);
        }
    };
    FinancialPriceSeriesView.prototype.cc = function () {
        this.aq();
    };
    FinancialPriceSeriesView.prototype.cd = function () {
        if (this.b7) {
            this.b4 = CategoryTrendLineManagerFactory.a(this.b4, this.e.ar(), this.e.m9, this.e, this.e.cn);
        }
    };
    FinancialPriceSeriesView.$t = markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
}(FinancialSeriesView));
export { FinancialPriceSeriesView };
