/*
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, __values } from "tslib";
import { AnnotationLayer } from "./AnnotationLayer";
import { DependencyProperty } from "igniteui-angular-core";
import { Series } from "./Series";
import { FinalValueSelectionMode_$type } from "./FinalValueSelectionMode";
import { Brush } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { FinalValueLayerFrame } from "./FinalValueLayerFrame";
import { List$1 } from "igniteui-angular-core";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { Base, enumGetBox, fromEnum, Point_$type, markType, markDep } from "igniteui-angular-core";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-angular-core";
/**
 * @hidden
 */
var FinalValueLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinalValueLayer, _super);
    function FinalValueLayer() {
        var _this = _super.call(this) || this;
        _this.axisAnnotationFormatLabel = null;
        _this.z3 = null;
        _this.z2 = null;
        var a = new FinalValueLayerFrame();
        var b = new FinalValueLayerFrame();
        var c = new FinalValueLayerFrame();
        var d = _this.kd / 1000;
        _this.xc = a;
        _this.xb = b;
        _this.xd = c;
        _this.ab = FinalValueLayer.$;
        return _this;
    }
    FinalValueLayer.prototype.bj = function () {
        return new FinalValueLayer();
    };
    FinalValueLayer.prototype.get_eq = function () {
        return true;
    };
    FinalValueLayer.prototype.cs = function () {
        return new FinalValueLayerView(this);
    };
    FinalValueLayer.prototype.q1 = function (a) {
        _super.prototype.q1.call(this, a);
        this.zy = a;
    };
    Object.defineProperty(FinalValueLayer.prototype, "aa8", {
        get: function () {
            return new Thickness(1, this.z6, this.z8, this.z7, this.z5);
        },
        enumerable: false,
        configurable: true
    });
    FinalValueLayer.prototype.z1 = function () {
        return this.axisAnnotationFormatLabel != null;
    };
    FinalValueLayer.prototype.yp = function (a, b) {
        if (this.z0 == null || this.z0 == a) {
            if (!this.a1.c) {
                this.rr(b);
            }
        }
    };
    FinalValueLayer.prototype.yr = function (a, b) {
        var e_1, _a;
        var _this = this;
        _super.prototype.yr.call(this, a, b);
        var c = a;
        c.f.clear();
        c.r.clear();
        c.q.clear();
        c.ac.clear();
        c.p.clear();
        c.ab.clear();
        c.h.clear();
        c.g.clear();
        c.i.clear();
        c.k.clear();
        c.m.clear();
        c.l.clear();
        c.j.clear();
        c.n.clear();
        c.o.clear();
        c.t.clear();
        c.s.clear();
        c.u.clear();
        c.w.clear();
        c.y.clear();
        c.x.clear();
        c.v.clear();
        c.z.clear();
        c.aa.clear();
        if (this.xi(this.z0)) {
            this.aap(this.z0, c);
        }
        else {
            try {
                for (var _b = __values(fromEnum(this.db.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (this.xi(d)) {
                        this.aap(d, c);
                    }
                    if (d.isStacked) {
                        d.p3(function (e) {
                            if (_this.xi(e)) {
                                _this.aap(e, c);
                            }
                            if (e.eg) {
                                e.p1(function (f) {
                                    if (_this.xi(f)) {
                                        _this.aap(f, c);
                                    }
                                    return true;
                                });
                            }
                            return true;
                        });
                    }
                    if (d.eg) {
                        d.p1(function (e) {
                            if (_this.xi(e)) {
                                _this.aap(e, c);
                            }
                            return true;
                        });
                    }
                }
            }
            catch (e_1_1) {
                e_1 = { error: e_1_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_1)
                        throw e_1.error;
                }
            }
        }
    };
    FinalValueLayer.prototype.xi = function (a) {
        if (!_super.prototype.xi.call(this, a)) {
            return false;
        }
        if (this.aam != null) {
            if (a.fb) {
                var b = a.nc();
                if (!Base.equalsStatic(this.aam, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.aam, a.name)) {
                    return false;
                }
            }
        }
        return true;
    };
    FinalValueLayer.prototype.qp = function () {
        _super.prototype.qp.call(this);
        if (!this.a1.c && !this.d3()) {
            return;
        }
        if (this.d3()) {
            this.aaq(this.xd, false);
        }
        else {
            this.aaq(this.xb, false);
        }
    };
    FinalValueLayer.prototype.aa7 = function (a) {
        var b = NaN;
        var c = NaN;
        var d = this.zz;
        if (d == 0) {
            d = 1;
        }
        var e = false;
        if (d == 2) {
            e = true;
        }
        if (a.isVertical) {
            var f = a.a0();
            if (f != null) {
                if (d == 1 || d == 2) {
                    var g = this.wj(this.cv);
                    if (f.ch) {
                        c = a.wh({ $type: Point_$type, x: g.right, y: g.bottom }).y;
                    }
                    else {
                        c = a.wh({ $type: Point_$type, x: g.right, y: g.top }).y;
                    }
                }
                else {
                    if (f.ch) {
                        c = 1;
                    }
                    else {
                        c = 0;
                    }
                }
            }
            return a.wc({ $type: Point_$type, x: 0, y: c }, e, true);
        }
        else {
            var h = a.a0();
            if (h != null) {
                if (d == 1 || d == 2) {
                    var i = this.wj(this.cv);
                    if (h.ch) {
                        b = a.wh({ $type: Point_$type, x: i.left, y: i.top }).x;
                    }
                    else {
                        b = a.wh({ $type: Point_$type, x: i.right, y: i.top }).x;
                    }
                }
                else {
                    if (h.ch) {
                        b = 0;
                    }
                    else {
                        b = 1;
                    }
                }
            }
            if (a.e6) {
                return a.wc({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
            else {
                return a.wc({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
        }
    };
    FinalValueLayer.prototype.aap = function (a, b) {
        var c = this.aa7(a);
        var d = this.wh(c);
        var e = this.u9;
        if (e == null) {
            e = this.vf;
        }
        if (e == null) {
            e = a.u9;
            if (e != null) {
                e = this.zy.b8(e);
            }
        }
        AxisAnnotationFrameManager.c(b, c, a, this.db, this.getEffectiveViewport(), e, this.aa4, this.z4, this.aa6, this.aa5, this.aa8, this.z9, this.aa4, this.z4, this.aa6, this.aa5, this.aa8, this.z9, this._visibility == 0 && a.isVertical, this._visibility == 0 && !a.isVertical);
    };
    FinalValueLayer.prototype.aaq = function (a, b) {
        var c = false;
        if (this.z2 == null) {
            c = true;
            this.z3 = new List$1(Axis.$, 0);
            this.z2 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.z2, this.z3, b, this.aaa, this.aaa, this.axisAnnotationFormatLabel, this.axisAnnotationFormatLabel);
    };
    FinalValueLayer.prototype.yu = function (a, b) {
        _super.prototype.yu.call(this, a, b);
        if (this.d3()) {
            this.aaq(this.xd, true);
        }
        else {
            this.aaq(this.xb, false);
        }
    };
    FinalValueLayer.prototype.ga = function () {
        return true;
    };
    FinalValueLayer.prototype.q9 = function (a, b, c, d) {
        var e_2, _a;
        _super.prototype.q9.call(this, a, b, c, d);
        switch (b) {
            case FinalValueLayer.$$p[11]:
            case FinalValueLayer.$$p[12]:
                this.rr(true);
                break;
            case FinalValueLayer.$$p[1]:
            case FinalValueLayer.$$p[0]:
            case FinalValueLayer.$$p[3]:
            case FinalValueLayer.$$p[5]:
            case FinalValueLayer.$$p[7]:
            case FinalValueLayer.$$p[6]:
            case FinalValueLayer.$$p[4]:
            case "Visibility":
            case FinalValueLayer.$$p[8]:
            case FinalValueLayer.$$p[9]:
            case FinalValueLayer.$$p[10]:
                this.rr(true);
                break;
            case "SeriesViewer":
                var e = this.z3;
                var f = this.z2;
                if (f != null) {
                    var _loop_1 = function (g) {
                        var h = g.value;
                        h.c(function (i) { return g.key.an.remove(i); });
                        h.clear();
                    };
                    try {
                        for (var _b = __values(fromEnum(f)), _c = _b.next(); !_c.done; _c = _b.next()) {
                            var g = _c.value;
                            _loop_1(g);
                        }
                    }
                    catch (e_2_1) {
                        e_2 = { error: e_2_1 };
                    }
                    finally {
                        try {
                            if (_c && !_c.done && (_a = _b.return))
                                _a.call(_b);
                        }
                        finally {
                            if (e_2)
                                throw e_2.error;
                        }
                    }
                    e.clear();
                    f.clear();
                }
                break;
        }
    };
    FinalValueLayer.prototype.o5 = function (a, b) {
        _super.prototype.o5.call(this, a, b);
        if (a) {
            AxisAnnotationFrameManager.b(this.xb);
            this.aaq(this.xb, false);
        }
    };
    FinalValueLayer.$t = markType(FinalValueLayer, 'FinalValueLayer', AnnotationLayer.$);
    FinalValueLayer.$$p = markDep(DependencyProperty, PropertyMetadata, FinalValueLayer, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:z4:aar', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:aa4:aas', [Brush.$, null], 'AxisAnnotationInterpolatedValuePrecision:aaa:aat', [1, -1], 'AxisAnnotationOutline:aa5:aau', [Brush.$, null], 'AxisAnnotationPaddingBottom:z5:aav', [1, NaN], 'AxisAnnotationPaddingLeft:z6:aaw', [1, NaN], 'AxisAnnotationPaddingRight:z7:aax', [1, NaN], 'AxisAnnotationPaddingTop:z8:aay', [1, NaN], 'AxisAnnotationStrokeThickness:z9:aaz', [1, NaN], 'AxisAnnotationTextColor:aa6:aa0', [Brush.$, null], 'FinalValueSelectionMode:zz:aa1', [FinalValueSelectionMode_$type, enumGetBox(FinalValueSelectionMode_$type, 0)], 'TargetSeriesName:aam:aa2', [2, null], 'TargetSeries:z0:aa3', [Series.$, null]]);
    return FinalValueLayer;
}(AnnotationLayer));
export { FinalValueLayer };
/**
 * @hidden
 */
var FinalValueLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinalValueLayerView, _super);
    function FinalValueLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b7 = null;
        _this.b7 = a;
        return _this;
    }
    FinalValueLayerView.prototype.au = function () {
        _super.prototype.au.call(this);
    };
    FinalValueLayerView.prototype.b8 = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.m(a, 0.1);
    };
    FinalValueLayerView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
    };
    FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
    return FinalValueLayerView;
}(AnnotationLayerView));
export { FinalValueLayerView };
