/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends, __values } from "tslib";
import { Base, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, Array_$type, enumGetBox, EnumUtil, typeGetValue, Number_$type, String_$type, fromEnum, typeCast, Date_$type, markDep, runOn, TypeRegistrar } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { DataAbbreviationMode_$type } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { FontInfo } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { Size } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { stringIsNullOrEmpty, stringEmpty } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { LegendItemBadgeShape_$type } from "igniteui-angular-core";
import { Control } from "igniteui-angular-core";
import { IDataLegend_$type } from "igniteui-angular-core";
import { IOnDemandRender_$type } from "igniteui-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { DataLegendValueMode_$type } from "igniteui-angular-core";
import { FontUtil } from "igniteui-angular-core";
import { DataLegendHeaderDateMode_$type } from "igniteui-angular-core";
import { DataLegendHeaderTimeMode_$type } from "igniteui-angular-core";
import { DataLegendSummaryType_$type } from "igniteui-angular-core";
import { DataLegendUnitsMode_$type } from "igniteui-angular-core";
import { DataLegendLabelMode_$type } from "igniteui-angular-core";
import { BindingFormatter } from "igniteui-angular-core";
import { DataLegendVisualData } from "./DataLegendVisualData";
import { Extensions } from "igniteui-angular-core";
import { TextBlock } from "igniteui-angular-core";
import { DataLegendVisualDataRow } from "./DataLegendVisualDataRow";
import { DataLegendVisualDataColumn } from "./DataLegendVisualDataColumn";
import { IDataLegendSeries_$type } from "igniteui-angular-core";
import { RectData } from "igniteui-angular-core";
import { AppearanceHelper } from "igniteui-angular-core";
import { FrameworkElement } from "igniteui-angular-core";
import { DataLegendSummaryEventArgs } from "./DataLegendSummaryEventArgs";
import { DataLegendSummaryCalculationTotal } from "./DataLegendSummaryCalculationTotal";
import { DataLegendSummaryCalculationAverage } from "./DataLegendSummaryCalculationAverage";
import { DataLegendSummaryCalculationMin } from "./DataLegendSummaryCalculationMin";
import { DataLegendSummaryCalculationMax } from "./DataLegendSummaryCalculationMax";
import { DataLegendSummaryCalculationEmpty } from "./DataLegendSummaryCalculationEmpty";
import { DataLegendStylingRowEventArgs } from "./DataLegendStylingRowEventArgs";
import { DataLegendStylingColumnEventArgs } from "./DataLegendStylingColumnEventArgs";
import { Dictionary$2 } from "igniteui-angular-core";
import { DataLegendColumn } from "./DataLegendColumn";
import { RenderingContext } from "igniteui-angular-core";
import { DataLegendRenderContext } from "./DataLegendRenderContext";
import { Pool$1 } from "igniteui-angular-core";
import { ContentControl } from "igniteui-angular-core";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSummaryColumn } from "igniteui-angular-core";
import { DataLegendSeriesGroup_$type } from "igniteui-angular-core";
import { DataAbbreviator } from "./DataAbbreviator";
import { NumberFormatSpecifier } from "igniteui-angular-core";
import { DateTimeFormatSpecifier } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity, truncate } from "igniteui-angular-core";
import { numberToString2 } from "igniteui-angular-core";
import { EventProxy } from "igniteui-angular-core";
import { Tuple$2 } from "igniteui-angular-core";
import { CanvasViewRenderer } from "igniteui-angular-core";
import { DataTemplatePassInfo } from "igniteui-angular-core";
import { DataTemplateMeasureInfo } from "igniteui-angular-core";
import { DataTemplateRenderInfo } from "igniteui-angular-core";
import { FontDefaults } from "igniteui-angular-core";
/**
 * @hidden
 */
var DataLegendContent = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DataLegendContent, _super);
    function DataLegendContent() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.a = new List$1(DataLegendRowInfo.$, 0);
        _this.d = 0;
        _this.c = 0;
        return _this;
    }
    Object.defineProperty(DataLegendContent.prototype, "b", {
        get: function () {
            return this.a;
        },
        enumerable: false,
        configurable: true
    });
    DataLegendContent.prototype.f = function () {
        this.b.clear();
    };
    DataLegendContent.prototype.e = function (a) {
        this.b.add(a);
    };
    DataLegendContent.$t = markType(DataLegendContent, 'DataLegendContent');
    return DataLegendContent;
}(Base));
export { DataLegendContent };
/**
 * @hidden
 */
var DataLegendRowBase = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DataLegendRowBase, _super);
    function DataLegendRowBase(a, b, c, d) {
        var _this = _super.call(this) || this;
        _this.e = 0;
        _this.b = false;
        _this.d = false;
        _this.a = false;
        _this.c = false;
        _this.e = d;
        _this.d = b;
        _this.a = c;
        _this.c = !c && !b;
        _this.b = true;
        return _this;
    }
    DataLegendRowBase.$t = markType(DataLegendRowBase, 'DataLegendRowBase');
    return DataLegendRowBase;
}(Base));
export { DataLegendRowBase };
/**
 * @hidden
 */
var DataLegendRowCell = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DataLegendRowCell, _super);
    function DataLegendRowCell(a, b, c, d) {
        var _this = _super.call(this, a, b, c, d) || this;
        _this.s = 0;
        _this.f = 0;
        _this.r = 0;
        _this.w = null;
        _this.v = null;
        _this.t = null;
        _this.x = null;
        _this.u = null;
        _this.z = null;
        _this.aa = null;
        _this.ab = null;
        _this.g = null;
        _this.i = null;
        _this.h = null;
        _this.al = null;
        _this.an = null;
        _this.am = null;
        _this.ag = new Size();
        _this.ak = new Size();
        _this.ai = new Size();
        _this.m = false;
        _this.j = false;
        _this.ac = null;
        _this.ae = null;
        _this.ad = null;
        _this.af = new Size();
        _this.aj = new Size();
        _this.ah = new Size();
        _this.r = NaN;
        _this.al = new Thickness(0, 0);
        _this.an = new Thickness(0, 0);
        _this.am = new Thickness(0, 0);
        _this.ag = new Size(1, 0, 0);
        _this.ak = new Size(1, 0, 0);
        _this.ai = new Size(1, 0, 0);
        _this.m = true;
        _this.j = true;
        if (_this.c) {
            _this.z = a.bs();
            _this.ab = a.bu();
            _this.aa = a.bt();
            _this.g = a.j();
            _this.i = a.n();
            _this.h = a.m();
        }
        else if (_this.d) {
            var e = a.br();
            var f = a.k();
            _this.z = e;
            _this.ab = e;
            _this.aa = e;
            _this.g = f;
            _this.i = f;
            _this.h = f;
        }
        else {
            var g = a.bp();
            var h = a.i();
            _this.z = g;
            _this.ab = g;
            _this.aa = g;
            _this.g = h;
            _this.i = h;
            _this.h = h;
        }
        _this.ac = Rect.empty;
        _this.ae = Rect.empty;
        _this.ad = Rect.empty;
        return _this;
    }
    DataLegendRowCell.prototype.k = function () {
        return this.ag.width > 0 && this.ag.height > 0;
    };
    DataLegendRowCell.prototype.n = function () {
        return this.ai.width > 0 && this.ai.height > 0;
    };
    DataLegendRowCell.prototype.p = function () {
        return this.ak.width > 0 && this.ak.height > 0;
    };
    DataLegendRowCell.prototype.l = function () {
        return this.t != null;
    };
    DataLegendRowCell.prototype.o = function () {
        return this.u != null;
    };
    DataLegendRowCell.prototype.q = function () {
        return !stringIsNullOrEmpty(this.x) && this.ak.width > 0 && this.ak.height > 0;
    };
    DataLegendRowCell.prototype.y = function () {
        this.af = new Size(1, 0, 0);
        this.aj = new Size(1, 0, 0);
        this.ah = new Size(1, 0, 0);
    };
    DataLegendRowCell.$t = markType(DataLegendRowCell, 'DataLegendRowCell', DataLegendRowBase.$);
    return DataLegendRowCell;
}(DataLegendRowBase));
export { DataLegendRowCell };
/**
 * @hidden
 */
var DataLegendRowInfo = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DataLegendRowInfo, _super);
    function DataLegendRowInfo(a, b, c, d) {
        var _this = _super.call(this, a, b, c, d) || this;
        _this.k = null;
        _this.j = false;
        _this.m = null;
        _this.f = null;
        _this.g = null;
        _this.n = null;
        _this.q = null;
        _this.i = null;
        _this.p = null;
        _this.t = new Size();
        _this.l = null;
        _this.h = 0;
        _this.w = null;
        _this.v = null;
        _this.x = null;
        _this.u = new Size();
        _this.r = null;
        _this.s = null;
        _this.f = new Array(0);
        _this.k = new List$1(DataLegendRowCell.$, 0);
        _this.j = _this.c;
        _this.w = new Thickness(0, 0);
        _this.v = new Thickness(0, 0);
        _this.x = new Thickness(0, 0);
        _this.t = new Size(1, 0, 0);
        _this.u = new Size(1, 0, 0);
        if (_this.c) {
            _this.q = a.bs();
            _this.i = a.l();
        }
        else if (_this.d) {
            var e = a.br();
            var f = a.k();
            _this.q = e;
            _this.i = f;
        }
        else {
            var g = a.bp();
            var h = a.i();
            _this.q = g;
            _this.i = h;
        }
        _this.s = Rect.empty;
        _this.r = Rect.empty;
        _this.h = 7;
        return _this;
    }
    DataLegendRowInfo.prototype.o = function (a) {
        if (this.k == null) {
            return;
        }
        for (var b = 0; b < this.k.count; b++) {
            a(this.k._inner[b]);
        }
    };
    DataLegendRowInfo.$t = markType(DataLegendRowInfo, 'DataLegendRowInfo', DataLegendRowBase.$);
    return DataLegendRowInfo;
}(DataLegendRowBase));
export { DataLegendRowInfo };
/**
 * @hidden
 */
