/*
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, Number_$type, fromEnum, markType } from "igniteui-react-core/ES2015/type";
import { Dictionary$2 } from "igniteui-react-core/ES2015/Dictionary$2";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
/**
 * @hidden
 */
export class PolylineBuilder extends Base {
    constructor() {
        super(...arguments);
        this.a = new Dictionary$2(Number_$type, List$1.$.specialize(Number_$type), 0);
        this.b = new Dictionary$2(Number_$type, List$1.$.specialize(Number_$type), 0);
    }
    e() {
        this.a.clear();
        this.b.clear();
    }
    c() {
        let a = new List$1(List$1.$.specialize(Number_$type), 0);
        for (let b of fromEnum(this.a.values)) {
            a.add(b);
        }
        return a;
    }
    d(a, b) {
        let c = null;
        let d = null;
        let e = this.b.tryGetValue(a, c);
        c = e.p1;
        let f = this.a.tryGetValue(b, d);
        d = f.p1;
        if (c == null && d == null) {
            let g = new List$1(Number_$type, 0);
            g.add(a);
            g.add(b);
            this.a.addItem(a, g);
            this.b.addItem(b, g);
        }
        if (c == null && d != null) {
            this.a.removeItem(b);
            d.insert(0, a);
            this.a.addItem(a, d);
        }
        if (c != null && d == null) {
            this.b.removeItem(a);
            c.add(b);
            this.b.addItem(b, c);
        }
        if (c != null && d != null) {
            if (c == d) {
                c.add(b);
                this.b.removeItem(a);
            }
            else {
                this.a.removeItem(d._inner[0]);
                this.b.removeItem(d._inner[d.count - 1]);
                this.b.removeItem(c._inner[c.count - 1]);
                c.o(d);
                this.b.addItem(c._inner[c.count - 1], c);
            }
        }
    }
}
PolylineBuilder.$t = markType(PolylineBuilder, 'PolylineBuilder');
