/*
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, Type, typeCast, Delegate_$type, runOn, markType, getInstanceType, delegateRemove, delegateCombine, Point_$type, fromEnum, Number_$type, IEnumerable_$type, EnumUtil, Array_$type, enumGetBox, markDep } from "igniteui-angular-core";
import { ServiceProvider_Spark } from "./ServiceProvider_Spark";
import { Dictionary$2 } from "igniteui-angular-core";
import { MessageChannel_Spark } from "./MessageChannel_Spark";
import { AxisRenderMessage_Spark } from "./AxisRenderMessage_Spark";
import { ContainerResizedMessage_Spark } from "./ContainerResizedMessage_Spark";
import { ViewportChangedMessage_Spark } from "./ViewportChangedMessage_Spark";
import { PixelRatioMessage_Spark } from "./PixelRatioMessage_Spark";
import { RenderingContext } from "igniteui-angular-core";
import { FontUtil } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { Color } from "igniteui-angular-core";
import { Line } from "igniteui-angular-core";
import { TextBlock } from "igniteui-angular-core";
import { BindingFormatter } from "igniteui-angular-core";
import { SparklineAxisVisualData } from "./SparklineAxisVisualData";
import { LineVisualData } from "igniteui-angular-core";
import { AppearanceHelper } from "igniteui-angular-core";
import { Visibility_$type } from "igniteui-angular-core";
import { ClearMessage_Spark } from "./ClearMessage_Spark";
import { ISchedulableRender_$type } from "igniteui-angular-core";
import { CanvasRenderScheduler } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { PolygonMessage_Spark } from "./PolygonMessage_Spark";
import { ColumnMessage_Spark } from "./ColumnMessage_Spark";
import { WinLossColumnMessage_Spark } from "./WinLossColumnMessage_Spark";
import { MarkerMessage_Spark } from "./MarkerMessage_Spark";
import { NormalRangeMessage_Spark } from "./NormalRangeMessage_Spark";
import { TrendLineMessage_Spark } from "./TrendLineMessage_Spark";
import { TooltipMessage_Spark } from "./TooltipMessage_Spark";
import { ToooltipTemplateMessage_Spark } from "./ToooltipTemplateMessage_Spark";
import { ContainerMessage_Spark } from "./ContainerMessage_Spark";
import { BrushChangedMessage_Spark } from "./BrushChangedMessage_Spark";
import { VisibilityMessage_Spark } from "./VisibilityMessage_Spark";
import { NumberChangedMessage_Spark } from "./NumberChangedMessage_Spark";
import { ContainerSizeChangedMessage_Spark } from "./ContainerSizeChangedMessage_Spark";
import { MouseMoveMessage_Spark } from "./MouseMoveMessage_Spark";
import { MouseLeaveMessage_Spark } from "./MouseLeaveMessage_Spark";
import { CanvasGestureDOMEventProxy } from "igniteui-angular-core";
import { CanvasViewRenderer } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { TranslateTransform } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { GeometryGroup } from "igniteui-angular-core";
import { EllipseGeometry } from "igniteui-angular-core";
import { PathGeometry } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { LineSegment } from "igniteui-angular-core";
import { RectangleGeometry } from "igniteui-angular-core";
import { SparklineToolTipContext } from "./SparklineToolTipContext";
import { DataContext } from "igniteui-angular-core";
import { SparklineVisualData } from "./SparklineVisualData";
import { RectData } from "igniteui-angular-core";
import { PathVisualData } from "igniteui-angular-core";
import { SparklineDisplayType_$type } from "./SparklineDisplayType";
import { truncate, isNaN_, isInfinity } from "igniteui-angular-core";
import { SparkFrame } from "./SparkFrame";
import { TrendLineType_$type } from "igniteui-angular-core";
import { TrendCalculators } from "igniteui-angular-core";
import { LeastSquaresFit } from "igniteui-angular-core";
import { DependencyObject } from "igniteui-angular-core";
import { IFastItemsSourceProvider_$type } from "igniteui-angular-core";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { PropertyChangedMessage_Spark } from "./PropertyChangedMessage_Spark";
import { FastItemsSource } from "igniteui-angular-core";
import { DataChangedMessage_Spark } from "./DataChangedMessage_Spark";
import { NotifyCollectionChangedEventArgs } from "igniteui-angular-core";
import { FastItemsSourceReference } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { UnknownValuePlotting_$type } from "igniteui-angular-core";
import { Control } from "igniteui-angular-core";
/**
 * @hidden
 */
