/*
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 { Base, runOn, delegateCombine, delegateRemove, markType, fromEnum, String_$type, INotifyPropertyChanged_$type, PropertyChangedEventArgs, EventArgs, fromEn, EnumUtil, enumGetBox, typeGetValue, Point_$type } from "igniteui-angular-core/ES2015/type";
import { RenderingContext } from "igniteui-angular-core/ES2015/RenderingContext";
import { FontInfo } from "igniteui-angular-core/ES2015/FontInfo";
import { Brush } from "igniteui-angular-core/ES2015/Brush";
import { Rect } from "igniteui-angular-core/ES2015/Rect";
import { CanvasViewRenderer } from "igniteui-angular-core/ES2015/CanvasViewRenderer";
import { CanvasGestureDOMEventProxy } from "igniteui-angular-core/ES2015/CanvasGestureDOMEventProxy";
import { TreemapVisualData } from "./TreemapVisualData";
import { List$1 } from "igniteui-angular-core/ES2015/List$1";
import { TreemapVisual } from "./TreemapVisual";
import { Pool$1 } from "igniteui-angular-core/ES2015/Pool$1";
import { FontUtil } from "igniteui-angular-core/ES2015/FontUtil";
import { truncate, isNaN_, logBase } from "igniteui-angular-core/ES2015/number";
import { Rectangle } from "igniteui-angular-core/ES2015/Rectangle";
import { TextBlock } from "igniteui-angular-core/ES2015/TextBlock";
import { Thickness } from "igniteui-angular-core/ES2015/Thickness";
import { TreemapNodeVisualData } from "./TreemapNodeVisualData";
import { TreemapLabelVisualData } from "./TreemapLabelVisualData";
import { RectangleVisualData } from "igniteui-angular-core/ES2015/RectangleVisualData";
import { PointData } from "igniteui-angular-core/ES2015/PointData";
import { SizeData } from "igniteui-angular-core/ES2015/SizeData";
import { AppearanceHelper } from "igniteui-angular-core/ES2015/AppearanceHelper";
import { HashSet$1 } from "igniteui-angular-core/ES2015/HashSet$1";
import { TreemapOrientation_$type } from "./TreemapOrientation";
import { Size } from "igniteui-angular-core/ES2015/Size";
import { AreaInfo } from "./AreaInfo";
import { Dictionary$2 } from "igniteui-angular-core/ES2015/Dictionary$2";
import { DoubleAnimator } from "igniteui-angular-core/ES2015/DoubleAnimator";
import { BrushCollection } from "igniteui-angular-core/ES2015/BrushCollection";
import { TreemapFillScaleMode_$type } from "./TreemapFillScaleMode";
import { TreemapLayoutType_$type } from "./TreemapLayoutType";
import { FastItemsSource } from "igniteui-angular-core/ES2015/FastItemsSource";
import { DeviceUtils } from "igniteui-angular-core/ES2015/DeviceUtils";
import { EasingFunctions } from "igniteui-angular-core/ES2015/EasingFunctions";
import { NotifyCollectionChangedEventArgs } from "igniteui-angular-core/ES2015/NotifyCollectionChangedEventArgs";
import { ObservableCollection$1 } from "igniteui-angular-core/ES2015/ObservableCollection$1";
import { RectData } from "igniteui-angular-core/ES2015/RectData";
import { TreemapNodeVisualDataList } from "./TreemapNodeVisualDataList";
import { BrushCollectionUtil } from "igniteui-angular-core/ES2015/BrushCollectionUtil";
import { TreemapValueMappingMode_$type } from "./TreemapValueMappingMode";
import { TreemapNodePointerEventArgs } from "./TreemapNodePointerEventArgs";
import { stringReplace, stringIsNullOrEmpty } from "igniteui-angular-core/ES2015/string";
import { BrushUtil } from "igniteui-angular-core/ES2015/BrushUtil";
/**
 * @hidden
 */
export class TreemapView extends Base {
    constructor() {
        super();
        this.b = null;
        this.a = null;
        this.m = false;
        this.ac = null;
        this.j = null;
        this.aa = null;
        this.q = 0;
        this.p = 0;
        this.e = null;
        this.ab = null;
        this.t = 1;
        this.z = null;
        this.c = null;
        this.r = 0;
        this.s = 0;
        this.a1 = null;
        this.g = null;
        this.f = null;
        this.o = null;
        this.k = null;
        this.d = ((() => {
            let $ret = new FontInfo();
            $ret.n = "Verdana";
            $ret.d = 13;
            return $ret;
        })());
        this.l = true;
        this.b = new TreemapViewRenderer();
        this.b.j = ((() => {
            let $ret = new Brush();
            $ret.fill = "white";
            return $ret;
        })());
    }
    au() {
    }
    ay() {
        this.ax();
    }
    az() {
        if (!this.m) {
            this.m = true;
            if (this.aa != null) {
                this.aa.setTimeout(runOn(this, this.ad), 0);
            }
            else {
                window.setTimeout(runOn(this, this.ad), 0);
            }
        }
    }
    ad() {
        if (this.m) {
            this.m = false;
            this.a.e3();
        }
    }
    n() {
        return true;
    }
    av() {
        this.t = this.a.bw;
        this.az();
    }
    ar(a) {
        if (a == null) {
            this.ac = null;
            this.aa = null;
            this.j = null;
            if (this.z != null) {
                window.removeEventListener("resize", this.z, false);
                this.z = null;
            }
            this.ae();
            return;
        }
        this.aa = a;
        this.ab = a;
        let b = this.ab.rootWrapper.width();
        let c = this.ab.rootWrapper.height();
        this.ao();
        this.t = (isNaN_(this.a.cc) ? this.a.bw : this.a.cc);
        let d = this.t;
        let e = Math.round(a.rootWrapper.width());
        let f = Math.round(a.rootWrapper.height());
        let g = e * d;
        let h = f * d;
        this.aa.rootWrapper.setStyleProperty("position", "relative");
        let i = a.createElement("canvas");
        i.setStyleProperty("position", "absolute");
        this.aa.rootWrapper.append(i);
        this.q = b;
        this.p = c;
        i.setAttribute("width", g.toString());
        i.setAttribute("height", h.toString());
        i.setStyleProperty("width", e.toString() + "px");
        i.setStyleProperty("height", f.toString() + "px");
        this.k = i.listen("contextmenu", (j) => j.preventDefault());
        this.a.ft = new Rect(0, 0, 0, e, f);
        this.ac = i;
        let j = this.aa.get2DCanvasContext(this.ac);
        this.j = new RenderingContext(new CanvasViewRenderer(), j);
        this.an();
        this.a0();
        this.j.ac(this.e);
        this.ax();
        this.c = new CanvasGestureDOMEventProxy(this.ac, this.aa, true);
        this.c.ak = (k) => true;
        this.c.bf = this.a.ft;
        let k = this.c;
        k.onMouseOver = delegateCombine(k.onMouseOver, runOn(this, this.aj));
        let l = this.c;
        l.onMouseUp = delegateCombine(l.onMouseUp, runOn(this, this.ak));
        let m = this.c;
        m.onMouseDown = delegateCombine(m.onMouseDown, runOn(this, this.ag));
        let n = this.c;
        n.onMouseEnter = delegateCombine(n.onMouseEnter, runOn(this, this.ah));
        let o = this.c;
        o.onMouseLeave = delegateCombine(o.onMouseLeave, runOn(this, this.ai));
    }
    ai(a) {
        this.a.es(a);
    }
    al(a) {
        this.b.e(a, this.o, this);
    }
    ah(a) {
        this.a.er(a);
    }
    ao() {
        if (this.z == null) {
            this.z = (a) => {
                let b = this.a.cc;
                let c = this.a.bw;
                if (!isNaN_(b) && b != 0) {
                    return;
                }
                if (window.devicePixelRatio != undefined && window.devicePixelRatio != c) {
                    this.a.bw = window.devicePixelRatio;
                }
            };
            let e_ = this.z;
            window.addEventListener("resize", e_, false);
        }
        this.z(null);
    }
    ae() {
        if (this.k != null) {
            this.k();
            this.k = null;
        }
        if (this.c != null) {
            let a = this.c;
            a.onMouseOver = delegateRemove(a.onMouseOver, runOn(this, this.aj));
            let b = this.c;
            b.onMouseUp = delegateRemove(b.onMouseUp, runOn(this, this.ak));
            let c = this.c;
            c.onMouseDown = delegateRemove(c.onMouseDown, runOn(this, this.ag));
            let d = this.c;
            d.onMouseEnter = delegateRemove(d.onMouseEnter, runOn(this, this.ah));
            let e = this.c;
            e.onMouseLeave = delegateRemove(e.onMouseLeave, runOn(this, this.ai));
            this.c.ak = null;
            this.c.aq();
        }
    }
    ag(a) {
        if (this.c.ai) {
            this.a.ew(a);
        }
        else {
            this.a.eq(a);
        }
    }
    ak(a) {
        if (this.c.ai) {
            this.a.ex(a);
        }
        else {
            this.a.eu(a);
        }
    }
    aj(a, b, c) {
        this.a.et(a);
    }
    an() {
    }
    i() {
        return this.b.b;
    }
    a0() {
        this.e = FontUtil.getFont(this.aa);
        if (this.f != null) {
            this.r = this.u(this.f);
        }
        else {
            this.r = this.u(this.e);
        }
        if (this.g != null) {
            this.s = this.u(this.g);
        }
        else {
            this.s = this.u(this.e);
        }
        this.a1 = new Brush();
        this.a1._fill = this.aa.rootWrapper.getStyleProperty("color");
        if (this.j != null) {
            this.j.ac(this.e);
        }
    }
    ap() {
        let a = this.ab.rootWrapper.width();
        let b = this.ab.rootWrapper.height();
        this.a.ft = new Rect(0, 0, 0, a, b);
        this.ao();
    }
    am() {
        if (this.m) {
            this.ad();
        }
    }
    ax() {
        if (this.j == null) {
            return;
        }
        let a = this.a.ft.width;
        let b = this.a.ft.height;
        let c = Math.round(a * this.t);
        let d = Math.round(b * this.t);
        if (this.q != c || this.p != d) {
            this.ac.setAttribute("width", c.toString());
            this.ac.setAttribute("height", d.toString());
            this.ac.setStyleProperty("width", a.toString() + "px");
            this.ac.setStyleProperty("height", b.toString() + "px");
            this.q = truncate(Math.round(c));
            this.p = truncate(Math.round(d));
        }
        if (this.j.d && this.t != 1) {
            this.j.z();
            this.j.aa(this.t, this.t);
        }
        this.b.f(this.j, this.a.ft, this.o);
        if (this.j.d && this.t != 1) {
            this.j.y();
        }
    }
    at(a) {
        if (this.g != null) {
            this.s = this.u(this.g);
        }
        else {
            this.s = this.u(this.e);
        }
        this.g = a;
    }
    aw(a) {
        if (this.f != null) {
            this.r = this.u(this.f);
        }
        else {
            this.r = this.u(this.e);
        }
        this.f = a;
    }
    af(a) {
        this.o = a;
        this.ax();
    }
    y(a) {
        if (a != null) {
            if (this.f != null) {
                this.j.ac(this.f);
            }
            else {
                this.j.ac(this.d);
            }
            return this.j.f(a);
        }
        return 0;
    }
    w(a) {
        if (a != null) {
            if (this.g != null) {
                this.j.ac(this.g);
            }
            else {
                this.j.ac(this.d);
            }
            return this.j.f(a);
        }
        return 0;
    }
    u(a) {
        return FontUtil.getCurrentFontHeight(this.aa, a);
    }
    x(a) {
        return this.r;
    }
    v(a) {
        return this.s;
    }
    a2() {
        return ((() => {
            let $ret = new Brush();
            $ret.fill = "rgb(220,220,220)";
            return $ret;
        })());
    }
    a3() {
        return ((() => {
            let $ret = new Brush();
            $ret.fill = "black";
            return $ret;
        })());
    }
    a5() {
        return ((() => {
            let $ret = new Brush();
            $ret.fill = "black";
            return $ret;
        })());
    }
    a4() {
        return ((() => {
            let $ret = new Brush();
            $ret.fill = "rgb(240,240,240)";
            return $ret;
        })());
    }
    a6() {
        return ((() => {
            let $ret = new Brush();
            $ret.fill = "rgb(240, 240, 240)";
            return $ret;
        })());
    }
    h() {
        return this.d;
    }
    aq() {
        this.l = true;
        this.ao();
        if (this.c != null) {
            this.c.ap(this.aa.rootWrapper, "");
        }
    }
    as() {
        this.l = false;
        if (this.c != null) {
            this.c.bb(this.aa.rootWrapper, "");
        }
    }
}
TreemapView.$t = markType(TreemapView, 'TreemapView');
/**
 * @hidden
 */
