/*
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 { 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 { AxisAnnotationFrame } from "./AxisAnnotationFrame";
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.w7 = 0;
        _this.w8 = 0;
        _this.w4 = 0;
        _this.wr = null;
        _this.wx = null;
        _this.ww = null;
        _this.ab = ValueOverlay.$;
        return _this;
    }
    ValueOverlay.prototype.bi = function () {
        return new ValueOverlay();
    };
    ValueOverlay.prototype.i3 = function (a, b, c) {
        return this.w9;
    };
    ValueOverlay.prototype.w5 = 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.v6 = function (a, b, c) {
        if (this.wq == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.w6();
        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.wq.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.ct.bx.top + this.ct.bx.height * (f - this.ct.by.top) / this.ct.by.height;
                e = this.ct.bx.left + this.ct.bx.width * (e - this.ct.by.left) / this.ct.by.width;
                break;
            case 0:
                e = d;
                f = a.y;
                f = this.ct.bx.top + this.ct.bx.height * (f - this.ct.by.top) / this.ct.by.height;
                break;
            case 1:
                f = d;
                e = a.x;
                e = this.ct.bx.left + this.ct.bx.width * (e - this.ct.by.left) / this.ct.by.width;
                break;
            case 3:
                g = this.w5(a, h);
                i = d;
                e = h.x + Math.cos(g) * i;
                f = h.y + Math.sin(g) * i;
                f = this.ct.bx.top + this.ct.bx.height * (f - this.ct.by.top) / this.ct.by.height;
                e = this.ct.bx.left + this.ct.bx.width * (e - this.ct.by.left) / this.ct.by.width;
                break;
        }
        return { $type: Point_$type, x: e, y: f };
    };
    ValueOverlay.prototype.j1 = function (a) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.kl = function (a) {
        return this;
    };
    ValueOverlay.prototype.gb = function (a) {
        return false;
    };
    ValueOverlay.prototype.ax = function (a) {
        var b = typeCast(NumericAxisBase.$, a);
        var c = this.w9;
        if (isNaN_(c) || isInfinity(c)) {
            return null;
        }
        return new AxisRange(c, c);
    };
    ValueOverlay.prototype.ro = function (a) {
        this.o3(true, this.ct);
        if (!this.wv()) {
            if (this.wr != null) {
                this.xs(NaN, this.d1());
            }
            return;
        }
        if (this.gd(a)) {
            if (this.d1()) {
                if (this.da.g) {
                    this.da.t();
                }
                var b = this.w7;
                this.w7 = this.w8;
                this.w8 = b;
            }
            else {
                this.w7 = this.w4;
            }
            this.w4 = this.w6();
            this.r1();
        }
        else {
            this.w4 = this.w6();
            this.xr(this.w4, this.wt);
        }
    };
    ValueOverlay.prototype.w6 = function () {
        var a, b;
        var c = this.getViewInfo(b, a);
        b = c.p0;
        a = c.p1;
        var d = this.getEffectiveViewport1(this.ct);
        var e = new ScalerParams(0, a, b, this.wq.ch, d);
        return this.wq.ek(this.w9, e);
    };
    ValueOverlay.prototype.xr = function (a, b) {
        if (this.wq == null) {
            return;
        }
        var c = typeCast(CategoryAxisBase.$, this.wq);
        if (c != null && !c.ce) {
            if (this.w9 > c.lh - 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.wq);
        if (g != null) {
            if (this.w9 < g.ly || this.w9 > g.lx) {
                return;
            }
            if (g.lk && this.w9 < 0) {
                return;
            }
        }
        var h;
        switch (this.wq.a2) {
            case 2:
            case 3:
                h = this.wq.j6(a, b.by, b.bx, this.getEffectiveViewport1(b), this.wd(b));
                break;
            default:
                h = this.wq.j6(a, b.by, b.bx, this.getEffectiveViewport1(b), this.wd(b));
                break;
        }
        if (h != null) {
            b.b1(h);
        }
        if (!b.q) {
            this.xs(a, this.d1());
        }
    };
    ValueOverlay.prototype.hc = function (a, b, c) {
        var d = true;
        d = _super.prototype.hc.call(this, a, b, c);
        if (!c.o() || b.isEmpty || a.isEmpty || this.wq == null || this.wq.bi == null) {
            d = false;
        }
        return d;
    };
    ValueOverlay.prototype.sl = function (a, b) {
        this.rn(false);
    };
    ValueOverlay.prototype.sk = function (a, b) {
        this.rn(false);
    };
    ValueOverlay.prototype.o9 = function (a, b, c, d) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.q5 = function (a, b, c, d) {
        _super.prototype.q5.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.rn(false);
                this.qh();
                break;
            case "TransitionProgress":
                this.w8 = this.w7 + this.jo * (this.w4 - this.w7);
                if (this.d3(this.ct)) {
                    return;
                }
                if (this.jo == 1) {
                    this.xr(this.w4, this.wt);
                    this.qk();
                }
                else {
                    this.xr(this.w8, this.wt);
                }
                if (this.c9 != null) {
                    this.c9.qa(this);
                }
                break;
            case ValueOverlay.$$p[13]:
                var e = typeCast(NumericAxisBase.$, this.wq);
                if (e != null) {
                    e.c1();
                }
                this.rn(true);
                this.qi();
                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.rn(true);
                break;
        }
    };
    ValueOverlay.prototype.p6 = function () {
        _super.prototype.p6.call(this);
        if (this.wq != null) {
            this.wq.h9(false);
        }
    };
    ValueOverlay.prototype.o3 = function (a, b) {
        _super.prototype.o3.call(this, a, b);
        var c = b;
        c.b0();
    };
    ValueOverlay.prototype.wv = function () {
        if (this.wq == null || this.wq.bi == null || isNaN_(this.w9) || this._visibility != 0) {
            return false;
        }
        var a = typeCast(CategoryAxisBase.$, this.wq);
        if (a != null && a.lh == 0) {
            return false;
        }
        return true;
    };
    ValueOverlay.prototype.preferredCategoryMode = function (a) {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "categoryAxis", {
        get: function () {
            return typeCast(CategoryAxisBase.$, this.wq);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.cq = function () {
        return new ValueOverlayView(this);
    };
    ValueOverlay.prototype.qx = function (a) {
        _super.prototype.qx.call(this, a);
        this.wt = typeCast(ValueOverlayView.$, a);
    };
    ValueOverlay.prototype.rp = function (a, b) {
        _super.prototype.rp.call(this, a, b);
        if (!this.gy) {
            this.ct.a4(b);
            return;
        }
        this.ct.a4(b);
        if (this.d3(this.cs) || !this.wv()) {
            return;
        }
        var c = this.getEffectiveViewport1(this.ct);
        var d = this.wq.ek(this.w9, new ScalerParams(0, this.cs.by, a, this.wq.ch, c));
        this.xr(d, typeCast(ValueOverlayView.$, this.cs));
        this.gy = false;
    };
    ValueOverlay.prototype.getOffsetValue = function () {
        return 0;
    };
    ValueOverlay.prototype.getCategoryWidth = function () {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "ya", {
        get: function () {
            return new Thickness(1, this.w0, this.w2, this.w1, this.wz);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.ai = function () {
        return [this.wq];
    };
    ValueOverlay.prototype.xs = function (a, b) {
        if (isNaN_(a)) {
            if (this.wr != null) {
                AxisAnnotationFrameManager.b(this.wr);
                AxisAnnotationFrameManager.d(this, this.wr, true, this.ww, this.wx, b, this.xa, this.xa, this.ws, this.ws);
            }
            return;
        }
        var c = false;
        if (this.ww == null) {
            c = true;
            this.wx = new List$1(Axis.$, 0);
            this.ww = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        this.wr = new AxisAnnotationFrame();
        var d = this.u3;
        if (d == null) {
            d = this.u9;
        }
        var e = this.wq.cp;
        AxisAnnotationFrameManager.c(this.wr, { $type: Point_$type, x: a, y: a }, this, this.c9, this.getEffectiveViewport(), d, this.x7, this.wy, this.x9, this.x8, this.ya, this.w3, this.x7, this.wy, this.x9, this.x8, this.ya, this.w3, !e && this.wu, e && this.wu);
        AxisAnnotationFrameManager.d(this, this.wr, c, this.ww, this.wx, b, this.xa, this.xa, this.ws, this.ws);
    };
    ValueOverlay.prototype.get_isValueOverlay = function () {
        return true;
    };
    ValueOverlay.prototype.xn = function (a) {
        if (this.wq != null) {
            return this.wq.ge(a);
        }
        return null;
    };
    Object.defineProperty(ValueOverlay.prototype, "xp", {
        get: function () {
            var a = this.xn(this.w9);
            return a != null ? a : stringFormat("{0:0.##}", this.w9);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:wy:xt', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:x7:xu', [Brush.$, null], 'AxisAnnotationFormatLabel:ws:xv', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:xa:xw', [1, -1], 'AxisAnnotationOutline:x8:xx', [Brush.$, null], 'AxisAnnotationPaddingBottom:wz:xy', [1, NaN], 'AxisAnnotationPaddingLeft:w0:xz', [1, NaN], 'AxisAnnotationPaddingRight:w1:x0', [1, NaN], 'AxisAnnotationPaddingTop:w2:x1', [1, NaN], 'AxisAnnotationStrokeThickness:w3:x2', [1, NaN], 'AxisAnnotationTextColor:x9:x3', [Brush.$, null], 'Axis:wq:x4', [Axis.$, null], 'IsAxisAnnotationEnabled:wu:x5', [0, false], 'Value:w9:x6', [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.u3;
        this.b2.ad = this.e.ic;
        this.b2.ai = this.e.vw;
        this.b2.aj = this.e.vx;
    };
    ValueOverlayView.prototype.be = function () {
        _super.prototype.be.call(this);
        var a = this.br();
        this.b2._stroke = a;
        this.b2.ad = this.e.ic + 3;
        this.b2._stroke = a;
        this.b2.ad = this.e.ic + 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.bb.exportPathData(a, this.b2, "ValueOverlayPath", []);
    };
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
}(SeriesView));
export { ValueOverlayView };
