/*
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 { Series } from "./Series";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { Axis } from "./Axis";
import { DependencyProperty } from "igniteui-angular-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { Point_$type, typeCast, Delegate_$type, markType, markDep } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { AxisAnnotationFrame } from "./AxisAnnotationFrame";
import { List$1 } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { SeriesView } from "./SeriesView";
import { NotImplementedException } from "igniteui-angular-core";
import { AxisRange } from "./AxisRange";
import { NumericAxisBase } from "./NumericAxisBase";
import { ScalerParams } from "./ScalerParams";
import { CategoryXAxis } from "./CategoryXAxis";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { stringFormat } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
/**
 * @hidden
 */
export let ValueOverlay = /*@__PURE__*/ (() => {
    class ValueOverlay extends Series {
        constructor() {
            super();
            this.qp = 0;
            this.qq = 0;
            this.qm = 0;
            this.p9 = null;
            this.qf = null;
            this.qe = null;
            this.ab = ValueOverlay.$;
        }
        gl(a, b, c) {
            return this.qr;
        }
        qn(a, b) {
            let c = Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
            let d = Math.acos((a.x - b.x) / c);
            if ((a.y - b.y) < 0) {
                d = (2 * Math.PI) - d;
            }
            return d;
        }
        pq(a, b, c) {
            if (this.p8 == null) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let d = this.qo();
            let e = NaN;
            let f = NaN;
            let g = NaN;
            let h = { $type: Point_$type, x: 0.5, y: 0.5 };
            let i = NaN;
            switch (this.p8.a1) {
                case 2:
                    i = Math.sqrt(Math.pow(a.x - h.x, 2) + Math.pow(a.y - h.y, 2));
                    g = d;
                    e = h.x + Math.cos(g) * i;
                    f = h.y + Math.sin(g) * i;
                    f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                    e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                    break;
                case 0:
                    e = d;
                    f = a.y;
                    f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                    break;
                case 1:
                    f = d;
                    e = a.x;
                    e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                    break;
                case 3:
                    g = this.qn(a, h);
                    i = d;
                    e = h.x + Math.cos(g) * i;
                    f = h.y + Math.sin(g) * i;
                    f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                    e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                    break;
            }
            return { $type: Point_$type, x: e, y: f };
        }
        hf(a) {
            throw new NotImplementedException(0);
        }
        hv(a) {
            return this;
        }
        eo(a) {
            return false;
        }
        ap(a) {
            let b = typeCast(NumericAxisBase.$, a);
            let c = this.qr;
            if (isNaN_(c) || isInfinity(c)) {
                return null;
            }
            return new AxisRange(c, c);
        }
        mm(a) {
            this.k0(true, this.b0);
            if (!this.qd()) {
                if (this.p9 != null) {
                    this.ra(NaN, this.cv());
                }
                return;
            }
            if (this.ep(a)) {
                if (this.cv()) {
                    if (this.ce.g) {
                        this.ce.t();
                    }
                    let b = this.qp;
                    this.qp = this.qq;
                    this.qq = b;
                }
                else {
                    this.qp = this.qm;
                }
                this.qm = this.qo();
                this.mu();
            }
            else {
                this.qm = this.qo();
                this.q9(this.qm, this.qb);
            }
        }
        qo() {
            let a, b;
            let c = this.getViewInfo(b, a);
            b = c.p0;
            a = c.p1;
            let d = this.getEffectiveViewport1(this.b0);
            let e = new ScalerParams(0, a, b, this.p8.cg, d);
            return this.p8.ei(this.qr, e);
        }
        q9(a, b) {
            if (this.p8 == null) {
                return;
            }
            let c = typeCast(CategoryAxisBase.$, this.p8);
            if (c != null && !c.cd) {
                if (this.qr > c.lf - 1) {
                    return;
                }
                if (c.categoryMode != 0) {
                    let d = this.getEffectiveViewport1(b);
                    let e = 0.5 * c.getCategorySize(b.bv, b.bu, d);
                    let f = false;
                    if (c.co && !c.cg) {
                        f = true;
                    }
                    if (typeCast(CategoryXAxis.$, c) !== null && c.cg) {
                        f = true;
                    }
                    if (f) {
                        e = -e;
                    }
                    a += e;
                }
            }
            let g = typeCast(NumericAxisBase.$, this.p8);
            if (g != null) {
                if (this.qr < g.lv || this.qr > g.lu) {
                    return;
                }
                if (g.lh && this.qr < 0) {
                    return;
                }
            }
            let h;
            switch (this.p8.a1) {
                case 2:
                case 3:
                    h = this.p8.j4(a, b.bv, b.bu, this.getEffectiveViewport1(b), this.pv(b));
                    break;
                default:
                    h = this.p8.j4(a, b.bv, b.bu);
                    break;
            }
            if (h != null) {
                b.by(h);
            }
            if (!b.q) {
                this.ra(a, this.cv());
            }
        }
        fb(a, b, c) {
            let d = true;
            d = super.fb(a, b, c);
            if (!c.o() || b.isEmpty || a.isEmpty || this.p8 == null || this.p8.bh == null) {
                d = false;
            }
            return d;
        }
        m9(a, b) {
            this.ml(false);
        }
        m8(a, b) {
            this.ml(false);
        }
        k3(a, b, c, d) {
            throw new NotImplementedException(0);
        }
        l7(a, b, c, d) {
            super.l7(a, b, c, d);
            switch (b) {
                case ValueOverlay.$$p[11]:
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    this.ml(false);
                    this.ls();
                    break;
                case "TransitionProgress":
                    this.qq = this.qp + this.g2 * (this.qm - this.qp);
                    if (this.cx(this.b0)) {
                        return;
                    }
                    if (this.g2 == 1) {
                        this.q9(this.qm, this.qb);
                    }
                    else {
                        this.q9(this.qq, this.qb);
                    }
                    if (this.cd != null) {
                        this.cd.oa(this);
                    }
                    break;
                case ValueOverlay.$$p[13]:
                    let e = typeCast(NumericAxisBase.$, this.p8);
                    if (e != null) {
                        e.c0();
                    }
                    this.ml(true);
                    this.lt();
                    break;
                case ValueOverlay.$$p[12]:
                case ValueOverlay.$$p[10]:
                case ValueOverlay.$$p[1]:
                case ValueOverlay.$$p[0]:
                case ValueOverlay.$$p[3]:
                case ValueOverlay.$$p[4]:
                case ValueOverlay.$$p[9]:
                case ValueOverlay.$$p[5]:
                case ValueOverlay.$$p[6]:
                case ValueOverlay.$$p[7]:
                case ValueOverlay.$$p[8]:
                    this.ml(true);
                    break;
            }
        }
        li() {
            super.li();
            if (this.p8 != null) {
                this.p8.h7(false);
            }
        }
        k0(a, b) {
            super.k0(a, b);
            let c = b;
            c.bx();
        }
        qd() {
            if (this.p8 == null || this.p8.bh == null || isNaN_(this.qr) || this._visibility != 0) {
                return false;
            }
            let a = typeCast(CategoryAxisBase.$, this.p8);
            if (a != null && a.lf == 0) {
                return false;
            }
            return true;
        }
        preferredCategoryMode(a) {
            return 0;
        }
        get categoryAxis() {
            return typeCast(CategoryAxisBase.$, this.p8);
        }
        bx() {
            return new ValueOverlayView(this);
        }
        l2(a) {
            super.l2(a);
            this.qb = typeCast(ValueOverlayView.$, a);
        }
        mn(a, b) {
            super.mn(a, b);
            if (!this.e1) {
                this.b0.a2(b);
                return;
            }
            this.b0.a2(b);
            if (this.cx(this.bz) || !this.qd()) {
                return;
            }
            let c = this.getEffectiveViewport1(this.b0);
            let d = this.p8.ei(this.qr, new ScalerParams(0, this.bz.bv, a, this.p8.cg, c));
            this.q9(d, typeCast(ValueOverlayView.$, this.bz));
            this.e1 = false;
        }
        getOffsetValue() {
            return 0;
        }
        getCategoryWidth() {
            return 0;
        }
        get rs() {
            return new Thickness(1, this.qi, this.qk, this.qj, this.qh);
        }
        ag() {
            return [this.p8];
        }
        ra(a, b) {
            if (isNaN_(a)) {
                if (this.p9 != null) {
                    AxisAnnotationFrameManager.b(this.p9);
                    AxisAnnotationFrameManager.d(this, this.p9, true, this.qe, this.qf, b, this.qs, this.qs, this.qa, this.qa);
                }
                return;
            }
            let c = false;
            if (this.qe == null) {
                c = true;
                this.qf = new List$1(Axis.$, 0);
                this.qe = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
            }
            this.p9 = new AxisAnnotationFrame();
            let d = this.o3;
            if (d == null) {
                d = this.o7;
            }
            let e = this.p8.co;
            AxisAnnotationFrameManager.c(this.p9, { $type: Point_$type, x: a, y: a }, this, this.cd, this.getEffectiveViewport(), d, this.rp, this.qg, this.rr, this.rq, this.rs, this.ql, this.rp, this.qg, this.rr, this.rq, this.rs, this.ql, !e && this.qc, e && this.qc);
            AxisAnnotationFrameManager.d(this, this.p9, c, this.qe, this.qf, b, this.qs, this.qs, this.qa, this.qa);
        }
        get_isValueOverlay() {
            return true;
        }
        q5(a) {
            if (this.p8 != null) {
                return this.p8.gc(a);
            }
            return null;
        }
        get q7() {
            let a = this.q5(this.qr);
            return a != null ? a : stringFormat("{0:0.##}", this.qr);
        }
    }
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:qg:rb', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:rp:rc', [Brush.$, null], 'AxisAnnotationFormatLabel:qa:rd', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:qs:re', [1, -1], 'AxisAnnotationOutline:rq:rf', [Brush.$, null], 'AxisAnnotationPaddingBottom:qh:rg', [1, NaN], 'AxisAnnotationPaddingLeft:qi:rh', [1, NaN], 'AxisAnnotationPaddingRight:qj:ri', [1, NaN], 'AxisAnnotationPaddingTop:qk:rj', [1, NaN], 'AxisAnnotationStrokeThickness:ql:rk', [1, NaN], 'AxisAnnotationTextColor:rr:rl', [Brush.$, null], 'Axis:p8:rm', [Axis.$, null], 'IsAxisAnnotationEnabled:qc:rn', [0, false], 'Value:qr:ro', [1, 0]]);
    return ValueOverlay;
})();
/**
 * @hidden
 */
export let ValueOverlayView = /*@__PURE__*/ (() => {
    class ValueOverlayView extends SeriesView {
        constructor(a) {
            super(a);
            this.bz = null;
            this.bz = new Path();
        }
        bb() {
            super.bb();
            this.bz._stroke = this.e.o3;
            this.bz.ac = this.e.fw;
            this.bz.ai = this.e.pg;
            this.bz.ad = this.e.ph;
        }
        bc() {
            super.bc();
            let a = this.bo();
            this.bz._stroke = a;
            this.bz.ac = this.e.fw + 3;
            this.bz._stroke = a;
            this.bz.ac = this.e.fw + 3;
        }
        by(a) {
            this.bz.ak = a;
            this.aq();
        }
        bx() {
            this.bz.ak = null;
            this.aq();
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                a.t(this.bz);
            }
        }
        al(a) {
            super.al(a);
            this.e.a8.exportPathData(a, this.bz, "ValueOverlayPath", []);
        }
    }
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
})();
