/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { DependencyProperty } from "igniteui-angular-core";
import { CategoryHighlightLayerFrame } from "./CategoryHighlightLayerFrame";
import { Base, Number_$type, typeCast, fromEnum, Point_$type, markType, markDep, runOn } from "igniteui-angular-core";
import { XamDataChart } from "./XamDataChart";
import { CategoryHighlightFrameRect } from "./CategoryHighlightFrameRect";
import { List$1 } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, truncate } from "igniteui-angular-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-angular-core";
import { Color } from "igniteui-angular-core";
/**
 * @hidden
 */
export class CategoryHighlightLayer extends AnnotationLayer {
    constructor() {
        super();
        let a = new CategoryHighlightLayerFrame();
        let b = new CategoryHighlightLayerFrame();
        let c = new CategoryHighlightLayerFrame();
        let d = this.fi / 1000;
        this.l2 = a;
        this.l1 = b;
        this.l3 = c;
        this.ab = CategoryHighlightLayer.$;
    }
    bf() {
        return new CategoryHighlightLayerView(this);
    }
    iu(a) {
        super.iu(a);
        this.m5 = a;
    }
    get m8() {
        return this.c(CategoryHighlightLayer.nf);
    }
    set m8(a) {
        this.h(CategoryHighlightLayer.nf, a);
    }
    mk(a, b) {
        if (this.m4 == null || this.m4 == a) {
            if (!this.aq.c) {
                this.jd(b);
            }
        }
    }
    m6(a) {
        return a != null && a.ce();
    }
    mn(a, b) {
        super.mn(a, b);
        let c = a;
        c.g.clear();
        let d = this.m7;
        if (isNaN_(this.m1.x) && isNaN_(this.m1.y)) {
            return;
        }
        if (this.m4 != null) {
            if (this.m6(this.m4)) {
                this.nd(this.m4, c, d);
            }
        }
        else {
            if (typeCast(XamDataChart.$, this.bs) !== null) {
                let e = this.bs;
                for (let f of fromEnum(e.axes)) {
                    if (typeCast(CategoryAxisBase.$, f) !== null && this.m6(f)) {
                        this.nd(f, c, d);
                    }
                }
            }
        }
    }
    nd(a, b, c) {
        if (this.bi == null || this.bi.bs.isEmpty || this.bi.br.isEmpty) {
            return;
        }
        let d = this.m1.x;
        if (a.cf && isNaN_(d)) {
            d = 0;
        }
        d = this.bi.br.left + this.bi.br.width * (d - this.bi.bs.left) / this.bi.bs.width;
        let e = this.m1.y;
        if (!a.cf && isNaN_(e)) {
            e = 0;
        }
        e = this.bi.br.top + this.bi.br.height * (e - this.bi.bs.top) / this.bi.bs.height;
        let f = a.ku({ $type: Point_$type, x: d, y: e }, c, this.m8);
        this.nc(f, b, a);
    }
    nc(a, b, c) {
        let d = new CategoryHighlightFrameRect();
        d.b = a.left;
        d.e = a.top;
        d.c = a.right;
        d.a = a.bottom;
        d.g = this.mz();
        d.h = this.m0();
        if (d.g == null) {
            d.g = this.m5.b9(c.ii);
        }
        if (d.h == null) {
            d.h = this.m5.b9(c.ii);
        }
        d.d = this.ey;
        d.f = Base.getHashCodeStatic(c);
        if (!a.isEmpty) {
            b.g.addItem(d.f, d);
        }
    }
    mq(a, b) {
        super.mq(a, b);
        let c = this.m5.b2;
        let d = a;
        let e = 0;
        for (let f of fromEnum(d.g.values)) {
            let g = c.item(e);
            this.ne(f, g);
            e++;
        }
        c.count = e;
    }
    c8() {
        return true;
    }
    ne(a, b) {
        if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.a) || isNaN_(a.c) || isNaN_(a.d)) {
            b._visibility = 1;
            return;
        }
        this.m5.b4(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.lb != null) {
            b.ai = this.lb;
        }
        else {
            b.ai = null;
        }
        b.ad = this.lc;
    }
    iz(a, b, c, d) {
        super.iz(a, b, c, d);
        switch (b) {
            case CategoryHighlightLayer.$$p[0]:
                this.jd(true);
                break;
            case CategoryHighlightLayer.$$p[1]:
                this.jd(true);
                break;
        }
    }
}
CategoryHighlightLayer.$t = markType(CategoryHighlightLayer, 'CategoryHighlightLayer', AnnotationLayer.$);
CategoryHighlightLayer.nf = DependencyProperty.i("BAndHighlightWidth", Number_$type, CategoryHighlightLayer.$, new PropertyMetadata(2, 10, (a, b) => a.raisePropertyChanged("BAndHighlightWidth", b.oldValue, b.newValue)));
CategoryHighlightLayer.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryHighlightLayer, 'raisePropertyChanged', ['TargetAxis:m4:ng', [CategoryAxisBase.$, null], 'UseInterpolation:m7:nh', [0, false]]);
/**
 * @hidden
 */
export class CategoryHighlightLayerView extends AnnotationLayerView {
    constructor(a) {
        super(a);
        this.b1 = null;
        this.b2 = null;
        this.b3 = null;
        this.b1 = a;
        this.b3 = new List$1(Rectangle.$, 0);
    }
    ap() {
        super.ap();
        this.b2 = ((() => {
            let $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(this, this.ca);
            $ret.activate = runOn(this, this.b5);
            $ret.disactivate = runOn(this, this.b7);
            $ret.destroy = runOn(this, this.b6);
            return $ret;
        })());
    }
    ca() {
        let a = new Rectangle();
        a.ab = false;
        this.b3.add(a);
        return a;
    }
    b5(a) {
        a._visibility = 0;
    }
    b7(a) {
        a._visibility = 1;
    }
    b6(a) {
        this.b3.remove(a);
    }
    b8(a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.l(a, 0.1);
    }
    b9(a) {
        if (a != null) {
            let b = BrushUtil.l(a, 0.3);
            if (b.isGradient) {
                let c = b;
                if (c.gradientStops != null) {
                    for (let d = 0; d < c.gradientStops.length; d++) {
                        let 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;
        }
    }
    b4(a, b, c, d, e) {
        a._visibility = 0;
        a.n = b;
        a.o = c;
        a.width = d;
        a.height = e;
    }
    a3(a, b) {
        super.a3(a, b);
        if (a.d && !b) {
            for (let c = 0; c < this.b3.count; c++) {
                let d = this.b3._inner[c];
                if (d._visibility == 0) {
                    a.v(d);
                }
            }
        }
    }
    ai(a) {
        super.ai(a);
        for (let b = 0; b < this.b3.count; b++) {
            this.e.a2.exportRectangleData(a, this.b3._inner[b], "cihRect", ["Main", "CategoryItem"]);
        }
    }
}
CategoryHighlightLayerView.$t = markType(CategoryHighlightLayerView, 'CategoryHighlightLayerView', AnnotationLayerView.$);
//# sourceMappingURL=CategoryHighlightLayer_combined.js.map