/*
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 { 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
 */
export let CalloutLayer = /*@__PURE__*/ (() => {
    class CalloutLayer extends AnnotationLayer {
        bi() {
            return new CalloutLayer();
        }
        get_em() {
            return true;
        }
        constructor() {
            super();
            this.calloutStyleUpdating = null;
            this.calloutRenderStyleUpdating = null;
            this.aac = null;
            this.aad = null;
            this.aae = null;
            this.aab = null;
            this.aaa = null;
            this.aa7 = new HashSet$1(CalloutAnnotationWrapper.$, 0);
            this.aba = new List$1(CalloutAnnotationWrapper.$, 0);
            this.abb = new List$1(CalloutAnnotationWrapper.$, 0);
            this.z1 = null;
            this.zp = null;
            this.z8 = null;
            this.aa8 = new LinkedList$1(CalloutAnnotationWrapper.$);
            this.aa5 = new Dictionary$2(CalloutAnnotationWrapper.$, LinkedListNode$1.$.specialize(CalloutAnnotationWrapper.$), 0);
            this.aak = null;
            this.ae0 = new Rect(0, 0, 0, 1, 1);
            this.aar = false;
            this.abm = 0;
            this.aez = Rect.empty;
            this.aap = false;
            this.aaq = false;
            this.calloutContentUpdating = null;
            this.calloutLabelUpdating = null;
            this.calloutSeriesSelecting = null;
            this.aa9 = new List$1(SeriesPointOfInterest.$, 0);
            this.aat = false;
            this.aau = false;
            this.abd = 0;
            this.aas = false;
            this.zs = null;
            this.aao = true;
            this.zt = 1;
            FastItemObjectColumn.m();
            this.zp = null;
            this.z1 = new CalloutPlacementPositionsCollection();
            let a = this.z1;
            a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.ada));
            this.xc = true;
            let b = new CalloutLayerFrame();
            let c = new CalloutLayerFrame();
            let d = new CalloutLayerFrame();
            let e = this.kb / 1000;
            this.w4 = b;
            this.w3 = c;
            this.w5 = d;
            this.ab = CalloutLayer.$;
        }
        ada(a, b) {
            this.adj();
        }
        adj() {
            this.zp = this.zr(this.z2);
            this.adg();
        }
        adb(a, b) {
            this.abb.clear();
            this.rn(false);
        }
        o9(a, b, c, d) {
            super.o9(a, b, c, d);
            let e = this.aa6();
            switch (a) {
                case 3:
                    this.ado(b, e);
                    break;
                case 1:
                    for (let f = b; f < b + c; f++) {
                        let g = new CalloutAnnotation();
                        let h = new CalloutAnnotationWrapper();
                        h.b = g;
                        h.b.series = this.z7;
                        this.abb.insert(f, h);
                        this.ado(f, e);
                    }
                    break;
                case 0:
                    this.abb.v(b, c);
                    break;
                case 2:
                    for (let i = b; i < b + c; i++) {
                        this.ado(i, e);
                    }
                    break;
                case 4:
                    this.abb.clear();
                    for (let j = 0; j < this.dl.count; j++) {
                        let k = new CalloutAnnotation();
                        let l = new CalloutAnnotationWrapper();
                        l.b = k;
                        l.b.series = this.z7;
                        this.abb.add(l);
                        this.ado(j, e);
                    }
                    break;
            }
            this.rn(true);
        }
        gd(a) {
            return false;
        }
        aa6() {
            let a = new Dictionary$2(String_$type, Series.$, 0);
            if (this.c9 != null) {
                for (let b = 0; b < this.c9.series.count; b++) {
                    let c = this.c9.series._inner[b];
                    if (c.name != null && !a.containsKey(c.name)) {
                        a.addItem(c.name, c);
                    }
                }
            }
            return a;
        }
        ado(a, b) {
            if (this.aaj == null || this.aah == null) {
                return;
            }
            let c = a;
            if (this.aai != null) {
                c = this.aai.item(a);
            }
            let d = this.aaj.item(a);
            let e = this.aah.item(a);
            let f = this.abb._inner[a];
            if (this.aag != null) {
                if (f.b.ab != this.aag.item(a)) {
                    f.b.key = this.aag.item(a);
                }
            }
            if (this.aa5.containsKey(f)) {
                f.b = this.aa5.item(f).c.b;
            }
            f.b.xValue = c;
            f.b.yValue = d;
            if (this.calloutLabelUpdating != null) {
                let g = ((() => {
                    let $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)) {
                    let h = g.c;
                    if (this.zs != null) {
                        f.b.text = this.zs.i(h);
                    }
                    else {
                        f.b.text = h != null ? h.toString() : "";
                    }
                }
            }
            else {
                if (this.zs != null) {
                    f.b.text = this.zs.i(e);
                }
                else {
                    f.b.text = e != null ? e.toString() : "";
                }
            }
            if (this.aaf != null) {
                f.b.content = this.aaf.item(a);
            }
            else {
                f.b.content = this.dl.item(a);
            }
            if (this.calloutSeriesSelecting != null) {
                let i = ((() => {
                    let $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.adp(f);
        }
        adp(a) {
            let b = new Thickness(0, DeviceUtils.g(3));
            if (isNaN_(this.ae2.left) || isNaN_(this.ae2.top) || isNaN_(this.ae2.right) || isNaN_(this.ae2.bottom)) {
                b = new Thickness(0, DeviceUtils.g(3));
            }
            else {
                b = this.ae2;
            }
            let c = DeviceUtils.g(3);
            if (isNaN_(this.abe)) {
                c = DeviceUtils.g(3);
            }
            else {
                c = this.abe;
            }
            let d = this.aet != null && !this.aa1 ? this.aet : this.z0.cl(a.b.l, a.b.itemColor);
            let e = this.aey != null ? this.aey : null;
            let f = this.aew != null ? this.aew : this.z0.co();
            let g = this.aeu != null ? this.aeu : this.z0.cm();
            let h = this.aex != null && !this.aa2 ? this.aex : this.z0.cp(a.b.l, a.b.itemColor);
            let i = this.aev != null ? this.aev : this.z0.cn(a.b.l, a.b.itemColor);
            let j = isNaN_(this.abk) ? 0 : this.abk;
            if (e == null && (this.aaz || this.aew != null || this.aeu != null)) {
                let 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.z0.co();
            }
            if (this.aay && this.calloutStyleUpdating != null) {
                let 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;
        }
        ko(a, b) {
            let c = this.nb(b);
            if (c == CalloutLayer.$$p[26]) {
                return this.kp(a, b, this.acr);
            }
            if (c == CalloutLayer.$$p[36]) {
                return this.kp(a, b, this.ac5);
            }
            if (c == CalloutLayer.$$p[37]) {
                return this.kp(a, b, this.ac8);
            }
            if (c == CalloutLayer.$$p[23]) {
                return this.kp(a, b, this.acl);
            }
            if (c == CalloutLayer.$$p[17]) {
                return this.kp(a, b, this.acd);
            }
            return super.ko(a, b);
        }
        mb(a) {
            let b = this.nb(a);
            if (b == CalloutLayer.$$p[26]) {
                return this.acr;
            }
            if (b == CalloutLayer.$$p[36]) {
                return this.ac5;
            }
            if (b == CalloutLayer.$$p[37]) {
                return this.ac8;
            }
            if (b == CalloutLayer.$$p[23]) {
                return this.acl;
            }
            if (b == CalloutLayer.$$p[17]) {
                return this.acd;
            }
            return super.mb(a);
        }
        get aah() {
            return this.aac;
        }
        set aah(a) {
            if (this.aac != a) {
                let b = this.aac;
                this.aac = a;
                this.raisePropertyChanged("LabelColumn", b, this.aac);
            }
        }
        get aai() {
            return this.aad;
        }
        set aai(a) {
            if (this.aad != a) {
                let b = this.aad;
                this.aad = a;
                this.raisePropertyChanged("XColumn", b, this.aad);
            }
        }
        get aaj() {
            return this.aae;
        }
        set aaj(a) {
            if (this.aae != a) {
                let b = this.aae;
                this.aae = a;
                this.raisePropertyChanged("YColumn", b, this.aae);
            }
        }
        get aag() {
            return this.aab;
        }
        set aag(a) {
            if (this.aab != a) {
                let b = this.aab;
                this.aab = a;
                this.raisePropertyChanged("KeyColumn", b, this.aab);
            }
        }
        get aaf() {
            return this.aaa;
        }
        set aaf(a) {
            if (this.aaa != a) {
                let b = this.aaa;
                this.aaa = a;
                this.raisePropertyChanged("ContentColumn", b, this.aaa);
            }
        }
        add(a, b) {
            if (b.propertyName == CalloutAnnotation.$$p[15] || b.propertyName == CalloutAnnotation.$$p[16]) {
                let c = a.k;
                if (!this.aa7.contains(c)) {
                    this.aa7.add_1(c);
                    this.aba.add(c);
                    this.rn(false);
                }
            }
        }
        cq() {
            return new CalloutLayerView(this);
        }
        qx(a) {
            super.qx(a);
            this.z0 = a;
        }
        get z2() {
            return this.z1;
        }
        set z2(a) {
            let b = this.z2;
            if (a != b) {
                this.z1 = a;
                this.raisePropertyChanged("AllowedPositions", b, this.z2);
            }
        }
        gs(a) {
            if (this.z7 == null) {
                return true;
            }
            if (this.z7 == a) {
                return true;
            }
            return false;
        }
        get zv() {
            return EnumUtil.getEnumValue(AutoCalloutVisibilityMode_$type, this.c(CalloutLayer.ad6));
        }
        set zv(a) {
            this.h(CalloutLayer.ad6, enumGetBox(AutoCalloutVisibilityMode_$type, a));
        }
        get zu() {
            return this.zt;
        }
        set zu(a) {
            this.zt = a;
        }
        get ae2() {
            return new Thickness(1, this.abg, this.abi, this.abh, this.abf);
        }
        get z9() {
            if (this.z8 == null) {
                this.z8 = FontUtil.toFontInfo(this.jx, this.acw);
            }
            return this.z8;
        }
        yh(a, b) {
            if (this.z7 == null || this.z7 == a) {
                if (!this.a0.c) {
                    this.rn(b);
                }
            }
        }
        yj(a, b) {
            super.yj(a, b);
            let 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();
            let d = this.abc();
            let e = new List$1(CalloutAnnotationWrapper.$, 0);
            let f = true;
            if (this.aav) {
                if (this.xa(this.z7)) {
                    this.adl(this.z7, c, e);
                }
                else {
                    for (let g of fromEnum(this.c9.series)) {
                        if (this.xa(g)) {
                            if (!g.eq) {
                                if (!g.isVertical) {
                                    f = false;
                                }
                            }
                            let h = false;
                            if (g.ee && this.z6 == 0 || this.z6 == 3 || this.z6 == 2) {
                                if (this.z6 == 0 || this.z6 == 2) {
                                    h = true;
                                }
                                g.px((i) => {
                                    this.adl(i, c, e);
                                    return true;
                                });
                            }
                            if (!h) {
                                this.adl(g, c, e);
                            }
                        }
                    }
                }
            }
            if (this.aav && this.zu == 2) {
                let i = 0;
                let j = 0;
                let k = 1.7976931348623157E+308;
                let l = 1.7976931348623157E+308;
                let m = -1.7976931348623157E+308;
                let 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 (let o = 0; o < e.count; o++) {
                        let p = e._inner[o];
                        if (p.c != null) {
                            let q = p.e;
                            let 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.adk(c, d, e);
        }
        sl(a, b) {
            super.sl(a, b);
            let c = b.width - this.ae0.width;
            let d = b.height - this.ae0.height;
            let e = 0;
            if (Math.abs(c) > Math.abs(d)) {
                e = c;
                this.abd = c * this.wl.width;
            }
            else {
                e = d;
                this.abd = d * this.wl.height;
            }
            if (e > 0 && this.abd > 5) {
                this.aau = true;
            }
            if (e < 0 && this.abd > 5) {
                this.aat = true;
            }
        }
        sk(a, b) {
            super.sk(a, b);
            if (!a.equals1(b)) {
                this.aas = true;
            }
        }
        get ae1() {
            return this.aez;
        }
        set ae1(a) {
            this.aez = a;
        }
        adk(a, b, c) {
            if (this.c9 != null) {
                this.ae0 = this.c9.vl;
            }
            if (this.wl.isEmpty) {
                return;
            }
            this.ae1 = new Rect(0, this.wl.left, this.wl.top, this.wl.width, this.wl.height);
            if (this.aak != null && this.aca != null && this.aca != this.aak.a7) {
                this.adf();
            }
            if (this.aak != null && this.aak.g != this.aam()) {
                this.adf();
            }
            if (this.aak == null) {
                let d = this.aal();
                if (d != null) {
                    this.aak = d;
                    let e = this.aak;
                    e.labelsMoved = delegateCombine(e.labelsMoved, runOn(this, this.adc));
                }
                else {
                    let f = this.wd(this.ct);
                    let g = new Array(2);
                    g[0] = 0;
                    g[1] = 3;
                    if (this.z7 != null) {
                        if (this.z7.isVertical) {
                            g = new Array(2);
                            g[0] = 2;
                            g[1] = 1;
                        }
                    }
                    else {
                        let h = false;
                        if (this.c9 != null && this.c9.series.count > 0) {
                            h = true;
                            for (let i of fromEnum(this.c9.series)) {
                                if (!i.eq) {
                                    if (!i.isVertical) {
                                        h = false;
                                    }
                                }
                            }
                        }
                        if (h) {
                            g = new Array(2);
                            g[0] = 2;
                            g[1] = 1;
                        }
                    }
                    if (this.zx == 4 || this.zx == 6) {
                        g = new Array(4);
                        g[0] = 10;
                        g[1] = 11;
                        g[2] = 8;
                        g[3] = 9;
                    }
                    if (this.zx == 5) {
                        g = new Array(4);
                        g[0] = 9;
                        g[1] = 10;
                        g[2] = 11;
                        g[3] = 8;
                    }
                    if (this.zx == 7) {
                        g = new Array(4);
                        g = new Array(4);
                        g[0] = 8;
                        g[1] = 10;
                        g[2] = 11;
                        g[3] = 9;
                    }
                    this.aak = new LabelCollisionManager(this.wl.right, this.wl.bottom, this.wl, this.z0.j(), this.abj, this.aam(), g, this.abq(), this.abp(), this.aaw, this.zp);
                    if (this.aca != null) {
                        this.aak.a7 = this.aca;
                        this.aak.a5 = this;
                    }
                    let j = this.aak;
                    j.labelsMoved = delegateCombine(j.labelsMoved, runOn(this, this.adc));
                }
            }
            if (this.aat) {
                this.aat = false;
                if (this.aak.a3 > 2) {
                    this.aar = true;
                }
            }
            if (this.aau) {
                this.aau = false;
                if (this.abd > 5) {
                    this.aar = true;
                }
            }
            if (this.aas) {
                this.aas = false;
                this.aak.bm(this.wl.right, this.wl.bottom, this.wl);
                this.aar = true;
            }
            let k = new HashSet$1(CalloutAnnotationWrapper.$, 0);
            let l = new HashSet$1(CalloutAnnotationWrapper.$, 0);
            let m = new List$1(CalloutAnnotationWrapper.$, 0);
            let n = new List$1(CalloutAnnotationWrapper.$, 0);
            let o = new HashSet$1(CalloutAnnotationWrapper.$, 0);
            for (let p = 0; p < b.count; p++) {
                o.add_1(b._inner[p]);
            }
            for (let q = 0; q < c.count; q++) {
                o.add_1(c._inner[q]);
            }
            let r = this.aa8.c;
            while (r != null) {
                let s = r.a;
                if (!o.contains(r.c)) {
                    n.add(r.c);
                    l.add_1(r.c);
                    let t = r.c.b;
                    t.propertyChanged = delegateRemove(t.propertyChanged, runOn(this, this.add));
                    this.aa8.h(r);
                    this.aa5.removeItem(r.c);
                    this.aak.bl(r.c.c);
                }
                r = s;
            }
            for (let u = 0; u < b.count; u++) {
                if (!this.aa5.containsKey(b._inner[u])) {
                    this.aa8.f(b._inner[u]);
                    let v = b._inner[u].b;
                    v.propertyChanged = delegateCombine(v.propertyChanged, runOn(this, this.add));
                    this.aa5.addItem(b._inner[u], this.aa8.d);
                    m.add(b._inner[u]);
                    k.add_1(b._inner[u]);
                    this.aar = true;
                }
            }
            for (let w = 0; w < c.count; w++) {
                if (!this.aa5.containsKey(c._inner[w])) {
                    this.aa8.f(c._inner[w]);
                    this.aa5.addItem(c._inner[w], this.aa8.d);
                    let x = c._inner[w].b;
                    x.propertyChanged = delegateCombine(x.propertyChanged, runOn(this, this.add));
                    m.add(c._inner[w]);
                    k.add_1(c._inner[w]);
                    this.aar = true;
                }
            }
            if (this.aap == true) {
                this.aap = false;
                this.aar = true;
            }
            let y = false;
            if (this.aba.count > 0) {
                y = true;
                this.aba.clear();
                this.aa7.clear();
            }
            r = this.aa8.c;
            while (r != null) {
                let z = this.aan(r.c);
                if (z == null) {
                    return;
                }
                if (!Base.equalsStatic(z, r.c.c.e)) {
                    let aa = false;
                    if (r.c.c.e == null) {
                        aa = true;
                    }
                    let 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.aak.z(ab, false);
                        }
                        if (aa) {
                            this.aak.a8(ab);
                        }
                        else {
                            this.aak.bi(ab);
                        }
                    }
                }
                r = r.a;
            }
            let ac = this.aak.a4();
            let ad = this.aak.ab();
            if (!this.aar && y && (ac != 0 || ad)) {
                {
                    this.aar = true;
                }
            }
            if (ad) {
                if (this.aak.t()) {
                    this.aar = true;
                }
            }
            if (this.aar && (ac != 0 || ad)) {
                this.aar = false;
                this.abm = 0x7FFFFFFF;
                if (this.aca != null) {
                    let ae = true;
                    for (let af = 0; af < this.c9.series.count; af++) {
                        let ag = this.c9.series._inner[af];
                        if (ag.eq && typeCast(CalloutLayer.$, ag) !== null) {
                            let ah = ag;
                            if (ah.aca == this.aca) {
                                if (!ah.ae1.equals1(this.aak.bu)) {
                                    ae = false;
                                    break;
                                }
                            }
                        }
                    }
                    if (ae) {
                        this.aak.bp();
                    }
                    else {
                        this.aak.a9();
                        this.aak.ba();
                    }
                }
                else {
                    this.aak.bp();
                }
            }
            else {
                this.aak.ba();
            }
            let ai = this.aa8.c;
            let aj;
            let ak;
            let al;
            let am;
            let an;
            let ao;
            let ap;
            let aq;
            let ar;
            let as;
            let at;
            let au;
            let av;
            let aw;
            let ax;
            let ay;
            let az = this.aax;
            let a0 = this.ct.bt();
            while (ai != null) {
                let a1 = ai.c;
                let 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;
                let 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) {
                    let 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;
            }
        }
        adf() {
            if (this.aak != null) {
                let a = this.aa8.c;
                while (a != null) {
                    let b = a.c.c;
                    if (b != null) {
                        this.aak.bl(b);
                    }
                    a = a.a;
                }
                let c = this.aak;
                c.labelsMoved = delegateRemove(c.labelsMoved, runOn(this, this.adc));
                this.aak = null;
            }
            this.ade();
        }
        aal() {
            if (this.c9 == null) {
                return null;
            }
            for (let a = 0; a < this.c9.series.count; a++) {
                let b = this.c9.series._inner[a];
                if (b.eq && typeCast(CalloutLayer.$, b) !== null) {
                    let c = b;
                    if (c != this) {
                        if (c.aca != null && c.aca == this.aca) {
                            if (c.aak != null) {
                                return c.aak;
                            }
                        }
                    }
                }
            }
            return null;
        }
        abp() {
            return 20000;
        }
        abq() {
            return 300;
        }
        aam() {
            switch (this.zx) {
                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;
        }
        adc(a) {
            let b = this.aak.a4();
            let c = this.abm;
            if (b < this.abm) {
                this.abm = b;
                if (c != 0x7FFFFFFF) {
                    this.rn(false);
                }
            }
        }
        aan(a) {
            let b = this.z7;
            if (a.b.l != null) {
                b = a.b.l;
            }
            if (b == null) {
                for (let c = 0; c < this.c9.series.count; c++) {
                    let d = this.c9.series._inner[c];
                    if (!d.eq) {
                        b = d;
                        break;
                    }
                }
            }
            if (b == null) {
                return null;
            }
            let e = b.ai();
            let f = b.iw();
            let g = null;
            let h = null;
            let i = false;
            for (let j = 0; j < e.length; j++) {
                if (e[j] == null) {
                    continue;
                }
                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;
            }
            let k = 0;
            let 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();
                }
            }
            let m = new ScalerParams(0, this.c9.vl, g.ke, g.ch, g.j9());
            m.b = f;
            let n = new ScalerParams(0, this.c9.vl, h.ke, h.ch, h.j9());
            n.b = f;
            let o = 0;
            let p = 0;
            if (i) {
                o = g.ek(this.abl(a.b.ac), m) + k;
                p = h.ek(this.abl(a.b.ad), n) + l;
                let q = o;
                let r = p;
                let s = { $type: Point_$type, x: 0.5, y: 0.5 };
                let t = s.x + (r * Math.cos(q));
                o = ViewportUtils.e(t, m.e, m.d, m.c);
                let u = s.y + (r * Math.sin(q));
                p = ViewportUtils.i(u, n.e, n.d, n.c);
            }
            else {
                o = g.ek(this.abl(a.b.ac), m) + k;
                p = h.ek(this.abl(a.b.ad), n) + l;
            }
            let v = new QuadTreeBoundingBox();
            v.d = o;
            v.e = p;
            v.g = 3;
            v.f = 3;
            v.i = a.b;
            return v;
        }
        abl(a) {
            if (typeCast(Date_$type, a) !== null) {
                return a.getTime();
            }
            if (a == null) {
                return 0;
            }
            return a;
        }
        abc() {
            let a = new List$1(CalloutAnnotationWrapper.$, 0);
            for (let b = 0; b < this.abb.count; b++) {
                if (stringIsNullOrEmpty(this.abb._inner[b].b.ao)) {
                    continue;
                }
                if (this.abb._inner[b].c == null) {
                    let c = new LabelCollisionInfo();
                    this.abb._inner[b].c = c;
                    let d = this.z0.cr(this.abr(this.abb._inner[b]), this.abb._inner[b].b.backgroundPadding);
                    c.o = d.height / 2;
                    c.p = d.width / 2;
                }
                let e = this.aan(this.abb._inner[b]);
                if (e == null || e.d < this.wl.left || e.d > this.wl.right || e.e < this.wl.top || e.e > this.wl.bottom) {
                    continue;
                }
                a.add(this.abb._inner[b]);
            }
            return a;
        }
        abr(a) {
            return a.b.ao;
        }
        xa(a) {
            if (!super.xa(a)) {
                return false;
            }
            if (this.act != null) {
                if (a.e9) {
                    let b = a.na();
                    if (!Base.equalsStatic(this.act, b)) {
                        return false;
                    }
                }
                else {
                    if (!Base.equalsStatic(this.act, a.name)) {
                        return false;
                    }
                }
            }
            return true;
        }
        ql() {
            super.ql();
            if (!this.a0.c && !this.d1()) {
                return;
            }
            if (this.aao) {
                this.aao = false;
                this.adh();
            }
            if (this.d1()) {
                this.adn(this.w5, false);
            }
            else {
                this.adn(this.w3, false);
            }
        }
        adi() {
            if (!this.aaq) {
                this.aaq = true;
                this.rn(true);
            }
        }
        adl(a, b, c) {
            let d = false;
            if (this.aaq) {
                this.aaq = false;
                d = true;
            }
            a.kg = this.zs;
            if (!a.gg && a.d9(this.aa9, this.aa4, this.aa0, this.abn)) {
                let e = this.aa9;
                for (let f = 0; f < this.aa9.count; f++) {
                    let g = e._inner[f];
                    let h = g.b != null ? g.b.item : null;
                    let i = g.b.item != null ? g.b.item : g.b;
                    let j = g.g;
                    let k = a;
                    let l = new CalloutKey(i, k);
                    let m = new CalloutAnnotationWrapper();
                    let n = new CalloutAnnotation();
                    m.b = n;
                    n.key = l;
                    let o = false;
                    if (this.aa5.containsKey(m)) {
                        m = this.aa5.item(m).c;
                        n = m.b;
                        o = d;
                    }
                    else {
                        o = true;
                    }
                    let p = n.ac;
                    let q = n.ad;
                    if (this.abl(p) != this.abl(g.d) && (!isNaN_(this.abl(p)) || !isNaN_(this.abl(g.d)))) {
                        n.xValue = g.d;
                    }
                    if (this.abl(q) != this.abl(g.e) && (!isNaN_(this.abl(q)) || !isNaN_(this.abl(g.e)))) {
                        n.yValue = g.e;
                    }
                    n.itemColor = j;
                    n.series = a;
                    let r = false;
                    if (g.f != n.az) {
                        n.az = g.f;
                        r = true;
                    }
                    if (o || r) {
                        if (this.calloutLabelUpdating != null) {
                            let s = ((() => {
                                let $ret = new CalloutLabelUpdatingEventArgs();
                                $ret.d = n.ac;
                                $ret.e = n.ad;
                                $ret.item = h;
                                $ret.a = a;
                                $ret.f = a.name;
                                return $ret;
                            })());
                            this.calloutLabelUpdating(this, s);
                            if (s.c != null && !Base.equalsStatic(s.c, m.b.ao)) {
                                let t = s.c;
                                if (this.zs != null) {
                                    m.b.text = this.zs.i(t);
                                }
                                else {
                                    m.b.text = t != null ? t.toString() : "";
                                }
                            }
                        }
                        else {
                            if (g.f != null) {
                                n.text = g.f;
                            }
                        }
                    }
                    if (n.ao == null) {
                        continue;
                    }
                    if (o || r) {
                        if (this.calloutContentUpdating != null) {
                            let u = ((() => {
                                let $ret = new CalloutContentUpdatingEventArgs();
                                $ret.c = n.ac;
                                $ret.d = n.ad;
                                $ret.item = h;
                                $ret.a = i;
                                return $ret;
                            })());
                            this.calloutContentUpdating(this, 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.adp(m);
                    }
                    if (m.c == null) {
                        let v = new LabelCollisionInfo();
                        m.c = v;
                        let w = this.z0.cr(this.abr(m), m.b.backgroundPadding);
                        v.o = w.height / 2;
                        v.p = w.width / 2;
                    }
                    let x = this.aan(m);
                    if (x == null || x.d < this.wl.left || x.d > this.wl.right || x.e < this.wl.top || x.e > this.wl.bottom) {
                        continue;
                    }
                    m.e = x.d;
                    m.f = x.e;
                    if (g.a != null) {
                        m.c.a = g.a;
                    }
                    c.add(m);
                }
            }
            a.kg = null;
        }
        b0() {
            return 1;
        }
        a1(a, b) {
            let c = this.aak.f(a, b);
            if (c == null) {
                return null;
            }
            return c.y;
        }
        gu(a, b) {
            if (this.aak == null) {
                return false;
            }
            return this.aak.f(a, b) != null;
        }
        adn(a, b) {
            let c = 0;
            let d = new HashSet$1(CalloutAnnotationWrapper.$, 0);
            for (c = 0; c < a.q.count; c++) {
                let e = a.n._inner[c];
                if (isNaN_(a.u._inner[c]) || isNaN_(a.v._inner[c])) {
                    continue;
                }
                let f = this.z0.cb.item(e);
                d.add_1(e);
                if (f.h != a.q._inner[c]) {
                    f.h = a.q._inner[c];
                    let 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.z0.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.z0.ck(f, e, a.r._inner[c]);
                f.r = { $type: Point_$type, x: a.u._inner[c], y: a.v._inner[c] };
            }
            let h = new List$1(CalloutAnnotationWrapper.$, 0);
            for (let i of fromEnum(this.z0.cb.c)) {
                if (!d.contains(i)) {
                    h.add(i);
                }
            }
            for (let j = 0; j < h.count; j++) {
                this.z0.cb.h(h._inner[j]);
            }
        }
        ym(a, b) {
            super.ym(a, b);
            if (this.d1()) {
                this.adn(this.w5, true);
            }
            else {
                this.adn(this.w3, false);
            }
        }
        f8() {
            return true;
        }
        q5(a, b, c, d) {
            super.q5(a, b, c, d);
            switch (b) {
                case CalloutLayer.$$p[29]:
                    this.z8 = null;
                    this.z0.ci();
                    this.rn(true);
                    break;
                case CalloutLayer.$$p[27]:
                case CalloutLayer.$$p[28]:
                    this.rn(true);
                    break;
                case CalloutLayer.$$p[24]:
                case CalloutLayer.$$p[25]:
                    if (this.aco != null) {
                        this.zs = new BindingFormatter();
                        this.zs.j = this.aco;
                        this.zs.d = this.zq;
                    }
                    else {
                        this.zs = null;
                    }
                    break;
                case CalloutLayer.$$p[16]:
                case CalloutLayer.$$p[18]:
                    this.rn(true);
                    break;
                case "SeriesViewer":
                    if (c != null) {
                        let e = c;
                        e.seriesAnimating = delegateRemove(e.seriesAnimating, runOn(this, this.adm));
                    }
                    if (d != null) {
                        let f = d;
                        f.seriesAnimating = delegateCombine(f.seriesAnimating, runOn(this, this.adm));
                    }
                    if (d == null) {
                        this.adf();
                    }
                    break;
                case "AutoCalloutVisibilityMode":
                    this.zu = this.zw();
                    this.adg();
                    break;
                case "AllowedPositions":
                    if (c != null) {
                        let g = c;
                        g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.ada));
                    }
                    if (d != null) {
                        let h = d;
                        h.collectionChanged = delegateCombine(h.collectionChanged, runOn(this, this.ada));
                    }
                    this.zp = this.zr(this.z2);
                    this.adg();
                    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.adg();
                    break;
                case CalloutLayer.$$p[26]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.aah);
                        this.aah = this.dk(this.acr);
                    }
                    break;
                case "LabelColumn":
                    this.adg();
                    break;
                case CalloutLayer.$$p[17]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.aaf);
                        this.aaf = this.dk(this.acd);
                    }
                    break;
                case "ContentColumn":
                    this.adg();
                    break;
                case CalloutLayer.$$p[36]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.aai);
                        this.aai = stringIsNullOrEmpty(this.ac5) == false ? this.dk(this.ac5) : null;
                    }
                    break;
                case "XColumn":
                    this.adg();
                    break;
                case CalloutLayer.$$p[37]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.aaj);
                        this.aaj = this.dk(this.ac8);
                    }
                    break;
                case "YColumn":
                    this.adg();
                    break;
                case CalloutLayer.$$p[23]:
                    if (this.dl != null) {
                        this.dl.deregisterColumn(this.aag);
                        this.aag = this.dk(this.acl);
                    }
                    break;
                case "KeyColumn":
                    this.adg();
                    break;
                case "FastItemsSource":
                    this.aap = true;
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.aah);
                        c.deregisterColumn(this.aaf);
                        c.deregisterColumn(this.aai);
                        c.deregisterColumn(this.aaj);
                        c.deregisterColumn(this.aag);
                        this.aah = null;
                        this.aaf = null;
                        this.aai = null;
                        this.aaj = null;
                        this.aag = null;
                        this.abb.clear();
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.aah = this.dk(this.acr);
                        this.aaf = this.dk(this.acd);
                        if (stringIsNullOrEmpty(this.ac5) == false) {
                            this.aai = this.dk(this.ac5);
                        }
                        this.aaj = this.dk(this.ac8);
                        this.aag = this.dk(this.acl);
                    }
                    this.adg();
                    break;
            }
        }
        zw() {
            if (this.zv == 0) {
                return 1;
            }
            return this.zv;
        }
        zr(a) {
            if (a == null || a.count == 0) {
                return null;
            }
            let b = new Array(a.count);
            for (let c = 0; c < a.count; c++) {
                b[c] = a._inner[c];
            }
            return b;
        }
        adm(a) {
            if (a.eq) {
                return;
            }
            if ((a == this.z7 || this.z7 == null) && this.aav) {
                this.rn(false);
            }
        }
        adg() {
            if (this.aao == false) {
                this.aao = true;
                this.rn(false);
            }
        }
        ade() {
            this.z0.cb.clear();
            this.aa8.g();
            this.aa5.clear();
        }
        adh() {
            if (this.aaj == null || this.aah == null) {
                let a = this.aa8.c;
                while (a != null) {
                    this.adp(a.c);
                    a = a.a;
                }
                return;
            }
            let b = this.aa6();
            for (let c = 0; c < this.aaj.count; c++) {
                let d;
                if (this.abb.count <= c) {
                    let e = new CalloutAnnotation();
                    d = new CalloutAnnotationWrapper();
                    d.b = e;
                    d.b.series = this.z7;
                    this.abb.add(d);
                }
                else {
                    d = this.abb._inner[c];
                }
                this.ado(c, b);
            }
        }
    }
    CalloutLayer.$t = /*@__PURE__*/ markType(CalloutLayer, 'CalloutLayer', AnnotationLayer.$);
    CalloutLayer.ad6 = /*@__PURE__*/ DependencyProperty.i("AutoCalloutVisibilityMode", AutoCalloutVisibilityMode_$type, CalloutLayer.$, /*@__PURE__*/ new PropertyMetadata(2, /*@__PURE__*/ enumGetBox(AutoCalloutVisibilityMode_$type, 0), (a, b) => a.raisePropertyChanged("AutoCalloutVisibilityMode", b.oldValue, b.newValue)));
    CalloutLayer.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CalloutLayer, 'raisePropertyChanged', ['AutoCalloutLabelPrecision:abn:adq', [1, 5], 'CalloutBackground:aet:adr', [Brush.$, null], 'CalloutCollisionMode:zx:ads', [CalloutCollisionMode_$type, /*@__PURE__*/ enumGetBox(CalloutCollisionMode_$type, 3)], 'CalloutCornerRadius:abe:adt', [1, NaN], 'CalloutDarkTextColor:aeu:adu', [Brush.$, null], 'CalloutInterpolatedValuePrecision:abo:adv', [1, -1], 'CalloutLeaderBrush:aev:adw', [Brush.$, null], 'CalloutLightTextColor:aew:adx', [Brush.$, null], 'CalloutOutline:aex:ady', [Brush.$, null], 'CalloutPaddingBottom:abf:adz', [1, NaN], 'CalloutPaddingLeft:abg:ad0', [1, NaN], 'CalloutPaddingRight:abh:ad1', [1, NaN], 'CalloutPaddingTop:abi:ad2', [1, NaN], 'CalloutPositionPadding:abj:ad3', [1, 10], 'CalloutStrokeThickness:abk:ad4', [1, NaN], 'CalloutTextColor:aey:ad5', [Brush.$, null], 'CollisionChannel:aca:ad7', [2, null], 'ContentMemberPath:acd:ad8', [2, null], 'HighlightedValueLabelMode:z6:ad9', [HighlightedValueLabelMode_$type, /*@__PURE__*/ enumGetBox(HighlightedValueLabelMode_$type, 0)], 'IsAutoCalloutBehaviorEnabled:aav:aea', [0, false], 'IsCalloutOffsettingEnabled:aaw:aeb', [0, true], 'IsCustomCalloutRenderStyleEnabled:aax:aec', [0, false], 'IsCustomCalloutStyleEnabled:aay:aed', [0, false], 'KeyMemberPath:acl:aee', [2, null], 'LabelFormat:aco:aef', [2, null], 'LabelFormatSpecifiers:zq:aeg', [Array_$type, null], 'LabelMemberPath:acr:aeh', [2, null], 'TargetSeriesName:act:aei', [2, null], 'TargetSeries:z7:aej', [Series.$, null], 'TextStyle:acw:aek', [2, null], 'UseAutoContrastingLabelColors:aaz:ael', [0, false], 'UseInterpolatedValueForAutoCalloutLabels:aa0:aem', [0, false], 'UseItemColorForFill:aa1:aen', [0, false], 'UseItemColorForOutline:aa2:aeo', [0, false], 'UseSeriesColorForOutline:aa3:aep', [0, false], 'UseValueForAutoCalloutLabels:aa4:aeq', [0, true], 'XMemberPath:ac5:aer', [2, null], 'YMemberPath:ac8:aes', [2, null]]);
    return CalloutLayer;
})();
/**
 * @hidden
 */