var HorizontalAxisView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(HorizontalAxisView, _super);
    function HorizontalAxisView(a) {
        var _this = _super.call(this) || this;
        _this.j = null;
        _this.w = null;
        _this.m = null;
        _this.l = null;
        _this.s = 0;
        _this.v = 0;
        _this.u = 0;
        _this.k = null;
        _this.r = -1;
        _this.ag = null;
        _this.af = null;
        _this.ah = null;
        _this.a = ["border-top-width", "border-top-color", "color"];
        _this.n = false;
        _this.q = 1;
        _this.g = null;
        _this.o = new Dictionary$2(Type.$, Delegate_$type, 0);
        _this.d = null;
        _this.c = null;
        _this.p.item(AxisRenderMessage_Spark.$, function (b) { return _this.ac(typeCast(AxisRenderMessage_Spark.$, b)); });
        _this.p.item(ContainerResizedMessage_Spark.$, function (b) { return _this.y(typeCast(ContainerResizedMessage_Spark.$, b)); });
        _this.p.item(ViewportChangedMessage_Spark.$, function (b) { return _this.ae(typeCast(ViewportChangedMessage_Spark.$, b)); });
        _this.p.item(PixelRatioMessage_Spark.$, function (b) { return _this.ab(typeCast(PixelRatioMessage_Spark.$, b)); });
        _this.j = a;
        return _this;
    }
    HorizontalAxisView.prototype.b = function () {
        if (!this.n) {
            this.n = true;
            this.k.a("ui-sparkline-axis-x", this.a);
        }
        return this.a;
    };
    HorizontalAxisView.prototype.t = function () {
        var a = this.r;
        if (a >= 0) {
            return a;
        }
        var b = this.b()[0];
        if (b != null) {
            a = parseInt(b);
        }
        this.r = a = (a < 1) ? 1 : a;
        return a;
    };
    Object.defineProperty(HorizontalAxisView.prototype, "h", {
        get: function () {
            return this.g;
        },
        set: function (a) {
            var b = this.g;
            this.g = a;
            this.k = a.getService("View");
            this.aa(b, this.g);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HorizontalAxisView.prototype, "p", {
        get: function () {
            return this.o;
        },
        set: function (a) {
            this.o = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HorizontalAxisView.prototype, "f", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            this.d = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HorizontalAxisView.prototype, "e", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: false,
        configurable: true
    });
    HorizontalAxisView.prototype.z = function (a) {
        var _this = this;
        var b;
        if (((function () { var c = _this.p.tryGetValue(getInstanceType(a), b); b = c.p1; return c.ret; })())) {
            b(a);
        }
    };
    HorizontalAxisView.prototype.aa = function (a, b) {
        if (a != null) {
            this.f.detachTarget(runOn(this, this.z));
        }
        if (b != null) {
            this.f = b.getService("RenderingMessages");
            this.e = b.getService("InteractionMessages");
            this.f.attachTarget(runOn(this, this.z));
        }
    };
    HorizontalAxisView.prototype.y = function (a) {
        this.w = a.j;
        this.m = a.b;
        this.l = this.k.o("ui-sparkline-axis-x");
        if (this.l == null) {
            this.l = FontUtil.getFont(a.h);
        }
        if (this.m != null) {
            this.m.ad(this.l);
        }
        this.s = FontUtil.getCurrentFontHeight(a.h, this.l);
        if (this.j != null && this.j.fm != 1) {
            a.d = a.d - this.s;
            a.e = this.t();
        }
    };
    HorizontalAxisView.prototype.ae = function (a) {
        this.v = this.w.width();
        this.u = this.s + this.t();
    };
    HorizontalAxisView.prototype.ac = function (a) {
        this.ad(a.c);
    };
    HorizontalAxisView.prototype.ad = function (a) {
        this.ah = null;
        var b = (!a || this.j == null) ? null : this.m;
        if (b == null || !b.d) {
            return;
        }
        b.l(0, 0, this.v, this.u);
        if (this.l != null) {
            b.ad(this.l);
        }
        if (this.q != 1) {
            b.aa();
            b.ab(this.q, this.q);
        }
        var c = this.t(), d = c / 2;
        var e = this.j.av == null || this.j.av.count == 0;
        if (e) {
            this.u = 0;
        }
        var f = e ? null : this.x(this.j.av.item(0));
        var g = f == null ? "" : f.toString();
        this.ag = new TextBlock();
        this.ag.al = g;
        this.ag.n = 2;
        this.af = new TextBlock();
        var h = e ? null : this.x(this.j.av.item(this.j.av.count - 1));
        this.af.al = g = h == null ? "" : h.toString();
        this.af.o = this.ag.o = c;
        this.af.n = this.v - b.g(g) - 4;
        var i = this.j.fb;
        var j = i == null ? null : i._fill;
        var k = new Color();
        var l = true;
        if (i != null) {
            l = false;
            k = i.color;
        }
        i = new Brush();
        if (l) {
            i._fill = (this.a[2] == null) ? "#000000" : this.a[2];
        }
        else {
            i.color = k;
        }
        this.ag.ao = this.af.ao = i;
        b.x(this.ag);
        b.x(this.af);
        if (c < 0.5) {
            return;
        }
        i = new Brush();
        if (j == null) {
            j = this.a[1];
        }
        i._fill = (j == null) ? "#000000" : j;
        this.ah = new Line();
        this.ah.ak = 0;
        this.ah.al = this.w.width();
        this.ah.am = d;
        this.ah.an = d;
        this.ah._stroke = i;
        this.ah.ac = c;
        b.s(this.ah);
        if (this.q != 1) {
            b.z();
        }
    };
    HorizontalAxisView.prototype.x = function (dataItem_) {
        var a = null;
        if (this.j.ai != null) {
            a = this.j.ai.i(dataItem_);
        }
        if (this.j.ax()) {
            a = this.j.c1(dataItem_);
        }
        if (a != null) {
            return a;
        }
        var label_ = this.j.br;
        return (typeof dataItem_ != 'undefined') ? dataItem_ : '';
        ;
    };
    HorizontalAxisView.prototype.i = function () {
        var a = new SparklineAxisVisualData();
        if (this.ah != null) {
            a.axisLine = new LineVisualData(1, "HorizontalAxisLine", this.ah);
            a.axisLine.appearance.isVisible = this.w.height() > 0;
        }
        var b = this.l;
        if (this.ag != null) {
            a.minLabel = AppearanceHelper.c(this.ag, this.l);
        }
        if (this.af != null) {
            a.maxLabel = AppearanceHelper.c(this.af, this.l);
        }
        return a;
    };
    HorizontalAxisView.prototype.ab = function (a) {
        this.q = a.b;
    };
    HorizontalAxisView.$t = markType(HorizontalAxisView, 'HorizontalAxisView');
    return HorizontalAxisView;
}(Base));
export { HorizontalAxisView };
/**
 * @hidden
 */
var VerticalAxisView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(VerticalAxisView, _super);
    function VerticalAxisView(a) {
        var _this = _super.call(this) || this;
        _this.ad = null;
        _this.ac = null;
        _this.al = null;
        _this.ak = null;
        _this.am = null;
        _this.w = -1;
        _this.u = -1;
        _this.j = null;
        _this.aa = null;
        _this.m = null;
        _this.l = null;
        _this.t = 0;
        _this.v = 0;
        _this.z = 0;
        _this.y = 0;
        _this.k = null;
        _this.s = -1;
        _this.a = ["border-top-width", "border-top-color", "color", "text-align"];
        _this.n = false;
        _this.g = null;
        _this.p = new Dictionary$2(Type.$, Delegate_$type, 0);
        _this.d = null;
        _this.c = null;
        _this.r = 1;
        _this.q.item(AxisRenderMessage_Spark.$, function (b) { return _this.ai(typeCast(AxisRenderMessage_Spark.$, b)); });
        _this.q.item(ContainerResizedMessage_Spark.$, function (b) { return _this.ae(typeCast(ContainerResizedMessage_Spark.$, b)); });
        _this.q.item(ViewportChangedMessage_Spark.$, function (b) { return _this.aj(typeCast(ViewportChangedMessage_Spark.$, b)); });
        _this.q.item(PixelRatioMessage_Spark.$, function (b) { return _this.ah(typeCast(PixelRatioMessage_Spark.$, b)); });
        _this.j = a;
        return _this;
    }
    VerticalAxisView.prototype.b = function () {
        if (!this.n) {
            this.n = true;
            this.k.a("ui-sparkline-axis-y", this.a);
        }
        return this.a;
    };
    VerticalAxisView.prototype.x = function () {
        var a = this.s;
        if (a >= 0) {
            return a;
        }
        var b = this.b()[0];
        if (b != null) {
            a = parseInt(b);
        }
        this.s = a = (a < 1) ? 1 : a;
        return a;
    };
    Object.defineProperty(VerticalAxisView.prototype, "h", {
        get: function () {
            return this.g;
        },
        set: function (a) {
            var b = this.g;
            this.g = a;
            this.k = a.getService("View");
            this.ag(b, this.g);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(VerticalAxisView.prototype, "q", {
        get: function () {
            return this.p;
        },
        set: function (a) {
            this.p = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(VerticalAxisView.prototype, "f", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            this.d = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(VerticalAxisView.prototype, "e", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAxisView.prototype.af = function (a) {
        var _this = this;
        var b;
        if (((function () { var c = _this.q.tryGetValue(getInstanceType(a), b); b = c.p1; return c.ret; })())) {
            b(a);
        }
    };
    VerticalAxisView.prototype.ag = function (a, b) {
        if (a != null) {
            this.f.detachTarget(runOn(this, this.af));
        }
        if (b != null) {
            this.f = b.getService("RenderingMessages");
            this.e = b.getService("InteractionMessages");
            this.f.attachTarget(runOn(this, this.af));
        }
    };
    VerticalAxisView.prototype.ae = function (a) {
        this.aa = a.k;
        this.m = a.c;
        this.l = this.k.o("ui-sparkline-axis-y");
        if (this.l == null) {
            this.l = FontUtil.getFont(a.h);
        }
        if (this.m != null) {
            this.m.ad(this.l);
        }
        this.t = FontUtil.getCurrentFontHeight(a.h, this.l);
        if (this.j != null && this.j.ft != 1) {
            this.o(false);
            a.g = a.g - this.v;
            a.f = this.x();
        }
    };
    VerticalAxisView.prototype.aj = function (a) {
        this.z = this.v + this.x();
        this.y = this.aa.height();
    };
    VerticalAxisView.prototype.ai = function (a) {
        if (this.o(a.c)) {
            var b = new ClearMessage_Spark();
            b.c = true;
            this.f.sendMessage(b);
        }
    };
    VerticalAxisView.prototype.o = function (a) {
        this.am = null;
        if (this.j == null || this.m == null || !this.m.d || (a && this.ak == null)) {
            return false;
        }
        var b = this.m;
        if (a) {
            b.l(0, 0, this.z, this.y);
        }
        var c = false;
        if (b != null && this.l != null) {
            b.ad(this.l);
        }
        if (!a) {
            this.al = new TextBlock();
            this.ak = new TextBlock();
            var d = this.ab(this.j.a4);
            this.al.al = this.ad = d == null ? "" : d.toString();
            var e = this.ab(this.j.a3);
            this.ak.al = this.ac = e == null ? "" : e.toString();
            if (b != null) {
                this.w = b.g(this.ad) + 3;
                if (this.w > this.v) {
                    c = true;
                    this.v = this.w;
                }
                this.u = b.g(this.ac) + 3;
                if (this.u > this.v) {
                    c = true;
                    this.v = this.u;
                }
            }
            if (!c) {
                var f = Math.max(this.w, this.u);
                if (f < this.v) {
                    this.v = f;
                    c = true;
                }
            }
            if (c) {
                this.z = this.v;
            }
        }
        else if (b != null) {
            if (this.r != 1) {
                b.aa();
                b.ab(this.r, this.r);
            }
            var g = this.j.fj;
            var h = 1;
            var i = g == null ? null : g._fill;
            var j = this.b()[3];
            if (j == "left") {
                h = 0;
            }
            else if (j == "center") {
                h = 0.5;
            }
            this.ak.o = 2;
            this.ak.n = (this.v - this.u) * h + 1;
            this.al.n = (this.v - this.w) * h + 1;
            this.al.o = this.y - this.t - 2;
            var k = new Color();
            var l = true;
            if (g != null) {
                k = g.color;
                l = false;
            }
            g = new Brush();
            if (l) {
                g._fill = (this.a[2] == null) ? "#000000" : this.a[2];
            }
            else {
                g.color = k;
            }
            this.al.ao = this.ak.ao = g;
            b.x(this.al);
            b.x(this.ak);
            var m = this.x(), n = m / 2;
            if (m >= 0.5) {
                g = new Brush();
                if (i == null) {
                    i = this.a[1];
                }
                g._fill = (i == null) ? "#000000" : i;
                this.am = new Line();
                this.am.ak = this.z - n;
                this.am.al = this.z - n;
                this.am.am = 0;
                this.am.an = this.y;
                this.am._stroke = g;
                this.am.ac = m;
                b.s(this.am);
            }
            if (this.r != 1) {
                b.z();
            }
        }
        return c;
    };
    VerticalAxisView.prototype.ab = function (dataItem_) {
        var a = null;
        if (this.j.aj != null) {
            a = this.j.aj.i(dataItem_);
        }
        if (this.j.ax()) {
            a = this.j.c1(dataItem_);
        }
        if (a != null) {
            return a;
        }
        var label_ = this.j.bt;
        return (typeof dataItem_ != 'undefined') ? dataItem_ : '';
        ;
    };
    VerticalAxisView.prototype.i = function () {
        var a = new SparklineAxisVisualData();
        if (this.am != null) {
            a.axisLine = new LineVisualData(1, "VerticalAxisLine", this.am);
            a.axisLine.appearance.isVisible = this.aa.width() > 0;
        }
        if (this.al != null) {
            a.minLabel = AppearanceHelper.c(this.al, this.l);
        }
        if (this.ak != null) {
            a.maxLabel = AppearanceHelper.c(this.ak, this.l);
        }
        return a;
    };
    VerticalAxisView.prototype.ah = function (a) {
        this.r = a.b;
    };
    VerticalAxisView.$t = markType(VerticalAxisView, 'VerticalAxisView');
    return VerticalAxisView;
}(Base));
export { VerticalAxisView };
/**
 * @hidden
 */
var XamSparklineView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(XamSparklineView, _super);
    function XamSparklineView() {
        var _this = _super.call(this) || this;
        _this.bn = null;
        _this.bm = null;
        _this.ae = null;
        _this.af = null;
        _this.ag = null;
        _this.ah = null;
        _this.p = null;
        _this.q = null;
        _this.r = null;
        _this.n = null;
        _this.u = false;
        _this.b = new Array(6);
        _this.y = -1;
        _this.bw = new Path();
        _this.bu = new Path();
        _this.bx = new Path();
        _this.bv = new Path();
        _this.bs = new Path();
        _this.bt = new Path();
        _this.br = new Path();
        _this.bp = new Path();
        _this.bo = new Path();
        _this.bq = new Path();
        _this.j = null;
        _this.f = null;
        _this.g = null;
        _this.v = new Dictionary$2(Type.$, Delegate_$type, 0);
        _this.l = null;
        _this.s = false;
        _this.ai = null;
        _this.e = null;
        _this.d = null;
        _this.c = null;
        _this.t = false;
        _this.x = 1;
        _this.bs._visibility = 1;
        _this.bt._visibility = 1;
        _this.br._visibility = 1;
        _this.bp._visibility = 1;
        _this.bo._visibility = 1;
        _this.bq._visibility = 1;
        _this.bv._visibility = 1;
        var a = _this.w;
        a.item(ClearMessage_Spark.$, function (b) { return _this.aj(typeCast(ClearMessage_Spark.$, b)); });
        a.item(PolygonMessage_Spark.$, function (b) { return _this.bc(typeCast(PolygonMessage_Spark.$, b)); });
        a.item(ColumnMessage_Spark.$, function (b) { return _this.a5(typeCast(ColumnMessage_Spark.$, b)); });
        a.item(WinLossColumnMessage_Spark.$, function (b) { return _this.bj(typeCast(WinLossColumnMessage_Spark.$, b)); });
        a.item(MarkerMessage_Spark.$, function (b) { return _this.a8(typeCast(MarkerMessage_Spark.$, b)); });
        a.item(NormalRangeMessage_Spark.$, function (b) { return _this.bd(typeCast(NormalRangeMessage_Spark.$, b)); });
        a.item(TrendLineMessage_Spark.$, function (b) { return _this.bg(typeCast(TrendLineMessage_Spark.$, b)); });
        a.item(TooltipMessage_Spark.$, function (b) { return _this.be(typeCast(TooltipMessage_Spark.$, b)); });
        a.item(ToooltipTemplateMessage_Spark.$, function (b) { return _this.bf(typeCast(ToooltipTemplateMessage_Spark.$, b)); });
        a.item(ContainerMessage_Spark.$, function (b) { return _this.ak(typeCast(ContainerMessage_Spark.$, b)); });
        a.item(PixelRatioMessage_Spark.$, function (b) { return _this.aw(typeCast(PixelRatioMessage_Spark.$, b)); });
        a.item(BrushChangedMessage_Spark.$, function (b) { return _this.a3(typeCast(BrushChangedMessage_Spark.$, b)); });
        a.item(ContainerResizedMessage_Spark.$, function (b) { return _this.at(); });
        a.item(VisibilityMessage_Spark.$, function (b) { return _this.bi(typeCast(VisibilityMessage_Spark.$, b)); });
        a.item(NumberChangedMessage_Spark.$, function (b) { return _this.bb(typeCast(NumberChangedMessage_Spark.$, b)); });
        a.item(ContainerSizeChangedMessage_Spark.$, function (b) { return _this.at(); });
        _this.d = new CanvasRenderScheduler();
        _this.c = new CanvasRenderScheduler();
        _this.d.l(_this);
        _this.c.l(_this);
        return _this;
    }
    XamSparklineView.prototype.aw = function (a) {
        this.x = a.b;
    };
    Object.defineProperty(XamSparklineView.prototype, "k", {
        get: function () {
            return this.j;
        },
        set: function (a) {
            var b = this.j;
            this.j = a;
            this.av(b, this.j);
            this.l = null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamSparklineView.prototype, "h", {
        get: function () {
            return this.f;
        },
        set: function (a) {
            this.f = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamSparklineView.prototype, "i", {
        get: function () {
            return this.g;
        },
        set: function (a) {
            this.g = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamSparklineView.prototype, "w", {
        get: function () {
            return this.v;
        },
        set: function (a) {
            this.v = a;
        },
        enumerable: false,
        configurable: true
    });
    XamSparklineView.prototype.av = function (a, b) {
        if (a != null) {
            this.i.detachTarget(runOn(this, this.ar));
            this.h = null;
        }
        if (b != null) {
            this.i = b.getService("RenderingMessages");
            this.h = b.getService("InteractionMessages");
            this.i.attachTarget(runOn(this, this.ar));
            this.a2(this.h);
        }
    };
    XamSparklineView.prototype.a2 = function (a) {
        this.h = a;
    };
    XamSparklineView.prototype.ar = function (a) {
        var _this = this;
        var b;
        if (((function () { var c = _this.w.tryGetValue(getInstanceType(a), b); b = c.p1; return c.ret; })())) {
            b(a);
        }
    };
    Object.defineProperty(XamSparklineView.prototype, "m", {
        get: function () {
            if (this.l == null) {
                this.l = this.k.getService("Controller");
            }
            return this.l;
        },
        enumerable: false,
        configurable: true
    });
    XamSparklineView.prototype.a1 = function (a, b, c) {
        var d = new MouseMoveMessage_Spark();
        d.position = a;
        this.h.sendMessage(d);
    };
    XamSparklineView.prototype.a0 = function (a) {
        var b = new MouseLeaveMessage_Spark();
        this.h.sendMessage(b);
    };
    XamSparklineView.prototype.a3 = function (a) {
        this.a4(a.b, a.c, null, -1, -1);
    };
    XamSparklineView.prototype.a4 = function (a, b, c, d, e) {
        var f = null;
        var g = true, h = true;
        switch (a) {
            case "sparkpath":
            case XamSparkline.$$p[0]:
                f = this.bw;
                break;
            case "negativesparkpath":
            case XamSparkline.$$p[29]:
                f = this.bu;
                break;
            case "markers":
            case XamSparkline.$$p[24]:
                f = this.bs;
                break;
            case "firstmarker":
            case XamSparkline.$$p[3]:
                f = this.bo;
                break;
            case "lastmarker":
            case XamSparkline.$$p[17]:
                f = this.bq;
                break;
            case "highmarker":
            case XamSparkline.$$p[7]:
                f = this.bp;
                break;
            case "lowmarker":
            case XamSparkline.$$p[21]:
                f = this.br;
                break;
            case "negativemarkers":
            case XamSparkline.$$p[30]:
                f = this.bt;
                break;
            case "trendline":
            case XamSparkline.$$p[38]:
                f = this.bx;
                h = false;
                break;
            case "range":
            case XamSparkline.$$p[33]:
                f = this.bv;
                g = false;
                break;
        }
        if (f == null) {
            return;
        }
        if (b == null && c != null) {
            b = new Brush();
            b._fill = c;
        }
        if (b != null) {
            if (h && (c == null || f._fill == null)) {
                f._fill = b;
            }
            if (g && (c == null || f._stroke == null)) {
                f._stroke = b;
            }
        }
        if (d > 0 && d < 1) {
            f._opacity = d;
        }
        if (e > 0 && (c == null || f.ac <= 0)) {
            f.ac = e;
        }
        this.aq();
    };
    XamSparklineView.prototype.bi = function (a) {
        switch (a.b) {
            case XamSparkline.$$p[26]:
                this.bs._visibility = a.c;
                break;
            case XamSparkline.$$p[5]:
                this.bo._visibility = a.c;
                break;
            case XamSparkline.$$p[19]:
                this.bq._visibility = a.c;
                break;
            case XamSparkline.$$p[9]:
                this.bp._visibility = a.c;
                break;
            case XamSparkline.$$p[23]:
                this.br._visibility = a.c;
                break;
            case XamSparkline.$$p[32]:
                this.bt._visibility = a.c;
                break;
            case XamSparkline.$$p[36]:
                this.bv._visibility = a.c;
                break;
            case XamSparkline.$$p[37]:
                this.u = a.c == 0;
                break;
        }
        this.aq();
    };
    XamSparklineView.prototype.bb = function (a) {
        var b = a.b;
        if (b <= 0) {
            return;
        }
        switch (a.c) {
            case XamSparkline.$$p[20]:
                this.bw.ac = this.bu.ac = b;
                break;
            case XamSparkline.$$p[40]:
                this.bx.ac = b;
                break;
        }
        this.aq();
    };
    XamSparklineView.prototype.ak = function (a) {
        if (a.b == null) {
            if (this.n != null) {
                this.n.av();
                var b = this.n;
                b.onMouseLeave = delegateRemove(b.onMouseLeave, runOn(this, this.a0));
                var c = this.n;
                c.onMouseOver = delegateRemove(c.onMouseOver, runOn(this, this.a1));
                this.n = null;
            }
            this.ae = null;
            this.af = null;
            this.ag = null;
            this.ah = null;
            this.p = this.q = this.r = null;
            this.d.j(null);
            return;
        }
        var d = a.b;
        this.d.j(d);
        this.ae = d;
        this.ae.rootWrapper.setStyleProperty("position", "relative");
        this.af = this.ae.createElement("canvas");
        this.af.setStyleProperty("position", "absolute");
        this.ag = this.ae.createElement("canvas");
        this.ag.setStyleProperty("position", "absolute");
        this.ah = this.ae.createElement("canvas");
        this.ah.setStyleProperty("position", "absolute");
        this.ae.append(this.af);
        this.ae.append(this.ag);
        this.ae.append(this.ah);
        this.p = new RenderingContext(new CanvasViewRenderer(), this.ae.get2DCanvasContext(this.af));
        this.q = new RenderingContext(new CanvasViewRenderer(), this.ae.get2DCanvasContext(this.ag));
        this.r = new RenderingContext(new CanvasViewRenderer(), this.ae.get2DCanvasContext(this.ah));
        this.n = new CanvasGestureDOMEventProxy(this.af, this.ae, false);
        var e = this.n;
        e.onMouseLeave = delegateCombine(e.onMouseLeave, runOn(this, this.a0));
        var f = this.n;
        f.onMouseOver = delegateCombine(f.onMouseOver, runOn(this, this.a1));
        this.n.ap = function (g) { return false; };
        this.ao();
        this.at();
    };
    XamSparklineView.prototype.ao = function () {
        var a = ["sparkpath", "negativesparkpath", "trendline", "markers", "firstmarker", "lastmarker", "highmarker", "lowmarker", "negativemarkers", "range"];
        var b = ["#8bdc5c", "#ee5879", "#565656", "#8b5bb1", "#f8a15f", "#ee5879", "#6db1ff", "#f7d262", "#ee5879", "#66666666"];
        for (var c = 0; c < 10; c++) {
            var d = a[c];
            var e = ["background-color", "opacity", "border-top-width"];
            this.a("ui-sparkline-" + d, e);
            var f = XamSparklineView.ad(e[2], (c < 3) ? (c < 2 ? 2 : 1.5) : -1);
            if (c > 2 && c < 9) {
                this.b[c - 3] = f;
            }
            this.a4(d, null, (e[0] == null) ? b[c] : e[0], XamSparklineView.ad(e[1], -1), c < 3 ? f : -1);
        }
    };
    XamSparklineView.ad = function (v_, a) {
        var d_ = (v_ == null || v_.length < 1) ? null : parseFloat(v_);
        return (d_ == null || d_.toString() == "NaN") ? a : d_;
    };
    XamSparklineView.prototype.a = function (a, b) {
        this.ae.startCSSQuery();
        for (var c = 0; c < b.length; c++) {
            b[c] = this.ae.getCssDefaultPropertyValue(a, b[c]);
        }
        this.ae.endCSSQuery();
        return b;
    };
    XamSparklineView.prototype.at = function () {
        if (this.ae == null || this.s) {
            return;
        }
        this.s = true;
        this.ap(this.m.q);
        var a = this.ae.rootWrapper.width(), b = this.ae.rootWrapper.height();
        var c, d, e;
        c = this.af;
        d = this.ag;
        e = this.ah;
        var f = new ContainerResizedMessage_Spark();
        f.g = a;
        f.d = b;
        f.b = this.q;
        f.h = this.ae;
        f.c = this.r;
        f.f = 0;
        f.e = 0;
        f.j = d;
        f.i = c;
        f.k = e;
        this.i.sendMessage(f);
        var g = f.e, h = f.f, i = f.g - h, j = f.d - g;
        var k = i, l = a - i, m = j, n = b - j;
        c.setStyleProperty("width", k.toString() + "px");
        c.setStyleProperty("height", m.toString() + "px");
        c.setAttribute("width", (k * this.x).toString());
        c.setAttribute("height", (m * this.x).toString());
        c.setStyleProperty("marginLeft", l + "px");
        k = (i + h);
        this.az(d, k, n, k * this.x, n * this.x);
        d.setStyleProperty("marginTop", m + "px");
        d.setStyleProperty("marginLeft", (a - i - h).toString() + "px");
        this.az(e, l, m, l * this.x, m * this.x);
        this.bn = new Rect(0, 0, 0, i, j);
        if (this.n != null) {
            this.n.bl = this.bn;
        }
        this.bh();
        var o = new ViewportChangedMessage_Spark();
        o.newLeft = this.bn.left;
        o.newTop = this.bn.top;
        o.newHeight = this.bn.height;
        o.newWidth = this.bn.width;
        this.i.sendMessage(o);
        this.s = false;
    };
    XamSparklineView.prototype.al = function (a) {
        if (a) {
            this.y = -1;
        }
        else if (this.y < 0) {
            this.bh();
        }
    };
    XamSparklineView.prototype.bh = function () {
        var a = this.bn.left;
        var b = this.bn.width;
        var c = this.bn.height;
        var d = this.ab(true);
        var e = new Rect(0, a + d, d, b - d * 2, c - d * 2);
        var f = new ViewportChangedMessage_Spark();
        f.newLeft = e.left;
        f.newTop = e.top;
        f.newHeight = e.height;
        f.newWidth = e.width;
        this.bm = e;
        this.h.sendMessage(f);
    };
    XamSparklineView.prototype.aj = function (a) {
        if (Rect.l_op_Equality(this.bn, null)) {
            return;
        }
        switch (a.b) {
            case 2:
                this.bs.ak = null;
                this.bo.ak = null;
                this.bq.ak = null;
                this.bp.ak = null;
                this.br.ak = null;
                this.bt.ak = null;
                break;
            case 8:
                this.bv.ak = null;
                break;
            case 1:
                this.bw.ak = null;
                this.bu.ak = null;
                break;
            case 4:
                this.am(null);
                break;
            case 16:
                this.bx.ak = null;
                break;
        }
        if (a.c) {
            this.at();
        }
    };
    XamSparklineView.prototype.ab = function (a) {
        if (a) {
            this.y = -1;
        }
        var b = this.y;
        if (b >= 0) {
            return b;
        }
        b = 0;
        var c = this.m.q;
        if (c.fp == 0) {
            b = this.ac(b, c.bd, 0);
        }
        if (c.fk == 0) {
            b = this.ac(b, c.a6, 1);
        }
        if (c.fn == 0) {
            b = this.ac(b, c.a8, 2);
        }
        if (c.fl == 0) {
            b = this.ac(b, c.a7, 3);
        }
        if (c.fo == 0) {
            b = this.ac(b, c.bc, 4);
        }
        if (c.fq == 0) {
            b = this.ac(b, c.bi, 5);
        }
        this.y = b;
        return b;
    };
    XamSparklineView.prototype.ac = function (a, b, c) {
        if (b >= 0) {
            return b > a ? b : a;
        }
        return this.b[c] > a ? this.b[c] : a;
    };
    XamSparklineView.prototype.a8 = function (a) {
        this.a9(this.bs, a.e, a.k, 0);
        this.a9(this.bt, a.f, a.l, 5);
        this.a9(this.br, a.d, a.j, 4);
        this.a9(this.bp, a.c, a.h, 3);
        this.ba(this.bo, a.m, a.g, 1);
        this.ba(this.bq, a.n, a.i, 2);
        this.aq();
    };
    XamSparklineView.prototype.ba = function (a, b, c, d) {
        var e = ((function () {
            var $ret = new List$1(Point_$type, 0);
            $ret.add(b);
            return $ret;
        })());
        this.a9(a, e, c, d);
    };
    XamSparklineView.prototype.a9 = function (a, b, c, d) {
        if (c < 0) {
            c = this.b[d];
        }
        a.ak = this.bl(b, c < 0.1 ? DeviceUtils.g(3) : c);
        if (this.m.q.aq != 3) {
            var e = new TranslateTransform();
            e.j = this.m.o.d;
            a.j = e;
        }
        else {
            a.j = null;
        }
    };
    XamSparklineView.prototype.bl = function (a, b) {
        var e_1, _a;
        var c = new GeometryGroup();
        c.c = 1;
        var d = this.bn.right;
        var e = this.bn.bottom;
        try {
            for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                if ((!f)) {
                    continue;
                }
                if (f.x < 0 || f.y < 0 || f.x > d || f.y > e) {
                    continue;
                }
                var g = new EllipseGeometry();
                g.c = b;
                g.d = b;
                g.e = f;
                c.d.add(g);
            }
        }
        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;
            }
        }
        return c;
    };
    XamSparklineView.prototype.bc = function (a) {
        var e_2, _a;
        var b = new PathGeometry();
        var c = this.m.q.aq == 1;
        try {
            for (var _b = __values(fromEnum(a.points)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                var e = d.length;
                if (e == 0) {
                    continue;
                }
                var f = new PathFigure();
                f._isClosed = f._isFilled = c;
                f._startPoint = d[0];
                for (var g = 1; g < e; g++) {
                    var h = new LineSegment(1);
                    h.c = d[g];
                    f._segments.add(h);
                }
                b.c.add(f);
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
        this.bw.ak = b;
        this.aq();
    };
    XamSparklineView.prototype.bk = function (a, b) {
        var e_3, _a;
        var c = typeCast(WinLossColumnMessage_Spark.$, b);
        var d = typeCast(ColumnMessage_Spark.$, b);
        var e = new GeometryGroup();
        var f = c != null ? c.i : d.i;
        var g = c != null ? c.h : d.h;
        var h = f * 0.1;
        try {
            for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var i = _c.value;
                var j = f * 2 - h * 2;
                var k = Math.abs(g - i.y);
                var l = i.x + h;
                var m = (i.y > g ? g : i.y);
                var n = new RectangleGeometry();
                n.e = new Rect(0, l, m, j, k);
                e.d.add(n);
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
        return e;
    };
    XamSparklineView.prototype.a5 = function (a) {
        this.a6(this.bw, a.d, a);
        this.a6(this.bu, a.g, a);
        this.aq();
    };
    XamSparklineView.prototype.a7 = function (a, b, c) {
        var d = ((function () {
            var $ret = new List$1(Point_$type, 0);
            $ret.add(b);
            return $ret;
        })());
        this.a6(a, d, c);
    };
    XamSparklineView.prototype.a6 = function (a, b, c) {
        a.ak = this.bk(b, c);
    };
    XamSparklineView.prototype.bj = function (a) {
        this.a6(this.bw, a.d, a);
        this.a6(this.bu, a.g, a);
        this.aq();
    };
    XamSparklineView.prototype.bd = function (a) {
        var b = new RectangleGeometry();
        b.e = new Rect(0, a.k, a.l, a.j, a.i);
        this.bv.ak = b;
        this.aq();
    };
    XamSparklineView.prototype.bg = function (a) {
        if (a.points.length == 0) {
            return;
        }
        var b = new PathGeometry();
        var c = new PathFigure();
        c._isClosed = c._isFilled = false;
        c._startPoint = a.points[0];
        var d = a.points.length;
        for (var e = 1; e < d; e++) {
            var f = new LineSegment(1);
            f.c = a.points[e];
            c._segments.add(f);
        }
        b.c.add(c);
        this.bx.ak = b;
        this.aq();
    };
    XamSparklineView.prototype.bf = function (a) {
        this.ai = a.template;
    };
    XamSparklineView.prototype.be = function (a) {
        if (!this.u) {
            this.am(null);
            return;
        }
        var b = truncate(Math.round(a.xOffset - 10));
        var c = truncate(Math.round(a.yOffset - 10));
        b = truncate(Math.round(b * this.x));
        c = truncate(Math.round(c * this.x));
        var d = this.p.a(b, c);
        if (d[3] > 0) {
            this.am(a);
        }
        else {
            this.am(null);
        }
    };
    XamSparklineView.prototype.am = function (a) {
        var x_ = 0, y_ = 0;
        var v_ = null, t_ = null, i_ = this.ae;
        {
            if (a != null) {
                t_ = this.ai;
                x_ = a.xOffset + 6;
                y_ = a.yOffset + 6;
                var b = a.context;
                var f_ = b.first, l_ = b.last, o_ = b.low, h_ = b.high;
                v_ = { First: f_, Last: l_, Low: o_, High: h_ };
            }
            var ren_ = this.ae;
            if (this.e == null) {
                this.e = new DataContext();
            }
            var dc_ = this.e;
            dc_.item = v_;
            dc_.series = this;
            var tt_ = this.ai;
            if (tt_ != null) {
                if (v_ != null) {
                    tt_.updateToolTip(dc_);
                    tt_.setRawPosition(x_, y_);
                }
                else {
                    tt_.hideToolTip();
                }
            }
        }
    };
    Object.defineProperty(XamSparklineView.prototype, "isDirty", {
        get: function () {
            return this.t;
        },
        set: function (a) {
            this.t = a;
        },
        enumerable: false,
        configurable: true
    });
    XamSparklineView.prototype.aq = function () {
        if (!this.isDirty) {
            this.isDirty = true;
            this.d.o(this.p, null);
            this.c.o(this.q, this.r);
        }
    };
    XamSparklineView.prototype.undirty = function (a) {
        this.t = false;
        this.ax();
    };
    Object.defineProperty(XamSparklineView.prototype, "index", {
        get: function () {
            return 10;
        },
        enumerable: false,
        configurable: true
    });
    XamSparklineView.prototype.ay = function (a, b) {
        b.t(a);
    };
    XamSparklineView.prototype.ax = function () {
        var a = this.p;
        if (a != null && a.d) {
            if (this.x != 1) {
                a.aa();
                a.ab(this.x, this.x);
            }
            a.l(this.bn.left, this.bn.top, this.bn.width, this.bn.height);
            a.t(this.bw);
            a.t(this.bu);
            this.ay(this.bs, a);
            this.ay(this.bt, a);
            this.ay(this.bp, a);
            this.ay(this.br, a);
            this.ay(this.bo, a);
            this.ay(this.bq, a);
            a.t(this.bv);
            a.t(this.bx);
            if (this.x != 1) {
                a.z();
            }
        }
        var b = new AxisRenderMessage_Spark();
        b.c = true;
        this.i.sendMessage(b);
        this.postRender();
    };
    XamSparklineView.prototype.postRender = function () {
    };
    XamSparklineView.prototype.an = function (a) {
        a.viewport = new RectData(this.bn.left, this.bn.top, this.bn.width, this.bn.height);
        a.marginViewport = new RectData(this.bm.left, this.bm.top, this.bm.width, this.bm.height);
        a.sparkPath = new PathVisualData(1, "SparkPath", this.bw);
        a.negativeSparkPath = new PathVisualData(1, "NegativeSparkPath", this.bu);
        a.trendLinePath = new PathVisualData(1, "TrendLinePath", this.bx);
        a.rangePath = new PathVisualData(1, "RangePath", this.bv);
        a.markersPath = new PathVisualData(1, "MarkersPath", this.bs);
        a.negativeMarkersPath = new PathVisualData(1, "NegativeMarkersPath", this.bt);
        a.lowMarkersPath = new PathVisualData(1, "LowMarkersPath", this.br);
        a.highMarkersPath = new PathVisualData(1, "HighMarkersPath", this.bp);
        a.firstMarkerPath = new PathVisualData(1, "FirstMarkerPath", this.bo);
        a.lastMarkerPath = new PathVisualData(1, "LastMarkerPath", this.bq);
    };
    XamSparklineView.prototype.preRender = function () {
    };
    XamSparklineView.prototype.isValid = function () {
        return true;
    };
    XamSparklineView.prototype.o = function (a) {
        return FontUtil.getFontForClass(this.ae, a);
    };
    XamSparklineView.prototype.az = function (a, b, c, d, e) {
        a.setStyleProperty("width", b + "px");
        a.setStyleProperty("height", c + "px");
        a.setAttribute("width", d.toString());
        a.setAttribute("height", e.toString());
    };
    XamSparklineView.prototype.ap = function (a) {
        var b = a.bl;
        var c = a.a5;
        if (!isNaN_(b) && b != 0) {
            return;
        }
        if (window.devicePixelRatio != undefined && window.devicePixelRatio != c) {
            a.a5 = window.devicePixelRatio;
        }
    };
    XamSparklineView.prototype.au = function () {
        if (this.n != null) {
            this.n.bh(this.af, "");
        }
    };
    XamSparklineView.prototype.as = function () {
        this.ap(this.l.q);
        if (this.n != null) {
            this.n.at(this.af, "");
        }
    };
    XamSparklineView.$t = markType(XamSparklineView, 'XamSparklineView', Base.$, [ISchedulableRender_$type]);
    return XamSparklineView;
}(Base));
export { XamSparklineView };
/**
 * @hidden
 */
var SparkFramePreparer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(SparkFramePreparer, _super);
    function SparkFramePreparer() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.b = null;
        _this.d = 0;
        _this.c = 0;
        return _this;
    }
    SparkFramePreparer.prototype.e = function (a) {
        var e_4, _a;
        var _this = this;
        this.b.r.al(false);
        a.g.clear();
        a.l.clear();
        a.j.clear();
        a.k.clear();
        a.i.clear();
        a.h.clear();
        var b = this.b.t;
        if (b == null) {
            return;
        }
        var c = b.count;
        var d = this.b.a3.top;
        var e = this.b.a3.left;
        var f = this.b.a3.width;
        var g = this.b.a3.height;
        var h = this.b.a3.bottom;
        var i = Math.floor((c + 1) / f);
        var j = truncate(Math.max(1, i));
        var k = 0;
        var l = truncate(Math.ceil(1 * c / j));
        var m = 0;
        var n = new List$1(Number_$type, 0);
        var o = this.b.q.ar;
        var p = this.b.q.aq;
        var q = this.b.q.bq;
        var r = o != 0 && q >= 1;
        var s = null;
        var t = null;
        if (p == 1 || p == 0) {
            this.d = 0;
        }
        else {
            if (l == 0) {
                this.d = 0;
            }
            else {
                this.d = f / l / 2;
            }
        }
        if (r) {
            var u = function (v) { return v + 1; };
            var v = function (w) { return b.item(w); };
            var w = function (x) { return _this.b.y(x); };
            var x = function (y) { return _this.b.z(y); };
            switch (this.b.q.ar) {
                case 9:
                    s = TrendCalculators.e(b, q);
                    break;
                case 10:
                    s = TrendCalculators.b(b, q);
                    break;
                case 11:
                    s = TrendCalculators.c(b, q);
                    break;
                case 12:
                    s = TrendCalculators.a(b);
                    break;
                case 13:
                    s = TrendCalculators.g(b, q);
                    break;
                case 1:
                    t = LeastSquaresFit.k(c, u, v);
                    break;
                case 2:
                    t = LeastSquaresFit.o(c, u, v);
                    break;
                case 3:
                    t = LeastSquaresFit.i(c, u, v);
                    break;
                case 4:
                    t = LeastSquaresFit.p(c, u, v);
                    break;
                case 5:
                    t = LeastSquaresFit.q(c, u, v);
                    break;
                case 7:
                    t = LeastSquaresFit.j(c, u, v);
                    break;
                case 6:
                    t = LeastSquaresFit.l(c, u, v);
                    break;
                case 8:
                    t = LeastSquaresFit.n(c, u, v);
                    break;
            }
            if (s != null) {
                try {
                    for (var _b = __values(fromEnum(s)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var y = _c.value;
                        n.add(y);
                    }
                }
                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;
                    }
                }
            }
            if (t != null) {
                var z = k * j;
                var aa = l * j;
                if (p == 1 || p == 0) {
                    aa = aa - 1;
                }
                var ab = 0 + this.d;
                var ac = f - this.d;
                var ad = 0;
                if (this.d != 0) {
                    ad = 0.5;
                }
                for (var ae = ab; ae <= ac; ae += 2) {
                    var af = ae / (f - 1);
                    var ag = z + af * (aa - z);
                    var ah = NaN;
                    switch (o) {
                        case 1:
                            ah = LeastSquaresFit.ad(t, ag - ad);
                            break;
                        case 2:
                            ah = LeastSquaresFit.ah(t, ag - ad);
                            break;
                        case 3:
                            ah = LeastSquaresFit.ab(t, ag - ad);
                            break;
                        case 4:
                            ah = LeastSquaresFit.ai(t, ag - ad);
                            break;
                        case 5:
                            ah = LeastSquaresFit.aj(t, ag - ad);
                            break;
                        case 7:
                            ah = LeastSquaresFit.ac(t, ag - ad);
                            break;
                        case 6:
                            ah = LeastSquaresFit.ae(t, ag - ad);
                            break;
                        case 8:
                            ah = LeastSquaresFit.ag(t, ag - ad);
                            break;
                    }
                    ag = w(ag);
                    ah = x(ah);
                    if (!isNaN_(ah) && !isInfinity(ah)) {
                        a.l.add({ $type: Point_$type, x: ag, y: ah });
                    }
                }
            }
        }
        var ai = this.b.t.minimum;
        var aj = this.b.t.maximum;
        var ak = this.b.q.a4;
        var al = this.b.q.a3;
        this.c = h - (m - ak) / (al - ak) * g;
        if (this.c < 0) {
            this.c = 0;
        }
        else if (this.c > h) {
            this.c = h;
        }
        var am = this.c;
        var an;
        for (var ao = k; ao < l; ao++) {
            var ap = this.a(ao, j, c);
            var aq = ap[1];
            var ar = ap[2];
            this.f(ap, c, this.b.a3, ak, al);
            an = ap[1];
            if (ap[2] < am) {
                an = ap[2];
            }
            a.g.add(ap);
            if (!isNaN_(ap[0]) && !isNaN_(ap[1])) {
                a.j.add({ $type: Point_$type, x: ap[0], y: an });
            }
            if (r && s != null) {
                var as = ao * j;
                var at = h - (((n._inner[as] - ai) / (aj - ai)) * g);
                a.l.add({ $type: Point_$type, x: ap[0] + this.d, y: at });
            }
            if (aq < m) {
                a.k.add({ $type: Point_$type, x: ap[0], y: ap[1] });
            }
            if (ai == aq) {
                a.i.add({ $type: Point_$type, x: ap[0], y: ap[1] });
            }
            if (aj == ar) {
                a.h.add({ $type: Point_$type, x: ap[0], y: ap[2] });
            }
        }
        if (a.j.count == 0) {
            a.m = a.n = { $type: Point_$type, x: NaN, y: NaN };
        }
        else {
            a.m = a.j._inner[0];
            a.n = a.j._inner[a.j.count - 1];
        }
    };
    SparkFramePreparer.prototype.a = function (a, b, c) {
        var d = Math.min(a * b, c - 1);
        var e = Math.min(d + b - 1, c - 1);
        var f = true;
        var g = 0;
        var h = 0;
        for (var i = d; i <= e; ++i) {
            var j = this.b.t.item(i);
            if (f) {
                f = false;
                g = j;
                h = j;
            }
            else {
                g = Math.min(g, j);
                h = Math.max(h, j);
            }
        }
        var k = [0, 0, 0];
        k[0] = (0.5 * (d + e));
        k[1] = g;
        k[2] = h;
        return k;
    };
    SparkFramePreparer.prototype.f = function (a, b, c, d, e) {
        var f = c.left;
        var g = c.top;
        var h = c.width;
        var i = c.height;
        if (this.b.q.aq == 1 || this.b.q.aq == 0) {
            b--;
        }
        if (b < 0) {
            b = 0;
        }
        var j = b > 0 ? a[0] / b : b == 0 ? 0.5 : NaN;
        a[0] = f + j * h;
        if (this.b.q.aq == 3) {
            if (a[1] > 0) {
                a[1] = g;
                a[2] = g;
            }
            else if (a[1] < 0) {
                a[1] = g + i;
                a[2] = g + i;
            }
            else {
                a[1] = g + (1 - ((a[1] - d) / (e - d))) * i;
                a[2] = g + (1 - ((a[2] - d) / (e - d))) * i;
            }
        }
        else {
            a[1] = g + (1 - ((a[1] - d) / (e - d))) * i;
            a[2] = g + (1 - ((a[2] - d) / (e - d))) * i;
        }
    };
    SparkFramePreparer.$t = markType(SparkFramePreparer, 'SparkFramePreparer');
    return SparkFramePreparer;
}(Base));
export { SparkFramePreparer };
/**
 * @hidden
 */
var SparklineConnector = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(SparklineConnector, _super);
    function SparklineConnector(a, b) {
        var _this = _super.call(this) || this;
        _this.d = null;
        _this.b = null;
        _this.e = null;
        _this.a = null;
        _this.c = null;
        _this.e = b;
        if (a == null) {
            return _this;
        }
        _this.d = typeCast(XamSparkline.$, a);
        _this.a = _this.d.ak;
        _this.c = _this.d.at;
        b.ap(_this.d);
        var c = new ServiceProvider_Spark();
        c.addService("ConfigurationMessages", new MessageChannel_Spark());
        c.addService("RenderingMessages", new MessageChannel_Spark());
        c.addService("InteractionMessages", new MessageChannel_Spark());
        c.addService("Model", _this.d);
        c.addService("View", _this.e);
        c.addService("HorizontalAxis", _this.a);
        c.addService("VerticalAxis", _this.c);
        _this.d.ao = c;
        _this.e.k = c;
        _this.a.h = c;
        _this.c.h = c;
        _this.b = new SparklineController(c);
        c.addService("Controller", _this.b);
        return _this;
    }
    SparklineConnector.$t = markType(SparklineConnector, 'SparklineConnector');
    return SparklineConnector;
}(Base));
export { SparklineConnector };
/**
 * @hidden
 */
var SparklineController = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(SparklineController, _super);
    function SparklineController(a) {
        var _this = _super.call(this) || this;
        _this.k = null;
        _this.m = null;
        _this.l = null;
        _this.p = null;
        _this.r = null;
        _this.t = null;
        _this.s = null;
        _this.o = new SparkFramePreparer();
        _this.n = new SparkFrame();
        _this.a3 = Rect.empty;
        _this.aa = null;
        _this.k = a.getService("ConfigurationMessages");
        _this.m = a.getService("RenderingMessages");
        _this.l = a.getService("InteractionMessages");
        _this.aa = function (b, c) { return _this.ah(c.action, c.position, c.count, c.propertyName); };
        _this.q = a.getService("Model");
        _this.r = a.getService("View");
        _this.k.attachTarget(runOn(_this, _this.ag));
        _this.l.attachTarget(runOn(_this, _this.aj));
        return _this;
    }
    Object.defineProperty(SparklineController.prototype, "q", {
        get: function () {
            return this.p;
        },
        set: function (a) {
            var b = this.p != a;
            if (b) {
                this.p = a;
                this.an(runOn(this, this.aw));
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "x", {
        get: function () {
            return this.q != null ? this.q.itemsSource : null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "u", {
        get: function () {
            return this.c(SparklineController.a2);
        },
        set: function (a) {
            this.h(SparklineController.a2, a);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "ad", {
        get: function () {
            return this.q != null ? this.q.c9 : null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "ac", {
        get: function () {
            return this.q != null ? this.q.ce : null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "ab", {
        get: function () {
            return this.q != null ? this.q.toolTip : null;
        },
        enumerable: false,
        configurable: true
    });
    SparklineController.prototype.y = function (a) {
        var b = this.t.count;
        if (this.q.aq == 1 || this.q.aq == 0) {
            b--;
        }
        if (b < 0) {
            b = 0;
        }
        var c = b > 0 ? a / b : b == 0 ? 0.5 : NaN;
        c = this.a3.left + (c) * this.a3.width;
        return c;
    };
    SparklineController.prototype.z = function (a) {
        var b = ((a - this.q.a4) / (this.q.a3 - this.q.a4));
        b = (1 - b);
        b = this.a3.top + (b) * this.a3.height;
        return b;
    };
    SparklineController.prototype.w = function () {
        return !this.a3.isEmpty && this.a3.width > 0 && this.a3.height > 0 && this.q != null && this.q.a4 != this.q.a3;
    };
    SparklineController.prototype.v = function (a) {
        if (a.oldValue != a.newValue) {
            return true;
        }
        return false;
    };
    SparklineController.prototype.av = function (a, b) {
        var _this = this;
        if (this.aa == null) {
            this.aa = function (c, d) { return _this.ah(d.action, d.position, d.count, d.propertyName); };
        }
        var c = typeCast(FastItemsSource.$, a);
        if (c != null) {
            c.event = delegateRemove(c.event, this.aa);
        }
        var d = typeCast(FastItemsSource.$, b);
        if (d != null) {
            d.event = delegateCombine(d.event, this.aa);
        }
    };
    SparklineController.prototype.ay = function () {
        if (this.q != null) {
            if (this.t == null) {
                this.q.a4 = this.q.a3 = NaN;
            }
            else {
                if (isNaN_(this.q.bh)) {
                    this.q.a4 = this.t.minimum;
                }
                else {
                    this.q.a4 = this.q.bh;
                }
                if (isNaN_(this.q.bg)) {
                    this.q.a3 = this.t.maximum;
                }
                else {
                    this.q.a3 = this.q.bg;
                }
                if (this.q.a4 == this.q.a3) {
                    if (!isNaN_(this.q.bg) && isNaN_(this.q.bh)) {
                        this.q.a4 = this.q.a3 - 1;
                    }
                    else if (isNaN_(this.q.bg) && !isNaN_(this.q.bh)) {
                        this.q.a3 = this.q.a4 + 1;
                    }
                    else {
                        if (Math.floor(this.q.a4) < this.q.a4) {
                            this.q.a4 = Math.floor(this.q.a4);
                        }
                        else {
                            this.q.a4 = Math.floor(this.q.a4) - 1;
                        }
                        if (Math.ceil(this.q.a3) > this.q.a3) {
                            this.q.a3 = Math.ceil(this.q.a3);
                        }
                        else {
                            this.q.a3 = Math.ceil(this.q.a3) + 1;
                        }
                    }
                }
            }
        }
    };
    SparklineController.prototype.a0 = function () {
        if (this.u != null) {
            this.u.deregisterColumn(this.t);
            this.t = this.u.registerColumn(this.ad, null, false);
        }
        else {
            this.t = null;
        }
    };
    SparklineController.prototype.ax = function () {
        if (this.u != null) {
            this.u.deregisterColumn(this.s);
            this.s = this.u.registerColumnObject(this.ac, null, false);
            this.q.av = this.s;
        }
        else {
            this.q.av = this.s = null;
        }
    };
    SparklineController.prototype.au = function () {
        var a = new AxisRenderMessage_Spark();
        this.m.sendMessage(a);
    };
    SparklineController.prototype.an = function (a) {
        a();
    };
    SparklineController.prototype.aw = function () {
        this.u = this.getFastItemsSource(this.x);
        this.a0();
        this.ax();
        this.ay();
        this.au();
    };
    SparklineController.prototype.ah = function (a, b, c, d) {
        this.a0();
        this.ax();
        this.ay();
        this.au();
        this.an(runOn(this, this.ao));
    };
    SparklineController.prototype.az = function () {
        var a = new ToooltipTemplateMessage_Spark();
        a.template = this.ab;
        this.m.sendMessage(a);
    };
    SparklineController.prototype.ag = function (a) {
        if (typeCast(PropertyChangedMessage_Spark.$, a) !== null) {
            this.am(a);
        }
        else if (typeCast(ContainerSizeChangedMessage_Spark.$, a) !== null) {
            this.m.sendMessage(a);
        }
        else if (typeCast(DataChangedMessage_Spark.$, a) !== null) {
            this.ai(a);
        }
    };
    SparklineController.prototype.ai = function (a) {
        var b = this.u;
        if (b == null) {
            return;
        }
        switch (a.b) {
            case 2:
                b.handleCollectionChanged(new NotifyCollectionChangedEventArgs(2, 2, a.d, a.e, a.c));
                break;
            case 0:
                b.handleCollectionChanged(new NotifyCollectionChangedEventArgs(1, 0, a.d, a.c));
                break;
            case 1:
                b.handleCollectionChanged(new NotifyCollectionChangedEventArgs(1, 1, a.e, a.c));
                break;
            case 4:
                b.handleCollectionChanged(new NotifyCollectionChangedEventArgs(0, 4));
                break;
        }
        this.an(runOn(this, this.aw));
    };
    SparklineController.prototype.aj = function (a) {
        var b = a;
        if (typeCast(ViewportChangedMessage_Spark.$, b) !== null) {
            this.a1(b);
        }
        else if (typeCast(MouseLeaveMessage_Spark.$, b) !== null) {
            this.ak(b);
        }
        else if (typeCast(MouseMoveMessage_Spark.$, b) !== null) {
            this.al(b);
        }
        else if (typeCast(ContainerSizeChangedMessage_Spark.$, b) !== null) {
            this.m.sendMessage(a);
        }
    };
    SparklineController.prototype.am = function (a) {
        switch (a.propertyName) {
            case XamSparkline.$$p[15]:
                this.an(runOn(this, this.aw));
                break;
            case XamSparkline.$$p[43]:
                this.an(runOn(this, this.aw));
                break;
            case XamSparkline.$$p[16]:
                this.an(runOn(this, this.aw));
                break;
            case "ToolTip":
                this.az();
                break;
            case XamSparkline.$$p[28]:
            case XamSparkline.$$p[27]:
                this.ay();
                this.au();
                break;
            case XamSparkline.$$p[11]:
            case XamSparkline.$$p[45]:
                this.au();
                break;
            case XamSparkline.$$p[0]:
            case XamSparkline.$$p[29]:
            case XamSparkline.$$p[24]:
            case XamSparkline.$$p[3]:
            case XamSparkline.$$p[17]:
            case XamSparkline.$$p[7]:
            case XamSparkline.$$p[21]:
            case XamSparkline.$$p[30]:
            case XamSparkline.$$p[38]:
            case XamSparkline.$$p[33]:
                var b = new BrushChangedMessage_Spark();
                b.c = typeCast(Brush.$, a.newValue);
                b.b = a.propertyName;
                this.m.sendMessage(b);
                break;
            case XamSparkline.$$p[26]:
            case XamSparkline.$$p[5]:
            case XamSparkline.$$p[19]:
            case XamSparkline.$$p[9]:
            case XamSparkline.$$p[23]:
            case XamSparkline.$$p[32]:
            case XamSparkline.$$p[36]:
            case XamSparkline.$$p[37]:
                var c = new VisibilityMessage_Spark();
                c.c = EnumUtil.getEnumValue(Visibility_$type, a.newValue);
                c.b = a.propertyName;
                this.m.sendMessage(c);
                this.r.al(true);
                break;
            case XamSparkline.$$p[25]:
            case XamSparkline.$$p[4]:
            case XamSparkline.$$p[18]:
            case XamSparkline.$$p[8]:
            case XamSparkline.$$p[22]:
            case XamSparkline.$$p[31]:
                this.r.al(true);
                break;
            case XamSparkline.$$p[20]:
            case XamSparkline.$$p[40]:
                var d = new NumberChangedMessage_Spark();
                d.b = a.newValue;
                d.c = a.propertyName;
                this.m.sendMessage(d);
                break;
            case XamSparkline.$$p[10]:
            case XamSparkline.$$p[44]:
            case XamSparkline.$$p[12]:
            case XamSparkline.$$p[46]:
                this.at();
                break;
            case "Container":
                var e = new ContainerMessage_Spark();
                e.b = a.newValue;
                this.m.sendMessage(e);
                break;
            case "ActualPixelScalingRatio":
                {
                    var f = new PixelRatioMessage_Spark();
                    f.b = a.newValue;
                    this.m.sendMessage(f);
                }
                break;
            case XamSparkline.$$p[13]:
            case XamSparkline.$$p[14]:
                if (this.q.ca != null) {
                    this.q.ai = new BindingFormatter();
                    this.q.ai.j = this.q.ca;
                    this.q.ai.d = this.q.ag;
                }
                else {
                    this.q.ai = null;
                }
                this.au();
                break;
            case XamSparkline.$$p[47]:
            case XamSparkline.$$p[48]:
                if (this.q.df != null) {
                    this.q.aj = new BindingFormatter();
                    this.q.aj.j = this.q.df;
                    this.q.aj.d = this.q.ah;
                }
                else {
                    this.q.aj = null;
                }
                this.au();
                break;
        }
        if (this.v(a)) {
            this.an(runOn(this, this.ao));
        }
    };
    SparklineController.prototype.at = function () {
        var a = new ClearMessage_Spark();
        a.c = true;
        this.m.sendMessage(a);
    };
    SparklineController.prototype.a1 = function (a) {
        this.a3 = new Rect(0, a.newLeft, a.newTop, a.newWidth, a.newHeight);
        this.an(runOn(this, this.ao));
    };
    SparklineController.prototype.al = function (a) {
        var b = new ClearMessage_Spark();
        b.b = 4;
        this.m.sendMessage(b);
        var c = new TooltipMessage_Spark();
        c.b = 4;
        c.xOffset = a.position.x + 10;
        c.yOffset = a.position.y + 10;
        if (this.t != null && this.t.count > 0) {
            var d = new SparklineToolTipContext();
            d.high = this.t.maximum;
            d.low = this.t.minimum;
            d.first = this.t.item(0);
            d.last = this.t.item(this.t.count - 1);
            c.context = d;
        }
        this.m.sendMessage(c);
    };
    SparklineController.prototype.ak = function (a) {
        var b = new ClearMessage_Spark();
        b.b = 4;
        this.m.sendMessage(b);
    };
    SparklineController.prototype.af = function (a) {
        var b = new ClearMessage_Spark();
        b.b = a;
        this.m.sendMessage(b);
    };
    SparklineController.prototype.ae = function () {
        this.af(1);
        this.af(2);
        this.af(16);
        this.af(8);
    };
    SparklineController.prototype.ao = function () {
        this.ae();
        if (!this.w()) {
            return;
        }
        this.o.b = this;
        this.o.e(this.n);
        switch (this.q.aq) {
            case 2:
                this.ap();
                break;
            case 3:
                this.as();
                break;
            case 0:
            case 1:
                this.ar();
                break;
        }
        var a = new NormalRangeMessage_Spark();
        a.k = this.a3.left;
        a.l = Math.max(this.a3.top, Math.min(this.a3.bottom, this.z(this.q.bj)));
        a.j = this.a3.width;
        var b = Math.max(this.a3.top, Math.min(this.a3.bottom, this.z(this.q.bk)));
        a.i = Math.abs(b - a.l);
        a.l = Math.min(a.l, b);
        a.d = this.q.aw;
        this.m.sendMessage(a);
        var c = new TrendLineMessage_Spark();
        c.points = this.n.l.toArray();
        this.m.sendMessage(c);
    };
    SparklineController.prototype.ap = function () {
        var a = new ColumnMessage_Spark();
        a.d = this.n.j;
        a.g = this.n.k;
        a.f = this.n.i;
        a.e = this.n.h;
        a.k = this.n.m;
        a.l = this.n.n;
        a.j = this.n.g.count;
        a.h = this.o.c;
        a.i = this.o.d;
        a.c = this.q.aq;
        this.m.sendMessage(a);
        this.aq();
    };
    SparklineController.prototype.as = function () {
        var a = new WinLossColumnMessage_Spark();
        a.d = this.n.j;
        a.g = this.n.k;
        a.f = this.n.i;
        a.e = this.n.h;
        a.k = this.n.m;
        a.l = this.n.n;
        a.j = this.n.g.count;
        a.h = this.o.c;
        a.i = this.o.d;
        a.c = this.q.aq;
        this.m.sendMessage(a);
    };
    SparklineController.prototype.ar = function () {
        var e_5, _a, e_6, _b, e_7, _c;
        if (this.n.g.count == 0) {
            return;
        }
        var a = new List$1(List$1.$.specialize(Array_$type), 0);
        var b = new List$1(Array_$type, 0);
        var c = true;
        try {
            for (var _d = __values(fromEnum(this.n.g)), _e = _d.next(); !_e.done; _e = _d.next()) {
                var d = _e.value;
                if (isNaN_(d[1]) || isInfinity(d[1])) {
                    if (!c) {
                        a.add(b);
                    }
                    c = true;
                    continue;
                }
                if (c) {
                    b = new List$1(Array_$type, 0);
                    c = false;
                }
                b.add(d);
            }
        }
        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;
            }
        }
        if (!c) {
            a.add(b);
        }
        var e = new PolygonMessage_Spark();
        e.points = new List$1(Array_$type, 0);
        if (this.q.as == 0) {
            var f = new List$1(Array_$type, 0);
            try {
                for (var _f = __values(fromEnum(a)), _g = _f.next(); !_g.done; _g = _f.next()) {
                    var g = _g.value;
                    f.o(g);
                }
            }
            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;
                }
            }
            var h = this.j(f);
            e.points.add(h);
        }
        else {
            try {
                for (var _h = __values(fromEnum(a)), _j = _h.next(); !_j.done; _j = _h.next()) {
                    var i = _j.value;
                    var j = this.j(i);
                    e.points.add(j);
                }
            }
            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.m.sendMessage(e);
        this.aq();
    };
    SparklineController.prototype.j = function (a) {
        var e_8, _a, e_9, _b;
        var b = this.o.c;
        var c = new List$1(Point_$type, 0);
        var d;
        var e = this.q.aq == 1;
        try {
            for (var _c = __values(fromEnum(a)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var f = _d.value;
                d = f[1];
                if (e) {
                    if (f[2] <= b) {
                        d = f[2];
                    }
                }
                c.add({ $type: Point_$type, x: f[0], y: d });
            }
        }
        catch (e_8_1) {
            e_8 = { error: e_8_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_8)
                    throw e_8.error;
            }
        }
        if (this.q.aq == 0) {
            var g = new List$1(Point_$type, 0);
            try {
                for (var _e = __values(fromEnum(a)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var h = _f.value;
                    g.add({ $type: Point_$type, x: h[0], y: h[2] });
                }
            }
            catch (e_9_1) {
                e_9 = { error: e_9_1 };
            }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return))
                        _b.call(_e);
                }
                finally {
                    if (e_9)
                        throw e_9.error;
                }
            }
            g.w();
            c.o(g);
        }
        if (this.q.aq == 1 && c.count > 0) {
            var i = c._inner[0];
            var j = c._inner[c.count - 1];
            c.add({ $type: Point_$type, x: j.x, y: this.o.c });
            c.add({ $type: Point_$type, x: i.x, y: this.o.c });
        }
        return c.toArray();
    };
    SparklineController.prototype.aq = function () {
        var a = new MarkerMessage_Spark();
        a.e = this.n.j;
        a.f = this.n.k;
        a.d = this.n.i;
        a.c = this.n.h;
        a.m = this.n.m;
        a.n = this.n.n;
        a.k = this.q.bd;
        a.g = this.q.a6;
        a.i = this.q.a8;
        a.h = this.q.a7;
        a.j = this.q.bc;
        a.l = this.q.bi;
        this.m.sendMessage(a);
    };
    SparklineController.prototype.getFastItemsSource = function (a) {
        var b = null;
        if (this.x != null) {
            var c = null;
            b = new FastItemsSource();
            b.e = this.x;
            c = new FastItemsSourceReference(b);
            c.b++;
            b = c.a;
        }
        return b;
    };
    SparklineController.prototype.releaseFastItemsSource = function (a) {
        if (a != null) {
            var b = null;
            --b.b;
        }
        return null;
    };
    SparklineController.$t = markType(SparklineController, 'SparklineController', DependencyObject.$, [IFastItemsSourceProvider_$type]);
    SparklineController.a2 = DependencyProperty.i("FastItemsSource", IFastItemsSource_$type, SparklineController.$, new PropertyMetadata(1, function (a, b) { return (typeCast(SparklineController.$, a)).av(b.oldValue, b.newValue); }));
    return SparklineController;
}(DependencyObject));
export { SparklineController };
/**
 * @hidden
 */
var XamSparkline = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(XamSparkline, _super);
    function XamSparkline() {
        var _this = _super.call(this) || this;
        _this.ap = null;
        _this.ai = null;
        _this.aj = null;
        _this.an = null;
        _this.al = new MessageChannel_Spark();
        _this.a0 = NaN;
        _this.az = NaN;
        _this.av = null;
        _this.ak = null;
        _this.at = null;
        _this.a2 = NaN;
        _this.a1 = 1;
        _this.ab = XamSparkline.$;
        _this.at = new VerticalAxisView(_this);
        _this.ak = new HorizontalAxisView(_this);
        _this.ap = new SparklineConnector(_this, new XamSparklineView());
        return _this;
    }
    Object.defineProperty(XamSparkline.prototype, "toolTip", {
        get: function () {
            return this.c(XamSparkline.ev);
        },
        set: function (a) {
            this.h(XamSparkline.ev, a);
            this.fs = a == null || a.toString().length == 0 ? 1 : 0;
        },
        enumerable: false,
        configurable: true
    });
    XamSparkline.prototype.ax = function () {
        return this.bp != null;
    };
    XamSparkline.prototype.c1 = function (a) {
        return this.bp(a);
    };
    Object.defineProperty(XamSparkline.prototype, "ao", {
        get: function () {
            return this.an;
        },
        set: function (a) {
            var b = this.an;
            this.an = a;
            this.ds(b, this.an);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamSparkline.prototype, "am", {
        get: function () {
            return this.al;
        },
        set: function (a) {
            this.al = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamSparkline.prototype, "a4", {
        get: function () {
            return this.a0;
        },
        set: function (a) {
            this.a0 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamSparkline.prototype, "a3", {
        get: function () {
            return this.az;
        },
        set: function (a) {
            this.az = a;
        },
        enumerable: false,
        configurable: true
    });
    XamSparkline.prototype.ds = function (a, b) {
        if (a != null) {
            this.am.detachFromNext();
        }
        if (b != null) {
            this.am.connectTo(b.getService("ConfigurationMessages"));
        }
    };
    XamSparkline.prototype.onDetachedFromUI = function () {
        this.ap.e.au();
    };
    XamSparkline.prototype.onAttachedToUI = function () {
        this.ap.e.as();
    };
    XamSparkline.prototype.dr = function (a, b, c) {
        if (a == "PixelScalingRatio") {
            if (!isNaN_(DeviceUtils.a(this.bl))) {
                this.a5 = DeviceUtils.a(this.bl);
            }
        }
        this.am.sendMessage(((function () {
            var $ret = new PropertyChangedMessage_Spark();
            $ret.propertyName = a;
            $ret.oldValue = b;
            $ret.newValue = c;
            return $ret;
        })()));
    };
    XamSparkline.prototype.destroy = function () {
        this.am.sendMessage(((function () {
            var $ret = new PropertyChangedMessage_Spark();
            $ret.propertyName = "Container";
            $ret.newValue = null;
            return $ret;
        })()));
    };
    XamSparkline.prototype.provideContainer = function (a) {
        this.am.sendMessage(((function () {
            var $ret = new PropertyChangedMessage_Spark();
            $ret.propertyName = "Container";
            $ret.newValue = a;
            return $ret;
        })()));
    };
    XamSparkline.prototype.notifyResized = function () {
        this.am.sendMessage(new ContainerSizeChangedMessage_Spark());
    };
    XamSparkline.prototype.dn = function (source_, a, b, c) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (source_ != this.itemsSource) {
            return;
        }
        this.am.sendMessage(((function () {
            var $ret = new DataChangedMessage_Spark();
            $ret.b = 2;
            $ret.e = b;
            $ret.d = c;
            $ret.c = a;
            return $ret;
        })()));
    };
    XamSparkline.prototype.dj = function (source_) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (source_ != this.itemsSource) {
            return;
        }
        this.am.sendMessage(((function () {
            var $ret = new DataChangedMessage_Spark();
            $ret.b = 4;
            return $ret;
        })()));
    };
    XamSparkline.prototype.dk = function (source_, a, b) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (source_ != this.itemsSource) {
            return;
        }
        this.am.sendMessage(((function () {
            var $ret = new DataChangedMessage_Spark();
            $ret.b = 0;
            $ret.d = b;
            $ret.c = a;
            return $ret;
        })()));
    };
    XamSparkline.prototype.dl = function (source_, a, b) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (source_ != this.itemsSource) {
            return;
        }
        this.am.sendMessage(((function () {
            var $ret = new DataChangedMessage_Spark();
            $ret.b = 1;
            $ret.e = b;
            $ret.c = a;
            return $ret;
        })()));
    };
    XamSparkline.prototype.au = function () {
        var a = new SparklineVisualData();
        a.name = "SparklineVisualData";
        a.horizontalAxis = this.ak.i();
        a.verticalAxis = this.at.i();
        this.ap.e.an(a);
        return a;
    };
    XamSparkline.prototype.by = function () {
        var a = this.au();
        a.scaleByViewport();
        return a.serialize();
    };
    Object.defineProperty(XamSparkline.prototype, "bl", {
        get: function () {
            return this.a2;
        },
        set: function (a) {
            var b = this.a2;
            this.a2 = a;
            this.dr("PixelScalingRatio", b, this.a2);
            if (this.a2 != b) {
                this.dr("PixelScalingRatio", b, this.a2);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamSparkline.prototype, "a5", {
        get: function () {
            return this.a1;
        },
        set: function (a) {
            var b = this.a1;
            this.a1 = a;
            if (this.a1 != b) {
                this.dr("ActualPixelScalingRatio", b, this.a1);
            }
        },
        enumerable: false,
        configurable: true
    });
    XamSparkline.$t = markType(XamSparkline, 'XamSparkline', Control.$);
    XamSparkline.bf = -1;
    XamSparkline.bb = -1;
    XamSparkline.ev = DependencyProperty.i("ToolTip", Base.$, XamSparkline.$, new PropertyMetadata(2, null, function (a, b) { return (typeCast(XamSparkline.$, a)).dr("ToolTip", b.oldValue, b.newValue); }));
    XamSparkline.bo = -1;
    XamSparkline.$$p = markDep(DependencyProperty, PropertyMetadata, XamSparkline, 'dr', ['Brush:e8:du', [Brush.$, null], 'DisplayNormalRangeInFront:aw:dv', [0, true], 'DisplayType:aq:dw', [SparklineDisplayType_$type, enumGetBox(SparklineDisplayType_$type, 0)], 'FirstMarkerBrush:e9:dx', [Brush.$, null], 'FirstMarkerSize:a6:dy', [1, XamSparkline.bf], 'FirstMarkerVisibility:fk:dz', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'FormatLabel:bp:d0', [Delegate_$type], 'HighMarkerBrush:fa:d1', [Brush.$, null], 'HighMarkerSize:a7:d2', [1, XamSparkline.bf], 'HighMarkerVisibility:fl:d3', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'HorizontalAxisBrush:fb:d4', [Brush.$, null], 'HorizontalAxisLabel:br:d5', [4, "{0}"], 'HorizontalAxisVisibility:fm:d6', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'HorizontalLabelFormat:ca:d7', [2, null], 'HorizontalLabelFormatSpecifiers:ag:d8', [Array_$type, null], 'ItemsSource::d9', [IEnumerable_$type, null], 'LabelMemberPath:ce:ea', [2, null], 'LastMarkerBrush:fc:eb', [Brush.$, null], 'LastMarkerSize:a8:ec', [1, XamSparkline.bf], 'LastMarkerVisibility:fn:ed', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'LineThickness:a9:ee', [1, XamSparkline.bb], 'LowMarkerBrush:fd:ef', [Brush.$, null], 'LowMarkerSize:bc:eg', [1, XamSparkline.bf], 'LowMarkerVisibility:fo:eh', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'MarkerBrush:fe:ei', [Brush.$, null], 'MarkerSize:bd:ej', [1, XamSparkline.bf], 'MarkerVisibility:fp:ek', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'Maximum:bg:el', [1, NaN], 'Minimum:bh:em', [1, NaN], 'NegativeBrush:ff:en', [Brush.$, null], 'NegativeMarkerBrush:fg:eo', [Brush.$, null], 'NegativeMarkerSize:bi:ep', [1, XamSparkline.bf], 'NegativeMarkerVisibility:fq:eq', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'NormalRangeFill:fh:er', [Brush.$, null], 'NormalRangeMaximum:bj:es', [1, 0], 'NormalRangeMinimum:bk:et', [1, 0], 'NormalRangeVisibility:fr:eu', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'ToolTipVisibility:fs:ew', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'TrendLineBrush:fi:ex', [Brush.$, null], 'TrendLinePeriod:bq:ey', [1, 7], 'TrendLineThickness:bm:ez', [1, XamSparkline.bo], 'TrendLineType:ar:e0', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'UnknownValuePlotting:as:e1', [UnknownValuePlotting_$type, enumGetBox(UnknownValuePlotting_$type, 1)], 'ValueMemberPath:c9:e2', [2, null], 'VerticalAxisBrush:fj:e3', [Brush.$, null], 'VerticalAxisLabel:bt:e4', [4, "{0:n}"], 'VerticalAxisVisibility:ft:e5', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'VerticalLabelFormat:df:e6', [2, null], 'VerticalLabelFormatSpecifiers:ah:e7', [Array_$type, null]]);
    return XamSparkline;
}(Control));
export { XamSparkline };