export class TreemapViewRenderer extends Base {
    constructor() {
        super();
        this.b = null;
        this.c = null;
        this.j = null;
        this.c = new List$1(TreemapVisual.$, 0);
        this.b = ((() => {
            let $ret = new Pool$1(TreemapVisual.$);
            $ret.create = runOn(this, this.a);
            $ret.activate = runOn(this, this.g);
            $ret.disactivate = runOn(this, this.i);
            $ret.destroy = runOn(this, this.h);
            return $ret;
        })());
    }
    a() {
        let a = new TreemapVisual();
        this.c.add(a);
        return a;
    }
    g(a) {
        a.n = 0;
    }
    i(a) {
        a.n = 1;
    }
    h(a) {
        this.c.remove(a);
    }
    d(a) {
        if (a.c.count != 2) {
            a.c.add1(new Rectangle());
            a.c.add1(new Rectangle());
            a.c.add1(new TextBlock());
        }
    }
    f(a, b, c) {
        a.k(b.left, b.top, b.width, b.height);
        if (c != null) {
            for (let d = 0; d < c.count; d++) {
                let e = c._inner[d];
                this.d(e);
                let f = e.c._inner[0];
                let g = e.c._inner[1];
                let h = e.c._inner[2];
                f._fill = e.h;
                f._stroke = e.k;
                f.ac = e.f;
                f.width = e.l.width;
                f.height = e.l.height;
                f.n = e.l.left;
                f.o = e.l.top;
                a.ac(e.a);
                if (e.b) {
                    h.ak = e.g;
                    h.n = e.l.left + e.l.width / 2 - e.e / 2 + e.f;
                    h.o = e.l.top + e.l.height / 2 - e.d / 2 + e.f;
                    h.am = e.j;
                }
                else {
                    g._fill = e.i;
                    g._stroke = e.k;
                    g.ac = e.f;
                    g.width = e.l.width;
                    g.height = e.d;
                    g.n = e.l.left;
                    g.o = e.l.top;
                    h.n = e.l.left + e.m.c + e.f;
                    h.o = e.l.top + e.m.e + e.f;
                    h.ak = e.g;
                    h.am = e.j;
                }
                a.v(f);
                if (!e.b) {
                    a.v(g);
                }
                a.z();
                a.ae(e.l);
                a.w(h);
                a.y();
            }
        }
    }
    e(a, b, c) {
        if (b != null) {
            for (let d = 0; d < b.count; d++) {
                let e = b._inner[d];
                this.d(e);
                let f = e.c._inner[0];
                let g = e.c._inner[1];
                let h = e.c._inner[2];
                let i = new TreemapNodeVisualData();
                i.c = new RectangleVisualData(1, "NodePath", f);
                i.b = new RectangleVisualData(1, "HeaderRect", g);
                let j = new TreemapLabelVisualData();
                j.labelPosition = new PointData(h.n, h.o);
                if (e.b) {
                    j.labelSize = new SizeData(c.y(h.ak), c.x(h.ak));
                }
                else {
                    j.labelSize = new SizeData(c.w(h.ak), c.v(h.ak));
                }
                j.labelValue = h.ak;
                j.appearance = AppearanceHelper.c(h, e.a);
                i.a = j;
                a.nodes.add(i);
            }
        }
    }
}
TreemapViewRenderer.$t = markType(TreemapViewRenderer, 'TreemapViewRenderer');
/**
 * @hidden
 */
export class TreemapLayoutCalculator extends Base {
    static c(a, b, c) {
        let d = a.e();
        let e = c.f;
        let f = e * e / (b.width * b.height);
        if (d / (b.width * b.height) < f) {
            return true;
        }
        return false;
    }
    static a(a, b, c, d, e) {
        for (let f = 0; f < c.count; f++) {
            let g = c._inner[f];
            if (!a.contains(g)) {
                return false;
            }
        }
        return true;
    }
    static b(a, b) {
        if (a.width < b.f || a.height < b.f) {
            return true;
        }
        return false;
    }
    static f(a, b, c, d, e, f) {
        if (!TreemapLayoutCalculator.a(a, b, c, e, f)) {
            while (d > 0) {
                let g = 0;
                for (let h of fromEnum(c)) {
                    if (a.contains(h)) {
                        continue;
                    }
                    if (d > 0) {
                        let i = (d > 1) ? 1 : d;
                        let j = b.j(h);
                        if (j.isEmpty) {
                            continue;
                        }
                        b.i(h, new Rect(0, j.x + g, j.y, j.width + i, j.height));
                        d -= i;
                        g += i;
                    }
                    else {
                        let k = b.j(h);
                        if (k.isEmpty) {
                            continue;
                        }
                        b.i(h, new Rect(0, k.x + g, k.y, k.width, k.height));
                    }
                }
            }
        }
    }
    static e(a, b, c, d, e, f) {
        if (!TreemapLayoutCalculator.a(a, b, c, e, f)) {
            while (d > 0) {
                let g = 0;
                for (let h of fromEnum(c)) {
                    if (a.contains(h)) {
                        continue;
                    }
                    if (d > 0) {
                        let i = (d > 1) ? 1 : d;
                        let j = b.j(h);
                        if (j.isEmpty) {
                            continue;
                        }
                        b.i(h, new Rect(0, j.x, j.y + g, j.width, j.height + i));
                        d -= i;
                        g += i;
                    }
                    else {
                        let k = b.j(h);
                        if (k.isEmpty) {
                            continue;
                        }
                        b.i(h, new Rect(0, k.x, k.y + g, k.width, k.height));
                    }
                }
            }
        }
    }
}
TreemapLayoutCalculator.$t = markType(TreemapLayoutCalculator, 'TreemapLayoutCalculator');
/**
 * @hidden
 */
export class StrippedCalculator extends TreemapLayoutCalculator {
    d(a, b) {
        a.f();
        this.l(a, b.b.a, b.h, b, 0);
    }
    n(a, b, c) {
        return new Thickness(0, 4);
    }
    l(a, b, c, d, e) {
        if (d.g >= 0 && e > d.g) {
            return;
        }
        if (b == d.c) {
            d.d = true;
            a.i(b, c);
            let f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
            c = f;
        }
        if (!d.d) {
            for (let g of fromEnum(b.b)) {
                this.l(a, g, c, d, e + 1);
            }
            return;
        }
        let h = this.n(b, c, d);
        let i = h.c + h.d;
        let j = h.e + h.b;
        let k = new Rect(0, c.left, c.top, c.width, c.height);
        let l = d.a;
        if (i >= k.width || j >= k.height) {
            return;
        }
        k.x = k.x + h.c;
        k.width = k.width - i;
        k.y = k.y + h.e;
        k.height = k.height - j;
        let m = new HashSet$1(TreemapTreeNode.$, 0);
        StrippedCalculator.m(m, d, b.b, k);
        let n = 0;
        for (let o = 0; o < b.b.count; o++) {
            let p = b.b._inner[o];
            if (!m.contains(p)) {
                n += p.e();
            }
        }
        let q = n;
        let r = (k.width * k.height) / q;
        let s = l == 0 ? k.width : k.height;
        let t = new List$1(TreemapTreeNode.$, 0);
        let u = new List$1(TreemapTreeNode.$, 0);
        for (let v = 0; v < b.b.count; v++) {
            let w = b.b._inner[v];
            if (m.contains(w) || isNaN_(w.e())) {
                continue;
            }
            let x = StrippedCalculator.g(u, s, r);
            u.add(w);
            let y = StrippedCalculator.g(u, s, r);
            if (x < y) {
                if (t.count > 0) {
                    let z = StrippedCalculator.j(m, a, d, t, r, k, l, false);
                    k = z.p5;
                }
                u.removeAt(u.count - 1);
                t.o(u);
                u.clear();
                u.add(w);
            }
        }
        let aa = StrippedCalculator.g(t, s, r);
        let ab = StrippedCalculator.g(u, s, r);
        let ac = new List$1(TreemapTreeNode.$, 0);
        ac.o(t);
        ac.o(u);
        let ad = StrippedCalculator.g(ac, s, r);
        if (ad < (aa + ab) / 2 || k.height < d.f * 2) {
            let ae = StrippedCalculator.j(m, a, d, ac, r, k, l, true);
            k = ae.p5;
        }
        else {
            let af = StrippedCalculator.j(m, a, d, t, r, k, l, false);
            k = af.p5;
            let ag = StrippedCalculator.j(m, a, d, u, r, k, l, true);
            k = ag.p5;
        }
        for (let ah = 0; ah < b.b.count; ah++) {
            let ai = b.b._inner[ah];
            if (m.contains(ai)) {
                continue;
            }
            let aj = a.j(ai);
            if (aj.isEmpty) {
                continue;
            }
            let ak = new Rect(0, aj.left, aj.top + d.e, aj.width, Math.max(aj.height - d.e, 0));
            this.l(a, ai, ak, d, e + 1);
        }
        if (b == d.c) {
            d.d = false;
        }
    }
    static j(a, b, c, d, e, f, g, h) {
        if (d.count == 0) {
            return {
                p5: f
            };
        }
        if (g == 0) {
            let i = StrippedCalculator.i(a, b, c, d, e, f, h);
            f = i.p5;
        }
        else {
            let j = StrippedCalculator.k(a, b, c, d, e, f, h);
            f = j.p5;
        }
        return {
            p5: f
        };
    }
    static i(a, b, c, d, e, f, g) {
        let h = StrippedCalculator.h(d);
        if (h <= 0) {
            return {
                p5: f
            };
        }
        let i = f.width;
        let j = (h * e) / i;
        let k = f.x;
        let l = 0;
        for (let m = 0; m < d.count; ++m) {
            let n = d._inner[m];
            let o = Math.floor((n.e() / h) * i);
            let p = new Rect(0, k, f.y, o, j);
            if (TreemapLayoutCalculator.b(p, c)) {
                a.add_1(n);
            }
            else {
                l = p.right;
                b.i(n, p);
            }
            if (a.contains(n)) {
                h -= n.e();
            }
            else {
                k += o;
            }
        }
        TreemapLayoutCalculator.f(a, b, d, f.right - k, f, c);
        f.y = f.y + j;
        if (f.height < j) {
            f.height = 0;
        }
        else {
            f.height = f.height - j;
        }
        d.clear();
        return {
            p5: f
        };
    }
    static k(a, b, c, d, e, f, g) {
        let h = StrippedCalculator.h(d);
        if (h <= 0) {
            return {
                p5: f
            };
        }
        let i = f.height;
        let j = (h * e) / i;
        let k = f.y;
        let l = 0;
        for (let m = 0; m < d.count; ++m) {
            let n = d._inner[m];
            let o = Math.floor((n.e() / h) * i);
            let p = new Rect(0, f.x, k, j, o);
            if (TreemapLayoutCalculator.b(p, c)) {
                a.add_1(n);
            }
            else {
                l = p.bottom;
                b.i(n, p);
            }
            if (a.contains(n)) {
                h -= n.e();
            }
            else {
                k += o;
            }
        }
        TreemapLayoutCalculator.e(a, b, d, f.bottom - k, f, c);
        f.x = f.x + j;
        if (f.width < j) {
            f.width = 0;
        }
        else {
            f.width = f.width - j;
        }
        d.clear();
        return {
            p5: f
        };
    }
    static g(a, b, c) {
        if (a.count == 0) {
            return 1.7976931348623157E+308;
        }
        let d = StrippedCalculator.h(a);
        let e = (d * c) / b;
        let f = 0;
        for (let g = 0; g < a.count; g++) {
            let h = a._inner[g];
            let i = (h.e() / d) * b;
            f += Math.max(i / e, e / i);
        }
        f /= a.count;
        return f;
    }
    static h(a) {
        let b = 0;
        for (let c = 0; c < a.count; c++) {
            let d = a._inner[c];
            b += d.e();
        }
        return b;
    }
    static m(a, b, c, d) {
        let e = 0;
        for (let f = 0; f < c.count; f++) {
            let g = c._inner[f];
        }
        let h = e;
        let i = b.f * b.f / (d.width * d.height);
        for (let j = 0; j < c.count; j++) {
            let k = c._inner[j];
            if (k.e() / h < i) {
                a.add_1(k);
            }
        }
    }
}
StrippedCalculator.$t = markType(StrippedCalculator, 'StrippedCalculator', TreemapLayoutCalculator.$);
/**
 * @hidden
 */
