/*
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-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
 */
export let CategoryHighlightLayer = /*@__PURE__*/ (() => {
    class CategoryHighlightLayer extends AnnotationLayer {
        constructor() {
            super();
            let a = new CategoryHighlightLayerFrame();
            let b = new CategoryHighlightLayerFrame();
            let c = new CategoryHighlightLayerFrame();
            let d = this.gj / 1000;
            this.ob = a;
            this.oa = b;
            this.oc = c;
            this.ab = CategoryHighlightLayer.$;
        }
        bp() {
            return new CategoryHighlightLayerView(this);
        }
        kk(a) {
            super.kk(a);
            this.pe = a;
        }
        get ph() {
            return this.c(CategoryHighlightLayer.po);
        }
        set ph(a) {
            this.h(CategoryHighlightLayer.po, a);
        }
        ot(a, b) {
            if (this.pd == null || this.pd == a) {
                if (!this.ar.c) {
                    this.k3(b);
                }
            }
        }
        pf(a) {
            return a != null && a.cg();
        }
        ow(a, b) {
            super.ow(a, b);
            let c = a;
            c.g.clear();
            let 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) {
                    let e = this.b6;
                    for (let f of fromEnum(e.axes)) {
                        if (typeCast(CategoryAxisBase.$, f) !== null && this.pf(f)) {
                            this.pm(f, c, d);
                        }
                    }
                }
            }
        }
        pm(a, b, c) {
            if (this.bs == null || this.bs.bv.isEmpty || this.bs.bu.isEmpty) {
                return;
            }
            let 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;
            let 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;
            let f = a.k3({ $type: Point_$type, x: d, y: e }, c, this.ph);
            this.pl(f, b, a);
        }
        pl(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.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);
            }
        }
        oz(a, b) {
            super.oz(a, b);
            let c = this.pe.b5;
            let d = a;
            let e = 0;
            for (let f of fromEnum(d.g.values)) {
                let g = c.item(e);
                this.pn(f, g);
                e++;
            }
            c.count = e;
        }
        dp() {
            return true;
        }
        pn(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;
        }
        kp(a, b, c, d) {
            super.kp(a, b, c, d);
            switch (b) {
                case CategoryHighlightLayer.$$p[0]:
                    this.k3(true);
                    break;
                case CategoryHighlightLayer.$$p[1]:
                    this.k3(true);
                    break;
            }
        }
    }
    CategoryHighlightLayer.$t = /*@__PURE__*/ markType(CategoryHighlightLayer, 'CategoryHighlightLayer', AnnotationLayer.$);
    CategoryHighlightLayer.po = /*@__PURE__*/ DependencyProperty.i("BAndHighlightWidth", Number_$type, CategoryHighlightLayer.$, /*@__PURE__*/ new PropertyMetadata(2, 10, (a, b) => a.raisePropertyChanged("BAndHighlightWidth", b.oldValue, b.newValue)));
    CategoryHighlightLayer.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryHighlightLayer, 'raisePropertyChanged', ['TargetAxis:pd:pp', [CategoryAxisBase.$, null], 'UseInterpolation:pg:pq', [0, false]]);
    return CategoryHighlightLayer;
})();
/**
 * @hidden
 */
export let CategoryHighlightLayerView = /*@__PURE__*/ (() => {
    class CategoryHighlightLayerView extends AnnotationLayerView {
        constructor(a) {
            super(a);
            this.b4 = null;
            this.b5 = null;
            this.b6 = null;
            this.b4 = a;
            this.b6 = new List$1(Rectangle.$, 0);
        }
        as() {
            super.as();
            this.b5 = ((() => {
                let $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;
            })());
        }
        cd() {
            let a = new Rectangle();
            a.ab = false;
            this.b6.add(a);
            return a;
        }
        b8(a) {
            a._visibility = 0;
        }
        ca(a) {
            a._visibility = 1;
        }
        b9(a) {
            this.b6.remove(a);
        }
        cb(a) {
            if (a == null) {
                return a;
            }
            return BrushUtil.l(a, 0.1);
        }
        cc(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;
            }
        }
        b7(a, b, c, d, e) {
            a._visibility = 0;
            a.n = b;
            a.o = c;
            a.width = d;
            a.height = e;
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d && !b) {
                for (let c = 0; c < this.b6.count; c++) {
                    let d = this.b6._inner[c];
                    if (d._visibility == 0) {
                        a.v(d);
                    }
                }
            }
        }
        al(a) {
            super.al(a);
            for (let b = 0; b < this.b6.count; b++) {
                this.e.a5.exportRectangleData(a, this.b6._inner[b], "cihRect", ["Main", "CategoryItem"]);
            }
        }
    }
    CategoryHighlightLayerView.$t = /*@__PURE__*/ markType(CategoryHighlightLayerView, 'CategoryHighlightLayerView', AnnotationLayerView.$);
    return CategoryHighlightLayerView;
})();
//# sourceMappingURL=CategoryHighlightLayer_combined.js.map
