/*
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-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { PenLineCap_$type } from "igniteui-react-core";
import { DoubleCollection } from "igniteui-react-core";
import { PriceDisplayType_$type } from "./PriceDisplayType";
import { Series } from "./Series";
import { Defaults } from "./Defaults";
import { enumGetBox, EnumUtil, Number_$type, typeCast, fromEnum, runOn, Point_$type, markType, markDep } from "igniteui-react-core";
import { CategoryFrame } from "./CategoryFrame";
import { ISortingAxis_$type } from "./ISortingAxis";
import { FinancialSeriesView } from "./FinancialSeriesView";
import { Rect } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { RectUtil } from "igniteui-react-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { AxisRange } from "./AxisRange";
import { ScalerParams } from "./ScalerParams";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { Pool$1 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { PathGeometry } from "igniteui-react-core";
import { PathFigure } from "igniteui-react-core";
import { LineSegment } from "igniteui-react-core";
import { GeometryGroup } from "igniteui-react-core";
import { LineGeometry } from "igniteui-react-core";
import { RectangleGeometry } from "igniteui-react-core";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { boxArray$1 } from "igniteui-react-core";
import { round10N } from "igniteui-react-core";
import { FinancialPriceBucketCalculator } from "./FinancialPriceBucketCalculator";
import { Extensions } from "igniteui-react-core";
/**
 * @hidden
 */
var FinancialPriceSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinancialPriceSeries, _super);
    function FinancialPriceSeries() {
        var _this = _super.call(this) || this;
        _this.aau = true;
        _this.aav = 0;
        _this.aaw = 0;
        _this.ab = FinancialPriceSeries.$;
        _this.w1 = new CategoryFrame(5);
        _this.w3 = new CategoryFrame(5);
        _this.wz = new CategoryFrame(5);
        return _this;
    }
    FinancialPriceSeries.prototype.bi = function () {
        return new FinancialPriceSeries();
    };
    FinancialPriceSeries.prototype.get_e7 = function () {
        return true;
    };
    FinancialPriceSeries.prototype.ji = function () {
        if (!isNaN_(this.jh)) {
            return _super.prototype.ji.call(this);
        }
        return Defaults.k;
    };
    FinancialPriceSeries.prototype.cq = function () {
        return new FinancialPriceSeriesView(this);
    };
    FinancialPriceSeries.prototype.qw = function (a) {
        _super.prototype.qw.call(this, a);
        this.aas = a;
    };
    Object.defineProperty(FinancialPriceSeries.prototype, "ab4", {
        get: function () {
            return this.c(FinancialPriceSeries.abm);
        },
        set: function (a) {
            this.h(FinancialPriceSeries.abm, a);
        },
        enumerable: false,
        configurable: true
    });
    FinancialPriceSeries.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        if (this.wx != null && typeCast(ISortingAxis_$type, this.wx) !== null) {
            this.wx.i$i();
        }
        this.aas.b0.e(this.ib);
        if (this.aas.ca) {
            this.aas.b8.g$e(a, b, c, d);
        }
        if (this.xg != null) {
            this.xg.c1();
        }
        this.rm(true);
        if (a == 0 || a == 2 || a == 3 || a == 4) {
            this.aau = true;
        }
        else if (a == 1) {
            for (var e = b; e < b + c; e++) {
                var f = 0;
                f += this.xr.item(e);
                f += this.xs.item(e);
                f += this.xq.item(e);
                this.aav += f / 3;
            }
            this.aaw = this.aav / this.xr.count;
        }
    };
    FinancialPriceSeries.prototype.b0 = function () {
        if (this.b1 == 0) {
            return 1;
        }
        else {
            return _super.prototype.b0.call(this);
        }
    };
    FinancialPriceSeries.prototype.wg = function (a) {
        if (this.wz == null || this.wz.f.count == 0) {
            return Rect.empty;
        }
        var b = this.v0(a);
        var c = this.ct.by;
        var d = this.ct.bx;
        var e = this.getEffectiveViewport1(this.ct);
        var f = this.am(this.wx, this.wz.f, this.yu(this.ct), this.yw(this.ct), 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.aax(this.xe, 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.aar = 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.aat == 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.an = function (a) {
        var b = new List$1(Rect.$, 0);
        var c = this.v0(a);
        var d = this.ct.by;
        var e = this.ct.bx;
        var f = this.getEffectiveViewport1(this.ct);
        var g = this.am(this.wx, this.wz.f, this.yu(this.ct), this.yw(this.ct), 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.aax(this.xe, f);
        l = Math.max(l, 3);
        var m = (l - 1) / 2;
        if (j < k) {
            return this.aar(h, m);
        }
        else {
            return this.aar(i, m);
        }
    };
    FinancialPriceSeries.prototype.gu = function (a, b) {
        if (this.gx(a, b)) {
            return true;
        }
        return false;
    };
    FinancialPriceSeries.prototype.gx = function (a, b) {
        var c = this.wh(a);
        if (c.isEmpty) {
            return false;
        }
        var d = RectUtil.r(c, (this.ic / 2) + this.is(b));
        if (d.containsPoint(a)) {
            var e = this.ao(a);
            if (e != null) {
                for (var f = 0; f < e.length; f++) {
                    var g = e[f];
                    var h = RectUtil.r(g, (this.ic / 2) + this.is(b));
                    if (h.containsPoint(a)) {
                        return true;
                    }
                }
            }
        }
        return false;
    };
    FinancialPriceSeries.prototype.q4 = function (a, b, c, d) {
        switch (b) {
            case FinancialPriceSeries.$$p[3]:
            case FinancialPriceSeries.$$p[4]:
            case FinancialPriceSeries.$$p[5]:
            case FinancialPriceSeries.$$p[6]:
            case FinancialPriceSeries.$$p[0]:
            case FinancialPriceSeries.$$p[1]:
            case FinancialPriceSeries.$$p[8]:
            case FinancialPriceSeries.$$p[9]:
                this.qa();
                break;
            case FinancialSeries.$$p[14]:
                this.aas.cg();
                if (this.c9 != null) {
                    this.c9.nq();
                }
                break;
            case "TrendLineType":
                var e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                if (e != 0) {
                    this.aas.b8 = CategoryTrendLineManagerFactory.a(this.aas.b8, this.wx, this.so, this, this.dp);
                }
                break;
        }
        _super.prototype.q4.call(this, a, b, c, d);
        if (this.aas.ca && this.aas.b8 != null && this.aas.b8.g$b(a, b, c, d)) {
            this.rm(false);
            this.qg();
        }
        switch (b) {
            case FinancialPriceSeries.$$p[2]:
                if (this.so != null) {
                    this.abl();
                    this.sb();
                    this.wz.x();
                    this.z5(this.wz, this.aas);
                }
                this.qg();
                break;
            case "ActualHighlightingMode":
            case "ActualSelectionMode":
            case "ActualFocusMode":
                this.rm(true);
                break;
            case "TrendLineBrush":
                this.ra(b);
                break;
            case "TrendLineType":
                this.qg();
                break;
            case FinancialSeries.$$p[10]:
            case FinancialPriceSeries.$$p[7]:
                this.qy();
                break;
        }
    };
    FinancialPriceSeries.prototype.abl = function () {
        this.aas.ck();
        if (this.cs != null) {
            this.cs.ck();
        }
    };
    FinancialPriceSeries.prototype.ax = function (a) {
        if (a != null && a == this.xg && this.xs != null && !isNaN_(this.xs.minimum) && this.xr != null && !isNaN_(this.xr.maximum)) {
            return new AxisRange(this.xs.minimum, this.xr.maximum);
        }
        return null;
    };
    FinancialPriceSeries.prototype.ay = function (a) {
        if (a.isEmpty && this.c9 != null) {
            a = this.c9.vl;
        }
        if (this.xs == null || this.xr == null) {
            return null;
        }
        var b = this.wc(this.ct);
        var c = new ScalerParams(0, a, this.c9.v0, this.wx.ch, this.getEffectiveViewport());
        var d = (this.wx.en(b.left, c));
        var e = (this.wx.en(b.right, c));
        if (this.wx.ch) {
            var f = d;
            d = e;
            e = f;
        }
        var g = null;
        if (this.wx.cn) {
            g = this.wx;
            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.xs.count - 1, d));
        e = Math.max(0, Math.min(this.xs.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.xs.item(k);
            if (this.xs.mayContainUnknowns) {
                if (isInfinity(l) || isNaN_(l)) {
                    continue;
                }
            }
            var m = this.xr.item(k);
            if (this.xr.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.aw(n, this.xg, a);
        return n;
    };
    FinancialPriceSeries.prototype.iw = function () {
        return Series.ix(this.xt, typeCast(ISortingAxis_$type, this.wx));
    };
    FinancialPriceSeries.prototype.gb = function (a) {
        var b = this.dl != null ? this.dl.indexOf(a) : -1;
        var c = this.ct.by;
        c = c.copy();
        var d = this.ct.bx;
        var e = new Rect(0, 0, 0, 1, 1);
        var f = this.we(this.ct);
        if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
            if (this.wx != null) {
                var g = new ScalerParams(0, e, e, this.wx.ch, f);
                var h = this.wx.ek(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.xg != null && this.xs != null && this.xr != null && b < this.xs.count && b < this.xr.count) {
                var i = new ScalerParams(0, e, e, this.xg.ch, f);
                i.b = this.iw();
                var j = this.xg.ek(this.xs.item(b), i);
                var k = this.xg.ek(this.xr.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.c1.au(this.c9, c, true);
        }
        return b >= 0;
    };
    FinancialPriceSeries.prototype.hc = function (a, b, c) {
        var d = _super.prototype.hc.call(this, a, b, c);
        if (this.xt == null || this.xq == null || this.xr == null || this.xs == null) {
            d = false;
        }
        return d;
    };
    FinancialPriceSeries.prototype.z3 = function (a, b) {
        var e_1, _a;
        var _this = this;
        _super.prototype.z3.call(this, a, b);
        var c = b.by;
        var d = b.bx;
        var e = this.getEffectiveViewport1(b);
        var f = this.wx;
        var g = this.xg;
        var h = new ScalerParams(0, c, d, f.ch, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, g.ch, e);
            $ret.b = _this.iw();
            return $ret;
        })());
        var j = this.wx.ag();
        var k = j[0];
        var l = j[1];
        a.f.clear();
        if (a.m != null) {
            a.m.clear();
        }
        a.n.clear();
        a.q.clear();
        var m = 0;
        var n = typeCast(ISortingAxis_$type, this.wx);
        if (n != null && (n.i$b == null || n.i$b.count != this.dl.count)) {
            return;
        }
        m = this.yo(c, d, e);
        var o = typeCast(FinancialPriceSeriesView.$, b);
        var p = this.ib;
        var q = b.b0.b;
        if (this.trendLineType != 0) {
            var r = new Array(this.dl.count);
            var s = 0;
            try {
                for (var _b = __values(fromEnum(this.yf)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var t = _c.value;
                    r[s] = t;
                    s++;
                }
            }
            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.aas.ca) {
                this.aas.b8.prepareLineCore(a.q, this.trendLineType, boxArray$1(r), this.trendLinePeriod, function (u) { return _this.wx.ek(u, h); }, function (u) { return _this.xg.ek(u, i); }, ((function () {
                    var $ret = new TrendResolutionParams();
                    $ret.e = b.b0.b;
                    $ret.f = b.b0.c;
                    $ret.g = b.b0.d;
                    $ret.a = m;
                    $ret.d = p;
                    $ret.i = d;
                    $ret.h = e;
                    $ret.c = k;
                    $ret.b = l;
                    return $ret;
                })()));
            }
        }
        var u = this.wx.en(2, h) - this.wx.en(1, h);
        for (var v = b.b0.c; v <= b.b0.d; ++v) {
            var w = void 0;
            var x = v * q;
            if (n == null) {
                w = b.b0.getBucket(v);
            }
            else {
                var y = n.i$b._inner[v];
                x = y;
                var z = n.i$d(y);
                var aa = this.xt.item(y);
                var ab = this.xr.item(y);
                var ac = this.xs.item(y);
                var ad = this.xq.item(y);
                var ae = aa;
                var af = ab;
                var ag = ac;
                var ah = ad;
                var ai = z;
                while (v < b.b0.d) {
                    y = n.i$b._inner[v + 1];
                    ai = n.i$d(y);
                    if (ai - z > u * p) {
                        break;
                    }
                    x = y;
                    v++;
                    af = Math.max(af, this.xr.item(y));
                    ag = Math.min(ag, this.xs.item(y));
                    ah = this.xq.item(y);
                }
                var aj = NaN;
                if (!isNaN_(z)) {
                    aj = this.wx.ek(z, h);
                }
                w = [aj, ae, af, ag, ah];
            }
            if (!isNaN_(w[0])) {
                if (n != null) {
                    w[0] = w[0] + m;
                }
                else {
                    w[0] = f.ek(w[0], h) + m;
                }
                w[1] = g.ek(w[1], i);
                w[2] = g.ek(w[2], i);
                w[3] = g.ek(w[3], i);
                w[4] = g.ek(w[4], i);
                if (n != null) {
                    if (a.m == null) {
                        a.m = new List$1(Number_$type, 0);
                    }
                    a.m.add(x);
                }
                a.f.add(w);
            }
        }
        return;
    };
    FinancialPriceSeries.prototype.o2 = function (a, b) {
        _super.prototype.o2.call(this, a, b);
        var c = typeCast(FinancialPriceSeriesView.$, b);
        c.ce();
        if (a) {
            c.b9.count = 0;
        }
        if (c.ca && c.b8 != null) {
            c.b8.g$d();
        }
    };
    FinancialPriceSeries.prototype.sj = function (a, b) {
        _super.prototype.sj.call(this, a, b);
        if (this.c9 != null) {
            this.c9.nq();
        }
    };
    FinancialPriceSeries.prototype.wm = function (a, b) {
        if (this.wx != null && this.wx.categoryMode == 0) {
            var c = this.getEffectiveViewport1(this.ct);
            var d = this.aax(this.xe, c) / 2;
            return new Thickness(1, d, 0, d, 0);
        }
        return _super.prototype.wm.call(this, a, b);
    };
    FinancialPriceSeries.prototype.get_eb = function () {
        return true;
    };
    FinancialPriceSeries.prototype.z5 = function (a, b) {
        _super.prototype.z5.call(this, a, b);
        if (this.wx == null || this.xg == null) {
            return;
        }
        var c = false;
        if (b.b3(a)) {
            c = true;
            b.b5(a);
        }
        this.w6.a2(this, this.x5(), runOn(this, this.wp), this.yu(b), this.yw(b));
        var d = false;
        var e = this.w6.b;
        if (e != null) {
            d = true;
        }
        var f = typeCast(FinancialPriceSeriesView.$, b);
        f.cd();
        f.cb = false;
        if (f.ca) {
            f.b8.g$d();
        }
        if (this.trendLineType != 0) {
            f.b8.g$g(a.q);
        }
        if (d) {
            this.abj(a, b, c);
        }
        else {
            f.b9.count = 0;
            this.abi(a, b);
        }
    };
    FinancialPriceSeries.prototype.iu = function () {
        var a = this.getEffectiveViewport1(this.ct);
        return this.aax(this.xe, a);
    };
    FinancialPriceSeries.prototype.abj = function (a, b, c) {
        var d = this.aat;
        var e = this.getEffectiveViewport1(b);
        var f = this.aax(b, e);
        var g = (f - 1) / 2;
        var h = typeCast(ISortingAxis_$type, this.wx) !== null;
        var i = typeCast(FinancialPriceSeriesView.$, b);
        i.cb = true;
        var j = a.f;
        var k = 0;
        var l = this.dl.count;
        var m = this.wx;
        var n = new ScalerParams(0, b.by, b.bx, m.ch, e);
        var o = this.u2;
        var p = this.aan;
        if (p == null) {
            p = o;
        }
        var q = this.u6;
        var r = this.ab5;
        if (r == null) {
            r = q;
        }
        var _loop_1 = function (s) {
            var t = j._inner[s][0] - g;
            var u = j._inner[s][0];
            var v = j._inner[s][0] + g;
            var w = j._inner[s][1];
            var x = j._inner[s][2];
            var y = j._inner[s][3];
            var z = j._inner[s][4];
            if (isNaN_(w) || isNaN_(x) || isNaN_(y) || isNaN_(z)) {
                return "continue";
            }
            var aa = i.b9.item(k);
            k++;
            var ab = w < z;
            var ac = new PathGeometry();
            if (c) {
                switch (d) {
                    case 0:
                        if (ab) {
                            var ad = w;
                            w = z;
                            z = ad;
                        }
                        var ae = new PathFigure();
                        ae._startPoint = { $type: Point_$type, x: u, y: y };
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: w };
                            return $ret;
                        })()));
                        var af = new PathFigure();
                        af._startPoint = { $type: Point_$type, x: t, y: z };
                        af._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: v, y: z };
                            return $ret;
                        })()));
                        af._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: v, y: w };
                            return $ret;
                        })()));
                        af._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: w };
                            return $ret;
                        })()));
                        af._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: z };
                            return $ret;
                        })()));
                        var ag = new PathFigure();
                        ag._startPoint = { $type: Point_$type, x: u, y: z };
                        ag._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: x };
                            return $ret;
                        })()));
                        ac.c.add(ae);
                        ac.c.add(af);
                        ac.c.add(ag);
                        break;
                    case 1:
                        var ah = new PathFigure();
                        ah._startPoint = { $type: Point_$type, x: t, y: w };
                        ah._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: w };
                            return $ret;
                        })()));
                        var ai = new PathFigure();
                        ai._startPoint = { $type: Point_$type, x: u, y: y };
                        ai._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: x };
                            return $ret;
                        })()));
                        var aj = new PathFigure();
                        aj._startPoint = { $type: Point_$type, x: u, y: z };
                        aj._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: v, y: z };
                            return $ret;
                        })()));
                        ac.c.add(ah);
                        ac.c.add(ai);
                        ac.c.add(aj);
                        break;
                }
            }
            if (ab) {
                this_1.w6.ak = p;
                this_1.w6.ag = p;
                this_1.w6.ah = r;
                this_1.w6.al = r;
                this_1.w6.f = true;
            }
            else {
                this_1.w6.ak = o;
                this_1.w6.ag = o;
                this_1.w6.ah = q;
                this_1.w6.al = q;
                this_1.w6.f = false;
            }
            var ak = this_1.w6.aw(l, s)[0];
            if (h && a.m != null && s >= 0 && s < a.m.count) {
                ak = truncate(Math.round(a.m._inner[s]));
            }
            this_1.z2(j, s, l, m, n, b.q, ak);
            if (d == 1) {
                this_1.w6.ad(aa, true, false, false, false);
            }
            else {
                this_1.w6.ad(aa, false, false, false, false);
            }
            if (c) {
                aa.an = ac;
            }
        };
        var this_1 = this;
        for (var s = 0; s < j.count; ++s) {
            _loop_1(s);
        }
        i.b9.count = k;
        i.cf();
    };
    FinancialPriceSeries.prototype.aax = function (a, b) {
        var c = this.wx.k5(a.by, a.bx, b);
        c = Math.max(c, this.ib * 0.9);
        c = Math.max(c, 3);
        return c;
    };
    FinancialPriceSeries.prototype.abi = function (a, b) {
        var c = this.aat;
        var d = this.getEffectiveViewport1(b);
        var e = this.aax(b, d);
        var f = (e - 1) / 2;
        var g = typeCast(FinancialPriceSeriesView.$, b);
        var h = g.cn();
        var i = g.cm();
        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.ku = function (a, b) {
        if (this.aas.ca && a == this.aas.b8.g$j) {
            return null;
        }
        return _super.prototype.ku.call(this, a, b);
    };
    FinancialPriceSeries.prototype.sa = function () {
        _super.prototype.sa.call(this);
        if (this.index < 0) {
            return;
        }
        this.aas.cl();
    };
    FinancialPriceSeries.prototype.pu = function (a) {
        _super.prototype.pu.call(this, a);
        if (this.aas.ca) {
            this.bb.exportTrendlineData(this, a, this.aas.b8.g$j);
        }
    };
    FinancialPriceSeries.prototype.vq = function () {
        return this.ab5;
    };
    FinancialPriceSeries.prototype.rw = function (a, b) {
        _super.prototype.rw.call(this, a, b);
        this.ab5 = b;
    };
    FinancialPriceSeries.prototype.bd = function (a) {
        if (this.aat == 0) {
            return 3;
        }
        else if (this.aat == 1) {
            if (this.bc == 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.i1(c, false, false);
        var e = this.iz(c, false, false);
        var f = new DataLegendSeriesValueInfo();
        f.a = 4;
        f.l = this.yp(c, false, false);
        f.q = "Close";
        f.r = this.y1 != null ? this.y1 : "Close";
        f.s = this.aa0 != null ? this.aa0 : "C:";
        f.t = this.aa2 != null ? this.aa2 : "";
        var g = new DataLegendSeriesValueInfo();
        g.l = this.yq(c, false, false);
        g.a = 3;
        g.q = "Open";
        g.r = this.zn != null ? this.zn : "Open";
        g.s = this.abe != null ? this.abe : "O:";
        g.t = this.abg != null ? this.abg : "";
        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.q = "Change";
        h.r = "Change";
        h.s = "";
        h.v = "";
        h.x = "+";
        h.w = "%";
        h.y = "%";
        h.t = 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.z = h.l >= 0 ? this.u2 : this.aan;
        f.z = h.l >= 0 ? this.u2 : this.aan;
        h.z = h.l >= 0 ? this.u2 : this.aan;
        var i = new DataLegendSeriesValueInfo();
        i.l = e > d ? d : e;
        i.a = 1;
        i.q = "Low";
        i.r = this.zj != null ? this.zj : "Low";
        i.s = this.aa9 != null ? this.aa9 : "L:";
        i.t = this.abb != null ? this.abb : "";
        i.k = true;
        var j = new DataLegendSeriesValueInfo();
        j.l = e > d ? e : d;
        j.a = 2;
        j.q = "High";
        j.r = this.ze != null ? this.ze : "High";
        j.s = this.aa5 != null ? this.aa5 : "H:";
        j.t = this.aa7 != null ? this.aa7 : "";
        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.q = "TypicalPrice";
        k.r = "TypicalPrice";
        k.s = "TP:";
        k.t = "";
        k.k = true;
        var l = new DataLegendSeriesValueInfo();
        l.l = this.yr(c, false, false);
        l.a = 8;
        l.q = "Volume";
        l.r = this.zr != null ? this.zr : "Volume";
        l.s = "VOL:";
        l.t = "";
        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.h = this.l9();
        n.e = m;
        return n;
    };
    FinancialPriceSeries.prototype.abk = function () {
        if (this.aau) {
            this.aav = 0;
            for (var a = 0; a < this.xr.count; a++) {
                var b = 0;
                b += this.xr.item(a);
                b += this.xs.item(a);
                b += this.xq.item(a);
                this.aav += b / 3;
            }
            this.aaw = this.aav / this.xr.count;
            this.aau = false;
        }
    };
    FinancialPriceSeries.prototype.ap = function (a) {
        var b = NaN;
        switch (a) {
            case 2:
                b = this.xr.maximum;
                break;
            case 1:
                b = this.xs.minimum;
                break;
            case 3:
                if (this.aau) {
                    this.abk();
                }
                b = this.aaw;
                break;
        }
        var c = this.xg;
        if (c.cp) {
            return [NaN, b];
        }
        else {
            return [b, NaN];
        }
    };
    FinancialPriceSeries.prototype.v8 = function (a) {
        var b = NaN;
        switch (a) {
            case 2:
                b = this.xr.maximum;
                break;
            case 1:
                b = this.xs.minimum;
                break;
            case 3:
                if (this.aau) {
                    this.abk();
                }
                b = this.aaw;
                break;
        }
        if (isNaN_(b)) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var c = this.xg;
        var d = this.getEffectiveViewport1(this.ct);
        var e = new ScalerParams(0, this.ct.by, this.ct.bx, c.ch, d);
        if (c.cp) {
            e.b = this.iw();
        }
        e.c = d;
        if (c.cp) {
            return { $type: Point_$type, x: NaN, y: c.ek(b, e) };
        }
        else {
            return { $type: Point_$type, x: c.ek(b, e), y: NaN };
        }
    };
    FinancialPriceSeries.prototype.v9 = function (a) {
        var b = this.xg;
        var c = this.getEffectiveViewport1(this.ct);
        var d = new ScalerParams(0, this.ct.by, this.ct.bx, b.ch, c);
        if (b.cp) {
            d.b = this.iw();
        }
        d.c = c;
        if (b.cp) {
            return { $type: Point_$type, x: NaN, y: b.ek(a[1], d) };
        }
        else {
            return { $type: Point_$type, x: b.ek(a[0], d), y: NaN };
        }
    };
    FinancialPriceSeries.$t = markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.abm = 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:aa0:abn', [2, null], 'CloseMemberAsLegendUnit:aa2:abo', [2, null], 'DisplayType:aat:abp', [PriceDisplayType_$type, enumGetBox(PriceDisplayType_$type, 0)], 'HighMemberAsLegendLabel:aa5:abq', [2, null], 'HighMemberAsLegendUnit:aa7:abr', [2, null], 'LowMemberAsLegendLabel:aa9:abs', [2, null], 'LowMemberAsLegendUnit:abb:abt', [2, null], 'NegativeOutline:ab5:abu', [Brush.$, null], 'OpenMemberAsLegendLabel:abe:abv', [2, null], 'OpenMemberAsLegendUnit:abg:abw', [2, null], 'TrendLineType::ab2', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ab1', [1, 1.5], 'TrendLinePeriod::ab0', [1, 7], 'TrendLineBrush::abx', [Brush.$, null], 'TrendLineZIndex:aaz:ab3', [1, 1001], 'TrendLineDashArray:ab6:aby', [DoubleCollection.$], 'TrendLineDashCap:ab7:abz', [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.b6 = null;
        _this.b9 = null;
        _this.cc = null;
        _this.cq = ((function () {
            var $ret = new Path();
            $ret.an = new GeometryGroup();
            return $ret;
        })());
        _this.cp = ((function () {
            var $ret = new Path();
            $ret.an = new GeometryGroup();
            return $ret;
        })());
        _this.b7 = null;
        _this.co = new Path();
        _this.cb = false;
        _this.b6 = a;
        _this.cc = new List$1(Path.$, 0);
        _this.b9 = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.cr);
            $ret.activate = runOn(_this, _this.ch);
            $ret.disactivate = runOn(_this, _this.cj);
            $ret.destroy = runOn(_this, _this.ci);
            return $ret;
        })());
        return _this;
    }
    FinancialPriceSeriesView.prototype.cr = function () {
        var a = new Path();
        this.cc.add(a);
        a._visibility = 1;
        return a;
    };
    FinancialPriceSeriesView.prototype.ch = function (a) {
        a._visibility = 0;
    };
    FinancialPriceSeriesView.prototype.cj = function (a) {
        a._visibility = 1;
    };
    FinancialPriceSeriesView.prototype.ci = function (a) {
        this.cc.remove(a);
    };
    FinancialPriceSeriesView.prototype.b1 = function () {
        return new FinancialPriceBucketCalculator(this);
    };
    FinancialPriceSeriesView.prototype.au = function () {
        _super.prototype.au.call(this);
        if (!this.q) {
            this.b6.aat = Defaults.g;
            this.b6.aan = Defaults.ah;
            this.b6.ab5 = Defaults.ai;
            this.b6.jn = Defaults.l;
            this.b6.vo = this.b6.u6;
        }
    };
    Object.defineProperty(FinancialPriceSeriesView.prototype, "b8", {
        get: function () {
            if (this.b7 == null) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.az(), this.e.so, this.e, this.e.dp);
            }
            return this.b7;
        },
        set: function (a) {
            this.b7 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialPriceSeriesView.prototype, "ca", {
        get: function () {
            return this.b7 != null;
        },
        enumerable: false,
        configurable: true
    });
    FinancialPriceSeriesView.prototype.ck = function () {
        if (this.b6.aat == 1) {
            this.cq._stroke = this.e.u2;
        }
        else {
            this.cq._stroke = this.e.u6;
        }
        if (this.b6.aat == 1) {
            this.cp._stroke = this.b2.aan;
        }
        else {
            this.cp._stroke = this.b6.ab5;
        }
    };
    FinancialPriceSeriesView.prototype.ce = function () {
        this.as();
        this.b9.count = 0;
        this.cd();
    };
    FinancialPriceSeriesView.prototype.cd = function () {
        var a = typeCast(GeometryGroup.$, this.cq.an);
        var b = typeCast(GeometryGroup.$, this.cp.an);
        Extensions.d(a);
        Extensions.d(b);
    };
    FinancialPriceSeriesView.prototype.cn = function () {
        this.as();
        return typeCast(GeometryGroup.$, this.cq.an);
    };
    FinancialPriceSeriesView.prototype.cm = function () {
        this.as();
        return typeCast(GeometryGroup.$, this.cp.an);
    };
    FinancialPriceSeriesView.prototype.cl = function () {
        this.b6.ab4 = null;
        if (this.b6.trendLineBrush != null) {
            this.b6.ab4 = this.b6.trendLineBrush;
        }
        else {
            this.b6.ab4 = this.b6.u2;
        }
    };
    FinancialPriceSeriesView.prototype.bd = function () {
        _super.prototype.bd.call(this);
        this.cq.ad = this.e.ic;
        this.cq.ai = this.e.vv;
        this.cq.aj = this.e.vw;
        if (this.b6.aat == 1) {
            this.cq._stroke = this.e.u2;
        }
        else {
            this.cq._stroke = this.e.u6;
            this.cq._fill = this.e.u2;
        }
        this.cp.ad = this.e.ic;
        this.cp.ai = this.e.vv;
        this.cp.aj = this.e.vw;
        if (this.b6.aat == 1) {
            this.cp._stroke = this.b2.aan;
        }
        else {
            this.cp._stroke = this.b6.ab5;
            this.cp._fill = this.b2.aan;
        }
    };
    FinancialPriceSeriesView.prototype.be = function () {
        _super.prototype.be.call(this);
        var a = this.br();
        this.cq.ad = this.e.ic + 3;
        if (this.b6.aat == 1) {
            this.cq._stroke = a;
        }
        else {
            this.cq._stroke = a;
            this.cq._fill = a;
        }
        this.cp.ad = this.e.ic + 3;
        if (this.b6.aat == 1) {
            this.cp._stroke = a;
        }
        else {
            this.cp._stroke = a;
            this.cp._fill = a;
        }
    };
    FinancialPriceSeriesView.prototype.ac = function (a) {
        return this.cc._inner[a];
    };
    FinancialPriceSeriesView.prototype.ab = function (a) {
        var b = this.cc._inner[a];
        this.co._visibility = b._visibility;
        this.co.an = b.an;
        var c = this.bs(a);
        this.co._fill = c;
        this.co._stroke = c;
        this.co.ad = this.e.ic + 3;
        return this.co;
    };
    FinancialPriceSeriesView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        if (a.d) {
            if (this.cb) {
                for (var c = 0; c < this.cc.count; c++) {
                    var d = this.aa(c, b);
                    if (d._visibility == 0) {
                        a.t(d);
                    }
                }
            }
            else {
                a.t(this.cq);
                a.t(this.cp);
            }
        }
    };
    FinancialPriceSeriesView.prototype.a7 = function (a, b) {
        if (a.d) {
            if (this.b6.trendLineType != 0 && !b) {
                var c = this.b8.g$j;
                c.ad = this.b6.trendLineThickness;
                c._stroke = this.b6.ab4;
                c.ai = this.b6.ab6;
                c.aj = this.b6.ab7;
                a.v(c);
            }
        }
        _super.prototype.a7.call(this, a, b);
    };
    FinancialPriceSeriesView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
        if (this.b6.x5()) {
            for (var b = 0; b < this.cc.count; b++) {
                var c = this.cc._inner[b];
                if (c._fill == this.b6.aan) {
                    this.e.bb.exportPathData(a, c, "negativePathShape" + b, ["Negative"]);
                }
                else {
                    this.e.bb.exportPathData(a, c, "positivePathShape" + b, ["Positive", "Main"]);
                }
            }
        }
        else {
            this.e.bb.exportPathData(a, this.cq, "positivePathShape", ["Positive", "Main"]);
            this.e.bb.exportPathData(a, this.cp, "negativePathShape", ["Negative"]);
        }
    };
    FinancialPriceSeriesView.prototype.cf = function () {
        this.as();
    };
    FinancialPriceSeriesView.prototype.cg = function () {
        if (this.ca) {
            this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.az(), this.e.so, this.e, this.e.dp);
        }
    };
    FinancialPriceSeriesView.$t = markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
}(FinancialSeriesView));
export { FinancialPriceSeriesView };
