/*
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 { Base, Point_$type, typeCast, runOn, delegateCombine, fromEnum, markType, String_$type, delegateRemove, EnumUtil, IEnumerable_$type, enumGetBox, markDep } from "igniteui-react-core";
import { IOuterLabelWidthDecider_$type } from "./IOuterLabelWidthDecider";
import { IFunnelLabelSizeDecider_$type } from "./IFunnelLabelSizeDecider";
import { ServiceProvider } from "./ServiceProvider";
import { MessageChannel } from "./MessageChannel";
import { MouseLeaveMessage } from "./MouseLeaveMessage";
import { MouseMoveMessage } from "./MouseMoveMessage";
import { MouseButtonMessage } from "./MouseButtonMessage";
import { Rect } from "igniteui-react-core";
import { RenderingContext } from "igniteui-react-core";
import { SetAreaSizeMessage } from "./SetAreaSizeMessage";
import { RenderingMessage } from "./RenderingMessage";
import { Polygon } from "igniteui-react-core";
import { PointCollection } from "igniteui-react-core";
import { TextBlock } from "igniteui-react-core";
import { RenderSliceMessage } from "./RenderSliceMessage";
import { List$1 } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { RenderOuterLabelMessage } from "./RenderOuterLabelMessage";
import { SliceInfo } from "./SliceInfo";
import { TooltipValueChangedMessage } from "./TooltipValueChangedMessage";
import { TooltipUpdateMessage } from "./TooltipUpdateMessage";
import { FunnelDataContext } from "./FunnelDataContext";
import { PropertyChangedMessage } from "./PropertyChangedMessage";
import { FontUtil } from "igniteui-react-core";
import { CanvasViewRenderer } from "igniteui-react-core";
import { DOMEventProxy } from "igniteui-react-core";
import { BrushCollection } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { MessageHandler } from "./MessageHandler";
import { ClearMessage } from "./ClearMessage";
import { ClearTooltipMessage } from "./ClearTooltipMessage";
import { ContainerSizeChangedMessage } from "./ContainerSizeChangedMessage";
import { ViewportChangedMessage } from "./ViewportChangedMessage";
import { ViewPropertyChangedMessage } from "./ViewPropertyChangedMessage";
import { ObjectColumn } from "./ObjectColumn";
import { Size } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { stringReplace } from "igniteui-react-core";
import { SliceInfoList } from "./SliceInfoList";
import { DoubleAnimator } from "igniteui-react-core";
import { Bezier } from "./Bezier";
import { DoubleColumn } from "./DoubleColumn";
import { OuterLabelAlignment_$type } from "./OuterLabelAlignment";
import { FunnelSliceDisplay_$type } from "./FunnelSliceDisplay";
import { IItemProvider_$type } from "./IItemProvider";
import { SliceSelectionManager } from "./SliceSelectionManager";
import { FunnelFrame } from "./FunnelFrame";
import { Style } from "igniteui-react-core";
import { IChartLegend_$type } from "igniteui-react-core";
import { DataTemplate } from "igniteui-react-core";
import { DataUpdatedMessage } from "./DataUpdatedMessage";
import { UserSelectedItemsChangedMessage } from "./UserSelectedItemsChangedMessage";
import { LabelSizeChangedMessage } from "./LabelSizeChangedMessage";
import { NotifyCollectionChangedEventArgs } from "igniteui-react-core";
import { FrameRenderCompleteMessage } from "./FrameRenderCompleteMessage";
import { IntColumn } from "./IntColumn";
import { PointList } from "./PointList";
import { Convert } from "igniteui-react-core";
import { ObservableCollection$1 } from "igniteui-react-core";
import { ILegendSeries_$type } from "igniteui-react-core";
import { UIElement } from "igniteui-react-core";
import { ContentControl } from "igniteui-react-core";
import { FunnelSliceDataContext } from "./FunnelSliceDataContext";
import { Control } from "igniteui-react-core";
import { SliceClickedMessage } from "./SliceClickedMessage";
import { SelectedItemsChangedMessage } from "./SelectedItemsChangedMessage";
import { SliceMouseMessage } from "./SliceMouseMessage";
import { ILegendOwner_$type } from "igniteui-react-core";
import { ILegendTemplateProvider_$type } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { FastItemsSource } from "igniteui-react-core";
import { Visibility_$type } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { FunnelLegendTemplates } from "./FunnelLegendTemplates";
import { DeviceUtils } from "igniteui-react-core";
import { FunnelSliceClickedEventArgs } from "./FunnelSliceClickedEventArgs";
import { FunnelSliceEventArgs } from "./FunnelSliceEventArgs";
import { FunnelChartVisualData } from "./FunnelChartVisualData";
import { RectData } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
/**
 * @hidden
 */
