/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { DependencyProperty } from "igniteui-react-core";
import { CategoryHighlightLayerFrame } from "./CategoryHighlightLayerFrame";
import { Base, Number_$type, typeCast, fromEnum, Point_$type, markType, markDep, runOn } from "igniteui-react-core";
import { XamDataChart } from "./XamDataChart";
import { CategoryHighlightFrameRect } from "./CategoryHighlightFrameRect";
import { List$1 } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, truncate } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
/**
 * @hidden
 */
var CategoryHighlightLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(CategoryHighlightLayer, _super);
    function CategoryHighlightLayer() {
        var _this = _super.call(this) || this;
        var a = new CategoryHighlightLayerFrame();
        var b = new CategoryHighlightLayerFrame();
        var c = new CategoryHighlightLayerFrame();
        var d = _this.gj / 1000;
        _this.ob = a;
        _this.oa = b;
        _this.oc = c;
        _this.ab = CategoryHighlightLayer.$;
        return _this;
    }
    CategoryHighlightLayer.prototype.bp = function () {
        return new CategoryHighlightLayerView(this);
    };
    CategoryHighlightLayer.prototype.kk = function (a) {
        _super.prototype.kk.call(this, a);
        this.pe = a;
    };
    Object.defineProperty(CategoryHighlightLayer.prototype, "ph", {
        get: function () {
            return this.c(CategoryHighlightLayer.po);
        },
        set: function (a) {
            this.h(CategoryHighlightLayer.po, a);
        },
        enumerable: true,
        configurable: true
    });
    CategoryHighlightLayer.prototype.ot = function (a, b) {
        if (this.pd == null || this.pd == a) {
            if (!this.ar.c) {
                this.k3(b);
            }
        }
    };
    CategoryHighlightLayer.prototype.pf = function (a) {
        return a != null && a.cg();
    };
    CategoryHighlightLayer.prototype.ow = function (a, b) {
        var e_1, _a;
        _super.prototype.ow.call(this, a, b);
        var c = a;
        c.g.clear();
        var d = this.pg;
        if (isNaN_(this.pa.x) && isNaN_(this.pa.y)) {
            return;
        }
        if (this.pd != null) {
            if (this.pf(this.pd)) {
                this.pm(this.pd, c, d);
            }
        }
        else {
            if (typeCast(XamDataChart.$, this.b6) !== null) {
                var e = this.b6;
                try {
                    for (var _b = tslib_1.__values(fromEnum(e.axes)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var f = _c.value;
                        if (typeCast(CategoryAxisBase.$, f) !== null && this.pf(f)) {
                            this.pm(f, c, d);
                        }
                    }
                }
                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;
                    }
                }
            }
        }
    };
    CategoryHighlightLayer.prototype.pm = function (a, b, c) {
        if (this.bs == null || this.bs.bv.isEmpty || this.bs.bu.isEmpty) {
            return;
        }
        var d = this.pa.x;
        if (a.ch && isNaN_(d)) {
            d = 0;
        }
        d = this.bs.bu.left + this.bs.bu.width * (d - this.bs.bv.left) / this.bs.bv.width;
        var e = this.pa.y;
        if (!a.ch && isNaN_(e)) {
            e = 0;
        }
        e = this.bs.bu.top + this.bs.bu.height * (e - this.bs.bv.top) / this.bs.bv.height;
        var f = a.k3({ $type: Point_$type, x: d, y: e }, c, this.ph);
        this.pl(f, b, a);
    };
    CategoryHighlightLayer.prototype.pl = function (a, b, c) {
        var d = new CategoryHighlightFrameRect();
        d.b = a.left;
        d.e = a.top;
        d.c = a.right;
        d.a = a.bottom;
        d.g = this.o8();
        d.h = this.o9();
        if (d.g == null) {
            d.g = this.pe.cc(c.is);
        }
        if (d.h == null) {
            d.h = this.pe.cc(c.is);
        }
        d.d = this.eu;
        d.f = Base.getHashCodeStatic(c);
        if (!a.isEmpty) {
            b.g.addItem(d.f, d);
        }
    };
    CategoryHighlightLayer.prototype.oz = function (a, b) {
        var e_2, _a;
        _super.prototype.oz.call(this, a, b);
        var c = this.pe.b5;
        var d = a;
        var e = 0;
        try {
            for (var _b = tslib_1.__values(fromEnum(d.g.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                var g = c.item(e);
                this.pn(f, g);
                e++;
            }
        }
        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;
            }
        }
        c.count = e;
    };
    CategoryHighlightLayer.prototype.dp = function () {
        return true;
    };
    CategoryHighlightLayer.prototype.pn = function (a, b) {
        if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.a) || isNaN_(a.c) || isNaN_(a.d)) {
            b._visibility = 1;
            return;
        }
        this.pe.b7(b, a.b, a.e, a.c - a.b, a.a - a.e);
        b._fill = a.g;
        b._stroke = a.h;
        b.ac = a.d;
        if (this.nj != null) {
            b.ai = this.nj;
        }
        else {
            b.ai = null;
        }
        b.ad = this.nk;
    };
    CategoryHighlightLayer.prototype.kp = function (a, b, c, d) {
        _super.prototype.kp.call(this, a, b, c, d);
        switch (b) {
            case CategoryHighlightLayer.$$p[0]:
                this.k3(true);
                break;
            case CategoryHighlightLayer.$$p[1]:
                this.k3(true);
                break;
        }
    };
    CategoryHighlightLayer.$t = markType(CategoryHighlightLayer, 'CategoryHighlightLayer', AnnotationLayer.$);
    CategoryHighlightLayer.po = DependencyProperty.i("BAndHighlightWidth", Number_$type, CategoryHighlightLayer.$, new PropertyMetadata(2, 10, function (a, b) { return a.raisePropertyChanged("BAndHighlightWidth", b.oldValue, b.newValue); }));
    CategoryHighlightLayer.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryHighlightLayer, 'raisePropertyChanged', ['TargetAxis:pd:pp', [CategoryAxisBase.$, null], 'UseInterpolation:pg:pq', [0, false]]);
    return CategoryHighlightLayer;
}(AnnotationLayer));
export { CategoryHighlightLayer };
/**
 * @hidden
 */
var CategoryHighlightLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(CategoryHighlightLayerView, _super);
    function CategoryHighlightLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b4 = null;
        _this.b5 = null;
        _this.b6 = null;
        _this.b4 = a;
        _this.b6 = new List$1(Rectangle.$, 0);
        return _this;
    }
    CategoryHighlightLayerView.prototype.as = function () {
        var _this = this;
        _super.prototype.as.call(this);
        this.b5 = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.cd);
            $ret.activate = runOn(_this, _this.b8);
            $ret.disactivate = runOn(_this, _this.ca);
            $ret.destroy = runOn(_this, _this.b9);
            return $ret;
        })());
    };
    CategoryHighlightLayerView.prototype.cd = function () {
        var a = new Rectangle();
        a.ab = false;
        this.b6.add(a);
        return a;
    };
    CategoryHighlightLayerView.prototype.b8 = function (a) {
        a._visibility = 0;
    };
    CategoryHighlightLayerView.prototype.ca = function (a) {
        a._visibility = 1;
    };
    CategoryHighlightLayerView.prototype.b9 = function (a) {
        this.b6.remove(a);
    };
    CategoryHighlightLayerView.prototype.cb = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.l(a, 0.1);
    };
    CategoryHighlightLayerView.prototype.cc = function (a) {
        if (a != null) {
            var b = BrushUtil.l(a, 0.3);
            if (b.isGradient) {
                var c = b;
                if (c.gradientStops != null) {
                    for (var d = 0; d < c.gradientStops.length; d++) {
                        var e = c.gradientStops[d];
                        e.color = Color.u(truncate(Math.round((e.color.l) * 0.2)), e.color.o, e.color.n, e.color.m);
                        e.color = e.color;
                    }
                }
            }
            else {
                b.color = Color.u(truncate(Math.round((b.color.l) * 0.2)), b.color.o, b.color.n, b.color.m);
                b.color = b.color;
            }
            return b;
        }
        else {
            return null;
        }
    };
    CategoryHighlightLayerView.prototype.b7 = function (a, b, c, d, e) {
        a._visibility = 0;
        a.n = b;
        a.o = c;
        a.width = d;
        a.height = e;
    };
    CategoryHighlightLayerView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d && !b) {
            for (var c = 0; c < this.b6.count; c++) {
                var d = this.b6._inner[c];
                if (d._visibility == 0) {
                    a.v(d);
                }
            }
        }
    };
    CategoryHighlightLayerView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        for (var b = 0; b < this.b6.count; b++) {
            this.e.a5.exportRectangleData(a, this.b6._inner[b], "cihRect", ["Main", "CategoryItem"]);
        }
    };
    CategoryHighlightLayerView.$t = markType(CategoryHighlightLayerView, 'CategoryHighlightLayerView', AnnotationLayerView.$);
    return CategoryHighlightLayerView;
}(AnnotationLayerView));
export { CategoryHighlightLayerView };
//# sourceMappingURL=CategoryHighlightLayer_combined.js.map
