/*
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 * as tslib_1 from "tslib";
import { Series } from "./Series";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { Axis } from "./Axis";
import { DependencyProperty } from "igniteui-angular-core/ES5/DependencyProperty";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { Type, Point_$type, typeCast, Delegate_$type, markType } from "igniteui-angular-core/ES5/type";
import { Brush } from "igniteui-angular-core/ES5/Brush";
import { Thickness } from "igniteui-angular-core/ES5/Thickness";
import { AxisAnnotationFrame } from "./AxisAnnotationFrame";
import { List$1 } from "igniteui-angular-core/ES5/List$1";
import { Dictionary$2 } from "igniteui-angular-core/ES5/Dictionary$2";
import { Pool$1 } from "igniteui-angular-core/ES5/Pool$1";
import { AxisAnnotation } from "./AxisAnnotation";
import { SeriesView } from "./SeriesView";
import { NotImplementedException } from "igniteui-angular-core/ES5/NotImplementedException";
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/ES5/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-angular-core/ES5/number";
import { stringFormat } from "igniteui-angular-core/ES5/stringExtended";
import { Path } from "igniteui-angular-core/ES5/Path";
/**
 * @hidden
 */
var ValueOverlay = /** @class */ (function (_super) {
    tslib_1.__extends(ValueOverlay, _super);
    function ValueOverlay() {
        var _this = _super.call(this) || this;
        _this.mg = 0;
        _this.mh = 0;
        _this.md = 0;
        _this.l1 = null;
        _this.l7 = null;
        _this.l6 = null;
        _this.ab = ValueOverlay.$;
        return _this;
    }
    ValueOverlay.prototype.en = function (a, b, c) {
        return this.mi;
    };
    ValueOverlay.prototype.me = function (a, b) {
        var c = Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
        var d = Math.acos((a.x - b.x) / c);
        if ((a.y - b.y) < 0) {
            d = (2 * Math.PI) - d;
        }
        return d;
    };
    ValueOverlay.prototype.ll = function (a, b, c) {
        if (this.l0 == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.mf();
        var e = NaN;
        var f = NaN;
        var g = NaN;
        var h = { $type: Point_$type, x: 0.5, y: 0.5 };
        var i = NaN;
        switch (this.l0.az) {
            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.bi.br.top + this.bi.br.height * (f - this.bi.bs.top) / this.bi.bs.height;
                e = this.bi.br.left + this.bi.br.width * (e - this.bi.bs.left) / this.bi.bs.width;
                break;
            case 0:
                e = d;
                f = a.y;
                f = this.bi.br.top + this.bi.br.height * (f - this.bi.bs.top) / this.bi.bs.height;
                break;
            case 1:
                f = d;
                e = a.x;
                e = this.bi.br.left + this.bi.br.width * (e - this.bi.bs.left) / this.bi.bs.width;
                break;
            case 3:
                g = this.me(a, h);
                i = d;
                e = h.x + Math.cos(g) * i;
                f = h.y + Math.sin(g) * i;
                f = this.bi.br.top + this.bi.br.height * (f - this.bi.bs.top) / this.bi.bs.height;
                e = this.bi.br.left + this.bi.br.width * (e - this.bi.bs.left) / this.bi.bs.width;
                break;
        }
        return { $type: Point_$type, x: e, y: f };
    };
    ValueOverlay.prototype.e8 = function (a) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.fp = function (a) {
        return this;
    };
    ValueOverlay.prototype.c9 = function (a) {
        return false;
    };
    ValueOverlay.prototype.an = function (a) {
        var b = typeCast(NumericAxisBase.$, a);
        var c = this.mi;
        if (isNaN_(c) || isInfinity(c)) {
            return null;
        }
        return new AxisRange(c, c);
    };
    ValueOverlay.prototype.je = function (a) {
        this.hv(true, this.bi);
        if (!this.l5()) {
            return;
        }
        if (this.da(a)) {
            if (this.ca()) {
                if (this.bt.g) {
                    this.bt.t();
                }
                var b = this.mg;
                this.mg = this.mh;
                this.mh = b;
            }
            else {
                this.mg = this.md;
            }
            this.md = this.mf();
            this.jl();
        }
        else {
            this.md = this.mf();
            this.mz(this.md, this.l3);
        }
    };
    ValueOverlay.prototype.mf = function () {
        var a, b;
        var c = this.getViewInfo(b, a);
        b = c.p0;
        a = c.p1;
        var d = this.getEffectiveViewport1(this.bi);
        var e = new ScalerParams(0, a, b, this.l0.b8, d);
        return this.l0.dw(this.mi, e);
    };
    ValueOverlay.prototype.mz = function (a, b) {
        if (this.l0 == null) {
            return;
        }
        var c = typeCast(CategoryAxisBase.$, this.l0);
        if (c != null && !c.b5) {
            if (this.mi > c.jz - 1) {
                return;
            }
            if (c.categoryMode == 2) {
                var d = this.getEffectiveViewport1(b);
                var e = 0.5 * c.getCategorySize(b.bs, b.br, d);
                var f = false;
                if (c.cf && !c.b8) {
                    f = true;
                }
                if (typeCast(CategoryXAxis.$, c) !== null && c.b8) {
                    f = true;
                }
                if (f) {
                    e = -e;
                }
                a += e;
            }
        }
        var g = typeCast(NumericAxisBase.$, this.l0);
        if (g != null) {
            if (this.mi < g.j4 || this.mi > g.j3) {
                return;
            }
            if (g.ju && this.mi < 0) {
                return;
            }
        }
        var h;
        switch (this.l0.az) {
            case 2:
            case 3:
                h = this.l0.it(a, b.bs, b.br, this.getEffectiveViewport1(b), this.lq(b));
                break;
            default:
                h = this.l0.it(a, b.bs, b.br);
                break;
        }
        if (h != null) {
            b.bv(h);
        }
        if (this.l4) {
            this.m0(a, this.ca());
        }
    };
    ValueOverlay.prototype.dw = function (a, b, c) {
        var d = true;
        d = _super.prototype.dw.call(this, a, b, c);
        if (!c.l() || b.isEmpty || a.isEmpty || this.l0 == null || this.l0.bf == null) {
            d = false;
        }
        return d;
    };
    ValueOverlay.prototype.jt = function (a, b) {
        this.jd(false);
    };
    ValueOverlay.prototype.js = function (a, b) {
        this.jd(false);
    };
    ValueOverlay.prototype.hy = function (a, b, c, d) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.iz = function (a, b, c, d) {
        _super.prototype.iz.call(this, a, b, c, d);
        switch (b) {
            case ValueOverlay.$$p[10]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ci(this);
                }
                this.jd(false);
                this.ik();
                break;
            case "TransitionProgress":
                this.mh = this.mg + this.ez * (this.md - this.mg);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ez == 1) {
                    this.mz(this.md, this.l3);
                }
                else {
                    this.mz(this.mh, this.l3);
                }
                if (this.bs != null) {
                    this.bs.jj(this);
                }
                break;
            case ValueOverlay.$$p[12]:
                var e = typeCast(NumericAxisBase.$, this.l0);
                if (e != null) {
                    e.cl();
                }
                this.jd(true);
                this.il();
                break;
            case ValueOverlay.$$p[11]:
            case ValueOverlay.$$p[9]:
            case ValueOverlay.$$p[0]:
            case ValueOverlay.$$p[2]:
            case ValueOverlay.$$p[3]:
            case ValueOverlay.$$p[8]:
            case ValueOverlay.$$p[4]:
            case ValueOverlay.$$p[5]:
            case ValueOverlay.$$p[6]:
            case ValueOverlay.$$p[7]:
                this.jd(true);
                break;
        }
    };
    ValueOverlay.prototype.ib = function () {
        _super.prototype.ib.call(this);
        if (this.l0 != null) {
            this.l0.g6(false);
        }
    };
    ValueOverlay.prototype.hv = function (a, b) {
        _super.prototype.hv.call(this, a, b);
        var c = b;
        c.bu();
    };
    ValueOverlay.prototype.l5 = function () {
        if (this.l0 == null || this.l0.bf == null || isNaN_(this.mi) || this._visibility == 1) {
            return false;
        }
        var a = typeCast(CategoryAxisBase.$, this.l0);
        if (a != null && a.jz == 0) {
            return false;
        }
        return true;
    };
    ValueOverlay.prototype.preferredCategoryMode = function (a) {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "categoryAxis", {
        get: function () {
            return typeCast(CategoryAxisBase.$, this.l0);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.prototype.bf = function () {
        return new ValueOverlayView(this);
    };
    ValueOverlay.prototype.iu = function (a) {
        _super.prototype.iu.call(this, a);
        this.l3 = typeCast(ValueOverlayView.$, a);
    };
    ValueOverlay.prototype.jf = function (a, b) {
        _super.prototype.jf.call(this, a, b);
        if (!this.dl) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh) || !this.l5()) {
            return;
        }
        var c = this.getEffectiveViewport1(this.bi);
        var d = this.l0.dw(this.mi, new ScalerParams(0, this.bh.bs, a, this.l0.b8, c));
        this.mz(d, typeCast(ValueOverlayView.$, this.bh));
        this.dl = false;
    };
    ValueOverlay.prototype.getOffsetValue = function () {
        return 0;
    };
    ValueOverlay.prototype.getCategoryWidth = function () {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "nh", {
        get: function () {
            return new Thickness(1, this.l9, this.mb, this.ma, this.l8);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.prototype.ag = function () {
        return [this.l0];
    };
    ValueOverlay.prototype.m0 = function (a, b) {
        if (isNaN_(a)) {
            return;
        }
        var c = false;
        if (this.l6 == null) {
            c = true;
            this.l7 = new List$1(Axis.$, 0);
            this.l6 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        this.l1 = new AxisAnnotationFrame();
        var d = this.k3;
        if (d == null) {
            d = this.k5;
        }
        var e = this.l0.cf;
        AxisAnnotationFrameManager.c(this.l1, { $type: Point_$type, x: a, y: a }, this, this.bs, this.getEffectiveViewport(), d, this.ne, this.ng, this.nf, this.nh, this.mc, this.ne, this.ng, this.nf, this.nh, this.mc, !this.l0.cf, this.l0.cf);
        AxisAnnotationFrameManager.d(this, this.l1, c, this.l6, this.l7, b, this.mj, this.mj, this.l2, this.l2);
    };
    ValueOverlay.prototype.get_c6 = function () {
        return true;
    };
    ValueOverlay.prototype.mv = function (a) {
        if (this.l0 != null) {
            return this.l0.fj(a);
        }
        return null;
    };
    Object.defineProperty(ValueOverlay.prototype, "mx", {
        get: function () {
            var a = this.mv(this.mi);
            return a != null ? a : stringFormat("{0:0.##}", this.mi);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    return ValueOverlay;
}(Series));
export { ValueOverlay };
Type.dep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackground:ne:m1', [Brush.$, null], 'AxisAnnotationFormatLabel:l2:m2', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:mj:m3', [1, -1], 'AxisAnnotationOutline:nf:m4', [Brush.$, null], 'AxisAnnotationPaddingBottom:l8:m5', [1, NaN], 'AxisAnnotationPaddingLeft:l9:m6', [1, NaN], 'AxisAnnotationPaddingRight:ma:m7', [1, NaN], 'AxisAnnotationPaddingTop:mb:m8', [1, NaN], 'AxisAnnotationStrokeThickness:mc:m9', [1, NaN], 'AxisAnnotationTextColor:ng:na', [Brush.$, null], 'Axis:l0:nb', [Axis.$, null], 'IsAxisAnnotationEnabled:l4:nc', [0, false], 'Value:mi:nd', [1, 0]]);
/**
 * @hidden
 */
var ValueOverlayView = /** @class */ (function (_super) {
    tslib_1.__extends(ValueOverlayView, _super);
    function ValueOverlayView(a) {
        var _this = _super.call(this, a) || this;
        _this.bw = null;
        _this.bw = new Path();
        return _this;
    }
    ValueOverlayView.prototype.a8 = function () {
        _super.prototype.a8.call(this);
        this.bw._stroke = this.e.k3;
        this.bw.ac = this.e.ey;
        this.bw.ai = this.e.lb;
        this.bw.ad = this.e.lc;
    };
    ValueOverlayView.prototype.a9 = function () {
        _super.prototype.a9.call(this);
        var a = this.bl();
        this.bw._stroke = a;
        this.bw.ac = this.e.ey + 3;
        this.bw._stroke = a;
        this.bw.ac = this.e.ey + 3;
    };
    ValueOverlayView.prototype.bv = function (a) {
        this.bw.ak = a;
        this.an();
    };
    ValueOverlayView.prototype.bu = function () {
        this.bw.ak = null;
        this.an();
    };
    ValueOverlayView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            a.s(this.bw);
        }
    };
    ValueOverlayView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        this.e.a2.exportPathData(a, this.bw, "ValueOverlayPath", []);
    };
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
}(SeriesView));
export { ValueOverlayView };
//# sourceMappingURL=ValueOverlay_combined.js.map