export let XamFunnelView = /*@__PURE__*/ (() => {
    class XamFunnelView extends Base {
        get i() {
            return this.h;
        }
        set i(a) {
            let b = this.h;
            this.h = a;
            this.a1(b, this.h);
        }
        am(a) {
            this.f.i(new MouseLeaveMessage());
        }
        an(a, b, c) {
            let d = new MouseMoveMessage();
            d.c = a;
            this.f.i(d);
        }
        al(a) {
            let b = new MouseButtonMessage();
            b.h = a;
            b.c = 1;
            b.e = this.j.al ? 1 : 0;
            b.f = this.j.bi;
            this.f.i(b);
        }
        ao(a) {
            let b = new MouseButtonMessage();
            b.h = a;
            b.c = 0;
            b.e = this.j.al ? 1 : 0;
            b.f = this.j.bi;
            this.f.i(b);
        }
        ap(a) {
            let b = this.bg;
            if (Rect.l_op_Equality(b, null)) {
                return;
            }
            let c = b.left, d = b.top, e = b.width, f = b.height;
            this.aq(this.q, c, d, e, f);
            this.aq(this.o, c, d, e, f);
            this.aq(this.p, c, d, e, f);
            this.aq(this.r, c, d, e, f);
        }
        aq(a, b, c, d, e) {
            if (a != null) {
                if (a.d && this.t != 1) {
                    a.aa();
                    a.ab(this.t, this.t);
                }
                a.l(b, c, d, e);
                if (a.d && this.t != 1) {
                    a.z();
                }
            }
        }
        ba(a) {
            let b = a.m;
            let c = a.e;
            if (c == "LeftPanel") {
                this.u = b;
            }
            if (c == "RightPanel") {
                this.v = b;
            }
        }
        a6(a) {
            let b = a.g;
            let c = this.q;
            if (c.d && this.t != 1) {
                c.aa();
                c.ab(this.t, this.t);
            }
            let d = new Polygon();
            let e = new PointCollection(0);
            for (let f = 0; f < b.au.count; f++) {
                let g = b.au._inner[f];
                e.add({ $type: Point_$type, x: g.x + this.u + b.aq.x, y: g.y + b.aq.y });
            }
            d.an = e;
            d.ad = a.h;
            d._opacity = b.p;
            d._fill = b.ad;
            d._stroke = a.h < 1 ? b.ad : b.ag;
            if (b.a0 != null) {
                c.j(d, b.a0);
                b.ad = d._fill;
                b.ag = d._stroke;
                b.q = d.ad;
                b.p = d._opacity;
            }
            c.u(d);
            b.q = d.ad;
            if (b.i) {
                let h = new TextBlock();
                if (this.bf == null) {
                    this.bf = new Brush();
                    this.bf._fill = this.ak("ui-funnel-slice", "color", -1);
                }
                h.ao = this.bf;
                c.ad(this.m());
                let i = b.v.toString();
                let j = c.g(i);
                let k = this.ab();
                h.al = i;
                h.o = b.an.y + b.aq.y - (k / 2);
                h.n = b.an.x + this.u + b.aq.x - (j / 2);
                b.ax = new Rect(0, h.n, h.o, j, k);
                b.a2 = h._visibility;
                c.x(h);
            }
            if (c.d && this.t != 1) {
                c.z();
            }
        }
        a5(a) {
            let b = 0;
            if (this.v > 0) {
                b = this.bg.width - this.v;
            }
            let c = a;
            let d = this.p;
            if (d.d && this.t != 1) {
                d.aa();
                d.ab(this.t, this.t);
            }
            let e = new TextBlock();
            e.al = c.j.toString();
            d.ad(this.n());
            if (this.be == null) {
                this.be = new Brush();
                this.be._fill = this.ad.rootWrapper.getStyleProperty("color");
            }
            e.ao = this.be;
            let f = this.ac();
            let g = c.l.y - f / 2;
            let h = d.g(e.al);
            e.n = b;
            e.o = g;
            c.f.b.ay = new Rect(0, b, g, h, f);
            d.x(e);
            if (d.d && this.t != 1) {
                d.z();
            }
        }
        az() {
            if (this.j != null) {
                this.j.bh(this.ai, "");
            }
        }
        ax(a) {
            this.av(a);
            if (this.j != null) {
                this.j.at(this.ai, "");
            }
        }
        bc(a) {
            this.aj = a.g;
        }
        bb(a) {
            this.at(a);
        }
        ar(a) {
            this.at(null);
        }
        at(a) {
            let x_ = 0, y_ = 0;
            let t_ = null, v_ = null, i_ = this.ad;
            {
                if (a != null) {
                    t_ = this.aj;
                    x_ = a.i.x + 6;
                    y_ = a.i.y + 6;
                    v_ = a.g.item;
                }
                let ren_ = this.ad;
                let dc_ = null;
                if (a != null) {
                    dc_ = a.g;
                }
                if (dc_ == null) {
                    dc_ = new FunnelDataContext();
                }
                dc_.item = v_;
                let tt_ = this.aj;
                if (tt_ != null) {
                    if (v_ != null) {
                        tt_.updateToolTip(dc_);
                        tt_.setRawPosition(x_, y_);
                    }
                    else {
                        tt_.hideToolTip();
                    }
                }
            }
        }
        a3(a) {
            let b = a;
            let c = b.g;
            switch (c) {
                case "Container":
                    this.ay(b.d);
                    break;
                case "TextStyle":
                    this.l = FontUtil.toFontInfo(this.ad, b.d.toString());
                    break;
                case "OuterLabelTextStyle":
                    this.k = FontUtil.toFontInfo(this.ad, b.d.toString());
                    break;
                case "ActualPixelScalingRatio":
                    if (isNaN_(this.w) || this.w == 0) {
                        this.t = b.d;
                    }
                    break;
                case "OuterLabelTextColor":
                    this.be = typeCast(Brush.$, b.d);
                    break;
                case "LabelTextColor":
                    this.bf = typeCast(Brush.$, b.d);
                    break;
            }
        }
        a4(a) {
            if (this.ad != null) {
                this.ad.setTimeout(a, 0);
            }
            else {
                window.setTimeout(a, 0);
            }
        }
        ay(a) {
            if (a == null) {
                if (this.j != null) {
                    this.j.av();
                }
                this.ad = null;
                this.ae = this.ah = this.ag = this.ai = null;
                this.o = this.q = this.p = this.r = null;
                this.j = null;
                return;
            }
            let b = a;
            let c = this.ad = b;
            c.rootWrapper.setStyleProperty("position", "relative");
            for (let d = 0; d < 4; d++) {
                let e = this.ad.createElement("canvas");
                e.setStyleProperty("position", "absolute");
                c.append(e);
                let f = new RenderingContext(new CanvasViewRenderer(), this.ad.get2DCanvasContext(e));
                if (d == 0) {
                    this.ae = e;
                    this.o = f;
                }
                if (d == 1) {
                    this.ah = e;
                    this.q = f;
                }
                if (d == 2) {
                    this.ag = e;
                    this.p = f;
                }
                if (d == 3) {
                    this.ai = e;
                    this.r = f;
                }
            }
            this.af = this.ad.createElement("span");
            this.af.setStyleProperty("position", "absolute");
            this.af.setStyleProperty("display", "none");
            c.append(this.af);
            this.j = new DOMEventProxy(this.ai, this.ad, false);
            let g = this.j;
            g.onMouseOver = delegateCombine(g.onMouseOver, runOn(this, this.an));
            let h = this.j;
            h.onMouseLeave = delegateCombine(h.onMouseLeave, runOn(this, this.am));
            let i = this.j;
            i.onMouseDown = delegateCombine(i.onMouseDown, runOn(this, this.al));
            let j = this.j;
            j.onMouseUp = delegateCombine(j.onMouseUp, runOn(this, this.ao));
            this.as();
        }
        aa() {
            let a = this.ak("ui-funnel-slice", "border-top-width", -1);
            return (a == null) ? -1 : parseInt(a);
        }
        m() {
            let a = this.l;
            if (a == null) {
                this.l = FontUtil.getFontForClass(this.ad, "ui-funnel-slice");
                a = this.l;
            }
            return a;
        }
        n() {
            let a = this.k;
            if (a == null) {
                this.k = a = FontUtil.getFont(this.ad);
            }
            return a;
        }
        ab() {
            let a = this.z;
            if (a < 0) {
                let b = this.l;
                a = FontUtil.getCurrentFontHeight(this.ad, b);
                this.z = a;
            }
            return a;
        }
        ac() {
            let a = this.y;
            if (a < 0) {
                let b = this.k;
                a = FontUtil.getCurrentFontHeight(this.ad, b);
                this.y = a;
            }
            return a;
        }
        d(a) {
            if (this.c != null) {
                return a ? this.c : this.e;
            }
            let b = BrushUtil.f("chart", this.ad, this.c, this.e);
            this.c = b.p2;
            this.e = b.p3;
            return a ? this.c : this.e;
        }
        ak(a, b, c) {
            let d = this.af;
            if (d == null) {
                return null;
            }
            d.addClass(a);
            let e = d.getStyleProperty(b);
            if (e == null || e.length == 0 || e == "null" || e == "transparent") {
                e = null;
            }
            if (c >= 0) {
                let f = new Brush();
                if (e != null && e.length != stringReplace(e, "(0, 0, 0, 0", "").length) {
                    e = null;
                }
                f._fill = e == null ? XamFunnelView.a[c % XamFunnelView.a.length] : e;
                this.c.item(c, f);
                let g = null;
                if (e != null) {
                    g = d.getStyleProperty("border-top-color");
                    if (g == null || g.length == 0 || g == "null" || g == "transparent") {
                        g = e;
                    }
                }
                f = new Brush();
                f._fill = (g == null) ? XamFunnelView.b[c % XamFunnelView.b.length] : g;
                this.e.item(c, f);
            }
            d.removeClass(a);
            return e;
        }
        a7(a, b, c) {
            let d = new PropertyChangedMessage();
            d.g = a;
            d.e = b;
            d.d = c;
            this.f.i(d);
        }
        constructor() {
            super();
            this.g = null;
            this.h = null;
            this.f = null;
            this.bg = null;
            this.ad = null;
            this.ae = null;
            this.ah = null;
            this.ai = null;
            this.ag = null;
            this.af = null;
            this.o = null;
            this.q = null;
            this.r = null;
            this.p = null;
            this.j = null;
            this.be = null;
            this.bf = null;
            this.k = null;
            this.l = null;
            this.x = -1;
            this.y = -1;
            this.z = -1;
            this.u = 0;
            this.v = 0;
            this.aj = null;
            this.c = null;
            this.e = null;
            this.t = 1;
            this.w = NaN;
            this.t = 1;
            this.w = NaN;
            this.f = new MessageChannel();
            this.a9();
            this.a8();
            let a = this.g = new MessageHandler();
            a.b(ClearMessage.$, runOn(this, this.ap));
            a.b(RenderSliceMessage.$, runOn(this, this.a6));
            a.b(RenderOuterLabelMessage.$, runOn(this, this.a5));
            a.b(SetAreaSizeMessage.$, runOn(this, this.ba));
            a.b(TooltipValueChangedMessage.$, runOn(this, this.bc));
            a.b(TooltipUpdateMessage.$, runOn(this, this.bb));
            a.b(ClearTooltipMessage.$, runOn(this, this.ar));
            a.b(PropertyChangedMessage.$, runOn(this, this.a3));
            a.b(ContainerSizeChangedMessage.$, (b) => this.as());
            this.as();
        }
        av(a) {
            let b = a.bs;
            let c = a.bn;
            if (!isNaN_(b) && b != 0) {
                return;
            }
            if (window.devicePixelRatio != undefined && window.devicePixelRatio != c) {
                a.bn = window.devicePixelRatio;
            }
        }
        aw(a) {
            this.g.c(a);
        }
        a1(a, b) {
            if (a != null) {
                let c = typeCast(MessageChannel.$, a.b("RenderingMessages"));
                if (c != null) {
                    c.h(runOn(this, this.aw));
                }
                this.f.g();
            }
            if (b != null) {
                let d = typeCast(MessageChannel.$, b.b("RenderingMessages"));
                if (d != null) {
                    d.e(runOn(this, this.aw));
                }
                let e = typeCast(MessageChannel.$, b.b("InteractionMessages"));
                this.f.f(e);
            }
        }
        bd(a, b, c, d, e) {
            a.setAttribute("width", b.toString());
            a.setAttribute("height", c.toString());
            a.setStyleProperty("width", d.toString() + "px");
            a.setStyleProperty("height", e.toString() + "px");
        }
        as() {
            if (this.ad == null) {
                return;
            }
            let a = this.ad.rootWrapper.width();
            let b = this.ad.rootWrapper.height();
            this.bg = new Rect(0, 0, 0, a, b);
            if (this.j != null) {
                this.j.bl = this.bg;
            }
            this.bd(this.ae, a * this.t, b * this.t, a, b);
            this.bd(this.ah, a * this.t, b * this.t, a, b);
            this.bd(this.ag, a * this.t, b * this.t, a, b);
            this.bd(this.ai, a * this.t, b * this.t, a, b);
            let c = new ViewportChangedMessage();
            c.e = a;
            c.d = b;
            this.f.i(c);
        }
        a0() {
            this.as();
        }
        a9() {
            let a = new ViewPropertyChangedMessage();
            a.g = "OuterLabelWidthDecider";
            a.e = null;
            a.d = typeCast(IOuterLabelWidthDecider_$type, this);
            this.f.i(a);
        }
        a8() {
            let a = new ViewPropertyChangedMessage();
            a.g = "FunnelLabelSizeDecider";
            a.e = null;
            a.d = typeCast(IFunnelLabelSizeDecider_$type, this);
            this.f.i(a);
        }
        decideWidth(a) {
            let b = a == null ? null : a.a;
            if (b == null) {
                return 0;
            }
            let c = 0;
            this.p.ad(this.n());
            for (let d of fromEnum(b)) {
                if (d != null) {
                    c = Math.max(this.p.g(d.toString()), c);
                }
            }
            return c;
        }
        decideLabelSize(a, b) {
            let c = 0;
            if (a.b.i) {
                this.p.ad(this.m());
                c = this.p.g(a.b.v.toString());
            }
            return new Size(1, c, b ? this.ab() : this.ac());
        }
        s(a, f_) {
            if (f_ == null) {
                return true;
            }
            let b = a.a;
            let c_ = this.ad;
            c_ = c_ ? c_.data('igFunnelChart') : null;
            if (b == null || c_ == null) {
                return false;
            }
            let i_ = b.count;
            let c = new Array(i_);
            while (i_-- > 0) {
                let v_ = b.item(i_);
                c[i_] = f_(v_, i_, c_);
            }
            a.b(c);
            return true;
        }
        au() {
        }
        a2() {
        }
    }
    XamFunnelView.$t = /*@__PURE__*/ markType(XamFunnelView, 'XamFunnelView', Base.$, [IOuterLabelWidthDecider_$type, IFunnelLabelSizeDecider_$type]);
    XamFunnelView.a = ["#7000ff", "#70ff00", "#00f0f0", "#ff0070", "#ff00ff"];
    XamFunnelView.b = ["#7000dd", "#70dd00", "#00d0d0", "#dd0070", "#dd00dd"];
    return XamFunnelView;
})();
/**
 * @hidden
 */