export class SliceAndDiceCalculator extends TreemapLayoutCalculator {
    d(a, b) {
        a.f();
        this.j(a, b.b.a, b.h, b, 0);
    }
    l(a, b, c) {
        return new Thickness(0, 4);
    }
    j(a, b, c, d, e) {
        if (d.g >= 0 && e > d.g) {
            return;
        }
        if (b == d.c) {
            d.d = true;
            a.i(b, c);
            let f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
            c = f;
        }
        if (!d.d) {
            for (let g of fromEnum(b.b)) {
                this.j(a, g, c, d, e + 1);
            }
            return;
        }
        let h = this.l(b, c, d);
        let i = SliceAndDiceCalculator.g(b, d, e);
        let j = h.c + h.d;
        let k = h.e + h.b;
        let l = new Rect(0, c.left, c.top, c.width, c.height);
        if (j >= l.width || k >= l.height) {
            return;
        }
        l.x = l.x + h.c;
        l.width = l.width - j;
        l.y = l.y + h.e;
        l.height = l.height - k;
        let m = new Size(1, l.width, l.height);
        let n = l.left;
        let o = l.top;
        let p = new HashSet$1(TreemapTreeNode.$, 0);
        let q = SliceAndDiceCalculator.h(b.b, b, d, m, p);
        if (q) {
            SliceAndDiceCalculator.k(b.b, b, d, m, p);
        }
        let r = 0;
        for (let s = 0; s < b.b.count; s++) {
            let t = b.b._inner[s];
            if (!p.contains(t)) {
                r += t.e();
            }
        }
        let u = (i == 0) ? m.height : m.width;
        let v = new Rect(4);
        for (let w = 0; w < b.b.count; w++) {
            let x = b.b._inner[w];
            if (p.contains(x) || isNaN_(x.e())) {
                continue;
            }
            if (r <= 0 || u <= 0) {
                break;
            }
            let y = x.e() / r;
            v.x = n;
            v.y = o;
            if (i == 0) {
                v.width = m.width;
                v.height = Math.round(u * y);
            }
            else {
                v.width = Math.round(u * y);
                v.height = m.height;
            }
            a.i(x, new Rect(0, v.left, v.top, v.width, v.height));
            if (i == 0) {
                o += v.height;
                u -= v.height;
            }
            else {
                n += v.width;
                u -= v.width;
            }
            r -= x.e();
            let z = a.j(x);
            if (z.isEmpty) {
                continue;
            }
            let aa = new Rect(0, z.left, z.top + d.e, z.width, Math.max(z.height - d.e, 0));
            this.j(a, x, aa, d, e + 1);
        }
        if (b == d.c) {
            d.d = false;
        }
    }
    static g(a, b, c) {
        let d = 0;
        if (b.a == 0) {
            d = (c % 2 == 0) ? 0 : 1;
        }
        else {
            d = (c % 2 == 0) ? 1 : 0;
        }
        return d;
    }
    static h(a, b, c, d, e) {
        let f = true;
        let g = b.e();
        let h = Math.min(d.width, d.height);
        for (let i = 0; i < a.count; i++) {
            let j = a._inner[i];
            if (Math.round(j.e() / g * h) < c.f) {
                if (!e.contains(j)) {
                    e.add_1(j);
                }
            }
            else {
                f = false;
            }
        }
        return f;
    }
    static k(a, b, c, d, e) {
        let f = new List$1(TreemapTreeNode.$, 0);
        f.o(a);
        f.aa((g, h) => {
            if (g.e() > h.e()) {
                return 1;
            }
            else if (g.e() < h.e()) {
                return -1;
            }
            return 0;
        });
        let g = 0;
        let h = Math.min(d.width, d.height);
        for (let i = 0; i < f.count; i++) {
            let j = f._inner[i];
            if (isNaN_(j.e())) {
                continue;
            }
            g += j.e();
            if (j.e() / g * h < c.f) {
                break;
            }
            else {
                if (e.contains(j)) {
                    e.remove(j);
                }
            }
        }
    }
}
SliceAndDiceCalculator.$t = markType(SliceAndDiceCalculator, 'SliceAndDiceCalculator', TreemapLayoutCalculator.$);
SliceAndDiceCalculator.i = null;
/**
 * @hidden
 */
export class TreemapLayoutSettings extends Base {
    constructor() {
        super();
        this.a = 0;
        this.h = null;
        this.b = null;
        this.e = 0;
        this.f = 0;
        this.g = 0;
        this.c = null;
        this.d = false;
        this.g = -1;
        this.d = false;
    }
}
TreemapLayoutSettings.$t = markType(TreemapLayoutSettings, 'TreemapLayoutSettings');
/**
 * @hidden
 */
export class SquarifiedCalculator extends TreemapLayoutCalculator {
    k(a, b, c, d, e) {
        if (d.g >= 0 && e > d.g) {
            return;
        }
        if (b == d.c) {
            d.d = true;
            a.i(b, c);
            let f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
            c = f;
        }
        if (!d.d) {
            for (let g of fromEnum(b.b)) {
                this.k(a, g, c, d, e + 1);
            }
            return;
        }
        let h = this.l(b, c, d);
        let i = new Rect(0, c.left, c.top, c.width, c.height);
        let j = h.c + h.d;
        let k = h.e + h.b;
        if (j >= i.width || k >= i.height) {
            return;
        }
        i.x = i.x + h.c;
        i.width = i.width - j;
        i.y = i.y + h.e;
        i.height = i.height - k;
        let l = i.left;
        let m = i.top;
        let n = new List$1(TreemapTreeNode.$, 0);
        let o = b.e();
        let p = (i.width * i.height) / o;
        let q = new List$1(TreemapTreeNode.$, 1, b.b);
        q.aa((r, s) => {
            if (s.e() < r.e()) {
                return -1;
            }
            if (s.e() > r.e()) {
                return 1;
            }
            return 0;
        });
        let r = new AreaInfo();
        r.b = i;
        r.a = o;
        let s = new HashSet$1(TreemapTreeNode.$, 0);
        for (let t of fromEnum(q)) {
            if (TreemapLayoutCalculator.c(t, i, d) || isNaN_(t.e())) {
                s.add_1(t);
                continue;
            }
            let u = Math.min(i.width, i.height);
            let v = SquarifiedCalculator.g(n, u, p);
            n.add(t);
            let w = SquarifiedCalculator.g(n, u, p);
            if (v <= w) {
                n.removeAt(n.count - 1);
                SquarifiedCalculator.i(s, a, n, r, d);
                i = r.b;
                n.add(t);
            }
        }
        SquarifiedCalculator.i(s, a, n, r, d);
        i = r.b;
        for (let x of fromEnum(b.b)) {
            if (s.contains(x)) {
                continue;
            }
            let y = a.j(x);
            if (y.isEmpty) {
                continue;
            }
            let z = new Rect(0, y.left, y.top + d.e, y.width, Math.max(y.height - d.e, 0));
            this.k(a, x, z, d, e + 1);
        }
        if (b == d.c) {
            d.d = false;
        }
    }
    l(a, b, c) {
        return new Thickness(0, 4);
    }
    static g(a, b, c) {
        if (a.count == 0) {
            return 1.7976931348623157E+308;
        }
        let d = 0;
        let e = 1.7976931348623157E+308;
        let f = -1.7976931348623157E+308;
        for (let g of fromEnum(a)) {
            let h = g.e() * c;
            if (e > h) {
                e = h;
            }
            if (f < h) {
                f = h;
            }
            d += h;
        }
        let i = (b * b * f) / (d * d);
        let j = (d * d) / (b * b * e);
        return Math.max(i, j);
    }
    static i(a, b, c, d, e) {
        if (c.count < 1) {
            return;
        }
        let f = 0;
        for (let g = 0; g < c.count; ++g) {
            f += c._inner[g].e();
        }
        if (f <= 0) {
            return;
        }
        if (d.b.width > d.b.height) {
            SquarifiedCalculator.h(a, b, c, f, d, e);
        }
        else {
            SquarifiedCalculator.j(a, b, c, f, d, e);
        }
    }
    static j(a, b, c, d, e, f) {
        let g = e.b;
        let h = e.a;
        let i = Math.round((d / h) * g.height);
        let j = g.x;
        for (let k = 0; k < c.count; ++k) {
            let l = c._inner[k];
            if (g.right < j) {
                a.add_1(l);
                continue;
            }
            let m = Math.floor((l.e() / d) * g.width);
            let n = new Rect(0, j, g.y, m, i);
            if (TreemapLayoutCalculator.b(n, f)) {
                a.add_1(l);
                continue;
            }
            b.i(l, n);
            j += n.width;
        }
        TreemapLayoutCalculator.f(a, b, c, g.right - j, g, f);
        g.y = g.y + i;
        if (g.height < i) {
            g.height = 0;
        }
        else {
            g.height = g.height - i;
        }
        h -= d;
        e.a = h;
        e.b = g;
        c.clear();
    }
    static h(a, b, c, d, e, f) {
        let g = e.b;
        let h = e.a;
        let i = Math.round((d / h) * g.width);
        let j = g.y;
        for (let k = 0; k < c.count; ++k) {
            let l = c._inner[k];
            if (g.bottom < j) {
                a.add_1(l);
                continue;
            }
            let m = Math.floor((l.e() / d) * g.height);
            let n = new Rect(0, g.x, j, i, m);
            if (TreemapLayoutCalculator.b(n, f)) {
                a.add_1(l);
                continue;
            }
            b.i(l, n);
            j += n.height;
        }
        TreemapLayoutCalculator.e(a, b, c, g.bottom - j, g, f);
        g.x = g.x + i;
        if (g.width < i) {
            g.width = 0;
        }
        else {
            g.width = g.width - i;
        }
        h -= d;
        e.a = h;
        e.b = g;
        c.clear();
    }
    d(a, b) {
        a.f();
        this.k(a, b.b.a, b.h, b, 0);
    }
}
SquarifiedCalculator.$t = markType(SquarifiedCalculator, 'SquarifiedCalculator', TreemapLayoutCalculator.$);
/**
 * @hidden
 */
