/*
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.qt = 0;
            this.qu = 0;
            this.qq = 0;
            this.qd = null;
            this.qj = null;
            this.qi = null;
            this.ab = ValueOverlay.$;
        }
        gn(a, b, c) {
            return this.qv;
        }
        qr(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;
        }
        ps(a, b, c) {
            if (this.qc == null) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let d = this.qs();
            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.qc.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.b1.bu.top + this.b1.bu.height * (f - this.b1.bv.top) / this.b1.bv.height;
                    e = this.b1.bu.left + this.b1.bu.width * (e - this.b1.bv.left) / this.b1.bv.width;
                    break;
                case 0:
                    e = d;
                    f = a.y;
                    f = this.b1.bu.top + this.b1.bu.height * (f - this.b1.bv.top) / this.b1.bv.height;
                    break;
                case 1:
                    f = d;
                    e = a.x;
                    e = this.b1.bu.left + this.b1.bu.width * (e - this.b1.bv.left) / this.b1.bv.width;
                    break;
                case 3:
                    g = this.qr(a, h);
                    i = d;
                    e = h.x + Math.cos(g) * i;
                    f = h.y + Math.sin(g) * i;
                    f = this.b1.bu.top + this.b1.bu.height * (f - this.b1.bv.top) / this.b1.bv.height;
                    e = this.b1.bu.left + this.b1.bu.width * (e - this.b1.bv.left) / this.b1.bv.width;
                    break;
            }
            return { $type: Point_$type, x: e, y: f };
        }
        hi(a) {
            throw new NotImplementedException(0);
        }
        hy(a) {
            return this;
        }
        eq(a) {
            return false;
        }
        aq(a) {
            let b = typeCast(NumericAxisBase.$, a);
            let c = this.qv;
            if (isNaN_(c) || isInfinity(c)) {
                return null;
            }
            return new AxisRange(c, c);
        }
        mo(a) {
            this.k2(true, this.b1);
            if (!this.qh()) {
                if (this.qd != null) {
                    this.re(NaN, this.cw());
                }
                return;
            }
            if (this.er(a)) {
                if (this.cw()) {
                    if (this.cf.g) {
                        this.cf.t();
                    }
                    let b = this.qt;
                    this.qt = this.qu;
                    this.qu = b;
                }
                else {
                    this.qt = this.qq;
                }
                this.qq = this.qs();
                this.mw();
            }
            else {
                this.qq = this.qs();
                this.rd(this.qq, this.qf);
            }
        }
        qs() {
            let a, b;
            let c = this.getViewInfo(b, a);
            b = c.p0;
            a = c.p1;
            let d = this.getEffectiveViewport1(this.b1);
            let e = new ScalerParams(0, a, b, this.qc.cg, d);
            return this.qc.ei(this.qv, e);
        }
        rd(a, b) {
            if (this.qc == null) {
                return;
            }
            let c = typeCast(CategoryAxisBase.$, this.qc);
            if (c != null && !c.cd) {
                if (this.qv > 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.qc);
            if (g != null) {
                if (this.qv < g.lw || this.qv > g.lv) {
                    return;
                }
                if (g.li && this.qv < 0) {
                    return;
                }
            }
            let h;
            switch (this.qc.a1) {
                case 2:
                case 3:
                    h = this.qc.j4(a, b.bv, b.bu, this.getEffectiveViewport1(b), this.pz(b));
                    break;
                default:
                    h = this.qc.j4(a, b.bv, b.bu);
                    break;
            }
            if (h != null) {
                b.by(h);
            }
            if (!b.q) {
                this.re(a, this.cw());
            }
        }
        fd(a, b, c) {
            let d = true;
            d = super.fd(a, b, c);
            if (!c.o() || b.isEmpty || a.isEmpty || this.qc == null || this.qc.bh == null) {
                d = false;
            }
            return d;
        }
        nb(a, b) {
            this.mn(false);
        }
        na(a, b) {
            this.mn(false);
        }
        k5(a, b, c, d) {
            throw new NotImplementedException(0);
        }
        l9(a, b, c, d) {
            super.l9(a, b, c, d);
            switch (b) {
                case ValueOverlay.$$p[11]:
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    this.mn(false);
                    this.lu();
                    break;
                case "TransitionProgress":
                    this.qu = this.qt + this.g5 * (this.qq - this.qt);
                    if (this.cy(this.b1)) {
                        return;
                    }
                    if (this.g5 == 1) {
                        this.rd(this.qq, this.qf);
                    }
                    else {
                        this.rd(this.qu, this.qf);
                    }
                    if (this.ce != null) {
                        this.ce.ob(this);
                    }
                    break;
                case ValueOverlay.$$p[13]:
                    let e = typeCast(NumericAxisBase.$, this.qc);
                    if (e != null) {
                        e.c0();
                    }
                    this.mn(true);
                    this.lv();
                    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.mn(true);
                    break;
            }
        }
        lk() {
            super.lk();
            if (this.qc != null) {
                this.qc.h7(false);
            }
        }
        k2(a, b) {
            super.k2(a, b);
            let c = b;
            c.bx();
        }
        qh() {
            if (this.qc == null || this.qc.bh == null || isNaN_(this.qv) || this._visibility != 0) {
                return false;
            }
            let a = typeCast(CategoryAxisBase.$, this.qc);
            if (a != null && a.lf == 0) {
                return false;
            }
            return true;
        }
        preferredCategoryMode(a) {
            return 0;
        }
        get categoryAxis() {
            return typeCast(CategoryAxisBase.$, this.qc);
        }
        by() {
            return new ValueOverlayView(this);
        }
        l4(a) {
            super.l4(a);
            this.qf = typeCast(ValueOverlayView.$, a);
        }
        mp(a, b) {
            super.mp(a, b);
            if (!this.e3) {
                this.b1.a2(b);
                return;
            }
            this.b1.a2(b);
            if (this.cy(this.b0) || !this.qh()) {
                return;
            }
            let c = this.getEffectiveViewport1(this.b1);
            let d = this.qc.ei(this.qv, new ScalerParams(0, this.b0.bv, a, this.qc.cg, c));
            this.rd(d, typeCast(ValueOverlayView.$, this.b0));
            this.e3 = false;
        }
        getOffsetValue() {
            return 0;
        }
        getCategoryWidth() {
            return 0;
        }
        get rw() {
            return new Thickness(1, this.qm, this.qo, this.qn, this.ql);
        }
        ag() {
            return [this.qc];
        }
        re(a, b) {
            if (isNaN_(a)) {
                if (this.qd != null) {
                    AxisAnnotationFrameManager.b(this.qd);
                    AxisAnnotationFrameManager.d(this, this.qd, true, this.qi, this.qj, b, this.qw, this.qw, this.qe, this.qe);
                }
                return;
            }
            let c = false;
            if (this.qi == null) {
                c = true;
                this.qj = new List$1(Axis.$, 0);
                this.qi = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
            }
            this.qd = new AxisAnnotationFrame();
            let d = this.o5;
            if (d == null) {
                d = this.o9;
            }
            let e = this.qc.co;
            AxisAnnotationFrameManager.c(this.qd, { $type: Point_$type, x: a, y: a }, this, this.ce, this.getEffectiveViewport(), d, this.rt, this.qk, this.rv, this.ru, this.rw, this.qp, this.rt, this.qk, this.rv, this.ru, this.rw, this.qp, !e && this.qg, e && this.qg);
            AxisAnnotationFrameManager.d(this, this.qd, c, this.qi, this.qj, b, this.qw, this.qw, this.qe, this.qe);
        }
        get_isValueOverlay() {
            return true;
        }
        q9(a) {
            if (this.qc != null) {
                return this.qc.gc(a);
            }
            return null;
        }
        get rb() {
            let a = this.q9(this.qv);
            return a != null ? a : stringFormat("{0:0.##}", this.qv);
        }
    }
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:qk:rf', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:rt:rg', [Brush.$, null], 'AxisAnnotationFormatLabel:qe:rh', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:qw:ri', [1, -1], 'AxisAnnotationOutline:ru:rj', [Brush.$, null], 'AxisAnnotationPaddingBottom:ql:rk', [1, NaN], 'AxisAnnotationPaddingLeft:qm:rl', [1, NaN], 'AxisAnnotationPaddingRight:qn:rm', [1, NaN], 'AxisAnnotationPaddingTop:qo:rn', [1, NaN], 'AxisAnnotationStrokeThickness:qp:ro', [1, NaN], 'AxisAnnotationTextColor:rv:rp', [Brush.$, null], 'Axis:qc:rq', [Axis.$, null], 'IsAxisAnnotationEnabled:qg:rr', [0, false], 'Value:qv:rs', [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.o5;
            this.bz.ad = this.e.fy;
            this.bz.ai = this.e.pi;
            this.bz.aj = this.e.pj;
        }
        bc() {
            super.bc();
            let a = this.bo();
            this.bz._stroke = a;
            this.bz.ad = this.e.fy + 3;
            this.bz._stroke = a;
            this.bz.ad = this.e.fy + 3;
        }
        by(a) {
            this.bz.an = a;
            this.aq();
        }
        bx() {
            this.bz.an = null;
            this.aq();
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                a.t(this.bz);
            }
        }
        al(a) {
            super.al(a);
            this.e.a9.exportPathData(a, this.bz, "ValueOverlayPath", []);
        }
    }
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
})();
