/*
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 { __extends } 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 { DeviceUtils } 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) {
    __extends(ValueOverlay, _super);
    function ValueOverlay() {
        var _this = _super.call(this) || this;
        _this.uk = 0;
        _this.ul = 0;
        _this.uh = 0;
        _this.t4 = null;
        _this.ua = null;
        _this.t9 = null;
        _this.ab = ValueOverlay.$;
        return _this;
    }
    ValueOverlay.prototype.bc = function () {
        return new ValueOverlay();
    };
    ValueOverlay.prototype.ia = function (a, b, c) {
        return this.um;
    };
    ValueOverlay.prototype.ui = 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.tj = function (a, b, c) {
        if (this.t3 == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.uj();
        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.t3.a2) {
            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.cg.bx.top + this.cg.bx.height * (f - this.cg.by.top) / this.cg.by.height;
                e = this.cg.bx.left + this.cg.bx.width * (e - this.cg.by.left) / this.cg.by.width;
                break;
            case 0:
                e = d;
                f = a.y;
                f = this.cg.bx.top + this.cg.bx.height * (f - this.cg.by.top) / this.cg.by.height;
                break;
            case 1:
                f = d;
                e = a.x;
                e = this.cg.bx.left + this.cg.bx.width * (e - this.cg.by.left) / this.cg.by.width;
                break;
            case 3:
                g = this.ui(a, h);
                i = d;
                e = h.x + Math.cos(g) * i;
                f = h.y + Math.sin(g) * i;
                f = this.cg.bx.top + this.cg.bx.height * (f - this.cg.by.top) / this.cg.by.height;
                e = this.cg.bx.left + this.cg.bx.width * (e - this.cg.by.left) / this.cg.by.width;
                break;
        }
        return { $type: Point_$type, x: e, y: f };
    };
    ValueOverlay.prototype.i9 = function (a) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.js = function (a) {
        return this;
    };
    ValueOverlay.prototype.fp = function (a) {
        return false;
    };
    ValueOverlay.prototype.aq = function (a) {
        var b = typeCast(NumericAxisBase.$, a);
        var c = this.um;
        if (isNaN_(c) || isInfinity(c)) {
            return null;
        }
        return new AxisRange(c, c);
    };
    ValueOverlay.prototype.ps = function (a) {
        this.nk(true, this.cg);
        if (!this.t8()) {
            if (this.t4 != null) {
                this.u5(NaN, this.dk());
            }
            return;
        }
        if (this.fq(a)) {
            if (this.dk()) {
                if (this.cw.g) {
                    this.cw.t();
                }
                var b = this.uk;
                this.uk = this.ul;
                this.ul = b;
            }
            else {
                this.uk = this.uh;
            }
            this.uh = this.uj();
            this.p5();
        }
        else {
            this.uh = this.uj();
            this.u4(this.uh, this.t6);
        }
    };
    ValueOverlay.prototype.uj = function () {
        var a, b;
        var c = this.getViewInfo(b, a);
        b = c.p0;
        a = c.p1;
        var d = this.getEffectiveViewport1(this.cg);
        var e = new ScalerParams(0, a, b, this.t3.ch, d);
        return this.t3.ej(this.um, e);
    };
    ValueOverlay.prototype.u4 = function (a, b) {
        if (this.t3 == null) {
            return;
        }
        var c = typeCast(CategoryAxisBase.$, this.t3);
        if (c != null && !c.ce) {
            if (this.um > c.lg - 1) {
                return;
            }
            if (c.categoryMode != 0) {
                var d = this.getEffectiveViewport1(b);
                var e = 0.5 * c.getCategorySize(b.by, b.bx, d);
                var f = false;
                if (c.cp && !c.ch) {
                    f = true;
                }
                if (typeCast(CategoryXAxis.$, c) !== null && c.ch) {
                    f = true;
                }
                if (f) {
                    e = -e;
                }
                a += e;
            }
        }
        var g = typeCast(NumericAxisBase.$, this.t3);
        if (g != null) {
            if (this.um < g.lx || this.um > g.lw) {
                return;
            }
            if (g.lj && this.um < 0) {
                return;
            }
        }
        var h;
        switch (this.t3.a2) {
            case 2:
            case 3:
                h = this.t3.j5(a, b.by, b.bx, this.getEffectiveViewport1(b), this.tq(b));
                break;
            default:
                h = this.t3.j5(a, b.by, b.bx);
                break;
        }
        if (h != null) {
            b.b1(h);
        }
        if (!b.q) {
            this.u5(a, this.dk());
        }
    };
    ValueOverlay.prototype.gm = function (a, b, c) {
        var d = true;
        d = _super.prototype.gm.call(this, a, b, c);
        if (!c.o() || b.isEmpty || a.isEmpty || this.t3 == null || this.t3.bi == null) {
            d = false;
        }
        return d;
    };
    ValueOverlay.prototype.qp = function (a, b) {
        this.pr(false);
    };
    ValueOverlay.prototype.qo = function (a, b) {
        this.pr(false);
    };
    ValueOverlay.prototype.np = function (a, b, c, d) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.pa = function (a, b, c, d) {
        _super.prototype.pa.call(this, a, b, c, d);
        switch (b) {
            case ValueOverlay.$$p[11]:
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                this.pr(false);
                this.om();
                break;
            case "TransitionProgress":
                this.ul = this.uk + this.iw * (this.uh - this.uk);
                if (this.dm(this.cg)) {
                    return;
                }
                if (this.iw == 1) {
                    this.u4(this.uh, this.t6);
                    this.op();
                }
                else {
                    this.u4(this.ul, this.t6);
                }
                if (this.cv != null) {
                    this.cv.or(this);
                }
                break;
            case ValueOverlay.$$p[13]:
                var e = typeCast(NumericAxisBase.$, this.t3);
                if (e != null) {
                    e.c1();
                }
                this.pr(true);
                this.on();
                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.pr(true);
                break;
        }
    };
    ValueOverlay.prototype.oc = function () {
        _super.prototype.oc.call(this);
        if (this.t3 != null) {
            this.t3.h8(false);
        }
    };
    ValueOverlay.prototype.nk = function (a, b) {
        _super.prototype.nk.call(this, a, b);
        var c = b;
        c.b0();
    };
    ValueOverlay.prototype.t8 = function () {
        if (this.t3 == null || this.t3.bi == null || isNaN_(this.um) || this._visibility != 0) {
            return false;
        }
        var a = typeCast(CategoryAxisBase.$, this.t3);
        if (a != null && a.lg == 0) {
            return false;
        }
        return true;
    };
    ValueOverlay.prototype.preferredCategoryMode = function (a) {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "categoryAxis", {
        get: function () {
            return typeCast(CategoryAxisBase.$, this.t3);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.cd = function () {
        return new ValueOverlayView(this);
    };
    ValueOverlay.prototype.o2 = function (a) {
        _super.prototype.o2.call(this, a);
        this.t6 = typeCast(ValueOverlayView.$, a);
    };
    ValueOverlay.prototype.pt = function (a, b) {
        _super.prototype.pt.call(this, a, b);
        if (!this.f9) {
            this.cg.a4(b);
            return;
        }
        this.cg.a4(b);
        if (this.dm(this.cf) || !this.t8()) {
            return;
        }
        var c = this.getEffectiveViewport1(this.cg);
        var d = this.t3.ej(this.um, new ScalerParams(0, this.cf.by, a, this.t3.ch, c));
        this.u4(d, typeCast(ValueOverlayView.$, this.cf));
        this.f9 = false;
    };
    ValueOverlay.prototype.getOffsetValue = function () {
        return 0;
    };
    ValueOverlay.prototype.getCategoryWidth = function () {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "vn", {
        get: function () {
            return new Thickness(1, this.ud, this.uf, this.ue, this.uc);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.ag = function () {
        return [this.t3];
    };
    ValueOverlay.prototype.u5 = function (a, b) {
        if (isNaN_(a)) {
            if (this.t4 != null) {
                AxisAnnotationFrameManager.b(this.t4);
                AxisAnnotationFrameManager.d(this, this.t4, true, this.t9, this.ua, b, this.un, this.un, this.t5, this.t5);
            }
            return;
        }
        var c = false;
        if (this.t9 == null) {
            c = true;
            this.ua = new List$1(Axis.$, 0);
            this.t9 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        this.t4 = new AxisAnnotationFrame();
        var d = this.su;
        if (d == null) {
            d = this.sy;
        }
        var e = this.t3.cp;
        AxisAnnotationFrameManager.c(this.t4, { $type: Point_$type, x: a, y: a }, this, this.cv, this.getEffectiveViewport(), d, this.vk, this.ub, this.vm, this.vl, this.vn, this.ug, this.vk, this.ub, this.vm, this.vl, this.vn, this.ug, !e && this.t7, e && this.t7);
        AxisAnnotationFrameManager.d(this, this.t4, c, this.t9, this.ua, b, this.un, this.un, this.t5, this.t5);
    };
    ValueOverlay.prototype.get_isValueOverlay = function () {
        return true;
    };
    ValueOverlay.prototype.u0 = function (a) {
        if (this.t3 != null) {
            return this.t3.gd(a);
        }
        return null;
    };
    Object.defineProperty(ValueOverlay.prototype, "u2", {
        get: function () {
            var a = this.u0(this.um);
            return a != null ? a : stringFormat("{0:0.##}", this.um);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:ub:u6', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:vk:u7', [Brush.$, null], 'AxisAnnotationFormatLabel:t5:u8', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:un:u9', [1, -1], 'AxisAnnotationOutline:vl:va', [Brush.$, null], 'AxisAnnotationPaddingBottom:uc:vb', [1, NaN], 'AxisAnnotationPaddingLeft:ud:vc', [1, NaN], 'AxisAnnotationPaddingRight:ue:vd', [1, NaN], 'AxisAnnotationPaddingTop:uf:ve', [1, NaN], 'AxisAnnotationStrokeThickness:ug:vf', [1, NaN], 'AxisAnnotationTextColor:vm:vg', [Brush.$, null], 'Axis:t3:vh', [Axis.$, null], 'IsAxisAnnotationEnabled:t7:vi', [0, false], 'Value:um:vj', [1, 0]]);
    return ValueOverlay;
}(Series));
export { ValueOverlay };
/**
 * @hidden
 */
var ValueOverlayView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ValueOverlayView, _super);
    function ValueOverlayView(a) {
        var _this = _super.call(this, a) || this;
        _this.b2 = null;
        _this.b2 = new Path();
        return _this;
    }
    ValueOverlayView.prototype.bd = function () {
        _super.prototype.bd.call(this);
        this.b2._stroke = this.e.su;
        this.b2.ad = this.e.hl;
        this.b2.ai = this.e.s9;
        this.b2.aj = this.e.ta;
    };
    ValueOverlayView.prototype.be = function () {
        _super.prototype.be.call(this);
        var a = this.br();
        this.b2._stroke = a;
        this.b2.ad = this.e.hl + 3;
        this.b2._stroke = a;
        this.b2.ad = this.e.hl + 3;
    };
    ValueOverlayView.prototype.b1 = function (a) {
        this.b2.an = a;
        this.as();
    };
    ValueOverlayView.prototype.b0 = function () {
        this.b2.an = null;
        this.as();
    };
    ValueOverlayView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        if (a.d) {
            a.t(this.b2);
        }
    };
    ValueOverlayView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
        this.e.a5.exportPathData(a, this.b2, "ValueOverlayPath", []);
    };
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
}(SeriesView));
export { ValueOverlayView };