export class TreemapTreeData extends Base {
    constructor() {
        super();
        this.a = null;
        this.b = null;
        this.d = null;
        this.c = null;
        this.b = new Dictionary$2(String_$type, TreemapTreeNode.$, 0);
        this.d = new List$1(String_$type, 0);
        this.c = new Dictionary$2(String_$type, List$1.$.specialize(TreemapTreeNode.$), 0);
        this.a = new TreemapTreeNode();
    }
    e(a) {
        this.b.addItem(a.i, a);
        this.d.add(a.i);
        if (a.k == null) {
            this.a.b.add(a);
        }
        else if (this.b.containsKey(a.k)) {
            this.b.item(a.k).b.add(a);
        }
        else {
            let b;
            if (!((() => { let c = this.c.tryGetValue(a.k, b); b = c.p1; return c.ret; })())) {
                b = new List$1(TreemapTreeNode.$, 0);
                this.c.item(a.k, b);
            }
            b.add(a);
        }
        if (this.c.containsKey(a.i)) {
            for (let c of fromEnum(this.c.item(a.i))) {
                a.b.add(c);
            }
            this.c.removeItem(a.i);
        }
    }
    g(a) {
        if (isNaN_(a.f)) {
            if (a.b.count > 0) {
                a.d = 0;
            }
            for (let b = 0; b < a.b.count; b++) {
                let c = a.b._inner[b];
                this.g(c);
                if (isNaN_(c.f)) {
                    a.d = a.d + c.d;
                }
                else {
                    a.d = a.d + c.f;
                }
            }
        }
    }
    f() {
        this.g(this.a);
    }
}
TreemapTreeData.$t = markType(TreemapTreeData, 'TreemapTreeData');
/**
 * @hidden
 */
export class TreemapTreeNode extends Base {
    constructor() {
        super();
        this.i = null;
        this.k = null;
        this.b = null;
        this.c = null;
        this.f = 0;
        this.g = null;
        this.d = 0;
        this.j = null;
        this.h = null;
        this.a = false;
        this.b = new List$1(TreemapTreeNode.$, 0);
        this.f = NaN;
        this.g = null;
        this.c = new List$1(TreemapNodeStyleMapping.$, 0);
        this.d = 0;
    }
    e() {
        if (isNaN_(this.f)) {
            return this.d;
        }
        return this.f;
    }
}
TreemapTreeNode.$t = markType(TreemapTreeNode, 'TreemapTreeNode');
/**
 * @hidden
 */