export let XamFunnelController = /*@__PURE__*/ (() => {
    class XamFunnelController extends Base {
        constructor() {
            super();
            this.bp = null;
            this.ag = null;
            this.at = null;
            this.cf = null;
            this.cg = null;
            this.cb = null;
            this.cc = null;
            this.bb = false;
            this.bg = false;
            this.au = null;
            this.aj = null;
            this.z = null;
            this.al = null;
            this.ao = null;
            this.ap = null;
            this.cl = null;
            this.ci = null;
            this.ch = null;
            this.a4 = false;
            this.bv = 0;
            this.bu = 0;
            this.w = null;
            this.v = null;
            this.t = null;
            this.p = null;
            this.a0 = false;
            this.a3 = false;
            this.bt = 0;
            this.a2 = false;
            this.bq = 0;
            this.a = null;
            this.b = null;
            this.ad = 0;
            this.m = 0;
            this.ax = false;
            this.bs = 0;
            this.a5 = false;
            this.dv = null;
            this.du = null;
            this.aw = false;
            this.b5 = 0;
            this.b6 = 0;
            this.r = null;
            this.ab = null;
            this.ah = null;
            this.g = null;
            this.e = null;
            this.f = null;
            this.d0 = null;
            this.d1 = null;
            this.a7 = false;
            this.a1 = false;
            this.a6 = false;
            this.az = false;
            this.ck = null;
            this.cj = null;
            this.br = -1;
            this.ay = false;
            this.l = null;
            this.o = null;
            this.dp = null;
            this.dn = null;
            this.dz = null;
            this.av = new DoubleAnimator(0, 1, 2000);
            let a = this.av;
            a.propertyChanged = delegateCombine(a.propertyChanged, runOn(this, this.cz));
            this.k = new FunnelFrame();
            this.j = new FunnelFrame();
            this.h = new FunnelFrame();
            this.ai = new SliceSelectionManager();
            this.am = new DoubleColumn();
            this.ar = new ObjectColumn();
            this.as = new ObjectColumn();
            this.y = new MessageChannel();
            this.x = new MessageChannel();
            this.aa = new MessageHandler();
            this.aa.b(PropertyChangedMessage.$, runOn(this, this.de));
            this.aa.b(DataUpdatedMessage.$, runOn(this, this.cv));
            this.aa.b(ViewportChangedMessage.$, runOn(this, this.dl));
            this.aa.b(ViewPropertyChangedMessage.$, runOn(this, this.dm));
            this.aa.b(MouseMoveMessage.$, runOn(this, this.c5));
            this.aa.b(MouseButtonMessage.$, runOn(this, this.c3));
            this.aa.b(MouseLeaveMessage.$, runOn(this, this.c4));
            this.aa.b(UserSelectedItemsChangedMessage.$, runOn(this, this.dk));
            this.aa.b(LabelSizeChangedMessage.$, runOn(this, this.c1));
            this.aa.b(ContainerSizeChangedMessage.$, (b) => this.y.i(b));
            this.bp = (b, c) => {
                this.bj = true;
                this.df();
            };
        }
        cz(a, b) {
            this.b2 = this.av.o;
            if (this.b2 == 1) {
                this.a9 = false;
                this.cw(this.h);
            }
            if (this.a9) {
                let c = 1 - this.b2;
                FunnelFrame.k(this.j, this.k, this.h, this.b2);
                this.cw(this.j);
            }
        }
        get av() {
            return this.au;
        }
        set av(a) {
            this.au = a;
        }
        get ak() {
            return this.aj;
        }
        set ak(a) {
            this.aj = a;
        }
        get aa() {
            return this.z;
        }
        set aa(a) {
            this.z = a;
        }
        get am() {
            return this.al;
        }
        set am(a) {
            this.al = a;
        }
        get ar() {
            if (!this.bb && this.at != null) {
                this.bb = this.at.s(this.ao, this.cb);
            }
            return this.ao;
        }
        set ar(a) {
            this.ao = a;
        }
        get as() {
            if (!this.bg && this.at != null) {
                this.bg = this.at.s(this.ap, this.cc);
            }
            return this.ap;
        }
        set as(a) {
            this.ap = a;
        }
        get cq() {
            return this.cl;
        }
        set cq(a) {
            this.cl = a;
        }
        get cn() {
            return this.ci;
        }
        set cn(a) {
            this.ci = a;
        }
        get cm() {
            return this.ch;
        }
        set cm(a) {
            this.ch = a;
        }
        get bj() {
            return this.a4;
        }
        set bj(a) {
            this.a4 = a;
        }
        get b4() {
            return this.bv;
        }
        set b4(a) {
            this.bv = a;
        }
        get b3() {
            return this.bu;
        }
        set b3(a) {
            this.bu = a;
        }
        get y() {
            return this.w;
        }
        set y(a) {
            this.w = a;
        }
        get x() {
            return this.v;
        }
        set x(a) {
            this.v = a;
        }
        get u() {
            return this.t;
        }
        set u(a) {
            this.t = a;
        }
        get q() {
            return this.p;
        }
        set q(a) {
            this.p = a;
        }
        get bc() {
            return this.a0;
        }
        set bc(a) {
            this.a0 = a;
        }
        get bh() {
            return this.a3;
        }
        set bh(a) {
            this.a3 = a;
        }
        get b2() {
            return this.bt;
        }
        set b2(a) {
            this.bt = a;
        }
        get be() {
            return this.a2;
        }
        set be(a) {
            this.a2 = a;
        }
        get bw() {
            return this.bq;
        }
        set bw(a) {
            this.bq = a;
        }
        get c() {
            if ((this.a == null || this.a.count < 1) && this.at != null) {
                this.a = this.at.d(true);
            }
            return this.a;
        }
        set c(a) {
            this.a = a;
        }
        get d() {
            if ((this.b == null || this.b.count < 1) && this.at != null) {
                this.b = this.at.d(false);
            }
            return this.b;
        }
        set d(a) {
            this.b = a;
        }
        get ae() {
            return this.ad;
        }
        set ae(a) {
            this.ad = a;
        }
        get n() {
            return this.m;
        }
        set n(a) {
            this.m = a;
        }
        get a9() {
            return this.ax;
        }
        set a9(a) {
            this.ax = a;
        }
        get b1() {
            return this.bs;
        }
        set b1(a) {
            this.bs = a;
        }
        get bm() {
            return this.a5;
        }
        set bm(a) {
            this.a5 = a;
        }
        get dy() {
            return this.dv;
        }
        set dy(a) {
            this.dv = a;
        }
        get dx() {
            return this.du;
        }
        set dx(a) {
            this.du = a;
        }
        get a8() {
            return this.aw;
        }
        set a8(a) {
            this.aw = a;
        }
        get b9() {
            return this.b5;
        }
        set b9(a) {
            this.b5 = a;
        }
        get ca() {
            return this.b6;
        }
        set ca(a) {
            this.b6 = a;
        }
        get s() {
            return this.r;
        }
        set s(a) {
            this.r = a;
        }
        get ac() {
            return this.ab;
        }
        set ac(a) {
            let b = this.ab;
            this.ab = a;
            this.c7(b, this.ab);
        }
        get ai() {
            return this.ah;
        }
        set ai(a) {
            this.ah = a;
        }
        get k() {
            return this.g;
        }
        set k(a) {
            this.g = a;
        }
        get h() {
            return this.e;
        }
        set h(a) {
            this.e = a;
        }
        get j() {
            return this.f;
        }
        set j(a) {
            this.f = a;
        }
        get d3() {
            return this.d0;
        }
        set d3(a) {
            this.d0 = a;
        }
        get d4() {
            return this.d1;
        }
        set d4(a) {
            this.d1 = a;
        }
        get bo() {
            return this.a7;
        }
        set bo(a) {
            this.a7 = a;
        }
        get bd() {
            return this.a1;
        }
        set bd(a) {
            this.a1 = a;
        }
        get bn() {
            return this.a6;
        }
        set bn(a) {
            this.a6 = a;
        }
        get ba() {
            return this.az;
        }
        set ba(a) {
            this.az = a;
        }
        get cp() {
            return this.ck;
        }
        set cp(a) {
            this.ck = a;
        }
        get co() {
            return this.cj;
        }
        set co(a) {
            this.cj = a;
        }
        get bz() {
            let a = this.br;
            if (a < 0 && this.at != null) {
                this.br = this.at.aa();
                a = this.br;
            }
            return a < 0 ? 1 : a;
        }
        c7(a, b) {
            if (a != null) {
                let c = typeCast(MessageChannel.$, a.b("ConfigurationMessages"));
                if (c != null) {
                    c.h(runOn(this, this.c2));
                }
                c = typeCast(MessageChannel.$, a.b("InteractionMessages"));
                if (c != null) {
                    c.h(runOn(this, this.c2));
                }
                this.y.g();
                this.x.g();
            }
            if (b != null) {
                let d = typeCast(MessageChannel.$, b.b("ConfigurationMessages"));
                if (d != null) {
                    d.e(runOn(this, this.c2));
                }
                d = typeCast(MessageChannel.$, b.b("InteractionMessages"));
                if (d != null) {
                    d.e(runOn(this, this.c2));
                }
                let e = typeCast(MessageChannel.$, b.b("RenderingMessages"));
                this.y.f(e);
                let f = typeCast(MessageChannel.$, b.b("ModelUpdateMessages"));
                this.x.f(f);
            }
            this.bj = true;
        }
        c2(a) {
            this.aa.c(a);
            let b = typeCast(RenderingMessage.$, a);
            if (b != null) {
                this.bj = b.c;
            }
            this.df();
        }
        bl() {
            return this.b3 >= 0 && this.b4 >= 0;
        }
        bf() {
            return this.am != null && this.am.a != null && this.am.a.count > 0 && this.u != null && this.q != null && this.c != null && this.c.count > 0 && this.d != null && this.d.count > 0 && this.bl();
        }
        df() {
            if (!this.bj) {
                return;
            }
            if (!this.bf()) {
                this.cu();
                return;
            }
            this.bj = false;
            let a = this.u.decideWidth(this.aq());
            if (a > this.b4) {
                a = 0;
            }
            if (!this.bh) {
                a = 0;
            }
            let b = this.b4 - a;
            let c = a > 0;
            let d = this.bc;
            let e = b >= 0;
            if (e || c) {
                this.dc(e, c, d, b, a);
            }
        }
        cu() {
            if (this.bk() && this.b2 > 0) {
                this.av.w();
            }
            this.dh("LeftLabels");
            this.dh("RightLabels");
            this.dh("SliceArea");
            this.ct();
            this.h.b.clear();
            this.j.b.clear();
            this.k.b.clear();
        }
        ct() {
            let a = new FrameRenderCompleteMessage();
            this.y.i(a);
        }
        dc(a, b, c, d, e) {
            if (this.a9) {
                let f = this.k;
                this.k = this.j;
                this.j = f;
            }
            else {
                let g = this.k;
                this.k = this.h;
                this.h = g;
            }
            this.dd(this.h, a, b, c, d, e);
            this.av.w();
            this.b2 = 0;
            if (this.bk()) {
                FunnelFrame.k(this.j, this.k, this.h, this.b2);
                this.cw(this.j);
                this.a9 = true;
                this.av.v();
            }
            else {
                this.cw(this.h);
            }
        }
        b0(a) {
            if (isNaN_(a)) {
                return 0;
            }
            return Math.abs(a);
        }
        dd(a, b, c, d, e, f) {
            let g = e / 2;
            this.ay = this.bm;
            if (this.ay) {
                this.c0(e, g);
            }
            else {
                this.ak = null;
            }
            let h = this.n == 1;
            let i = this.an();
            let j = 0;
            for (let k of fromEnum(i.a)) {
                j += this.b0(this.am.a.item(k));
            }
            if (j == 0) {
                h = false;
            }
            let l = this.b3 / i.a.count;
            let m = 0;
            let n = 0;
            n = this.bz / 2;
            a.j = f;
            a.f = d;
            a.h = c;
            a.g = this.ae == 0;
            a.b = new SliceInfoList();
            let o = 0;
            for (let p of fromEnum(i.a)) {
                let q;
                if (h) {
                    q = (this.b0(this.am.a.item(p)) / j) * this.b3;
                }
                else {
                    q = l;
                }
                let r = this.by(e, m + n);
                let s = m + q;
                let t = this.by(e, s - n);
                let u = r / 2;
                let v = t / 2;
                let w = new SliceInfo();
                let x = w.b;
                x.o = m;
                x.n = s;
                let y = new Rect(4);
                let z = new Rect(4);
                let aa = 0;
                if (v > u) {
                    aa = g - v;
                }
                else {
                    aa = g - u;
                }
                let ab = m;
                x.ad = this.ds(p);
                x.ag = this.dt(p);
                x.a0 = this.d2(p);
                x.j = this.ai.c(p);
                if (b) {
                    w.h = true;
                    x.ar = { $type: Point_$type, x: g - u - aa + n, y: m - ab + n };
                    x.as = { $type: Point_$type, x: g + u - aa - n, y: m - ab + n };
                    x.ao = { $type: Point_$type, x: g - v - aa + n, y: s - ab - n };
                    x.ap = { $type: Point_$type, x: g + v - aa - n, y: s - ab - n };
                    if (this.ay) {
                        this.cr(x, m + n, s - n, g, aa - n, ab);
                    }
                    x.x();
                }
                if (d) {
                    x.i = true;
                    x.an = { $type: Point_$type, x: g - aa, y: (m + s) / 2 - ab };
                    x.v = this.cd(p);
                    let ac = this.q.decideLabelSize(w, true);
                    if (ac.width > e) {
                        x.i = false;
                    }
                    if (ac.height > q) {
                        x.i = false;
                    }
                    y.height = ac.height;
                    y.width = ac.width;
                    y.x = x.an.x;
                    y.y = x.an.y;
                    x.ax = y;
                }
                else {
                    x.i = false;
                    x.v = this.cd(p);
                }
                if (d || b) {
                    x.aq = { $type: Point_$type, x: aa, y: ab };
                    x.item = this.am.a.item(p);
                    x.s = p;
                }
                if (c) {
                    w.g = true;
                    w.n = { $type: Point_$type, x: 0, y: (m + s) / 2 };
                    w.l = this.ce(p);
                    let ad = this.q.decideLabelSize(w, false);
                    if (ad.height > q) {
                        w.g = false;
                    }
                    z.height = ad.height;
                    z.width = ad.width;
                    y.x = w.n.x;
                    y.y = w.n.y;
                    x.ay = z;
                }
                else {
                    w.g = false;
                    w.l = this.ce(p);
                }
                w.j = p;
                a.b.add(w);
                m += q;
                o++;
            }
            if ((this.ar != null && this.ar.a != null && this.ar.a.count > 0) || (this.as != null && this.as.a != null && this.as.a.count > 0)) {
                this.dg(a);
            }
            a.b.ae();
        }
        cr(a, b, c, d, e, f) {
            let g = this.ak.b(b);
            let h = this.ak.b(c);
            let i = new PointList();
            let j = new PointList();
            let k = g.b;
            let l = h.b;
            for (let m = k; m <= l; m++) {
                i.add({ $type: Point_$type, x: this.ak.e._inner[m].c.x - e, y: this.ak.e._inner[m].c.y - f });
            }
            e += this.bz;
            for (let n = l; n >= k; n--) {
                let o = this.ak.e._inner[n].c;
                j.add({ $type: Point_$type, x: d + d - o.x - e, y: o.y - f });
            }
            a.c = i;
            a.e = j;
        }
        bi(a, b) {
            if (a.x != b.x || a.y != b.y) {
                return true;
            }
            return false;
        }
        c0(a, b) {
            let c;
            let d;
            let e = 0, f = this.b3;
            e = this.bz / 2;
            f -= e;
            if (this.bd) {
                c = { $type: Point_$type, x: b - (a * this.bw / 2), y: e };
                d = { $type: Point_$type, x: b - (a / 2), y: f };
            }
            else {
                c = { $type: Point_$type, x: b - (a / 2), y: e };
                d = { $type: Point_$type, x: b - (a * this.bw / 2), y: f };
            }
            let g = this.dy.y < this.dx.y ? this.dy : this.dx;
            let h = this.dx.y > this.dy.y ? this.dx : this.dy;
            if (g.y < 0) {
                g.y = 0;
            }
            if (h.y > 1) {
                h.y = 1;
            }
            if (this.bd) {
                let i = h.x;
                h.x = g.x;
                g.x = i;
                i = g.y;
                g.y = 1 - h.y;
                h.y = 1 - i;
            }
            let j = { $type: Point_$type, x: a * g.x, y: this.b3 * g.y };
            let k = { $type: Point_$type, x: a * h.x, y: this.b3 * h.y };
            if (this.ak == null || this.bi(c, this.ak.q) || this.bi(j, this.ak.r) || this.bi(k, this.ak.s) || this.bi(d, this.ak.t)) {
                this.ak = new Bezier(c, j, k, d, 2, b);
            }
            if (this.ak == null) {
                this.ay = false;
            }
            else {
                this.ay = this.ak.d;
            }
        }
        ce(a) {
            let b = this.as;
            let c = b == null ? null : b.a;
            return c == null || a >= c.count ? null : c.item(a);
        }
        cd(a) {
            let b = this.ar;
            let c = b == null ? null : b.a;
            return c == null || a >= c.count ? null : c.item(a);
        }
        d2(a) {
            if (this.ai.c(a)) {
                return this.d3;
            }
            if (this.ai.d(a) && this.bo) {
                return this.d4;
            }
            return null;
        }
        dt(a) {
            return this.d.item(a % this.d.count);
        }
        ds(a) {
            return this.c.item(a % this.c.count);
        }
        by(a, b) {
            let c = a * this.bw;
            if (this.ay) {
                let d = this.ak.b(b).c.x;
                return ((a / 2) - d) * 2;
            }
            else {
                if (this.bd) {
                    return a - ((a - c) * ((this.b3 - b) / this.b3));
                }
                else {
                    return a - ((a - c) * (b / this.b3));
                }
            }
        }
        an() {
            let a = new IntColumn();
            a.b(this.am.a.count);
            a.c((b, c) => {
                if (this.am.a.item(b) < this.am.a.item(c)) {
                    return this.bd ? -1 : 1;
                }
                if (this.am.a.item(b) > this.am.a.item(c)) {
                    return this.bd ? 1 : -1;
                }
                return 0;
            });
            return a;
        }
        cw(a) {
            this.cx(a);
        }
        cy() {
            if (this.l != null) {
                this.cx(this.l);
            }
        }
        cx(a) {
            this.dh("LeftLabels");
            this.dh("RightLabels");
            this.dh("SliceArea");
            if (a.g) {
                this.di("LeftPanel", a.j);
                this.di("RightPanel", 0);
            }
            else {
                this.di("LeftPanel", 0);
                this.di("RightPanel", a.j);
            }
            this.ag = a.b;
            for (let b of fromEnum(a.b)) {
                if (b.h) {
                    let c = new RenderSliceMessage();
                    c.e = "SliceArea";
                    c.g = b.b;
                    c.h = this.bz;
                    this.y.i(c);
                }
            }
            for (let d of fromEnum(a.b)) {
                if (d.g) {
                    let e = new RenderOuterLabelMessage();
                    if (a.g) {
                        e.e = "LeftLabels";
                    }
                    else {
                        e.e = "RightLabels";
                    }
                    e.j = d.l;
                    e.l = d.n;
                    e.h = a.j;
                    e.f = d;
                    this.y.i(e);
                }
            }
            let f = new FrameRenderCompleteMessage();
            this.y.i(f);
        }
        di(a, b) {
            let c = new SetAreaSizeMessage();
            c.e = a;
            c.i = true;
            c.m = b;
            this.y.i(c);
        }
        bk() {
            return this.b1 > 0;
        }
        dh(a) {
            let b = new ClearMessage();
            b.e = a;
            this.y.i(b);
        }
        aq() {
            return this.as;
        }
        cv(a) {
            this.bj = true;
        }
        b7(a) {
            return Convert.toInt32(a);
        }
        de(a) {
            let b = a;
            let c = b.d;
            switch (b.g) {
                case "TextStyle":
                    this.cp = c != null ? c.toString() : "";
                    let d = new PropertyChangedMessage();
                    d.g = b.g;
                    d.e = b.e;
                    d.d = c;
                    this.y.i(d);
                    this.bj = true;
                    break;
                case "OuterLabelTextStyle":
                    this.co = c != null ? c.toString() : "";
                    let e = new PropertyChangedMessage();
                    e.g = b.g;
                    e.e = b.e;
                    e.d = c;
                    this.y.i(e);
                    this.bj = true;
                    break;
                case "ValueColumn":
                    this.am.b(c);
                    this.bj = true;
                    break;
                case "InnerLabelColumn":
                    this.bb = false;
                    this.cf = c;
                    this.ar.b(c);
                    this.bj = true;
                    break;
                case "InnerLabelVisibility":
                    this.bc = c;
                    this.bj = true;
                    break;
                case "OuterLabelVisibility":
                    this.bh = c;
                    this.bj = true;
                    break;
                case "OuterLabelColumn":
                    this.bg = false;
                    this.cg = c;
                    this.as.b(c);
                    this.bj = true;
                    break;
                case "ValueMemberPath":
                    this.cq = typeCast(String_$type, c);
                    break;
                case "OuterLabelMemberPath":
                    this.cn = typeCast(String_$type, c);
                    break;
                case "InnerLabelMemberPath":
                    this.cm = typeCast(String_$type, c);
                    break;
                case "BottomEdgeWidth":
                    this.bw = c;
                    if (this.bw > 1) {
                        this.bw = 1;
                    }
                    if (this.bw < 0.001) {
                        this.bw = 0.001;
                    }
                    this.bj = true;
                    break;
                case "Brushes":
                    if (b.e != null) {
                        let f = b.e;
                        f.collectionChanged = delegateRemove(f.collectionChanged, this.bp);
                    }
                    if (c != null) {
                        let g = c;
                        g.collectionChanged = delegateCombine(g.collectionChanged, this.bp);
                    }
                    this.c = typeCast(BrushCollection.$, c);
                    this.bj = true;
                    break;
                case "Outlines":
                    this.d = typeCast(BrushCollection.$, c);
                    this.bj = true;
                    break;
                case "OuterLabelAlignment":
                    this.ae = EnumUtil.getEnumValue(OuterLabelAlignment_$type, c);
                    this.bj = true;
                    break;
                case "FunnelSliceDisplay":
                    this.n = EnumUtil.getEnumValue(FunnelSliceDisplay_$type, c);
                    this.bj = true;
                    break;
                case "FormatInnerLabel":
                    this.ar.b(this.cf);
                    this.bb = false;
                    this.cb = c;
                    this.bj = true;
                    break;
                case "FormatOuterLabel":
                    this.as.b(this.cg);
                    this.cc = c;
                    this.bg = false;
                    this.bj = true;
                    break;
                case "IsInverted":
                    this.bd = c;
                    this.bj = true;
                    break;
                case "TransitionDuration":
                    this.av.r = this.b7(c);
                    this.b1 = this.av.r;
                    break;
                case "AllowSliceSelection":
                    this.a8 = c;
                    break;
                case "SelectedSliceStyle":
                    this.d3 = c;
                    this.bj = true;
                    break;
                case "UnselectedSliceStyle":
                    this.d4 = c;
                    this.bj = true;
                    break;
                case "UseUnselectedStyle":
                    this.bo = c;
                    this.bj = true;
                    break;
                case "UseBezierCurve":
                    this.bm = c;
                    this.bj = true;
                    break;
                case "UpperBezierControlPoint":
                    this.dy = c;
                    this.bj = true;
                    break;
                case "LowerBezierControlPoint":
                    this.dx = c;
                    this.bj = true;
                    break;
                case "ItemProvider":
                    this.s = c;
                    break;
                case "ToolTip":
                    let h = new TooltipValueChangedMessage();
                    if (c != null) {
                        this.ba = true;
                    }
                    else {
                        this.ba = false;
                        let i = new ClearTooltipMessage();
                        this.y.i(i);
                    }
                    h.g = c;
                    this.y.i(h);
                    break;
                case "Legend":
                    this.c6(c);
                    this.bj = true;
                    break;
                case "LegendItemTemplate":
                    this.dr = c;
                    this.bj = true;
                    break;
                case "LegendItemBadgeTemplate":
                    this.dq = c;
                    this.bj = true;
                    break;
                case "UseOuterLabelsForLegend":
                    this.bn = c;
                    this.bj = true;
                    break;
                case "OutlineThickness":
                    this.br = c;
                    this.bj = true;
                    this.y.i(b);
                    break;
                case "Container":
                case "PixelScalingRatio":
                case "ActualPixelScalingRatio":
                case "OuterLabelTextColor":
                case "LabelTextColor":
                    if (b.g == "Container") {
                        let j = b.d;
                        this.av.u(j);
                    }
                    let k = new PropertyChangedMessage();
                    k.g = b.g;
                    k.e = b.e;
                    k.d = c;
                    this.y.i(k);
                    break;
            }
        }
        get dr() {
            return this.dp;
        }
        set dr(a) {
            this.dp = a;
        }
        get dq() {
            return this.dn;
        }
        set dq(a) {
            this.dn = a;
        }
        c6(a) {
            if (this.o != null) {
                this.o.clearLegendItemsForSeries(this.ac.b("Model"));
            }
            this.o = a;
        }
        dg(a) {
            let b = new List$1(UIElement.$, 0);
            for (let c of fromEnum(a.b)) {
                let d = new ContentControl();
                let e = "";
                if (c.b.v != null) {
                    if (this.bn && c.l != null) {
                        e = c.l.toString();
                    }
                    else {
                        e = c.b.v.toString();
                    }
                }
                else if (c.l != null) {
                    e = c.l.toString();
                }
                let f = null;
                let g = null;
                if (f == null && c.b.ad != null) {
                    f = c.b.ad;
                }
                if (g == null && c.b.ag != null) {
                    g = c.b.ag;
                }
                let h = null;
                if (this.s != null) {
                    h = this.s.getItem(c.b.s);
                }
                d.content = ((() => {
                    let $ret = new FunnelSliceDataContext();
                    $ret.series = this.ac.b("Model");
                    $ret.item = h;
                    $ret.itemBrush = f;
                    $ret.itemLabel = e;
                    $ret.thickness = this.bz;
                    $ret.outline = g;
                    $ret.itemOutline = g;
                    return $ret;
                })());
                d.ah = this.dr;
                b.add(d);
            }
            if (this.o != null) {
                if (this.o.isItemwise) {
                    let i = this.o;
                    i.createItemwiseLegendItems(b, this.ac.b("Model"));
                }
            }
        }
        dm(a) {
            let b = a;
            switch (b.g) {
                case "OuterLabelWidthDecider":
                    this.u = typeCast(IOuterLabelWidthDecider_$type, b.d);
                    this.bj = true;
                    break;
                case "FunnelLabelSizeDecider":
                    this.q = typeCast(IFunnelLabelSizeDecider_$type, b.d);
                    this.bj = true;
                    break;
            }
        }
        dl(a) {
            let b = a;
            this.b4 = b.e;
            this.b3 = b.d;
            this.bj = true;
        }
        c3(a) {
            let b = a;
            if (b.e == 1) {
                return;
            }
            if (b.c == 1) {
                this.ca = this.b9;
            }
            else if (b.c == 0) {
                let c = this.ca;
                this.ca = -1;
                if (b.f == 0) {
                }
                else if (b.f != 2) {
                    return;
                }
                if (c == this.b9) {
                    this.c8(c);
                }
            }
        }
        c8(a) {
            if (a < 0 || a > this.am.a.count - 1) {
                return;
            }
            if (this.a8) {
                this.ai.k(a, this.am.a.item(a));
                let b = this.ai.a();
                let c = new SelectedItemsChangedMessage();
                c.c = b;
                this.x.i(c);
                this.bj = true;
            }
            let d = new SliceClickedMessage();
            d.c = a;
            d.item = this.am.a.item(a);
            d.f = this.dz;
            this.x.i(d);
        }
        da(a) {
            if (this.am != null && a >= 0 && a < this.am.a.count) {
                let b = new SliceMouseMessage();
                b.e = a;
                b.item = this.am.a.item(a);
                b.c = 0;
                b.i = this.dz;
                this.x.i(b);
            }
        }
        db(a, b) {
            if (this.am != null && a >= 0 && a < this.am.a.count) {
                let c = new SliceMouseMessage();
                c.e = a;
                c.item = this.am.a.item(a);
                c.c = 2;
                c.i = this.dz;
                c.h = b;
                this.x.i(c);
            }
        }
        c9(a) {
            if (this.am != null && a >= 0 && a < this.am.a.count) {
                let b = new SliceMouseMessage();
                b.e = a;
                b.item = this.am.a.item(a);
                b.c = 1;
                b.i = this.dz;
                this.x.i(b);
            }
        }
        c5(a) {
            let b = a;
            let c = this.b9;
            this.b9 = this.b8(b.c);
            if (c != this.b9) {
                if (c != -1) {
                    this.da(c);
                }
                if (this.b9 != -1) {
                    this.c9(this.b9);
                }
            }
            else {
                if (this.b9 != -1) {
                    this.db(this.b9, b.c);
                }
            }
            if (this.ba) {
                this.dj(b.c);
            }
        }
        c4(a) {
            let b = this.b9;
            this.b9 = -1;
            if (b != -1) {
                this.da(b);
            }
            let c = new ClearTooltipMessage();
            this.y.i(c);
        }
        dj(a) {
            let b = new FunnelDataContext();
            if (this.s != null && this.b9 >= 0 && this.b9 < this.s.count) {
                b.item = this.s.getItem(this.b9);
            }
            b.b = this.b9;
            if (b.b < 0) {
                let c = new ClearTooltipMessage();
                this.y.i(c);
                return;
            }
            let d = new TooltipUpdateMessage();
            d.g = b;
            d.i = this.dw(a, b);
            this.y.i(d);
        }
        dw(a, b) {
            let c = { $type: Point_$type, x: a.x + 10, y: a.y + 10 };
            return c;
        }
        b8(a) {
            if (!this.bf()) {
                return -1;
            }
            let b = a.y;
            let c = a.x;
            let d = this.i();
            if (d.g) {
                c -= d.j;
            }
            let e = this.af(b);
            if (e == null) {
                return -1;
            }
            let f = this.bx();
            let g = this.by(f, b);
            let h = g / 2;
            let i = f / 2;
            let j = new Rect(0, e.b.ar.x, e.b.ar.y, Math.max(e.b.ap.x - e.b.ar.x, 0), Math.max(e.b.ap.y - e.b.ar.y, 0));
            if (c >= (i - h) && c <= (i + h)) {
                this.dz = j;
                return e.j;
            }
            else {
                return -1;
            }
        }
        bx() {
            let a = this.i();
            return this.b4 - a.j;
        }
        af(a) {
            let b = this.i();
            let c = b.b.ad(a);
            if (c >= 0 && c < b.b.count) {
                return b.b._inner[c];
            }
            return null;
        }
        i() {
            let a = null;
            if (this.a9) {
                a = this.j;
            }
            else {
                a = this.h;
            }
            return a;
        }
        dk(a) {
            let b = a;
            this.ai.i(b.c, this.am);
            this.bj = true;
        }
        c1(a) {
            this.cs(a);
        }
        cs(a) {
            let b = this.i();
            if (a.c == -1) {
                this.bj = true;
            }
            else {
                let c = b.b._inner[a.c];
                if (a.b) {
                    if (a.d.width > b.j) {
                        this.bj = true;
                    }
                    if (a.d.height != a.e.height) {
                        this.bj = true;
                    }
                    if (a.d.height > c.b.ap.y - c.b.as.y) {
                        this.bj = true;
                    }
                }
                else {
                    if (a.d.height > c.b.ap.y - c.b.as.y) {
                        this.bj = true;
                    }
                }
            }
        }
    }
    XamFunnelController.$t = /*@__PURE__*/ markType(XamFunnelController, 'XamFunnelController');
    return XamFunnelController;
})();
/**
 * @hidden
 */
