/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { DependencyProperty } from "igniteui-angular-core";
import { Base, runOn, delegateCombine, String_$type, enumGetBox, EnumUtil, typeCast, fromEnum, delegateRemove, Point_$type, Date_$type, markType, markDep } from "igniteui-angular-core";
import { Series } from "./Series";
import { CalloutPlacementPositionsCollection } from "./CalloutPlacementPositionsCollection";
import { AutoCalloutVisibilityMode_$type } from "./AutoCalloutVisibilityMode";
import { Brush } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { CalloutCollisionMode_$type } from "./CalloutCollisionMode";
import { FontUtil } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { CalloutLayerFrame } from "./CalloutLayerFrame";
import { HashSet$1 } from "igniteui-angular-core";
import { CalloutAnnotationWrapper } from "./CalloutAnnotationWrapper";
import { List$1 } from "igniteui-angular-core";
import { LinkedList$1 } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { LinkedListNode$1 } from "igniteui-angular-core";
import { LabelCollisionManager } from "igniteui-angular-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { CalloutAnnotation } from "./CalloutAnnotation";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { CalloutLabelUpdatingEventArgs } from "./CalloutLabelUpdatingEventArgs";
import { CalloutSeriesSelectingEventArgs } from "./CalloutSeriesSelectingEventArgs";
import { CalloutStyleUpdatingEventArgs } from "./CalloutStyleUpdatingEventArgs";
import { DeviceUtils } from "igniteui-angular-core";
import { CalloutRenderStyleUpdatingEventArgs } from "./CalloutRenderStyleUpdatingEventArgs";
import { LabelCollisionInfo } from "igniteui-angular-core";
import { QuadTreeBoundingBox } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { ViewportUtils } from "./ViewportUtils";
import { Size } from "igniteui-angular-core";
import { CalloutContentUpdatingEventArgs } from "./CalloutContentUpdatingEventArgs";
import { CalloutKey } from "./CalloutKey";
import { DataContext } from "igniteui-angular-core";
import { HashPool$2 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
import { stringIsNullOrEmpty } from "igniteui-angular-core";
import { FastItemObjectColumn } from "igniteui-angular-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-angular-core";
import { TextBlock } from "igniteui-angular-core";
import { Color } from "igniteui-angular-core";
import { Line } from "igniteui-angular-core";
import { CalloutViewHelper } from "./CalloutViewHelper";
import { Rectangle } from "igniteui-angular-core";
import { TranslateTransform } from "igniteui-angular-core";
/**
 * @hidden
 */
var CalloutLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutLayer, _super);
    function CalloutLayer() {
        var _this = _super.call(this) || this;
        _this.calloutStyleUpdating = null;
        _this.calloutRenderStyleUpdating = null;
        _this.tv = null;
        _this.tw = null;
        _this.tx = null;
        _this.tu = null;
        _this.tt = null;
        _this.un = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        _this.uq = new List$1(CalloutAnnotationWrapper.$, 0);
        _this.ur = new List$1(CalloutAnnotationWrapper.$, 0);
        _this.tl = null;
        _this.tb = null;
        _this.tr = null;
        _this.uo = new LinkedList$1(CalloutAnnotationWrapper.$);
        _this.ul = new Dictionary$2(CalloutAnnotationWrapper.$, LinkedListNode$1.$.specialize(CalloutAnnotationWrapper.$), 0);
        _this.t3 = null;
        _this.xx = new Rect(0, 0, 0, 1, 1);
        _this.ua = false;
        _this.u2 = 0;
        _this.xw = Rect.empty;
        _this.t8 = false;
        _this.t9 = false;
        _this.calloutContentUpdating = null;
        _this.calloutLabelUpdating = null;
        _this.calloutSeriesSelecting = null;
        _this.up = new List$1(SeriesPointOfInterest.$, 0);
        _this.uc = false;
        _this.ud = false;
        _this.ut = 0;
        _this.ub = false;
        _this.t7 = true;
        _this.td = 1;
        FastItemObjectColumn.m();
        _this.tb = null;
        _this.tl = new CalloutPlacementPositionsCollection();
        var a = _this.tl;
        a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.wh));
        _this.qy = true;
        var b = new CalloutLayerFrame();
        var c = new CalloutLayerFrame();
        var d = new CalloutLayerFrame();
        var e = _this.hr / 1000;
        _this.qq = b;
        _this.qp = c;
        _this.qr = d;
        _this.ab = CalloutLayer.$;
        return _this;
    }
    CalloutLayer.prototype.get_c9 = function () {
        return true;
    };
    CalloutLayer.prototype.wh = function (a, b) {
        this.wq();
    };
    CalloutLayer.prototype.wq = function () {
        this.tb = this.tc(this.tm);
        this.wn();
    };
    CalloutLayer.prototype.wi = function (a, b) {
        this.ur.clear();
        this.mn(false);
    };
    CalloutLayer.prototype.k5 = function (a, b, c, d) {
        _super.prototype.k5.call(this, a, b, c, d);
        var e = this.um();
        switch (a) {
            case 3:
                this.wv(b, e);
                break;
            case 1:
                for (var f = b; f < b + c; f++) {
                    var g = new CalloutAnnotation();
                    var h = new CalloutAnnotationWrapper();
                    h.b = g;
                    h.b.series = this.tq;
                    this.ur.insert(f, h);
                    this.wv(f, e);
                }
                break;
            case 0:
                this.ur.v(b, c);
                break;
            case 2:
                for (var i = b; i < b + c; i++) {
                    this.wv(i, e);
                }
                break;
            case 4:
                this.ur.clear();
                for (var j = 0; j < this.cl.count; j++) {
                    var k = new CalloutAnnotation();
                    var l = new CalloutAnnotationWrapper();
                    l.b = k;
                    l.b.series = this.tq;
                    this.ur.add(l);
                    this.wv(j, e);
                }
                break;
        }
        this.mn(true);
    };
    CalloutLayer.prototype.er = function (a) {
        return false;
    };
    CalloutLayer.prototype.um = function () {
        var a = new Dictionary$2(String_$type, Series.$, 0);
        if (this.ce != null) {
            for (var b = 0; b < this.ce.series.count; b++) {
                var c = this.ce.series._inner[b];
                if (c.name != null && !a.containsKey(c.name)) {
                    a.addItem(c.name, c);
                }
            }
        }
        return a;
    };
    CalloutLayer.prototype.wv = function (a, b) {
        var _this = this;
        if (this.t2 == null || this.t0 == null) {
            return;
        }
        var c = a;
        if (this.t1 != null) {
            c = this.t1.item(a);
        }
        var d = this.t2.item(a);
        var e = this.t0.item(a);
        var f = this.ur._inner[a];
        if (this.tz != null) {
            if (f.b.ab != this.tz.item(a)) {
                f.b.key = this.tz.item(a);
            }
        }
        if (this.ul.containsKey(f)) {
            f.b = this.ul.item(f).c.b;
        }
        f.b.xValue = c;
        f.b.yValue = d;
        if (this.calloutLabelUpdating != null) {
            var g = ((function () {
                var $ret = new CalloutLabelUpdatingEventArgs();
                $ret.d = c;
                $ret.e = d;
                $ret.item = _this.cl.item(a);
                return $ret;
            })());
            this.calloutLabelUpdating(this, g);
            if (g.c != null && !Base.equalsStatic(g.c, f.b.ao)) {
                var h = g.c;
                f.b.text = h != null ? h.toString() : "";
            }
        }
        else {
            f.b.text = e != null ? e.toString() : "";
        }
        if (this.ty != null) {
            f.b.content = this.ty.item(a);
        }
        else {
            f.b.content = this.cl.item(a);
        }
        if (this.calloutSeriesSelecting != null) {
            var i = ((function () {
                var $ret = new CalloutSeriesSelectingEventArgs();
                $ret.c = c;
                $ret.d = d;
                $ret.item = _this.cl.item(a);
                return $ret;
            })());
            this.calloutSeriesSelecting(this, i);
            if (i.a != null) {
                f.b.series = i.a;
            }
            else if (i.e != null) {
                if (b.containsKey(i.e)) {
                    f.b.series = b.item(i.e);
                }
            }
        }
        this.ww(f);
    };
    CalloutLayer.prototype.ww = function (a) {
        var b = new Thickness(0, DeviceUtils.g(3));
        if (isNaN_(this.xz.left) || isNaN_(this.xz.top) || isNaN_(this.xz.right) || isNaN_(this.xz.bottom)) {
            b = new Thickness(0, DeviceUtils.g(3));
        }
        else {
            b = this.xz;
        }
        var c = DeviceUtils.g(3);
        if (isNaN_(this.uu)) {
            c = DeviceUtils.g(3);
        }
        else {
            c = this.uu;
        }
        var d = this.xs != null ? this.xs : this.tk.ci(a.b.l);
        var e = this.xv != null ? this.xv : this.tk.cl();
        var f = this.xu != null ? this.xu : this.tk.ck(a.b.l);
        var g = this.xt != null ? this.xt : this.tk.cj(a.b.l);
        var h = isNaN_(this.u0) ? 0 : this.u0;
        if (this.uh && this.calloutStyleUpdating != null) {
            var i = new CalloutStyleUpdatingEventArgs();
            i.item = a.b.aa;
            i.xValue = a.b.ac;
            i.yValue = a.b.ad;
            i.series = a.b.l;
            i.background = d;
            i.textColor = e;
            i.outline = f;
            i.leaderBrush = g;
            i.strokeThickness = h;
            this.calloutStyleUpdating(this, i);
            d = i.background;
            e = i.textColor;
            f = i.outline;
            g = i.leaderBrush;
            h = i.strokeThickness;
        }
        a.b.backgroundPadding = b;
        a.b.backgroundCornerRadius = c;
        a.b.background = d;
        a.b.textColor = e;
        a.b.outline = f;
        a.b.leaderBrush = g;
        a.b.strokeThickness = h;
    };
    CalloutLayer.prototype.h1 = function (a, b) {
        var c = this.jv(b);
        if (c == CalloutLayer.$$p[21]) {
            return this.h2(a, b, this.v1);
        }
        if (c == CalloutLayer.$$p[28]) {
            return this.h2(a, b, this.wc);
        }
        if (c == CalloutLayer.$$p[29]) {
            return this.h2(a, b, this.wf);
        }
        if (c == CalloutLayer.$$p[20]) {
            return this.h2(a, b, this.vy);
        }
        if (c == CalloutLayer.$$p[15]) {
            return this.h2(a, b, this.vr);
        }
        return _super.prototype.h1.call(this, a, b);
    };
    Object.defineProperty(CalloutLayer.prototype, "t0", {
        get: function () {
            return this.tv;
        },
        set: function (a) {
            if (this.tv != a) {
                var b = this.tv;
                this.tv = a;
                this.raisePropertyChanged("LabelColumn", b, this.tv);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "t1", {
        get: function () {
            return this.tw;
        },
        set: function (a) {
            if (this.tw != a) {
                var b = this.tw;
                this.tw = a;
                this.raisePropertyChanged("XColumn", b, this.tw);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "t2", {
        get: function () {
            return this.tx;
        },
        set: function (a) {
            if (this.tx != a) {
                var b = this.tx;
                this.tx = a;
                this.raisePropertyChanged("YColumn", b, this.tx);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "tz", {
        get: function () {
            return this.tu;
        },
        set: function (a) {
            if (this.tu != a) {
                var b = this.tu;
                this.tu = a;
                this.raisePropertyChanged("KeyColumn", b, this.tu);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "ty", {
        get: function () {
            return this.tt;
        },
        set: function (a) {
            if (this.tt != a) {
                var b = this.tt;
                this.tt = a;
                this.raisePropertyChanged("ContentColumn", b, this.tt);
            }
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.wk = function (a, b) {
        if (b.propertyName == CalloutAnnotation.$$p[14] || b.propertyName == CalloutAnnotation.$$p[15]) {
            var c = a.k;
            if (!this.un.contains(c)) {
                this.un.add_1(c);
                this.uq.add(c);
                this.mn(false);
            }
        }
    };
    CalloutLayer.prototype.by = function () {
        return new CalloutLayerView(this);
    };
    CalloutLayer.prototype.l4 = function (a) {
        _super.prototype.l4.call(this, a);
        this.tk = a;
    };
    Object.defineProperty(CalloutLayer.prototype, "tm", {
        get: function () {
            return this.tl;
        },
        set: function (a) {
            var b = this.tm;
            if (a != b) {
                this.tl = a;
                this.raisePropertyChanged("AllowedPositions", b, this.tm);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "tf", {
        get: function () {
            return EnumUtil.getEnumValue(AutoCalloutVisibilityMode_$type, this.c(CalloutLayer.xb));
        },
        set: function (a) {
            this.h(CalloutLayer.xb, enumGetBox(AutoCalloutVisibilityMode_$type, a));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "te", {
        get: function () {
            return this.td;
        },
        set: function (a) {
            this.td = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xz", {
        get: function () {
            return new Thickness(1, this.uw, this.uy, this.ux, this.uv);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "ts", {
        get: function () {
            if (this.tr == null) {
                this.tr = FontUtil.toFontInfo(this.he, this.v6);
            }
            return this.tr;
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.r3 = function (a, b) {
        if (this.tq == null || this.tq == a) {
            if (!this.at.c) {
                this.mn(b);
            }
        }
    };
    CalloutLayer.prototype.r5 = function (a, b) {
        var e_1, _a;
        _super.prototype.r5.call(this, a, b);
        var c = a;
        c.q.clear();
        c.r.clear();
        c.n.clear();
        c.f.clear();
        c.i.clear();
        c.h.clear();
        c.k.clear();
        c.m.clear();
        c.l.clear();
        c.j.clear();
        c.g.clear();
        c.o.clear();
        c.p.clear();
        c.u.clear();
        c.v.clear();
        c.s.clear();
        c.t.clear();
        var d = this.us();
        var e = new List$1(CalloutAnnotationWrapper.$, 0);
        var f = true;
        if (this.ue) {
            if (this.qw(this.tq)) {
                this.ws(this.tq, c, e);
            }
            else {
                try {
                    for (var _b = __values(fromEnum(this.ce.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var g = _c.value;
                        if (this.qw(g)) {
                            if (!g.dd) {
                                if (!g.isVertical) {
                                    f = false;
                                }
                            }
                            this.ws(g, c, e);
                        }
                    }
                }
                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 (this.ue && this.te == 2) {
            var h = 0;
            var i = 0;
            var j = 1.7976931348623157E+308;
            var k = 1.7976931348623157E+308;
            var l = -1.7976931348623157E+308;
            var m = -1.7976931348623157E+308;
            if (e.count > 0) {
                if (e._inner[0].c != null) {
                    h = e._inner[0].e;
                    i = e._inner[0].f;
                }
                for (var n = 0; n < e.count; n++) {
                    var o = e._inner[n];
                    if (o.c != null) {
                        var p = o.e;
                        var q = o.f;
                        if (p != h) {
                            j = Math.min(j, Math.abs(p - h));
                        }
                        if (q != i) {
                            k = Math.min(k, Math.abs(q - i));
                        }
                        l = Math.max(o.c.l + o.c.l, l);
                        m = Math.max(o.c.k + o.c.k, m);
                    }
                }
                if (f) {
                    if (m > k) {
                        e.clear();
                    }
                }
                else {
                    if (l > j) {
                        e.clear();
                    }
                }
            }
        }
        this.wr(c, d, e);
    };
    CalloutLayer.prototype.nb = function (a, b) {
        _super.prototype.nb.call(this, a, b);
        var c = b.width - this.xx.width;
        var d = b.height - this.xx.height;
        var e = 0;
        if (Math.abs(c) > Math.abs(d)) {
            e = c;
            this.ut = c * this.p7.width;
        }
        else {
            e = d;
            this.ut = d * this.p7.height;
        }
        if (e > 0 && this.ut > 5) {
            this.ud = true;
        }
        if (e < 0 && this.ut > 5) {
            this.uc = true;
        }
    };
    CalloutLayer.prototype.na = function (a, b) {
        _super.prototype.na.call(this, a, b);
        if (!a.equals1(b)) {
            this.ub = true;
        }
    };
    Object.defineProperty(CalloutLayer.prototype, "xy", {
        get: function () {
            return this.xw;
        },
        set: function (a) {
            this.xw = a;
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.wr = function (a, b, c) {
        var e_2, _a;
        if (this.ce != null) {
            this.xx = this.ce.ta;
        }
        if (this.p7.isEmpty) {
            return;
        }
        this.xy = new Rect(0, this.p7.left, this.p7.top, this.p7.width, this.p7.height);
        if (this.t3 != null && this.vo != null && this.vo != this.t3.ap) {
            this.wm();
        }
        if (this.t3 == null) {
            var d = this.t4();
            if (d != null) {
                this.t3 = d;
                var e = this.t3;
                e.labelsMoved = delegateCombine(e.labelsMoved, runOn(this, this.wj));
            }
            else {
                var f = this.pz(this.b1);
                var g = new Array(2);
                g[0] = 0;
                g[1] = 3;
                if (this.tq != null) {
                    if (this.tq.isVertical) {
                        g = new Array(2);
                        g[0] = 2;
                        g[1] = 1;
                    }
                }
                else {
                    var h = false;
                    if (this.ce != null && this.ce.series.count > 0) {
                        h = true;
                        try {
                            for (var _b = __values(fromEnum(this.ce.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                                var i = _c.value;
                                if (!i.dd) {
                                    if (!i.isVertical) {
                                        h = false;
                                    }
                                }
                            }
                        }
                        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;
                            }
                        }
                    }
                    if (h) {
                        g = new Array(2);
                        g[0] = 2;
                        g[1] = 1;
                    }
                }
                this.t3 = new LabelCollisionManager(this.p7.right, this.p7.bottom, this.p7, this.tk.j(), this.uz, this.t5(), g, this.u6(), this.u5(), this.uf, this.tb);
                if (this.vo != null) {
                    this.t3.ap = this.vo;
                    this.t3.an = this;
                }
                var j = this.t3;
                j.labelsMoved = delegateCombine(j.labelsMoved, runOn(this, this.wj));
            }
        }
        if (this.uc) {
            this.uc = false;
            if (this.t3.al > 2) {
                this.ua = true;
            }
        }
        if (this.ud) {
            this.ud = false;
            if (this.ut > 5) {
                this.ua = true;
            }
        }
        if (this.ub) {
            this.ub = false;
            this.t3.a3(this.p7.right, this.p7.bottom, this.p7);
            this.ua = true;
        }
        var k = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        var l = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        var m = new List$1(CalloutAnnotationWrapper.$, 0);
        var n = new List$1(CalloutAnnotationWrapper.$, 0);
        var o = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        for (var p = 0; p < b.count; p++) {
            o.add_1(b._inner[p]);
        }
        for (var q = 0; q < c.count; q++) {
            o.add_1(c._inner[q]);
        }
        var r = this.uo.c;
        while (r != null) {
            var s = r.a;
            if (!o.contains(r.c)) {
                n.add(r.c);
                l.add_1(r.c);
                var t = r.c.b;
                t.propertyChanged = delegateRemove(t.propertyChanged, runOn(this, this.wk));
                this.uo.h(r);
                this.ul.removeItem(r.c);
                this.t3.a2(r.c.c);
            }
            r = s;
        }
        for (var u = 0; u < b.count; u++) {
            if (!this.ul.containsKey(b._inner[u])) {
                this.uo.f(b._inner[u]);
                var v = b._inner[u].b;
                v.propertyChanged = delegateCombine(v.propertyChanged, runOn(this, this.wk));
                this.ul.addItem(b._inner[u], this.uo.d);
                m.add(b._inner[u]);
                k.add_1(b._inner[u]);
                this.ua = true;
            }
        }
        for (var w = 0; w < c.count; w++) {
            if (!this.ul.containsKey(c._inner[w])) {
                this.uo.f(c._inner[w]);
                this.ul.addItem(c._inner[w], this.uo.d);
                var x = c._inner[w].b;
                x.propertyChanged = delegateCombine(x.propertyChanged, runOn(this, this.wk));
                m.add(c._inner[w]);
                k.add_1(c._inner[w]);
                this.ua = true;
            }
        }
        if (this.t8 == true) {
            this.t8 = false;
            this.ua = true;
        }
        if (this.uq.count > 0) {
            this.ua = true;
            this.uq.clear();
            this.un.clear();
        }
        r = this.uo.c;
        while (r != null) {
            var y = this.t6(r.c);
            if (y == null) {
                return;
            }
            if (!Base.equalsStatic(y, r.c.c.c)) {
                var z = false;
                if (r.c.c.c == null) {
                    z = true;
                }
                var aa = r.c.c;
                aa.o = y.b;
                aa.p = y.c;
                if (!isNaN_(aa.o) && !isNaN_(aa.p)) {
                    aa.n = y.e;
                    aa.m = y.d;
                    if (aa.b == null) {
                        this.t3.t(aa, false);
                    }
                    if (z) {
                        this.t3.aq(aa);
                    }
                    else {
                        this.t3.az(aa);
                    }
                }
            }
            r = r.a;
        }
        var ab = this.t3.am();
        var ac = this.t3.u();
        if (ac) {
            if (this.t3.q()) {
                this.ua = true;
            }
        }
        if (this.ua && (ab != 0 || ac)) {
            this.ua = false;
            this.u2 = 0x7FFFFFFF;
            if (this.vo != null) {
                var ad = true;
                for (var ae = 0; ae < this.ce.series.count; ae++) {
                    var af = this.ce.series._inner[ae];
                    if (af.dd && typeCast(CalloutLayer.$, af) !== null) {
                        var ag = af;
                        if (ag.vo == this.vo) {
                            if (!ag.xy.equals1(this.t3.a5)) {
                                ad = false;
                                break;
                            }
                        }
                    }
                }
                if (ad) {
                    this.t3.a4();
                }
                else {
                    this.t3.ar();
                    this.t3.as();
                }
            }
            else {
                this.t3.a4();
            }
        }
        else {
            this.t3.as();
        }
        var ah = this.uo.c;
        var ai;
        var aj;
        var ak;
        var al;
        var am;
        var an;
        var ao;
        var ap;
        var aq;
        var ar;
        var as;
        var at;
        var au;
        var av;
        var aw;
        var ax;
        var ay = this.ug;
        while (ah != null) {
            var az = ah.c;
            var a0 = az.b;
            ai = a0.bk;
            aj = a0.bm;
            ak = a0.bl;
            al = a0.backgroundPadding.left;
            am = a0.backgroundPadding.top;
            an = a0.backgroundPadding.right;
            ao = a0.backgroundPadding.bottom;
            aq = a0.backgroundCornerRadius;
            ap = a0.y;
            ar = a0.bn;
            as = a0.ao;
            at = a0.aa;
            var a1 = az.c;
            au = a1.o - (a1.g - a1.l);
            av = a1.p - (a1.h - a1.k);
            aw = a1.g - a1.l;
            ax = a1.h - a1.k;
            if (ay) {
                var a2 = new CalloutRenderStyleUpdatingEventArgs();
                a2.background = ai;
                a2.outline = aj;
                a2.leaderBrush = ak;
                a2.strokeThickness = ap;
                a2.textColor = ar;
                a2.item = at;
                a2.series = a0.l;
                a2.actualPosition = a1.a;
                a2.xValue = a0.ac;
                a2.yValue = a0.ad;
                if (this.calloutRenderStyleUpdating != null) {
                    this.calloutRenderStyleUpdating(this, a2);
                    ai = a2.background;
                    aj = a2.outline;
                    ak = a2.leaderBrush;
                    ap = a2.strokeThickness;
                    ar = a2.textColor;
                }
            }
            a.n.add1(az);
            a.f.add(ai);
            a.i.add(aj);
            a.h.add(ak);
            a.k.add(al);
            a.m.add(am);
            a.l.add(an);
            a.j.add(ao);
            a.g.add(aq);
            a.o.add(ap);
            a.p.add(ar);
            a.q.add1(as);
            a.r.add1(at);
            a.u.add(au);
            a.v.add(av);
            a.s.add(aw);
            a.t.add(ax);
            ah = ah.a;
        }
    };
    CalloutLayer.prototype.wm = function () {
        if (this.t3 != null) {
            var a = this.uo.c;
            while (a != null) {
                var b = a.c.c;
                if (b != null) {
                    this.t3.a2(b);
                }
                a = a.a;
            }
            var c = this.t3;
            c.labelsMoved = delegateRemove(c.labelsMoved, runOn(this, this.wj));
            this.t3 = null;
        }
        this.wl();
    };
    CalloutLayer.prototype.t4 = function () {
        if (this.ce == null) {
            return null;
        }
        for (var a = 0; a < this.ce.series.count; a++) {
            var b = this.ce.series._inner[a];
            if (b.dd && typeCast(CalloutLayer.$, b) !== null) {
                var c = b;
                if (c != this) {
                    if (c.vo != null && c.vo == this.vo) {
                        if (c.t3 != null) {
                            return c.t3;
                        }
                    }
                }
            }
        }
        return null;
    };
    CalloutLayer.prototype.u5 = function () {
        return 20000;
    };
    CalloutLayer.prototype.u6 = function () {
        return 300;
    };
    CalloutLayer.prototype.t5 = function () {
        switch (this.th) {
            case 0: return 2;
            case 2: return 1;
            case 3: return 2;
            case 1: return 0;
        }
        return 2;
    };
    CalloutLayer.prototype.wj = function (a) {
        var b = this.t3.am();
        if (b < this.u2) {
            this.u2 = b;
            this.mn(false);
        }
    };
    CalloutLayer.prototype.t6 = function (a) {
        var b = this.tq;
        if (a.b.l != null) {
            b = a.b.l;
        }
        if (b == null) {
            for (var c = 0; c < this.ce.series.count; c++) {
                var d = this.ce.series._inner[c];
                if (!d.dd) {
                    b = d;
                    break;
                }
            }
        }
        if (b == null) {
            return null;
        }
        var e = b.ag();
        var f = b.gg();
        var g = null;
        var h = null;
        var i = false;
        for (var j = 0; j < e.length; j++) {
            if (e[j].b8) {
                i = true;
                g = e[j];
            }
            else if (e[j].cl) {
                i = true;
                h = e[j];
            }
            else if (e[j].co) {
                h = e[j];
            }
            else {
                g = e[j];
            }
        }
        if (g == null || h == null) {
            return null;
        }
        if (!g.cn() || !h.cn()) {
            return null;
        }
        var k = 0;
        var l = 0;
        if (g.ca && g.categoryMode != 0) {
            if (b.ds) {
                k = b.getOffsetValue();
            }
            else if (b.dj) {
                k = b.getOffsetValue();
            }
        }
        if (h.ca && h.categoryMode != 0) {
            if (b.dj) {
                l = b.getOffsetValue();
            }
        }
        var m = new ScalerParams(0, this.ce.ta, g.kc, g.cg, g.j7());
        m.b = f;
        var n = new ScalerParams(0, this.ce.ta, h.kc, h.cg, h.j7());
        n.b = f;
        var o = 0;
        var p = 0;
        if (i) {
            o = g.ei(this.u1(a.b.ac), m) + k;
            p = h.ei(this.u1(a.b.ad), n) + l;
            var q = o;
            var r = p;
            var s = { $type: Point_$type, x: 0.5, y: 0.5 };
            var t = s.x + (r * Math.cos(q));
            o = ViewportUtils.c(t, m.e, m.d);
            var u = s.y + (r * Math.sin(q));
            p = ViewportUtils.f(u, n.e, n.d);
        }
        else {
            o = g.ei(this.u1(a.b.ac), m) + k;
            p = h.ei(this.u1(a.b.ad), n) + l;
        }
        var v = new QuadTreeBoundingBox();
        v.b = o;
        v.c = p;
        v.e = 3;
        v.d = 3;
        v.g = a.b;
        return v;
    };
    CalloutLayer.prototype.u1 = function (a) {
        if (typeCast(Date_$type, a) !== null) {
            return a.getTime();
        }
        if (a == null) {
            return 0;
        }
        return a;
    };
    CalloutLayer.prototype.us = function () {
        var a = new List$1(CalloutAnnotationWrapper.$, 0);
        for (var b = 0; b < this.ur.count; b++) {
            if (stringIsNullOrEmpty(this.ur._inner[b].b.ao)) {
                continue;
            }
            if (this.ur._inner[b].c == null) {
                var c = new LabelCollisionInfo();
                this.ur._inner[b].c = c;
                var d = this.tk.cn(this.u7(this.ur._inner[b]), this.ur._inner[b].b.backgroundPadding);
                c.k = d.height / 2;
                c.l = d.width / 2;
            }
            var e = this.t6(this.ur._inner[b]);
            if (e == null || e.b < this.p7.left || e.b > this.p7.right || e.c < this.p7.top || e.c > this.p7.bottom) {
                continue;
            }
            a.add(this.ur._inner[b]);
        }
        return a;
    };
    CalloutLayer.prototype.u7 = function (a) {
        return a.b.ao;
    };
    CalloutLayer.prototype.qw = function (a) {
        if (!_super.prototype.qw.call(this, a)) {
            return false;
        }
        if (this.v3 != null) {
            if (a.dx) {
                var b = a.ju();
                if (!Base.equalsStatic(this.v3, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.v3, a.name)) {
                    return false;
                }
            }
        }
        return true;
    };
    CalloutLayer.prototype.lx = function () {
        _super.prototype.lx.call(this);
        if (!this.at.c && !this.cw()) {
            return;
        }
        if (this.t7) {
            this.t7 = false;
            this.wo();
        }
        if (this.cw()) {
            this.wu(this.qr, false);
        }
        else {
            this.wu(this.qp, false);
        }
    };
    CalloutLayer.prototype.wp = function () {
        if (!this.t9) {
            this.t9 = true;
            this.mn(true);
        }
    };
    CalloutLayer.prototype.ws = function (a, b, c) {
        var d = false;
        if (this.t9) {
            this.t9 = false;
            d = true;
        }
        if (!a.et && a.c2(this.up, this.uk, this.ui, this.u3)) {
            var e = this.up;
            var _loop_1 = function (f) {
                var g = e._inner[f];
                var h = g.a != null ? g.a.item : null;
                var i = g.a.item != null ? g.a.item : g.a;
                var j = a;
                var k = new CalloutKey(i, j);
                var l = new CalloutAnnotationWrapper();
                var m = new CalloutAnnotation();
                l.b = m;
                m.key = k;
                var n = false;
                if (this_1.ul.containsKey(l)) {
                    l = this_1.ul.item(l).c;
                    m = l.b;
                    n = d;
                }
                else {
                    n = true;
                }
                var o = m.ac;
                var p = m.ad;
                if (this_1.u1(o) != this_1.u1(g.b)) {
                    m.xValue = g.b;
                }
                if (this_1.u1(p) != this_1.u1(g.c)) {
                    m.yValue = g.c;
                }
                m.series = a;
                var q = false;
                if (g.d != m.ay) {
                    m.ay = g.d;
                    q = true;
                }
                if (n || q) {
                    if (this_1.calloutLabelUpdating != null) {
                        var r = ((function () {
                            var $ret = new CalloutLabelUpdatingEventArgs();
                            $ret.d = m.ac;
                            $ret.e = m.ad;
                            $ret.item = h;
                            $ret.a = a;
                            $ret.f = a.name;
                            return $ret;
                        })());
                        this_1.calloutLabelUpdating(this_1, r);
                        if (r.c != null && !Base.equalsStatic(r.c, l.b.ao)) {
                            var s = r.c;
                            l.b.text = s != null ? s.toString() : "";
                        }
                    }
                    else {
                        if (g.d != null) {
                            m.text = g.d;
                        }
                    }
                }
                if (m.ao == null) {
                    return "continue";
                }
                if (n || q) {
                    if (this_1.calloutContentUpdating != null) {
                        var t = ((function () {
                            var $ret = new CalloutContentUpdatingEventArgs();
                            $ret.c = m.ac;
                            $ret.d = m.ad;
                            $ret.item = h;
                            $ret.a = i;
                            return $ret;
                        })());
                        this_1.calloutContentUpdating(this_1, t);
                        if (t.a != null && t.a != l.b.aa) {
                            l.b.content = t.a;
                        }
                    }
                    else {
                        if (i != null && i != l.b.aa) {
                            l.b.content = i;
                        }
                    }
                }
                if (n) {
                    this_1.ww(l);
                }
                if (l.c == null) {
                    var u = new LabelCollisionInfo();
                    l.c = u;
                    var v = this_1.tk.cn(this_1.u7(l), l.b.backgroundPadding);
                    u.k = v.height / 2;
                    u.l = v.width / 2;
                }
                var w = this_1.t6(l);
                if (w == null || w.b < this_1.p7.left || w.b > this_1.p7.right || w.c < this_1.p7.top || w.c > this_1.p7.bottom) {
                    return "continue";
                }
                l.e = w.b;
                l.f = w.c;
                c.add(l);
            };
            var this_1 = this;
            for (var f = 0; f < this.up.count; f++) {
                _loop_1(f);
            }
        }
    };
    CalloutLayer.prototype.bq = function () {
        return 1;
    };
    CalloutLayer.prototype.au = function (a, b) {
        var c = this.t3.f(a, b);
        if (c == null) {
            return null;
        }
        return c.u;
    };
    CalloutLayer.prototype.ez = function (a, b) {
        if (this.t3 == null) {
            return false;
        }
        return this.t3.f(a, b) != null;
    };
    CalloutLayer.prototype.wu = function (a, b) {
        var e_3, _a;
        var c = 0;
        var d = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        for (c = 0; c < a.q.count; c++) {
            var e = a.n._inner[c];
            if (isNaN_(a.u._inner[c]) || isNaN_(a.v._inner[c])) {
                continue;
            }
            var f = this.tk.b8.item(e);
            d.add_1(e);
            if (f.h != a.q._inner[c]) {
                f.h = a.q._inner[c];
                var g = f.u();
            }
            f.e = a.o._inner[c];
            f.m = a.f._inner[c];
            f.p = a.p._inner[c];
            f.o = f.e > 0 ? a.i._inner[c] : this.b1.bq();
            f.n = a.h._inner[c];
            f.x = new Thickness(1, a.k._inner[c], a.m._inner[c], a.l._inner[c], a.j._inner[c]);
            f.d = a.g._inner[c];
            this.tk.cg(f, Math.min(a.s._inner[c], a.s._inner[c] + a.u._inner[c]), Math.min(a.t._inner[c], a.t._inner[c] + a.v._inner[c]));
            this.tk.ch(f, e, a.r._inner[c]);
            f.r = { $type: Point_$type, x: a.u._inner[c], y: a.v._inner[c] };
        }
        var h = new List$1(CalloutAnnotationWrapper.$, 0);
        try {
            for (var _b = __values(fromEnum(this.tk.b8.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var i = _c.value;
                if (!d.contains(i)) {
                    h.add(i);
                }
            }
        }
        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;
            }
        }
        for (var j = 0; j < h.count; j++) {
            this.tk.b8.h(h._inner[j]);
        }
    };
    CalloutLayer.prototype.r8 = function (a, b) {
        _super.prototype.r8.call(this, a, b);
        if (this.cw()) {
            this.wu(this.qr, true);
        }
        else {
            this.wu(this.qp, false);
        }
    };
    CalloutLayer.prototype.ep = function () {
        return true;
    };
    CalloutLayer.prototype.l9 = function (a, b, c, d) {
        _super.prototype.l9.call(this, a, b, c, d);
        switch (b) {
            case CalloutLayer.$$p[24]:
                this.tr = null;
                this.tk.cf();
                this.mn(true);
                break;
            case CalloutLayer.$$p[22]:
            case CalloutLayer.$$p[23]:
                this.mn(true);
                break;
            case CalloutLayer.$$p[14]:
                this.mn(true);
                break;
            case "SeriesViewer":
                if (c != null) {
                    var e = c;
                    e.seriesAnimating = delegateRemove(e.seriesAnimating, runOn(this, this.wt));
                }
                if (d != null) {
                    var f = d;
                    f.seriesAnimating = delegateCombine(f.seriesAnimating, runOn(this, this.wt));
                }
                if (d == null) {
                    this.wm();
                }
                break;
            case "AutoCalloutVisibilityMode":
                this.te = this.tg();
                this.wn();
                break;
            case "AllowedPositions":
                if (c != null) {
                    var g = c;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.wh));
                }
                if (d != null) {
                    var h = d;
                    h.collectionChanged = delegateCombine(h.collectionChanged, runOn(this, this.wh));
                }
                this.tb = this.tc(this.tm);
                this.wn();
                break;
            case CalloutLayer.$$p[16]:
            case CalloutLayer.$$p[17]:
            case CalloutLayer.$$p[1]:
            case CalloutLayer.$$p[6]:
            case CalloutLayer.$$p[5]:
            case CalloutLayer.$$p[25]:
            case CalloutLayer.$$p[26]:
            case CalloutLayer.$$p[19]:
            case CalloutLayer.$$p[18]:
            case CalloutLayer.$$p[8]:
            case CalloutLayer.$$p[10]:
            case CalloutLayer.$$p[9]:
            case CalloutLayer.$$p[7]:
            case CalloutLayer.$$p[12]:
            case CalloutLayer.$$p[13]:
                this.wn();
                break;
            case CalloutLayer.$$p[21]:
                if (this.cl != null) {
                    this.cl.deregisterColumn(this.t0);
                    this.t0 = this.ck(this.v1);
                }
                break;
            case "LabelColumn":
                this.wn();
                break;
            case CalloutLayer.$$p[15]:
                if (this.cl != null) {
                    this.cl.deregisterColumn(this.ty);
                    this.ty = this.ck(this.vr);
                }
                break;
            case "ContentColumn":
                this.wn();
                break;
            case CalloutLayer.$$p[28]:
                if (this.cl != null) {
                    this.cl.deregisterColumn(this.t1);
                    this.t1 = stringIsNullOrEmpty(this.wc) == false ? this.ck(this.wc) : null;
                }
                break;
            case "XColumn":
                this.wn();
                break;
            case CalloutLayer.$$p[29]:
                if (this.cl != null) {
                    this.cl.deregisterColumn(this.t2);
                    this.t2 = this.ck(this.wf);
                }
                break;
            case "YColumn":
                this.wn();
                break;
            case CalloutLayer.$$p[20]:
                if (this.cl != null) {
                    this.cl.deregisterColumn(this.tz);
                    this.tz = this.ck(this.vy);
                }
                break;
            case "KeyColumn":
                this.wn();
                break;
            case "FastItemsSource":
                this.t8 = true;
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.t0);
                    c.deregisterColumn(this.ty);
                    c.deregisterColumn(this.t1);
                    c.deregisterColumn(this.t2);
                    c.deregisterColumn(this.tz);
                    this.t0 = null;
                    this.ty = null;
                    this.t1 = null;
                    this.t2 = null;
                    this.tz = null;
                    this.ur.clear();
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.t0 = this.ck(this.v1);
                    this.ty = this.ck(this.vr);
                    if (stringIsNullOrEmpty(this.wc) == false) {
                        this.t1 = this.ck(this.wc);
                    }
                    this.t2 = this.ck(this.wf);
                    this.tz = this.ck(this.vy);
                }
                this.wn();
                break;
        }
    };
    CalloutLayer.prototype.tg = function () {
        if (this.tf == 0) {
            return 1;
        }
        return this.tf;
    };
    CalloutLayer.prototype.tc = function (a) {
        if (a == null || a.count == 0) {
            return null;
        }
        var b = new Array(a.count);
        for (var c = 0; c < a.count; c++) {
            b[c] = a._inner[c];
        }
        return b;
    };
    CalloutLayer.prototype.wt = function (a) {
        if (a.dd) {
            return;
        }
        if ((a == this.tq || this.tq == null) && this.ue) {
            this.mn(false);
        }
    };
    CalloutLayer.prototype.wn = function () {
        if (this.t7 == false) {
            this.t7 = true;
            this.mn(false);
        }
    };
    CalloutLayer.prototype.wl = function () {
        this.tk.b8.clear();
        this.uo.g();
        this.ul.clear();
    };
    CalloutLayer.prototype.wo = function () {
        if (this.t2 == null || this.t0 == null) {
            var a = this.uo.c;
            while (a != null) {
                this.ww(a.c);
                a = a.a;
            }
            return;
        }
        var b = this.um();
        for (var c = 0; c < this.t2.count; c++) {
            var d = void 0;
            if (this.ur.count <= c) {
                var e = new CalloutAnnotation();
                d = new CalloutAnnotationWrapper();
                d.b = e;
                d.b.series = this.tq;
                this.ur.add(d);
            }
            else {
                d = this.ur._inner[c];
            }
            this.wv(c, b);
        }
    };
    CalloutLayer.$t = markType(CalloutLayer, 'CalloutLayer', AnnotationLayer.$);
    CalloutLayer.xb = DependencyProperty.i("AutoCalloutVisibilityMode", AutoCalloutVisibilityMode_$type, CalloutLayer.$, new PropertyMetadata(2, enumGetBox(AutoCalloutVisibilityMode_$type, 0), function (a, b) { return a.raisePropertyChanged("AutoCalloutVisibilityMode", b.oldValue, b.newValue); }));
    CalloutLayer.$$p = markDep(DependencyProperty, PropertyMetadata, CalloutLayer, 'raisePropertyChanged', ['AutoCalloutLabelPrecision:u3:wx', [1, 5], 'CalloutBackground:xs:wy', [Brush.$, null], 'CalloutCollisionMode:th:wz', [CalloutCollisionMode_$type, enumGetBox(CalloutCollisionMode_$type, 3)], 'CalloutCornerRadius:uu:w0', [1, NaN], 'CalloutInterpolatedValuePrecision:u4:w1', [1, -1], 'CalloutLeaderBrush:xt:w2', [Brush.$, null], 'CalloutOutline:xu:w3', [Brush.$, null], 'CalloutPaddingBottom:uv:w4', [1, NaN], 'CalloutPaddingLeft:uw:w5', [1, NaN], 'CalloutPaddingRight:ux:w6', [1, NaN], 'CalloutPaddingTop:uy:w7', [1, NaN], 'CalloutPositionPadding:uz:w8', [1, 10], 'CalloutStrokeThickness:u0:w9', [1, NaN], 'CalloutTextColor:xv:xa', [Brush.$, null], 'CollisionChannel:vo:xc', [2, null], 'ContentMemberPath:vr:xd', [2, null], 'IsAutoCalloutBehaviorEnabled:ue:xe', [0, false], 'IsCalloutOffsettingEnabled:uf:xf', [0, true], 'IsCustomCalloutRenderStyleEnabled:ug:xg', [0, false], 'IsCustomCalloutStyleEnabled:uh:xh', [0, false], 'KeyMemberPath:vy:xi', [2, null], 'LabelMemberPath:v1:xj', [2, null], 'TargetSeriesName:v3:xk', [2, null], 'TargetSeries:tq:xl', [Series.$, null], 'TextStyle:v6:xm', [2, null], 'UseInterpolatedValueForAutoCalloutLabels:ui:xn', [0, false], 'UseSeriesColorForOutline:uj:xo', [0, false], 'UseValueForAutoCalloutLabels:uk:xp', [0, true], 'XMemberPath:wc:xq', [2, null], 'YMemberPath:wf:xr', [2, null]]);
    return CalloutLayer;
}(AnnotationLayer));
export { CalloutLayer };
/**
 * @hidden
 */
var CalloutLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutLayerView, _super);
    function CalloutLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b4 = null;
        _this.b9 = null;
        _this.b8 = null;
        _this.ca = NaN;
        _this.b5 = null;
        _this.b4 = a;
        _this.b9 = new List$1(CalloutView.$, 0);
        return _this;
    }
    CalloutLayerView.prototype.as = function () {
        var _this = this;
        _super.prototype.as.call(this);
        this.b8 = ((function () {
            var $ret = new HashPool$2(CalloutAnnotationWrapper.$, CalloutView.$);
            $ret.create = runOn(_this, _this.b6);
            $ret.activate = runOn(_this, _this.cc);
            $ret.disactivate = runOn(_this, _this.ce);
            $ret.destroy = runOn(_this, _this.cd);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.b6 = function () {
        var a = new CalloutView(this);
        this.b9.add(a);
        return a;
    };
    CalloutLayerView.prototype.cc = function (a) {
        a.y = 0;
    };
    CalloutLayerView.prototype.ce = function (a) {
        a.y = 1;
    };
    CalloutLayerView.prototype.cd = function (a) {
        this.b9.remove(a);
    };
    CalloutLayerView.prototype.cm = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.l(a, 0.1);
    };
    CalloutLayerView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        a.ad(this.b7());
        if (a.d && !b) {
            for (var c = 0; c < this.b9.count; c++) {
                var d = this.b9._inner[c];
                if (d.y == 0) {
                    d.j(a);
                }
            }
        }
    };
    CalloutLayerView.prototype.b7 = function () {
        if (this.b4.ts != null) {
            return this.b4.ts;
        }
        return this.e.ce.getFontInfo();
    };
    CalloutLayerView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        for (var b = 0; b < this.b9.count; b++) {
            var c = this.b9._inner[b];
            if (c.y != 0) {
                continue;
            }
            c.i(this.b4, this.b7(), a);
        }
    };
    CalloutLayerView.prototype.co = function (a) {
        this.k.ad(this.b7());
        this.ca = this.cb();
        var b = this.k.ah(a, this.ca, true);
        return new Size(1, b.c, b.b);
    };
    CalloutLayerView.prototype.cb = function () {
        var a = this.b7();
        if (isNaN_(this.ca)) {
            var b = FontUtil.getCurrentFontHeight(this.e.ce.cu.j.ae, a);
            this.ca = b;
        }
        return this.ca;
    };
    CalloutLayerView.prototype.cn = function (a, b) {
        if (this.b5 == null) {
            this.b5 = new CalloutView(this);
        }
        this.b5.h = a;
        this.b5.x = b;
        var c = this.b5.u();
        this.b5.h = null;
        return c;
    };
    CalloutLayerView.prototype.cg = function (a, b, c) {
        a.f = b;
        a.g = c;
    };
    CalloutLayerView.prototype.ch = function (a, b, c) {
        a.k(this.e, b, c);
    };
    CalloutLayerView.prototype.ci = function (a) {
        if (a != null) {
            return this.cm(a.pa);
        }
        return this.e.pa;
    };
    CalloutLayerView.prototype.cl = function () {
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 255, 255, 255);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.ck = function (a) {
        if (this.b4.uj) {
            if (a != null) {
                return this.cm(a.pa);
            }
        }
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 255, 255, 255);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.cj = function (a) {
        if (a != null) {
            return this.cm(a.o5);
        }
        return this.e.o5;
    };
    CalloutLayerView.prototype.cf = function () {
        this.ca = NaN;
    };
    CalloutLayerView.$t = markType(CalloutLayerView, 'CalloutLayerView', AnnotationLayerView.$);
    return CalloutLayerView;
}(AnnotationLayerView));
export { CalloutLayerView };
/**
 * @hidden
 */
var CalloutView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutView, _super);
    function CalloutView(a) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.y = 0;
        _this.l = null;
        _this.t = null;
        _this.q = { $type: Point_$type, x: 0, y: 0 };
        _this.s = null;
        _this.w = new Thickness(0, 0);
        _this.v = null;
        _this.c = 0;
        _this.f = 0;
        _this.g = 0;
        _this.b = null;
        _this.s = new Line();
        _this.s.ab = false;
        _this.s._stroke = ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 0, 0, 0);
            return $ret;
        })());
        _this.s.ad = 2;
        _this.l = new TextBlock();
        _this.t = new Rectangle();
        _this.t.ad = 0;
        _this.a = a;
        _this.y = 0;
        return _this;
    }
    CalloutView.prototype.j = function (a) {
        a.aa();
        a.ag(this.f, this.g);
        var b = new TranslateTransform();
        b.j = this.v.left;
        b.k = this.v.top;
        this.t.j = b;
        a.s(this.s);
        a.aa();
        this.t.width = this.l.m + this.w.left + this.w.right;
        this.t.height = this.l.l + this.w.top + this.w.bottom;
        this.t.ap = this.c;
        this.t.aq = this.c;
        a.k(this.t.j);
        a.w(this.t);
        this.l.ag = true;
        this.l.o = this.w.top;
        this.l.n = this.w.left;
        a.x(this.l);
        a.z();
        a.z();
    };
    Object.defineProperty(CalloutView.prototype, "r", {
        get: function () {
            return this.q;
        },
        set: function (a) {
            if (this.q.x != a.x || this.q.y != a.y) {
                var b = this.u();
                var c = b.height;
                var d = b.width;
                this.q = a;
                var e = CalloutViewHelper.b(this.r, d, c, this.s);
                this.v = e;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "p", {
        get: function () {
            return this.l.ao;
        },
        set: function (a) {
            this.l.ao = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "o", {
        get: function () {
            return this.t._stroke;
        },
        set: function (a) {
            this.t._stroke = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "n", {
        get: function () {
            return this.s._stroke;
        },
        set: function (a) {
            this.s._stroke = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "m", {
        get: function () {
            return this.t._fill;
        },
        set: function (a) {
            this.t._fill = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "e", {
        get: function () {
            return this.t.ad;
        },
        set: function (a) {
            this.t.ad = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "x", {
        get: function () {
            return this.w;
        },
        set: function (a) {
            this.w = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "d", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "h", {
        get: function () {
            return this.l.al;
        },
        set: function (a) {
            if (a == null) {
                this.l.al = "";
            }
            else {
                this.l.al = a.toString();
            }
            var b = this.u();
            var c = b.height;
            var d = b.width;
            var e = CalloutViewHelper.b(this.r, d, c, this.s);
            this.v = e;
        },
        enumerable: false,
        configurable: true
    });
    CalloutView.prototype.u = function () {
        var a = this.a.co(this.l);
        this.l.m = a.width;
        this.l.l = a.height;
        return new Size(1, a.width + this.w.left + this.w.right, a.height + this.w.top + this.w.bottom);
    };
    CalloutView.prototype.k = function (a, b, c) {
        if (this.b == null) {
            this.b = new DataContext();
        }
        this.b.series = a;
        this.b.item = c;
        if (b.c != null) {
            b.c.u = this.b;
        }
    };
    CalloutView.prototype.i = function (a, b, c) {
        a.a9.exportCalloutData(this.f, this.g, this.v.left, this.v.top, c, this.t, this.l, b, this.s, "callout", ["Main", "Callout"]);
    };
    CalloutView.$t = markType(CalloutView, 'CalloutView');
    return CalloutView;
}(Base));
export { CalloutView };