export let CalloutLayerView = /*@__PURE__*/ (() => {
    class CalloutLayerView extends AnnotationLayerView {
        constructor(a) {
            super(a);
            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);
        }
        au() {
            super.au();
            this.cb = ((() => {
                let $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;
            })());
        }
        b9() {
            let a = new CalloutView(this);
            this.cc.add(a);
            return a;
        }
        cf(a) {
            a.y = 0;
        }
        ch(a) {
            a.y = 1;
        }
        cg(a) {
            this.cc.remove(a);
        }
        cq(a) {
            if (a == null) {
                return a;
            }
            return BrushUtil.m(a, 0.1);
        }
        a8(a, b) {
            super.a8(a, b);
            a.ad(this.ca());
            if (a.d && !b) {
                for (let c = 0; c < this.cc.count; c++) {
                    let d = this.cc._inner[c];
                    if (d.y == 0) {
                        d.j(a);
                    }
                }
            }
        }
        ca() {
            if (this.b7.z9 != null) {
                return this.b7.z9;
            }
            return this.e.c9.getFontInfo();
        }
        an(a) {
            super.an(a);
            for (let b = 0; b < this.cc.count; b++) {
                let c = this.cc._inner[b];
                if (c.y != 0) {
                    continue;
                }
                c.i(this.b7, this.ca(), a);
            }
        }
        cs(a) {
            this.k.ad(this.ca());
            this.cd = this.ce();
            let b = this.k.ah(a, this.cd, true);
            return new Size(1, b.c, b.b);
        }
        ce() {
            let a = this.ca();
            if (isNaN_(this.cd)) {
                let b = FontUtil.getCurrentFontHeight(this.e.c9.c8.j.ae, a);
                this.cd = b;
            }
            return this.cd;
        }
        cr(a, b) {
            if (this.b8 == null) {
                this.b8 = new CalloutView(this);
            }
            this.b8.h = a;
            this.b8.x = b;
            let c = this.b8.u();
            this.b8.h = null;
            return c;
        }
        cj(a, b, c) {
            a.f = b;
            a.g = c;
        }
        ck(a, b, c) {
            a.k(this.e, b, c);
        }
        cl(a, b) {
            if (b != null && this.b7.aa1) {
                return this.cq(b);
            }
            if (a != null) {
                return this.cq(a.va);
            }
            return this.e.va;
        }
        co() {
            return ((() => {
                let $ret = new Brush();
                $ret.color = Color.u(255, 255, 255, 255);
                return $ret;
            })());
        }
        cm() {
            return ((() => {
                let $ret = new Brush();
                $ret.color = Color.u(255, 0, 0, 0);
                return $ret;
            })());
        }
        cp(a, b) {
            if (b != null && this.b7.aa2) {
                return this.cq(b);
            }
            if (this.b7.aa3) {
                if (a != null) {
                    return this.cq(a.va);
                }
            }
            return ((() => {
                let $ret = new Brush();
                $ret.color = Color.u(255, 255, 255, 255);
                return $ret;
            })());
        }
        cn(a, b) {
            if (b != null && this.b7.aa2) {
                return this.cq(b);
            }
            if (a != null) {
                return this.cq(a.u3);
            }
            return this.e.u3;
        }
        ci() {
            this.cd = NaN;
        }
    }
    CalloutLayerView.$t = /*@__PURE__*/ markType(CalloutLayerView, 'CalloutLayerView', AnnotationLayerView.$);
    return CalloutLayerView;
})();
/**
 * @hidden
 */