export let XamFunnelChart = /*@__PURE__*/ (() => {
    class XamFunnelChart extends Control {
        constructor() {
            super();
            this.aq = null;
            this.as = null;
            this.ap = null;
            this.ax = null;
            this.bt = null;
            this.a2 = null;
            this.a0 = null;
            this.a1 = null;
            this.bu = null;
            this.bv = null;
            this.bk = new ObservableCollection$1(Base.$, 0);
            this.bh = new Dictionary$2(Base.$, Base.$, 0);
            this.b2 = null;
            this.b1 = null;
            this.sliceClicked = null;
            this.sliceEnter = null;
            this.sliceLeave = null;
            this.sliceHover = null;
            this.bz = null;
            this.bm = NaN;
            this.bl = 1;
            this.er = null;
            this.es = null;
            this.bl = 1;
            this.bm = NaN;
            let a = this.bk;
            a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.dt));
            this.ar = new MessageHandler();
            this.ar.b(SliceClickedMessage.$, runOn(this, this.dx));
            this.ar.b(SliceMouseMessage.$, runOn(this, this.dy));
            this.ar.b(SelectedItemsChangedMessage.$, runOn(this, this.du));
            this.ap = new MessageChannel();
            this.bt = (b, c) => this.db(c.action, c.position, c.count, c.propertyName);
            this.dv();
            this.ab = XamFunnelChart.$;
            this.ax = new XamFunnelConnector(new XamFunnelView(), this);
            this.legendItemTemplate = ((() => {
                let $ret = new DataTemplate();
                $ret.render = FunnelLegendTemplates.e;
                $ret.measure = FunnelLegendTemplates.c;
                return $ret;
            })());
            this.legendItemBadgeTemplate = ((() => {
                let $ret = new DataTemplate();
                $ret.render = FunnelLegendTemplates.d;
                $ret.measure = FunnelLegendTemplates.f;
                return $ret;
            })());
        }
        destroy() {
            this.provideContainer(null);
        }
        get ar() {
            return this.aq;
        }
        set ar(a) {
            this.aq = a;
        }
        dv() {
            this.dq(XamFunnelChart.$$p[1], 0, this.bo);
            this.dq(XamFunnelChart.$$p[6], enumGetBox(Visibility_$type, this.ez), enumGetBox(Visibility_$type, this.ez));
            this.dq(XamFunnelChart.$$p[13], enumGetBox(OuterLabelAlignment_$type, this.au), enumGetBox(OuterLabelAlignment_$type, this.au));
            this.dq(XamFunnelChart.$$p[4], enumGetBox(FunnelSliceDisplay_$type, this.ak), enumGetBox(FunnelSliceDisplay_$type, this.ak));
            this.dq(XamFunnelChart.$$p[22], this.ew, this.ew);
            this.dq(XamFunnelChart.$$p[12], this.ev, this.ev);
            this.dw();
        }
        dw() {
            let a = new PropertyChangedMessage();
            a.g = "ItemProvider";
            a.e = null;
            a.d = this;
            this.ap.i(a);
        }
        get at() {
            return this.as;
        }
        set at(a) {
            let b = this.as;
            this.as = a;
            this.dr(b, this.as);
        }
        dr(a, b) {
            if (a != null) {
                let c = typeCast(MessageChannel.$, a.b("ModelUpdateMessages"));
                if (c != null) {
                    c.h(runOn(this, this.dg));
                }
                this.ap.g();
            }
            if (b != null) {
                let d = typeCast(MessageChannel.$, b.b("ModelUpdateMessages"));
                if (d != null) {
                    d.e(runOn(this, this.dg));
                }
                let e = typeCast(MessageChannel.$, b.b("ConfigurationMessages"));
                this.ap.f(e);
            }
        }
        dg(a) {
            this.ar.c(a);
        }
        db(a, b, c, d) {
            let e = ((() => {
                let $ret = new DataUpdatedMessage();
                $ret.g = b;
                $ret.f = c;
                $ret.i = d;
                return $ret;
            })());
            switch (a) {
                case 3:
                    e.c = 3;
                    break;
                case 1:
                    e.c = 1;
                    break;
                case 0:
                    e.c = 0;
                    break;
                case 2:
                    e.c = 2;
                    break;
                case 4:
                    e.c = 4;
                    break;
            }
            this.dq("ValueColumn", this.a7, this.a7);
            this.dq("InnerLabelColumn", this.a3, this.a3);
            this.dq("OuterLabelColumn", this.a4, this.a4);
            this.ap.i(e);
        }
        get a7() {
            return this.a2;
        }
        set a7(a) {
            if (this.a2 != a) {
                let b = this.a2;
                this.a2 = a;
                this.dq("ValueColumn", b, this.a2);
            }
        }
        get a3() {
            return this.a0;
        }
        set a3(a) {
            if (this.a0 != a) {
                let b = this.a0;
                this.a0 = a;
                this.dq("InnerLabelColumn", b, this.a3);
            }
        }
        get a4() {
            return this.a1;
        }
        set a4(a) {
            if (this.a1 != a) {
                let b = this.a1;
                this.a1 = a;
                this.dq("OuterLabelColumn", b, this.a4);
            }
        }
        get bw() {
            return this.bu;
        }
        set bw(a) {
            let b = this.bu;
            this.bu = a;
            this.dq("FormatInnerLabel", b, a);
        }
        get bx() {
            return this.bv;
        }
        set bx(a) {
            let b = this.bv;
            this.bv = a;
            this.dq("FormatOuterLabel", b, a);
        }
        get bj() {
            return this.bk;
        }
        get cz() {
            return this.b2;
        }
        set cz(a) {
            let b = this.b2;
            this.b2 = a;
            this.dq("TextStyle", b, a);
        }
        get cr() {
            return this.b1;
        }
        set cr(a) {
            let b = this.b1;
            this.b1 = a;
            this.dq("OuterLabelTextStyle", b, a);
        }
        onDetachedFromUI() {
            this.ax.e.az();
        }
        onAttachedToUI() {
            this.ax.e.ax(this);
        }
        dq(a, b, c) {
            if (this.ba(a, b, c) || this.a9(a, b, c) || this.bc(a, b, c) || this.bb(a, b, c)) {
                return;
            }
            if (a == "PixelScalingRatio") {
                if (isNaN_(DeviceUtils.a(this.bs))) {
                    this.bn = 1;
                }
                else {
                    this.bn = DeviceUtils.a(this.bs);
                }
            }
            this.ap.i(((() => {
                let $ret = new PropertyChangedMessage();
                $ret.g = a;
                $ret.e = b;
                $ret.d = c;
                return $ret;
            })()));
        }
        a9(a, b, c) {
            if (a == XamFunnelChart.$$p[2] || a == XamFunnelChart.$$p[17]) {
                this.ap.i(((() => {
                    let $ret = new PropertyChangedMessage();
                    $ret.g = a;
                    $ret.e = b == null ? null : b;
                    $ret.d = c == null ? null : c;
                    return $ret;
                })()));
                return true;
            }
            return false;
        }
        ba(a, b, c) {
            if (a == XamFunnelChart.$$p[8]) {
                if (b != null) {
                    this.az = null;
                }
                if (c != null) {
                    this.bj.clear();
                    this.az = ((() => {
                        let $ret = new FastItemsSource();
                        $ret.e = this.itemsSource;
                        return $ret;
                    })());
                }
                return true;
            }
            else if (a == XamFunnelChart.$$p[3]) {
                if (b != null) {
                    let d = b;
                    d.event = delegateRemove(d.event, this.bt);
                }
                if (c != null) {
                    let e = c;
                    e.event = delegateCombine(e.event, this.bt);
                }
                this.de(a, b, c);
                return true;
            }
            else if (a == XamFunnelChart.$$p[26] || a == XamFunnelChart.$$p[5] || a == XamFunnelChart.$$p[14]) {
                this.de(a, b, c);
                return false;
            }
            return false;
        }
        a5(a, b) {
            return a.registerColumn(b, null, false);
        }
        a6(a, b) {
            return a.registerColumnObject(b, null, false);
        }
        de(a, b, c) {
            if (this.az == null) {
                let d = typeCast(FastItemsSource.$, b);
                if (d != null) {
                    if (this.a7 != null) {
                        d.deregisterColumn(this.a7);
                    }
                    if (this.a3 != null) {
                        d.deregisterColumn(this.a3);
                    }
                    if (this.a4 != null) {
                        d.deregisterColumn(this.a4);
                    }
                    this.a7 = null;
                    this.a3 = null;
                    this.a4 = null;
                }
                return;
            }
            if (b != null && typeof b === 'string') {
                switch (a) {
                    case XamFunnelChart.$$p[26]:
                        this.az.deregisterColumn(this.a7);
                        this.a7 = null;
                        break;
                    case XamFunnelChart.$$p[5]:
                        this.az.deregisterColumn(this.a3);
                        this.a3 = null;
                        break;
                    case XamFunnelChart.$$p[14]:
                        this.az.deregisterColumn(this.a4);
                        this.a4 = null;
                        break;
                }
            }
            if (c != null && typeCast(FastItemsSource.$, c) !== null) {
                if (this.c9 != null) {
                    this.a7 = this.a5(c, this.c9);
                }
                if (this.cd != null) {
                    this.a3 = this.a6(c, this.cd);
                }
                if (this.co != null) {
                    this.a4 = this.a6(c, this.co);
                }
            }
            if (c != null && typeof c === 'string') {
                switch (a) {
                    case XamFunnelChart.$$p[26]:
                        this.a7 = this.a5(this.az, this.c9);
                        break;
                    case XamFunnelChart.$$p[5]:
                        this.a3 = this.a6(this.az, this.cd);
                        break;
                    case XamFunnelChart.$$p[14]:
                        this.a4 = this.a6(this.az, this.co);
                        break;
                }
            }
        }
        bc(a, b, c) {
            if (a == XamFunnelChart.$$p[6] || a == XamFunnelChart.$$p[15]) {
                let d = EnumUtil.getEnumValue(Visibility_$type, b) == 0;
                let e = EnumUtil.getEnumValue(Visibility_$type, c) == 0;
                this.ap.i(((() => {
                    let $ret = new PropertyChangedMessage();
                    $ret.g = a;
                    $ret.d = e;
                    $ret.e = d;
                    return $ret;
                })()));
                return true;
            }
            return false;
        }
        bb(a, b, c) {
            if (a == XamFunnelChart.$$p[20]) {
                let d = new PropertyChangedMessage();
                d.g = a;
                if (b != null) {
                    d.e = b;
                }
                if (c != null) {
                    d.d = c;
                }
                this.ap.i(d);
                return true;
            }
            return false;
        }
        dx(a) {
            let b = a;
            if (this.sliceClicked != null) {
                let c = new FunnelSliceClickedEventArgs();
                c.index = b.c;
                c.bounds = b.f;
                if (this.az.count > b.c && b.c >= 0) {
                    c.item = this.az.item(b.c);
                }
                this.sliceClicked(this, c);
            }
        }
        dy(a) {
            let b = a;
            switch (b.c) {
                case 1:
                    {
                        if (this.sliceEnter != null) {
                            let c = new FunnelSliceEventArgs();
                            c.index = b.e;
                            c.bounds = b.i;
                            if (this.az.count > b.e && b.e >= 0) {
                                c.item = this.az.item(b.e);
                            }
                            this.sliceEnter(this, c);
                        }
                        break;
                    }
                case 0:
                    {
                        if (this.sliceLeave != null) {
                            let d = new FunnelSliceEventArgs();
                            d.index = b.e;
                            d.bounds = b.i;
                            if (this.az.count > b.e && b.e >= 0) {
                                d.item = this.az.item(b.e);
                            }
                            this.sliceLeave(this, d);
                        }
                        break;
                    }
                case 2:
                    {
                        if (this.sliceHover != null) {
                            let e = new FunnelSliceEventArgs();
                            e.index = b.e;
                            e.bounds = b.i;
                            e.position = b.h;
                            if (this.az.count > b.e && b.e >= 0) {
                                e.item = this.az.item(b.e);
                            }
                            this.sliceHover(this, e);
                        }
                        break;
                    }
            }
        }
        du(a) {
        }
        dt(a, b) {
        }
        df(a, b, c, d) {
            let e = new List$1(Base.$, 0);
            for (let f of fromEnum(a)) {
                if (!d.containsKey(f)) {
                    e.add1(f);
                }
            }
            for (let g of fromEnum(e)) {
                a.remove(g);
                b.removeItem(g);
            }
            for (let h of fromEnum(c)) {
                if (!b.containsKey(h)) {
                    a.add(h);
                    b.addItem(h, h);
                }
            }
        }
        getItem(a) {
            return this.az.item(a);
        }
        get count() {
            return this.az != null ? this.az.count : 0;
        }
        dd() {
            this.ax.i();
        }
        provideContainer(a) {
            let b = this.bz;
            this.bz = a;
            this.dq("Container", b, this.bz);
        }
        notifyResized() {
            this.ax.g();
            this.ap.i(new ContainerSizeChangedMessage());
        }
        dm(source_, a, b, c) {
            this.di(source_, new NotifyCollectionChangedEventArgs(2, 2, c, b, a));
        }
        dh(source_) {
            this.di(source_, new NotifyCollectionChangedEventArgs(0, 4));
        }
        dj(source_, a, b) {
            this.di(source_, new NotifyCollectionChangedEventArgs(1, 0, b, a));
        }
        dk(source_, a, b) {
            this.di(source_, new NotifyCollectionChangedEventArgs(1, 1, b, a));
        }
        di(s_, a) {
            if (s_.dataView && s_.dataSource) {
                s_ = s_.dataView();
            }
            ;
            if (s_ == this.itemsSource) {
                let b = this.az;
                if (b != null) {
                    b.handleCollectionChanged(a);
                }
            }
        }
        ay() {
            let a = this.ax;
            return a == null ? null : a.c;
        }
        av() {
            let a = this.ay();
            return a == null ? null : a.ai;
        }
        get ag() {
            let a = this.av();
            return a == null ? null : a.a();
        }
        set ag(a) {
            let b = this.av();
            if (b == null) {
                return;
            }
            let c = this.ay();
            b.f();
            let d = a == null ? 0 : a.length;
            while (d-- > 0) {
                b.k(a[d], c.am.a.item(a[d]));
            }
            c.bj = true;
            c.df();
        }
        dz(a) {
            let b = this.av();
            if (b == null) {
                return;
            }
            let c = this.ay();
            let d = c.am.a.item(a);
            if (d != null) {
                c.ai.k(a, d);
                c.bj = true;
                c.df();
            }
        }
        aw() {
            let a = new FunnelChartVisualData();
            let b = this.ax.c.ag;
            if (b != null) {
                for (let c = 0; c < b.count; c++) {
                    let d = b._inner[c].d();
                    a.slices.add(d);
                }
            }
            a.opacity = this._opacity;
            a.isInverted = this.bd;
            a.selectedItems = this.bj;
            a.name = this.name;
            a.viewport = new RectData(0, 0, this.ax.c.b4, this.ax.c.b3);
            return a;
        }
        b7() {
            let a = this.aw();
            a.scaleByViewport();
            return a.serialize();
        }
        resolveLegendIndex() {
            return -1;
        }
        forSubItems(a) {
        }
        get bs() {
            return this.bm;
        }
        set bs(a) {
            if (isNaN_(a) || a == 0) {
                return;
            }
            let b = this.bm;
            this.bm = a;
            this.dq("PixelScalingRatio", b, this.bm);
        }
        get bn() {
            return this.bl;
        }
        set bn(a) {
            let b = this.bl;
            this.bl = a;
            if (this.bl != b) {
                this.dq("ActualPixelScalingRatio", b, this.bl);
            }
        }
        get container() {
            return this;
        }
        get isStacked() {
            return false;
        }
        get isVertical() {
            return false;
        }
        get isUsableInLegend() {
            return true;
        }
        get hasSubItems() {
            return false;
        }
        get hasMarkers() {
            return false;
        }
        get et() {
            return this.er;
        }
        set et(a) {
            let b = this.et;
            if (a != b) {
                this.er = a;
                this.dq("OuterLabelTextColor", b, this.et);
            }
        }
        get eu() {
            return this.es;
        }
        set eu(a) {
            let b = this.eu;
            if (a != b) {
                this.es = a;
                this.dq("LabelTextColor", b, this.eu);
            }
        }
    }
    XamFunnelChart.$t = /*@__PURE__*/ markType(XamFunnelChart, 'XamFunnelChart', Control.$, [IItemProvider_$type, ILegendOwner_$type, ILegendTemplateProvider_$type, ILegendSeries_$type]);
    XamFunnelChart.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, XamFunnelChart, 'dq', ['AllowSliceSelection:a8:d0', [0, false], 'BottomEdgeWidth:bo:d1', [1, 0.35], 'Brushes:ah:d2', [BrushCollection.$, null], 'FastItemsSource:az:d3', [FastItemsSource.$], 'FunnelSliceDisplay:ak:d4', [FunnelSliceDisplay_$type, /*@__PURE__*/ enumGetBox(FunnelSliceDisplay_$type, 0)], 'InnerLabelMemberPath:cd:d5', [2, null], 'InnerLabelVisibility:ez:d6', [Visibility_$type, /*@__PURE__*/ enumGetBox(Visibility_$type, 0)], 'IsInverted:bd:d7', [0, false], 'ItemsSource::d8', [IEnumerable_$type, null], 'LegendItemBadgeTemplate::d9', [DataTemplate.$, null], 'LegendItemTemplate::ea', [DataTemplate.$, null], 'Legend::eb', [IChartLegend_$type, null], 'LowerBezierControlPoint:ev:ec', [Point_$type, { $type: Point_$type, x: 0.5, y: 1 }], 'OuterLabelAlignment:au:ed', [OuterLabelAlignment_$type, /*@__PURE__*/ enumGetBox(OuterLabelAlignment_$type, 0)], 'OuterLabelMemberPath:co:ee', [2, null], 'OuterLabelVisibility:e0:ef', [Visibility_$type, /*@__PURE__*/ enumGetBox(Visibility_$type, 1)], 'OutlineThickness:bq:eh', [1, -1], 'Outlines:ai:eg', [BrushCollection.$, null], 'SelectedSliceStyle:ex:ei', [Style.$, null], 'ToolTip:b0:ej', [4, null], 'TransitionDuration:by:ek', [1, 0], 'UnselectedSliceStyle:ey:el', [Style.$, null], 'UpperBezierControlPoint:ew:em', [Point_$type, { $type: Point_$type, x: 0.5, y: 0 }], 'UseBezierCurve:be:en', [0, false], 'UseOuterLabelsForLegend:bf:eo', [0, false], 'UseUnselectedStyle:bg:ep', [0, false], 'ValueMemberPath:c9:eq', [2, null]]);
    return XamFunnelChart;
})();
/**
 * @hidden
 */