export class Treemap extends Base {
    constructor() {
        super();
        this.g = null;
        this.f = null;
        this.e = null;
        this.ae = null;
        this.fs = null;
        this.ag = null;
        this.cr = null;
        this.cq = "Root";
        this.cl = " : ";
        this.cp = null;
        this.co = null;
        this.cm = null;
        this.cn = null;
        this.bg = null;
        this.a = new BrushCollection();
        this.v = new TreemapNodeStyleMappingCollection();
        this.c = 0;
        this.a1 = false;
        this.cg = 10;
        this.bm = NaN;
        this.bl = NaN;
        this.e9 = null;
        this.e8 = null;
        this.fb = null;
        this.fd = null;
        this.fa = null;
        this.ak = null;
        this.aj = null;
        this.bp = DeviceUtils.g(10);
        this.br = DeviceUtils.g(3);
        this.bq = DeviceUtils.g(10);
        this.bo = DeviceUtils.g(3);
        this.bn = NaN;
        this.fc = null;
        this.bu = NaN;
        this.y = 0;
        this.i = 0;
        this.bs = 3;
        this.ch = 500;
        this.bv = 0;
        this.cf = null;
        this.ah = null;
        this.as = null;
        this.ao = null;
        this.ar = null;
        this.ap = null;
        this.aq = null;
        this.bt = NaN;
        this.bi = 1;
        this.a0 = false;
        this.a5 = false;
        this.a8 = false;
        this.a4 = false;
        this.aa = null;
        this.h = null;
        this.bj = NaN;
        this.bk = DeviceUtils.g(1);
        this.propertyChanged = null;
        this.n = null;
        this.k = null;
        this.ad = null;
        this.ac = null;
        this.fr = null;
        this.nodeStyling = null;
        this.nodePointerOver = null;
        this.nodePointerEnter = null;
        this.nodePointerLeave = null;
        this.nodePointerPressed = null;
        this.nodePointerReleased = null;
        let a = new TreemapView();
        a.a = this;
        this.h = new SquarifiedCalculator();
        this.ae = a;
        this.ae.au();
        this.cf = (b, c) => this.ed(c.action, c.position, c.count, c.propertyName);
        this.fs = Rect.empty;
        this.g = new TreemapFrame();
        this.f = new TreemapFrame();
        this.e = new TreemapFrame();
        this.a5 = true;
        this.ag = new DoubleAnimator(0, 1, this.ck);
        this.ag.b = EasingFunctions.cubicEase;
        let b = this.ag;
        b.propertyChanged = delegateCombine(b.propertyChanged, runOn(this, this.ec));
        let c = this.v;
        c.collectionChanged = delegateCombine(c.collectionChanged, runOn(this, this.ea));
        let d = this.v;
        d.collectionResetting = delegateCombine(d.collectionResetting, runOn(this, this.eb));
    }
    eb(a, b) {
        for (let c of fromEnum(this.styleMappings)) {
            c.propertyChanged = delegateRemove(c.propertyChanged, runOn(this, this.e5));
        }
        this.a5 = true;
        this.a8 = true;
        this.ae.az();
    }
    ea(a, b) {
        if (b.oldItems != null) {
            for (let c of fromEn(b.oldItems)) {
                let d = c;
                if (d != null) {
                    d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.e5));
                }
            }
        }
        if (b.newItems != null) {
            for (let e of fromEn(b.newItems)) {
                let f = e;
                if (f != null) {
                    f.propertyChanged = delegateCombine(f.propertyChanged, runOn(this, this.e5));
                }
            }
        }
        this.a5 = true;
        this.a8 = true;
        this.ae.az();
    }
    e5(a, b) {
        this.a5 = true;
        this.a8 = true;
        this.ae.az();
    }
    ed(a, b, c, d) {
        this.aa = null;
        this.a5 = true;
        this.a4 = true;
        this.a8 = true;
        this.ae.az();
    }
    notifySizeChanged() {
        this.ae.ap();
    }
    destroy() {
        this.provideContainer(null);
    }
    af() {
        let a = new TreemapVisualData();
        a.viewport = new RectData(this.ft.left, this.ft.top, this.ft.width, this.ft.height);
        a.nodes = new TreemapNodeVisualDataList();
        this.ae.al(a);
        return a;
    }
    cy() {
        let a = this.af();
        a.scaleByViewport();
        return a.serialize();
    }
    ev(a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        this.e0(a, b, c);
    }
    e0(a, b, c) {
        switch (a) {
            case "LayoutType":
                {
                    switch (EnumUtil.getEnumValue(TreemapLayoutType_$type, c)) {
                        case 0:
                            this.h = new SquarifiedCalculator();
                            break;
                        case 1:
                            this.h = new SliceAndDiceCalculator();
                            break;
                        case 2:
                            this.h = new StrippedCalculator();
                            break;
                    }
                    this.a5 = true;
                    this.ae.az();
                }
                break;
            case "BreadcrumbSequence":
                this.a5 = true;
                this.ae.az();
                break;
            case "RootTitle":
                this.a5 = true;
                this.ae.az();
                break;
            case "ValueMemberPath":
                if (this.ai != null) {
                    this.ai.deregisterColumn(this.az);
                    this.az = this.ax(this.d7);
                    this.aa = null;
                }
                this.a5 = true;
                this.a4 = true;
                this.ae.az();
                break;
            case "CustomValueMemberPath":
                if (this.ai != null) {
                    this.ai.deregisterColumn(this.at);
                    this.at = this.ay(this.cw);
                    this.aa = null;
                }
                this.a5 = true;
                this.a4 = true;
                this.ae.az();
                break;
            case "IdMemberPath":
                if (this.ai != null) {
                    this.ai.deregisterColumn(this.au);
                    this.au = this.ay(this.dh);
                    this.aa = null;
                }
                this.a5 = true;
                this.a4 = true;
                this.ae.az();
                break;
            case "LabelMemberPath":
                if (this.ai != null) {
                    this.ai.deregisterColumn(this.av);
                    this.av = this.ay(this.dm);
                    this.aa = null;
                }
                this.a5 = true;
                this.a4 = true;
                this.ae.az();
                break;
            case "ParentIdMemberPath":
                if (this.ai != null) {
                    this.ai.deregisterColumn(this.aw);
                    this.aw = this.ay(this.du);
                    this.aa = null;
                }
                this.a5 = true;
                this.a4 = true;
                this.ae.az();
                break;
            case "ItemsSource":
                this.ai = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.dataSource;
                    return $ret;
                })());
                break;
            case "HeaderLabelLeftMargin":
            case "HeaderLabelTopMargin":
            case "HeaderLabelRightMargin":
            case "HeaderLabelBottomMargin":
            case "HeaderTextColor":
            case "HeaderHoverTextColor":
            case "HeaderHoverBackground":
            case "StrokeThickness":
            case "Outline":
            case "FillBrushes":
            case "IsFillScaleLogarithmic":
            case "FillScaleMinimumValue":
            case "FillScaleMaximumValue":
            case "HeaderBackground":
            case "HeaderHeight":
            case "FillScaleLogarithmBase":
            case "FillScaleMode":
            case "MinimumDisplaySize":
            case "LayoutOrientation":
                this.a5 = true;
                this.ae.az();
                break;
            case "TextStyle":
                this.ae.aw(this.an);
                this.a5 = true;
                this.ae.az();
                break;
            case "HeaderTextStyle":
                this.ae.at(this.am);
                this.a5 = true;
                this.ae.az();
                break;
            case "PixelScalingRatio":
                this.bw = c;
                break;
            case "ActualPixelScalingRatio":
                if (this.ae != null) {
                    this.ae.av();
                }
                break;
            case "TransitionProgress":
                if (this.ce >= 1) {
                    this.ag.w();
                    let d = this.f;
                    this.f = this.g;
                    this.g = d;
                    this.ez();
                    this.e2(this.f);
                    this.ae.ay();
                    this.ae.az();
                    return;
                }
                this.e.g(this.ce, this.g, this.f);
                this.e2(this.e);
                this.ae.ay();
                break;
            case "Viewport":
                this.a5 = true;
                this.ae.az();
                break;
            case "FastItemsSource":
                let e = b;
                let f = c;
                if (b != null) {
                    e.event = delegateRemove(e.event, this.cf);
                    this.a0 = false;
                    e.deregisterColumn(this.az);
                    e.deregisterColumn(this.au);
                    e.deregisterColumn(this.aw);
                    e.deregisterColumn(this.av);
                    e.deregisterColumn(this.at);
                    this.az = null;
                    this.au = null;
                    this.aw = null;
                    this.av = null;
                    this.aa = null;
                }
                if (c != null) {
                    f.event = delegateCombine(f.event, this.cf);
                    this.a0 = true;
                    this.az = this.ax(this.d7);
                    this.au = this.ay(this.dh);
                    this.aw = this.ay(this.du);
                    this.av = this.ay(this.dm);
                    this.at = this.ay(this.cw);
                }
                this.a5 = true;
                this.a4 = true;
                this.ae.az();
                break;
            case "TransitionDuration":
                this.ag.r = this.ck;
                break;
        }
    }
    get ft() {
        return this.fs;
    }
    set ft(a) {
        let b = this.fs;
        this.fs = a;
        if (!b.equals1(this.fs)) {
            this.ev("Viewport", b, this.fs);
        }
    }
    ec(a, b) {
        this.ce = this.ag.o;
    }
    get d7() {
        return this.cr;
    }
    set d7(a) {
        let b = this.cr;
        this.cr = a;
        if (b != this.cr) {
            this.e0("ValueMemberPath", b, a);
        }
    }
    get dx() {
        return this.cq;
    }
    set dx(a) {
        let b = this.cq;
        this.cq = a;
        if (b != this.cq) {
            this.e0("RootTitle", b, a);
        }
    }
    get ct() {
        return this.cl;
    }
    set ct(a) {
        let b = this.cl;
        this.cl = a;
        if (b != this.cq) {
            this.e0("BreadcrumbSequence", b, a);
        }
    }
    get du() {
        return this.cp;
    }
    set du(a) {
        let b = this.cp;
        this.cp = a;
        if (b != this.cp) {
            this.ev("ParentIdMemberPath", b, a);
        }
    }
    get dm() {
        return this.co;
    }
    set dm(a) {
        let b = this.co;
        this.co = a;
        if (b != this.co) {
            this.ev("LabelMemberPath", b, a);
        }
    }
    get cw() {
        return this.cm;
    }
    set cw(a) {
        let b = this.cm;
        this.cm = a;
        if (b != this.cm) {
            this.ev("CustomValueMemberPath", b, a);
        }
    }
    get dh() {
        return this.cn;
    }
    set dh(a) {
        let b = this.cn;
        this.cn = a;
        if (b != this.cn) {
            this.ev("IdMemberPath", b, a);
        }
    }
    get dataSource() {
        return this.bg;
    }
    set dataSource(a) {
        let b = this.bg;
        this.bg = a;
        if (b != this.bg) {
            this.ev("ItemsSource", b, a);
        }
    }
    get b() {
        return this.a;
    }
    set b(a) {
        let b = this.a;
        this.a = a;
        if (b != this.a) {
            this.ev("FillBrushes", b, a);
        }
    }
    get styleMappings() {
        return this.v;
    }
    get d() {
        return this.c;
    }
    set d(a) {
        let b = this.c;
        this.c = a;
        if (b != this.c) {
            this.ev("FillScaleMode", enumGetBox(TreemapFillScaleMode_$type, b), enumGetBox(TreemapFillScaleMode_$type, a));
        }
    }
    get a6() {
        return this.a1;
    }
    set a6(a) {
        let b = this.a1;
        this.a1 = a;
        if (b != this.a1) {
            this.ev("IsFillScaleLogarithmic", b, a);
        }
    }
    get ci() {
        return this.cg;
    }
    set ci(a) {
        let b = this.cg;
        this.cg = a;
        if (b != this.cg) {
            this.ev("FillScaleLogarithmBase", b, a);
        }
    }
    get bz() {
        return this.bm;
    }
    set bz(a) {
        let b = this.bm;
        this.bm = a;
        if (b != this.bm) {
            this.ev("FillScaleMinimumValue", b, a);
        }
    }
    get by() {
        return this.bl;
    }
    set by(a) {
        let b = this.bl;
        this.bl = a;
        if (b != this.bl) {
            this.ev("FillScaleMaximumValue", b, a);
        }
    }
    get fm() {
        return this.e9;
    }
    set fm(a) {
        let b = this.e9;
        this.e9 = a;
        if (b != this.e9) {
            this.ev("HeaderHoverBackground", b, a);
        }
    }
    get fl() {
        return this.e8;
    }
    set fl(a) {
        let b = this.e8;
        this.e8 = a;
        if (b != this.e8) {
            this.ev("HeaderBackground", b, a);
        }
    }
    get fo() {
        return this.fb;
    }
    set fo(a) {
        let b = this.fb;
        this.fb = a;
        if (b != this.fb) {
            this.ev("HeaderTextColor", b, a);
        }
    }
    get fq() {
        return this.fd;
    }
    set fq(a) {
        let b = this.fd;
        this.fd = a;
        if (b != this.fd) {
            this.ev("TextColor", b, a);
        }
    }
    get fn() {
        return this.fa;
    }
    set fn(a) {
        let b = this.fa;
        this.fa = a;
        if (b != this.fa) {
            this.ev("HeaderHoverTextColor", b, a);
        }
    }
    get an() {
        return this.ak;
    }
    set an(a) {
        let b = this.ak;
        this.ak = a;
        if (b != this.ak) {
            this.ev("TextStyle", b, this.ak);
        }
    }
    get am() {
        return this.aj;
    }
    set am(a) {
        let b = this.aj;
        this.aj = a;
        if (b != this.aj) {
            this.ev("HeaderTextStyle", b, this.aj);
        }
    }
    get b8() {
        return this.bp;
    }
    set b8(a) {
        let b = this.bp;
        this.bp = a;
        if (b != this.bp) {
            this.ev("HeaderLabelLeftMargin", b, a);
        }
    }
    get ca() {
        return this.br;
    }
    set ca(a) {
        let b = this.br;
        this.br = a;
        if (b != this.br) {
            this.ev("HeaderLabelTopMargin", b, a);
        }
    }
    get b9() {
        return this.bq;
    }
    set b9(a) {
        let b = this.bq;
        this.bq = a;
        if (b != this.bq) {
            this.ev("HeaderLabelRightMargin", b, a);
        }
    }
    get b7() {
        return this.bo;
    }
    set b7(a) {
        let b = this.bo;
        this.bo = a;
        if (b != this.bo) {
            this.ev("HeaderLabelBottomMargin", b, a);
        }
    }
    get b6() {
        return this.bn;
    }
    set b6(a) {
        let b = this.bn;
        this.bn = a;
        if (b != this.bn) {
            this.ev("HeaderHeight", b, a);
        }
    }
    get fp() {
        return this.fc;
    }
    set fp(a) {
        let b = this.fc;
        this.fc = a;
        if (b != this.fc) {
            this.ev("Outline", b, a);
        }
    }
    get cd() {
        return this.bu;
    }
    set cd(a) {
        let b = this.bu;
        this.bu = a;
        if (b != this.bu) {
            this.ev("StrokeThickness", b, a);
        }
    }
    get z() {
        return this.y;
    }
    set z(a) {
        let b = this.y;
        this.y = a;
        if (b != this.y) {
            this.ev("LayoutOrientation", enumGetBox(TreemapOrientation_$type, b), enumGetBox(TreemapOrientation_$type, a));
        }
    }
    get j() {
        return this.i;
    }
    set j(a) {
        let b = this.i;
        this.i = a;
        if (b != this.i) {
            this.ev("LayoutType", enumGetBox(TreemapLayoutType_$type, b), enumGetBox(TreemapLayoutType_$type, a));
        }
    }
    get cb() {
        return this.bs;
    }
    set cb(a) {
        let b = this.bs;
        this.bs = a;
        if (b != this.bs) {
            this.ev("MinimumDisplaySize", b, a);
        }
    }
    get ck() {
        return this.ch;
    }
    set ck(a) {
        let b = this.ch;
        this.ch = a;
        if (b != this.ch) {
            this.ev("TransitionDuration", b, a);
        }
    }
    get ce() {
        return this.bv;
    }
    set ce(a) {
        let b = this.bv;
        this.bv = a;
        if (b != this.bv) {
            this.ev("TransitionProgress", b, a);
        }
    }
    get ai() {
        return this.ah;
    }
    set ai(a) {
        let b = this.ah;
        this.ah = a;
        if (b != this.ah) {
            this.ev("FastItemsSource", b, this.ah);
        }
    }
    get az() {
        return this.as;
    }
    set az(a) {
        this.as = a;
    }
    get at() {
        return this.ao;
    }
    set at(a) {
        this.ao = a;
    }
    get aw() {
        return this.ar;
    }
    set aw(a) {
        this.ar = a;
    }
    get au() {
        return this.ap;
    }
    set au(a) {
        this.ap = a;
    }
    get av() {
        return this.aq;
    }
    set av(a) {
        this.aq = a;
    }
    get cc() {
        return this.bt;
    }
    set cc(a) {
        let b = this.bt;
        this.bt = a;
        if (b != this.bt) {
            this.ev("PixelScalingRatio", b, a);
        }
    }
    get bw() {
        return this.bi;
    }
    set bw(a) {
        let b = this.bi;
        this.bi = a;
        if (b != this.bi) {
            this.ev("ActualPixelScalingRatio", b, a);
        }
    }
    ax(a) {
        let b = null;
        return this.ai.registerColumn(a, b, false);
    }
    ay(a) {
        let b = null;
        return this.ai.registerColumnObject(a, b, false);
    }
    ei() {
        this.a5 = true;
        this.ae.az();
    }
    get a2() {
        return this.ag.f();
    }
    ab() {
        let a = new TreemapTreeData();
        if (this.az == null || (this.av == null && this.au == null)) {
            return null;
        }
        for (let b = 0; b < this.ai.count; b++) {
            let c = null;
            if (this.at != null && this.at.count > b) {
                c = this.at.item(b);
            }
            let d = this.az.item(b);
            let e = null;
            let f = "";
            if (this.av != null) {
                f = this.av.item(b) != null ? this.av.item(b).toString() : "";
            }
            if (this.au != null) {
                if (this.au.item(b) == null) {
                    continue;
                }
                e = stringReplace(this.au.item(b).toString(), " ", "_");
            }
            if (e == null) {
                e = stringReplace(f, " ", "_");
                if (stringIsNullOrEmpty(e)) {
                    continue;
                }
            }
            let g = null;
            if (this.aw != null) {
                g = this.aw.item(b) != null ? stringReplace(this.aw.item(b).toString(), " ", "_") : null;
            }
            let h = new TreemapTreeNode();
            h.i = e;
            h.k = g;
            h.h = this.ai.item(b);
            h.f = d;
            h.g = c;
            h.j = f;
            a.e(h);
        }
        a.f();
        return a;
    }
    ez() {
        if (this.aa == null) {
            this.aa = this.ab();
            if (this.aa == null) {
                return;
            }
        }
        if (this.a8) {
            this.a8 = false;
            for (let a = 0; a < this.aa.d.count; a++) {
                let b = this.aa.b.item(this.aa.d._inner[a]);
                b.c.clear();
                for (let c = 0; c < this.styleMappings.count; c++) {
                    if (this.a3(this.styleMappings._inner[c], b)) {
                        b.c.add(this.styleMappings._inner[c]);
                    }
                }
            }
        }
        if (!this.ae.n()) {
            return;
        }
        let d = new TreemapLayoutSettings();
        d.b = this.aa;
        d.h = this.ft;
        d.c = this.ac;
        d.f = this.cb;
        d.a = this.z;
        let e = this.b1();
        let f = this.b3();
        let g = this.b2();
        let h = this.b0();
        d.e = this.ae.v("M") + f + h;
        if (!isNaN_(this.b6)) {
            d.e = this.b6;
        }
        d.d = this.ac == null;
        this.h.d(this.f, d);
        let i = 1.7976931348623157E+308;
        let j = -1.7976931348623157E+308;
        if (this.d == 1 || this.d == 3) {
            for (let k = 0; k < this.aa.d.count; k++) {
                let l = 0;
                if (this.d == 1) {
                    l = this.aa.b.item(this.aa.d._inner[k]).e();
                }
                else {
                    l = this.aa.b.item(this.aa.d._inner[k]).f;
                }
                if (!isNaN_(l)) {
                    i = Math.min(l, i);
                    j = Math.max(l, j);
                }
            }
        }
        else {
            for (let m = 0; m < this.f.d.count; m++) {
                let n = 0;
                if (this.d == 0) {
                    n = this.aa.b.item(this.f.d._inner[m]).e();
                }
                else {
                    n = this.aa.b.item(this.f.d._inner[m]).f;
                }
                if (!isNaN_(n)) {
                    i = Math.min(n, i);
                    j = Math.max(n, j);
                }
            }
        }
        for (let o = 0; o < this.f.d.count; o++) {
            let p = this.f.d._inner[o];
            let q = this.aa.b.item(p);
            let r = this.fe(q, i, j);
            let s = this.fj(q);
            let t = this.ff(q);
            let u = this.b5(q);
            let v = this.c5(this.f, q, e, g);
            let w = this.fi(q);
            let x = this.al(q);
            let y = 0;
            if (this.a7(q)) {
                y = this.ae.w(v);
            }
            else {
                y = this.ae.y(v);
            }
            let z = 0;
            if (this.a7(q)) {
                z = d.e;
            }
            else {
                z = this.ae.x(v);
            }
            this.f.h(q, v, r, s, t, w, u, y, z, e, f, g, h);
            if (q.c.count > 0) {
                for (let aa = 0; aa < q.c.count; aa++) {
                    this.f.e(q, q.c._inner[aa]);
                }
            }
            if (this.nodeStyling != null) {
                let ab = new TreemapNodeStylingEventArgs();
                ab.item = q.h;
                if (q.k != null) {
                    if (this.aa.b.containsKey(q.k)) {
                        let ac = this.aa.b.item(q.k);
                        ab.parentItem = ac.h;
                        ab.parentLabel = ac.j;
                        ab.parentSum = ac.e();
                        ab.parentValue = ac.f;
                    }
                }
                ab.sum = q.e();
                ab.value = q.f;
                ab.label = q.j;
                ab.customValue = q.g;
                ab.style = new TreemapNodeStyle();
                this.nodeStyling(this, ab);
                this.f.e(q, ab.style);
            }
        }
    }
    a7(a) {
        return a.b != null && a.b.count > 0;
    }
    b0() {
        return this.b7;
    }
    b2() {
        return this.b9;
    }
    b3() {
        return this.ca;
    }
    b1() {
        return this.b8;
    }
    d5(a, b, c, d, e) {
        let f = b.length;
        let g = b;
        let h = ("\u2026");
        if (isNaN_(this.bj)) {
            if (this.a7(a)) {
                this.bj = this.ae.w(h);
            }
            else {
                this.bj = this.ae.y(h);
            }
        }
        if (c <= (this.bj + d + e)) {
            return h;
        }
        let i = 0;
        if (this.a7(a)) {
            i = this.ae.w(b);
        }
        else {
            i = this.ae.y(b);
        }
        if (i + d + e <= c) {
            return b;
        }
        let j = c / (i + d + e);
        let k = truncate(Math.ceil(f * j));
        let l = b.substr(0, k) + h;
        let m = 0;
        if (this.a7(a)) {
            m = this.ae.w(l);
        }
        else {
            m = this.ae.y(l);
        }
        if ((m + d + e) > c) {
            f = k;
        }
        else {
            k = k + 1;
            l = b.substr(0, k) + h;
            if (this.a7(a)) {
                m = this.ae.w(l);
            }
            else {
                m = this.ae.y(l);
            }
            if ((m + d + e) > c) {
                f = k;
            }
        }
        while ((i + d + e) > c && f > 0) {
            f--;
            b = b.substr(0, f) + h;
            if (this.a7(a)) {
                i = this.ae.w(b);
            }
            else {
                i = this.ae.y(b);
            }
        }
        return b;
    }
    c5(a, b, c, d) {
        if (b == null) {
            if (this.ct != null && this.dx != null) {
                return this.dx + this.ct;
            }
            return "";
        }
        let e = a.j(b);
        let f = e.width;
        let g = b.j;
        if (this.ac != null && this.ac == b && this.ct != null) {
            let h = null;
            let i = b;
            while (i.k != null) {
                if (this.aa.b.containsKey(b.k)) {
                    h = this.aa.b.item(b.k);
                    if (h.j != null) {
                        g = h.j + this.ct + g;
                    }
                    i = h;
                }
            }
            if (this.dx != null) {
                g = this.dx + this.ct + g;
            }
        }
        let j = 0;
        let k = 0;
        if (a.b(b.i)) {
            let l = a.a(b.i);
            if (b.b.count > 0) {
                j = c;
                k = d;
            }
        }
        return this.d5(b, g, f, j, k);
    }
    b5(a) {
        if (!isNaN_(this.cd)) {
            return this.cd;
        }
        return this.bk;
    }
    ff(a) {
        if (a == this.ad) {
            return this.fg(a);
        }
        if (this.fl != null) {
            return this.fl;
        }
        return this.ae.a2();
    }
    fi(a) {
        if (a.b.count > 0) {
            if (a == this.ad) {
                return this.fh(a);
            }
            if (this.fo != null) {
                return this.fo;
            }
            return this.ae.a3();
        }
        else {
            if (this.fq != null) {
                return this.fq;
            }
            return this.ae.a6();
        }
    }
    al(a) {
        if (a.b.count > 0) {
            if (this.am != null) {
                return this.am;
            }
            return this.ae.h();
        }
        else {
            if (this.an != null) {
                return this.an;
            }
            return this.ae.h();
        }
    }
    onDetachedFromUI() {
        this.ae.as();
    }
    onAttachedToUI() {
        this.ae.aq();
    }
    fg(a) {
        if (this.fm != null) {
            return this.fm;
        }
        return this.ae.a4();
    }
    fh(a) {
        if (this.fn != null) {
            return this.fn;
        }
        if (this.fo != null) {
            return this.fo;
        }
        return this.ae.a3();
    }
    fj(a) {
        if (this.fp != null) {
            return this.fp;
        }
        return this.ae.a5();
    }
    fe(a, b, c) {
        if (this.b == null || this.b.count == 0) {
            return this.fk(a);
        }
        let d = this.b4(a);
        if (isNaN_(d)) {
            return this.fk(a);
        }
        let e = 0;
        if (this.a6 && this.ci > 0) {
            if (d > 0) {
                e = (logBase(d, this.ci) - logBase(b, this.ci)) / (logBase(c, this.ci) - logBase(b, this.ci));
            }
            else {
                return this.fk(a);
            }
        }
        else {
            e = (d - b) / (c - b);
        }
        e = e * (this.b.count - 1);
        return BrushCollectionUtil.b(this.b, e);
    }
    b4(a) {
        switch (this.d) {
            case 0:
            case 1: return a.e();
            case 2:
            case 3: return a.f;
        }
        return a.e();
    }
    fk(a) {
        return this.ae.a2();
    }
    e2(a) {
        let b = new List$1(TreemapVisual.$, 0);
        let c = this.ae.i();
        let d = 0;
        for (let e = 0; e < a.d.count; e++) {
            let f = a.d._inner[e];
            let g = a.a(f);
            let h = c.item(d);
            if (g.r.isEmpty || (g.r.width == 0 && g.r.height == 0)) {
                h.n = 1;
                continue;
            }
            d++;
            b.add(h);
            h.a = this.al(g.d);
            h.h = g.n;
            h.k = g.q;
            h.i = g.o;
            h.m = new Thickness(1, g.g, g.i, g.h, g.f);
            h.j = g.p;
            h.g = g.m;
            h.f = g.k;
            h.n = 0;
            h.l = g.r;
            h.b = g.d.b.count == 0;
            h.e = g.j;
            h.d = g.e;
        }
        c.count = d;
        this.ae.af(b);
    }
    bc() {
        return !this.ft.isEmpty && this.ae.n();
    }
    e3() {
        if (!this.bc()) {
            return;
        }
        if (this.a5) {
            let a = this.g;
            if (this.a2) {
                if (this.ag.g) {
                    this.ag.t();
                }
                this.g = this.e;
                this.e = a;
            }
            else {
                this.g = this.f;
                this.f = a;
            }
        }
        else if (this.a2) {
            this.e.g(this.ce, this.g, this.f);
            this.e2(this.e);
        }
        if (this.a5) {
            this.ez();
        }
        if (this.a5 && this.bd) {
            this.e4();
            this.e.g(this.ce, this.g, this.f);
            this.e2(this.e);
        }
        else {
            if (this.a5) {
                this.e2(this.f);
            }
        }
        this.a5 = false;
        this.ae.ay();
    }
    a3(a, b) {
        let c = null;
        switch (a.ax) {
            case 1:
                c = b.f;
                break;
            case 0:
                c = b.e();
                break;
            case 2:
                c = b.g;
                break;
        }
        if (this.a9(c)) {
            let d = this.bx(c);
            if (a.a3 != null) {
                if (this.a9(a.a3)) {
                    let e = this.bx(a.a3);
                    if (isNaN_(e) && isNaN_(d)) {
                        return true;
                    }
                    if (d == e) {
                        return true;
                    }
                }
            }
            else if (!isNaN_(a.a1) || !isNaN_(a.a0)) {
                let f = a.a1;
                let g = a.a0;
                if (d >= f && d <= g) {
                    return true;
                }
            }
        }
        else if (this.bb(c)) {
            if (a.a3 != null) {
                if (this.bb(a.a3)) {
                    let h = (a.a3);
                    if (Base.equalsStatic(h, c)) {
                        return true;
                    }
                }
            }
        }
        else {
            if (Base.equalsStatic(c, a.a3)) {
                return true;
            }
        }
        return false;
    }
    bb(a) {
        return typeof a === 'string';
    }
    bx(a) {
        if (typeof a === 'number') {
            return a;
        }
        if (typeof a === 'number') {
            return typeGetValue(a);
        }
        if (typeof a === 'number') {
            return typeGetValue(a);
        }
        if (typeof a === 'number') {
            return typeGetValue(a);
        }
        if (typeof a === 'number') {
            return a;
        }
        if (typeof a === 'number') {
            return typeGetValue(a);
        }
        if (typeof a === 'number') {
            return a;
        }
        return NaN;
    }
    a9(a) {
        if (typeof a === 'number') {
            return true;
        }
        if (typeof a === 'number') {
            return true;
        }
        if (typeof a === 'number') {
            return true;
        }
        if (typeof a === 'number') {
            return true;
        }
        if (typeof a === 'number') {
            return true;
        }
        if (typeof a === 'number') {
            return true;
        }
        if (typeof a === 'number') {
            return true;
        }
        return false;
    }
    l(a) {
        let b = this.f;
        if (this.a2) {
            b = this.e;
        }
        let c = new List$1(TreemapNodeFrame.$, 0);
        for (let d = 0; d < b.d.count; d++) {
            let e = b.d._inner[d];
            let f = b.a(e);
            if (a.x >= f.r.left && a.x <= f.r.right && a.y >= f.r.top && a.y <= f.r.bottom) {
                c.add(f);
            }
        }
        c.aa((g, h) => {
            let i = this.cj(h);
            let j = this.cj(g);
            if (i > j) {
                return 1;
            }
            else if (j > i) {
                return -1;
            }
            return 0;
        });
        for (let g of fromEnum(c)) {
            if (g.d.b.count > 0) {
                return g;
            }
        }
        return null;
    }
    cj(a) {
        let b = a.d;
        let c = 0;
        while (b.k != null) {
            if (this.aa == null) {
                break;
            }
            if (this.aa.b.containsKey(b.k)) {
                c++;
                b = this.aa.b.item(b.k);
            }
        }
        return c;
    }
    m(a) {
        let b = this.f;
        if (this.a2) {
            b = this.e;
        }
        let c = new List$1(TreemapNodeFrame.$, 0);
        for (let d = 0; d < b.d.count; d++) {
            let e = b.d._inner[d];
            let f = b.a(e);
            if (a.x >= f.r.left && a.x <= f.r.right && a.y >= f.r.top && a.y <= f.r.bottom) {
                c.add(f);
            }
        }
        c.aa((g, h) => {
            let i = this.cj(h);
            let j = this.cj(g);
            if (i > j) {
                return 1;
            }
            else if (j > i) {
                return -1;
            }
            return 0;
        });
        for (let g of fromEnum(c)) {
            return g;
        }
        return null;
    }
    e4() {
        this.bv = 0;
        this.ag.w();
        this.ag.v();
    }
    get bd() {
        return this.ck > 0;
    }
    provideContainer(a) {
        this.ae.ar(a);
        this.ag.u(a);
    }
    eg() {
        this.ae.am();
    }
    get o() {
        return this.k;
    }
    set o(a) {
        let b = this.k;
        this.k = a;
        if (b != a) {
            this.eh(b);
            this.ef(a);
        }
    }
    ef(a) {
        if (a != null) {
            if (this.nodePointerEnter != null) {
                this.nodePointerEnter(this, this.p(a));
            }
        }
    }
    eh(a) {
        if (a != null) {
            if (this.nodePointerLeave != null) {
                this.nodePointerLeave(this, this.p(a));
            }
        }
    }
    p(a) {
        let b = new TreemapNodePointerEventArgs();
        if (a != null) {
            b.customValue = a.d.g;
            b.item = a.d.h;
            b.position = this.fr;
            b.sum = a.d.e();
            b.value = a.d.f;
            b.label = a.d.j;
            b.isOverHeader = this.ba(this.fr, a);
            if (a.d.k != null && this.aa != null && this.aa.b.containsKey(a.d.k)) {
                let c = this.aa.b.item(a.d.k);
                b.parentItem = c.h;
                b.parentSum = c.e();
                b.parentValue = c.f;
                b.parentLabel = c.j;
            }
        }
        b.isRightButton = false;
        return b;
    }
    eq(a) {
        this.e7(a);
        if (this.nodePointerPressed != null && this.o != null) {
            let b = this.p(this.o);
            this.nodePointerPressed(this, b);
        }
    }
    eu(a) {
        this.e7(a);
        let b = false;
        if (this.nodePointerReleased != null && this.o != null) {
            let c = this.p(this.o);
            this.nodePointerReleased(this, c);
            b = c.isHandled;
        }
        if (!b) {
            if (this.n != null) {
                if (this.n.d == this.ac && this.ba(a, this.n)) {
                    this.ac = null;
                    this.a5 = true;
                    this.ae.az();
                    return;
                }
                this.ac = this.n.d;
                this.a5 = true;
                this.ae.az();
            }
            else {
                this.ac = null;
                this.a5 = true;
                this.ae.az();
            }
        }
    }
    ba(a, b) {
        let c = this.f;
        if (this.a2) {
            c = this.e;
        }
        if (b == null) {
            return false;
        }
        let d = b;
        if (a.x >= d.r.left && a.x <= d.r.right && a.y >= d.r.top && a.y <= d.r.bottom) {
            if (a.y - d.r.top <= d.e) {
                return true;
            }
        }
        return false;
    }
    em(source_, a, b, c) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (!this.be(source_)) {
            return;
        }
        let d = this.ai;
        if (d == null) {
            return;
        }
        d.handleCollectionChanged(new NotifyCollectionChangedEventArgs(2, 2, c, b, a));
    }
    ej(source_) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (!this.be(source_)) {
            return;
        }
        let a = this.ai;
        a.handleCollectionChanged(new NotifyCollectionChangedEventArgs(0, 4));
    }
    be(a) {
        return Treemap.bf(a, this.dataSource);
    }
    static bf(a, b) {
        return a == b;
    }
    ek(source_, a, b) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (!this.be(source_)) {
            return;
        }
        let c = this.ai;
        if (c == null) {
            return;
        }
        c.handleCollectionChanged(new NotifyCollectionChangedEventArgs(1, 0, b, a));
    }
    el(source_, a, b) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (!this.be(source_)) {
            return;
        }
        let c = this.ai;
        if (c == null) {
            return;
        }
        c.handleCollectionChanged(new NotifyCollectionChangedEventArgs(1, 1, b, a));
    }
    er(a) {
        this.e7(a);
    }
    es(a) {
        this.e7(a);
        this.n = null;
        this.o = null;
        this.a5 = true;
        this.ae.az();
    }
    e7(a) {
        this.fr = { $type: Point_$type, x: a.x, y: a.y };
        this.n = this.l(a);
        this.o = this.m(a);
        this.e6(a);
    }
    et(a) {
        this.e7(a);
        if (this.o != null) {
            if (this.nodePointerOver != null) {
                this.nodePointerOver(this, this.p(this.o));
            }
        }
    }
    e6(a) {
        if (!this.a2) {
            if (this.ba(a, this.n)) {
                let b = this.ad;
                this.ad = this.n.d;
                if (this.ad != b) {
                    this.a5 = true;
                    this.ae.az();
                }
            }
            else {
                let c = this.ad;
                this.ad = null;
                if (this.ad != c) {
                    this.a5 = true;
                    this.ae.az();
                }
            }
        }
    }
    ew(a) {
        this.e7(a);
        if (this.nodePointerPressed != null && this.o != null) {
            let b = this.p(this.o);
            b.isRightButton = true;
            this.nodePointerPressed(this, b);
        }
    }
    ex(a) {
        this.e7(a);
        let b = false;
        if (this.nodePointerReleased != null && this.o != null) {
            let c = this.p(this.o);
            c.isRightButton = true;
            this.nodePointerReleased(this, c);
            b = c.isHandled;
        }
        if (!b) {
            this.n = null;
            this.ac = null;
            this.a5 = true;
            this.ae.az();
        }
    }
    ey(a) {
        this.a5 = true;
        this.ae.az();
    }
}
Treemap.$t = markType(Treemap, 'Treemap', Base.$, [INotifyPropertyChanged_$type]);
/**
 * @hidden
 */
