/*
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 { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core";
import { CategoryItemHighlightType_$type } from "./CategoryItemHighlightType";
import { MarkerType_$type } from "./MarkerType";
import { Brush } from "igniteui-react-core";
import { DataTemplate } from "igniteui-react-core";
import { CategoryItemHighlightLayerFrame } from "./CategoryItemHighlightLayerFrame";
import { Base, enumGetBox, fromEnum, typeCast, Point_$type, markType, markDep, runOn } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { ItemHighlightFrameRect } from "./ItemHighlightFrameRect";
import { List$1 } from "igniteui-react-core";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { Rect } from "igniteui-react-core";
import { MarkerSeries } from "./MarkerSeries";
import { DataContext } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { ContentControl } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, isInfinity, truncate } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { Marker } from "./Marker";
import { BrushUtil } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { DataTemplatePassInfo } from "igniteui-react-core";
import { DataTemplateRenderInfo } from "igniteui-react-core";
import { DataTemplateMeasureInfo } from "igniteui-react-core";
/**
 * @hidden
 */
export let CategoryItemHighlightLayer = /*@__PURE__*/ (() => {
    class CategoryItemHighlightLayer extends AnnotationLayer {
        constructor() {
            super();
            this.nk = false;
            this.nj = true;
            this.nn = 10;
            let a = new CategoryItemHighlightLayerFrame();
            let b = new CategoryItemHighlightLayerFrame();
            let c = new CategoryItemHighlightLayerFrame();
            this.mc = a;
            this.mb = b;
            this.md = c;
            this.ab = CategoryItemHighlightLayer.$;
        }
        bf() {
            return new CategoryItemHighlightLayerView(this);
        }
        i2(a) {
            super.i2(a);
            this.ne = a;
        }
        mv(a, b) {
            if (this.ni == null || this.ni == a) {
                if (!this.aq.c) {
                    this.jl(b);
                }
            }
        }
        mi(a) {
            if (!super.mi(a)) {
                return false;
            }
            let b = this.mq(a);
            if (!b.c) {
                return false;
            }
            return true;
        }
        mx(a, b) {
            super.mx(a, b);
            let c = a;
            let d = this.nm;
            c.g.clear();
            if (isNaN_(this.nb.x) && isNaN_(this.nb.y)) {
                return;
            }
            if (this.mi(this.ni)) {
                this.n0(this.ni, c, d);
            }
            else {
                for (let e of fromEnum(this.bs.series)) {
                    if (this.mi(e)) {
                        this.n0(e, c, d);
                    }
                }
            }
        }
        i7(a, b, c, d) {
            super.i7(a, b, c, d);
            switch (b) {
                case CategoryItemHighlightLayer.$$p[4]:
                case CategoryItemHighlightLayer.$$p[5]:
                case CategoryItemHighlightLayer.$$p[2]:
                case CategoryItemHighlightLayer.$$p[3]:
                    this.jl(true);
                    break;
                case CategoryItemHighlightLayer.$$p[7]:
                    this.jl(true);
                    break;
                case CategoryItemHighlightLayer.$$p[8]:
                    this.nk = d;
                    this.jl(true);
                    break;
                case CategoryItemHighlightLayer.$$p[1]:
                    this.jl(true);
                    break;
                case CategoryItemHighlightLayer.$$p[0]:
                    this.nn = this.no;
                    this.jl(true);
                    break;
                case CategoryItemHighlightLayer.$$p[6]:
                    this.nj = d;
                    this.jl(true);
                    break;
            }
        }
        n0(a, b, c) {
            if (this.bi == null || this.bi.bs.isEmpty || this.bi.br.isEmpty) {
                return;
            }
            if (!a.cl && !a.cr) {
                return;
            }
            let d = a;
            if (d.categoryAxis == null) {
                return;
            }
            let e = this.nb.x;
            e = this.bi.br.left + this.bi.br.width * (e - this.bi.bs.left) / this.bi.bs.width;
            let f = this.nb.y;
            f = this.bi.br.top + this.bi.br.height * (f - this.bi.bs.top) / this.bi.bs.height;
            let g = this.nl;
            let h = true;
            let i = typeCast(IHasCategoryModePreference_$type, a);
            let j = 0;
            if (i != null) {
                j = i.preferredCategoryMode(d.categoryAxis);
                if (j == 2) {
                    h = false;
                }
            }
            let k = true;
            if (!h || this.nf == 2) {
                k = false;
            }
            if (this.nf == 1) {
                k = true;
            }
            let l = this.mq(a);
            if (!l.c) {
                return;
            }
            if (k) {
                let m = a.lv(l.d, this.nm, g);
                if (j != 0 && !d.categoryAxis.cf) {
                    let n = m.x;
                    if (a.cr) {
                        n -= a.getOffsetValue();
                        n += a.getCategoryWidth() * 0.5;
                        m = { $type: Point_$type, x: n, y: m.y };
                    }
                    else if (a.cl) {
                        n -= a.getOffsetValue();
                        n += a.getCategoryWidth() * 0.5;
                        m = { $type: Point_$type, x: n, y: m.y };
                    }
                }
                if (!isNaN_(m.x) && !isNaN_(m.y)) {
                    m = this.ly(m);
                }
                this.ny(m, b, a);
            }
            else {
                let o = a.lv(l.d, this.nm, g);
                let p;
                let q = this.getEffectiveViewport1(this.bi);
                if (a.isVertical) {
                    let r = o.y;
                    let s = d.categoryAxis;
                    let t = this.nn;
                    if (j != 0) {
                        t = s.jz(this.bi.bs, this.bi.br, q);
                    }
                    if (isNaN_(t) || isInfinity(t)) {
                        return;
                    }
                    p = new Rect(0, this.l8.left, r - t / 2, this.l8.width, t);
                }
                else {
                    let u = o.x;
                    let v = d.categoryAxis;
                    let w = this.nn;
                    if (j != 0) {
                        w = v.jz(this.bi.bs, this.bi.br, q);
                    }
                    if (isNaN_(w) || isInfinity(w)) {
                        return;
                    }
                    p = new Rect(0, u - w / 2, this.l8.top, w, this.l8.height);
                }
                p.intersect(this.bi.br);
                this.nz(p, b, a);
            }
        }
        ny(a, b, c) {
            let d = new ItemHighlightFrameRect();
            d.b = a.x;
            d.e = a.y;
            d.i = this.m9();
            if (this.od != null) {
                d.i = this.od;
            }
            d.j = this.na();
            if (this.oe != null) {
                d.j = this.oe;
            }
            if (d.i == null) {
                if (c.hasMarkers) {
                    d.i = this.ne.cf(c.lg());
                }
                else {
                    d.i = this.ne.cf(c.lb);
                }
            }
            if (d.j == null) {
                if (c.hasMarkers) {
                    d.j = this.ne.cf(c.lh());
                }
                else {
                    d.j = this.ne.cf(c.lc);
                }
            }
            d.d = this.ey;
            d.f = Base.getHashCodeStatic(c);
            d.g = this.ng(c, a);
            let e = (typeCast(MarkerSeries.$, c) !== null) ? c.mu : null;
            if (e == null || e == MarkerSeries.mx || (this.nh != 2 && this.nh != 0)) {
                let f = MarkerSeries.mc(c, 2);
                if (this.nh != 2 && this.nh != 0) {
                    f = this.nh;
                }
                switch (f) {
                    case 3:
                    case 13:
                        e = this.bs.ls;
                        break;
                    case 4:
                        e = this.bs.l1;
                        break;
                    case 5:
                        e = this.bs.ly;
                        break;
                    case 6:
                        e = this.bs.lz;
                        break;
                    case 7:
                        e = this.bs.lt;
                        break;
                    case 8:
                        e = this.bs.lw;
                        break;
                    case 9:
                        e = this.bs.lu;
                        break;
                    case 10:
                        e = this.bs.l0;
                        break;
                    case 11:
                        e = this.bs.lx;
                        break;
                    case 12:
                        e = this.bs.lv;
                        break;
                }
            }
            d.h = this.n3 != null ? this.n3 : e;
            if (!isNaN_(d.b) && !isNaN_(d.e)) {
                b.g.addItem(d.f, d);
            }
        }
        ng(a, b) {
            let c = a.fp(b);
            let d = a.eb(b);
            if (this.nm && d != Math.floor(d)) {
                c = null;
            }
            return ((() => {
                let $ret = new DataContext();
                $ret.series = a;
                $ret.item = c;
                return $ret;
            })());
        }
        nz(a, b, c) {
            let d = new ItemHighlightFrameRect();
            d.b = a.left;
            d.e = a.top;
            d.c = a.right;
            d.a = a.bottom;
            d.i = this.m9();
            d.j = this.na();
            if (d.i == null) {
                if (c != null) {
                    d.i = this.ne.cg(c.lb);
                }
            }
            if (d.j == null) {
                if (c != null) {
                    d.j = this.ne.cg(c.lc);
                }
            }
            d.d = this.ey;
            d.f = Base.getHashCodeStatic(c);
            if (!a.isEmpty) {
                b.g.addItem(d.f, d);
            }
        }
        m0(a, b) {
            super.m0(a, b);
            let c = this.ne.b3;
            let d = this.ne.b2;
            let e = 0;
            let f = 0;
            let g = a;
            for (let h of fromEnum(g.g.values)) {
                if (h.h != null) {
                    let i = d.item(f);
                    this.n1(h, i);
                    f++;
                }
                else {
                    let j = c.item(e);
                    this.n2(h, j);
                    e++;
                }
            }
            c.count = e;
            d.count = f;
        }
        n1(a, b) {
            if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.d) || a.g == null) {
                b._visibility = 1;
                return;
            }
            let c = { $type: Point_$type, x: a.b, y: a.e };
            let d = a.g;
            d.itemBrush = a.i;
            let e = d.series.lv(c, this.ca() || this.nk, this.nj);
            if (isNaN_(e.x) || isNaN_(e.y)) {
                b._visibility = 1;
                return;
            }
            this.ne.b9(b, e.x, e.y);
            b.ah = a.h;
            b.content = a.g;
        }
        n2(a, b) {
            if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.a) || isNaN_(a.c) || isNaN_(a.d)) {
                b._visibility = 1;
                return;
            }
            this.ne.ca(b, a.b, a.e, a.c - a.b, a.a - a.e);
            b._fill = a.i;
            b._stroke = a.j;
            b.ac = a.d;
            if (this.ll != null) {
                b.ai = this.ll;
            }
            else {
                b.ai = null;
            }
            b.ad = this.lm;
        }
        c8() {
            return true;
        }
    }
    CategoryItemHighlightLayer.$t = /*@__PURE__*/ markType(CategoryItemHighlightLayer, 'CategoryItemHighlightLayer', AnnotationLayer.$);
    CategoryItemHighlightLayer.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryItemHighlightLayer, 'raisePropertyChanged', ['BandHighlightWidth:no:n4', [1, 10], 'HighlightType:nf:n5', [CategoryItemHighlightType_$type, /*@__PURE__*/ enumGetBox(CategoryItemHighlightType_$type, 0)], 'MarkerBrush:od:n6', [Brush.$, null], 'MarkerOutline:oe:n7', [Brush.$, null], 'MarkerTemplate:n3:n8', [DataTemplate.$, null], 'MarkerType:nh:n9', [MarkerType_$type, /*@__PURE__*/ enumGetBox(MarkerType_$type, 2)], 'SkipUnknownValues:nl:oa', [0, true], 'TargetSeries:ni:ob', [Series.$, null], 'UseInterpolation:nm:oc', [0, false]]);
    return CategoryItemHighlightLayer;
})();
/**
 * @hidden
 */