export let XamFunnelConnector = /*@__PURE__*/ (() => {
    class XamFunnelConnector extends Base {
        get e() {
            return this.d;
        }
        get c() {
            return this.b;
        }
        g() {
            this.c.at.av(this.a);
        }
        constructor(a, b) {
            super();
            this.d = null;
            this.b = null;
            this.a = null;
            let c = new ServiceProvider();
            c.c("ConfigurationMessages", new MessageChannel());
            c.c("RenderingMessages", new MessageChannel());
            c.c("InteractionMessages", new MessageChannel());
            c.c("ModelUpdateMessages", new MessageChannel());
            a.av(b);
            let d = new XamFunnelController();
            d.at = a;
            d.ac = c;
            a.i = c;
            this.b = d;
            this.d = a;
            b.at = c;
            this.a = b;
            c.c("Model", this.a);
        }
        h(a) {
            this.d = a;
            let b = this.b.ac;
            this.b.ac = null;
            this.b.ac = b;
            this.d.i = b;
        }
        f() {
            if (this.d != null) {
                this.d.i = null;
            }
        }
        i() {
            this.b.df();
        }
    }
    XamFunnelConnector.$t = /*@__PURE__*/ markType(XamFunnelConnector, 'XamFunnelConnector');
    return XamFunnelConnector;
})();
