/*
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 { MarkerManagerBase } from "./MarkerManagerBase";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Marker } from "./Marker";
import { Base, Number_$type, Point_$type, fromEnum, markType } from "igniteui-react-core/ES2015/type";
import { OwnedPoint } from "./OwnedPoint";
import { boxArray$1 } from "igniteui-react-core/ES2015/array";
import { CompareUtil } from "igniteui-react-core/ES2015/compareUtil";
/**
 * @hidden
 */
export class BubbleMarkerManager extends MarkerManagerBase {
    constructor(a, b, c, d, e) {
        super(a, b, c, d, e);
        this.m = null;
        this.o = null;
        this.n = null;
        this.o = new List$1(Number_$type, 0);
        this.n = new List$1(Marker.$, 0);
    }
    l(a, b, c, d, e) {
        let f = this.f();
        a.clear();
        this.o.clear();
        this.n.clear();
        let g = new List$1(Number_$type, 0);
        b = Math.max(0, b);
        let h = null;
        this.i(c, d, boxArray$1(f), g);
        if (b >= g.count) {
            h = g;
        }
        else {
            h = new List$1(Number_$type, 0);
            let i = Math.max(8, e);
            let j = this.c(d, g, i, boxArray$1(f));
            let k = new List$1(Number_$type, 1, j.keys);
            if (MarkerManagerBase.b) {
                k.y();
            }
            this.k(b, j, k, h);
        }
        for (let l = 0; l < h.count; ++l) {
            let m = f[h._inner[l]].x;
            let n = f[h._inner[l]].y;
            let o = this.m.item(h._inner[l]);
            this.o.add(o);
            let p = this.h(this.g(h._inner[l]));
            p.content.item = this.g(h._inner[l]);
            let q = new OwnedPoint();
            q.a = p.content.item;
            q.c = { $type: Point_$type, x: m, y: n };
            if (!a.containsKey(q.a)) {
                a.addItem(q.a, q);
                this.n.add(p);
            }
        }
    }
    j(a, b) {
        let c = new List$1(Base.$, 1, a.keys);
        if (MarkerManagerBase.b) {
            c.aa((d, e) => {
                let f = a.item(d);
                let g = a.item(e);
                let h = Math.pow(f.c.x, 2) + Math.pow(f.c.y, 2);
                let i = Math.pow(g.c.x, 2) + Math.pow(g.c.y, 2);
                return CompareUtil.compareToObject(h, i);
            });
        }
        for (let d of fromEnum(c)) {
            let e = a.item(d);
            let f = this.h(e.a);
            f.s = c.indexOf1(d);
            f.n = e.c.x;
            f.o = e.c.y;
        }
        this.a(a);
    }
}
BubbleMarkerManager.$t = markType(BubbleMarkerManager, 'BubbleMarkerManager', MarkerManagerBase.$);
