/*
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-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
 */
export let FinancialPriceSeries = /*@__PURE__*/ (() => {
    class FinancialPriceSeries extends FinancialSeries {
        constructor() {
            super();
            this.tx = true;
            this.ty = 0;
            this.tz = 0;
            this.ab = FinancialPriceSeries.$;
            this.qo = new CategoryFrame(5);
            this.qq = new CategoryFrame(5);
            this.qm = new CategoryFrame(5);
        }
        get_dv() {
            return true;
        }
        gz() {
            if (!isNaN_(this.gy)) {
                return super.gz();
            }
            return Defaults.k;
        }
        by() {
            return new FinancialPriceSeriesView(this);
        }
        l4(a) {
            super.l4(a);
            this.tv = a;
        }
        get u7() {
            return this.c(FinancialPriceSeries.up);
        }
        set u7(a) {
            this.h(FinancialPriceSeries.up, a);
        }
        k5(a, b, c, d) {
            super.k5(a, b, c, d);
            if (this.qk != null && typeCast(ISortingAxis_$type, this.qk) !== null) {
                this.qk.i$i();
            }
            this.tv.bx.e(this.fx);
            if (this.tv.b7) {
                this.tv.b5.g$e(a, b, c, d);
            }
            if (this.q6 != null) {
                this.q6.c0();
            }
            this.mn(true);
            if (a == 0 || a == 2 || a == 3 || a == 4) {
                this.tx = true;
            }
            else if (a == 1) {
                for (let e = b; e < b + c; e++) {
                    let f = 0;
                    f += this.re.item(e);
                    f += this.rf.item(e);
                    f += this.rd.item(e);
                    this.ty += f / 3;
                }
                this.tz = this.ty / this.re.count;
            }
        }
        bq() {
            if (this.br == 0) {
                return 1;
            }
            else {
                return super.bq();
            }
        }
        p3(a) {
            if (this.qm == null || this.qm.f.count == 0) {
                return Rect.empty;
            }
            let b = this.pn(a);
            let c = this.b1.bv;
            let d = this.b1.bu;
            let e = this.getEffectiveViewport1(this.b1);
            let f = this.aj(this.qk, this.qm.f, this.sh(this.b1), this.sj(this.b1), 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.t0(this.q1, 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);
            }
        }
        tu(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.tw == 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.pn(a);
            let d = this.b1.bv;
            let e = this.b1.bu;
            let f = this.getEffectiveViewport1(this.b1);
            let g = this.aj(this.qk, this.qm.f, this.sh(this.b1), this.sj(this.b1), 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.t0(this.q1, f);
            l = Math.max(l, 3);
            let m = (l - 1) / 2;
            if (j < k) {
                return this.tu(h, m);
            }
            else {
                return this.tu(i, m);
            }
        }
        ez(a, b) {
            if (this.e2(a, b)) {
                return true;
            }
            return false;
        }
        e2(a, b) {
            let c = this.p4(a);
            if (c.isEmpty) {
                return false;
            }
            let d = RectUtil.r(c, (this.fy / 2) + this.gc(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.fy / 2) + this.gc(b));
                        if (h.containsPoint(a)) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
        l9(a, b, c, d) {
            switch (b) {
                case FinancialSeries.$$p[9]:
                    this.tv.cd();
                    if (this.ce != null) {
                        this.ce.l6();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.tv.b5 = CategoryTrendLineManagerFactory.a(this.tv.b5, this.qk, this.nf, this, this.co);
                    }
                    break;
            }
            super.l9(a, b, c, d);
            if (this.tv.b7 && this.tv.b5 != null && this.tv.b5.g$b(a, b, c, d)) {
                this.mn(false);
                this.lu();
            }
            switch (b) {
                case FinancialPriceSeries.$$p[2]:
                    if (this.nf != null) {
                        this.uo();
                        this.m2();
                        this.qm.w();
                        this.td(this.qm, this.tv);
                    }
                    this.lu();
                    break;
                case "ActualHighlightingMode":
                    this.mn(true);
                    break;
                case "TrendLineBrush":
                    this.m1();
                    break;
                case "TrendLineType":
                    this.lu();
                    break;
                case FinancialSeries.$$p[5]:
                case FinancialPriceSeries.$$p[7]:
                    this.l6();
                    break;
            }
        }
        uo() {
            this.tv.ch();
            if (this.b0 != null) {
                this.b0.ch();
            }
        }
        aq(a) {
            if (a != null && a == this.q6 && this.rf != null && !isNaN_(this.rf.minimum) && this.re != null && !isNaN_(this.re.maximum)) {
                return new AxisRange(this.rf.minimum, this.re.maximum);
            }
            return null;
        }
        ar(a) {
            if (a.isEmpty && this.ce != null) {
                a = this.ce.ta;
            }
            if (this.rf == null || this.re == null) {
                return null;
            }
            let b = this.pz(this.b1);
            let c = new ScalerParams(0, a, this.ce.tp, this.qk.cg, this.getEffectiveViewport());
            let d = (this.qk.el(b.left, c));
            let e = (this.qk.el(b.right, c));
            if (this.qk.cg) {
                let f = d;
                d = e;
                e = f;
            }
            let g = null;
            if (this.qk.cm) {
                g = this.qk;
                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.rf.count - 1, d));
            e = Math.max(0, Math.min(this.rf.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.rf.item(k);
                if (this.rf.mayContainUnknowns) {
                    if (isInfinity(l) || isNaN_(l)) {
                        continue;
                    }
                }
                let m = this.re.item(k);
                if (this.re.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.q6, a);
            return n;
        }
        gg() {
            return Series.gh(this.rg, typeCast(ISortingAxis_$type, this.qk));
        }
        eq(a) {
            let b = this.cl != null ? this.cl.indexOf(a) : -1;
            let c = this.b1.bv;
            c = c.copy();
            let d = this.b1.bu;
            let e = new Rect(0, 0, 0, 1, 1);
            let f = this.p1(this.b1);
            if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
                if (this.qk != null) {
                    let g = new ScalerParams(0, e, e, this.qk.cg, f);
                    let h = this.qk.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.q6 != null && this.rf != null && this.re != null && b < this.rf.count && b < this.re.count) {
                    let i = new ScalerParams(0, e, e, this.q6.cg, f);
                    i.b = this.gg();
                    let j = this.q6.ei(this.rf.item(b), i);
                    let k = this.q6.ei(this.re.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.b9.au(this.ce, c, true);
            }
            return b >= 0;
        }
        fd(a, b, c) {
            let d = super.fd(a, b, c);
            if (this.rg == null || this.rd == null || this.re == null || this.rf == null) {
                d = false;
            }
            return d;
        }
        tb(a, b) {
            super.tb(a, b);
            let c = b.bv;
            let d = b.bu;
            let e = this.getEffectiveViewport1(b);
            let f = this.qk;
            let g = this.q6;
            let h = new ScalerParams(0, c, d, f.cg, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, g.cg, e);
                $ret.b = this.gg();
                return $ret;
            })());
            a.f.clear();
            a.m.clear();
            a.p.clear();
            let j = 0;
            let k = typeCast(ISortingAxis_$type, this.qk);
            if (k != null && (k.i$b == null || k.i$b.count != this.cl.count)) {
                return;
            }
            j = this.sb(c, d, e);
            let l = typeCast(FinancialPriceSeriesView.$, b);
            let m = this.fx;
            if (this.trendLineType != 0) {
                let n = new Array(this.cl.count);
                let o = 0;
                for (let p of fromEnum(this.r2)) {
                    n[o] = p;
                    o++;
                }
                if (this.tv.b7) {
                    this.tv.b5.prepareLineCore(a.p, this.trendLineType, boxArray$1(n), this.trendLinePeriod, (q) => this.qk.ei(q, h), (q) => this.q6.ei(q, i), ((() => {
                        let $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;
                    })()));
                }
            }
            let q = this.qk.el(2, h) - this.qk.el(1, h);
            for (let r = b.bx.c; r <= b.bx.d; ++r) {
                let s;
                if (k == null) {
                    s = b.bx.getBucket(r);
                }
                else {
                    let t = k.i$b._inner[r];
                    let u = k.i$d(t);
                    let v = this.rg.item(t);
                    let w = this.re.item(t);
                    let x = this.rf.item(t);
                    let y = this.rd.item(t);
                    let z = v;
                    let aa = w;
                    let ab = x;
                    let ac = y;
                    let 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.re.item(t));
                        ab = Math.min(ab, this.rf.item(t));
                        ac = this.rd.item(t);
                    }
                    let ae = NaN;
                    if (!isNaN_(u)) {
                        ae = this.qk.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;
        }
        k2(a, b) {
            super.k2(a, b);
            let c = typeCast(FinancialPriceSeriesView.$, b);
            c.cb();
            if (a) {
                c.b6.count = 0;
            }
            if (c.b7 && c.b5 != null) {
                c.b5.g$d();
            }
        }
        na(a, b) {
            super.na(a, b);
            if (this.ce != null) {
                this.ce.l6();
            }
        }
        p9(a, b) {
            if (this.qk != null && this.qk.categoryMode == 0) {
                let c = this.getEffectiveViewport1(this.b1);
                let d = this.t0(this.q1, c) / 2;
                return new Thickness(1, d, 0, d, 0);
            }
            return super.p9(a, b);
        }
        get_c3() {
            return true;
        }
        td(a, b) {
            super.td(a, b);
            if (this.qk == null || this.q6 == null) {
                return;
            }
            let c = false;
            if (b.b0(a)) {
                c = true;
                b.b2(a);
            }
            this.qt.a2(this, this.rs(), runOn(this, this.qc), this.sh(b), this.sj(b));
            let d = false;
            let e = this.qt.b;
            if (e != null) {
                d = true;
            }
            let 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.um(a, b, c);
            }
            else {
                f.b6.count = 0;
                this.ul(a, b);
            }
        }
        ge() {
            let a = this.getEffectiveViewport1(this.b1);
            return this.t0(this.q1, a);
        }
        um(a, b, c) {
            let d = this.tw;
            let e = this.getEffectiveViewport1(b);
            let f = this.t0(b, e);
            let g = (f - 1) / 2;
            let h = typeCast(FinancialPriceSeriesView.$, b);
            h.b8 = true;
            let i = a.f;
            let j = 0;
            let k = this.cl.count;
            let l = this.qk;
            let m = new ScalerParams(0, b.bv, b.bu, l.cg, e);
            let n = this.o5;
            let o = this.tq;
            if (o == null) {
                o = n;
            }
            let p = this.o8;
            let q = this.u8;
            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.b6.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.qt.ak = o;
                    this.qt.ag = o;
                    this.qt.ah = q;
                    this.qt.al = q;
                    this.qt.f = true;
                }
                else {
                    this.qt.ak = n;
                    this.qt.ag = n;
                    this.qt.ah = p;
                    this.qt.al = p;
                    this.qt.f = false;
                }
                this.ta(i, r, k, l, m, b.q);
                if (d == 1) {
                    this.qt.ad(z, true, false, false, false);
                }
                else {
                    this.qt.ad(z, false, false, false, false);
                }
                if (c) {
                    z.an = ab;
                }
            }
            h.b6.count = j;
            h.cc();
        }
        t0(a, b) {
            let c = this.qk.k3(a.bv, a.bu, b);
            c = Math.max(c, this.fx * 0.9);
            c = Math.max(c, 3);
            return c;
        }
        ul(a, b) {
            let c = this.tw;
            let d = this.getEffectiveViewport1(b);
            let e = this.t0(b, d);
            let f = (e - 1) / 2;
            let g = typeCast(FinancialPriceSeriesView.$, b);
            let h = g.ck();
            let i = g.cj();
            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;
                }
            }
        }
        h4(a, b) {
            if (this.tv.b7 && a == this.tv.b5.g$j) {
                return null;
            }
            return super.h4(a, b);
        }
        m1() {
            super.m1();
            if (this.index < 0) {
                return;
            }
            this.tv.ci();
        }
        lc(a) {
            super.lc(a);
            if (this.tv.b7) {
                this.a9.exportTrendlineData(this, a, this.tv.b5.g$j);
            }
        }
        pg() {
            return this.u8;
        }
        ms(a, b) {
            super.ms(a, b);
            this.u8 = b;
        }
        bb(a) {
            if (this.tw == 0) {
                return 3;
            }
            else if (this.tw == 1) {
                if (this.ba == 1) {
                    return 3;
                }
                return 2;
            }
            return a;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.gl(c, false, false);
            let e = this.gj(c, false, false);
            let f = new DataLegendSeriesValueInfo();
            f.a = 4;
            f.l = this.sc(c, false, false);
            f.p = "Close";
            f.q = this.so != null ? this.so : "Close";
            f.r = this.t3 != null ? this.t3 : "C:";
            f.s = this.t5 != null ? this.t5 : "";
            let g = new DataLegendSeriesValueInfo();
            g.l = this.sd(c, false, false);
            g.a = 3;
            g.p = "Open";
            g.q = this.s0 != null ? this.s0 : "Open";
            g.r = this.uh != null ? this.uh : "O:";
            g.s = this.uj != null ? this.uj : "";
            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.o5 : this.tq;
            f.y = h.l >= 0 ? this.o5 : this.tq;
            h.y = h.l >= 0 ? this.o5 : this.tq;
            let i = new DataLegendSeriesValueInfo();
            i.l = e > d ? d : e;
            i.a = 1;
            i.p = "Low";
            i.q = this.sw != null ? this.sw : "Low";
            i.r = this.uc != null ? this.uc : "L:";
            i.s = this.ue != null ? this.ue : "";
            i.k = true;
            let j = new DataLegendSeriesValueInfo();
            j.l = e > d ? e : d;
            j.a = 2;
            j.p = "High";
            j.q = this.sr != null ? this.sr : "High";
            j.r = this.t8 != null ? this.t8 : "H:";
            j.s = this.ua != null ? this.ua : "";
            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.se(c, false, false);
            l.a = 8;
            l.p = "Volume";
            l.q = this.s4 != null ? this.s4 : "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;
        }
        un() {
            if (this.tx) {
                this.ty = 0;
                for (let a = 0; a < this.re.count; a++) {
                    let b = 0;
                    b += this.re.item(a);
                    b += this.rf.item(a);
                    b += this.rd.item(a);
                    this.ty += b / 3;
                }
                this.tz = this.ty / this.re.count;
                this.tx = false;
            }
        }
        am(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.re.maximum;
                    break;
                case 1:
                    b = this.rf.minimum;
                    break;
                case 3:
                    if (this.tx) {
                        this.un();
                    }
                    b = this.tz;
                    break;
            }
            let c = this.q6;
            if (c.co) {
                return [NaN, b];
            }
            else {
                return [b, NaN];
            }
        }
        pv(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.re.maximum;
                    break;
                case 1:
                    b = this.rf.minimum;
                    break;
                case 3:
                    if (this.tx) {
                        this.un();
                    }
                    b = this.tz;
                    break;
            }
            if (isNaN_(b)) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let c = this.q6;
            let d = this.getEffectiveViewport1(this.b1);
            let e = new ScalerParams(0, this.b1.bv, this.b1.bu, c.cg, d);
            if (c.co) {
                e.b = this.gg();
            }
            e.c = d;
            if (c.co) {
                return { $type: Point_$type, x: NaN, y: c.ei(b, e) };
            }
            else {
                return { $type: Point_$type, x: c.ei(b, e), y: NaN };
            }
        }
        pw(a) {
            let b = this.q6;
            let c = this.getEffectiveViewport1(this.b1);
            let d = new ScalerParams(0, this.b1.bv, this.b1.bu, b.cg, c);
            if (b.co) {
                d.b = this.gg();
            }
            d.c = c;
            if (b.co) {
                return { $type: Point_$type, x: NaN, y: b.ei(a[1], d) };
            }
            else {
                return { $type: Point_$type, x: b.ei(a[0], d), y: NaN };
            }
        }
    }
    FinancialPriceSeries.$t = markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.up = DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
    FinancialPriceSeries.$$p = markDep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['CloseMemberAsLegendLabel:t3:uq', [2, null], 'CloseMemberAsLegendUnit:t5:ur', [2, null], 'DisplayType:tw:us', [PriceDisplayType_$type, enumGetBox(PriceDisplayType_$type, 0)], 'HighMemberAsLegendLabel:t8:ut', [2, null], 'HighMemberAsLegendUnit:ua:uu', [2, null], 'LowMemberAsLegendLabel:uc:uv', [2, null], 'LowMemberAsLegendUnit:ue:uw', [2, null], 'NegativeOutline:u8:ux', [Brush.$, null], 'OpenMemberAsLegendLabel:uh:uy', [2, null], 'OpenMemberAsLegendUnit:uj:uz', [2, null], 'TrendLineType::u5', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::u4', [1, 1.5], 'TrendLinePeriod::u3', [1, 7], 'TrendLineBrush::u0', [Brush.$, null], 'TrendLineZIndex:t2:u6', [1, 1001], 'TrendLineDashArray:u9:u1', [DoubleCollection.$], 'TrendLineDashCap:va:u2', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
    return FinancialPriceSeries;
})();
/**
 * @hidden
 */
