/*
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-react-core";
import { Base, runOn, delegateCombine, String_$type, Array_$type, enumGetBox, EnumUtil, typeCast, fromEnum, delegateRemove, Point_$type, Date_$type, markType, markDep } from "igniteui-react-core";
import { Series } from "./Series";
import { CalloutPlacementPositionsCollection } from "./CalloutPlacementPositionsCollection";
import { HighlightedValueLabelMode_$type } from "igniteui-react-core";
import { AutoCalloutVisibilityMode_$type } from "./AutoCalloutVisibilityMode";
import { Brush } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { CalloutCollisionMode_$type } from "igniteui-react-core";
import { FontUtil } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { BindingFormatter } from "igniteui-react-core";
import { CalloutLayerFrame } from "./CalloutLayerFrame";
import { HashSet$1 } from "igniteui-react-core";
import { CalloutAnnotationWrapper } from "./CalloutAnnotationWrapper";
import { List$1 } from "igniteui-react-core";
import { LinkedList$1 } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { LinkedListNode$1 } from "igniteui-react-core";
import { LabelCollisionManager } from "igniteui-react-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { CalloutAnnotation } from "./CalloutAnnotation";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { CalloutLabelUpdatingEventArgs } from "./CalloutLabelUpdatingEventArgs";
import { CalloutSeriesSelectingEventArgs } from "./CalloutSeriesSelectingEventArgs";
import { CalloutStyleUpdatingEventArgs } from "./CalloutStyleUpdatingEventArgs";
import { DeviceUtils } from "igniteui-react-core";
import { BrushUtilCore } from "igniteui-react-core";
import { LabelCollisionInfo } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { CalloutRenderStyleUpdatingEventArgs } from "./CalloutRenderStyleUpdatingEventArgs";
import { QuadTreeBoundingBox } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { ViewportUtils } from "./ViewportUtils";
import { Size } from "igniteui-react-core";
import { CalloutContentUpdatingEventArgs } from "./CalloutContentUpdatingEventArgs";
import { CalloutKey } from "./CalloutKey";
import { DataContext } from "igniteui-react-core";
import { HashPool$2 } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { stringIsNullOrEmpty } from "igniteui-react-core";
import { FastItemObjectColumn } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { TextBlock } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { Line } from "igniteui-react-core";
import { CalloutViewHelper } from "./CalloutViewHelper";
import { Rectangle } from "igniteui-react-core";
import { TranslateTransform } from "igniteui-react-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.aab = null;
        _this.aac = null;
        _this.aad = null;
        _this.aaa = null;
        _this.z9 = null;
        _this.aa6 = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        _this.aa9 = new List$1(CalloutAnnotationWrapper.$, 0);
        _this.aba = new List$1(CalloutAnnotationWrapper.$, 0);
        _this.z0 = null;
        _this.zo = null;
        _this.z7 = null;
        _this.aa7 = new LinkedList$1(CalloutAnnotationWrapper.$);
        _this.aa4 = new Dictionary$2(CalloutAnnotationWrapper.$, LinkedListNode$1.$.specialize(CalloutAnnotationWrapper.$), 0);
        _this.aaj = null;
        _this.aez = new Rect(0, 0, 0, 1, 1);
        _this.aaq = false;
        _this.abl = 0;
        _this.aey = Rect.empty;
        _this.aao = false;
        _this.aap = false;
        _this.calloutContentUpdating = null;
        _this.calloutLabelUpdating = null;
        _this.calloutSeriesSelecting = null;
        _this.aa8 = new List$1(SeriesPointOfInterest.$, 0);
        _this.aas = false;
        _this.aat = false;
        _this.abc = 0;
        _this.aar = false;
        _this.zr = null;
        _this.aan = true;
        _this.zs = 1;
        FastItemObjectColumn.m();
        _this.zo = null;
        _this.z0 = new CalloutPlacementPositionsCollection();
        var a = _this.z0;
        a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.ac9));
        _this.xb = true;
        var b = new CalloutLayerFrame();
        var c = new CalloutLayerFrame();
        var d = new CalloutLayerFrame();
        var e = _this.kb / 1000;
        _this.w3 = b;
        _this.w2 = c;
        _this.w4 = d;
        _this.ab = CalloutLayer.$;
        return _this;
    }
    CalloutLayer.prototype.bi = function () {
        return new CalloutLayer();
    };
    CalloutLayer.prototype.get_em = function () {
        return true;
    };
    CalloutLayer.prototype.ac9 = function (a, b) {
        this.adi();
    };
    CalloutLayer.prototype.adi = function () {
        this.zo = this.zq(this.z1);
        this.adf();
    };
    CalloutLayer.prototype.ada = function (a, b) {
        this.aba.clear();
        this.rm(false);
    };
    CalloutLayer.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        var e = this.aa5();
        switch (a) {
            case 3:
                this.adn(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.z6;
                    this.aba.insert(f, h);
                    this.adn(f, e);
                }
                break;
            case 0:
                this.aba.v(b, c);
                break;
            case 2:
                for (var i = b; i < b + c; i++) {
                    this.adn(i, e);
                }
                break;
            case 4:
                this.aba.clear();
                for (var j = 0; j < this.dl.count; j++) {
                    var k = new CalloutAnnotation();
                    var l = new CalloutAnnotationWrapper();
                    l.b = k;
                    l.b.series = this.z6;
                    this.aba.add(l);
                    this.adn(j, e);
                }
                break;
        }
        this.rm(true);
    };
    CalloutLayer.prototype.gd = function (a) {
        return false;
    };
    CalloutLayer.prototype.aa5 = function () {
        var a = new Dictionary$2(String_$type, Series.$, 0);
        if (this.c9 != null) {
            for (var b = 0; b < this.c9.series.count; b++) {
                var c = this.c9.series._inner[b];
                if (c.name != null && !a.containsKey(c.name)) {
                    a.addItem(c.name, c);
                }
            }
        }
        return a;
    };
    CalloutLayer.prototype.adn = function (a, b) {
        var _this = this;
        if (this.aai == null || this.aag == null) {
            return;
        }
        var c = a;
        if (this.aah != null) {
            c = this.aah.item(a);
        }
        var d = this.aai.item(a);
        var e = this.aag.item(a);
        var f = this.aba._inner[a];
        if (this.aaf != null) {
            if (f.b.ab != this.aaf.item(a)) {
                f.b.key = this.aaf.item(a);
            }
        }
        if (this.aa4.containsKey(f)) {
            f.b = this.aa4.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.dl.item(a);
                return $ret;
            })());
            this.calloutLabelUpdating(this, g);
            if (g.c != null && !Base.equalsStatic(g.c, f.b.ao)) {
                var h = g.c;
                if (this.zr != null) {
                    f.b.text = this.zr.i(h);
                }
                else {
                    f.b.text = h != null ? h.toString() : "";
                }
            }
        }
        else {
            if (this.zr != null) {
                f.b.text = this.zr.i(e);
            }
            else {
                f.b.text = e != null ? e.toString() : "";
            }
        }
        if (this.aae != null) {
            f.b.content = this.aae.item(a);
        }
        else {
            f.b.content = this.dl.item(a);
        }
        if (this.calloutSeriesSelecting != null) {
            var i = ((function () {
                var $ret = new CalloutSeriesSelectingEventArgs();
                $ret.c = c;
                $ret.d = d;
                $ret.item = _this.dl.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.ado(f);
    };
    CalloutLayer.prototype.ado = function (a) {
        var b = new Thickness(0, DeviceUtils.g(3));
        if (isNaN_(this.ae1.left) || isNaN_(this.ae1.top) || isNaN_(this.ae1.right) || isNaN_(this.ae1.bottom)) {
            b = new Thickness(0, DeviceUtils.g(3));
        }
        else {
            b = this.ae1;
        }
        var c = DeviceUtils.g(3);
        if (isNaN_(this.abd)) {
            c = DeviceUtils.g(3);
        }
        else {
            c = this.abd;
        }
        var d = this.aes != null && !this.aa0 ? this.aes : this.zz.cl(a.b.l, a.b.itemColor);
        var e = this.aex != null ? this.aex : null;
        var f = this.aev != null ? this.aev : this.zz.co();
        var g = this.aet != null ? this.aet : this.zz.cm();
        var h = this.aew != null && !this.aa1 ? this.aew : this.zz.cp(a.b.l, a.b.itemColor);
        var i = this.aeu != null ? this.aeu : this.zz.cn(a.b.l, a.b.itemColor);
        var j = isNaN_(this.abj) ? 0 : this.abj;
        if (e == null && (this.aay || this.aev != null || this.aet != null)) {
            var k = d;
            if (k == null || BrushUtilCore.a(d)) {
                k = this.c9 != null ? this.c9.u1 : null;
                if (a.c != null && (a.c.b == 8 || a.c.b == 9)) {
                    k = a.b.itemColor;
                }
                if (k == null || BrushUtilCore.a(d)) {
                    k = BrushUtil.h(255, 255, 255, 255);
                }
            }
            e = BrushUtil.j(k, g, f);
        }
        if (e == null) {
            e = this.zz.co();
        }
        if (this.aax && this.calloutStyleUpdating != null) {
            var l = new CalloutStyleUpdatingEventArgs();
            l.item = a.b.aa;
            l.xValue = a.b.ac;
            l.yValue = a.b.ad;
            l.series = a.b.l;
            l.background = d;
            l.textColor = e;
            l.outline = h;
            l.leaderBrush = i;
            l.strokeThickness = j;
            this.calloutStyleUpdating(this, l);
            d = l.background;
            e = l.textColor;
            h = l.outline;
            i = l.leaderBrush;
            j = l.strokeThickness;
        }
        a.b.backgroundPadding = b;
        a.b.backgroundCornerRadius = c;
        a.b.background = d;
        a.b.textColor = e;
        a.b.outline = h;
        a.b.leaderBrush = i;
        a.b.strokeThickness = j;
    };
    CalloutLayer.prototype.ko = function (a, b) {
        var c = this.na(b);
        if (c == CalloutLayer.$$p[26]) {
            return this.kp(a, b, this.acq);
        }
        if (c == CalloutLayer.$$p[36]) {
            return this.kp(a, b, this.ac4);
        }
        if (c == CalloutLayer.$$p[37]) {
            return this.kp(a, b, this.ac7);
        }
        if (c == CalloutLayer.$$p[23]) {
            return this.kp(a, b, this.ack);
        }
        if (c == CalloutLayer.$$p[17]) {
            return this.kp(a, b, this.acc);
        }
        return _super.prototype.ko.call(this, a, b);
    };
    CalloutLayer.prototype.ma = function (a) {
        var b = this.na(a);
        if (b == CalloutLayer.$$p[26]) {
            return this.acq;
        }
        if (b == CalloutLayer.$$p[36]) {
            return this.ac4;
        }
        if (b == CalloutLayer.$$p[37]) {
            return this.ac7;
        }
        if (b == CalloutLayer.$$p[23]) {
            return this.ack;
        }
        if (b == CalloutLayer.$$p[17]) {
            return this.acc;
        }
        return _super.prototype.ma.call(this, a);
    };
    Object.defineProperty(CalloutLayer.prototype, "aag", {
        get: function () {
            return this.aab;
        },
        set: function (a) {
            if (this.aab != a) {
                var b = this.aab;
                this.aab = a;
                this.raisePropertyChanged("LabelColumn", b, this.aab);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "aah", {
        get: function () {
            return this.aac;
        },
        set: function (a) {
            if (this.aac != a) {
                var b = this.aac;
                this.aac = a;
                this.raisePropertyChanged("XColumn", b, this.aac);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "aai", {
        get: function () {
            return this.aad;
        },
        set: function (a) {
            if (this.aad != a) {
                var b = this.aad;
                this.aad = a;
                this.raisePropertyChanged("YColumn", b, this.aad);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "aaf", {
        get: function () {
            return this.aaa;
        },
        set: function (a) {
            if (this.aaa != a) {
                var b = this.aaa;
                this.aaa = a;
                this.raisePropertyChanged("KeyColumn", b, this.aaa);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "aae", {
        get: function () {
            return this.z9;
        },
        set: function (a) {
            if (this.z9 != a) {
                var b = this.z9;
                this.z9 = a;
                this.raisePropertyChanged("ContentColumn", b, this.z9);
            }
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.adc = function (a, b) {
        if (b.propertyName == CalloutAnnotation.$$p[15] || b.propertyName == CalloutAnnotation.$$p[16]) {
            var c = a.k;
            if (!this.aa6.contains(c)) {
                this.aa6.add_1(c);
                this.aa9.add(c);
                this.rm(false);
            }
        }
    };
    CalloutLayer.prototype.cq = function () {
        return new CalloutLayerView(this);
    };
    CalloutLayer.prototype.qw = function (a) {
        _super.prototype.qw.call(this, a);
        this.zz = a;
    };
    Object.defineProperty(CalloutLayer.prototype, "z1", {
        get: function () {
            return this.z0;
        },
        set: function (a) {
            var b = this.z1;
            if (a != b) {
                this.z0 = a;
                this.raisePropertyChanged("AllowedPositions", b, this.z1);
            }
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.gs = function (a) {
        if (this.z6 == null) {
            return true;
        }
        if (this.z6 == a) {
            return true;
        }
        return false;
    };
    Object.defineProperty(CalloutLayer.prototype, "zu", {
        get: function () {
            return EnumUtil.getEnumValue(AutoCalloutVisibilityMode_$type, this.c(CalloutLayer.ad5));
        },
        set: function (a) {
            this.h(CalloutLayer.ad5, enumGetBox(AutoCalloutVisibilityMode_$type, a));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "zt", {
        get: function () {
            return this.zs;
        },
        set: function (a) {
            this.zs = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "ae1", {
        get: function () {
            return new Thickness(1, this.abf, this.abh, this.abg, this.abe);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "z8", {
        get: function () {
            if (this.z7 == null) {
                this.z7 = FontUtil.toFontInfo(this.jx, this.acv);
            }
            return this.z7;
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.yg = function (a, b) {
        if (this.z6 == null || this.z6 == a) {
            if (!this.a0.c) {
                this.rm(b);
            }
        }
    };
    CalloutLayer.prototype.yi = function (a, b) {
        var e_1, _a;
        var _this = this;
        _super.prototype.yi.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.abb();
        var e = new List$1(CalloutAnnotationWrapper.$, 0);
        var f = true;
        if (this.aau) {
            if (this.w9(this.z6)) {
                this.adk(this.z6, c, e);
            }
            else {
                try {
                    for (var _b = __values(fromEnum(this.c9.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var g = _c.value;
                        if (this.w9(g)) {
                            if (!g.eq) {
                                if (!g.isVertical) {
                                    f = false;
                                }
                            }
                            var h = false;
                            if (g.ee && this.z5 == 0 || this.z5 == 3 || this.z5 == 2) {
                                if (this.z5 == 0 || this.z5 == 2) {
                                    h = true;
                                }
                                g.pw(function (i) {
                                    _this.adk(i, c, e);
                                    return true;
                                });
                            }
                            if (!h) {
                                this.adk(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.aau && this.zt == 2) {
            var i = 0;
            var j = 0;
            var k = 1.7976931348623157E+308;
            var l = 1.7976931348623157E+308;
            var m = -1.7976931348623157E+308;
            var n = -1.7976931348623157E+308;
            if (e.count > 0) {
                if (e._inner[0].c != null) {
                    i = e._inner[0].e;
                    j = e._inner[0].f;
                }
                for (var o = 0; o < e.count; o++) {
                    var p = e._inner[o];
                    if (p.c != null) {
                        var q = p.e;
                        var r = p.f;
                        if (q != i) {
                            k = Math.min(k, Math.abs(q - i));
                        }
                        if (r != j) {
                            l = Math.min(l, Math.abs(r - j));
                        }
                        m = Math.max(p.c.p + p.c.p, m);
                        n = Math.max(p.c.o + p.c.o, n);
                    }
                }
                if (f) {
                    if (n > l) {
                        e.clear();
                    }
                }
                else {
                    if (m > k) {
                        e.clear();
                    }
                }
            }
        }
        this.adj(c, d, e);
    };
    CalloutLayer.prototype.sk = function (a, b) {
        _super.prototype.sk.call(this, a, b);
        var c = b.width - this.aez.width;
        var d = b.height - this.aez.height;
        var e = 0;
        if (Math.abs(c) > Math.abs(d)) {
            e = c;
            this.abc = c * this.wk.width;
        }
        else {
            e = d;
            this.abc = d * this.wk.height;
        }
        if (e > 0 && this.abc > 5) {
            this.aat = true;
        }
        if (e < 0 && this.abc > 5) {
            this.aas = true;
        }
    };
    CalloutLayer.prototype.sj = function (a, b) {
        _super.prototype.sj.call(this, a, b);
        if (!a.equals1(b)) {
            this.aar = true;
        }
    };
    Object.defineProperty(CalloutLayer.prototype, "ae0", {
        get: function () {
            return this.aey;
        },
        set: function (a) {
            this.aey = a;
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.adj = function (a, b, c) {
        var e_2, _a;
        if (this.c9 != null) {
            this.aez = this.c9.vl;
        }
        if (this.wk.isEmpty) {
            return;
        }
        this.ae0 = new Rect(0, this.wk.left, this.wk.top, this.wk.width, this.wk.height);
        if (this.aaj != null && this.ab9 != null && this.ab9 != this.aaj.a7) {
            this.ade();
        }
        if (this.aaj != null && this.aaj.g != this.aal()) {
            this.ade();
        }
        if (this.aaj == null) {
            var d = this.aak();
            if (d != null) {
                this.aaj = d;
                var e = this.aaj;
                e.labelsMoved = delegateCombine(e.labelsMoved, runOn(this, this.adb));
            }
            else {
                var f = this.wc(this.ct);
                var g = new Array(2);
                g[0] = 0;
                g[1] = 3;
                if (this.z6 != null) {
                    if (this.z6.isVertical) {
                        g = new Array(2);
                        g[0] = 2;
                        g[1] = 1;
                    }
                }
                else {
                    var h = false;
                    if (this.c9 != null && this.c9.series.count > 0) {
                        h = true;
                        try {
                            for (var _b = __values(fromEnum(this.c9.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                                var i = _c.value;
                                if (!i.eq) {
                                    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;
                    }
                }
                if (this.zw == 4 || this.zw == 6) {
                    g = new Array(4);
                    g[0] = 10;
                    g[1] = 11;
                    g[2] = 8;
                    g[3] = 9;
                }
                if (this.zw == 5) {
                    g = new Array(4);
                    g[0] = 9;
                    g[1] = 10;
                    g[2] = 11;
                    g[3] = 8;
                }
                if (this.zw == 7) {
                    g = new Array(4);
                    g = new Array(4);
                    g[0] = 8;
                    g[1] = 10;
                    g[2] = 11;
                    g[3] = 9;
                }
                this.aaj = new LabelCollisionManager(this.wk.right, this.wk.bottom, this.wk, this.zz.j(), this.abi, this.aal(), g, this.abp(), this.abo(), this.aav, this.zo);
                if (this.ab9 != null) {
                    this.aaj.a7 = this.ab9;
                    this.aaj.a5 = this;
                }
                var j = this.aaj;
                j.labelsMoved = delegateCombine(j.labelsMoved, runOn(this, this.adb));
            }
        }
        if (this.aas) {
            this.aas = false;
            if (this.aaj.a3 > 2) {
                this.aaq = true;
            }
        }
        if (this.aat) {
            this.aat = false;
            if (this.abc > 5) {
                this.aaq = true;
            }
        }
        if (this.aar) {
            this.aar = false;
            this.aaj.bm(this.wk.right, this.wk.bottom, this.wk);
            this.aaq = 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.aa7.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.adc));
                this.aa7.h(r);
                this.aa4.removeItem(r.c);
                this.aaj.bl(r.c.c);
            }
            r = s;
        }
        for (var u = 0; u < b.count; u++) {
            if (!this.aa4.containsKey(b._inner[u])) {
                this.aa7.f(b._inner[u]);
                var v = b._inner[u].b;
                v.propertyChanged = delegateCombine(v.propertyChanged, runOn(this, this.adc));
                this.aa4.addItem(b._inner[u], this.aa7.d);
                m.add(b._inner[u]);
                k.add_1(b._inner[u]);
                this.aaq = true;
            }
        }
        for (var w = 0; w < c.count; w++) {
            if (!this.aa4.containsKey(c._inner[w])) {
                this.aa7.f(c._inner[w]);
                this.aa4.addItem(c._inner[w], this.aa7.d);
                var x = c._inner[w].b;
                x.propertyChanged = delegateCombine(x.propertyChanged, runOn(this, this.adc));
                m.add(c._inner[w]);
                k.add_1(c._inner[w]);
                this.aaq = true;
            }
        }
        if (this.aao == true) {
            this.aao = false;
            this.aaq = true;
        }
        var y = false;
        if (this.aa9.count > 0) {
            y = true;
            this.aa9.clear();
            this.aa6.clear();
        }
        r = this.aa7.c;
        while (r != null) {
            var z = this.aam(r.c);
            if (z == null) {
                return;
            }
            if (!Base.equalsStatic(z, r.c.c.e)) {
                var aa = false;
                if (r.c.c.e == null) {
                    aa = true;
                }
                var ab = r.c.c;
                ab.s = z.d;
                ab.t = z.e;
                if (!isNaN_(ab.s) && !isNaN_(ab.t)) {
                    ab.r = z.g;
                    ab.q = z.f;
                    if (ab.c == null) {
                        this.aaj.z(ab, false);
                    }
                    if (aa) {
                        this.aaj.a8(ab);
                    }
                    else {
                        this.aaj.bi(ab);
                    }
                }
            }
            r = r.a;
        }
        var ac = this.aaj.a4();
        var ad = this.aaj.ab();
        if (!this.aaq && y && (ac != 0 || ad)) {
            {
                this.aaq = true;
            }
        }
        if (ad) {
            if (this.aaj.t()) {
                this.aaq = true;
            }
        }
        if (this.aaq && (ac != 0 || ad)) {
            this.aaq = false;
            this.abl = 0x7FFFFFFF;
            if (this.ab9 != null) {
                var ae = true;
                for (var af = 0; af < this.c9.series.count; af++) {
                    var ag = this.c9.series._inner[af];
                    if (ag.eq && typeCast(CalloutLayer.$, ag) !== null) {
                        var ah = ag;
                        if (ah.ab9 == this.ab9) {
                            if (!ah.ae0.equals1(this.aaj.bu)) {
                                ae = false;
                                break;
                            }
                        }
                    }
                }
                if (ae) {
                    this.aaj.bp();
                }
                else {
                    this.aaj.a9();
                    this.aaj.ba();
                }
            }
            else {
                this.aaj.bp();
            }
        }
        else {
            this.aaj.ba();
        }
        var ai = this.aa7.c;
        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;
        var az = this.aaw;
        var a0 = this.ct.bt();
        while (ai != null) {
            var a1 = ai.c;
            var a2 = a1.b;
            aj = a2.bm;
            ak = a2.bp;
            al = a2.bo;
            am = a2.backgroundPadding.left;
            an = a2.backgroundPadding.top;
            ao = a2.backgroundPadding.right;
            ap = a2.backgroundPadding.bottom;
            ar = a2.backgroundCornerRadius;
            aq = a2.y;
            as = a2.bq;
            at = a2.ao;
            au = a2.aa;
            var a3 = a1.c;
            av = a3.s - (a3.k - a3.p);
            aw = a3.t - (a3.l - a3.o);
            ax = a3.k - a3.p;
            ay = a3.l - a3.o;
            if (a1.c.h) {
                av = NaN;
                aw = NaN;
            }
            if (!a1.c.h && (a1.c.b == 8 || a1.c.b == 9)) {
                al = a0;
                av = a3.k;
                aw = a3.l;
            }
            if (az) {
                var a4 = new CalloutRenderStyleUpdatingEventArgs();
                a4.background = aj;
                a4.outline = ak;
                a4.leaderBrush = al;
                a4.strokeThickness = aq;
                a4.textColor = as;
                a4.item = au;
                a4.series = a2.l;
                a4.actualPosition = a3.b;
                a4.xValue = a2.ac;
                a4.yValue = a2.ad;
                if (this.calloutRenderStyleUpdating != null) {
                    this.calloutRenderStyleUpdating(this, a4);
                    aj = a4.background;
                    ak = a4.outline;
                    al = a4.leaderBrush;
                    aq = a4.strokeThickness;
                    as = a4.textColor;
                }
            }
            a.n.add1(a1);
            a.f.add(aj);
            a.i.add(ak);
            a.h.add(al);
            a.k.add(am);
            a.m.add(an);
            a.l.add(ao);
            a.j.add(ap);
            a.g.add(ar);
            a.o.add(aq);
            a.p.add(as);
            a.q.add1(at);
            a.r.add1(au);
            a.u.add(av);
            a.v.add(aw);
            a.s.add(ax);
            a.t.add(ay);
            ai = ai.a;
        }
    };
    CalloutLayer.prototype.ade = function () {
        if (this.aaj != null) {
            var a = this.aa7.c;
            while (a != null) {
                var b = a.c.c;
                if (b != null) {
                    this.aaj.bl(b);
                }
                a = a.a;
            }
            var c = this.aaj;
            c.labelsMoved = delegateRemove(c.labelsMoved, runOn(this, this.adb));
            this.aaj = null;
        }
        this.add();
    };
    CalloutLayer.prototype.aak = function () {
        if (this.c9 == null) {
            return null;
        }
        for (var a = 0; a < this.c9.series.count; a++) {
            var b = this.c9.series._inner[a];
            if (b.eq && typeCast(CalloutLayer.$, b) !== null) {
                var c = b;
                if (c != this) {
                    if (c.ab9 != null && c.ab9 == this.ab9) {
                        if (c.aaj != null) {
                            return c.aaj;
                        }
                    }
                }
            }
        }
        return null;
    };
    CalloutLayer.prototype.abo = function () {
        return 20000;
    };
    CalloutLayer.prototype.abp = function () {
        return 300;
    };
    CalloutLayer.prototype.aal = function () {
        switch (this.zw) {
            case 0: return 2;
            case 2: return 1;
            case 3: return 2;
            case 1: return 0;
            case 4: return 3;
            case 7: return 7;
            case 5: return 5;
            case 6: return 6;
        }
        return 2;
    };
    CalloutLayer.prototype.adb = function (a) {
        var b = this.aaj.a4();
        var c = this.abl;
        if (b < this.abl) {
            this.abl = b;
            if (c != 0x7FFFFFFF) {
                this.rm(false);
            }
        }
    };
    CalloutLayer.prototype.aam = function (a) {
        var b = this.z6;
        if (a.b.l != null) {
            b = a.b.l;
        }
        if (b == null) {
            for (var c = 0; c < this.c9.series.count; c++) {
                var d = this.c9.series._inner[c];
                if (!d.eq) {
                    b = d;
                    break;
                }
            }
        }
        if (b == null) {
            return null;
        }
        var e = b.ai();
        var f = b.iw();
        var g = null;
        var h = null;
        var i = false;
        for (var j = 0; j < e.length; j++) {
            if (e[j].b9) {
                i = true;
                g = e[j];
            }
            else if (e[j].cm) {
                i = true;
                h = e[j];
            }
            else if (e[j].cp) {
                h = e[j];
            }
            else {
                g = e[j];
            }
        }
        if (g == null || h == null) {
            return null;
        }
        if (!g.co() || !h.co()) {
            return null;
        }
        var k = 0;
        var l = 0;
        if (g.cb && g.categoryMode != 0) {
            if (b.e4) {
                k = b.getOffsetValue();
            }
            else if (b.ew) {
                k = b.getOffsetValue();
            }
        }
        if (h.cb && h.categoryMode != 0) {
            if (b.ew) {
                l = b.getOffsetValue();
            }
        }
        var m = new ScalerParams(0, this.c9.vl, g.ke, g.ch, g.j9());
        m.b = f;
        var n = new ScalerParams(0, this.c9.vl, h.ke, h.ch, h.j9());
        n.b = f;
        var o = 0;
        var p = 0;
        if (i) {
            o = g.ek(this.abk(a.b.ac), m) + k;
            p = h.ek(this.abk(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.e(t, m.e, m.d, m.c);
            var u = s.y + (r * Math.sin(q));
            p = ViewportUtils.i(u, n.e, n.d, n.c);
        }
        else {
            o = g.ek(this.abk(a.b.ac), m) + k;
            p = h.ek(this.abk(a.b.ad), n) + l;
        }
        var v = new QuadTreeBoundingBox();
        v.d = o;
        v.e = p;
        v.g = 3;
        v.f = 3;
        v.i = a.b;
        return v;
    };
    CalloutLayer.prototype.abk = function (a) {
        if (typeCast(Date_$type, a) !== null) {
            return a.getTime();
        }
        if (a == null) {
            return 0;
        }
        return a;
    };
    CalloutLayer.prototype.abb = function () {
        var a = new List$1(CalloutAnnotationWrapper.$, 0);
        for (var b = 0; b < this.aba.count; b++) {
            if (stringIsNullOrEmpty(this.aba._inner[b].b.ao)) {
                continue;
            }
            if (this.aba._inner[b].c == null) {
                var c = new LabelCollisionInfo();
                this.aba._inner[b].c = c;
                var d = this.zz.cr(this.abq(this.aba._inner[b]), this.aba._inner[b].b.backgroundPadding);
                c.o = d.height / 2;
                c.p = d.width / 2;
            }
            var e = this.aam(this.aba._inner[b]);
            if (e == null || e.d < this.wk.left || e.d > this.wk.right || e.e < this.wk.top || e.e > this.wk.bottom) {
                continue;
            }
            a.add(this.aba._inner[b]);
        }
        return a;
    };
    CalloutLayer.prototype.abq = function (a) {
        return a.b.ao;
    };
    CalloutLayer.prototype.w9 = function (a) {
        if (!_super.prototype.w9.call(this, a)) {
            return false;
        }
        if (this.acs != null) {
            if (a.e9) {
                var b = a.m9();
                if (!Base.equalsStatic(this.acs, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.acs, a.name)) {
                    return false;
                }
            }
        }
        return true;
    };
    CalloutLayer.prototype.qk = function () {
        _super.prototype.qk.call(this);
        if (!this.a0.c && !this.d1()) {
            return;
        }
        if (this.aan) {
            this.aan = false;
            this.adg();
        }
        if (this.d1()) {
            this.adm(this.w4, false);
        }
        else {
            this.adm(this.w2, false);
        }
    };
    CalloutLayer.prototype.adh = function () {
        if (!this.aap) {
            this.aap = true;
            this.rm(true);
        }
    };
    CalloutLayer.prototype.adk = function (a, b, c) {
        var d = false;
        if (this.aap) {
            this.aap = false;
            d = true;
        }
        a.kg = this.zr;
        if (!a.gg && a.d9(this.aa8, this.aa3, this.aaz, this.abm)) {
            var e = this.aa8;
            var _loop_1 = function (f) {
                var g = e._inner[f];
                var h = g.b != null ? g.b.item : null;
                var i = g.b.item != null ? g.b.item : g.b;
                var j = g.g;
                var k = a;
                var l = new CalloutKey(i, k);
                var m = new CalloutAnnotationWrapper();
                var n = new CalloutAnnotation();
                m.b = n;
                n.key = l;
                var o = false;
                if (this_1.aa4.containsKey(m)) {
                    m = this_1.aa4.item(m).c;
                    n = m.b;
                    o = d;
                }
                else {
                    o = true;
                }
                var p = n.ac;
                var q = n.ad;
                if (this_1.abk(p) != this_1.abk(g.d) && (!isNaN_(this_1.abk(p)) || !isNaN_(this_1.abk(g.d)))) {
                    n.xValue = g.d;
                }
                if (this_1.abk(q) != this_1.abk(g.e) && (!isNaN_(this_1.abk(q)) || !isNaN_(this_1.abk(g.e)))) {
                    n.yValue = g.e;
                }
                n.itemColor = j;
                n.series = a;
                var r = false;
                if (g.f != n.az) {
                    n.az = g.f;
                    r = true;
                }
                if (o || r) {
                    if (this_1.calloutLabelUpdating != null) {
                        var s = ((function () {
                            var $ret = new CalloutLabelUpdatingEventArgs();
                            $ret.d = n.ac;
                            $ret.e = n.ad;
                            $ret.item = h;
                            $ret.a = a;
                            $ret.f = a.name;
                            return $ret;
                        })());
                        this_1.calloutLabelUpdating(this_1, s);
                        if (s.c != null && !Base.equalsStatic(s.c, m.b.ao)) {
                            var t = s.c;
                            if (this_1.zr != null) {
                                m.b.text = this_1.zr.i(t);
                            }
                            else {
                                m.b.text = t != null ? t.toString() : "";
                            }
                        }
                    }
                    else {
                        if (g.f != null) {
                            n.text = g.f;
                        }
                    }
                }
                if (n.ao == null) {
                    return "continue";
                }
                if (o || r) {
                    if (this_1.calloutContentUpdating != null) {
                        var u = ((function () {
                            var $ret = new CalloutContentUpdatingEventArgs();
                            $ret.c = n.ac;
                            $ret.d = n.ad;
                            $ret.item = h;
                            $ret.a = i;
                            return $ret;
                        })());
                        this_1.calloutContentUpdating(this_1, u);
                        if (u.a != null && u.a != m.b.aa) {
                            m.b.content = u.a;
                        }
                    }
                    else {
                        if (i != null && i != m.b.aa) {
                            m.b.content = i;
                        }
                    }
                }
                if (o) {
                    this_1.ado(m);
                }
                if (m.c == null) {
                    var v = new LabelCollisionInfo();
                    m.c = v;
                    var w = this_1.zz.cr(this_1.abq(m), m.b.backgroundPadding);
                    v.o = w.height / 2;
                    v.p = w.width / 2;
                }
                var x = this_1.aam(m);
                if (x == null || x.d < this_1.wk.left || x.d > this_1.wk.right || x.e < this_1.wk.top || x.e > this_1.wk.bottom) {
                    return "continue";
                }
                m.e = x.d;
                m.f = x.e;
                if (g.a != null) {
                    m.c.a = g.a;
                }
                c.add(m);
            };
            var this_1 = this;
            for (var f = 0; f < this.aa8.count; f++) {
                _loop_1(f);
            }
        }
        a.kg = null;
    };
    CalloutLayer.prototype.b0 = function () {
        return 1;
    };
    CalloutLayer.prototype.a1 = function (a, b) {
        var c = this.aaj.f(a, b);
        if (c == null) {
            return null;
        }
        return c.y;
    };
    CalloutLayer.prototype.gu = function (a, b) {
        if (this.aaj == null) {
            return false;
        }
        return this.aaj.f(a, b) != null;
    };
    CalloutLayer.prototype.adm = 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.zz.cb.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.ct.bt();
            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.zz.cj(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.zz.ck(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.zz.cb.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.zz.cb.h(h._inner[j]);
        }
    };
    CalloutLayer.prototype.yl = function (a, b) {
        _super.prototype.yl.call(this, a, b);
        if (this.d1()) {
            this.adm(this.w4, true);
        }
        else {
            this.adm(this.w2, false);
        }
    };
    CalloutLayer.prototype.f8 = function () {
        return true;
    };
    CalloutLayer.prototype.q4 = function (a, b, c, d) {
        _super.prototype.q4.call(this, a, b, c, d);
        switch (b) {
            case CalloutLayer.$$p[29]:
                this.z7 = null;
                this.zz.ci();
                this.rm(true);
                break;
            case CalloutLayer.$$p[27]:
            case CalloutLayer.$$p[28]:
                this.rm(true);
                break;
            case CalloutLayer.$$p[24]:
            case CalloutLayer.$$p[25]:
                if (this.acn != null) {
                    this.zr = new BindingFormatter();
                    this.zr.j = this.acn;
                    this.zr.d = this.zp;
                }
                else {
                    this.zr = null;
                }
                break;
            case CalloutLayer.$$p[16]:
            case CalloutLayer.$$p[18]:
                this.rm(true);
                break;
            case "SeriesViewer":
                if (c != null) {
                    var e = c;
                    e.seriesAnimating = delegateRemove(e.seriesAnimating, runOn(this, this.adl));
                }
                if (d != null) {
                    var f = d;
                    f.seriesAnimating = delegateCombine(f.seriesAnimating, runOn(this, this.adl));
                }
                if (d == null) {
                    this.ade();
                }
                break;
            case "AutoCalloutVisibilityMode":
                this.zt = this.zv();
                this.adf();
                break;
            case "AllowedPositions":
                if (c != null) {
                    var g = c;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.ac9));
                }
                if (d != null) {
                    var h = d;
                    h.collectionChanged = delegateCombine(h.collectionChanged, runOn(this, this.ac9));
                }
                this.zo = this.zq(this.z1);
                this.adf();
                break;
            case CalloutLayer.$$p[19]:
            case CalloutLayer.$$p[20]:
            case CalloutLayer.$$p[1]:
            case CalloutLayer.$$p[8]:
            case CalloutLayer.$$p[6]:
            case CalloutLayer.$$p[31]:
            case CalloutLayer.$$p[34]:
            case CalloutLayer.$$p[22]:
            case CalloutLayer.$$p[21]:
            case CalloutLayer.$$p[10]:
            case CalloutLayer.$$p[12]:
            case CalloutLayer.$$p[11]:
            case CalloutLayer.$$p[9]:
            case "Visibility":
            case CalloutLayer.$$p[14]:
            case CalloutLayer.$$p[15]:
            case CalloutLayer.$$p[2]:
                this.adf();
                break;
            case CalloutLayer.$$p[26]:
                if (this.dl != null) {
                    this.dl.deregisterColumn(this.aag);
                    this.aag = this.dk(this.acq);
                }
                break;
            case "LabelColumn":
                this.adf();
                break;
            case CalloutLayer.$$p[17]:
                if (this.dl != null) {
                    this.dl.deregisterColumn(this.aae);
                    this.aae = this.dk(this.acc);
                }
                break;
            case "ContentColumn":
                this.adf();
                break;
            case CalloutLayer.$$p[36]:
                if (this.dl != null) {
                    this.dl.deregisterColumn(this.aah);
                    this.aah = stringIsNullOrEmpty(this.ac4) == false ? this.dk(this.ac4) : null;
                }
                break;
            case "XColumn":
                this.adf();
                break;
            case CalloutLayer.$$p[37]:
                if (this.dl != null) {
                    this.dl.deregisterColumn(this.aai);
                    this.aai = this.dk(this.ac7);
                }
                break;
            case "YColumn":
                this.adf();
                break;
            case CalloutLayer.$$p[23]:
                if (this.dl != null) {
                    this.dl.deregisterColumn(this.aaf);
                    this.aaf = this.dk(this.ack);
                }
                break;
            case "KeyColumn":
                this.adf();
                break;
            case "FastItemsSource":
                this.aao = true;
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.aag);
                    c.deregisterColumn(this.aae);
                    c.deregisterColumn(this.aah);
                    c.deregisterColumn(this.aai);
                    c.deregisterColumn(this.aaf);
                    this.aag = null;
                    this.aae = null;
                    this.aah = null;
                    this.aai = null;
                    this.aaf = null;
                    this.aba.clear();
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.aag = this.dk(this.acq);
                    this.aae = this.dk(this.acc);
                    if (stringIsNullOrEmpty(this.ac4) == false) {
                        this.aah = this.dk(this.ac4);
                    }
                    this.aai = this.dk(this.ac7);
                    this.aaf = this.dk(this.ack);
                }
                this.adf();
                break;
        }
    };
    CalloutLayer.prototype.zv = function () {
        if (this.zu == 0) {
            return 1;
        }
        return this.zu;
    };
    CalloutLayer.prototype.zq = 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.adl = function (a) {
        if (a.eq) {
            return;
        }
        if ((a == this.z6 || this.z6 == null) && this.aau) {
            this.rm(false);
        }
    };
    CalloutLayer.prototype.adf = function () {
        if (this.aan == false) {
            this.aan = true;
            this.rm(false);
        }
    };
    CalloutLayer.prototype.add = function () {
        this.zz.cb.clear();
        this.aa7.g();
        this.aa4.clear();
    };
    CalloutLayer.prototype.adg = function () {
        if (this.aai == null || this.aag == null) {
            var a = this.aa7.c;
            while (a != null) {
                this.ado(a.c);
                a = a.a;
            }
            return;
        }
        var b = this.aa5();
        for (var c = 0; c < this.aai.count; c++) {
            var d = void 0;
            if (this.aba.count <= c) {
                var e = new CalloutAnnotation();
                d = new CalloutAnnotationWrapper();
                d.b = e;
                d.b.series = this.z6;
                this.aba.add(d);
            }
            else {
                d = this.aba._inner[c];
            }
            this.adn(c, b);
        }
    };
    CalloutLayer.$t = markType(CalloutLayer, 'CalloutLayer', AnnotationLayer.$);
    CalloutLayer.ad5 = 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:abm:adp', [1, 5], 'CalloutBackground:aes:adq', [Brush.$, null], 'CalloutCollisionMode:zw:adr', [CalloutCollisionMode_$type, enumGetBox(CalloutCollisionMode_$type, 3)], 'CalloutCornerRadius:abd:ads', [1, NaN], 'CalloutDarkTextColor:aet:adt', [Brush.$, null], 'CalloutInterpolatedValuePrecision:abn:adu', [1, -1], 'CalloutLeaderBrush:aeu:adv', [Brush.$, null], 'CalloutLightTextColor:aev:adw', [Brush.$, null], 'CalloutOutline:aew:adx', [Brush.$, null], 'CalloutPaddingBottom:abe:ady', [1, NaN], 'CalloutPaddingLeft:abf:adz', [1, NaN], 'CalloutPaddingRight:abg:ad0', [1, NaN], 'CalloutPaddingTop:abh:ad1', [1, NaN], 'CalloutPositionPadding:abi:ad2', [1, 10], 'CalloutStrokeThickness:abj:ad3', [1, NaN], 'CalloutTextColor:aex:ad4', [Brush.$, null], 'CollisionChannel:ab9:ad6', [2, null], 'ContentMemberPath:acc:ad7', [2, null], 'HighlightedValueLabelMode:z5:ad8', [HighlightedValueLabelMode_$type, enumGetBox(HighlightedValueLabelMode_$type, 0)], 'IsAutoCalloutBehaviorEnabled:aau:ad9', [0, false], 'IsCalloutOffsettingEnabled:aav:aea', [0, true], 'IsCustomCalloutRenderStyleEnabled:aaw:aeb', [0, false], 'IsCustomCalloutStyleEnabled:aax:aec', [0, false], 'KeyMemberPath:ack:aed', [2, null], 'LabelFormat:acn:aee', [2, null], 'LabelFormatSpecifiers:zp:aef', [Array_$type, null], 'LabelMemberPath:acq:aeg', [2, null], 'TargetSeriesName:acs:aeh', [2, null], 'TargetSeries:z6:aei', [Series.$, null], 'TextStyle:acv:aej', [2, null], 'UseAutoContrastingLabelColors:aay:aek', [0, false], 'UseInterpolatedValueForAutoCalloutLabels:aaz:ael', [0, false], 'UseItemColorForFill:aa0:aem', [0, false], 'UseItemColorForOutline:aa1:aen', [0, false], 'UseSeriesColorForOutline:aa2:aeo', [0, false], 'UseValueForAutoCalloutLabels:aa3:aep', [0, true], 'XMemberPath:ac4:aeq', [2, null], 'YMemberPath:ac7:aer', [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.b7 = null;
        _this.cc = null;
        _this.cb = null;
        _this.cd = NaN;
        _this.b8 = null;
        _this.b7 = a;
        _this.cc = new List$1(CalloutView.$, 0);
        return _this;
    }
    CalloutLayerView.prototype.au = function () {
        var _this = this;
        _super.prototype.au.call(this);
        this.cb = ((function () {
            var $ret = new HashPool$2(CalloutAnnotationWrapper.$, CalloutView.$);
            $ret.create = runOn(_this, _this.b9);
            $ret.activate = runOn(_this, _this.cf);
            $ret.disactivate = runOn(_this, _this.ch);
            $ret.destroy = runOn(_this, _this.cg);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.b9 = function () {
        var a = new CalloutView(this);
        this.cc.add(a);
        return a;
    };
    CalloutLayerView.prototype.cf = function (a) {
        a.y = 0;
    };
    CalloutLayerView.prototype.ch = function (a) {
        a.y = 1;
    };
    CalloutLayerView.prototype.cg = function (a) {
        this.cc.remove(a);
    };
    CalloutLayerView.prototype.cq = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.m(a, 0.1);
    };
    CalloutLayerView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        a.ad(this.ca());
        if (a.d && !b) {
            for (var c = 0; c < this.cc.count; c++) {
                var d = this.cc._inner[c];
                if (d.y == 0) {
                    d.j(a);
                }
            }
        }
    };
    CalloutLayerView.prototype.ca = function () {
        if (this.b7.z8 != null) {
            return this.b7.z8;
        }
        return this.e.c9.getFontInfo();
    };
    CalloutLayerView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
        for (var b = 0; b < this.cc.count; b++) {
            var c = this.cc._inner[b];
            if (c.y != 0) {
                continue;
            }
            c.i(this.b7, this.ca(), a);
        }
    };
    CalloutLayerView.prototype.cs = function (a) {
        this.k.ad(this.ca());
        this.cd = this.ce();
        var b = this.k.ah(a, this.cd, true);
        return new Size(1, b.c, b.b);
    };
    CalloutLayerView.prototype.ce = function () {
        var a = this.ca();
        if (isNaN_(this.cd)) {
            var b = FontUtil.getCurrentFontHeight(this.e.c9.c8.j.ae, a);
            this.cd = b;
        }
        return this.cd;
    };
    CalloutLayerView.prototype.cr = function (a, b) {
        if (this.b8 == null) {
            this.b8 = new CalloutView(this);
        }
        this.b8.h = a;
        this.b8.x = b;
        var c = this.b8.u();
        this.b8.h = null;
        return c;
    };
    CalloutLayerView.prototype.cj = function (a, b, c) {
        a.f = b;
        a.g = c;
    };
    CalloutLayerView.prototype.ck = function (a, b, c) {
        a.k(this.e, b, c);
    };
    CalloutLayerView.prototype.cl = function (a, b) {
        if (b != null && this.b7.aa0) {
            return this.cq(b);
        }
        if (a != null) {
            return this.cq(a.u9);
        }
        return this.e.u9;
    };
    CalloutLayerView.prototype.co = function () {
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 255, 255, 255);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.cm = function () {
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 0, 0, 0);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.cp = function (a, b) {
        if (b != null && this.b7.aa1) {
            return this.cq(b);
        }
        if (this.b7.aa2) {
            if (a != null) {
                return this.cq(a.u9);
            }
        }
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 255, 255, 255);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.cn = function (a, b) {
        if (b != null && this.b7.aa1) {
            return this.cq(b);
        }
        if (a != null) {
            return this.cq(a.u2);
        }
        return this.e.u2;
    };
    CalloutLayerView.prototype.ci = function () {
        this.cd = 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.cs(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.y = this.b;
        }
    };
    CalloutView.prototype.i = function (a, b, c) {
        a.bb.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 };
