/*
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-react-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { Point_$type, typeCast, Delegate_$type, markType, markDep } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { AxisAnnotationFrame } from "./AxisAnnotationFrame";
import { List$1 } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { SeriesView } from "./SeriesView";
import { NotImplementedException } from "igniteui-react-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-react-core";
import { isNaN_, isInfinity } from "igniteui-react-core";
import { stringFormat } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
/**
 * @hidden
 */
var ValueOverlay = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ValueOverlay, _super);
    function ValueOverlay() {
        var _this = _super.call(this) || this;
        _this.mq = 0;
        _this.mr = 0;
        _this.mn = 0;
        _this.mb = null;
        _this.mh = null;
        _this.mg = null;
        _this.ab = ValueOverlay.$;
        return _this;
    }
    ValueOverlay.prototype.en = function (a, b, c) {
        return this.ms;
    };
    ValueOverlay.prototype.mo = 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.lv = function (a, b, c) {
        if (this.ma == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.mp();
        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.ma.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.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.mo(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.ms;
        if (isNaN_(c) || isInfinity(c)) {
            return null;
        }
        return new AxisRange(c, c);
    };
    ValueOverlay.prototype.jm = function (a) {
        this.h3(true, this.bi);
        if (!this.mf()) {
            if (this.mb != null) {
                this.na(NaN, this.ca());
            }
            return;
        }
        if (this.da(a)) {
            if (this.ca()) {
                if (this.bt.g) {
                    this.bt.t();
                }
                var b = this.mq;
                this.mq = this.mr;
                this.mr = b;
            }
            else {
                this.mq = this.mn;
            }
            this.mn = this.mp();
            this.jt();
        }
        else {
            this.mn = this.mp();
            this.m9(this.mn, this.md);
        }
    };
    ValueOverlay.prototype.mp = 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.ma.ca, d);
        return this.ma.dy(this.ms, e);
    };
    ValueOverlay.prototype.m9 = function (a, b) {
        if (this.ma == null) {
            return;
        }
        var c = typeCast(CategoryAxisBase.$, this.ma);
        if (c != null && !c.b7) {
            if (this.ms > c.j8 - 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.ch && !c.ca) {
                    f = true;
                }
                if (typeCast(CategoryXAxis.$, c) !== null && c.ca) {
                    f = true;
                }
                if (f) {
                    e = -e;
                }
                a += e;
            }
        }
        var g = typeCast(NumericAxisBase.$, this.ma);
        if (g != null) {
            if (this.ms < g.kc || this.ms > g.kb) {
                return;
            }
            if (g.j2 && this.ms < 0) {
                return;
            }
        }
        var h;
        switch (this.ma.a1) {
            case 2:
            case 3:
                h = this.ma.i1(a, b.bs, b.br, this.getEffectiveViewport1(b), this.l0(b));
                break;
            default:
                h = this.ma.i1(a, b.bs, b.br);
                break;
        }
        if (h != null) {
            b.bv(h);
        }
        this.na(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.ma == null || this.ma.bh == null) {
            d = false;
        }
        return d;
    };
    ValueOverlay.prototype.j1 = function (a, b) {
        this.jl(false);
    };
    ValueOverlay.prototype.j0 = function (a, b) {
        this.jl(false);
    };
    ValueOverlay.prototype.h6 = function (a, b, c, d) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.i7 = function (a, b, c, d) {
        _super.prototype.i7.call(this, a, b, c, d);
        switch (b) {
            case ValueOverlay.$$p[10]:
                if (c != null) {
                    c.bx(this);
                }
                if (d != null) {
                    d.ck(this);
                }
                this.jl(false);
                this.it();
                break;
            case "TransitionProgress":
                this.mr = this.mq + this.ez * (this.mn - this.mq);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ez == 1) {
                    this.m9(this.mn, this.md);
                }
                else {
                    this.m9(this.mr, this.md);
                }
                if (this.bs != null) {
                    this.bs.ko(this);
                }
                break;
            case ValueOverlay.$$p[12]:
                var e = typeCast(NumericAxisBase.$, this.ma);
                if (e != null) {
                    e.cn();
                }
                this.jl(true);
                this.iu();
                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.jl(true);
                break;
        }
    };
    ValueOverlay.prototype.ik = function () {
        _super.prototype.ik.call(this);
        if (this.ma != null) {
            this.ma.hb(false);
        }
    };
    ValueOverlay.prototype.h3 = function (a, b) {
        _super.prototype.h3.call(this, a, b);
        var c = b;
        c.bu();
    };
    ValueOverlay.prototype.mf = function () {
        if (this.ma == null || this.ma.bh == null || isNaN_(this.ms) || this._visibility == 1) {
            return false;
        }
        var a = typeCast(CategoryAxisBase.$, this.ma);
        if (a != null && a.j8 == 0) {
            return false;
        }
        return true;
    };
    ValueOverlay.prototype.preferredCategoryMode = function (a) {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "categoryAxis", {
        get: function () {
            return typeCast(CategoryAxisBase.$, this.ma);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.prototype.bf = function () {
        return new ValueOverlayView(this);
    };
    ValueOverlay.prototype.i2 = function (a) {
        _super.prototype.i2.call(this, a);
        this.md = typeCast(ValueOverlayView.$, a);
    };
    ValueOverlay.prototype.jn = function (a, b) {
        _super.prototype.jn.call(this, a, b);
        if (!this.dl) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh) || !this.mf()) {
            return;
        }
        var c = this.getEffectiveViewport1(this.bi);
        var d = this.ma.dy(this.ms, new ScalerParams(0, this.bh.bs, a, this.ma.ca, c));
        this.m9(d, typeCast(ValueOverlayView.$, this.bh));
        this.dl = false;
    };
    ValueOverlay.prototype.getOffsetValue = function () {
        return 0;
    };
    ValueOverlay.prototype.getCategoryWidth = function () {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "nr", {
        get: function () {
            return new Thickness(1, this.mj, this.ml, this.mk, this.mi);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.prototype.ag = function () {
        return [this.ma];
    };
    ValueOverlay.prototype.na = function (a, b) {
        if (isNaN_(a)) {
            if (this.mb != null) {
                AxisAnnotationFrameManager.b(this.mb);
                AxisAnnotationFrameManager.d(this, this.mb, true, this.mg, this.mh, b, this.mt, this.mt, this.mc, this.mc);
            }
            return;
        }
        var c = false;
        if (this.mg == null) {
            c = true;
            this.mh = new List$1(Axis.$, 0);
            this.mg = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        this.mb = new AxisAnnotationFrame();
        var d = this.lb;
        if (d == null) {
            d = this.ld;
        }
        var e = this.ma.ch;
        AxisAnnotationFrameManager.c(this.mb, { $type: Point_$type, x: a, y: a }, this, this.bs, this.getEffectiveViewport(), d, this.no, this.nq, this.np, this.nr, this.mm, this.no, this.nq, this.np, this.nr, this.mm, !e && this.me, e && this.me);
        AxisAnnotationFrameManager.d(this, this.mb, c, this.mg, this.mh, b, this.mt, this.mt, this.mc, this.mc);
    };
    ValueOverlay.prototype.get_c6 = function () {
        return true;
    };
    ValueOverlay.prototype.m5 = function (a) {
        if (this.ma != null) {
            return this.ma.fl(a);
        }
        return null;
    };
    Object.defineProperty(ValueOverlay.prototype, "m7", {
        get: function () {
            var a = this.m5(this.ms);
            return a != null ? a : stringFormat("{0:0.##}", this.ms);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackground:no:nb', [Brush.$, null], 'AxisAnnotationFormatLabel:mc:nc', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:mt:nd', [1, -1], 'AxisAnnotationOutline:np:ne', [Brush.$, null], 'AxisAnnotationPaddingBottom:mi:nf', [1, NaN], 'AxisAnnotationPaddingLeft:mj:ng', [1, NaN], 'AxisAnnotationPaddingRight:mk:nh', [1, NaN], 'AxisAnnotationPaddingTop:ml:ni', [1, NaN], 'AxisAnnotationStrokeThickness:mm:nj', [1, NaN], 'AxisAnnotationTextColor:nq:nk', [Brush.$, null], 'Axis:ma:nl', [Axis.$, null], 'IsAxisAnnotationEnabled:me:nm', [0, false], 'Value:ms:nn', [1, 0]]);
    return ValueOverlay;
}(Series));
export { ValueOverlay };
/**
 * @hidden
 */
var ValueOverlayView = /** @class */ /*@__PURE__*/ (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.lb;
        this.bw.ac = this.e.ey;
        this.bw.ai = this.e.ll;
        this.bw.ad = this.e.lm;
    };
    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