export class TreemapNodeStyle extends Base {
    constructor() {
        super(...arguments);
        this.a = null;
        this.c = new HashSet$1(String_$type, 0);
        this.ak = null;
        this.aj = null;
        this.am = null;
        this.p = null;
        this.ao = null;
        this.al = null;
        this.f = DeviceUtils.g(10);
        this.h = DeviceUtils.g(3);
        this.g = DeviceUtils.g(10);
        this.e = DeviceUtils.g(3);
        this.d = NaN;
        this.ai = null;
        this.an = null;
        this.i = NaN;
        this.propertyChanged = null;
    }
    ag(a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        this.ah(a, b, c);
    }
    af() {
        this.c.clear();
    }
    b(a) {
        return this.c.contains(a);
    }
    ah(a, b, c) {
        if (!this.c.contains(a)) {
            this.c.add_1(a);
        }
        switch (a) {
        }
        if (this.a != null) {
            this.a.ey(this);
        }
    }
    get ar() {
        return this.ak;
    }
    set ar(a) {
        let b = this.ak;
        this.ak = a;
        if (b != this.ak) {
            this.ag("HeaderHoverBackground", b, a);
        }
    }
    get aq() {
        return this.aj;
    }
    set aq(a) {
        let b = this.aj;
        this.aj = a;
        if (b != this.aj) {
            this.ag("HeaderBackground", b, a);
        }
    }
    get at() {
        return this.am;
    }
    set at(a) {
        let b = this.am;
        this.am = a;
        if (b != this.am) {
            this.ag("HeaderTextColor", b, a);
        }
    }
    get aa() {
        return this.p;
    }
    set aa(a) {
        let b = this.p;
        this.p = a;
        if (b != this.p) {
            this.ag("Label", b, a);
        }
    }
    get av() {
        return this.ao;
    }
    set av(a) {
        let b = this.ao;
        this.ao = a;
        if (b != this.ao) {
            this.ag("TextColor", b, a);
        }
    }
    get as() {
        return this.al;
    }
    set as(a) {
        let b = this.al;
        this.al = a;
        if (b != this.al) {
            this.ag("HeaderHoverTextColor", b, a);
        }
    }
    get l() {
        return this.f;
    }
    set l(a) {
        let b = this.f;
        this.f = a;
        if (b != this.f) {
            this.ag("HeaderLabelLeftMargin", b, a);
        }
    }
    get n() {
        return this.h;
    }
    set n(a) {
        let b = this.h;
        this.h = a;
        if (b != this.h) {
            this.ag("HeaderLabelTopMargin", b, a);
        }
    }
    get m() {
        return this.g;
    }
    set m(a) {
        let b = this.g;
        this.g = a;
        if (b != this.g) {
            this.ag("HeaderLabelRightMargin", b, a);
        }
    }
    get k() {
        return this.e;
    }
    set k(a) {
        let b = this.e;
        this.e = a;
        if (b != this.e) {
            this.ag("HeaderLabelBottomMargin", b, a);
        }
    }
    get j() {
        return this.d;
    }
    set j(a) {
        let b = this.d;
        this.d = a;
        if (b != this.d) {
            this.ag("HeaderHeight", b, a);
        }
    }
    get ap() {
        return this.ai;
    }
    set ap(a) {
        let b = this.ai;
        this.ai = a;
        if (b != this.ai) {
            this.ag("Fill", b, a);
        }
    }
    get au() {
        return this.an;
    }
    set au(a) {
        let b = this.an;
        this.an = a;
        if (b != this.an) {
            this.ag("Outline", b, a);
        }
    }
    get o() {
        return this.i;
    }
    set o(a) {
        let b = this.i;
        this.i = a;
        if (b != this.i) {
            this.ag("StrokeThickness", b, a);
        }
    }
}
TreemapNodeStyle.$t = markType(TreemapNodeStyle, 'TreemapNodeStyle', Base.$, [INotifyPropertyChanged_$type]);
/**
 * @hidden
 */
