UNPKG

igniteui-angular-charts

Version:

Ignite UI Angular charting components for building rich data visualizations for modern web apps.

3,355 lines 117 kB
/*
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, stringContains } 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 { DataLegendLayoutMode_$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 { ILegendContext_$type } from "igniteui-angular-core";
import { AppearanceHelper } from "igniteui-angular-core";
import { RectData } from "igniteui-angular-core";
import { PrimitiveAppearanceData } 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 { IDataLegendSeries_$type } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { DataLegendSeriesGroupInfo } from "./DataLegendSeriesGroupInfo";
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 { DataLegendColumn } from "./DataLegendColumn";
import { DataLegendSummaryColumn } 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 { EventProxy } from "igniteui-angular-core";
import { Tuple$2 } from "igniteui-angular-core";
import { CanvasScalingHelpers } from "igniteui-angular-core";
import { CanvasViewRenderer } from "igniteui-angular-core";
import { DataTemplatePassInfo } from "igniteui-angular-core";
import { Rectangle } 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, e) {
        var _this = _super.call(this) || this;
        _this.g = 0;
        _this.c = false;
        _this.e = false;
        _this.a = false;
        _this.b = false;
        _this.d = false;
        _this.f = false;
        _this.g = e;
        _this.e = b;
        _this.b = c;
        _this.a = d;
        _this.d = !c && !b && !d;
        _this.c = true;
        _this.f = false;
        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, e) {
        var _this = _super.call(this, a, b, c, d, e) || this;
        _this.u = 0;
        _this.h = 0;
        _this.t = 0;
        _this.y = null;
        _this.x = null;
        _this.v = null;
        _this.z = null;
        _this.w = null;
        _this.ab = null;
        _this.ac = null;
        _this.ad = null;
        _this.i = null;
        _this.k = null;
        _this.j = null;
        _this.an = null;
        _this.ap = null;
        _this.ao = null;
        _this.ai = new Size();
        _this.am = new Size();
        _this.ak = new Size();
        _this.o = false;
        _this.l = false;
        _this.ae = null;
        _this.ag = null;
        _this.af = null;
        _this.ah = new Size();
        _this.al = new Size();
        _this.aj = new Size();
        _this.t = NaN;
        _this.an = new Thickness(0, 0);
        _this.ap = new Thickness(0, 0);
        _this.ao = new Thickness(0, 0);
        _this.ai = new Size(1, 0, 0);
        _this.am = new Size(1, 0, 0);
        _this.ak = new Size(1, 0, 0);
        _this.o = true;
        _this.l = true;
        if (_this.d) {
            _this.ab = a.bw();
            _this.ad = a.by();
            _this.ac = a.bx();
            _this.i = a.l();
            _this.k = a.p();
            _this.j = a.o();
        }
        else if (_this.e) {
            var f = a.bv();
            var g = a.m();
            _this.ab = f;
            _this.ad = f;
            _this.ac = f;
            _this.i = g;
            _this.k = g;
            _this.j = g;
        }
        else if (_this.a) {
            var h = a.bs();
            var i = a.j();
            _this.ab = h;
            _this.ad = h;
            _this.ac = h;
            _this.i = i;
            _this.k = i;
            _this.j = i;
        }
        else {
            var j = a.bt();
            var k = a.k();
            _this.ab = j;
            _this.ad = j;
            _this.ac = j;
            _this.i = k;
            _this.k = k;
            _this.j = k;
        }
        _this.ae = Rect.empty;
        _this.ag = Rect.empty;
        _this.af = Rect.empty;
        return _this;
    }
    DataLegendRowCell.prototype.m = 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.r = function () {
        return this.am.width > 0 && this.am.height > 0;
    };
    DataLegendRowCell.prototype.n = function () {
        return this.v != null;
    };
    DataLegendRowCell.prototype.q = function () {
        return this.w != null;
    };
    DataLegendRowCell.prototype.s = function () {
        return !stringIsNullOrEmpty(this.z) && this.am.width > 0 && this.am.height > 0;
    };
    DataLegendRowCell.prototype.aa = function () {
        this.ah = new Size(1, 0, 0);
        this.al = new Size(1, 0, 0);
        this.aj = 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, e) {
        var _this = _super.call(this, a, b, c, d, e) || this;
        _this.m = null;
        _this.l = false;
        _this.q = null;
        _this.h = null;
        _this.i = null;
        _this.r = null;
        _this.u = null;
        _this.k = null;
        _this.y = new Size();
        _this.ab = null;
        _this.p = null;
        _this.t = null;
        _this.x = new Size();
        _this.n = null;
        _this.j = 0;
        _this.o = null;
        _this.aa = null;
        _this.z = null;
        _this.v = null;
        _this.w = null;
        _this.h = new Array(0);
        _this.m = new List$1(DataLegendRowCell.$, 0);
        _this.l = _this.d;
        _this.aa = new Thickness(0, 0);
        _this.z = new Thickness(0, 0);
        _this.ab = new Thickness(0, 0);
        _this.x = new Size(1, 0, 0);
        _this.y = new Size(1, 0, 0);
        if (_this.d) {
            _this.u = a.bw();
            _this.k = a.n();
        }
        else if (_this.e) {
            var f = a.bv();
            var g = a.m();
            _this.u = f;
            _this.k = g;
        }
        else if (_this.a) {
            var h = a.bs();
            var i = a.j();
            _this.u = h;
            _this.k = i;
        }
        else {
            var j = a.bt();
            var k = a.k();
            _this.u = j;
            _this.k = k;
        }
        _this.w = Rect.empty;
        _this.v = Rect.empty;
        _this.j = 7;
        _this.o = "None";
        return _this;
    }
    DataLegendRowInfo.prototype.s = function (a) {
        if (this.m == null) {
            return;
        }
        for (var b = 0; b < this.m.count; b++) {
            a(this.m._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.b0 = false;
        _this.cn = NaN;
        _this.co = NaN;
        _this.cp = 1;
        _this.jt = new Thickness(0, 0);
        _this.i9 = BrushUtil.j(0, 255, 255, 255);
        _this.i8 = BrushUtil.j(0, 255, 255, 255);
        _this.b1 = false;
        _this.bm = null;
        _this.be = null;
        _this.bd = null;
        _this.bh = null;
        _this.bj = null;
        _this.bg = null;
        _this.bi = null;
        _this.a9 = null;
        _this.bl = null;
        _this.bk = null;
        _this.b7 = false;
        _this.bf = null;
        _this.cq = NaN;
        _this.calculateColumnSummary = null;
        _this.styleHeaderRow = null;
        _this.styleGroupRow = null;
        _this.styleSeriesRow = null;
        _this.styleSummaryRow = null;
        _this.styleSeriesColumn = null;
        _this.styleSummaryColumn = null;
        _this.propertyChanged = null;
        _this.ce = null;
        _this.cd = null;
        _this.ch = null;
        _this.cg = null;
        _this.a7 = null;
        _this.jm = null;
        _this._externalObject = null;
        _this.by = false;
        _this.bz = false;
        _this.cm = null;
        _this.cf = new Dictionary$2(String_$type, DataLegendSeriesGroupInfo.$, 0);
        _this.cj = new List$1(String_$type, 0);
        _this.ao = new DataLegendContent();
        _this.cy = 0;
        _this.ak = null;
        _this.al = null;
        _this.c4 = "";
        _this.ai = null;
        _this.aj = null;
        _this.jm = Rect.empty;
        _this.b1 = true;
        _this.ab = XamDataLegend.$;
        _this.gt();
        _this.gu();
        _this.gv();
        _this.a7 = _this.a6();
        return _this;
    }
    Object.defineProperty(XamDataLegend.prototype, "cr", {
        get: function () {
            return this.cn;
        },
        set: function (a) {
            var b = this.cn;
            this.cn = a;
            if (b != this.cn) {
                this.gj("ActualCursorPositionX", b, this.cn);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "cs", {
        get: function () {
            return this.co;
        },
        set: function (a) {
            var b = this.co;
            this.co = a;
            if (b != this.co) {
                this.gj("ActualCursorPositionY", b, this.co);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "ct", {
        get: function () {
            return this.cp;
        },
        set: function (a) {
            var b = this.cp;
            this.cp = a;
            this.gj("ActualPixelScalingRatio", b, this.cp);
        },
        enumerable: false,
        configurable: true
    });
    XamDataLegend.prototype.gv = function () {
        if (isNaN_(this.cw)) {
            this.jr = this.jt;
        }
        else {
            if (this.cw > 0) {
                this.jr = new Thickness(0, this.cw);
            }
            else {
                this.jr = this.jt;
            }
        }
    };
    XamDataLegend.prototype.gu = function () {
        if (this.i7 == null) {
            this.i5 = this.i9;
        }
        else {
            this.i5 = this.i7;
        }
    };
    XamDataLegend.prototype.gt = function () {
        if (this.i6 == null) {
            this.i4 = this.i8;
        }
        else {
            this.i4 = this.i6;
        }
    };
    Object.defineProperty(XamDataLegend.prototype, "bx", {
        get: function () {
            return this.bm;
        },
        set: function (a) {
            var b = this.bm;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.p();
            }
            this.bm = a;
            if (b != this.bm) {
                this.gj("ValueTextStyle", b, this.bm);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bp", {
        get: function () {
            return this.be;
        },
        set: function (a) {
            var b = this.be;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.k();
            }
            this.be = a;
            if (b != this.be) {
                this.gj("HeaderTextStyle", b, this.be);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bo", {
        get: function () {
            return this.bd;
        },
        set: function (a) {
            var b = this.bd;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.j();
            }
            this.bd = a;
            if (b != this.bd) {
                this.gj("GroupTextStyle", b, this.bd);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bs", {
        get: function () {
            return this.bh;
        },
        set: function (a) {
            var b = this.bh;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.m();
            }
            this.bh = a;
            if (b != this.bh) {
                this.gj("SummaryTitleTextStyle", b, this.bh);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bu", {
        get: function () {
            return this.bj;
        },
        set: function (a) {
            var b = this.bj;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.p();
            }
            this.bj = a;
            if (b != this.bj) {
                this.gj("SummaryValueTextStyle", b, this.bj);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "br", {
        get: function () {
            return this.bg;
        },
        set: function (a) {
            var b = this.bg;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.l();
            }
            this.bg = a;
            if (b != this.bg) {
                this.gj("SummaryLabelTextStyle", b, this.bg);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bt", {
        get: function () {
            return this.bi;
        },
        set: function (a) {
            var b = this.bi;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.o();
            }
            this.bi = a;
            if (b != this.bi) {
                this.gj("SummaryUnitsTextStyle", b, this.bi);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bw", {
        get: function () {
            return this.bl;
        },
        set: function (a) {
            var b = this.bl;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.o();
            }
            this.bl = a;
            if (b != this.bl) {
                this.gj("UnitsTextStyle", b, this.bl);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bv", {
        get: function () {
            return this.bk;
        },
        set: function (a) {
            var b = this.bk;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.n();
            }
            this.bk = a;
            if (b != this.bk) {
                this.gj("TitleTextStyle", b, this.bk);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "bq", {
        get: function () {
            return this.bf;
        },
        set: function (a) {
            var b = this.bf;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a7.al, a);
            }
            else if (a == null || a.c()) {
                a = this.a7.l();
            }
            this.bf = a;
            if (b != this.bf) {
                this.gj("LabelTextStyle", b, this.bf);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamDataLegend.prototype, "pixelScalingRatio", {
        get: function () {
            return this.cq;
        },
        set: function (a) {
            var b = this.cq;
            this.cq = a;
            this.gj("PixelScalingRatio", b, this.cq);
        },
        enumerable: false,
        configurable: true
    });
    XamDataLegend.prototype.exportSerializedVisualData = function () {
        var a = this.exportVisualData();
        return a.serialize();
    };
    XamDataLegend.prototype.cv = 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.cu = function (a, b) {
        return Math.min(b.left, a);
    };
    XamDataLegend.prototype.jl = 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;
        a.background = AppearanceHelper.b(this.i4);
        a.borderBrush = AppearanceHelper.b(this.i5);
        if (this.jr != null) {
            a.borderThicknessTop = this.jr.top;
            a.borderThicknessLeft = this.jr.left;
            a.borderThicknessRight = this.jr.right;
            a.borderThicknessBottom = this.jr.bottom;
        }
        if (this.a7 == null) {
            return a;
        }
        var b = -1;
        var c = -1;
        var d = -1;
        var e = -1;
        var f = this.a7.af;
        var g = this.a7.ad;
        var h = this.a7.ah;
        var i = this.a7.ag;
        if (Rect.l_op_Equality(this.jm, null) || this.jm.isEmpty) {
            a.viewport = null;
        }
        else {
            a.viewport = new RectData(0, 0, this.jm.width, this.jm.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.g;
            l.rowMarginTop = k.aa.top;
            l.rowMarginBottom = k.aa.bottom;
            l.rowMarginRight = k.aa.right;
            l.rowMarginLeft = k.aa.left;
            var m = Rect.empty;
            if (k.c) {
                if (Extensions.b(k.w) && f.count > (b + 1)) {
                    b++;
                    var n = f._inner[b];
                    var o = this.bn(n, k.k);
                    var p = new DataLegendVisualDataColumn();
                    p.bounds = RectData.b(k.w);
                    p.text = n.al;
                    p.textColor = AppearanceHelper.b(k.u);
                    p.marginTop = k.ab.top;
                    p.marginLeft = k.ab.left;
                    p.marginRight = k.ab.right;
                    p.marginBottom = k.ab.bottom;
                    this.gw(p, o);
                    l.columns.add(p);
                    m = this.jl(m, k.w);
                }
                try {
                    for (var _b = (e_1 = void 0, __values(fromEnum(k.m))), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var q = _c.value;
                        if (Extensions.b(q.ae) && g.count > (c + 1)) {
                            c++;
                            var r = g._inner[c];
                            var s = this.bn(r, q.i);
                            var t = new DataLegendVisualDataColumn();
                            t.bounds = RectData.b(q.ae);
                            t.text = r.al;
                            t.textColor = AppearanceHelper.b(q.ab);
                            t.marginTop = q.an.top;
                            t.marginLeft = q.an.left;
                            t.marginRight = q.an.right;
                            t.marginBottom = q.an.bottom;
                            this.gw(t, s);
                            l.columns.add(t);
                            m = this.jl(m, q.ae);
                        }
                        if (Extensions.b(q.ag) && h.count > (d + 1)) {
                            d++;
                            var u = h._inner[d];
                            var v = this.bn(u, q.k);
                            var w = new DataLegendVisualDataColumn();
                            w.bounds = RectData.b(q.ag);
                            w.text = u.al;
                            w.textColor = AppearanceHelper.b(q.ad);
                            w.marginTop = q.ap.top;
                            w.marginLeft = q.ap.left;
                            w.marginRight = q.ap.right;
                            w.marginBottom = q.ap.bottom;
                            this.gw(w, v);
                            l.columns.add(w);
                            m = this.jl(m, q.ag);
                        }
                        if (Extensions.b(q.af) && i.count > (e + 1)) {
                            e++;
                            var x = i._inner[e];
                            var y = this.bn(x, q.j);
                            var z = new DataLegendVisualDataColumn();
                            z.bounds = RectData.b(q.af);
                            z.text = q.o ? q.w : null;
                            z.textColor = AppearanceHelper.b(q.ac);
                            z.marginTop = q.ao.top;
                            z.marginLeft = q.ao.left;
                            z.marginRight = q.ao.right;
                            z.marginBottom = q.ao.bottom;
                            this.gw(z, y);
                            l.columns.add(z);
                            m = this.jl(m, q.af);
                        }
                    }
                }
                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.l) {
                    m = this.jl(m, k.v);
                    l.badgeBounds = RectData.b(k.v);
                    l.badgeMarginTop = k.z.top;
                    l.badgeMarginBottom = k.z.bottom;
                    l.badgeMarginRight = k.z.right;
                    l.badgeMarginLeft = k.z.left;
                    l.badgeAppearance = new PrimitiveAppearanceData();
                    var aa = typeCast(ILegendContext_$type, k.n);
                    var ab = typeCast(ILegendContext_$type, k.i);
                    l.badgeAppearance.fill = AppearanceHelper.b(aa.actualItemBrush);
                    l.badgeAppearance.stroke = AppearanceHelper.b(aa.outline);
                    l.badgeShape = k.o;
                }
                l.rowBounds = RectData.b(m);
            }
            a.rows.add(l);
        }
        return a;
    };
    XamDataLegend.prototype.gw = function (a, b) {
        if (b != null) {
            if (b.q != null) {
                a.fontFamily = b.q;
            }
            if (!isNaN_(b.f)) {
                a.fontSize = b.f;
            }
            a.fontWeight = stringIsNullOrEmpty(b.v) ? "Normal" : b.v;
            a.fontStyle = stringIsNullOrEmpty(b.t) ? "Normal" : b.t;
            if (b.r != null) {
                a.fontStretch = b.t;
            }
        }
    };
    XamDataLegend.prototype.bn = 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.a7.al, b.fontString);
        }
    };
    XamDataLegend.prototype.a2 = 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.a8 = function () {
        switch (this.a3) {
            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.g1 = function (a) {
        if (this.styleSummaryRow != null) {
            var b = this.a0(a);
            this.styleSummaryRow(this, b);
            this.gx(a, b);
        }
        if (a.c && a.m != null && this.styleSummaryColumn != null) {
            for (var c = 0; c < a.m.count; c++) {
                var d = this.az(a.m._inner[c]);
                d.d = a.g;
                d.g = a.q;
                d.c = c;
                d.e = a.p;
                this.styleSummaryColumn(this, d);
                this.g2(a.m._inner[c], d);
            }
        }
    };
    XamDataLegend.prototype.g0 = function (a) {
        if (this.styleSeriesRow != null) {
            var b = this.a0(a);
            this.styleSeriesRow(this, b);
            this.gx(a, b);
        }
        if (a.c && a.m != null && this.styleSeriesColumn != null) {
            for (var c = 0; c < a.m.count; c++) {
                var d = this.az(a.m._inner[c]);
                d.d = a.g;
                d.g = a.q;
                d.c = c;
                d.e = a.p;
                this.styleSeriesColumn(this, d);
                this.g2(a.m._inner[c], d);
            }
        }
    };
    XamDataLegend.prototype.gz = function (a) {
        if (this.styleHeaderRow != null) {
            var b = this.a0(a);
            this.styleHeaderRow(this, b);
            this.gx(a, b);
        }
    };
    XamDataLegend.prototype.gy = function (a) {
        if (this.styleGroupRow != null) {
            var b = this.a0(a);
            this.styleGroupRow(this, b);
            this.gx(a, b);
        }
    };
    XamDataLegend.prototype.a0 = function (a) {
        var b = new DataLegendStylingRowEventArgs();
        b.g = a.r;
        b.h = a.u;
        b.e = a.p;
        b.a = a.j;
        b.b = a.l;
        b.c = a.c;
        b.d = a.g;
        b.f = a.q;
        return b;
    };
    XamDataLegend.prototype.gx = function (a, b) {
        a.r = b.g;
        a.u = b.h;
        a.j = b.a;
        a.l = b.b;
        a.c = b.c;
    };
    XamDataLegend.prototype.az = function (a) {
        var b = new DataLegendStylingColumnEventArgs();
        b.f = a.v;
        b.l = a.ab;
        b.h = a.w;
        b.m = a.ac;
        b.k = a.z;
        b.n = a.ad;
        b.b = a.t;
        b.j = a.y;
        b.i = a.x;
        b.a = a.h;
        return b;
    };
    XamDataLegend.prototype.g2 = function (a, b) {
        a.ab = b.l;
        a.v = b.f;
        a.l = !stringIsNullOrEmpty(a.v);
        a.w = b.h;
        a.ac = b.m;
        a.o = !stringIsNullOrEmpty(a.w);
        a.z = b.k;
        a.ad = b.n;
    };
    XamDataLegend.prototype.gm = function (a, b, c) {
        var _this = this;
        switch (a) {
            case XamDataLegend.$$p[5]:
                this.gt();
                break;
            case XamDataLegend.$$p[6]:
                this.gv();
                this.gu();
                break;
            case XamDataLegend.$$p[7]:
                this.gv();
                break;
            case XamDataLegend.$$p[31]:
                this.b1 = c;
                break;
            case XamDataLegend.$$p[25]:
            case XamDataLegend.$$p[9]:
                this.g6();
                break;
            case XamDataLegend.$$p[24]:
            case XamDataLegend.$$p[8]:
                this.g5();
                break;
            case XamDataLegend.$$p[44]:
                var d = c;
                var e = b;
                this.gk(e, d);
                break;
            case XamDataLegend.$$p[42]:
                if (this.b6(this.targetCursorPositionX)) {
                    this.cr = this.targetCursorPositionX;
                }
                break;
            case XamDataLegend.$$p[43]:
                if (this.b6(this.targetCursorPositionY)) {
                    this.cs = this.targetCursorPositionY;
                }
                break;
            case XamDataLegend.$$p[58]:
            case XamDataLegend.$$p[57]:
                if (!stringIsNullOrEmpty(this.fo)) {
                    this.ak = ((function () {
                        var $ret = new BindingFormatter();
                        $ret.j = _this.fo;
                        $ret.d = _this.ah;
                        return $ret;
                    })());
                }
                else {
                    this.ak = null;
                }
                break;
            case XamDataLegend.$$p[17]:
            case XamDataLegend.$$p[16]:
                if (!stringIsNullOrEmpty(this.dv)) {
                    this.ai = ((function () {
                        var $ret = new BindingFormatter();
                        $ret.j = _this.dv;
                        $ret.d = _this.ag;
                        return $ret;
                    })());
                }
                else {
                    this.ai = null;
                }
                break;
            case "PixelScalingRatio":
                if (isNaN_(this.ct)) {
                    this.a7.ay();
                }
                else {
                    this.ct = this.pixelScalingRatio;
                }
                break;
            case "ActualPixelScalingRatio":
                this.a7.a9(c);
                break;
        }
        this.go();
    };
    XamDataLegend.prototype.gj = function (a, b, c) {
        this.gm(a, b, c);
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
    };
    XamDataLegend.prototype.gk = function (a, b) {
        this.a9 = b;
        if (a != null) {
            a.detachDataLegend(this);
        }
        if (b != null) {
            b.attachDataLegend(this);
            if (isNaN_(this.targetCursorPositionX)) {
                this.cr = -1;
            }
            if (isNaN_(this.targetCursorPositionY)) {
                this.cs = -1;
            }
        }
    };
    XamDataLegend.prototype.g6 = function () {
        this.ch = this.ci(this.includedSeries);
        this.cg = this.ci(this.excludedSeries);
    };
    XamDataLegend.prototype.g5 = function () {
        var e_2, _a, e_3, _b;
        this.ce = this.ci(this.includedColumns);
        this.cd = this.ci(this.excludedColumns);
        if (this.ce != null) {
            var a = new List$1(String_$type, 1, this.ce.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.ce.item(b);
                    if (!this.ce.containsKey(c)) {
                        this.ce.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.f0(this.ce);
        }
        if (this.cd != null) {
            var e = new List$1(String_$type, 1, this.cd.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.cd.item(f);
                    if (!this.cd.containsKey(g)) {
                        this.cd.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.f0(this.cd);
        }
    };
    XamDataLegend.prototype.f0 = 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.ci = 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.b6 = 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.b6(a.x);
        var d = !isNaN_(a.y) && this.b6(a.y);
        if (!b && c && d) {
            this.cr = a.x;
            this.cs = a.y;
        }
    };
    XamDataLegend.prototype.notifySizeChanged = function () {
        this.a7.a7();
    };
    XamDataLegend.prototype.notifyVisualPropertiesChanged = function (a) {
    };
    XamDataLegend.prototype.notifySeriesCollectionChanged = function () {
        this.go();
    };
    XamDataLegend.prototype.notifySeriesDataChanged = function () {
        if (this.b1) {
            this.go();
        }
    };
    XamDataLegend.prototype.updatePropertyByName = function (a, b) {
        switch (a) {
            case XamDataLegend.$$p[26]:
                this.isEmbeddedInDataTooltip = b;
                break;
            case XamDataLegend.$$p[25]:
                this.includedSeries = b;
                break;
            case XamDataLegend.$$p[9]:
                this.excludedSeries = b;
                break;
            case XamDataLegend.$$p[24]:
                this.includedColumns = b;
                break;
            case XamDataLegend.$$p[8]:
                this.excludedColumns = b;
                break;
            case XamDataLegend.$$p[51]:
                this.an = EnumUtil.getEnumValue(DataAbbreviationMode_$type, b);
                break;
            case XamDataLegend.$$p[54]:
                this.c0 = typeGetValue(b);
                break;
            case XamDataLegend.$$p[55]:
                this.c1 = typeGetValue(b);
                break;
            case XamDataLegend.$$p[56]:
                this.a5 = EnumUtil.getEnumValue(DataLegendValueMode_$type, b);
                break;
            case XamDataLegend.$$p[52]:
                this.fg = b;
                break;
            case XamDataLegend.$$p[59]:
                this.ca = b;
                break;
            case XamDataLegend.$$p[58]:
                this.fo = b;
                break;
            case XamDataLegend.$$p[57]:
                this.ah = b;
                break;
            case XamDataLegend.$$p[60]:
                this.j4 = b;
                break;
            case XamDataLegend.$$p[61]:
                this.cb = b;
                break;
            case XamDataLegend.$$p[65]:
                this.fx = b;
                break;
            case XamDataLegend.$$p[64]:
                this.cc = b;
                break;
            case XamDataLegend.$$p[63]:
                this.j5 = b;
                break;
            case XamDataLegend.$$p[62]:
                this.jk = b;
                break;
            case "ValueTextStyle":
                this.bx = b;
                break;
            case XamDataLegend.$$p[17]:
                this.dv = b;
                break;
            case XamDataLegend.$$p[16]:
                this.ag = b;
                break;
            case XamDataLegend.$$p[14]:
                this.dr = b;
                break;
            case XamDataLegend.$$p[15]:
                this.ap = EnumUtil.getEnumValue(DataLegendHeaderDateMode_$type, b);
                break;
            case XamDataLegend.$$p[18]:
                this.aq = EnumUtil.getEnumValue(DataLegendHeaderTimeMode_$type, b);
                break;
            case XamDataLegend.$$p[23]:
                this.d0 = b;
                break;
            case XamDataLegend.$$p[21]:
                this.jb = b;
                break;
            case XamDataLegend.$$p[22]:
                this.jx = b;
                break;
            case XamDataLegend.$$p[19]:
                this.jw = b;
                break;
            case XamDataLegend.$$p[20]:
                this.b5 = b;
                break;
            case "HeaderTextStyle":
                this.bp = b;
                break;
            case XamDataLegend.$$p[12]:
                this.ja = b;
                break;
            case XamDataLegend.$$p[13]:
                this.jv = b;
                break;
            case XamDataLegend.$$p[10]:
                this.ju = b;
                break;
            case XamDataLegend.$$p[11]:
                this.b3 = b;
                break;
            case "GroupTextStyle":
                this.bo = b;
                break;
            case XamDataLegend.$$p[35]:
                this.jf = b;
                break;
            case "SummaryTitleTextStyle":
                this.bs = b;
                break;
            case XamDataLegend.$$p[38]:
                this.a3 = EnumUtil.getEnumValue(DataLegendSummaryType_$type, b);
                break;
            case XamDataLegend.$$p[37]:
                this.er = b;
                break;
            case XamDataLegend.$$p[36]:
                this.j0 = b;
                break;
            case XamDataLegend.$$p[34]:
                this.jz = b;
                break;
            case XamDataLegend.$$p[41]:
                this.jh = b;
                break;
            case "SummaryValueTextStyle":
                this.bu = b;
                break;
            case XamDataLegend.$$p[33]:
                this.em = b;
                break;
            case XamDataLegend.$$p[32]:
                this.je = b;
                break;
            case "SummaryLabelTextStyle":
                this.br = b;
                break;
            case XamDataLegend.$$p[40]:
                this.ex = b;
                break;
            case XamDataLegend.$$p[39]:
                this.jg = b;
                break;
            case "SummaryUnitsTextStyle":
                this.bt = b;
                break;
            case XamDataLegend.$$p[3]:
                this.js = b;
                break;
            case XamDataLegend.$$p[4]:
                this.ba = EnumUtil.getEnumValue(LegendItemBadgeShape_$type, b);
                break;
            case XamDataLegend.$$p[47]:
                this.a4 = EnumUtil.getEnumValue(DataLegendUnitsMode_$type, b);
                break;
            case XamDataLegend.$$p[50]:
                this.fa = b;
                break;
            case XamDataLegend.$$p[48]:
                this.jj = b;
                break;
            case XamDataLegend.$$p[49]:
                this.j2 = b;
                break;
            case "UnitsTextStyle":
                this.bw = b;
                break;
            case XamDataLegend.$$p[46]:
                this.j1 = b;
                break;
            case XamDataLegend.$$p[45]:
                this.ji = b;
                break;
            case "TitleTextStyle":
                this.bv = b;
                break;
            case XamDataLegend.$$p[27]:
                this.ar = EnumUtil.getEnumValue(DataLegendLabelMode_$type, b);
                break;
            case XamDataLegend.$$p[28]:
                this.jc = b;
                break;
            case XamDataLegend.$$p[29]:
                this.b7 = true;
                this.jy = b;
                break;
            case XamDataLegend.$$p[30]:
                this.as = EnumUtil.getEnumValue(DataLegendLayoutMode_$type, b);
                break;
            case "LabelTextStyle":
                this.bq = b;
                break;
        }
    };
    XamDataLegend.prototype.a6 = 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.a7.av();
    };
    XamDataLegend.prototype.onAttachedToUI = function () {
        this.a7.a5();
    };
    XamDataLegend.prototype.onDetachedFromUI = function () {
        this.a7.a8();
    };
    XamDataLegend.prototype.ensureIndirectContainer = function (a, b) {
        if (this.a7.al == null) {
            this.a7.a6(a, true);
        }
    };
    XamDataLegend.prototype.provideContainer = function (a) {
        this.a7.a6(a, false);
    };
    XamDataLegend.prototype.go = function () {
        if (this.by) {
            return;
        }
        if (this.a7 != null) {
            this.by = this.a7.aa();
        }
    };
    Object.defineProperty(XamDataLegend.prototype, "shouldOnDemandRender", {
        get: function () {
            return this.bz;
        },
        set: function (a) {
            this.bz = a;
        },
        enumerable: false,
        configurable: true
    });
    XamDataLegend.prototype.doRender = function (a, b) {
        if (this.jm.isEmpty) {
            var c = this.getDesiredSize();
            this.jm = new Rect(0, 0, 0, c.width, c.height);
        }
        this.gp(true);
        this.a7.bb(a, b);
    };
    XamDataLegend.prototype.ensureUpdated = function () {
        var a = this.getDesiredSize();
    };
    XamDataLegend.prototype.f9 = function () {
        if (!this.by) {
            if (this.ao == null) {
                this.go();
            }
            else {
                return;
            }
        }
        this.g4();
    };
    XamDataLegend.prototype.getDesiredSize = function () {
        this.f9();
        if (this.ao == null) {
            return new Size(1, 0, 0);
        }
        return new Size(1, this.ao.d, this.ao.c);
    };
    XamDataLegend.prototype.g4 = function () {
        var e_5, _a, e_6, _b, e_7, _c;
        this.f6();
        if (this.a9 == null || this.a9.isDetached || !this.b4()) {
            return;
        }
        var a = this.a9;
        var b = a.getDataLegendSeries();
        this.ga(b);
        this.fz(b, "");
        this.cm = new List$1(String_$type, 0);
        try {
            for (var _d = __values(fromEnum(this.cj)), _e = _d.next(); !_e.done; _e = _d.next()) {
                var c = _e.value;
                var d = this.cf.item(c);
                this.gd(d);
                try {
                    for (var _f = (e_6 = void 0, __values(fromEnum(d.b))), _g = _f.next(); !_g.done; _g = _f.next()) {
                        var e = _g.value;
                        if (!this.cm.contains(e.h) && !stringContains(e.h, "Highlight") && !stringContains(e.h, "Overlay") && !stringContains(e.h, "Value Layer")) {
                            this.cm.add(e.h);
                        }
                    }
                }
                catch (e_6_1) {
                    e_6 = { error: e_6_1 };
                }
                finally {
                    try {
                        if (_g && !_g.done && (_b = _f.return))
                            _b.call(_f);
                    }
                    finally {
                        if (e_6)
                            throw e_6.error;
                    }
                }
            }
        }
        catch (e_5_1) {
            e_5 = { error: e_5_1 };
        }
        finally {
            try {
                if (_e && !_e.done && (_a = _d.return))
                    _a.call(_d);
            }
            finally {
                if (e_5)
                    throw e_5.error;
            }
        }
        try {
            for (var _h = __values(fromEnum(this.cj)), _j = _h.next(); !_j.done; _j = _h.next()) {
                var f = _j.value;
                var g = this.cf.item(f);
                if (g.c.count > 0) {
                    this.gc(g);
                }
            }
        }
        catch (e_7_1) {
            e_7 = { error: e_7_1 };
        }
        finally {
            try {
                if (_j && !_j.done && (_c = _h.return))
                    _c.call(_h);
            }
            finally {
                if (e_7)
                    throw e_7.error;
            }
        }
        this.b0 = this.b8();
        this.f5(this.ao);
    };
    XamDataLegend.prototype.ga = function (a) {
        var e_8, _a, e_9, _b, e_10, _c;
        var b = new Dictionary$2(Number_$type, List$1.$.specialize(IDataLegendSeries_$type), 0);
        for (var c = 0; c < a.length; c++) {
            if (!this.isEmbeddedInDataTooltip) {
                if (a[c].legendItemVisibility != 0) {
                    continue;
                }
            }
            var d = a[c].title == null ? null : a[c].title.toString();
            var e = this.ch == null || this.ch.containsKey(a[c].dataLegendKey) || this.ch.containsKey(a[c].parentKey) || this.ch.containsKey(a[c].parentTitle) || this.ch.containsKey(a[c].index.toString()) || this.ch.containsKey(a[c].group) || this.ch.containsKey(d);
            var f = this.cg != null && (this.cg.containsKey(a[c].dataLegendKey) || this.cg.containsKey(a[c].parentKey) || this.cg.containsKey(a[c].parentTitle) || this.cg.containsKey(a[c].index.toString()) || this.cg.containsKey(a[c].group) || this.cg.containsKey(d));
            if (e && !f) {
                var g = this.cz(a[c]);
                if (!b.containsKey(g)) {
                    b.addItem(g, new List$1(IDataLegendSeries_$type, 0));
                }
                b.item(g).add(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 _d = __values(fromEnum(h)), _e = _d.next(); !_e.done; _e = _d.next()) {
                var j = _e.value;
                try {
                    for (var _f = (e_9 = void 0, __values(fromEnum(b.item(j)))), _g = _f.next(); !_g.done; _g = _f.next()) {
                        var k = _g.value;
                        i.add(k);
                    }
                }
                catch (e_9_1) {
                    e_9 = { error: e_9_1 };
                }
                finally {
                    try {
                        if (_g && !_g.done && (_b = _f.return))
                            _b.call(_f);
                    }
                    finally {
                        if (e_9)
                            throw e_9.error;
                    }
                }
            }
        }
        catch (e_8_1) {
            e_8 = { error: e_8_1 };
        }
        finally {
            try {
                if (_e && !_e.done && (_a = _d.return))
                    _a.call(_d);
            }
            finally {
                if (e_8)
                    throw e_8.error;
            }
        }
        this.cf = new Dictionary$2(String_$type, DataLegendSeriesGroupInfo.$, 0);
        this.cj = new List$1(String_$type, 0);
        var _loop_1 = function (l) {
            var m = l.group;
            if (!this_1.cf.containsKey(m)) {
                this_1.cj.add(m);
                this_1.cf.addItem(m, ((function () {
                    var $ret = new DataLegendSeriesGroupInfo();
                    $ret.f = m;
                    return $ret;
                })()));
            }
            this_1.cf.item(m).c.add(l);
        };
        var this_1 = this;
        try {
            for (var _h = __values(fromEnum(i)), _j = _h.next(); !_j.done; _j = _h.next()) {
                var l = _j.value;
                _loop_1(l);
            }
        }
        catch (e_10_1) {
            e_10 = { error: e_10_1 };
        }
        finally {
            try {
                if (_j && !_j.done && (_c = _h.return))
                    _c.call(_h);
            }
            finally {
                if (e_10)
                    throw e_10.error;
            }
        }
    };
    XamDataLegend.prototype.cz = function (a) {
        if (this.ch == null) {
            return a.index;
        }
        var b = a.dataLegendKey;
        if (this.ch.containsKey(b)) {
            return this.ch.item(b);
        }
        var c = a.index.toString();
        if (this.ch.containsKey(c)) {
            return this.ch.item(c);
        }
        var d = a.title == null ? null : a.title.toString();
        if (this.ch.containsKey(d)) {
            return this.ch.item(d);
        }
        return a.index;
    };
    XamDataLegend.prototype.f8 = function () {
        this.by = false;
        if (!this.a7.z) {
            return;
        }
        var a = new Size(1, 0, 0);
        if (this.ao != null) {
            a = new Size(1, this.ao.d, this.ao.c);
        }
        this.g4();
        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.a7.aq(b.width, b.height);
        }
        this.gp(this.bz);
    };
    XamDataLegend.prototype.ge = function (message_) {
    };
    XamDataLegend.prototype.gp = function (a) {
        var b = new DataLegendRenderContext();
        for (var c = 0; c < this.ao.b.count; c++) {
            var d = this.ao.b._inner[c];
            this.gr(d, b);
        }
        this.a7.r.count = b.b;
        this.a7.s.count = b.c;
        this.a7.u.count = b.e;
        this.a7.t.count = b.d;
        this.a7.q.count = b.a;
        if (!a) {
            this.a7.au(this.ao);
        }
    };
    XamDataLegend.prototype.gr = function (a, b) {
        var e_11, _a;
        this.a7.bd();
        if (a.x.width > 0 && a.x.height > 0 && !a.b && !a.e && !a.a && a.l) {
            var c = this.a7.r.item(b.b);
            b.b += 1;
            this.gq(c, a, b);
        }
        var d = !stringIsNullOrEmpty(a.r);
        if (!a.w.isEmpty && a.w.width > 0 && d && a.w.height > 0) {
            var e = this.a7.s.item(b.c);
            b.c += 1;
            this.gs(e, a.r, a.u, a.k, a.w);
        }
        try {
            for (var _b = __values(fromEnum(a.m)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                if (!f.ag.isEmpty && f.s()) {
                    var g = this.a7.u.item(b.e);
                    b.e += 1;
                    this.gs(g, f.z, f.ad, f.k, f.ag);
                }
                if (!f.af.isEmpty && f.q() && f.o) {
                    var h = this.a7.t.item(b.d);
                    b.d += 1;
                    this.gs(h, f.w, f.ac, f.j, f.af);
                }
                if (!f.ae.isEmpty && f.n() && f.l) {
                    var i = this.a7.q.item(b.a);
                    b.a += 1;
                    this.gs(i, f.v, f.ab, f.i, f.ae);
                }
            }
        }
        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;
            }
        }
        this.a7.ar();
    };
    XamDataLegend.prototype.gs = function (a, b, c, d, e) {
        a.al = b;
        this.a7.bc(a, e.left, e.top);
        this.a7.as(a, d);
        this.a7.at(a, d);
        a.ao = c;
    };
    XamDataLegend.prototype.gq = function (a, b, c) {
        a.ah = b.t;
        a.content = b.n;
        a.width = b.x.width;
        a.height = b.x.height;
        if (!b.v.isEmpty && !isInfinity(b.v.top) && !isInfinity(b.v.left)) {
            this.a7.bc(a, b.v.left, b.v.top);
        }
    };
    XamDataLegend.prototype.b2 = function (a, b) {
        if (b == null) {
            return false;
        }
        return a.containsKey(b);
    };
    XamDataLegend.prototype.gd = function (a) {
        var e_12, _a;
        a.a.clear();
        a.b.clear();
        a.d = 0;
        for (var b = 0; b < a.c.count; b++) {
            var c = a.c._inner[b];
            var d = b;
            var e = c.getDataLegendResolvedWorldPositionX(this.cr);
            var f = c.getDataLegendResolvedWorldPositionY(this.cs);
            var g = typeCast(DataLegendSeriesContext.$, c.getDataLegendSeriesContextAt(e, f));
            if (g != null) {
                var h = new List$1(DataLegendSeriesValueInfo.$, 0);
                for (var i = 0; i < g.e.count; i++) {
                    var j = g.e._inner[i];
                    var k = this.ce == null || this.b2(this.ce, j.r) || this.b2(this.ce, j.q) || this.b2(this.ce, j.s) || this.b2(this.ce, "ALL");
                    var l = this.cd != null && (this.b2(this.cd, j.r) || this.b2(this.cd, j.q) || this.b2(this.cd, j.s) || this.b2(this.cd, "ALL"));
                    var m = this.ce == null && this.cd == null && j.k;
                    if (k && (!l && !m)) {
                        j.o = h.count;
                        h.add(j);
                        if (!a.a.containsKey(j.o)) {
                            a.a.addItem(j.o, new DataLegendColumn());
                        }
                        a.a.item(j.o).i = j.o;
                        a.a.item(j.o).d.q(d, j.t);
                        a.a.item(j.o).b.q(d, j.s);
                        a.a.item(j.o).e.q(d, j.l);
                        a.a.item(j.o).c.q(d, j);
                        a.a.item(j.o).h.add(d);
                    }
                }
                g.e = h;
                a.b.add(g);
                a.d = Math.max(a.d, g.e.count);
            }
        }
        try {
            for (var _b = __values(fromEnum(a.a.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var n = _c.value;
                n.f.clear();
                n.a.clear();
                var o = n.e.p(n.h);
                var p = this.ck(o);
                for (var q = 0; q < p.count; q++) {
                    var r = p._inner[q];
                    var s = n.h._inner[q];
                    n.a.q(s, r);
                    var t = n.c.item(s);
                    var u = this.ek(r, t);
                    n.f.q(s, u);
                    var v = !stringIsNullOrEmpty(r.l);
                    if (v) {
                        n.g = true;
                    }
                }
            }
        }
        catch (e_12_1) {
            e_12 = { error: e_12_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_12)
                    throw e_12.error;
            }
        }
    };
    XamDataLegend.prototype.gc = function (a) {
        if (this.cf.count >= 1 && this.b3) {
            this.f1(a.f);
        }
        for (var b = 0; b < a.c.count; b++) {
            this.g3(a.c._inner[b], this.ba);
            this.f2(a, b);
        }
        if (this.as == 0) {
            this.f3(a);
        }
    };
    XamDataLegend.prototype.b8 = function () {
        var a = false;
        for (var b = 0; b < this.ao.b.count; b++) {
            var c = this.ao.b._inner[b];
            if (c.d && c.l && c.j != 7) {
                a = true;
                break;
            }
        }
        return a;
    };
    XamDataLegend.prototype.f5 = function (a) {
        var e_13, _a;
        for (var b = 0; b < a.b.count; b++) {
            var c = a.b._inner[b];
            this.gf(c);
        }
        var d = 0;
        var e = new Size(1, 0, 0);
        var f = new Size(1, 0, 0);
        var g = new Dictionary$2(Number_$type, Size.$, 0);
        var h = new Dictionary$2(Number_$type, Size.$, 0);
        var i = new Dictionary$2(Number_$type, Size.$, 0);
        try {
            for (var _b = __values(fromEnum(a.b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var j = _c.value;
                for (var k = 0; k < j.m.count; k++) {
                    var l = j.m._inner[k];
                    if (!g.containsKey(k)) {
                        g.addItem(k, new Size(1, 0, 0));
                    }
                    g.item(k, this.jq(g.item(k), l.am, l.ap));
                    if (!h.containsKey(k)) {
                        h.addItem(k, new Size(1, 0, 0));
                    }
                    h.item(k, this.jq(h.item(k), l.ak, l.ao));
                    if (!i.containsKey(k)) {
                        i.addItem(k, new Size(1, 0, 0));
                    }
                    i.item(k, this.jq(i.item(k), l.ai, l.an));
                }
            }
        }
        catch (e_13_1) {
            e_13 = { error: e_13_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_13)
                    throw e_13.error;
            }
        }
        for (var m = 0; m < a.b.count; m++) {
            var n = a.b._inner[m];
            f = this.jp(f, n.x, n.z);
            e = this.jq(e, n.y, n.ab);
            for (var o = 0; o < n.m.count; o++) {
                n.m._inner[o].al = g.item(o);
                n.m._inner[o].aj = h.item(o);
                n.m._inner[o].ah = i.item(o);
            }
            if (n.e) {
                var p = n.y.width + n.ab.left + n.ab.right;
                d = Math.max(d, p + n.aa.left);
            }
            else if (n.d) {
                var q = n.y.width + n.ab.left + n.ab.right;
                var r = n.x.width + n.z.left + n.z.right;
                d = Math.max(d, q + n.aa.left + r);
            }
        }
        var s = 0;
        var t = 0;
        for (var u = 0; u < a.b.count; u++) {
            var v = a.b._inner[u];
            var w = this.jn(t, v, d, e, f);
            t = w.height;
            s = Math.max(s, w.width);
        }
        a.d = s + this.jr.left + this.jr.right;
        a.c = t + this.jr.top + this.jr.bottom;
    };
    XamDataLegend.prototype.jp = 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.jq = 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.jn = function (a, b, c, d, e) {
        var e_14, _a, e_15, _b;
        var f = 0;
        var g = 0;
        g = Math.max(b.x.height, g);
        g = Math.max(b.y.height, g);
        try {
            for (var _c = __values(fromEnum(b.m)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var h = _d.value;
                g = Math.max(h.am.height, g);
                if (h.o) {
                    g = Math.max(h.ak.height, g);
                }
                if (h.l) {
                    g = Math.max(h.ai.height, g);
                }
            }
        }
        catch (e_14_1) {
            e_14 = { error: e_14_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_14)
                    throw e_14.error;
            }
        }
        f += b.aa.left;
        a += b.aa.top;
        if (!b.b && !b.e && !b.a && !b.f && this.b0) {
            f += b.z.left;
            var i = 0;
            if (g > b.x.height) {
                i = (g - b.x.height) / 2;
            }
            b.v = new Rect(0, f, a + i, b.x.width, b.x.height);
            f += (b.v.width) + b.z.right;
        }
        else {
            b.v = new Rect(0, 0, 0, 0, 0);
        }
        if (!stringIsNullOrEmpty(b.r)) {
            f += b.ab.left;
            var j = 0;
            if (g > b.y.height) {
                j = (g - b.y.height) / 2;
            }
            b.w = new Rect(0, f, a + j, b.y.width + b.ab.right, b.y.height);
            f = Math.max(c, b.w.right);
        }
        try {
            for (var _e = __values(fromEnum(b.m)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var k = _f.value;
                if ((k.n() && k.l) && k.ah.width > 0) {
                    var l = 0;
                    if (g > k.ai.height) {
                        l = (g - k.ai.height) / 2;
                    }
                    k.ae = new Rect(0, f + k.an.left, a + l, k.ai.width, k.ai.height);
                    f += k.ah.width;
                }
                if (k.s()) {
                    f += k.ap.left;
                    f += (k.al.width - (k.am.width + k.ap.right));
                    var m = 0;
                    if (g > k.am.height) {
                        m = (g - k.am.height) / 2;
                    }
                    k.ag = new Rect(0, f, a + m, k.am.width, k.am.height);
                    f += k.ag.width;
                    f += k.ap.right;
                }
                if ((k.q() && k.o) && k.aj.width > 0) {
                    var n = 0;
                    if (g > k.ak.height) {
                        n = (g - k.ak.height) / 2;
                    }
                    k.af = new Rect(0, f + k.ao.left, a + n, k.ak.width, k.ak.height);
                    f += k.aj.width;
                }
            }
        }
        catch (e_15_1) {
            e_15 = { error: e_15_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_15)
                    throw e_15.error;
            }
        }
        f += b.aa.right;
        a += g;
        a += b.aa.bottom;
        return new Size(1, f, a);
    };
    XamDataLegend.prototype.gf = function (a) {
        var e_16, _a;
        a.y = a.r == null ? new Size(1, 0, 0) : this.a7.bz(a.r, a.k);
        try {
            for (var _b = __values(fromEnum(a.m)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.am = b.z == null ? new Size(1, 0, 0) : this.a7.bz(b.z, b.k);
                b.ak = b.w == null ? new Size(1, 0, 0) : this.a7.bz(b.w, b.j);
                b.ai = b.v == null ? new Size(1, 0, 0) : this.a7.bz(b.v, b.i);
            }
        }
        catch (e_16_1) {
            e_16 = { error: e_16_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_16)
                    throw e_16.error;
            }
        }
    };
    XamDataLegend.prototype.ej = function (a, b, c, d, e) {
        if (this.a4 == 2) {
            return null;
        }
        var f = "";
        if (stringIsNullOrEmpty(this.fa)) {
            f = c;
        }
        else {
            f = this.fa;
        }
        if (e) {
            if (stringIsNullOrEmpty(f)) {
                f = d;
            }
            else {
                f = d + f;
            }
        }
        var g = a.a.item(b).d;
        var h = a.a.item(b).g;
        if (h && stringIsNullOrEmpty(f)) {
            f = " ";
        }
        else if (g.count > 0 && stringIsNullOrEmpty(f)) {
            f = " ";
        }
        else if (!e) {
            return null;
        }
        return f;
    };
    XamDataLegend.prototype.eh = function (a, b, c, d) {
        if (this.ar == 2) {
            return null;
        }
        var e = a.d > 1;
        var f = this.ar == 1;
        var g = a.a.item(b).b.count > 0;
        if (g && (e || f)) {
            if (stringIsNullOrEmpty(c)) {
                return " ";
            }
            else if (d) {
                return c;
            }
        }
        return null;
    };
    XamDataLegend.prototype.f3 = function (a) {
        var e_17, _a, e_18, _b;
        if (this.a3 == 5) {
            return;
        }
        if (a.f == "Value Layer") {
            return;
        }
        if (a.c == null || a.c.count <= 1) {
            return;
        }
        var b = new Dictionary$2(Number_$type, DataLegendSummaryColumn.$, 0);
        var c = 0;
        var d = false;
        var e = new List$1(String_$type, 0);
        try {
            for (var _c = __values(fromEnum(a.b)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var f = _d.value;
                c = Math.max(c, f.e.count);
                if (!e.contains(f.h)) {
                    e.add(f.h);
                }
                if (this.a3 == 0) {
                    if (e.count > 1) {
                        return;
                    }
                }
                if (stringContains(f.h, "Geographic") || stringContains(f.h, "Scatter") || stringContains(f.h, "Shape") || stringContains(f.h, "Polar") || stringContains(f.h, "Financial") || stringContains(f.h, "Indicator")) {
                    d = true;
                }
                for (var g = 0; g < f.e.count; g++) {
                    var h = f.e._inner[g];
                    if (!b.containsKey(g)) {
                        b.addItem(g, new DataLegendSummaryColumn());
                    }
                    var i = b.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.z = h.z;
                    i.ak(h.l);
                    i.ai(h.s);
                    i.aj(h.t);
                    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.y)) {
                        i.y = h.y;
                    }
                    if (stringIsNullOrEmpty(i.r)) {
                        i.r = h.r;
                    }
                    if (stringIsNullOrEmpty(i.q)) {
                        i.q = h.q;
                    }
                }
            }
        }
        catch (e_17_1) {
            e_17 = { error: e_17_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_17)
                    throw e_17.error;
            }
        }
        if (this.a3 == 0) {
            if (d) {
                return;
            }
            var j = this.cm.count > 1;
            if (j) {
                return;
            }
            for (var k = 0; k < a.c.count; k++) {
                var l = a.c._inner[k];
                if (!l.isSummarizationSupported) {
                    return;
                }
            }
        }
        var m = this.a8();
        var n = new DataLegendRowInfo(this.a7, true, false, false, -1);
        n.r = this.er != null ? this.er : m.title;
        n.u = this.jf || this.ji || n.u;
        n.k = this.bs || this.bv || n.k;
        n.p = a.f;
        for (var o = 0; o < c; o++) {
            var p = b.item(o);
            var q = m.calculate(p.ac, p.r);
            q = this.a2(q);
            var r = this.an;
            var s = r == 0 || r == 2 || r == 8;
            var t = -1;
            try {
                for (var _e = (e_18 = void 0, __values(fromEnum(a.a.item(o).a.values))), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var u = _f.value;
                    if (u.b()) {
                        t = Math.max(t, u.h);
                        if (s) {
                            r = u.a;
                        }
                    }
                }
            }
            catch (e_18_1) {
                e_18 = { error: e_18_1 };
            }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return))
                        _b.call(_e);
                }
                finally {
                    if (e_18)
                        throw e_18.error;
                }
            }
            var v = this.c1 >= 0 ? this.c1 : t;
            var w = this.c0 >= 0 ? this.c0 : t;
            var x = this.am(q.c, r, v, w);
            x.i = v;
            x.h = w;
            var y = this.ek(x, p);
            var z = new DataLegendRowCell(this.a7, true, false, false, -1);
            z.u = n.m.count;
            z.v = this.eh(a, z.u, " ", p.b);
            if (!stringIsNullOrEmpty(this.em)) {
                z.v = this.em;
            }
            if (q.e != null) {
                z.v = q.e;
            }
            z.l = !stringIsNullOrEmpty(z.v);
            z.ab = this.je || this.jc || z.ab;
            z.i = this.br || this.bq || z.i;
            z.z = y;
            z.k = this.bu || this.bx || z.k;
            z.ad = this.jd(this.jh, this.jk || z.ad, null);
            z.t = q.c;
            z.h = x.a;
            z.y = p.r;
            z.x = p.q;
            var aa = p.ab.length == 1 ? p.ab[0] : " ";
            z.w = this.ej(a, z.u, aa, x.l, p.d);
            if (!stringIsNullOrEmpty(this.ex)) {
                z.w = this.ex;
            }
            if (q.f != null) {
                z.w = q.f;
            }
            z.o = !stringIsNullOrEmpty(z.w);
            z.ac = this.jg || this.jj || z.ac;
            z.j = this.bt || this.bw || z.j;
            n.m.add(z);
        }
        this.g1(n);
        if (n.c) {
            this.f4(n);
            this.gl(n);
            this.ao.e(n);
        }
    };
    XamDataLegend.prototype.am = function (a, b, c, d) {
        if (b == 8 || b == 0) {
            b = this.an;
        }
        if (d < 0) {
            d = this.c0;
        }
        if (c < 0) {
            c = this.c1;
        }
        return DataAbbreviator.a(a, b, c, d);
    };
    XamDataLegend.prototype.cx = function (a, b, c, d) {
        return this.am(a, b, c, d).d;
    };
    XamDataLegend.prototype.dk = function (a, b, c, d) {
        return this.am(a, b, c, d).l;
    };
    XamDataLegend.prototype.dj = function (a, b, c, d) {
        var e = this.am(a, b, c, d);
        return e.m + e.l;
    };
    XamDataLegend.prototype.ck = function (a) {
        var b = this.c1;
        var c = this.c0;
        var d = this.an;
        var e = DataAbbreviator.h(a, d, b, c);
        return e;
    };
    XamDataLegend.prototype.cl = function (a, b) {
        var c = new List$1(Number_$type, 0);
        if (b < 0) {
            return c;
        }
        for (var d = 0; d < a.b.count; d++) {
            var e = a.b._inner[d];
            if (e.e.count > b) {
                var f = e.e._inner[b].l;
                if (!isNaN_(f)) {
                    c.add(f);
                }
            }
        }
        return c;
    };
    XamDataLegend.prototype.f4 = function (a) {
    };
    XamDataLegend.prototype.jd = function (a, b, c) {
        if (a != null) {
            return a;
        }
        if (this.cc && c != null) {
            return c;
        }
        return b;
    };
    XamDataLegend.prototype.ei = function (a, b) {
        return stringIsNullOrEmpty(a) ? b : a;
    };
    XamDataLegend.prototype.ek = function (a, b) {
        var c = a.d;
        if (b == null || isNaN_(c) || isInfinity(c)) {
            return this.fx;
        }
        var d;
        var e = b.d ? a.d : a.g;
        if (this.ak != null) {
            d = this.ak.i(e);
        }
        else {
            var f = this.a5;
            if (f == 0) {
                f = 1;
            }
            var g = new NumberFormatSpecifier();
            g.useGrouping = this.ca;
            g.locale = this.ei(this.fg, null);
            g.currencyCode = this.fi;
            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.c1 >= 0) {
                    g.minimumFractionDigits = this.c1;
                }
                if (b.m >= 0 && b.m > a.h) {
                    g.maximumFractionDigits = b.m;
                }
                else if (this.c0 >= 0) {
                    g.maximumFractionDigits = this.c0;
                }
            }
            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.x + d;
            }
            else if (e < 0) {
                d = b.v + d;
            }
            if (e >= 0) {
                d += b.y;
            }
            else {
                d += b.w;
            }
        }
        return d;
    };
    XamDataLegend.prototype.f2 = function (a, b) {
        if (this.cb == false) {
            return;
        }
        var c = a.b._inner[b];
        var d = a.c._inner[b];
        var e = d.getDataLegendSeriesTitle();
        var f = c.a();
        var g = new DataLegendRowInfo(this.a7, false, false, false, b);
        g.h = f;
        g.q = e;
        g.p = a.f;
        g.r = e;
        g.u = this.ji || g.u;
        g.k = this.bv || g.k;
        g.j = this.bb(d);
        g.o = d.getDataLegendBadgeShapeAndMarker();
        if (this.as == 0) {
            for (var h = 0; h < c.e.count; h++) {
                var i = c.e._inner[h];
                var j = a.a.item(h).a.item(b);
                var k = a.a.item(h).f.item(b);
                var l = new DataLegendRowCell(this.a7, false, false, false, b);
                l.u = g.m.count;
                l.k = this.bx || l.k;
                l.z = k;
                l.ad = this.jd(this.jk, l.ad, i.z);
                l.y = i.r;
                l.x = i.q;
                l.t = i.l;
                l.h = j.a;
                l.w = this.ej(a, l.u, i.t, j.l, i.d);
                l.o = !stringIsNullOrEmpty(l.w);
                l.ac = this.jj || l.ac;
                l.j = this.bw || l.j;
                l.v = this.eh(a, l.u, i.s, i.b);
                l.l = !stringIsNullOrEmpty(l.v);
                l.ab = this.jc || l.ab;
                l.i = this.bq || l.i;
                g.m.add(l);
            }
            this.f4(g);
            this.gl(g);
            this.g0(g);
            if (g.c) {
                if (g.l) {
                    this.g3(d, g.j);
                    var m = this.g7(d);
                    var n = this.c3(d);
                    g.t = m;
                    g.n = n;
                }
                this.ao.e(g);
            }
        }
        else if (this.as == 1) {
            this.f4(g);
            this.gl(g);
            this.g0(g);
            if (g.c) {
                if (g.l) {
                    this.g3(d, g.j);
                    var o = this.g7(d);
                    var p = this.c3(d);
                    g.t = o;
                    g.n = p;
                }
                this.ao.e(g);
            }
            for (var q = 0; q < c.e.count; q++) {
                var r = c.e._inner[q];
                var s = a.a.item(q).a.item(b);
                var t = a.a.item(q).f.item(b);
                var u = new DataLegendRowCell(this.a7, false, false, false, b);
                u.u = g.m.count;
                u.k = this.bx || u.k;
                u.z = t;
                u.ad = this.jd(this.jk, u.ad, r.z);
                u.y = r.r;
                u.x = r.q;
                u.t = r.l;
                u.h = s.a;
                u.w = this.ej(a, u.u, r.t, s.l, r.d);
                u.o = !stringIsNullOrEmpty(u.w);
                u.ac = this.jj || u.ac;
                u.j = this.bw || u.j;
                u.v = this.eh(a, u.u, r.s, r.b);
                u.l = !stringIsNullOrEmpty(u.v);
                u.ab = this.jc || u.ab;
                u.i = this.bq || u.i;
                var v = new DataLegendRowInfo(this.a7, false, false, false, b);
                v.h = f;
                v.p = a.f;
                v.f = true;
                v.l = false;
                v.j = 7;
                v.m.add(u);
                this.f4(v);
                this.gl(v);
                this.g0(v);
                if (v.c) {
                    this.ao.e(v);
                }
            }
        }
    };
    XamDataLegend.prototype.c3 = function (a) {
        if (a.isColoredItemwise) {
            var b = a.getDataLegendBadgeContextAtPosition(this.cr, this.cs);
            if (b == null) {
                return a.getDataLegendBadgeContext();
            }
        }
        return a.getDataLegendBadgeContext();
    };
    XamDataLegend.prototype.bb = function (a) {
        if (this.ba != 0) {
            return this.ba;
        }
        return a.legendItemBadgeShape;
    };
    XamDataLegend.prototype.g3 = function (a, b) {
        if (b == 0) {
            return;
        }
        if (a.legendItemBadgeShape != b) {
            a.legendItemBadgeShape = b;
        }
    };
    XamDataLegend.prototype.b4 = function () {
        return !isNaN_(this.cr) && !isNaN_(this.cs);
    };
    XamDataLegend.prototype.g7 = function (a) {
        return a.getDataLegendBadge();
    };
    XamDataLegend.prototype.fz = function (a, b) {
        if (this.b5 == false) {
            return;
        }
        var c = this.eg(a);
        if (c == null) {
            c = this.c4;
        }
        else {
            this.c4 = c;
        }
        if (stringIsNullOrEmpty(c)) {
            return;
        }
        var d = new DataLegendRowInfo(this.a7, false, true, false, -1);
        d.r = c;
        d.u = this.jb || d.u;
        d.k = this.bp || d.k;
        d.p = b;
        this.f4(d);
        this.gl(d);
        this.gz(d);
        if (d.c) {
            this.ao.e(d);
        }
    };
    XamDataLegend.prototype.f1 = function (a) {
        if (stringIsNullOrEmpty(a)) {
            return;
        }
        var b = new DataLegendRowInfo(this.a7, false, false, true, -1);
        b.r = a;
        b.u = this.ja || b.u;
        b.k = this.bo || b.k;
        b.p = a;
        this.f4(b);
        this.gl(b);
        this.gy(b);
        if (b.c) {
            this.ao.e(b);
        }
    };
    XamDataLegend.prototype.j3 = 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.gl = function (a) {
        var e_19, _a;
        if (a.d) {
            a.ab = this.j3(this.j1);
            a.aa = this.j3(this.j4);
        }
        else if (a.b) {
            a.ab = this.j3(this.jx);
            a.aa = this.j3(this.jw);
        }
        else if (a.a) {
            a.ab = this.j3(this.jv);
            a.aa = this.j3(this.ju);
        }
        else {
            a.ab = this.j3(this.j0);
            a.aa = this.j3(this.jz);
        }
        try {
            for (var _b = __values(fromEnum(a.m)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.ap = this.j3(this.j5);
                b.ao = this.j3(this.j2);
                if (this.as == 1 && !this.b7) {
                    b.an = this.j3(new Thickness(1, 0, 0, 20, 0));
                }
                else {
                    b.an = this.j3(this.jy);
                }
            }
        }
        catch (e_19_1) {
            e_19 = { error: e_19_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_19)
                    throw e_19.error;
            }
        }
        if (a.d) {
            a.z = this.j3(this.js);
            a.x = new Size(1, 20, 15);
        }
    };
    XamDataLegend.prototype.eg = function (a) {
        if (this.d0 != null) {
            return this.d0;
        }
        var b = true;
        var c = null;
        for (var d = 0; d < a.length; d++) {
            var e = a[d];
            var f = this.ee(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.ee = function (a) {
        if (this.b4()) {
            var b = a.getDataLegendAxisLabelFromCursorPosition(this.cr, this.cs);
            if (typeCast(Date_$type, b) !== null) {
                var c = b;
                b = this.ef(c);
            }
            return b == null ? "" : b.toString();
        }
        else {
            return null;
        }
    };
    XamDataLegend.prototype.ef = 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.ei(this.dr, "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.f6 = function () {
        if (this.ao != null) {
            this.ao.f();
        }
    };
    XamDataLegend.$t = markType(XamDataLegend, 'XamDataLegend', Control.$, [INotifyPropertyChanged_$type, IDataLegend_$type, IOnDemandRender_$type]);
    XamDataLegend.$$p = markDep(DependencyProperty, PropertyMetadata, XamDataLegend, 'gj', ['ActualBackground:i4:g8', [Brush.$, null], 'ActualBorderBrush:i5:g9', [Brush.$, null], 'ActualBorderThickness:jr:ha', [Thickness.$, new Thickness(0, 0)], 'BadgeMargin:js:hb', [Thickness.$, new Thickness(1, 0, 0, 0, 0)], 'BadgeShape:ba:hc', [LegendItemBadgeShape_$type, enumGetBox(LegendItemBadgeShape_$type, 0)], 'ContentBackground:i6:hd', [Brush.$, null], 'ContentBorderBrush:i7:he', [Brush.$, null], 'ContentBorderThickness:cw:hf', [1, NaN], 'ExcludedColumns::hg', [Array_$type, null], 'ExcludedSeries::hh', [Array_$type, null], 'GroupRowMargin:ju:hi', [Thickness.$, new Thickness(0, 5)], 'GroupRowVisible:b3:hj', [0, false], 'GroupTextColor:ja:hk', [Brush.$, null], 'GroupTextMargin:jv:hl', [Thickness.$, new Thickness(1, 2, 0, 0, 0)], 'HeaderFormatCulture:dr:hm', [2, stringEmpty()], 'HeaderFormatDate:ap:hn', [DataLegendHeaderDateMode_$type, enumGetBox(DataLegendHeaderDateMode_$type, 0)], 'HeaderFormatSpecifiers:ag:ho', [Array_$type, null], 'HeaderFormatString:dv:hp', [2, null], 'HeaderFormatTime:aq:hq', [DataLegendHeaderTimeMode_$type, enumGetBox(DataLegendHeaderTimeMode_$type, 0)], 'HeaderRowMargin:jw:hr', [Thickness.$, new Thickness(0, 5)], 'HeaderRowVisible:b5:hs', [0, true], 'HeaderTextColor:jb:ht', [Brush.$, null], 'HeaderTextMargin:jx:hu', [Thickness.$, new Thickness(1, 2, 0, 0, 0)], 'HeaderText:d0:hv', [2, null], 'IncludedColumns::hw', [Array_$type, null], 'IncludedSeries::hx', [Array_$type, null], 'IsEmbeddedInDataTooltip::hy', [0, false], 'LabelDisplayMode:ar:hz', [DataLegendLabelMode_$type, enumGetBox(DataLegendLabelMode_$type, 0)], 'LabelTextColor:jc:h0', [Brush.$, null], 'LabelTextMargin:jy:h1', [Thickness.$, new Thickness(1, 12, 0, 0, 0)], 'LayoutMode:as:h2', [DataLegendLayoutMode_$type, enumGetBox(DataLegendLayoutMode_$type, 0)], 'ShouldUpdateWhenSeriesDataChanges:b9:h3', [0, true], 'SummaryLabelTextColor:je:h4', [Brush.$, null], 'SummaryLabelText:em:h5', [2, null], 'SummaryRowMargin:jz:h6', [Thickness.$, new Thickness(0, 5)], 'SummaryTitleTextColor:jf:h7', [Brush.$, null], 'SummaryTitleTextMargin:j0:h8', [Thickness.$, new Thickness(1, 2, 0, 4, 0)], 'SummaryTitleText:er:h9', [2, null], 'SummaryType:a3:ia', [DataLegendSummaryType_$type, enumGetBox(DataLegendSummaryType_$type, 0)], 'SummaryUnitsTextColor:jg:ib', [Brush.$, null], 'SummaryUnitsText:ex:ic', [2, null], 'SummaryValueTextColor:jh:id', [Brush.$, null], 'TargetCursorPositionX::ie', [1, NaN], 'TargetCursorPositionY::ig', [1, NaN], 'Target::ih', [4, null], 'TitleTextColor:ji:ii', [Brush.$, null], 'TitleTextMargin:j1:ij', [Thickness.$, new Thickness(1, 0, 0, 4, 0)], 'UnitsDisplayMode:a4:ik', [DataLegendUnitsMode_$type, enumGetBox(DataLegendUnitsMode_$type, 0)], 'UnitsTextColor:jj:il', [Brush.$, null], 'UnitsTextMargin:j2:im', [Thickness.$, new Thickness(1, 0, 0, 0, 0)], 'UnitsText:fa:io', [2, null], 'ValueFormatAbbreviation:an:ip', [DataAbbreviationMode_$type, enumGetBox(DataAbbreviationMode_$type, 0)], 'ValueFormatCulture:fg:iq', [2, stringEmpty()], 'ValueFormatCurrencyCode:fi:ir', [2, null], 'ValueFormatMaxFractions:c0:is', [1, -1], 'ValueFormatMinFractions:c1:it', [1, -1], 'ValueFormatMode:a5:iu', [DataLegendValueMode_$type, enumGetBox(DataLegendValueMode_$type, 0)], 'ValueFormatSpecifiers:ah:iv', [Array_$type, null], 'ValueFormatString:fo:iw', [2, null], 'ValueFormatUseGrouping:ca:ix', [0, true], 'ValueRowMargin:j4:iy', [Thickness.$, new Thickness(0, 5)], 'ValueRowVisible:cb:iz', [0, true], 'ValueTextColor:jk:i0', [Brush.$, null], 'ValueTextMargin:j5:i1', [Thickness.$, new Thickness(1, 2, 0, 2, 0)], 'ValueTextUseSeriesColors:cc:i2', [0, false], 'ValueTextWhenMissingData:fx:i3', [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.ad = null;
        _this.af = null;
        _this.ah = null;
        _this.ag = null;
        _this.ae = null;
        _this.q = null;
        _this.s = null;
        _this.u = null;
        _this.t = null;
        _this.r = null;
        _this.a = null;
        _this.am = null;
        _this.al = null;
        _this.v = null;
        _this.b = null;
        _this.ai = 1;
        _this.y = false;
        _this.ao = -1;
        _this.an = -1;
        _this.ab = new Dictionary$2(FontInfo.$, Tuple$2.$.specialize(Number_$type, FontInfo.$), 0);
        _this.x = false;
        _this.ac = new List$1(FrameworkElement.$, 0);
        _this.aj = 0;
        _this.g = null;
        _this.i = null;
        _this.h = null;
        _this.e = null;
        _this.f = null;
        _this.d = null;
        _this.c = null;
        _this.w = null;
        _this.a = a;
        _this.s = ((function () {
            var $ret = new Pool$1(TextBlock.$);
            $ret.create = runOn(_this, _this.bp);
            $ret.activate = runOn(_this, _this.be);
            $ret.disactivate = runOn(_this, _this.bg);
            $ret.destroy = runOn(_this, _this.bf);
            return $ret;
        })());
        _this.u = ((function () {
            var $ret = new Pool$1(TextBlock.$);
            $ret.create = runOn(_this, _this.br);
            $ret.activate = runOn(_this, _this.bk);
            $ret.disactivate = runOn(_this, _this.bm);
            $ret.destroy = runOn(_this, _this.bl);
            return $ret;
        })());
        _this.t = ((function () {
            var $ret = new Pool$1(TextBlock.$);
            $ret.create = runOn(_this, _this.bq);
            $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(ContentControl.$);
            $ret.create = runOn(_this, _this.bn);
            $ret.activate = runOn(_this, _this.a2);
            $ret.disactivate = runOn(_this, _this.a4);
            $ret.destroy = runOn(_this, _this.a3);
            return $ret;
        })());
        _this.q = ((function () {
            var $ret = new Pool$1(TextBlock.$);
            $ret.create = runOn(_this, _this.bo);
            $ret.activate = runOn(_this, _this.az);
            $ret.disactivate = runOn(_this, _this.a1);
            $ret.destroy = runOn(_this, _this.a0);
            return $ret;
        })());
        _this.ad = new List$1(TextBlock.$, 0);
        _this.af = new List$1(TextBlock.$, 0);
        _this.ah = new List$1(TextBlock.$, 0);
        _this.ag = new List$1(TextBlock.$, 0);
        _this.ae = new List$1(ContentControl.$, 0);
        return _this;
    }
    DataLegendView.prototype.av = function () {
        this.a.f8();
    };
    DataLegendView.prototype.bp = function () {
        var a = new TextBlock();
        this.af.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.af.remove(a);
    };
    DataLegendView.prototype.br = function () {
        var a = new TextBlock();
        this.ah.add(a);
        return a;
    };
    DataLegendView.prototype.bk = function (a) {
        a._visibility = 0;
    };
    DataLegendView.prototype.bm = function (a) {
        a._visibility = 1;
    };
    DataLegendView.prototype.bl = function (a) {
        this.ah.remove(a);
    };
    DataLegendView.prototype.bq = function () {
        var a = new TextBlock();
        this.ag.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.ag.remove(a);
    };
    DataLegendView.prototype.bo = function () {
        var a = new TextBlock();
        this.ad.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) {
        this.ad.remove(a);
    };
    DataLegendView.prototype.bn = function () {
        var a = new ContentControl();
        this.ae.add(a);
        return a;
    };
    DataLegendView.prototype.a2 = function (a) {
        a._visibility = 0;
    };
    DataLegendView.prototype.a4 = function (a) {
        a._visibility = 1;
    };
    DataLegendView.prototype.a3 = function (a) {
    };
    DataLegendView.prototype.ay = function () {
        var a = CanvasScalingHelpers.b(this.al);
        if (this.b != null) {
            CanvasScalingHelpers.h(this.b, a);
        }
        this.a.ct = CanvasScalingHelpers.a(this.a.pixelScalingRatio, this.a.ct, a);
    };
    DataLegendView.prototype.a7 = function () {
        this.ay();
        var a = Math.round(this.al.rootWrapper.width());
        var b = Math.round(this.al.rootWrapper.height());
        this.a.jm = new Rect(0, 0, 0, a, b);
        if (this.b != null) {
            this.b.bm = this.a.jm;
        }
        this.a.go();
    };
    DataLegendView.prototype.ap = function () {
        if (this.b != null) {
            this.b.ap = null;
            this.b.aw();
            this.b = null;
        }
    };
    Object.defineProperty(DataLegendView.prototype, "z", {
        get: function () {
            return this.al != null;
        },
        enumerable: false,
        configurable: true
    });
    DataLegendView.prototype.a6 = function (a, b) {
        if (a == null) {
            this.am = null;
            this.al = null;
            this.v = null;
            this.ap();
            return;
        }
        this.ai = (isNaN_(this.a.pixelScalingRatio) ? this.a.ct : this.a.pixelScalingRatio);
        var c = a;
        this.al = c;
        var d = this.ai;
        var e = Math.round(c.rootWrapper.width());
        var f = Math.round(c.rootWrapper.height());
        var g = e * d;
        var h = f * d;
        this.al.rootWrapper.setStyleProperty("position", "relative");
        var i = this.al.createElement("canvas");
        i.setStyleProperty("position", "absolute");
        this.al.append(i);
        this.ao = truncate(Math.round(g));
        this.an = 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.jm = new Rect(0, 0, 0, e, f);
        this.am = i;
        var j = this.al.get2DCanvasContext(this.am);
        this.v = new RenderingContext(new CanvasViewRenderer(), j);
        this.ap();
        if (TypeRegistrar.isRegistered("CanvasGestureDOMEventProxy")) {
            this.b = typeCast(EventProxy.$, TypeRegistrar.create("CanvasGestureDOMEventProxy", this.al.rootWrapper, this.al, false));
        }
        if (this.b != null) {
        }
    };
    DataLegendView.prototype.ax = function (a, b) {
        this.a7();
    };
    DataLegendView.prototype.aw = function (a) {
    };
    DataLegendView.prototype.ba = function () {
        var a = this.a.jm.width;
        var b = this.a.jm.height;
        var c = Math.round(a * this.ai);
        var d = Math.round(b * this.ai);
        if (this.ao != c || this.an != d) {
            this.am.setAttribute("width", c.toString());
            this.am.setAttribute("height", d.toString());
            this.am.setStyleProperty("width", a.toString() + "px");
            this.am.setStyleProperty("height", b.toString() + "px");
            this.ao = truncate(Math.round(c));
            this.an = truncate(Math.round(d));
        }
        this.bb(this.v, this.ai);
    };
    DataLegendView.prototype.bb = function (a, b) {
        if (this.v == null) {
            this.y = true;
            this.v = a;
        }
        if (a.d && b != 1) {
            a.aa();
            a.ab(b, b);
        }
        if (a == this.v) {
            if (!a.e) {
                a.l(this.a.jm.left, this.a.jm.top, this.a.jm.width, this.a.jm.height);
            }
        }
        if (this.a.i6 != null || this.a.i7 != null) {
            var c = new Rectangle();
            c.o = this.a.jm.top;
            c.n = this.a.jm.left;
            c.height = this.a.jm.height;
            c.width = this.a.jm.width;
            c.height = this.a.jm.height;
            if (this.a.i6 != null) {
                c._fill = this.a.i6;
            }
            if (this.a.i7 != null && this.a.cw > 0) {
                c._stroke = this.a.i7;
                c.ad = this.a.cw;
            }
            a.w(c);
        }
        var d = new DataTemplatePassInfo();
        d.passID = "LegendItem";
        for (var e = 0; e < this.ae.count; e++) {
            var f = this.ae._inner[e];
            if (f == null) {
                continue;
            }
            var g = f.ah;
            if (g == null) {
                continue;
            }
            var h = new DataTemplateMeasureInfo();
            h.passInfo = d;
            h.context = this.v.h();
            h.width = f.width;
            h.height = f.height;
            h.data = f.content;
            h.renderContext = a;
            g.measure(h);
            var i = new DataTemplateRenderInfo();
            i.availableWidth = f.width;
            i.availableHeight = f.height;
            i.passInfo = d;
            i.context = a.h();
            i.renderContext = a;
            i.data = f.content;
            i.xPosition = f.n;
            i.yPosition = f.o;
            a.aa();
            a.ai(f.n, f.o);
            g.render(i);
            a.z();
        }
        for (var j = 0; j < this.af.count; j++) {
            var k = this.af._inner[j];
            a.af(k.dataContext);
            a.x(k);
        }
        for (var l = 0; l < this.ad.count; l++) {
            var m = this.ad._inner[l];
            a.af(m.dataContext);
            a.x(m);
        }
        for (var n = 0; n < this.ah.count; n++) {
            var o = this.ah._inner[n];
            a.af(o.dataContext);
            a.x(o);
        }
        for (var p = 0; p < this.ag.count; p++) {
            var q = this.ag._inner[p];
            a.af(q.dataContext);
            a.x(q);
        }
        if (a.d && b != 1) {
            a.z();
        }
    };
    DataLegendView.prototype.aa = function () {
        if (this.al != null) {
            this.al.setTimeout(runOn(this.a, this.a.f8), 0);
            return true;
        }
        return false;
    };
    DataLegendView.prototype.bz = function (a, b) {
        this.v.af(b);
        var c = new TextBlock();
        c.al = a;
        var d = this.v.aj(c, this.ak(b), true);
        return new Size(1, d.c, d.b);
    };
    DataLegendView.prototype.ak = function (a) {
        if (this.ab.containsKey(a)) {
            var b = this.ab.item(a);
            if (b.d.j == a.j) {
                return b.c;
            }
        }
        var c = FontUtil.getCurrentFontHeight(this.al, a);
        var d = new Tuple$2(Number_$type, FontInfo.$, c, a);
        this.ab.item(a, d);
        return c;
    };
    DataLegendView.prototype.bc = function (a, b, c) {
        if (this.x) {
            this.ac.add(a);
        }
        a.n = b;
        a.o = c;
    };
    DataLegendView.prototype.au = function (a) {
        this.ba();
    };
    DataLegendView.prototype.as = function (a, b) {
        a.dataContext = b;
    };
    DataLegendView.prototype.by = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bw = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bx = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bu = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bv = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bt = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.bs = function () {
        return FontDefaults.dataLegendFontBrush;
    };
    DataLegendView.prototype.n = function () {
        if (this.g == null) {
            this.g = ((function () {
                var $ret = new FontInfo();
                $ret.q = FontDefaults.dataLegendFontFamily;
                $ret.f = FontDefaults.dataLegendFontSize;
                $ret.t = FontDefaults.dataLegendFontStyle;
                $ret.v = FontDefaults.dataLegendFontWeight;
                $ret.r = FontDefaults.dataLegendFontStretch;
                $ret.u = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.g;
    };
    DataLegendView.prototype.p = function () {
        if (this.i == null) {
            this.i = ((function () {
                var $ret = new FontInfo();
                $ret.q = FontDefaults.dataLegendFontFamily;
                $ret.f = FontDefaults.dataLegendFontSize;
                $ret.t = FontDefaults.dataLegendFontStyle;
                $ret.v = FontDefaults.dataLegendFontWeight;
                $ret.r = FontDefaults.dataLegendFontStretch;
                $ret.u = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.i;
    };
    DataLegendView.prototype.o = function () {
        if (this.h == null) {
            this.h = ((function () {
                var $ret = new FontInfo();
                $ret.q = FontDefaults.dataLegendFontFamily;
                $ret.f = FontDefaults.dataLegendFontSize;
                $ret.t = FontDefaults.dataLegendFontStyle;
                $ret.v = FontDefaults.dataLegendFontWeight;
                $ret.r = FontDefaults.dataLegendFontStretch;
                $ret.u = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.h;
    };
    DataLegendView.prototype.l = function () {
        if (this.e == null) {
            this.e = ((function () {
                var $ret = new FontInfo();
                $ret.q = FontDefaults.dataLegendFontFamily;
                $ret.f = FontDefaults.dataLegendFontSize;
                $ret.t = FontDefaults.dataLegendFontStyle;
                $ret.v = FontDefaults.dataLegendFontWeight;
                $ret.r = FontDefaults.dataLegendFontStretch;
                $ret.u = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.e;
    };
    DataLegendView.prototype.m = function () {
        if (this.f == null) {
            this.f = ((function () {
                var $ret = new FontInfo();
                $ret.q = FontDefaults.dataLegendFontFamily;
                $ret.f = FontDefaults.dataLegendFontSize;
                $ret.t = FontDefaults.dataLegendFontStyle;
                $ret.v = FontDefaults.dataLegendFontWeight;
                $ret.r = FontDefaults.dataLegendFontStretch;
                $ret.u = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.f;
    };
    DataLegendView.prototype.k = function () {
        if (this.d == null) {
            this.d = ((function () {
                var $ret = new FontInfo();
                $ret.q = FontDefaults.dataLegendFontFamily;
                $ret.f = FontDefaults.dataLegendFontSize;
                $ret.t = FontDefaults.dataLegendFontStyle;
                $ret.v = FontDefaults.dataLegendHeaderFontWeight;
                $ret.r = FontDefaults.dataLegendFontStretch;
                $ret.u = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.d;
    };
    DataLegendView.prototype.j = function () {
        if (this.c == null) {
            this.c = ((function () {
                var $ret = new FontInfo();
                $ret.q = FontDefaults.dataLegendFontFamily;
                $ret.f = FontDefaults.dataLegendFontSize;
                $ret.t = FontDefaults.dataLegendFontStyle;
                $ret.v = FontDefaults.dataLegendFontWeight;
                $ret.r = FontDefaults.dataLegendFontStretch;
                $ret.u = FontDefaults.dataLegendFontVariant;
                return $ret;
            })());
        }
        return this.c;
    };
    DataLegendView.prototype.aq = function (a, b) {
        var model_ = this.a;
        var ext_ = model_.externalObject;
        if (ext_ != null) {
            var width_ = a;
            var height_ = b;
            this.al.rootWrapper.setStyleProperty("min-height", b + "px");
            this.al.rootWrapper.setStyleProperty("min-width", a + "px");
            this.a.notifySizeChanged();
        }
    };
    DataLegendView.prototype.a9 = function (a) {
        this.ai = a;
    };
    DataLegendView.prototype.a5 = function () {
        if (this.b != null) {
            var a = this.al.rootWrapper;
            this.b.au(a, "");
        }
    };
    DataLegendView.prototype.a8 = function () {
        if (this.b != null) {
            if (this.al == null) {
                return;
            }
            var a = this.al.rootWrapper;
            this.b.bi(a, "");
        }
    };
    DataLegendView.prototype.at = function (a, b) {
        a.ag = true;
        var c = this.v.aj(a, this.ak(b), true);
    };
    DataLegendView.prototype.bd = function () {
        this.ac.clear();
        this.x = true;
        this.aj = 0;
    };
    DataLegendView.prototype.ar = function () {
        for (var a = 0; a < this.ac.count; a++) {
            this.aj = Math.max(this.aj, this.ac._inner[a].ah);
        }
        if (this.aj > 0) {
            for (var b = 0; b < this.ac.count; b++) {
                this.ac._inner[b].ah = this.aj;
            }
        }
        this.x = false;
        this.aj = 0;
    };
    DataLegendView.$t = markType(DataLegendView, 'DataLegendView');
    return DataLegendView;
}(Base));
export { DataLegendView };