/*
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, Point_$type, markType } from "./type";
import { List$1 } from "./List$1";
import { LabelCollisionPlacementPositions_$type } from "./LabelCollisionPlacementPositions";
import { QuadTree } from "./QuadTree";
import { LinkedList$1 } from "./LinkedList$1";
import { LabelCollisionInfo } from "./LabelCollisionInfo";
import { QuadTreeBoundingBox } from "./QuadTreeBoundingBox";
import { Random } from "./Random";
import { HashSet$1 } from "./HashSet$1";
import { GeometryUtil } from "./GeometryUtil";
import { truncate, isNaN_ } from "./number";
/**
 * @hidden
 */
export let LabelCollisionManager = /*@__PURE__*/ (() => {
    class LabelCollisionManager extends Base {
        constructor(a, b, c, d, e, f, g, h, i, j, k) {
            super();
            this.l = false;
            this.a = new Array(8);
            this.y = null;
            this.labelsMoved = null;
            this.j = null;
            this.h = null;
            this.g = 0;
            this.e = null;
            this.x = null;
            this.ad = 0;
            this.ak = 0;
            this.aj = 0;
            this.a5 = null;
            this.ae = 0;
            this.ac = 0;
            this.v = new LinkedList$1(LabelCollisionInfo.$);
            this.ag = 0;
            this.w = new List$1(LabelCollisionInfo.$, 0);
            this.n = false;
            this.m = false;
            this.ai = 0;
            this.af = 0;
            this.z = 0;
            this.aa = 0;
            this.ah = 0;
            this.o = false;
            this.k = false;
            this.b = null;
            this.ap = null;
            this.an = null;
            this.l = k != null;
            this.a5 = c;
            this.ae = a;
            this.ac = b;
            this.h = new QuadTree(a, b, 8, 8);
            this.g = f;
            this.e = d;
            this.x = new List$1(LabelCollisionPlacementPositions_$type, 0);
            this.x.add(0);
            this.x.add(5);
            this.x.add(7);
            this.x.add(2);
            this.x.add(3);
            this.x.add(6);
            this.x.add(1);
            this.x.add(4);
            let l = 0;
            for (let m = 0; m < g.length; m++) {
                if (this.x.contains(g[m])) {
                    this.x.remove(g[m]);
                    this.x.insert(l, g[m]);
                    l++;
                }
            }
            if (k != null) {
                this.y = new List$1(LabelCollisionPlacementPositions_$type, 0);
                for (let n = 0; n < this.a.length; n++) {
                    this.a[n] = false;
                }
                for (let o = 0; o < k.length; o++) {
                    this.a[k[o]] = true;
                    this.y.add(k[o]);
                }
                this.b = k;
            }
            else {
                this.y = new List$1(LabelCollisionPlacementPositions_$type, 0);
                this.y.add(0);
                this.y.add(5);
                this.y.add(7);
                this.y.add(2);
                this.y.add(3);
                this.y.add(6);
                this.y.add(1);
                this.y.add(4);
                let p = 0;
                for (let q = 0; q < g.length; q++) {
                    if (this.y.contains(g[q])) {
                        this.y.remove(g[q]);
                        this.y.insert(p, g[q]);
                        p++;
                    }
                }
            }
            this.ad = e;
            this.ak = h;
            this.aj = i;
            this.k = j;
        }
        i(a, b, c, d, e) {
            let f = 0;
            let g = 0;
            switch (b) {
                case 0:
                    f = a.o;
                    g = (((a.p - a.m) - a.k) - this.ad - d);
                    break;
                case 4:
                    f = (((a.o - a.n) - a.l) - this.ad) - c;
                    g = (((a.p - a.m) - a.k) - this.ad) - d;
                    break;
                case 5:
                    f = (((a.o + a.n) + a.l) + this.ad) + c;
                    g = (((a.p - a.m) - a.k) - this.ad) - d;
                    break;
                case 1:
                    f = (((a.o - a.n) - a.l) - this.ad) - c;
                    g = a.p;
                    break;
                case 2:
                    f = (((a.o + a.n) + a.l) + this.ad) + c;
                    g = a.p;
                    break;
                case 3:
                    f = a.o;
                    g = (((a.p + a.m) + a.k) + this.ad) + d;
                    break;
                case 6:
                    f = (((a.o - a.n) - a.l) - this.ad) - c;
                    g = (((a.p + a.m) + a.k) + this.ad) + d;
                    break;
                case 7:
                    f = (((a.o + a.n) + a.l) + this.ad) + c;
                    g = (((a.p + a.m) + a.k) + this.ad) - d;
                    break;
            }
            let h = new QuadTreeBoundingBox();
            h.b = f;
            h.c = g;
            h.e = a.l;
            h.d = a.k;
            h.g = a;
            if (this.s(h) && !e) {
                return null;
            }
            return h;
        }
        s(a) {
            let b = a.b - a.e;
            let c = a.b + a.e;
            let d = a.c - a.d;
            let e = a.c + a.d;
            let f = this.a5;
            if (b < f.left || c > f.right || d < f.top || e > f.bottom) {
                return true;
            }
            return false;
        }
        ax(a, b, c, d, e) {
            this.aw(a, b, c, d, e);
        }
        aw(a, b, c, d, e) {
            this.h.d(a);
            a.b = b;
            a.c = c;
            a.e = d;
            a.d = e;
            this.h.c(a);
        }
        a1(a) {
            this.h.d(a);
        }
        aq(a) {
            this.ag++;
            this.v.f(a);
            a.e = this.v.d;
            if (a.c == null) {
                a.c = new QuadTreeBoundingBox();
                a.c.b = a.o;
                a.c.c = a.p;
                a.c.e = a.n;
                a.c.d = a.m;
                a.c.g = a;
                this.h.c(a.c);
            }
        }
        a2(a) {
            if (a.c != null) {
                this.h.d(a.c);
                a.c = null;
            }
            if (a.b != null) {
                this.h.d(a.b);
                a.b = null;
            }
            if (a.e != null) {
                this.v.h(a.e);
                a.e = null;
            }
            this.ag--;
        }
        az(a) {
            if (a.c != null && a.c.b == a.o && a.c.c == a.p) {
                return;
            }
            if (a.c != null) {
                this.h.d(a.c);
            }
            let b = NaN;
            let c = NaN;
            if (a.c == null) {
                a.c = new QuadTreeBoundingBox();
                a.c.g = a;
            }
            else {
                if (a.b != null) {
                    b = a.b.b - a.c.b;
                    c = a.b.c - a.c.c;
                }
            }
            a.c.b = a.o;
            a.c.c = a.p;
            a.c.e = a.n;
            a.c.d = a.m;
            this.h.c(a.c);
            if (a.b != null) {
                this.h.d(a.b);
                if (!isNaN_(b)) {
                    a.b = new QuadTreeBoundingBox();
                    a.b.b = a.c.b + b;
                    a.b.c = a.c.c + c;
                    a.b.g = a;
                    a.b.e = a.l;
                    a.b.d = a.k;
                    a.g = a.b.b;
                    a.h = a.b.c;
                    this.h.c(a.b);
                }
                else {
                    a.b = this.i(a, a.a, 0, 0, true);
                    a.g = a.b.b;
                    a.h = a.b.c;
                    this.h.c(a.b);
                }
            }
        }
        ay(a) {
            this.h.d(a.b);
            a.b.b = a.g;
            a.b.c = a.h;
            a.b.e = a.l;
            a.b.d = a.k;
            this.h.c(a.b);
        }
        a4() {
            this.m = false;
            {
                let a = this.v.c;
                while (a != null) {
                    if (a.c.b != null) {
                        this.h.d(a.c.b);
                        a.c.b = null;
                        if (a.c.f != null) {
                            a.c.f.clear();
                        }
                    }
                    a = a.a;
                }
                this.ah = 0;
            }
            this.af = 0;
            this.z = 0.4;
            this.aa = 0.4;
            let b = truncate(Math.ceil((this.aj / 150) * this.ak));
            this.ai = b;
            this.at();
        }
        as() {
            this.w.clear();
        }
        ar() {
            this.m = true;
        }
        av() {
            this.n = false;
            if (this.m) {
                return;
            }
            this.at();
        }
        at() {
            this.w.clear();
            this.a0(false);
            if (this.g == 0) {
                for (let a = 0; a < this.ak; a++) {
                    this.aa = this.z * (this.ai - this.af) / this.ai;
                    this.au();
                    this.af++;
                    if (this.af > this.ai) {
                        if (this.j != null) {
                            this.j();
                        }
                        return;
                    }
                }
                if (this.labelsMoved != null) {
                    this.labelsMoved(this.w);
                }
                if (this.ah > 0) {
                    if (!this.n) {
                        this.n = true;
                        this.e.executeDelayed(runOn(this, this.av), 150);
                    }
                }
                else {
                    if (this.j != null) {
                        this.j();
                    }
                }
            }
            else {
                if (this.g == 2) {
                    let b = this.v.c;
                    this.h.k();
                    while (b != null) {
                        let c = b.c;
                        if (c.b != null) {
                            this.h.d(c.b);
                            c.b = null;
                            c.d = false;
                            c.f = null;
                        }
                        b = b.a;
                    }
                    this.ah = 0;
                    this.a0(true);
                }
                if (this.labelsMoved != null) {
                    this.labelsMoved(this.w);
                }
            }
        }
        au() {
            let a = truncate(Math.round((this.ag - 1) * LabelCollisionManager.ao.nextDouble()));
            let b = 0;
            let c = this.v.c;
            let d = this.ab(null);
            let e = 30;
            let f = 60;
            while (c != null) {
                let g = c.c;
                let h = 0;
                let i = 0;
                if (this.k) {
                    h = LabelCollisionManager.ao.nextDouble() * g.l * 2;
                    i = LabelCollisionManager.ao.nextDouble() * g.k * 2;
                }
                if (b == a) {
                    let j = truncate(Math.round((this.y.count - 1) * LabelCollisionManager.ao.nextDouble()));
                    while (this.y._inner[j] == g.a) {
                        j = truncate(Math.round((this.y.count - 1) * LabelCollisionManager.ao.nextDouble()));
                    }
                    let k = g.b;
                    let l = this.i(g, this.y._inner[j], h, i, false);
                    let m = 0;
                    while (l == null) {
                        if (m >= e) {
                            h = 0;
                            i = 0;
                        }
                        if (m >= f) {
                            break;
                        }
                        j = truncate(Math.round((this.y.count - 1) * LabelCollisionManager.ao.nextDouble()));
                        l = this.i(g, this.y._inner[j], h, i, false);
                        m++;
                    }
                    g.b = l;
                    if (k != null) {
                        this.h.d(k);
                    }
                    if (l != null) {
                        this.h.c(l);
                        let n = this.ab(g);
                        let o = d > n;
                        if (!o) {
                            let p = Math.exp(-(n - d) / this.aa);
                            if (LabelCollisionManager.ao.nextDouble() < p) {
                                o = true;
                            }
                        }
                        if (!o && k != null) {
                            this.h.d(l);
                            this.h.c(k);
                            g.b = k;
                            if (!this.o) {
                                this.ab(g);
                            }
                        }
                        else {
                            g.a = this.y._inner[j];
                            g.g = g.b.b;
                            g.h = g.b.c;
                            this.w.add(g);
                        }
                    }
                    else {
                        if (!this.o) {
                            this.ab(g);
                        }
                        g.d = false;
                        this.w.add(g);
                    }
                    break;
                }
                b++;
                c = c.a;
            }
        }
        ab(a) {
            if (this.o) {
                let b = 0;
                let c = this.v.c;
                while (c != null) {
                    let d = c.c;
                    let e = d.d;
                    d.d = false;
                    if (d.b != null) {
                        let f = this.h.e(d.b);
                        for (let g = 0; g < f.count; g++) {
                            let h = f._inner[g].l.c;
                            while (h != null) {
                                let i = h.c;
                                if (i.g == d) {
                                    h = h.a;
                                    continue;
                                }
                                if (d.b.a(i)) {
                                    d.d = true;
                                    b += d.b.f(i);
                                }
                                h = h.a;
                            }
                        }
                        if (d.d != e) {
                            this.w.add(d);
                        }
                    }
                    c = c.a;
                }
                return b;
            }
            else {
                if (a != null) {
                    let j = new HashSet$1(LabelCollisionInfo.$, 0);
                    let k = new HashSet$1(LabelCollisionInfo.$, 0);
                    let l = new HashSet$1(LabelCollisionInfo.$, 0);
                    let m = new List$1(LabelCollisionInfo.$, 0);
                    if (a.f != null) {
                        for (let n = 0; n < a.f.count; n++) {
                            j.add_1(a.f._inner[n]);
                            k.add_1(a.f._inner[n]);
                        }
                    }
                    let o = a.d;
                    a.d = false;
                    if (a.b != null) {
                        let p = this.h.e(a.b);
                        for (let q = 0; q < p.count; q++) {
                            let r = p._inner[q].l.c;
                            while (r != null) {
                                let s = r.c;
                                if (s.g == a) {
                                    r = r.a;
                                    continue;
                                }
                                if (a.b.a(s) && !l.contains(s.g)) {
                                    a.d = true;
                                    l.add_1(s.g);
                                    m.add(s.g);
                                }
                                r = r.a;
                            }
                        }
                        p = this.h.e(a.c);
                        for (let t = 0; t < p.count; t++) {
                            let u = p._inner[t].l.c;
                            while (u != null) {
                                let v = u.c;
                                if (v.g == a) {
                                    u = u.a;
                                    continue;
                                }
                                if (this.p(a.c, v)) {
                                    u = u.a;
                                    continue;
                                }
                                if (a.c.a(v) && !l.contains(v.g)) {
                                    a.d = true;
                                    l.add_1(v.g);
                                    m.add(v.g);
                                }
                                u = u.a;
                            }
                        }
                        if (a.d != o) {
                            this.w.add(a);
                        }
                        if (a.f != null) {
                            for (let w = a.f.count - 1; w >= 0; w--) {
                                if (!l.contains(a.f._inner[w])) {
                                    let x = a.f._inner[w];
                                    let y = x.f.remove(a);
                                    a.f.removeAt(w);
                                    if (x.f.count == 0 && y) {
                                        this.ah--;
                                    }
                                    let z = j.remove(x);
                                    if (j.count == 0 && z) {
                                        this.ah--;
                                    }
                                }
                            }
                        }
                        for (let aa = 0; aa < m.count; aa++) {
                            let ab = m._inner[aa];
                            if (!j.contains(ab)) {
                                if (a.f == null) {
                                    a.f = new List$1(LabelCollisionInfo.$, 0);
                                }
                                a.f.add(ab);
                                if (j.count == 0) {
                                    this.ah++;
                                }
                                j.add_1(ab);
                                if (ab.f == null) {
                                    ab.f = new List$1(LabelCollisionInfo.$, 0);
                                }
                                if (ab.f.count == 0) {
                                    this.ah++;
                                }
                                ab.f.add(a);
                            }
                        }
                    }
                }
                return this.ah;
            }
        }
        p(a, b) {
            if (a.g.c == a && b.g.c == b) {
                return true;
            }
            return false;
        }
        get al() {
            return this.ah;
        }
        a3(a, b, c) {
            this.a5 = c;
            let d = new QuadTree(a, b, this.h.i, this.h.f);
            let e = this.v.c;
            while (e != null) {
                d.c(e.c.c);
                if (e.c.b != null) {
                    d.c(e.c.b);
                }
                e = e.a;
            }
            this.h = d;
            this.ae = a;
            this.ac = b;
        }
        u() {
            let a = this.v.c;
            while (a != null) {
                a.c.d = false;
                if (a.c.b != null) {
                    if (this.s(a.c.b)) {
                        return true;
                    }
                }
                a = a.a;
            }
            return false;
        }
        q() {
            let a = this.v.c;
            let b = this.y;
            while (a != null) {
                if (a.c.b != null) {
                    if (this.s(a.c.b)) {
                        let c = a.c;
                        for (let d = 0; d < b.count; d++) {
                            let e = this.i(c, b._inner[d], 0, 0, false);
                            if (e != null) {
                                return true;
                            }
                        }
                    }
                }
                a = a.a;
            }
            return false;
        }
        am() {
            let a = this.v.c;
            while (a != null) {
                a.c.d = false;
                a = a.a;
            }
            a = this.v.c;
            while (a != null) {
                let b = a.c.b;
                let c = a.c.c;
                let d = this.h.e(c);
                for (let e = 0; e < d.count; e++) {
                    let f = d._inner[e].l.c;
                    while (f != null) {
                        let g = f.c;
                        if (this.p(c, g)) {
                            f = f.a;
                            continue;
                        }
                        if (c.a(g)) {
                            let h = f.c.g;
                            if (h != a.c) {
                                h.d = true;
                                a.c.d = true;
                            }
                        }
                        f = f.a;
                    }
                }
                if (b == null) {
                    return -1;
                }
                d = this.h.e(b);
                for (let i = 0; i < d.count; i++) {
                    let j = d._inner[i].l.c;
                    while (j != null) {
                        let k = j.c;
                        if (b.a(k)) {
                            let l = j.c.g;
                            if (l != a.c) {
                                l.d = true;
                                a.c.d = true;
                            }
                        }
                        j = j.a;
                    }
                }
                a = a.a;
            }
            let m = 0;
            a = this.v.c;
            while (a != null) {
                if (a.c.d) {
                    m++;
                }
                a = a.a;
            }
            return m;
        }
        a0(a) {
            let b = this.v.c;
            while (b != null) {
                let c = b.c;
                if (c.b == null || a) {
                    let d = false;
                    if (a) {
                        let e = this.h.a(c.o, c.p, 1.5);
                        let f = this.c(e);
                        if (f != null) {
                            for (let g = 0; g < f.length; g++) {
                                let h = f[g];
                                let i = this.i(c, h, 0, 0, false);
                                if (i == null) {
                                    continue;
                                }
                                let j = this.h.e(i);
                                d = true;
                                for (let k = 0; k < j.count; k++) {
                                    let l = j._inner[k].l.c;
                                    while (l != null) {
                                        let m = l.c;
                                        if (i.a(m)) {
                                            d = false;
                                            break;
                                        }
                                        l = l.a;
                                    }
                                }
                                if (d) {
                                    c.b = i;
                                    c.a = h;
                                    c.g = c.b.b;
                                    c.h = c.b.c;
                                    this.h.c(c.b);
                                    this.w.add(c);
                                    break;
                                }
                            }
                        }
                    }
                    if (!d) {
                        d = this.t(c, false);
                    }
                    if (!d) {
                        if (c.b == null) {
                            this.t(c, true);
                        }
                    }
                }
                b = b.a;
            }
        }
        t(a, b) {
            let c = this.y;
            let d = false;
            if (!d) {
                for (let e = 0; e < c.count; e++) {
                    let f = this.i(a, c._inner[e], 0, 0, b);
                    if (f == null) {
                        continue;
                    }
                    d = !this.r(f, a);
                    let g = a.c;
                    if (g == null) {
                        g = new QuadTreeBoundingBox();
                        g.g = a;
                        g.b = a.o;
                        g.c = a.p;
                        g.e = a.n;
                        g.d = a.m;
                        this.h.c(g);
                        a.c = g;
                    }
                    let h = this.r(g, a);
                    d = d && !h;
                    if (d) {
                        a.b = f;
                        a.a = c._inner[e];
                        a.g = a.b.b;
                        a.h = a.b.c;
                        this.h.c(a.b);
                        this.w.add(a);
                        break;
                    }
                }
            }
            if (!d) {
                let i = Number.POSITIVE_INFINITY;
                let j = 0;
                let k = null;
                for (let l = 0; l < c.count; l++) {
                    let m = 0;
                    let n = null;
                    let o = new HashSet$1(LabelCollisionInfo.$, 0);
                    if (!this.o) {
                        n = new List$1(LabelCollisionInfo.$, 0);
                    }
                    let p = this.i(a, c._inner[l], 0, 0, b);
                    if (p == null) {
                        continue;
                    }
                    let q = this.h.e(p);
                    for (let r = 0; r < q.count; r++) {
                        let s = q._inner[r].l.c;
                        while (s != null) {
                            let t = s.c;
                            if (p.a(t)) {
                                m += p.f(t);
                                if (!this.o) {
                                    if (!o.contains(t.g)) {
                                        n.add(t.g);
                                        o.add_1(t.g);
                                    }
                                }
                            }
                            s = s.a;
                        }
                    }
                    let u = a.c;
                    if (u == null) {
                        u = new QuadTreeBoundingBox();
                        u.g = a;
                        u.b = a.o;
                        u.c = a.p;
                        u.e = a.n;
                        u.d = a.m;
                    }
                    q = this.h.e(u);
                    for (let v = 0; v < q.count; v++) {
                        let w = q._inner[v].l.c;
                        while (w != null) {
                            let x = w.c;
                            if (w.c.g == a) {
                                w = w.a;
                                continue;
                            }
                            if (this.p(u, x)) {
                                w = w.a;
                                continue;
                            }
                            if (u.a(x)) {
                                if (!this.o) {
                                    if (!o.contains(x.g)) {
                                        n.add(x.g);
                                        o.add_1(x.g);
                                    }
                                }
                            }
                            w = w.a;
                        }
                    }
                    if (m < i) {
                        let y = this.i(a, c._inner[l], 0, 0, b);
                        if (y != null) {
                            i = m;
                            j = l;
                            if (!this.o) {
                                k = n;
                            }
                        }
                    }
                }
                let z = this.i(a, c._inner[j], 0, 0, b);
                a.d = true;
                if (!this.o) {
                    if (a.f != null && a.f.count > 0) {
                        this.ah--;
                        for (let aa = a.f.count - 1; aa >= 0; aa--) {
                            let ab = a.f._inner[aa];
                            if (ab.f != null) {
                                ab.f.remove(a);
                                if (ab.f.count == 0) {
                                    this.ah--;
                                }
                            }
                        }
                    }
                    if (k == null) {
                        a.d = false;
                        this.w.add(a);
                        return false;
                    }
                    a.f = k;
                    if (k.count > 0) {
                        this.ah++;
                    }
                    for (let ac = 0; ac < k.count; ac++) {
                        let ad = k._inner[ac];
                        if (ad.f == null) {
                            ad.f = new List$1(LabelCollisionInfo.$, 0);
                        }
                        if (!ad.f.contains(a)) {
                            if (ad.f.count == 0) {
                                this.ah++;
                            }
                            ad.f.add(a);
                        }
                    }
                }
                a.b = z;
                a.a = c._inner[j];
                a.g = a.b.b;
                a.h = a.b.c;
                this.h.c(a.b);
                this.w.add(a);
            }
            return d;
        }
        r(a, b) {
            let c = false;
            let d = this.h.e(a);
            for (let e = 0; e < d.count; e++) {
                let f = d._inner[e].l.c;
                while (f != null) {
                    if (f.c.g == b) {
                        f = f.a;
                        continue;
                    }
                    let g = f.c;
                    if (this.p(a, g)) {
                        f = f.a;
                        continue;
                    }
                    if (a.a(g)) {
                        c = true;
                        break;
                    }
                    f = f.a;
                }
            }
            return c;
        }
        c(a) {
            let b = new Array(3);
            let c = GeometryUtil.f({ $type: Point_$type, x: 0, y: 0 }, { $type: Point_$type, x: a.a, y: a.b });
            c = c * 180 / Math.PI;
            c = GeometryUtil.i(c);
            if ((c >= 0 && c <= 22.5) || (c >= 337.5 && c <= 360)) {
                b[0] = 2;
                b[1] = 5;
                b[2] = 7;
            }
            if (c >= 22.5 && c <= 67.5) {
                b[0] = 2;
                b[1] = 7;
                b[2] = 3;
            }
            if (c >= 67.5 && c <= 112.5) {
                b[0] = 7;
                b[1] = 3;
                b[2] = 6;
            }
            if (c >= 112.5 && c <= 157.5) {
                b[0] = 3;
                b[1] = 6;
                b[2] = 1;
            }
            if (c >= 157.5 && c <= 202.5) {
                b[0] = 6;
                b[1] = 1;
                b[2] = 4;
            }
            if (c >= 202.5 && c <= 247.5) {
                b[0] = 1;
                b[1] = 4;
                b[2] = 0;
            }
            if (c >= 247.5 && c <= 292.5) {
                b[0] = 4;
                b[1] = 0;
                b[2] = 5;
            }
            if (c >= 292.5 && c <= 337.5) {
                b[0] = 0;
                b[1] = 5;
                b[2] = 2;
            }
            if (this.l) {
                let d = 0;
                for (let e = 0; e < b.length; e++) {
                    if (this.a[b[e]]) {
                        d++;
                    }
                }
                if (d == 0) {
                    return null;
                }
                let f = 0;
                let g = new Array(d);
                for (let h = 0; h < b.length; h++) {
                    if (this.a[b[h]]) {
                        g[f] = b[h];
                        f++;
                    }
                }
                b = g;
            }
            return b;
        }
        f(a, b) {
            let c = false;
            let d = null;
            let e = new QuadTreeBoundingBox();
            e.b = a.x;
            e.c = a.y;
            e.e = 5;
            e.d = 5;
            let f = this.h.e(e);
            for (let g = 0; g < f.count; g++) {
                let h = f._inner[g].l.c;
                while (h != null) {
                    let i = h.c;
                    if (i.g.c == i) {
                        h = h.a;
                        continue;
                    }
                    if (e.a(i)) {
                        d = i;
                        c = true;
                        break;
                    }
                    h = h.a;
                }
            }
            if (c) {
                return d.g;
            }
            else {
                return null;
            }
        }
    }
    LabelCollisionManager.$t = markType(LabelCollisionManager, 'LabelCollisionManager');
    LabelCollisionManager.ao = new Random(0);
    return LabelCollisionManager;
})();