export class TreemapNodeStyleMapping extends TreemapNodeStyle {
    constructor() {
        super(...arguments);
        this.a4 = null;
        this.az = NaN;
        this.ay = NaN;
        this.a2 = null;
        this.aw = 1;
    }
    get a8() {
        return this.a4;
    }
    set a8(a) {
        let b = this.a4;
        this.a4 = a;
        if (b != this.a4) {
            this.ag("Name", b, a);
        }
    }
    get a1() {
        return this.az;
    }
    set a1(a) {
        let b = this.az;
        this.az = a;
        if (b != this.az) {
            this.ag("MinimumValue", b, a);
        }
    }
    get a0() {
        return this.ay;
    }
    set a0(a) {
        let b = this.ay;
        this.ay = a;
        if (b != this.ay) {
            this.ag("MaximumValue", b, a);
        }
    }
    get a3() {
        return this.a2;
    }
    set a3(a) {
        let b = this.a2;
        this.a2 = a;
        if (b != this.a2) {
            this.ag("Value", b, a);
        }
    }
    get ax() {
        return this.aw;
    }
    set ax(a) {
        let b = this.aw;
        this.aw = a;
        if (b != this.aw) {
            this.ag("MappingMode", enumGetBox(TreemapValueMappingMode_$type, b), enumGetBox(TreemapValueMappingMode_$type, a));
        }
    }
}
TreemapNodeStyleMapping.$t = markType(TreemapNodeStyleMapping, 'TreemapNodeStyleMapping', TreemapNodeStyle.$);
/**
 * @hidden
 */