var XamDataLegend = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(XamDataLegend, _super);
    function XamDataLegend() {
        var _this = _super.call(this) || this;
        _this.bw = false;
        _this.ci = NaN;
        _this.cj = NaN;
        _this.ck = 1;
        _this.bx = false;
        _this.bj = null;
        _this.bb = null;
        _this.be = null;
        _this.bg = null;
        _this.bd = null;
        _this.bf = null;
        _this.a7 = null;
        _this.bi = null;
        _this.bh = null;
        _this.bc = null;
        _this.cl = NaN;
        _this.calculateColumnSummary = null;
        _this.styleHeaderRow = null;
        _this.styleSeriesRow = null;
        _this.styleSummaryRow = null;
        _this.styleSeriesColumn = null;
        _this.styleSummaryColumn = null;
        _this.propertyChanged = null;
        _this.b9 = null;
        _this.b8 = null;
        _this.cb = null;
        _this.ca = null;
        _this.a5 = null;
        _this.ic = null;
        _this._externalObject = null;
        _this.bu = false;
        _this.bv = false;
        _this.ao = new DataLegendContent();
        _this.cd = null;
        _this.ce = new List$1(DataLegendSeriesContext.$, 0);
        _this.b7 = new Dictionary$2(Number_$type, DataLegendColumn.$, 0);
        _this.cs = 0;
        _this.ak = null;
        _this.al = null;
        _this.cy = "";
        _this.ai = null;
        _this.aj = null;
        _this.ic = Rect.empty;
        _this.bx = true;
        _this.ab = XamDataLegend.$;
        _this.a5 = _this.a4();
        return _this;
    }
    Object.defineProperty(XamDataLegend.prototype, "cm", {
        get: function () {
            return this.ci;
        },
        set: function (a) {
            var b = this.ci;
            this.ci = a;
            if (b != this.ci) {
                this.fy("ActualCursorPositionX", b, this.ci);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "cn", {
        get: function () {
            return this.cj;
        },
        set: function (a) {
            var b = this.cj;
            this.cj = a;
            if (b != this.cj) {
                this.fy("ActualCursorPositionY", b, this.cj);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "co", {
        get: function () {
            return this.ck;
        },
        set: function (a) {
            var b = this.ck;
            this.ck = a;
            this.fy("ActualPixelScalingRatio", b, this.ck);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bt", {
        get: function () {
            return this.bj;
        },
        set: function (a) {
            var b = this.bj;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.bj = a;
            if (b != this.bj) {
                this.fy("ValueTextStyle", b, this.bj);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bl", {
        get: function () {
            return this.bb;
        },
        set: function (a) {
            var b = this.bb;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.bb = a;
            if (b != this.bb) {
                this.fy("HeaderTextStyle", b, this.bb);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bo", {
        get: function () {
            return this.be;
        },
        set: function (a) {
            var b = this.be;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.be = a;
            if (b != this.be) {
                this.fy("SummaryTitleTextStyle", b, this.be);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bq", {
        get: function () {
            return this.bg;
        },
        set: function (a) {
            var b = this.bg;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.bg = a;
            if (b != this.bg) {
                this.fy("SummaryValueTextStyle", b, this.bg);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bn", {
        get: function () {
            return this.bd;
        },
        set: function (a) {
            var b = this.bd;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.bd = a;
            if (b != this.bd) {
                this.fy("SummaryLabelTextStyle", b, this.bd);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bp", {
        get: function () {
            return this.bf;
        },
        set: function (a) {
            var b = this.bf;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.bf = a;
            if (b != this.bf) {
                this.fy("SummaryUnitsTextStyle", b, this.bf);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bs", {
        get: function () {
            return this.bi;
        },
        set: function (a) {
            var b = this.bi;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.bi = a;
            if (b != this.bi) {
                this.fy("UnitsTextStyle", b, this.bi);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "br", {
        get: function () {
            return this.bh;
        },
        set: function (a) {
            var b = this.bh;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.bh = a;
            if (b != this.bh) {
                this.fy("TitleTextStyle", b, this.bh);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bm", {
        get: function () {
            return this.bc;
        },
        set: function (a) {
            var b = this.bc;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ai, a);
            }
            this.bc = a;
            if (b != this.bc) {
                this.fy("LabelTextStyle", b, this.bc);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "pixelScalingRatio", {
        get: function () {
            return this.cl;
        },
        set: function (a) {
            var b = this.cl;
            this.cl = a;
            this.fy("PixelScalingRatio", b, this.cl);
        },
        enumerable: false,
        configurable: true
    });
    XamDataLegend.prototype.exportSerializedVisualData = function () {
        var a = this.exportVisualData();
        return a.serialize();
    };
    XamDataLegend.prototype.cq = function (a, b) {
        var c = Math.max(b.left, a);
        var d = Math.max(b.right, a);
        var e = Math.max(b.right, a);
        return Math.min(b.top, a);
    };
    XamDataLegend.prototype.cp = function (a, b) {
        return Math.min(b.left, a);
    };
    XamDataLegend.prototype.ib = function (a, b) {
        var c = Rect.l_op_Equality(a, null) || a.isEmpty || !Extensions.b(a);
        var d = Rect.l_op_Equality(b, null) || b.isEmpty || !Extensions.b(b);
        if (c) {
            return b;
        }
        if (d) {
            return a;
        }
        if (c && c) {
            return Rect.empty;
        }
        var e = Math.min(a.top, b.top);
        var f = Math.min(a.left, b.left);
        var g = Math.max(a.right, b.right);
        var h = Math.max(a.bottom, b.bottom);
        return new Rect(0, f, e, g - f, h - e);
    };
    XamDataLegend.prototype.exportVisualData = function () {
        var e_1, _a;
        var a = new DataLegendVisualData();
        a.width = this.ao.d;
        a.height = this.ao.c;
        if (this.a5 == null) {
            return a;
        }
        var b = -1;
        var c = -1;
        var d = -1;
        var e = -1;
        var f = this.a5.ac;
        var g = this.a5.aa;
        var h = this.a5.ae;
        var i = this.a5.ad;
        if (f.count < this.ao.b.count) {
            return a;
        }
        if (Rect.l_op_Equality(this.ic, null) || this.ic.isEmpty) {
            a.viewport = null;
        }
        else {
            a.viewport = new RectData(0, 0, this.ic.width, this.ic.height);
        }
        for (var j = 0; j < this.ao.b.count; j++) {
            var k = this.ao.b._inner[j];
            var l = new DataLegendVisualDataRow();
            l.seriesIndex = k.e;
            l.rowMarginTop = k.w.top;
            l.rowMarginBottom = k.w.bottom;
            l.rowMarginRight = k.w.right;
            l.rowMarginLeft = k.w.left;
            var m = Rect.empty;
            if (k.b) {
                if (Extensions.b(k.s) && f.count > (b + 1)) {
                    b++;
                    var n = f._inner[b];
                    var o = this.bk(n, k.i);
                    var p = new DataLegendVisualDataColumn();
                    p.bounds = RectData.b(k.s);
                    p.text = n.al;
                    p.textColor = AppearanceHelper.b(k.q);
                    p.marginTop = k.x.top;
                    p.marginLeft = k.x.left;
                    p.marginRight = k.x.right;
                    p.marginBottom = k.x.bottom;
                    this.f8(p, o);
                    l.columns.add(p);
                    m = this.ib(m, k.s);
                }
                try {
                    for (var _b = (e_1 = void 0, __values(fromEnum(k.k))), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var q = _c.value;
                        if (Extensions.b(q.ac) && g.count > (c + 1)) {
                            c++;
                            var r = g._inner[c];
                            var s = this.bk(r, q.g);
                            var t = new DataLegendVisualDataColumn();
                            t.bounds = RectData.b(q.ac);
                            t.text = r.al;
                            t.textColor = AppearanceHelper.b(q.z);
                            t.marginTop = q.al.top;
                            t.marginLeft = q.al.left;
                            t.marginRight = q.al.right;
                            t.marginBottom = q.al.bottom;
                            this.f8(t, s);
                            l.columns.add(t);
                            m = this.ib(m, q.ac);
                        }
                        if (Extensions.b(q.ae) && h.count > (d + 1)) {
                            d++;
                            var u = h._inner[d];
                            var v = this.bk(u, q.i);
                            var w = new DataLegendVisualDataColumn();
                            w.bounds = RectData.b(q.ae);
                            w.text = u.al;
                            w.textColor = AppearanceHelper.b(q.ab);
                            w.marginTop = q.an.top;
                            w.marginLeft = q.an.left;
                            w.marginRight = q.an.right;
                            w.marginBottom = q.an.bottom;
                            this.f8(w, v);
                            l.columns.add(w);
                            m = this.ib(m, q.ae);
                        }
                        if (Extensions.b(q.ad) && i.count > (e + 1)) {
                            e++;
                            var x = i._inner[e];
                            var y = this.bk(x, q.h);
                            var z = new DataLegendVisualDataColumn();
                            z.bounds = RectData.b(q.ad);
                            z.text = q.m ? q.u : null;
                            z.textColor = AppearanceHelper.b(q.aa);
                            z.marginTop = q.am.top;
                            z.marginLeft = q.am.left;
                            z.marginRight = q.am.right;
                            z.marginBottom = q.am.bottom;
                            this.f8(z, y);
                            l.columns.add(z);
                            m = this.ib(m, q.ad);
                        }
                    }
                }
                catch (e_1_1) {
                    e_1 = { error: e_1_1 };
                }
                finally {
                    try {
                        if (_c && !_c.done && (_a = _b.return))
                            _a.call(_b);
                    }
                    finally {
                        if (e_1)
                            throw e_1.error;
                    }
                }
                if (k.j) {
                    m = this.ib(m, k.r);
                    l.badgeBounds = RectData.b(k.r);
                    l.badgeMarginTop = k.v.top;
                    l.badgeMarginBottom = k.v.bottom;
                    l.badgeMarginRight = k.v.right;
                    l.badgeMarginLeft = k.v.left;
                    if (k.e >= 0 && k.e < this.cd.count) {
                        var aa = this.cd._inner[k.e];
                        l.badgeShape = aa.getDataLegendBadgeShapeAndMarker();
                    }
                    else {
                        l.badgeShape = "None";
                    }
                }
                l.rowBounds = RectData.b(m);
            }
            a.rows.add(l);
        }
        return a;
    };
    XamDataLegend.prototype.f8 = function (a, b) {
        if (b != null) {
            if (b.n != null) {
                a.fontFamily = b.n;
            }
            if (!isNaN_(b.d)) {
                a.fontSize = b.d;
            }
            a.fontWeight = stringIsNullOrEmpty(b.s) ? "Normal" : b.s;
            a.fontStyle = stringIsNullOrEmpty(b.q) ? "Normal" : b.q;
            if (b.o != null) {
                a.fontStretch = b.q;
            }
        }
    };
    XamDataLegend.prototype.bk = function (a, b) {
        var c = a.dataContext;
        if (c != null) {
            b = a.dataContext;
        }
        if (b == null || stringIsNullOrEmpty(b.fontString)) {
            return b;
        }
        else {
            return FontUtil.toFontInfo(this.a5.ai, b.fontString);
        }
    };
    XamDataLegend.prototype.a0 = function (a) {
        if (this.calculateColumnSummary != null) {
            var b = new DataLegendSummaryEventArgs(a.a, a.d);
            b.summaryValue = a.c;
            this.calculateColumnSummary(this, b);
            a.c = b.summaryValue;
            a.f = b.summaryUnits;
            a.e = b.summaryLabel;
        }
        return a;
    };
    XamDataLegend.prototype.a6 = function () {
        switch (this.a1) {
            case 0:
            case 1: return new DataLegendSummaryCalculationTotal();
            case 2: return new DataLegendSummaryCalculationAverage();
            case 3: return new DataLegendSummaryCalculationMin();
            case 4: return new DataLegendSummaryCalculationMax();
            case 5: return new DataLegendSummaryCalculationEmpty();
            default: return new DataLegendSummaryCalculationEmpty();
        }
    };
    XamDataLegend.prototype.gc = function (a) {
        if (this.styleSummaryRow != null) {
            var b = this.ay(a);
            this.styleSummaryRow(this, b);
            this.f9(a, b);
        }
        if (a.b && a.k != null && this.styleSummaryColumn != null) {
            for (var c = 0; c < a.k.count; c++) {
                var d = this.ax(a.k._inner[c]);
                d.d = a.e;
                d.f = a.m;
                d.c = c;
                this.styleSummaryColumn(this, d);
                this.gd(a.k._inner[c], d);
            }
        }
    };
    XamDataLegend.prototype.gb = function (a) {
        if (this.styleSeriesRow != null) {
            var b = this.ay(a);
            this.styleSeriesRow(this, b);
            this.f9(a, b);
        }
        if (a.b && a.k != null && this.styleSeriesColumn != null) {
            for (var c = 0; c < a.k.count; c++) {
                var d = this.ax(a.k._inner[c]);
                d.d = a.e;
                d.f = a.m;
                d.c = c;
                this.styleSeriesColumn(this, d);
                this.gd(a.k._inner[c], d);
            }
        }
    };
    XamDataLegend.prototype.ga = function (a) {
        if (this.styleHeaderRow != null) {
            var b = this.ay(a);
            this.styleHeaderRow(this, b);
            this.f9(a, b);
        }
    };
    XamDataLegend.prototype.ay = function (a) {
        var b = new DataLegendStylingRowEventArgs();
        b.f = a.n;
        b.g = a.q;
        b.a = a.h;
        b.b = a.j;
        b.c = a.b;
        b.d = a.e;
        b.e = a.m;
        return b;
    };
    XamDataLegend.prototype.f9 = function (a, b) {
        a.n = b.f;
        a.q = b.g;
        a.h = b.a;
        a.j = b.b;
        a.b = b.c;
    };
    XamDataLegend.prototype.ax = function (a) {
        var b = new DataLegendStylingColumnEventArgs();
        b.e = a.t;
        b.k = a.z;
        b.g = a.u;
        b.l = a.aa;
        b.j = a.x;
        b.m = a.ab;
        b.b = a.r;
        b.i = a.w;
        b.h = a.v;
        b.a = a.f;
        return b;
    };
    XamDataLegend.prototype.gd = function (a, b) {
        a.z = b.k;
        a.t = b.e;
        a.j = !stringIsNullOrEmpty(a.t);
        a.u = b.g;
        a.aa = b.l;
        a.m = !stringIsNullOrEmpty(a.u);
        a.x = b.j;
        a.ab = b.m;
    };
    XamDataLegend.prototype.f1 = function (a, b, c) {
        var _this = this;
        switch (a) {
            case XamDataLegend.$$p[19]:
                this.bx = c;
                break;
            case XamDataLegend.$$p[15]:
            case XamDataLegend.$$p[3]:
                this.gh();
                break;
            case XamDataLegend.$$p[14]:
            case XamDataLegend.$$p[2]:
                this.gg();
                break;
            case XamDataLegend.$$p[32]:
                var d = c;
                var e = b;
                this.fz(e, d);
                break;
            case XamDataLegend.$$p[30]:
                if (this.b1(this.targetCursorPositionX)) {
                    this.cm = this.targetCursorPositionX;
                }
                break;
            case XamDataLegend.$$p[31]:
                if (this.b1(this.targetCursorPositionY)) {
                    this.cn = this.targetCursorPositionY;
                }
                break;
            case XamDataLegend.$$p[46]:
            case XamDataLegend.$$p[45]:
                if (!stringIsNullOrEmpty(this.e6)) {
                    this.ak = ((function () {
                        var $ret = new BindingFormatter();
                        $ret.j = _this.e6;
                        $ret.d = _this.ah;
                        return $ret;
                    })());
                }
                else {
                    this.ak = null;
                }
                break;
            case XamDataLegend.$$p[7]:
            case XamDataLegend.$$p[6]:
                if (!stringIsNullOrEmpty(this.dd)) {
                    this.ai = ((function () {
                        var $ret = new BindingFormatter();
                        $ret.j = _this.dd;
                        $ret.d = _this.ag;
                        return $ret;
                    })());
                }
                else {
                    this.ai = null;
                }
                break;
            case "PixelScalingRatio":
                if (isNaN_(this.co)) {
                    this.a5.av();
                }
                else {
                    this.co = this.pixelScalingRatio;
                }
                break;
            case "ActualPixelScalingRatio":
                this.a5.a6(c);
                break;
        }
        this.f3();
    };
    XamDataLegend.prototype.fy = function (a, b, c) {
        this.f1(a, b, c);
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
    };
    XamDataLegend.prototype.fz = function (a, b) {
        this.a7 = b;
        if (a != null) {
            a.detachDataLegend(this);
        }
        if (b != null) {
            b.attachDataLegend(this);
            if (isNaN_(this.targetCursorPositionX)) {
                this.cm = 1;
            }
            if (isNaN_(this.targetCursorPositionY)) {
                this.cn = 0.5;
            }
        }
    };
    XamDataLegend.prototype.gh = function () {
        this.cb = this.cc(this.includedSeries);
        this.ca = this.cc(this.excludedSeries);
    };
    XamDataLegend.prototype.gg = function () {
        var e_2, _a, e_3, _b;
        this.b9 = this.cc(this.includedColumns);
        this.b8 = this.cc(this.excludedColumns);
        if (this.b9 != null) {
            var a = new List$1(String_$type, 1, this.b9.keys);
            try {
                for (var _c = __values(fromEnum(a)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var b = _d.value;
                    var c = b + ":";
                    var d = this.b9.item(b);
                    if (!this.b9.containsKey(c)) {
                        this.b9.addItem(c, d);
                    }
                }
            }
            catch (e_2_1) {
                e_2 = { error: e_2_1 };
            }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return))
                        _a.call(_c);
                }
                finally {
                    if (e_2)
                        throw e_2.error;
                }
            }
            this.fh(this.b9);
        }
        if (this.b8 != null) {
            var e = new List$1(String_$type, 1, this.b8.keys);
            try {
                for (var _e = __values(fromEnum(e)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var f = _f.value;
                    var g = f + ":";
                    var h = this.b8.item(f);
                    if (!this.b8.containsKey(g)) {
                        this.b8.addItem(g, h);
                    }
                }
            }
            catch (e_3_1) {
                e_3 = { error: e_3_1 };
            }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return))
                        _b.call(_e);
                }
                finally {
                    if (e_3)
                        throw e_3.error;
                }
            }
            this.fh(this.b8);
        }
    };
    XamDataLegend.prototype.fh = function (a) {
        var e_4, _a;
        var b = new List$1(String_$type, 1, a.keys);
        try {
            for (var _b = __values(fromEnum(b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                var d = a.item(c);
                var e = c.toLowerCase();
                if (!a.containsKey(e)) {
                    a.addItem(e, d);
                }
                var f = c.toUpperCase();
                if (!a.containsKey(f)) {
                    a.addItem(f, d);
                }
                if (c.length > 0) {
                    var g = f.substr(0, 1) + e.substr(1);
                    if (!a.containsKey(g)) {
                        a.addItem(g, d);
                    }
                }
            }
        }
        catch (e_4_1) {
            e_4 = { error: e_4_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_4)
                    throw e_4.error;
            }
        }
    };
    XamDataLegend.prototype.cc = function (a) {
        if (a == null) {
            return null;
        }
        var b = new Dictionary$2(String_$type, Number_$type, 0);
        for (var c = 0; c < a.length; c++) {
            var d = a[c];
            if (!stringIsNullOrEmpty(d) && !b.containsKey(d.trim())) {
                b.addItem(d.trim(), b.count);
            }
        }
        return b;
    };
    XamDataLegend.prototype.b1 = function (a) {
        return a >= 0 && a <= 1;
    };
    XamDataLegend.prototype.notifyCursorPositionChanged = function (a) {
        var b = !isNaN_(this.targetCursorPositionX) || !isNaN_(this.targetCursorPositionY);
        var c = !isNaN_(a.x) && this.b1(a.x);
        var d = !isNaN_(a.y) && this.b1(a.y);
        if (!b && c && d) {
            this.cm = a.x;
            this.cn = a.y;
        }
    };
    XamDataLegend.prototype.notifySizeChanged = function () {
        this.a5.a4();
    };
    XamDataLegend.prototype.notifyVisualPropertiesChanged = function (a) {
    };
    XamDataLegend.prototype.notifySeriesCollectionChanged = function () {
        this.f3();
    };
    XamDataLegend.prototype.notifySeriesDataChanged = function () {
        if (this.bx) {
            this.f3();
        }
    };
    XamDataLegend.prototype.updatePropertyByName = function (a, b) {
        switch (a) {
            case XamDataLegend.$$p[15]:
                this.includedSeries = b;
                break;
            case XamDataLegend.$$p[3]:
                this.excludedSeries = b;
                break;
            case XamDataLegend.$$p[14]:
                this.includedColumns = b;
                break;
            case XamDataLegend.$$p[2]:
                this.excludedColumns = b;
                break;
            case XamDataLegend.$$p[39]:
                this.an = EnumUtil.getEnumValue(DataAbbreviationMode_$type, b);
                break;
            case XamDataLegend.$$p[42]:
                this.cu = typeGetValue(b);
                break;
            case XamDataLegend.$$p[43]:
                this.cv = typeGetValue(b);
                break;
            case XamDataLegend.$$p[44]:
                this.a3 = EnumUtil.getEnumValue(DataLegendValueMode_$type, b);
                break;
            case XamDataLegend.$$p[40]:
                this.ey = b;
                break;
            case XamDataLegend.$$p[47]:
                this.b4 = b;
                break;
            case XamDataLegend.$$p[46]:
                this.e6 = b;
                break;
            case XamDataLegend.$$p[45]:
                this.ah = b;
                break;
            case XamDataLegend.$$p[48]:
                this.is = b;
                break;
            case XamDataLegend.$$p[49]:
                this.b5 = b;
                break;
            case XamDataLegend.$$p[53]:
                this.ff = b;
                break;
            case XamDataLegend.$$p[52]:
                this.b6 = b;
                break;
            case XamDataLegend.$$p[51]:
                this.it = b;
                break;
            case XamDataLegend.$$p[50]:
                this.ia = b;
                break;
            case "ValueTextStyle":
                this.bt = b;
                break;
            case XamDataLegend.$$p[7]:
                this.dd = b;
                break;
            case XamDataLegend.$$p[6]:
                this.ag = b;
                break;
            case XamDataLegend.$$p[4]:
                this.c9 = b;
                break;
            case XamDataLegend.$$p[5]:
                this.ap = EnumUtil.getEnumValue(DataLegendHeaderDateMode_$type, b);
                break;
            case XamDataLegend.$$p[8]:
                this.aq = EnumUtil.getEnumValue(DataLegendHeaderTimeMode_$type, b);
                break;
            case XamDataLegend.$$p[13]:
                this.di = b;
                break;
            case XamDataLegend.$$p[11]:
                this.h1 = b;
                break;
            case XamDataLegend.$$p[12]:
                this.ik = b;
                break;
            case XamDataLegend.$$p[9]:
                this.ij = b;
                break;
            case XamDataLegend.$$p[10]:
                this.b0 = b;
                break;
            case "HeaderTextStyle":
                this.bl = b;
                break;
            case XamDataLegend.$$p[23]:
                this.h5 = b;
                break;
            case "SummaryTitleTextStyle":
                this.bo = b;
                break;
            case XamDataLegend.$$p[26]:
                this.a1 = EnumUtil.getEnumValue(DataLegendSummaryType_$type, b);
                break;
            case XamDataLegend.$$p[25]:
                this.d9 = b;
                break;
            case XamDataLegend.$$p[24]:
                this.io = b;
                break;
            case XamDataLegend.$$p[22]:
                this.im = b;
                break;
            case XamDataLegend.$$p[29]:
                this.h7 = b;
                break;
            case "SummaryValueTextStyle":
                this.bq = b;
                break;
            case XamDataLegend.$$p[21]:
                this.d4 = b;
                break;
            case XamDataLegend.$$p[20]:
                this.h4 = b;
                break;
            case "SummaryLabelTextStyle":
                this.bn = b;
                break;
            case XamDataLegend.$$p[28]:
                this.ef = b;
                break;
            case XamDataLegend.$$p[27]:
                this.h6 = b;
                break;
            case "SummaryUnitsTextStyle":
                this.bp = b;
                break;
            case XamDataLegend.$$p[0]:
                this.ii = b;
                break;
            case XamDataLegend.$$p[1]:
                this.a8 = EnumUtil.getEnumValue(LegendItemBadgeShape_$type, b);
                break;
            case XamDataLegend.$$p[35]:
                this.a2 = EnumUtil.getEnumValue(DataLegendUnitsMode_$type, b);
                break;
            case XamDataLegend.$$p[38]:
                this.es = b;
                break;
            case XamDataLegend.$$p[36]:
                this.h9 = b;
                break;
            case XamDataLegend.$$p[37]:
                this.iq = b;
                break;
            case "UnitsTextStyle":
                this.bs = b;
                break;
            case XamDataLegend.$$p[34]:
                this.ip = b;
                break;
            case XamDataLegend.$$p[33]:
                this.h8 = b;
                break;
            case "TitleTextStyle":
                this.br = b;
                break;
            case XamDataLegend.$$p[16]:
                this.ar = EnumUtil.getEnumValue(DataLegendLabelMode_$type, b);
                break;
            case XamDataLegend.$$p[17]:
                this.h2 = b;
                break;
            case XamDataLegend.$$p[18]:
                this.il = b;
                break;
            case "LabelTextStyle":
                this.bm = b;
                break;
        }
    };
    XamDataLegend.prototype.a4 = function () {
        return new DataLegendView(this);
    };
    XamDataLegend.prototype.destroy = function () {
        this.provideContainer(null);
    };
    Object.defineProperty(XamDataLegend.prototype, "externalObject", {
        get: function () {
            return this._externalObject;
        },
        set: function (a) {
            this._externalObject = a;
        },
        enumerable: false,
        configurable: true
    });
    XamDataLegend.prototype.flush = function () {
        this.a5.as();
    };
    XamDataLegend.prototype.onAttachedToUI = function () {
        this.a5.a2();
    };
    XamDataLegend.prototype.onDetachedFromUI = function () {
        this.a5.a5();
    };
    XamDataLegend.prototype.ensureIndirectContainer = function (a, b) {
        if (this.a5.ai == null) {
            this.a5.a3(a, true);
        }
    };
    XamDataLegend.prototype.provideContainer = function (a) {
        this.a5.a3(a, false);
    };
    XamDataLegend.prototype.f3 = function () {
        if (this.bu) {
            return;
        }
        this.bu = this.a5.x();
    };
    Object.defineProperty(XamDataLegend.prototype, "shouldOnDemandRender", {
        get: function () {
            return this.bv;
        },
        set: function (a) {
            this.bv = a;
        },
        enumerable: false,
        configurable: true
    });
    XamDataLegend.prototype.doRender = function (a, b) {
        if (this.ic.isEmpty) {
            var c = this.getDesiredSize();
            this.ic = new Rect(0, 0, 0, c.width, c.height);
        }
        this.f4(this.ao, true);
        this.a5.a8(a, b);
    };
    XamDataLegend.prototype.ensureUpdated = function () {
        var a = this.getDesiredSize();
    };
    XamDataLegend.prototype.fq = function () {
        if (!this.bu) {
            if (this.ao == null) {
                this.f3();
            }
            else {
                return;
            }
        }
        this.gf();
    };
    XamDataLegend.prototype.getDesiredSize = function () {
        this.fq();
        if (this.ao == null) {
            return new Size(1, 0, 0);
        }
        return new Size(1, this.ao.d, this.ao.c);
    };
    XamDataLegend.prototype.gf = function () {
        if (this.a7 == null) {
            this.fn();
            return;
        }
        var a = this.a7;
        var b = a.getDataLegendSeries();
        var c = this.cg(b);
        this.fs(c);
    };
    XamDataLegend.prototype.cg = function (a) {
        var e_5, _a;
        var b = new Dictionary$2(Number_$type, IDataLegendSeries_$type, 0);
        for (var c = 0; c < a.length; c++) {
            var d = a[c].title == null ? null : a[c].title.toString();
            var e = this.cb == null || this.cb.containsKey(a[c].dataLegendKey) || this.cb.containsKey(a[c].index.toString()) || this.cb.containsKey(d);
            var f = this.ca != null && (this.ca.containsKey(a[c].dataLegendKey) || this.ca.containsKey(a[c].index.toString()) || this.ca.containsKey(d));
            if (a[c].isValueOverlay && (!e || this.cb == null)) {
                continue;
            }
            if (e && !f) {
                var g = this.ct(a[c]);
                b.addItem(g, a[c]);
            }
        }
        var h = new List$1(Number_$type, 1, b.keys);
        h.y();
        var i = new List$1(IDataLegendSeries_$type, 0);
        try {
            for (var _b = __values(fromEnum(h)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var j = _c.value;
                i.add(b.item(j));
            }
        }
        catch (e_5_1) {
            e_5 = { error: e_5_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_5)
                    throw e_5.error;
            }
        }
        return i;
    };
    XamDataLegend.prototype.ct = function (a) {
        if (this.cb == null) {
            return a.index;
        }
        var b = a.dataLegendKey;
        if (this.cb.containsKey(b)) {
            return this.cb.item(b);
        }
        var c = a.index.toString();
        if (this.cb.containsKey(c)) {
            return this.cb.item(c);
        }
        var d = a.title == null ? null : a.title.toString();
        if (this.cb.containsKey(d)) {
            return this.cb.item(d);
        }
        return a.index;
    };
    XamDataLegend.prototype.fp = function () {
        this.bu = false;
        var a = new Size(1, 0, 0);
        if (this.ao != null) {
            a = new Size(1, this.ao.d, this.ao.c);
        }
        this.gf();
        var b = new Size(1, 0, 0);
        if (this.ao != null) {
            b = new Size(1, this.ao.d, this.ao.c);
        }
        if (!a.equals(b)) {
            this.a5.an(b.width, b.height);
        }
        this.f4(this.ao, this.bv);
    };
    XamDataLegend.prototype.ft = function (message_) {
    };
    XamDataLegend.prototype.f4 = function (a, b) {
        var c = new DataLegendRenderContext();
        for (var d = 0; d < a.b.count; d++) {
            var e = a.b._inner[d];
            this.f6(a, e, c);
        }
        this.a5.p.count = c.b;
        this.a5.q.count = c.c;
        this.a5.s.count = c.e;
        this.a5.r.count = c.d;
        this.a5.o.count = c.a;
        if (!b) {
            this.a5.ar(a);
        }
    };
    XamDataLegend.prototype.f6 = function (a, b, c) {
        var e_6, _a;
        if (b.t.width > 0 && b.t.height > 0 && !b.a && !b.d && b.j) {
            var d = this.a5.p.item(c.b);
            c.b += 1;
            this.f5(d, a, b, c);
        }
        this.a5.ba();
        if (!b.s.isEmpty && b.s.width > 0 && b.s.height > 0) {
            var e = this.a5.q.item(c.c);
            c.c += 1;
            this.f7(e, b.n, b.q, b.i, b.s);
        }
        try {
            for (var _b = __values(fromEnum(b.k)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                if (!f.ae.isEmpty && f.q()) {
                    var g = this.a5.s.item(c.e);
                    c.e += 1;
                    this.f7(g, f.x, f.ab, f.i, f.ae);
                }
                if (!f.ad.isEmpty && f.o() && f.m) {
                    var h = this.a5.r.item(c.d);
                    c.d += 1;
                    this.f7(h, f.u, f.aa, f.h, f.ad);
                }
                if (!f.ac.isEmpty && f.l() && f.j) {
                    var i = this.a5.o.item(c.a);
                    c.a += 1;
                    this.f7(i, f.t, f.z, f.g, f.ac);
                }
            }
        }
        catch (e_6_1) {
            e_6 = { error: e_6_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_6)
                    throw e_6.error;
            }
        }
        this.a5.ao();
    };
    XamDataLegend.prototype.f7 = function (a, b, c, d, e) {
        a.al = b;
        this.a5.a9(a, e.left, e.top);
        this.a5.ap(a, d);
        this.a5.aq(a, d);
        a.ao = c;
    };
    XamDataLegend.prototype.f5 = function (a, b, c, d) {
        a.ah = c.p;
        a.content = c.l;
        a.width = c.t.width;
        a.height = c.t.height;
        this.a5.a9(a, c.r.left, c.r.top);
    };
    XamDataLegend.prototype.by = function (a, b) {
        if (b == null) {
            return false;
        }
        return a.containsKey(b);
    };
    XamDataLegend.prototype.fs = function (a) {
        var e_7, _a;
        if (this.bz()) {
            this.ao.f();
            this.cd = a;
            this.ce.clear();
            this.cs = 0;
            this.b7.clear();
        }
        else {
            return;
        }
        for (var b = 0; b < a.count; b++) {
            var c = a._inner[b];
            var d = b;
            var e = typeCast(DataLegendSeriesContext.$, c.getDataLegendSeriesContextAt(this.cm, this.cn));
            if (e != null) {
                var f = new List$1(DataLegendSeriesValueInfo.$, 0);
                for (var g = 0; g < e.f.count; g++) {
                    var h = e.f._inner[g];
                    var i = this.b9 == null || this.by(this.b9, h.q) || this.by(this.b9, h.p) || this.by(this.b9, h.r) || this.by(this.b9, "ALL");
                    var j = this.b8 != null && (this.by(this.b8, h.q) || this.by(this.b8, h.p) || this.by(this.b8, h.r) || this.by(this.b8, "ALL"));
                    var k = this.b9 == null && this.b8 == null && h.k;
                    if (i && (!j && !k)) {
                        h.o = f.count;
                        f.add(h);
                        if (!this.b7.containsKey(h.o)) {
                            this.b7.addItem(h.o, new DataLegendColumn());
                        }
                        this.b7.item(h.o).i = h.o;
                        this.b7.item(h.o).d.q(d, h.s);
                        this.b7.item(h.o).b.q(d, h.r);
                        this.b7.item(h.o).e.q(d, h.l);
                        this.b7.item(h.o).c.q(d, h);
                        this.b7.item(h.o).h.add(d);
                    }
                }
                e.f = f;
                this.ce.add(e);
                this.cs = Math.max(this.cs, e.f.count);
            }
        }
        try {
            for (var _b = __values(fromEnum(this.b7.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var l = _c.value;
                l.f.clear();
                l.a.clear();
                var m = l.e.p(l.h);
                var n = this.cf(m);
                for (var o = 0; o < n.count; o++) {
                    var p = n._inner[o];
                    var q = l.h._inner[o];
                    l.a.q(q, p);
                    var r = l.c.item(q);
                    var s = this.d2(p, r);
                    l.f.q(q, s);
                    var t = !stringIsNullOrEmpty(p.l);
                    if (t) {
                        l.g = true;
                    }
                }
            }
        }
        catch (e_7_1) {
            e_7 = { error: e_7_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_7)
                    throw e_7.error;
            }
        }
        this.fi(this.ao, a);
        for (var u = 0; u < a.count; u++) {
            this.ge(a._inner[u], this.a8);
            this.fj(this.ao, a._inner[u], u);
        }
        this.fk(this.ao, a);
        this.bw = this.b2();
        this.fm(this.ao);
    };
    XamDataLegend.prototype.b2 = function () {
        var a = false;
        for (var b = 0; b < this.ao.b.count; b++) {
            var c = this.ao.b._inner[b];
            if (c.c && c.j && c.h != 7) {
                a = true;
                break;
            }
        }
        return a;
    };
    XamDataLegend.prototype.fm = function (a) {
        var e_8, _a;
        var b = 0;
        var c = 0;
        for (var d = 0; d < a.b.count; d++) {
            var e = a.b._inner[d];
            this.fu(e);
        }
        var f = 0;
        var g = new Size(1, 0, 0);
        var h = new Size(1, 0, 0);
        var i = new Dictionary$2(Number_$type, Size.$, 0);
        var j = new Dictionary$2(Number_$type, Size.$, 0);
        var k = new Dictionary$2(Number_$type, Size.$, 0);
        try {
            for (var _b = __values(fromEnum(a.b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var l = _c.value;
                for (var m = 0; m < l.k.count; m++) {
                    var n = l.k._inner[m];
                    if (!i.containsKey(m)) {
                        i.addItem(m, new Size(1, 0, 0));
                    }
                    i.item(m, this.ih(i.item(m), n.ak, n.an));
                    if (!j.containsKey(m)) {
                        j.addItem(m, new Size(1, 0, 0));
                    }
                    j.item(m, this.ih(j.item(m), n.ai, n.am));
                    if (!k.containsKey(m)) {
                        k.addItem(m, new Size(1, 0, 0));
                    }
                    k.item(m, this.ih(k.item(m), n.ag, n.al));
                }
            }
        }
        catch (e_8_1) {
            e_8 = { error: e_8_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_8)
                    throw e_8.error;
            }
        }
        for (var o = 0; o < a.b.count; o++) {
            var p = a.b._inner[o];
            h = this.ig(h, p.t, p.v);
            g = this.ih(g, p.u, p.x);
            for (var q = 0; q < p.k.count; q++) {
                p.k._inner[q].aj = i.item(q);
                p.k._inner[q].ah = j.item(q);
                p.k._inner[q].af = k.item(q);
            }
            if (p.d) {
                var r = p.u.width + p.x.left + p.x.right;
                f = Math.max(f, r + p.w.left);
            }
            else if (p.c) {
                var s = p.u.width + p.x.left + p.x.right;
                var t = p.t.width + p.v.left + p.v.right;
                f = Math.max(f, s + p.w.left + t);
            }
        }
        var u = 0;
        var v = 0;
        for (var w = 0; w < a.b.count; w++) {
            var x = a.b._inner[w];
            var y = this.id(v, x, f, g, h);
            v = y.height;
            u = Math.max(u, y.width);
        }
        c = v;
        b = u;
        a.d = b;
        a.c = c;
    };
    XamDataLegend.prototype.ig = function (a, b, c) {
        return new Size(1, Math.max(a.width, b.width + c.left + c.right), Math.max(a.height, b.height + c.top + c.bottom));
    };
    XamDataLegend.prototype.ih = function (a, b, c) {
        return new Size(1, Math.max(a.width, b.width + c.left + c.right), Math.max(a.height, b.height + c.top + c.bottom));
    };
    XamDataLegend.prototype.id = function (a, b, c, d, e) {
        var e_9, _a, e_10, _b;
        var f = 0;
        var g = 0;
        g = Math.max(b.t.height, g);
        g = Math.max(b.u.height, g);
        try {
            for (var _c = __values(fromEnum(b.k)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var h = _d.value;
                g = Math.max(h.ak.height, g);
                if (h.m) {
                    g = Math.max(h.ai.height, g);
                }
                if (h.j) {
                    g = Math.max(h.ag.height, g);
                }
            }
        }
        catch (e_9_1) {
            e_9 = { error: e_9_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_9)
                    throw e_9.error;
            }
        }
        f += b.w.left;
        a += b.w.top;
        if (!b.a && !b.d && this.bw) {
            f += b.v.left;
            var i = 0;
            if (g > b.t.height) {
                i = (g - b.t.height) / 2;
            }
            b.r = new Rect(0, f, a + i, b.t.width, b.t.height);
            f += (b.r.width) + b.v.right;
        }
        else {
            b.r = new Rect(0, 0, 0, 0, 0);
        }
        f += b.x.left;
        var j = 0;
        if (g > b.u.height) {
            j = (g - b.u.height) / 2;
        }
        b.s = new Rect(0, f, a + j, b.u.width + b.x.right, b.u.height);
        f = Math.max(c, b.s.right);
        try {
            for (var _e = __values(fromEnum(b.k)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var k = _f.value;
                var l = " C=" + k.s + " SR=" + numberToString2(f, "000");
                if ((k.l() && k.j) && k.af.width > 0) {
                    var m = 0;
                    if (g > k.ag.height) {
                        m = (g - k.ag.height) / 2;
                    }
                    k.ac = new Rect(0, f + k.al.left, a + m, k.ag.width, k.ag.height);
                    f += k.af.width;
                    l += " label L=" + numberToString2(k.ac.left, "000") + " R=" + numberToString2(k.ac.right, "000");
                }
                if (k.q()) {
                    l += " v MW=" + numberToString2(k.aj.width, "000");
                    f += k.an.left;
                    f += (k.aj.width - (k.ak.width + k.an.right));
                    var n = 0;
                    if (g > k.ak.height) {
                        n = (g - k.ak.height) / 2;
                    }
                    k.ae = new Rect(0, f, a + n, k.ak.width, k.ak.height);
                    l += " v ML=" + numberToString2(k.an.left, "00") + " MR=" + numberToString2(k.an.right, "00");
                    l += " v BL=" + numberToString2(k.ae.left, "000") + " BR=" + numberToString2(k.ae.right, "000");
                    f += k.ae.width;
                    f += k.an.right;
                }
                if ((k.o() && k.m) && k.ah.width > 0) {
                    var o = 0;
                    if (g > k.ai.height) {
                        o = (g - k.ai.height) / 2;
                    }
                    k.ad = new Rect(0, f + k.am.left, a + o, k.ai.width, k.ai.height);
                    f += k.ah.width;
                    l += " unit L=" + numberToString2(k.ad.left, "000") + " R=" + numberToString2(k.ad.right, "000");
                }
                this.ft("maxRight " + numberToString2(c, "0") + l);
            }
        }
        catch (e_10_1) {
            e_10 = { error: e_10_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_10)
                    throw e_10.error;
            }
        }
        f += b.w.right;
        a += g;
        a += b.w.bottom;
        return new Size(1, f, a);
    };
    XamDataLegend.prototype.fu = function (a) {
        var e_11, _a;
        a.u = a.n == null ? new Size(1, 0, 0) : this.a5.bv(a.n, a.i);
        try {
            for (var _b = __values(fromEnum(a.k)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.ak = b.x == null ? new Size(1, 0, 0) : this.a5.bv(b.x, b.i);
                b.ai = b.u == null ? new Size(1, 0, 0) : this.a5.bv(b.u, b.h);
                b.ag = b.t == null ? new Size(1, 0, 0) : this.a5.bv(b.t, b.g);
            }
        }
        catch (e_11_1) {
            e_11 = { error: e_11_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_11)
                    throw e_11.error;
            }
        }
    };
    XamDataLegend.prototype.d1 = function (a, b, c, d) {
        if (this.a2 == 2) {
            return null;
        }
        var e = "";
        if (stringIsNullOrEmpty(this.es)) {
            e = b;
        }
        else {
            e = this.es;
        }
        if (d) {
            if (stringIsNullOrEmpty(e)) {
                e = c;
            }
            else {
                e = c + e;
            }
        }
        var f = this.b7.item(a).d;
        var g = this.b7.item(a).g;
        if (g && stringIsNullOrEmpty(e)) {
            e = " ";
        }
        else if (f.count > 0 && stringIsNullOrEmpty(e)) {
            e = " ";
        }
        else if (!d) {
            return null;
        }
        return e;
    };
    XamDataLegend.prototype.dy = function (a, b, c) {
        if (this.ar == 2) {
            return null;
        }
        var d = this.cs > 1;
        var e = this.ar == 1;
        var f = this.b7.item(a).b.count > 0;
        if (f && (d || e)) {
            if (stringIsNullOrEmpty(b)) {
                return " ";
            }
            else if (c) {
                return b;
            }
        }
        return null;
    };
    XamDataLegend.prototype.fk = function (a, b) {
        var e_12, _a, e_13, _b;
        if (this.a1 == 5) {
            return;
        }
        if (b == null || b.count <= 1) {
            return;
        }
        var c = new Dictionary$2(Number_$type, DataLegendSummaryColumn.$, 0);
        var d = 0;
        var e = new List$1(DataLegendSeriesGroup_$type, 0);
        try {
            for (var _c = __values(fromEnum(this.ce)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var f = _d.value;
                d = Math.max(d, f.f.count);
                if (!e.contains(f.b)) {
                    e.add(f.b);
                }
                for (var g = 0; g < f.f.count; g++) {
                    var h = f.f._inner[g];
                    if (!c.containsKey(g)) {
                        c.addItem(g, new DataLegendSummaryColumn());
                    }
                    var i = c.item(g);
                    i.n = h.n;
                    i.m = h.m;
                    i.e = h.e;
                    i.h = h.h;
                    i.f = h.f;
                    i.f = h.g;
                    i.d = h.d;
                    i.y = h.y;
                    i.aj(h.l);
                    i.ah(h.r);
                    i.ai(h.s);
                    if (stringIsNullOrEmpty(i.u)) {
                        i.u = h.u;
                    }
                    if (stringIsNullOrEmpty(i.v)) {
                        i.v = h.v;
                    }
                    if (stringIsNullOrEmpty(i.w)) {
                        i.w = h.w;
                    }
                    if (stringIsNullOrEmpty(i.x)) {
                        i.x = h.x;
                    }
                    if (stringIsNullOrEmpty(i.q)) {
                        i.q = h.q;
                    }
                    if (stringIsNullOrEmpty(i.p)) {
                        i.p = h.p;
                    }
                }
            }
        }
        catch (e_12_1) {
            e_12 = { error: e_12_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_12)
                    throw e_12.error;
            }
        }
        if (this.a1 == 0) {
            if (e.count > 1) {
                return;
            }
            if (!e.contains(0)) {
                return;
            }
        }
        var j = this.a6();
        var k = new DataLegendRowInfo(this.a5, true, false, -1);
        k.n = this.d9 != null ? this.d9 : j.title;
        k.q = this.h5 || k.q;
        k.i = this.bo || k.i;
        for (var l = 0; l < d; l++) {
            var m = c.item(l);
            var n = j.calculate(m.ab, m.q);
            n = this.a0(n);
            var o = this.an;
            var p = o == 0 || o == 2 || o == 8;
            var q = -1;
            try {
                for (var _e = (e_13 = void 0, __values(fromEnum(this.b7.item(l).a.values))), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var r = _f.value;
                    if (r.b()) {
                        q = Math.max(q, r.h);
                        if (p) {
                            o = r.a;
                        }
                    }
                }
            }
            catch (e_13_1) {
                e_13 = { error: e_13_1 };
            }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return))
                        _b.call(_e);
                }
                finally {
                    if (e_13)
                        throw e_13.error;
                }
            }
            var s = this.cv >= 0 ? this.cv : q;
            var t = this.cu >= 0 ? this.cu : q;
            var u = this.am(n.c, o, s, t);
            u.i = s;
            u.h = t;
            var v = this.d2(u, m);
            var w = new DataLegendRowCell(this.a5, true, false, -1);
            w.s = k.k.count;
            w.t = this.dy(w.s, " ", m.b);
            if (!stringIsNullOrEmpty(this.d4)) {
                w.t = this.d4;
            }
            if (n.e != null) {
                w.t = n.e;
            }
            w.j = !stringIsNullOrEmpty(w.t);
            w.z = this.h4 || w.z;
            w.g = this.bn || w.g;
            w.x = v;
            w.i = this.bq || w.i;
            w.ab = this.h3(this.h7, w.ab, null);
            w.r = n.c;
            w.f = u.a;
            w.w = m.q;
            w.v = m.p;
            var x = m.aa.length >= 1 ? m.aa[0] : " ";
            w.u = this.d1(w.s, x, u.l, m.d);
            if (n.f != null) {
                w.u = n.f;
            }
            w.m = !stringIsNullOrEmpty(w.u);
            w.aa = this.h6 || w.aa;
            w.h = this.bp || w.h;
            k.k.add(w);
        }
        this.gc(k);
        if (k.b) {
            this.fl(k);
            this.f0(k);
            a.e(k);
        }
    };
    XamDataLegend.prototype.am = function (a, b, c, d) {
        if (b == 8 || b == 0) {
            b = this.an;
        }
        if (d < 0) {
            d = this.cu;
        }
        if (c < 0) {
            c = this.cv;
        }
        return DataAbbreviator.a(a, b, c, d);
    };
    XamDataLegend.prototype.cr = function (a, b, c, d) {
        return this.am(a, b, c, d).d;
    };
    XamDataLegend.prototype.c8 = function (a, b, c, d) {
        return this.am(a, b, c, d).l;
    };
    XamDataLegend.prototype.c7 = function (a, b, c, d) {
        var e = this.am(a, b, c, d);
        return e.m + e.l;
    };
    XamDataLegend.prototype.cf = function (a) {
        var b = this.cv;
        var c = this.cu;
        var d = this.an;
        var e = DataAbbreviator.h(a, d, b, c);
        return e;
    };
    XamDataLegend.prototype.ch = function (a) {
        var b = new List$1(Number_$type, 0);
        if (a < 0) {
            return b;
        }
        for (var c = 0; c < this.ce.count; c++) {
            var d = this.ce._inner[c];
            if (d.f.count > a) {
                var e = d.f._inner[a].l;
                if (!isNaN_(e)) {
                    b.add(e);
                }
            }
        }
        return b;
    };
    XamDataLegend.prototype.fl = function (a) {
    };
    XamDataLegend.prototype.h3 = function (a, b, c) {
        if (a != null) {
            return a;
        }
        if (this.b6 && c != null) {
            return c;
        }
        return b;
    };
    XamDataLegend.prototype.dz = function (a, b) {
        return stringIsNullOrEmpty(a) ? b : a;
    };
    XamDataLegend.prototype.d2 = function (a, b) {
        var c = a.d;
        if (b == null || isNaN_(c) || isInfinity(c)) {
            return this.ff;
        }
        var d;
        var e = b.d ? a.d : a.g;
        if (this.ak != null) {
            d = this.ak.i(e);
        }
        else {
            var f = this.a3;
            if (f == 0) {
                f = 1;
            }
            var g = new NumberFormatSpecifier();
            g.useGrouping = this.b4;
            g.locale = this.dz(this.ey, null);
            g.currencyCode = this.e0;
            if (b.d) {
                g.minimumFractionDigits = a.i;
                g.maximumFractionDigits = a.h;
                if (b.n >= 0 && b.n > a.i) {
                    g.minimumFractionDigits = b.n;
                }
                else if (this.cv >= 0) {
                    g.minimumFractionDigits = this.cv;
                }
                if (b.m >= 0 && b.m > a.h) {
                    g.maximumFractionDigits = b.m;
                }
                else if (this.cu >= 0) {
                    g.maximumFractionDigits = this.cu;
                }
            }
            else {
                g.minimumFractionDigits = b.n;
                g.maximumFractionDigits = b.m;
            }
            if (g.minimumFractionDigits > g.maximumFractionDigits) {
                g.maximumFractionDigits = g.minimumFractionDigits;
            }
            if (f == 2 && b.e) {
                g.style = "currency";
            }
            if (this.al == null) {
                this.al = new BindingFormatter();
            }
            this.al.j = "{0}";
            this.al.d = [g];
            d = this.al.i(e);
            if (e > 0) {
                d = b.w + d;
            }
            else if (e < 0) {
                d = b.u + d;
            }
            if (e >= 0) {
                d += b.x;
            }
            else {
                d += b.v;
            }
        }
        return d;
    };
    XamDataLegend.prototype.fj = function (a, b, c) {
        if (this.b5 == false) {
            return;
        }
        var d = this.ce._inner[c];
        var e = this.d0(b);
        var f = new DataLegendRowInfo(this.a5, false, false, c);
        f.f = d.a();
        f.m = e;
        f.n = e;
        f.q = this.h8 || f.q;
        f.i = this.br || f.i;
        for (var g = 0; g < d.f.count; g++) {
            var h = d.f._inner[g];
            var i = this.b7.item(g).a.item(c);
            var j = this.b7.item(g).f.item(c);
            var k = new DataLegendRowCell(this.a5, false, false, c);
            k.s = f.k.count;
            k.i = this.bt || k.i;
            k.x = j;
            k.ab = this.h3(this.ia, k.ab, h.y);
            k.w = h.q;
            k.v = h.p;
            k.r = h.l;
            k.f = i.a;
            k.u = this.d1(k.s, h.s, i.l, h.d);
            k.m = !stringIsNullOrEmpty(k.u);
            k.aa = this.h9 || k.aa;
            k.h = this.bs || k.h;
            k.t = this.dy(k.s, h.r, h.b);
            k.j = !stringIsNullOrEmpty(k.t);
            k.z = this.h2 || k.z;
            k.g = this.bm || k.g;
            f.k.add(k);
        }
        f.h = this.a9(b);
        this.fl(f);
        this.f0(f);
        this.gb(f);
        if (f.b) {
            if (f.j) {
                this.ge(b, f.h);
                var l = this.gi(b);
                var m = this.cx(b);
                f.p = l;
                f.l = m;
            }
            a.e(f);
        }
    };
    XamDataLegend.prototype.cx = function (a) {
        return a.getDataLegendBadgeContext();
    };
    XamDataLegend.prototype.a9 = function (a) {
        if (this.a8 != 0) {
            return this.a8;
        }
        return a.legendItemBadgeShape;
    };
    XamDataLegend.prototype.ge = function (a, b) {
        if (b == 0) {
            return;
        }
        if (a.legendItemBadgeShape != b) {
            a.legendItemBadgeShape = b;
        }
    };
    XamDataLegend.prototype.bz = function () {
        return !isNaN_(this.cm) && !isNaN_(this.cn);
    };
    XamDataLegend.prototype.gi = function (a) {
        return a.getDataLegendBadge();
    };
    XamDataLegend.prototype.d0 = function (a) {
        return a.getDataLegendSeriesTitle();
    };
    XamDataLegend.prototype.fi = function (a, b) {
        if (this.b0 == false) {
            return;
        }
        var c = this.dx(b);
        if (c == null) {
            c = this.cy;
        }
        else {
            this.cy = c;
        }
        if (stringIsNullOrEmpty(c)) {
            return;
        }
        var d = new DataLegendRowInfo(this.a5, false, true, -1);
        d.n = c;
        d.q = this.h1 || d.q;
        d.i = this.bl || d.i;
        this.fl(d);
        this.f0(d);
        this.ga(d);
        if (d.b) {
            a.e(d);
        }
    };
    XamDataLegend.prototype.ir = function (a) {
        var b = new Thickness(0, 0);
        if (a.top >= 0) {
            b.top = a.top;
        }
        if (a.bottom >= 0) {
            b.bottom = a.bottom;
        }
        if (a.left >= 0) {
            b.left = a.left;
        }
        if (a.right >= 0) {
            b.right = a.right;
        }
        return b;
    };
    XamDataLegend.prototype.f0 = function (a) {
        var e_14, _a;
        if (a.c) {
            a.x = this.ir(this.ip);
            a.w = this.ir(this.is);
        }
        else if (a.a) {
            a.x = this.ir(this.ik);
            a.w = this.ir(this.ij);
        }
        else {
            a.x = this.ir(this.io);
            a.w = this.ir(this.im);
        }
        try {
            for (var _b = __values(fromEnum(a.k)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.an = this.ir(this.it);
                b.am = this.ir(this.iq);
                b.al = this.ir(this.il);
            }
        }
        catch (e_14_1) {
            e_14 = { error: e_14_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_14)
                    throw e_14.error;
            }
        }
        if (a.c) {
            a.v = this.ir(this.ii);
            a.t = new Size(1, 20, 15);
        }
    };
    XamDataLegend.prototype.dx = function (a) {
        if (this.di != null) {
            return this.di;
        }
        var b = true;
        var c = null;
        for (var d = 0; d < a.count; d++) {
            var e = a._inner[d];
            var f = this.dv(e);
            if (f == null) {
                continue;
            }
            if (c == null) {
                c = f;
            }
            else {
                if (!Base.equalsStatic(c, f)) {
                    b = false;
                    break;
                }
            }
        }
        if (b || !stringIsNullOrEmpty(c)) {
            return c;
        }
        return null;
    };
    XamDataLegend.prototype.dv = function (a) {
        if (this.bz()) {
            var b = a.getDataLegendAxisLabelFromCursorPosition(this.cm, this.cn);
            if (typeCast(Date_$type, b) !== null) {
                var c = b;
                b = this.dw(c);
            }
            return b == null ? "" : b.toString();
        }
        else {
            return null;
        }
    };
    XamDataLegend.prototype.dw = function (a) {
        if (this.ai != null) {
            var b = this.ai.i(a);
            return b;
        }
        else {
            var c = new DateTimeFormatSpecifier();
            c.dateStyle = "short";
            c.timeStyle = "full";
            var d = this.ap;
            if (d == 0) {
                d = 1;
            }
            if (d == 3) {
                c.dateStyle = "medium";
            }
            if (d == 1) {
                c.dateStyle = "short";
            }
            if (d == 4) {
                c.dateStyle = "full";
            }
            if (d == 2) {
                c.dateStyle = "long";
            }
            if (d == 5) {
                c.dateStyle = null;
            }
            var e = this.aq;
            if (e == 0) {
                e = 1;
            }
            if (e == 3) {
                c.timeStyle = "medium";
            }
            if (e == 1) {
                c.timeStyle = "short";
            }
            if (e == 4) {
                c.timeStyle = "full";
            }
            if (e == 2) {
                c.timeStyle = "long";
            }
            if (e == 5) {
                c.timeStyle = null;
            }
            c.locale = this.dz(this.c9, "en-US");
            if (this.aj == null) {
                this.aj = new BindingFormatter();
            }
            this.aj.j = "{0}";
            this.aj.d = [c];
            var f = this.aj.i(a);
            return f;
        }
    };
    XamDataLegend.prototype.fn = function () {
    };
    XamDataLegend.$t = markType(XamDataLegend, 'XamDataLegend', Control.$, [INotifyPropertyChanged_$type, IDataLegend_$type, IOnDemandRender_$type]);
    XamDataLegend.$$p = markDep(DependencyProperty, PropertyMetadata, XamDataLegend, 'fy', ['BadgeMargin:ii:gj', [Thickness.$, new Thickness(1, 0, 0, 0, 0)], 'BadgeShape:a8:gk', [LegendItemBadgeShape_$type, enumGetBox(LegendItemBadgeShape_$type, 0)], 'ExcludedColumns::gl', [Array_$type, null], 'ExcludedSeries::gm', [Array_$type, null], 'HeaderFormatCulture:c9:gn', [2, stringEmpty()], 'HeaderFormatDate:ap:go', [DataLegendHeaderDateMode_$type, enumGetBox(DataLegendHeaderDateMode_$type, 0)], 'HeaderFormatSpecifiers:ag:gp', [Array_$type, null], 'HeaderFormatString:dd:gq', [2, null], 'HeaderFormatTime:aq:gr', [DataLegendHeaderTimeMode_$type, enumGetBox(DataLegendHeaderTimeMode_$type, 0)], 'HeaderRowMargin:ij:gs', [Thickness.$, new Thickness(0, 5)], 'HeaderRowVisible:b0:gt', [0, true], 'HeaderTextColor:h1:gu', [Brush.$, null], 'HeaderTextMargin:ik:gv', [Thickness.$, new Thickness(1, 2, 0, 0, 0)], 'HeaderText:di:gw', [2, null], 'IncludedColumns::gx', [Array_$type, null], 'IncludedSeries::gy', [Array_$type, null], 'LabelDisplayMode:ar:gz', [DataLegendLabelMode_$type, enumGetBox(DataLegendLabelMode_$type, 0)], 'LabelTextColor:h2:g0', [Brush.$, null], 'LabelTextMargin:il:g1', [Thickness.$, new Thickness(1, 12, 0, 0, 0)], 'ShouldUpdateWhenSeriesDataChanges:b3:g2', [0, true], 'SummaryLabelTextColor:h4:g3', [Brush.$, null], 'SummaryLabelText:d4:g4', [2, null], 'SummaryRowMargin:im:g5', [Thickness.$, new Thickness(0, 5)], 'SummaryTitleTextColor:h5:g6', [Brush.$, null], 'SummaryTitleTextMargin:io:g7', [Thickness.$, new Thickness(1, 2, 0, 4, 0)], 'SummaryTitleText:d9:g8', [2, null], 'SummaryType:a1:g9', [DataLegendSummaryType_$type, enumGetBox(DataLegendSummaryType_$type, 0)], 'SummaryUnitsTextColor:h6:ha', [Brush.$, null], 'SummaryUnitsText:ef:hb', [2, null], 'SummaryValueTextColor:h7:hc', [Brush.$, null], 'TargetCursorPositionX::hd', [1, NaN], 'TargetCursorPositionY::he', [1, NaN], 'Target::hf', [4, null], 'TitleTextColor:h8:hg', [Brush.$, null], 'TitleTextMargin:ip:hh', [Thickness.$, new Thickness(1, 0, 0, 4, 0)], 'UnitsDisplayMode:a2:hi', [DataLegendUnitsMode_$type, enumGetBox(DataLegendUnitsMode_$type, 0)], 'UnitsTextColor:h9:hj', [Brush.$, null], 'UnitsTextMargin:iq:hk', [Thickness.$, new Thickness(1, 0, 0, 0, 0)], 'UnitsText:es:hl', [2, null], 'ValueFormatAbbreviation:an:hm', [DataAbbreviationMode_$type, enumGetBox(DataAbbreviationMode_$type, 0)], 'ValueFormatCulture:ey:hn', [2, stringEmpty()], 'ValueFormatCurrencyCode:e0:ho', [2, null], 'ValueFormatMaxFractions:cu:hp', [1, -1], 'ValueFormatMinFractions:cv:hq', [1, -1], 'ValueFormatMode:a3:hr', [DataLegendValueMode_$type, enumGetBox(DataLegendValueMode_$type, 0)], 'ValueFormatSpecifiers:ah:hs', [Array_$type, null], 'ValueFormatString:e6:ht', [2, null], 'ValueFormatUseGrouping:b4:hu', [0, true], 'ValueRowMargin:is:hv', [Thickness.$, new Thickness(0, 5)], 'ValueRowVisible:b5:hw', [0, true], 'ValueTextColor:ia:hx', [Brush.$, null], 'ValueTextMargin:it:hy', [Thickness.$, new Thickness(1, 2, 0, 2, 0)], 'ValueTextUseSeriesColors:b6:hz', [0, false], 'ValueTextWhenMissingData:ff:h0', [2, "N/A"]]);
    return XamDataLegend;
}(Control));
export { XamDataLegend };
/**
 * @hidden
 */
var DataLegendView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DataLegendView, _super);
    function DataLegendView(a) {
        var _this = _super.call(this) || this;
        _this.aa = null;
        _this.ac = null;
        _this.ae = null;
        _this.ad = null;
        _this.ab = null;
        _this.o = null;
        _this.q = null;
        _this.s = null;
        _this.r = null;
        _this.p = null;
        _this.a = null;
        _this.aj = null;
        _this.ai = null;
        _this.t = null;
        _this.b = null;
        _this.af = 1;
        _this.w = false;
        _this.al = -1;
        _this.ak = -1;
        _this.y = new Dictionary$2(FontInfo.$, Tuple$2.$.specialize(Number_$type, FontInfo.$), 0);
        _this.v = false;
        _this.z = new List$1(FrameworkElement.$, 0);
        _this.ag = 0;
        _this.f = null;
        _this.h = null;
        _this.g = null;
        _this.d = null;
        _this.e = null;
        _this.c = null;
        _this.u = null;
        _this.a = a;
        _this.q = ((function () {
            var $ret = new Pool$1(TextBlock.$);
            $ret.create = runOn(_this, _this.bm);
            $ret.activate = runOn(_this, _this.bb);
            $ret.disactivate = runOn(_this, _this.bd);
            $ret.destroy = runOn(_this, _this.bc);
            return $ret;
        })());
        _this.s = ((function () {
            var $ret = new Pool$1(TextBlock.$);
            $ret.create = runOn(_this, _this.bo);
            $ret.activate = runOn(_this, _this.bh);
            $ret.disactivate = runOn(_this, _this.bj);
            $ret.destroy = runOn(_this, _this.bi);
            return $ret;
        })());
        _this.r = ((function () {
            var $ret = new Pool$1(TextBlock.$);
            $ret.create = runOn(_this, _this.bn);
            $ret.activate = runOn(_this, _this.be);
            $ret.disactivate = runOn(_this, _this.bg);
            $ret.destroy = runOn(_this, _this.bf);
            return $ret;
        })());
        _this.p = ((function () {
            var $ret = new Pool$1(ContentControl.$);
            $ret.create = runOn(_this, _this.bk);
            $ret.activate = runOn(_this, _this.az);
            $ret.disactivate = runOn(_this, _this.a1);
            $ret.destroy = runOn(_this, _this.a0);
            return $ret;
        })());
        _this.o = ((function () {
            var $ret = new Pool$1(TextBlock.$);
            $ret.create = runOn(_this, _this.bl);
            $ret.activate = runOn(_this, _this.aw);
            $ret.disactivate = runOn(_this, _this.ay);
            $ret.destroy = runOn(_this, _this.ax);
            return $ret;
        })());
        _this.aa = new List$1(TextBlock.$, 0);
        _this.ac = new List$1(TextBlock.$, 0);
        _this.ae = new List$1(TextBlock.$, 0);
        _this.ad = new List$1(TextBlock.$, 0);
        _this.ab = new List$1(ContentControl.$, 0);
        return _this;
    }
    DataLegendView.prototype.as = function () {
        this.a.fp();
    };
    DataLegendView.prototype.bm = function () {
        var a = new TextBlock();
        this.ac.add(a);
        return a;
    };
    DataLegendView.prototype.bb = function (a) {
        a._visibility = 0;
    };
    DataLegendView.prototype.bd = function (a) {
        a._visibility = 1;
    };
    DataLegendView.prototype.bc = function (a) {
        this.ac.remove(a);
    };
    DataLegendView.prototype.bo = function () {
        var a = new TextBlock();
        this.ae.add(a);
        return a;
    };
    DataLegendView.prototype.bh = function (a) {
        a._visibility = 0;
    };
    DataLegendView.prototype.bj = function (a) {
        a._visibility = 1;
    };
    DataLegendView.prototype.bi = function (a) {
        this.ae.remove(a);
    };
    DataLegendView.prototype.bn = function () {
        var a = new TextBlock();
        this.ad.add(a);
        return a;
    };
    DataLegendView.prototype.be = function (a) {
        a._visibility = 0;
    };
    DataLegendView.prototype.bg = function (a) {
        a._visibility = 1;
    };
    DataLegendView.prototype.bf = function (a) {
        this.ad.remove(a);
    };
    DataLegendView.prototype.bl = function () {
        var a = new TextBlock();
        this.aa.add(a);
        return a;
    };
    DataLegendView.prototype.aw = function (a) {
        a._visibility = 0;
    };
    DataLegendView.prototype.ay = function (a) {
        a._visibility = 1;
    };
    DataLegendView.prototype.ax = function (a) {
        this.aa.remove(a);
    };
    DataLegendView.prototype.bk = function () {
        var a = new ContentControl();
        this.ab.add(a);
        return a;
    };
    DataLegendView.prototype.az = function (a) {
        a._visibility = 0;
    };
    DataLegendView.prototype.a1 = function (a) {
        a._visibility = 1;
    };
    DataLegendView.prototype.a0 = function (a) {
    };
    DataLegendView.prototype.av = function () {
        var a = this.a.pixelScalingRatio;
        var b = this.a.co;
        if (!isNaN_(a) && a != 0) {
            return;
        }
        if (window.devicePixelRatio != undefined && window.devicePixelRatio != b) {
            this.a.co = window.devicePixelRatio;
        }
    };
    DataLegendView.prototype.a4 = function () {
        this.av();
        var a = Math.round(this.ai.rootWrapper.width());
        var b = Math.round(this.ai.rootWrapper.height());
        this.a.ic = new Rect(0, 0, 0, a, b);
        if (this.b != null) {
            this.b.bl = this.a.ic;
        }
        this.a.f3();
    };
    DataLegendView.prototype.am = function () {
        if (this.b != null) {
            this.b.ao = null;
            this.b.av();
        }
    };
    DataLegendView.prototype.a3 = function (a, b) {
        if (a == null) {
            this.aj = null;
            this.ai = null;
            this.t = null;
            this.am();
            return;
        }
        this.af = (isNaN_(this.a.pixelScalingRatio) ? this.a.co : this.a.pixelScalingRatio);
        var c = a;
        this.ai = c;
        var d = this.af;
        var e = Math.round(c.rootWrapper.width());
        var f = Math.round(c.rootWrapper.height());
        var g = e * d;
        var h = f * d;
        this.ai.rootWrapper.setStyleProperty("position", "relative");
        var i = this.ai.createElement("canvas");
        i.setStyleProperty("position", "absolute");
        this.ai.append(i);
        this.al = truncate(Math.round(g));
        this.ak = truncate(Math.round(h));
        i.setAttribute("width", g.toString());
        i.setAttribute("height", h.toString());
        i.setStyleProperty("width", e.toString() + "px");
        i.setStyleProperty("height", f.toString() + "px");
        this.a.ic = new Rect(0, 0, 0, e, f);
        this.aj = i;
        var j = this.ai.get2DCanvasContext(this.aj);
        this.t = new RenderingContext(new CanvasViewRenderer(), j);
        this.am();
        if (TypeRegistrar.isRegistered("CanvasGestureDOMEventProxy")) {
            this.b = typeCast(EventProxy.$, TypeRegistrar.create("CanvasGestureDOMEventProxy", this.ai.rootWrapper, this.ai, false));
        }
        if (this.b != null) {
        }
    };
    DataLegendView.prototype.au = function (a, b) {
        this.a4();
    };
    DataLegendView.prototype.at = function (a) {
    };
    DataLegendView.prototype.a7 = function () {
        var a = this.a.ic.width;
        var b = this.a.ic.height;
        var c = Math.round(a * this.af);
        var d = Math.round(b * this.af);
        if (this.al != c || this.ak != d) {
            this.aj.setAttribute("width", c.toString());
            this.aj.setAttribute("height", d.toString());
            this.aj.setStyleProperty("width", a.toString() + "px");
            this.aj.setStyleProperty("height", b.toString() + "px");
            this.al = truncate(Math.round(c));
            this.ak = truncate(Math.round(d));
        }
        this.a8(this.t, this.af);
    };
    DataLegendView.prototype.a8 = function (a, b) {
        if (this.t == null) {
            this.w = true;
            this.t = a;
        }
        if (a.d && b != 1) {
            a.aa();
            a.ab(b, b);
        }
        if (a == this.t) {
            if (!a.e) {
                a.l(this.a.ic.left, this.a.ic.top, this.a.ic.width, this.a.ic.height);
            }
        }
        var c = new DataTemplatePassInfo();
        c.passID = "LegendItem";
        for (var d = 0; d < this.ab.count; d++) {
            var e = this.ab._inner[d];
            if (e == null) {
                continue;
            }
            var f = e.ah;
            if (f == null) {
                continue;
            }
            var g = new DataTemplateMeasureInfo();
            g.passInfo = c;
            g.context = this.t.h();
            g.width = e.width;
            g.height = e.height;
            g.data = e.content;
            g.renderContext = a;
            f.measure(g);
            var h = new DataTemplateRenderInfo();
            h.availableWidth = e.width;
            h.availableHeight = e.height;
            h.passInfo = c;
            h.context = a.h();
            h.renderContext = a;
            h.data = e.content;
            h.xPosition = e.n;
            h.yPosition = e.o;
            a.aa();
            a.ag(e.n, e.o);
            f.render(h);
            a.z();
        }
        for (var i = 0; i < this.ac.count; i++) {
            var j = this.ac._inner[i];
            a.ad(j.dataContext);
            a.x(j);
        }
        for (var k = 0; k < this.aa.count; k++) {
            var l = this.aa._inner[k];
            a.ad(l.dataContext);
            a.x(l);
        }
        for (var m = 0; m < this.ae.count; m++) {
            var n = this.ae._inner[m];
            a.ad(n.dataContext);
            a.x(n);
        }
        for (var o = 0; o < this.ad.count; o++) {
            var p = this.ad._inner[o];
            a.ad(p.dataContext);
            a.x(p);
        }
        if (a.d && b != 1) {
            a.z();
        }
    };
    DataLegendView.prototype.x = function () {
        if (this.ai != null) {
            this.ai.setTimeout(runOn(this.a, this.a.fp), 0);
            return true;
        }
        return false;
    };
    DataLegendView.prototype.bv = function (a, b) {
        this.t.ad(b);
        var c = new TextBlock();
        c.al = a;
        var d = this.t.ah(c, this.ah(b), true);
        return new Size(1, d.c, d.b);
    };
    DataLegendView.prototype.ah = function (a) {
        if (this.y.containsKey(a)) {
            var b = this.y.item(a);
            if (b.d.g == a.g) {
                return b.c;
            }
        }
        var c = FontUtil.getCurrentFontHeight(this.ai, a);
        var d = new Tuple$2(Number_$type, FontInfo.$, c, a);
        this.y.item(a, d);
        return c;
    };
    DataLegendView.prototype.a9 = function (a, b, c) {
        if (this.v) {
            this.z.add(a);
        }
        a.n = b;
        a.o = c;
    };
    DataLegendView.prototype.ar = function (a) {
        this.a7();
    };
    DataLegendView.prototype.ap = function (a, b) {
        a.dataContext = b;
    };
    DataLegendView.prototype.bu = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bs = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bt = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bq = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.br = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bp = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.l = function () {
        if (this.f == null) {
            this.f = ((function () {
                var $ret = new FontInfo();
                $ret.n = FontDefaults.dataLegendFontFamily;
                $ret.d = FontDefaults.dataLegendFontSize;
                $ret.q = FontDefaults.dataLegendFontStyle;
                $ret.s = FontDefaults.dataLegendFontWeight;
                $ret.o = FontDefaults.dataLegendFontStretch;
                $ret.r = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.f;
    };
    DataLegendView.prototype.n = function () {
        if (this.h == null) {
            this.h = ((function () {
                var $ret = new FontInfo();
                $ret.n = FontDefaults.dataLegendFontFamily;
                $ret.d = FontDefaults.dataLegendFontSize;
                $ret.q = FontDefaults.dataLegendFontStyle;
                $ret.s = FontDefaults.dataLegendFontWeight;
                $ret.o = FontDefaults.dataLegendFontStretch;
                $ret.r = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.h;
    };
    DataLegendView.prototype.m = function () {
        if (this.g == null) {
            this.g = ((function () {
                var $ret = new FontInfo();
                $ret.n = FontDefaults.dataLegendFontFamily;
                $ret.d = FontDefaults.dataLegendFontSize;
                $ret.q = FontDefaults.dataLegendFontStyle;
                $ret.s = FontDefaults.dataLegendFontWeight;
                $ret.o = FontDefaults.dataLegendFontStretch;
                $ret.r = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.g;
    };
    DataLegendView.prototype.j = function () {
        if (this.d == null) {
            this.d = ((function () {
                var $ret = new FontInfo();
                $ret.n = FontDefaults.dataLegendFontFamily;
                $ret.d = FontDefaults.dataLegendFontSize;
                $ret.q = FontDefaults.dataLegendFontStyle;
                $ret.s = FontDefaults.dataLegendFontWeight;
                $ret.o = FontDefaults.dataLegendFontStretch;
                $ret.r = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.d;
    };
    DataLegendView.prototype.k = function () {
        if (this.e == null) {
            this.e = ((function () {
                var $ret = new FontInfo();
                $ret.n = FontDefaults.dataLegendFontFamily;
                $ret.d = FontDefaults.dataLegendFontSize;
                $ret.q = FontDefaults.dataLegendFontStyle;
                $ret.s = FontDefaults.dataLegendFontWeight;
                $ret.o = FontDefaults.dataLegendFontStretch;
                $ret.r = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.e;
    };
    DataLegendView.prototype.i = function () {
        if (this.c == null) {
            this.c = ((function () {
                var $ret = new FontInfo();
                $ret.n = FontDefaults.dataLegendFontFamily;
                $ret.d = FontDefaults.dataLegendFontSize;
                $ret.q = FontDefaults.dataLegendFontStyle;
                $ret.s = FontDefaults.dataLegendHeaderFontWeight;
                $ret.o = FontDefaults.dataLegendFontStretch;
                $ret.r = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.c;
    };
    DataLegendView.prototype.an = function (a, b) {
        var model_ = this.a;
        var ext_ = model_.externalObject;
        if (ext_ != null) {
            var width_ = a;
            var height_ = b;
            this.ai.rootWrapper.setStyleProperty("min-height", b + "px");
            this.ai.rootWrapper.setStyleProperty("min-width", a + "px");
            this.a.notifySizeChanged();
        }
    };
    DataLegendView.prototype.a6 = function (a) {
        this.af = a;
    };
    DataLegendView.prototype.a2 = function () {
        if (this.b != null) {
            this.b.at(this.aj, "");
        }
    };
    DataLegendView.prototype.a5 = function () {
        if (this.b != null) {
            this.b.bh(this.aj, "");
        }
    };
    DataLegendView.prototype.aq = function (a, b) {
        a.ag = true;
        var c = this.t.ah(a, this.ah(b), true);
    };
    DataLegendView.prototype.ba = function () {
        this.z.clear();
        this.v = true;
        this.ag = 0;
    };
    DataLegendView.prototype.ao = function () {
        for (var a = 0; a < this.z.count; a++) {
            this.ag = Math.max(this.ag, this.z._inner[a].ah);
        }
        if (this.ag > 0) {
            for (var b = 0; b < this.z.count; b++) {
                this.z._inner[b].ah = this.ag;
            }
        }
        this.v = false;
        this.ag = 0;
    };
    DataLegendView.$t = markType(DataLegendView, 'DataLegendView');
    return DataLegendView;
}(Base));
export { DataLegendView };