export let CategoryItemHighlightLayerView = /*@__PURE__*/ (() => {
    class CategoryItemHighlightLayerView extends AnnotationLayerView {
        constructor(a) {
            super(a);
            this.b1 = null;
            this.b3 = null;
            this.b2 = null;
            this.b4 = null;
            this.b5 = null;
            this.b1 = a;
            this.b4 = new List$1(ContentControl.$, 0);
            this.b5 = new List$1(Rectangle.$, 0);
        }
        ap() {
            super.ap();
            this.b3 = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.ch);
                $ret.activate = runOn(this, this.cb);
                $ret.disactivate = runOn(this, this.cd);
                $ret.destroy = runOn(this, this.cc);
                return $ret;
            })());
            this.b2 = ((() => {
                let $ret = new Pool$1(ContentControl.$);
                $ret.create = runOn(this, this.ce);
                $ret.activate = runOn(this, this.b6);
                $ret.disactivate = runOn(this, this.b8);
                $ret.destroy = runOn(this, this.b7);
                return $ret;
            })());
        }
        ch() {
            let a = new Rectangle();
            a.ab = false;
            this.b5.add(a);
            return a;
        }
        cb(a) {
            a._visibility = 0;
        }
        cd(a) {
            a._visibility = 1;
        }
        cc(a) {
            this.b5.remove(a);
        }
        ce() {
            let a = new Marker();
            this.b4.add(a);
            return a;
        }
        b6(a) {
            a._visibility = 0;
        }
        b8(a) {
            a._visibility = 1;
        }
        b7(a) {
            this.b4.remove(a);
        }
        cf(a) {
            if (a == null) {
                return a;
            }
            return BrushUtil.l(a, 0.3);
        }
        cg(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.3)), e.color.o, e.color.n, e.color.m);
                            e.color = e.color;
                        }
                    }
                }
                else {
                    b.color = Color.u(truncate(Math.round((b.color.l & 255) * 0.3)), b.color.o, b.color.n, b.color.m);
                    b.color = b.color;
                }
                return b;
            }
            else {
                return null;
            }
        }
        ca(a, b, c, d, e) {
            a._visibility = 0;
            a.n = b;
            a.o = c;
            a.width = d;
            a.height = e;
        }
        b9(a, b, c) {
            a.n = b;
            a.o = c;
        }
        be(a, b) {
            super.be(a, b);
            let c = a;
            let d = c.content;
            if (d != null) {
                if (d.itemBrush != null) {
                    d.actualItemBrush = d.itemBrush;
                }
                let e = d.series;
                if (e.hasMarkers) {
                    d.outline = e.lh();
                }
                d.thickness = 0.5;
            }
        }
        a3(a, b) {
            super.a3(a, b);
            if (a.d && !b) {
                for (let c = 0; c < this.b5.count; c++) {
                    let d = this.b5._inner[c];
                    if (d._visibility == 0) {
                        a.v(d);
                    }
                }
                if (this.b4.count > 0) {
                    let e = new DataTemplatePassInfo();
                    e.isHitTestRender = b;
                    e.context = a.g();
                    e.viewportTop = this.br.top;
                    e.viewportLeft = this.br.left;
                    e.viewportWidth = this.br.width;
                    e.viewportHeight = this.br.height;
                    e.passID = "ItemMarkers";
                    let f = new DataTemplateRenderInfo();
                    f.isHitTestRender = b;
                    f.passInfo = e;
                    let g = new DataTemplateMeasureInfo();
                    g.passInfo = e;
                    let h = false;
                    let i = a.g();
                    g.context = i;
                    f.context = i;
                    g.renderContext = a;
                    f.renderContext = a;
                    let j = 0;
                    let k = 0;
                    let l = new Dictionary$2(DataTemplate.$, DataTemplate.$, 0);
                    for (let m = 0; m < this.b4.count; m++) {
                        let n = this.b4._inner[m];
                        let o = n.ah;
                        if (!l.containsKey(o)) {
                            l.addItem(o, o);
                            if (o != null && o.passStarting != null) {
                                o.passStarting(e);
                            }
                        }
                        if (n._visibility == 1) {
                            continue;
                        }
                        this.bd(n, m, b);
                        if (!h) {
                            g.data = n.content;
                            g.width = n.width;
                            g.height = n.height;
                            if (o.measure != null) {
                                g.data = n.content;
                                o.measure(g);
                                h = g.isConstant;
                                if (h) {
                                    j = g.width;
                                    k = g.height;
                                }
                            }
                            f.availableWidth = g.width;
                            f.availableHeight = g.height;
                        }
                        else {
                            f.availableWidth = j;
                            f.availableHeight = k;
                        }
                        if (!isNaN_(n.width) && !isInfinity(n.width)) {
                            f.availableWidth = n.width;
                        }
                        if (!isNaN_(n.height) && !isInfinity(n.height)) {
                            f.availableHeight = n.height;
                        }
                        a.p(f, n);
                        n.m = f.availableWidth;
                        n.l = f.availableHeight;
                    }
                    for (let p of fromEnum(l.keys)) {
                        if (p != null && p.passCompleted != null) {
                            p.passCompleted(e);
                        }
                    }
                }
            }
        }
        ai(a) {
            super.ai(a);
            for (let b = 0; b < this.b5.count; b++) {
                this.e.a2.exportRectangleData(a, this.b5._inner[b], "catItemRect", ["Main", "CategoryItem"]);
            }
            for (let c = 0; c < this.b4.count; c++) {
                this.e.a2.exportMarkerVisualDataFromMarker(this.e, a, this.b4._inner[c]);
            }
        }
    }
    CategoryItemHighlightLayerView.$t = /*@__PURE__*/ markType(CategoryItemHighlightLayerView, 'CategoryItemHighlightLayerView', AnnotationLayerView.$);
    return CategoryItemHighlightLayerView;
})();
//# sourceMappingURL=CategoryItemHighlightLayer_combined.js.map
