/*
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 { 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) {
    __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.kd / 1000;
        _this.xa = a;
        _this.w9 = b;
        _this.xb = c;
        _this.ab = CategoryHighlightLayer.$;
        return _this;
    }
    CategoryHighlightLayer.prototype.bj = function () {
        return new CategoryHighlightLayer();
    };
    CategoryHighlightLayer.prototype.get_er = function () {
        return true;
    };
    CategoryHighlightLayer.prototype.cs = function () {
        return new CategoryHighlightLayerView(this);
    };
    CategoryHighlightLayer.prototype.qz = function (a) {
        _super.prototype.qz.call(this, a);
        this.zw = a;
    };
    Object.defineProperty(CategoryHighlightLayer.prototype, "zz", {
        get: function () {
            return this.c(CategoryHighlightLayer.z6);
        },
        set: function (a) {
            this.h(CategoryHighlightLayer.z6, a);
        },
        enumerable: false,
        configurable: true
    });
    CategoryHighlightLayer.prototype.ym = function (a, b) {
        if (this.zv == null || this.zv == a) {
            if (!this.a1.c) {
                this.rp(b);
            }
        }
    };
    CategoryHighlightLayer.prototype.zx = function (a) {
        return a != null && a.co();
    };
    CategoryHighlightLayer.prototype.yp = function (a, b) {
        var e_1, _a;
        _super.prototype.yp.call(this, a, b);
        var c = a;
        c.g.clear();
        var d = this.zy;
        if (isNaN_(this.zs.x) && isNaN_(this.zs.y)) {
            return;
        }
        if (this.zv != null) {
            if (this.zx(this.zv)) {
                this.z4(this.zv, c, d);
            }
        }
        else {
            if (typeCast(XamDataChart.$, this.db) !== null) {
                var e = this.db;
                try {
                    for (var _b = __values(fromEnum(e.axes)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var f = _c.value;
                        if (typeCast(CategoryAxisBase.$, f) !== null && this.zx(f)) {
                            this.z4(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.z4 = function (a, b, c) {
        if (this.cv == null || this.cv.by.isEmpty || this.cv.bx.isEmpty) {
            return;
        }
        var d = this.zs.x;
        if (a.cp && isNaN_(d)) {
            d = 0;
        }
        var e = this.wh(this.cv);
        d = e.left + e.width * (d - this.cv.by.left) / this.cv.by.width;
        var f = this.zs.y;
        if (!a.cp && isNaN_(f)) {
            f = 0;
        }
        f = e.top + e.height * (f - this.cv.by.top) / this.cv.by.height;
        var g = a.mj({ $type: Point_$type, x: d, y: f }, c, this.zz);
        this.z3(g, b, a);
    };
    CategoryHighlightLayer.prototype.z3 = 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.zi();
        d.h = this.zj();
        if (d.g == null) {
            d.g = this.zw.cf(c.jy);
        }
        if (d.h == null) {
            d.h = this.zw.cf(c.jy);
        }
        d.d = this.ie;
        d.f = Base.getHashCodeStatic(c);
        if (!a.isEmpty) {
            b.g.addItem(d.f, d);
        }
    };
    CategoryHighlightLayer.prototype.ys = function (a, b) {
        var e_2, _a;
        _super.prototype.ys.call(this, a, b);
        var c = this.zw.b8;
        var d = a;
        var e = 0;
        try {
            for (var _b = __values(fromEnum(d.g.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                var g = c.item(e);
                this.z5(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.ga = function () {
        return true;
    };
    CategoryHighlightLayer.prototype.z5 = function (a, b) {
        if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.a) || isNaN_(a.c) || isNaN_(a.d)) {
            b._visibility = 1;
            return;
        }
        this.zw.ca(b, a.b, a.e, a.c - a.b, a.a - a.e);
        b._fill = a.g;
        b._stroke = a.h;
        b.ad = a.d;
        if (this.v0 != null) {
            b.ai = this.v0;
        }
        else {
            b.ai = null;
        }
        b.aj = this.v1;
        b.am = this.v3;
        b.al = this.v2;
        b.ak = this.v2;
        b.ac = this.jh;
    };
    CategoryHighlightLayer.prototype.q7 = function (a, b, c, d) {
        _super.prototype.q7.call(this, a, b, c, d);
        switch (b) {
            case CategoryHighlightLayer.$$p[0]:
                this.rp(true);
                break;
            case CategoryHighlightLayer.$$p[1]:
                this.rp(true);
                break;
        }
    };
    CategoryHighlightLayer.$t = markType(CategoryHighlightLayer, 'CategoryHighlightLayer', AnnotationLayer.$);
    CategoryHighlightLayer.z6 = 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:zv:z7', [CategoryAxisBase.$, null], 'UseInterpolation:zy:z8', [0, false]]);
    return CategoryHighlightLayer;
}(AnnotationLayer));
export { CategoryHighlightLayer };
/**
 * @hidden
 */
var CategoryHighlightLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CategoryHighlightLayerView, _super);
    function CategoryHighlightLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b7 = null;
        _this.b8 = null;
        _this.b9 = null;
        _this.b7 = a;
        _this.b9 = new List$1(Rectangle.$, 0);
        return _this;
    }
    CategoryHighlightLayerView.prototype.au = function () {
        var _this = this;
        _super.prototype.au.call(this);
        this.b8 = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.cg);
            $ret.activate = runOn(_this, _this.cb);
            $ret.disactivate = runOn(_this, _this.cd);
            $ret.destroy = runOn(_this, _this.cc);
            return $ret;
        })());
    };
    CategoryHighlightLayerView.prototype.cg = function () {
        var a = new Rectangle();
        a.ab = false;
        this.b9.add(a);
        return a;
    };
    CategoryHighlightLayerView.prototype.cb = function (a) {
        a._visibility = 0;
    };
    CategoryHighlightLayerView.prototype.cd = function (a) {
        a._visibility = 1;
    };
    CategoryHighlightLayerView.prototype.cc = function (a) {
        this.b9.remove(a);
    };
    CategoryHighlightLayerView.prototype.ce = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.m(a, 0.1);
    };
    CategoryHighlightLayerView.prototype.cf = function (a) {
        if (a != null) {
            var b = BrushUtil.m(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.ca = function (a, b, c, d, e) {
        a._visibility = 0;
        a.n = b;
        a.o = c;
        a.width = d;
        a.height = e;
    };
    CategoryHighlightLayerView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        if (a.d && !b) {
            for (var c = 0; c < this.b9.count; c++) {
                var d = this.b9._inner[c];
                if (d._visibility == 0) {
                    a.w(d);
                }
            }
        }
    };
    CategoryHighlightLayerView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
        for (var b = 0; b < this.b9.count; b++) {
            this.e.bc.exportRectangleData(a, this.b9._inner[b], "cihRect", ["Main", "CategoryItem"]);
        }
    };
    CategoryHighlightLayerView.$t = markType(CategoryHighlightLayerView, 'CategoryHighlightLayerView', AnnotationLayerView.$);
    return CategoryHighlightLayerView;
}(AnnotationLayerView));
export { CategoryHighlightLayerView };