export let FinancialPriceSeriesView = /*@__PURE__*/ (() => {
    class FinancialPriceSeriesView extends FinancialSeriesView {
        constructor(a) {
            super(a);
            this.b3 = null;
            this.b6 = null;
            this.b9 = null;
            this.cn = ((() => {
                let $ret = new Path();
                $ret.an = new GeometryGroup();
                return $ret;
            })());
            this.cm = ((() => {
                let $ret = new Path();
                $ret.an = 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 = ((() => {
                let $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;
            })());
        }
        co() {
            let a = new Path();
            this.b9.add(a);
            a._visibility = 1;
            return a;
        }
        ce(a) {
            a._visibility = 0;
        }
        cg(a) {
            a._visibility = 1;
        }
        cf(a) {
            this.b9.remove(a);
        }
        by() {
            return new FinancialPriceBucketCalculator(this);
        }
        as() {
            super.as();
            if (!this.q) {
                this.b3.tw = Defaults.g;
                this.b3.tq = Defaults.ah;
                this.b3.u8 = Defaults.ai;
                this.b3.g4 = Defaults.l;
                this.b3.pe = this.b3.o8;
            }
        }
        get b5() {
            if (this.b4 == null) {
                this.b4 = CategoryTrendLineManagerFactory.a(this.b4, this.e.as(), this.e.nf, this.e, this.e.co);
            }
            return this.b4;
        }
        set b5(a) {
            this.b4 = a;
        }
        get b7() {
            return this.b4 != null;
        }
        ch() {
            if (this.b3.tw == 1) {
                this.cn._stroke = this.e.o5;
            }
            else {
                this.cn._stroke = this.e.o8;
            }
            if (this.b3.tw == 1) {
                this.cm._stroke = this.bz.tq;
            }
            else {
                this.cm._stroke = this.b3.u8;
            }
        }
        cb() {
            this.aq();
            this.b6.count = 0;
            this.ca();
        }
        ca() {
            let a = typeCast(GeometryGroup.$, this.cn.an);
            let b = typeCast(GeometryGroup.$, this.cm.an);
            Extensions.d(a);
            Extensions.d(b);
        }
        ck() {
            this.aq();
            return typeCast(GeometryGroup.$, this.cn.an);
        }
        cj() {
            this.aq();
            return typeCast(GeometryGroup.$, this.cm.an);
        }
        ci() {
            this.b3.u7 = null;
            if (this.b3.trendLineBrush != null) {
                this.b3.u7 = this.b3.trendLineBrush;
            }
            else {
                this.b3.u7 = this.b3.o5;
            }
        }
        bb() {
            super.bb();
            this.cn.ad = this.e.fy;
            this.cn.ai = this.e.pi;
            this.cn.aj = this.e.pj;
            if (this.b3.tw == 1) {
                this.cn._stroke = this.e.o5;
            }
            else {
                this.cn._stroke = this.e.o8;
                this.cn._fill = this.e.o5;
            }
            this.cm.ad = this.e.fy;
            this.cm.ai = this.e.pi;
            this.cm.aj = this.e.pj;
            if (this.b3.tw == 1) {
                this.cm._stroke = this.bz.tq;
            }
            else {
                this.cm._stroke = this.b3.u8;
                this.cm._fill = this.bz.tq;
            }
        }
        bc() {
            super.bc();
            let a = this.bo();
            this.cn.ad = this.e.fy + 3;
            if (this.b3.tw == 1) {
                this.cn._stroke = a;
            }
            else {
                this.cn._stroke = a;
                this.cn._fill = a;
            }
            this.cm.ad = this.e.fy + 3;
            if (this.b3.tw == 1) {
                this.cm._stroke = a;
            }
            else {
                this.cm._stroke = a;
                this.cm._fill = a;
            }
        }
        ac(a) {
            return this.b9._inner[a];
        }
        ab(a) {
            let b = this.b9._inner[a];
            this.cl._visibility = b._visibility;
            this.cl.an = b.an;
            let c = this.bp(a);
            this.cl._fill = c;
            this.cl._stroke = c;
            this.cl.ad = this.e.fy + 3;
            return this.cl;
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                if (this.b8) {
                    for (let c = 0; c < this.b9.count; c++) {
                        let d = this.aa(c, b);
                        if (d._visibility == 0) {
                            a.t(d);
                        }
                    }
                }
                else {
                    a.t(this.cn);
                    a.t(this.cm);
                }
            }
        }
        a5(a, b) {
            if (a.d) {
                if (this.b3.trendLineType != 0 && !b) {
                    let c = this.b5.g$j;
                    c.ad = this.b3.trendLineThickness;
                    c._stroke = this.b3.u7;
                    c.ai = this.b3.u9;
                    c.aj = this.b3.va;
                    a.v(c);
                }
            }
            super.a5(a, b);
        }
        al(a) {
            super.al(a);
            if (this.b3.rs()) {
                for (let b = 0; b < this.b9.count; b++) {
                    let c = this.b9._inner[b];
                    if (c._fill == this.b3.tq) {
                        this.e.a9.exportPathData(a, c, "negativePathShape" + b, ["Negative"]);
                    }
                    else {
                        this.e.a9.exportPathData(a, c, "positivePathShape" + b, ["Positive", "Main"]);
                    }
                }
            }
            else {
                this.e.a9.exportPathData(a, this.cn, "positivePathShape", ["Positive", "Main"]);
                this.e.a9.exportPathData(a, this.cm, "negativePathShape", ["Negative"]);
            }
        }
        cc() {
            this.aq();
        }
        cd() {
            if (this.b7) {
                this.b4 = CategoryTrendLineManagerFactory.a(this.b4, this.e.as(), this.e.nf, this.e, this.e.co);
            }
        }
    }
    FinancialPriceSeriesView.$t = markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
})();