export let CalloutView = /*@__PURE__*/ (() => {
    class CalloutView extends Base {
        constructor(a) {
            super();
            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 = ((() => {
                let $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;
        }
        j(a) {
            a.aa();
            a.ag(this.f, this.g);
            let 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();
        }
        get r() {
            return this.q;
        }
        set r(a) {
            if (this.q.x != a.x || this.q.y != a.y) {
                let b = this.u();
                let c = b.height;
                let d = b.width;
                this.q = a;
                let e = CalloutViewHelper.b(this.r, d, c, this.s);
                this.v = e;
            }
        }
        get p() {
            return this.l.ao;
        }
        set p(a) {
            this.l.ao = a;
        }
        get o() {
            return this.t._stroke;
        }
        set o(a) {
            this.t._stroke = a;
        }
        get n() {
            return this.s._stroke;
        }
        set n(a) {
            this.s._stroke = a;
        }
        get m() {
            return this.t._fill;
        }
        set m(a) {
            this.t._fill = a;
        }
        get e() {
            return this.t.ad;
        }
        set e(a) {
            this.t.ad = a;
        }
        get x() {
            return this.w;
        }
        set x(a) {
            this.w = a;
        }
        get d() {
            return this.c;
        }
        set d(a) {
            this.c = a;
        }
        get h() {
            return this.l.al;
        }
        set h(a) {
            if (a == null) {
                this.l.al = "";
            }
            else {
                this.l.al = a.toString();
            }
            let b = this.u();
            let c = b.height;
            let d = b.width;
            let e = CalloutViewHelper.b(this.r, d, c, this.s);
            this.v = e;
        }
        u() {
            let 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);
        }
        k(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;
            }
        }
        i(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 = /*@__PURE__*/ markType(CalloutView, 'CalloutView');
    return CalloutView;
})();