export class TreemapNodeStyleMappingCollection extends ObservableCollection$1 {
    constructor() {
        super(TreemapNodeStyleMapping.$, 0);
        this.collectionResetting = null;
    }
    p() {
        if (this.collectionResetting != null) {
            this.collectionResetting(this, null);
        }
        super.p();
    }
}
TreemapNodeStyleMappingCollection.$t = markType(TreemapNodeStyleMappingCollection, 'TreemapNodeStyleMappingCollection', ObservableCollection$1.$.specialize(TreemapNodeStyleMapping.$));
/**
 * @hidden
 */
export class TreemapNodeStylingEventArgs extends EventArgs {
    constructor() {
        super(...arguments);
        this._value = 0;
        this._sum = 0;
        this._customValue = null;
        this._item = null;
        this._parentItem = null;
        this._label = null;
        this._parentValue = 0;
        this._parentLabel = null;
        this._parentSum = 0;
        this._style = null;
    }
    get value() {
        return this._value;
    }
    set value(a) {
        this._value = a;
    }
    get sum() {
        return this._sum;
    }
    set sum(a) {
        this._sum = a;
    }
    get customValue() {
        return this._customValue;
    }
    set customValue(a) {
        this._customValue = a;
    }
    get item() {
        return this._item;
    }
    set item(a) {
        this._item = a;
    }
    get parentItem() {
        return this._parentItem;
    }
    set parentItem(a) {
        this._parentItem = a;
    }
    get label() {
        return this._label;
    }
    set label(a) {
        this._label = a;
    }
    get parentValue() {
        return this._parentValue;
    }
    set parentValue(a) {
        this._parentValue = a;
    }
    get parentLabel() {
        return this._parentLabel;
    }
    set parentLabel(a) {
        this._parentLabel = a;
    }
    get parentSum() {
        return this._parentSum;
    }
    set parentSum(a) {
        this._parentSum = a;
    }
    get style() {
        return this._style;
    }
    set style(a) {
        this._style = a;
    }
}
TreemapNodeStylingEventArgs.$t = markType(TreemapNodeStylingEventArgs, 'TreemapNodeStylingEventArgs', EventArgs.$);
/**
 * @hidden
 */
export class TreemapFrame extends Base {
    constructor() {
        super();
        this.c = null;
        this.d = null;
        this.d = new List$1(String_$type, 0);
        this.c = new Dictionary$2(String_$type, TreemapNodeFrame.$, 0);
    }
    g(a, b, c) {
        this.f();
        for (let d = 0; d < b.d.count; d++) {
            let e = b.d._inner[d];
            if (c.c.containsKey(e)) {
                let f = TreemapNodeFrame.a(a, b.c.item(e), c.c.item(e));
                this.c.addItem(f.l, f);
                this.d.add(f.l);
            }
            else {
                let g = TreemapNodeFrame.c(a, b.c.item(e));
                this.c.addItem(g.l, g);
                this.d.add(g.l);
            }
        }
        for (let h = 0; h < c.d.count; h++) {
            let i = c.d._inner[h];
            if (!b.c.containsKey(i)) {
                let j = TreemapNodeFrame.b(a, c.c.item(i));
                this.c.addItem(j.l, j);
                this.d.add(j.l);
            }
        }
    }
    i(a, b) {
        let c;
        if (!((() => { let d = this.c.tryGetValue(a.i, c); c = d.p1; return d.ret; })())) {
            c = new TreemapNodeFrame();
            c.l = a.i;
            c.d = a;
            this.c.item(c.l, c);
            this.d.add(c.l);
        }
        c.r = b;
    }
    j(a) {
        let b;
        if (!((() => { let c = this.c.tryGetValue(a.i, b); b = c.p1; return c.ret; })())) {
            return Rect.empty;
        }
        return b.r;
    }
    h(a, b, c, d, e, f, g, h, i, j, k, l, m) {
        let n;
        if (!((() => { let o = this.c.tryGetValue(a.i, n); n = o.p1; return o.ret; })())) {
            return;
        }
        n.m = b;
        n.n = c;
        n.q = d;
        n.k = g;
        n.o = e;
        n.j = h;
        n.e = i;
        n.p = f;
        n.g = j;
        n.i = k;
        n.h = l;
        n.f = m;
    }
    f() {
        this.d.clear();
        this.c.clear();
    }
    b(a) {
        return this.c.containsKey(a);
    }
    a(a) {
        return this.c.item(a);
    }
    e(a, b) {
        let c;
        if (!((() => { let d = this.c.tryGetValue(a.i, c); c = d.p1; return d.ret; })())) {
            return;
        }
        if (b.b("Label")) {
            c.m = b.aa;
        }
        if (b.b("Fill")) {
            c.n = b.ap;
        }
        if (b.b("Outline")) {
            c.q = b.au;
        }
        if (b.b("StrokeThickness")) {
            c.k = b.o;
        }
        if (b.b("HeaderBackground")) {
            c.o = b.aq;
        }
        if (a.b != null && a.b.count > 0) {
            if (b.b("HeaderTextColor")) {
                c.p = b.at;
            }
        }
        else {
            if (b.b("TextColor")) {
                c.p = b.av;
            }
        }
        if (b.b("HeaderLabelLeftMargin")) {
            c.g = b.l;
        }
        if (b.b("HeaderLabelTopMargin")) {
            c.i = b.n;
        }
        if (b.b("HeaderLabelRightMargin")) {
            c.h = b.m;
        }
        if (b.b("HeaderLabelBottomMargin")) {
            c.f = b.k;
        }
    }
}
TreemapFrame.$t = markType(TreemapFrame, 'TreemapFrame');
/**
 * @hidden
 */
export class TreemapNodeFrame extends Base {
    constructor() {
        super();
        this.r = null;
        this.d = null;
        this.l = null;
        this.m = null;
        this.n = null;
        this.q = null;
        this.k = 0;
        this.g = 0;
        this.i = 0;
        this.h = 0;
        this.f = 0;
        this.p = null;
        this.o = null;
        this.j = 0;
        this.e = 0;
        this.r = Rect.empty;
    }
    static a(a, b, c) {
        let d = new TreemapNodeFrame();
        d.d = c.d;
        d.l = c.l;
        d.m = c.m;
        let e = c.r;
        if (e.isEmpty) {
            e = new Rect(0, 0, 0, 0, 0);
        }
        let f = b.r;
        if (f.isEmpty) {
            f = new Rect(0, 0, 0, 0, 0);
        }
        d.r = new Rect(0, f.left + (e.left - f.left) * a, f.top + (e.top - f.top) * a, f.width + (e.width - f.width) * a, f.height + (e.height - f.height) * a);
        d.n = BrushUtil.g(b.n, a, c.n, 0);
        d.q = BrushUtil.g(b.q, a, c.q, 0);
        d.o = BrushUtil.g(b.o, a, c.o, 0);
        d.p = BrushUtil.g(b.p, a, c.p, 0);
        d.k = b.k + (c.k - b.k) * a;
        d.g = b.g + (c.g - b.g) * a;
        d.i = b.i + (c.i - b.i) * a;
        d.h = b.h + (c.h - b.h) * a;
        d.f = b.f + (c.f - b.f) * a;
        d.j = b.j + (c.j - b.j) * a;
        d.e = b.e + (c.e - b.e) * a;
        return d;
    }
    static c(a, b) {
        let c = new Rect(0, 0, 0, 0, 0);
        let d = new TreemapNodeFrame();
        d.d = b.d;
        d.m = b.m;
        d.l = b.l;
        let e = b.r;
        if (e.isEmpty) {
            e = new Rect(0, 0, 0, 0, 0);
        }
        d.r = new Rect(0, e.left + (c.left - e.left) * a, e.top + (c.top - e.top) * a, e.width + (c.width - e.width) * a, e.height + (c.height - e.height) * a);
        d.n = BrushUtil.g(b.n, a, null, 0);
        d.q = BrushUtil.g(b.q, a, null, 0);
        d.o = BrushUtil.g(b.o, a, null, 0);
        d.p = BrushUtil.g(b.p, a, null, 0);
        d.k = b.k + (0 - b.k) * a;
        d.g = b.g + (0 - b.g) * a;
        d.i = b.i + (0 - b.i) * a;
        d.h = b.h + (0 - b.h) * a;
        d.f = b.f + (0 - b.f) * a;
        d.j = b.j + (0 - b.j) * a;
        d.e = b.e + (0 - b.e) * a;
        return d;
    }
    static b(a, b) {
        let c = new Rect(0, 0, 0, 0, 0);
        let d = new TreemapNodeFrame();
        d.d = b.d;
        d.m = b.m;
        d.l = b.l;
        let e = b.r;
        if (e.isEmpty) {
            e = new Rect(0, 0, 0, 0, 0);
        }
        d.r = new Rect(0, c.left + (e.left - c.left) * a, c.top + (e.top - c.top) * a, c.width + (e.width - c.width) * a, c.height + (e.height - c.height) * a);
        d.n = BrushUtil.g(null, a, b.n, 0);
        d.q = BrushUtil.g(null, a, b.q, 0);
        d.o = BrushUtil.g(null, a, b.o, 0);
        d.p = BrushUtil.g(null, a, b.p, 0);
        d.k = 0 + (b.k - 0) * a;
        d.g = 0 + (b.g - 0) * a;
        d.i = 0 + (b.i - 0) * a;
        d.h = 0 + (b.h - 0) * a;
        d.f = 0 + (b.f - 0) * a;
        d.j = 0 + (b.j - 0) * a;
        d.e = 0 + (b.e - 0) * a;
        return d;
    }
}
TreemapNodeFrame.$t = markType(TreemapNodeFrame, 'TreemapNodeFrame');
//# sourceMappingURL=TreemapView_combined.js.map