/*
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 { 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, 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
 */
export let FinancialPriceSeries = /*@__PURE__*/ (() => {
    class FinancialPriceSeries extends FinancialSeries {
        bc() {
            return new FinancialPriceSeries();
        }
        get_eo() {
            return true;
        }
        iq() {
            if (!isNaN_(this.ip)) {
                return super.iq();
            }
            return Defaults.k;
        }
        cd() {
            return new FinancialPriceSeriesView(this);
        }
        o2(a) {
            super.o2(a);
            this.x6 = a;
        }
        constructor() {
            super();
            this.x8 = true;
            this.x9 = 0;
            this.ya = 0;
            this.ab = FinancialPriceSeries.$;
            this.uf = new CategoryFrame(5);
            this.uh = new CategoryFrame(5);
            this.ud = new CategoryFrame(5);
        }
        get zi() {
            return this.c(FinancialPriceSeries.y0);
        }
        set zi(a) {
            this.h(FinancialPriceSeries.y0, a);
        }
        np(a, b, c, d) {
            super.np(a, b, c, d);
            if (this.ub != null && typeCast(ISortingAxis_$type, this.ub) !== null) {
                this.ub.i$i();
            }
            this.x6.b0.e(this.hk);
            if (this.x6.ca) {
                this.x6.b8.g$e(a, b, c, d);
            }
            if (this.uu != null) {
                this.uu.c1();
            }
            this.pr(true);
            if (a == 0 || a == 2 || a == 3 || a == 4) {
                this.x8 = true;
            }
            else if (a == 1) {
                for (let e = b; e < b + c; e++) {
                    let f = 0;
                    f += this.u5.item(e);
                    f += this.u6.item(e);
                    f += this.u4.item(e);
                    this.x9 += f / 3;
                }
                this.ya = this.x9 / this.u5.count;
            }
        }
        bu() {
            if (this.bv == 0) {
                return 1;
            }
            else {
                return super.bu();
            }
        }
        tu(a) {
            if (this.ud == null || this.ud.f.count == 0) {
                return Rect.empty;
            }
            let b = this.te(a);
            let c = this.cg.by;
            let d = this.cg.bx;
            let e = this.getEffectiveViewport1(this.cg);
            let f = this.aj(this.ub, this.ud.f, this.v8(this.cg), this.wa(this.cg), a, true);
            let g = f[0];
            let h = f[1];
            let i = Math.abs(b.x - g[0]);
            let j = Math.abs(b.x - h[0]);
            let k = this.yb(this.us, e);
            k = Math.max(k, 3);
            let l = (k - 1) / 2;
            if (i < j) {
                let m = g[0] - l;
                let n = g[0];
                let o = g[0] + l;
                let p = g[1];
                let q = g[2];
                let r = g[3];
                let s = g[4];
                let t = Math.min(Math.min(Math.min(p, q), r), s);
                let u = Math.max(Math.max(Math.max(p, q), r), s);
                return new Rect(0, m, t, Math.abs(o - m), u - t);
            }
            else {
                let v = h[0] - l;
                let w = h[0];
                let x = h[0] + l;
                let y = h[1];
                let z = h[2];
                let aa = h[3];
                let ab = h[4];
                let ac = Math.min(Math.min(Math.min(y, z), aa), ab);
                let ad = Math.max(Math.max(Math.max(y, z), aa), ab);
                return new Rect(0, v, ac, Math.abs(x - v), ad - ac);
            }
        }
        x5(a, b) {
            let c = a[0] - b;
            let d = a[0];
            let e = a[0] + b;
            let f = a[1];
            let g = a[2];
            let h = a[3];
            let i = a[4];
            let j = Math.min(Math.min(Math.min(f, g), h), i);
            let k = Math.max(Math.max(Math.max(f, g), h), i);
            let l = Math.min(g, h);
            let m = Math.max(g, h);
            let n = Math.min(f, i);
            let o = Math.max(f, i);
            if (this.x7 == 1) {
                let p = new Array(3);
                let q = new Rect(0, c, f, b, 0);
                let r = new Rect(0, d, i, b, 0);
                let s = new Rect(0, d, l, 0, m - l);
                p[0] = q;
                p[1] = r;
                p[2] = s;
                return p;
            }
            else {
                let t = new Array(2);
                let u = new Rect(0, d, l, 0, m - l);
                let v = new Rect(0, c, n, b * 2, o - n);
                t[0] = u;
                t[1] = v;
                return t;
            }
        }
        ak(a) {
            let b = new List$1(Rect.$, 0);
            let c = this.te(a);
            let d = this.cg.by;
            let e = this.cg.bx;
            let f = this.getEffectiveViewport1(this.cg);
            let g = this.aj(this.ub, this.ud.f, this.v8(this.cg), this.wa(this.cg), a, true);
            let h = g[0];
            let i = g[1];
            let j = Math.abs(c.x - h[0]);
            let k = Math.abs(c.x - i[0]);
            let l = this.yb(this.us, f);
            l = Math.max(l, 3);
            let m = (l - 1) / 2;
            if (j < k) {
                return this.x5(h, m);
            }
            else {
                return this.x5(i, m);
            }
        }
        f5(a, b) {
            if (this.f8(a, b)) {
                return true;
            }
            return false;
        }
        f8(a, b) {
            let c = this.tv(a);
            if (c.isEmpty) {
                return false;
            }
            let d = RectUtil.r(c, (this.hl / 2) + this.hz(b));
            if (d.containsPoint(a)) {
                let e = this.al(a);
                if (e != null) {
                    for (let f = 0; f < e.length; f++) {
                        let g = e[f];
                        let h = RectUtil.r(g, (this.hl / 2) + this.hz(b));
                        if (h.containsPoint(a)) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
        pa(a, b, c, d) {
            switch (b) {
                case FinancialSeries.$$p[14]:
                    this.x6.cg();
                    if (this.cv != null) {
                        this.cv.mg();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.x6.b8 = CategoryTrendLineManagerFactory.a(this.x6.b8, this.ub, this.qt, this, this.da);
                    }
                    break;
            }
            super.pa(a, b, c, d);
            if (this.x6.ca && this.x6.b8 != null && this.x6.b8.g$b(a, b, c, d)) {
                this.pr(false);
                this.om();
            }
            switch (b) {
                case FinancialPriceSeries.$$p[2]:
                    if (this.qt != null) {
                        this.yz();
                        this.qg();
                        this.ud.w();
                        this.xj(this.ud, this.x6);
                    }
                    this.om();
                    break;
                case "ActualHighlightingMode":
                    this.pr(true);
                    break;
                case "TrendLineBrush":
                    this.pg(b);
                    break;
                case "TrendLineType":
                    this.om();
                    break;
                case FinancialSeries.$$p[10]:
                case FinancialPriceSeries.$$p[7]:
                    this.o4();
                    break;
            }
        }
        yz() {
            this.x6.ck();
            if (this.cf != null) {
                this.cf.ck();
            }
        }
        aq(a) {
            if (a != null && a == this.uu && this.u6 != null && !isNaN_(this.u6.minimum) && this.u5 != null && !isNaN_(this.u5.maximum)) {
                return new AxisRange(this.u6.minimum, this.u5.maximum);
            }
            return null;
        }
        ar(a) {
            if (a.isEmpty && this.cv != null) {
                a = this.cv.tr;
            }
            if (this.u6 == null || this.u5 == null) {
                return null;
            }
            let b = this.tq(this.cg);
            let c = new ScalerParams(0, a, this.cv.t6, this.ub.ch, this.getEffectiveViewport());
            let d = (this.ub.em(b.left, c));
            let e = (this.ub.em(b.right, c));
            if (this.ub.ch) {
                let f = d;
                d = e;
                e = f;
            }
            let g = null;
            if (this.ub.cn) {
                g = this.ub;
                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.u6.count - 1, d));
            e = Math.max(0, Math.min(this.u6.count - 1, e));
            let h = 1.7976931348623157E+308;
            let i = -1.7976931348623157E+308;
            for (let j = truncate(d); j <= truncate(e); j++) {
                let k = j;
                if (g != null) {
                    k = g.i$b._inner[j];
                }
                let l = this.u6.item(k);
                if (this.u6.mayContainUnknowns) {
                    if (isInfinity(l) || isNaN_(l)) {
                        continue;
                    }
                }
                let m = this.u5.item(k);
                if (this.u5.mayContainUnknowns) {
                    if (isInfinity(m) || isNaN_(m)) {
                        continue;
                    }
                }
                h = Math.min(h, l);
                i = Math.max(i, m);
            }
            let n = new AxisRange(h, i);
            n = this.ap(n, this.uu, a);
            return n;
        }
        h3() {
            return Series.h4(this.u7, typeCast(ISortingAxis_$type, this.ub));
        }
        fp(a) {
            let b = this.c7 != null ? this.c7.indexOf(a) : -1;
            let c = this.cg.by;
            c = c.copy();
            let d = this.cg.bx;
            let e = new Rect(0, 0, 0, 1, 1);
            let f = this.ts(this.cg);
            if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
                if (this.ub != null) {
                    let g = new ScalerParams(0, e, e, this.ub.ch, f);
                    let h = this.ub.ej(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.uu != null && this.u6 != null && this.u5 != null && b < this.u6.count && b < this.u5.count) {
                    let i = new ScalerParams(0, e, e, this.uu.ch, f);
                    i.b = this.h3();
                    let j = this.uu.ej(this.u6.item(b), i);
                    let k = this.uu.ej(this.u5.item(b), i);
                    if (!isNaN_(j) && !isNaN_(k)) {
                        let 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.co.au(this.cv, c, true);
            }
            return b >= 0;
        }
        gm(a, b, c) {
            let d = super.gm(a, b, c);
            if (this.u7 == null || this.u4 == null || this.u5 == null || this.u6 == null) {
                d = false;
            }
            return d;
        }
        xh(a, b) {
            super.xh(a, b);
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = this.ub;
            let g = this.uu;
            let h = new ScalerParams(0, c, d, f.ch, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, g.ch, e);
                $ret.b = this.h3();
                return $ret;
            })());
            let j = this.ub.ag();
            let k = j[0];
            let l = j[1];
            a.f.clear();
            a.m.clear();
            a.p.clear();
            let m = 0;
            let n = typeCast(ISortingAxis_$type, this.ub);
            if (n != null && (n.i$b == null || n.i$b.count != this.c7.count)) {
                return;
            }
            m = this.v2(c, d, e);
            let o = typeCast(FinancialPriceSeriesView.$, b);
            let p = this.hk;
            if (this.trendLineType != 0) {
                let q = new Array(this.c7.count);
                let r = 0;
                for (let s of fromEnum(this.vt)) {
                    q[r] = s;
                    r++;
                }
                if (this.x6.ca) {
                    this.x6.b8.prepareLineCore(a.p, this.trendLineType, boxArray$1(q), this.trendLinePeriod, (t) => this.ub.ej(t, h), (t) => this.uu.ej(t, i), ((() => {
                        let $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.h = d;
                        $ret.c = k;
                        $ret.b = l;
                        return $ret;
                    })()));
                }
            }
            let t = this.ub.em(2, h) - this.ub.em(1, h);
            for (let u = b.b0.c; u <= b.b0.d; ++u) {
                let v;
                if (n == null) {
                    v = b.b0.getBucket(u);
                }
                else {
                    let w = n.i$b._inner[u];
                    let x = n.i$d(w);
                    let y = this.u7.item(w);
                    let z = this.u5.item(w);
                    let aa = this.u6.item(w);
                    let ab = this.u4.item(w);
                    let ac = y;
                    let ad = z;
                    let ae = aa;
                    let af = ab;
                    let ag = x;
                    while (u < b.b0.d) {
                        w = n.i$b._inner[u + 1];
                        ag = n.i$d(w);
                        if (ag - x > t * p) {
                            break;
                        }
                        u++;
                        ad = Math.max(ad, this.u5.item(w));
                        ae = Math.min(ae, this.u6.item(w));
                        af = this.u4.item(w);
                    }
                    let ah = NaN;
                    if (!isNaN_(x)) {
                        ah = this.ub.ej(x, h);
                    }
                    v = [ah, ac, ad, ae, af];
                }
                if (!isNaN_(v[0])) {
                    if (n != null) {
                        v[0] = v[0] + m;
                    }
                    else {
                        v[0] = f.ej(v[0], h) + m;
                    }
                    v[1] = g.ej(v[1], i);
                    v[2] = g.ej(v[2], i);
                    v[3] = g.ej(v[3], i);
                    v[4] = g.ej(v[4], i);
                    a.f.add(v);
                }
            }
            return;
        }
        nk(a, b) {
            super.nk(a, b);
            let c = typeCast(FinancialPriceSeriesView.$, b);
            c.ce();
            if (a) {
                c.b9.count = 0;
            }
            if (c.ca && c.b8 != null) {
                c.b8.g$d();
            }
        }
        qo(a, b) {
            super.qo(a, b);
            if (this.cv != null) {
                this.cv.mg();
            }
        }
        t0(a, b) {
            if (this.ub != null && this.ub.categoryMode == 0) {
                let c = this.getEffectiveViewport1(this.cg);
                let d = this.yb(this.us, c) / 2;
                return new Thickness(1, d, 0, d, 0);
            }
            return super.t0(a, b);
        }
        get_dv() {
            return true;
        }
        xj(a, b) {
            super.xj(a, b);
            if (this.ub == null || this.uu == null) {
                return;
            }
            let c = false;
            if (b.b3(a)) {
                c = true;
                b.b5(a);
            }
            this.uk.a2(this, this.vj(), runOn(this, this.t3), this.v8(b), this.wa(b));
            let d = false;
            let e = this.uk.b;
            if (e != null) {
                d = true;
            }
            let 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.p);
            }
            if (d) {
                this.yx(a, b, c);
            }
            else {
                f.b9.count = 0;
                this.yw(a, b);
            }
        }
        h1() {
            let a = this.getEffectiveViewport1(this.cg);
            return this.yb(this.us, a);
        }
        yx(a, b, c) {
            let d = this.x7;
            let e = this.getEffectiveViewport1(b);
            let f = this.yb(b, e);
            let g = (f - 1) / 2;
            let h = typeCast(FinancialPriceSeriesView.$, b);
            h.cb = true;
            let i = a.f;
            let j = 0;
            let k = this.c7.count;
            let l = this.ub;
            let m = new ScalerParams(0, b.by, b.bx, l.ch, e);
            let n = this.su;
            let o = this.x1;
            if (o == null) {
                o = n;
            }
            let p = this.sx;
            let q = this.zj;
            if (q == null) {
                q = p;
            }
            for (let r = 0; r < i.count; ++r) {
                let s = i._inner[r][0] - g;
                let t = i._inner[r][0];
                let u = i._inner[r][0] + g;
                let v = i._inner[r][1];
                let w = i._inner[r][2];
                let x = i._inner[r][3];
                let y = i._inner[r][4];
                if (isNaN_(v) || isNaN_(w) || isNaN_(x) || isNaN_(y)) {
                    continue;
                }
                let z = h.b9.item(j);
                j++;
                let aa = v < y;
                let ab = new PathGeometry();
                if (c) {
                    switch (d) {
                        case 0:
                            if (aa) {
                                let ac = v;
                                v = y;
                                y = ac;
                            }
                            let ad = new PathFigure();
                            ad._startPoint = { $type: Point_$type, x: t, y: x };
                            ad._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: v };
                                return $ret;
                            })()));
                            let ae = new PathFigure();
                            ae._startPoint = { $type: Point_$type, x: s, y: y };
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: y };
                                return $ret;
                            })()));
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: v };
                                return $ret;
                            })()));
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: s, y: v };
                                return $ret;
                            })()));
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: s, y: y };
                                return $ret;
                            })()));
                            let af = new PathFigure();
                            af._startPoint = { $type: Point_$type, x: t, y: y };
                            af._segments.add(((() => {
                                let $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:
                            let ag = new PathFigure();
                            ag._startPoint = { $type: Point_$type, x: s, y: v };
                            ag._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: v };
                                return $ret;
                            })()));
                            let ah = new PathFigure();
                            ah._startPoint = { $type: Point_$type, x: t, y: x };
                            ah._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: w };
                                return $ret;
                            })()));
                            let ai = new PathFigure();
                            ai._startPoint = { $type: Point_$type, x: t, y: y };
                            ai._segments.add(((() => {
                                let $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.uk.ak = o;
                    this.uk.ag = o;
                    this.uk.ah = q;
                    this.uk.al = q;
                    this.uk.f = true;
                }
                else {
                    this.uk.ak = n;
                    this.uk.ag = n;
                    this.uk.ah = p;
                    this.uk.al = p;
                    this.uk.f = false;
                }
                this.xg(i, r, k, l, m, b.q);
                if (d == 1) {
                    this.uk.ad(z, true, false, false, false);
                }
                else {
                    this.uk.ad(z, false, false, false, false);
                }
                if (c) {
                    z.an = ab;
                }
            }
            h.b9.count = j;
            h.cf();
        }
        yb(a, b) {
            let c = this.ub.k4(a.by, a.bx, b);
            c = Math.max(c, this.hk * 0.9);
            c = Math.max(c, 3);
            return c;
        }
        yw(a, b) {
            let c = this.x7;
            let d = this.getEffectiveViewport1(b);
            let e = this.yb(b, d);
            let f = (e - 1) / 2;
            let g = typeCast(FinancialPriceSeriesView.$, b);
            let h = g.cn();
            let i = g.cm();
            let j = a.f;
            for (let k = 0; k < j.count; ++k) {
                let l = j._inner[k][0] - f;
                let m = j._inner[k][0];
                let n = j._inner[k][0] + f;
                let o = j._inner[k][1];
                let p = j._inner[k][2];
                let q = j._inner[k][3];
                let r = j._inner[k][4];
                if (isNaN_(o) || isNaN_(p) || isNaN_(q) || isNaN_(r)) {
                    continue;
                }
                let s = o < r;
                let t = s ? i : h;
                switch (c) {
                    case 0:
                        if (s) {
                            let u = o;
                            o = r;
                            r = u;
                        }
                        t.d.add(((() => {
                            let $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(((() => {
                            let $ret = new RectangleGeometry();
                            $ret.e = new Rect(0, l, r, n - l, o - r);
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $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(((() => {
                            let $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(((() => {
                            let $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(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: r };
                            $ret.c = { $type: Point_$type, x: n, y: r };
                            return $ret;
                        })()));
                        break;
                }
            }
        }
        jz(a, b) {
            if (this.x6.ca && a == this.x6.b8.g$j) {
                return null;
            }
            return super.jz(a, b);
        }
        qf() {
            super.qf();
            if (this.index < 0) {
                return;
            }
            this.x6.cl();
        }
        n2(a) {
            super.n2(a);
            if (this.x6.ca) {
                this.a5.exportTrendlineData(this, a, this.x6.b8.g$j);
            }
        }
        s6() {
            return this.zj;
        }
        p1(a, b) {
            super.p1(a, b);
            this.zj = b;
        }
        a7(a) {
            if (this.x7 == 0) {
                return 3;
            }
            else if (this.x7 == 1) {
                if (this.a6 == 1) {
                    return 3;
                }
                return 2;
            }
            return a;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.h8(c, false, false);
            let e = this.h6(c, false, false);
            let f = new DataLegendSeriesValueInfo();
            f.a = 4;
            f.l = this.v3(c, false, false);
            f.p = "Close";
            f.q = this.wf != null ? this.wf : "Close";
            f.r = this.ye != null ? this.ye : "C:";
            f.s = this.yg != null ? this.yg : "";
            let g = new DataLegendSeriesValueInfo();
            g.l = this.v4(c, false, false);
            g.a = 3;
            g.p = "Open";
            g.q = this.w1 != null ? this.w1 : "Open";
            g.r = this.ys != null ? this.ys : "O:";
            g.s = this.yu != null ? this.yu : "";
            g.k = true;
            let 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 = "Change";
            h.r = "";
            h.u = "";
            h.w = "+";
            h.v = "%";
            h.x = "%";
            h.s = 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.y = h.l >= 0 ? this.su : this.x1;
            f.y = h.l >= 0 ? this.su : this.x1;
            h.y = h.l >= 0 ? this.su : this.x1;
            let i = new DataLegendSeriesValueInfo();
            i.l = e > d ? d : e;
            i.a = 1;
            i.p = "Low";
            i.q = this.wx != null ? this.wx : "Low";
            i.r = this.yn != null ? this.yn : "L:";
            i.s = this.yp != null ? this.yp : "";
            i.k = true;
            let j = new DataLegendSeriesValueInfo();
            j.l = e > d ? e : d;
            j.a = 2;
            j.p = "High";
            j.q = this.ws != null ? this.ws : "High";
            j.r = this.yj != null ? this.yj : "H:";
            j.s = this.yl != null ? this.yl : "";
            j.k = true;
            let 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 = "TypicalPrice";
            k.r = "TP:";
            k.s = "";
            k.k = true;
            let l = new DataLegendSeriesValueInfo();
            l.l = this.v5(c, false, false);
            l.a = 8;
            l.p = "Volume";
            l.q = this.w5 != null ? this.w5 : "Volume";
            l.r = "VOL:";
            l.s = "";
            l.k = true;
            l.n = 0;
            l.m = 0;
            l.e = false;
            l.f = false;
            l.h = false;
            let 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);
            let n = new DataLegendSeriesContext();
            n.b = this.aw();
            n.f = m;
            return n;
        }
        yy() {
            if (this.x8) {
                this.x9 = 0;
                for (let a = 0; a < this.u5.count; a++) {
                    let b = 0;
                    b += this.u5.item(a);
                    b += this.u6.item(a);
                    b += this.u4.item(a);
                    this.x9 += b / 3;
                }
                this.ya = this.x9 / this.u5.count;
                this.x8 = false;
            }
        }
        am(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.u5.maximum;
                    break;
                case 1:
                    b = this.u6.minimum;
                    break;
                case 3:
                    if (this.x8) {
                        this.yy();
                    }
                    b = this.ya;
                    break;
            }
            let c = this.uu;
            if (c.cp) {
                return [NaN, b];
            }
            else {
                return [b, NaN];
            }
        }
        tm(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.u5.maximum;
                    break;
                case 1:
                    b = this.u6.minimum;
                    break;
                case 3:
                    if (this.x8) {
                        this.yy();
                    }
                    b = this.ya;
                    break;
            }
            if (isNaN_(b)) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let c = this.uu;
            let d = this.getEffectiveViewport1(this.cg);
            let e = new ScalerParams(0, this.cg.by, this.cg.bx, c.ch, d);
            if (c.cp) {
                e.b = this.h3();
            }
            e.c = d;
            if (c.cp) {
                return { $type: Point_$type, x: NaN, y: c.ej(b, e) };
            }
            else {
                return { $type: Point_$type, x: c.ej(b, e), y: NaN };
            }
        }
        tn(a) {
            let b = this.uu;
            let c = this.getEffectiveViewport1(this.cg);
            let d = new ScalerParams(0, this.cg.by, this.cg.bx, b.ch, c);
            if (b.cp) {
                d.b = this.h3();
            }
            d.c = c;
            if (b.cp) {
                return { $type: Point_$type, x: NaN, y: b.ej(a[1], d) };
            }
            else {
                return { $type: Point_$type, x: b.ej(a[0], d), y: NaN };
            }
        }
    }
    FinancialPriceSeries.$t = /*@__PURE__*/ markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.y0 = /*@__PURE__*/ DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, /*@__PURE__*/ new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
    FinancialPriceSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['CloseMemberAsLegendLabel:ye:y1', [2, null], 'CloseMemberAsLegendUnit:yg:y2', [2, null], 'DisplayType:x7:y3', [PriceDisplayType_$type, /*@__PURE__*/ enumGetBox(PriceDisplayType_$type, 0)], 'HighMemberAsLegendLabel:yj:y4', [2, null], 'HighMemberAsLegendUnit:yl:y5', [2, null], 'LowMemberAsLegendLabel:yn:y6', [2, null], 'LowMemberAsLegendUnit:yp:y7', [2, null], 'NegativeOutline:zj:y8', [Brush.$, null], 'OpenMemberAsLegendLabel:ys:y9', [2, null], 'OpenMemberAsLegendUnit:yu:za', [2, null], 'TrendLineType::zg', [TrendLineType_$type, /*@__PURE__*/ enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::zf', [1, 1.5], 'TrendLinePeriod::ze', [1, 7], 'TrendLineBrush::zb', [Brush.$, null], 'TrendLineZIndex:yd:zh', [1, 1001], 'TrendLineDashArray:zk:zc', [DoubleCollection.$], 'TrendLineDashCap:zl:zd', [PenLineCap_$type, /*@__PURE__*/ enumGetBox(PenLineCap_$type, 0)]]);
    return FinancialPriceSeries;
})();
/**
 * @hidden
 */
export let FinancialPriceSeriesView = /*@__PURE__*/ (() => {
    class FinancialPriceSeriesView extends FinancialSeriesView {
        constructor(a) {
            super(a);
            this.b6 = null;
            this.b9 = null;
            this.cc = null;
            this.cq = ((() => {
                let $ret = new Path();
                $ret.an = new GeometryGroup();
                return $ret;
            })());
            this.cp = ((() => {
                let $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 = ((() => {
                let $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;
            })());
        }
        cr() {
            let a = new Path();
            this.cc.add(a);
            a._visibility = 1;
            return a;
        }
        ch(a) {
            a._visibility = 0;
        }
        cj(a) {
            a._visibility = 1;
        }
        ci(a) {
            this.cc.remove(a);
        }
        b1() {
            return new FinancialPriceBucketCalculator(this);
        }
        au() {
            super.au();
            if (!this.q) {
                this.b6.x7 = Defaults.g;
                this.b6.x1 = Defaults.ah;
                this.b6.zj = Defaults.ai;
                this.b6.iv = Defaults.l;
                this.b6.s4 = this.b6.sx;
            }
        }
        get b8() {
            if (this.b7 == null) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.as(), this.e.qt, this.e, this.e.da);
            }
            return this.b7;
        }
        set b8(a) {
            this.b7 = a;
        }
        get ca() {
            return this.b7 != null;
        }
        ck() {
            if (this.b6.x7 == 1) {
                this.cq._stroke = this.e.su;
            }
            else {
                this.cq._stroke = this.e.sx;
            }
            if (this.b6.x7 == 1) {
                this.cp._stroke = this.b2.x1;
            }
            else {
                this.cp._stroke = this.b6.zj;
            }
        }
        ce() {
            this.as();
            this.b9.count = 0;
            this.cd();
        }
        cd() {
            let a = typeCast(GeometryGroup.$, this.cq.an);
            let b = typeCast(GeometryGroup.$, this.cp.an);
            Extensions.d(a);
            Extensions.d(b);
        }
        cn() {
            this.as();
            return typeCast(GeometryGroup.$, this.cq.an);
        }
        cm() {
            this.as();
            return typeCast(GeometryGroup.$, this.cp.an);
        }
        cl() {
            this.b6.zi = null;
            if (this.b6.trendLineBrush != null) {
                this.b6.zi = this.b6.trendLineBrush;
            }
            else {
                this.b6.zi = this.b6.su;
            }
        }
        bd() {
            super.bd();
            this.cq.ad = this.e.hl;
            this.cq.ai = this.e.s9;
            this.cq.aj = this.e.ta;
            if (this.b6.x7 == 1) {
                this.cq._stroke = this.e.su;
            }
            else {
                this.cq._stroke = this.e.sx;
                this.cq._fill = this.e.su;
            }
            this.cp.ad = this.e.hl;
            this.cp.ai = this.e.s9;
            this.cp.aj = this.e.ta;
            if (this.b6.x7 == 1) {
                this.cp._stroke = this.b2.x1;
            }
            else {
                this.cp._stroke = this.b6.zj;
                this.cp._fill = this.b2.x1;
            }
        }
        be() {
            super.be();
            let a = this.br();
            this.cq.ad = this.e.hl + 3;
            if (this.b6.x7 == 1) {
                this.cq._stroke = a;
            }
            else {
                this.cq._stroke = a;
                this.cq._fill = a;
            }
            this.cp.ad = this.e.hl + 3;
            if (this.b6.x7 == 1) {
                this.cp._stroke = a;
            }
            else {
                this.cp._stroke = a;
                this.cp._fill = a;
            }
        }
        ac(a) {
            return this.cc._inner[a];
        }
        ab(a) {
            let b = this.cc._inner[a];
            this.co._visibility = b._visibility;
            this.co.an = b.an;
            let c = this.bs(a);
            this.co._fill = c;
            this.co._stroke = c;
            this.co.ad = this.e.hl + 3;
            return this.co;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                if (this.cb) {
                    for (let c = 0; c < this.cc.count; c++) {
                        let d = this.aa(c, b);
                        if (d._visibility == 0) {
                            a.t(d);
                        }
                    }
                }
                else {
                    a.t(this.cq);
                    a.t(this.cp);
                }
            }
        }
        a7(a, b) {
            if (a.d) {
                if (this.b6.trendLineType != 0 && !b) {
                    let c = this.b8.g$j;
                    c.ad = this.b6.trendLineThickness;
                    c._stroke = this.b6.zi;
                    c.ai = this.b6.zk;
                    c.aj = this.b6.zl;
                    a.v(c);
                }
            }
            super.a7(a, b);
        }
        an(a) {
            super.an(a);
            if (this.b6.vj()) {
                for (let b = 0; b < this.cc.count; b++) {
                    let c = this.cc._inner[b];
                    if (c._fill == this.b6.x1) {
                        this.e.a5.exportPathData(a, c, "negativePathShape" + b, ["Negative"]);
                    }
                    else {
                        this.e.a5.exportPathData(a, c, "positivePathShape" + b, ["Positive", "Main"]);
                    }
                }
            }
            else {
                this.e.a5.exportPathData(a, this.cq, "positivePathShape", ["Positive", "Main"]);
                this.e.a5.exportPathData(a, this.cp, "negativePathShape", ["Negative"]);
            }
        }
        cf() {
            this.as();
        }
        cg() {
            if (this.ca) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.as(), this.e.qt, this.e, this.e.da);
            }
        }
    }
    FinancialPriceSeriesView.$t = /*@__PURE__*/ markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
})();
