/*
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, typeGetValue, String_$type, typeCast, Array_$type, fromEnum, markType } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { DocCoreUtils } from "./DocCoreUtils";
import { Encoding } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { BinaryReader } from "igniteui-angular-core";
import { InformationBase_PropertySectionDefinition } from "./InformationBase_PropertySectionDefinition";
import { Guid } from "igniteui-angular-core";
import { InformationBase_PropertyDefinition } from "./InformationBase_PropertyDefinition";
import { VariantUtilities } from "./VariantUtilities";
import { BinaryWriter } from "igniteui-angular-core";
import { arrayGetValue } from "igniteui-angular-core";
/**
 * @hidden
 */
export class InformationBase extends Base {
    constructor() {
        super();
        this.a = null;
        this.g = DocCoreUtils.ad;
        this.c = new Guid();
        this.a = new Dictionary$2(Number_$type, Base.$, 0);
    }
    static h(a) {
        let b = DocCoreUtils.ad;
        for (let c = 0; c < a.count; c++) {
            let d = a._inner[c];
            if (d != b.getString(b.getBytes1(d))) {
                return Encoding.uTF8;
            }
        }
        return b;
    }
    k(a) {
        let b = new BinaryReader(1, a);
        let c = b.readUInt16();
        if (c != 65534) {
            a.position = 0;
            return;
        }
        let d = b.readUInt16();
        b.readInt32();
        this.c = new Guid(1, b.readBytes(16));
        let e = new List$1(InformationBase_PropertySectionDefinition.$, 0);
        let f = b.readInt32();
        for (let g = 0; g < f; g++) {
            let h = new InformationBase_PropertySectionDefinition();
            h.b = new Guid(1, b.readBytes(16));
            h.c = b.readInt32();
            e.add(h);
        }
        for (let i = 0; i < f; i++) {
            this.m(b, e._inner[i]);
        }
    }
    l(a) {
        let b = new InformationBase_PropertySectionDefinition();
        b.b = new Guid(3, this.f);
        a.add(b);
    }
    e(a, b) {
        a.baseStream.position = b.a;
        return VariantUtilities.b(a, this.g);
    }
    m(a, b) {
        a.baseStream.position = b.c;
        b.e = a.readInt32();
        b.d = a.readInt32();
        b.a = new List$1(InformationBase_PropertyDefinition.$, 2, b.d);
        for (let c = 0; c < b.d; c++) {
            let d = new InformationBase_PropertyDefinition();
            d.b = a.readInt32();
            d.a = b.c + a.readInt32();
            b.a.add(d);
        }
        this.n(a, b);
    }
    i(a, b) {
        for (let c = 0; c < b.d; c++) {
            let d = b.a._inner[c];
            if (d.b == 1) {
                return DocCoreUtils.ae(typeGetValue(this.e(a, d)));
            }
        }
        return DocCoreUtils.ad;
    }
    n(a, b) {
        let c = b.b.toString2("N");
        if (c == this.f) {
            this.a = new Dictionary$2(Number_$type, Base.$, 0);
            this.g = this.i(a, b);
            for (let d = 0; d < b.d; d++) {
                let e = b.a._inner[d];
                if (a.baseStream.length < (e.a + 4)) {
                    continue;
                }
                if (e.b != 1) {
                    this.a.addItem(e.b, this.e(a, e));
                }
            }
        }
        else {
        }
    }
    o(a) {
        this.p();
        let b = new BinaryWriter(1, a);
        b.v(65534);
        b.v(0);
        let c = 0;
        b.q(c);
        b.h(this.c.toByteArray());
        let d = new List$1(InformationBase_PropertySectionDefinition.$, 0);
        this.l(d);
        a.position += 4 + (20 * d.count);
        for (let e = 0; e < d.count; e++) {
            let f = d._inner[e];
            f.c = a.position;
            this.q(b, f);
        }
        a.position = 24;
        b.q(d.count);
        for (let g = 0; g < d.count; g++) {
            let h = d._inner[g];
            b.h(h.b.toByteArray());
            b.q(h.c);
        }
        a.position = a.length;
    }
    p() {
        let a = new List$1(String_$type, 0);
        for (let b of fromEnum(this.a.values)) {
            let c = typeCast(String_$type, b);
            if (c != null) {
                a.add(c);
                continue;
            }
            let d = typeCast(Array_$type, b);
            if (d != null) {
                for (let e = 0; e < d.length; e++) {
                    c = typeCast(String_$type, arrayGetValue(d, e));
                    if (c != null) {
                        a.add(c);
                    }
                }
            }
        }
        this.g = InformationBase.h(a);
    }
    q(a, b) {
        a.c.position += 8;
        this.r(a, b);
        while (a.c.position % 4 != 0) {
            a.m(0);
        }
        b.e = (a.c.position - b.c);
        a.c.position = b.c;
        a.q(b.e);
        a.q(b.a.count);
        for (let c = 0; c < b.a.count; c++) {
            let d = b.a._inner[c];
            a.q(d.b);
            a.q(d.a - b.c);
        }
        a.c.position = b.c + b.e;
    }
    r(a, b) {
        let c = b.b.toString2("N");
        if (c == this.f) {
            b.d = this.a.count + 1;
            b.a = new List$1(InformationBase_PropertyDefinition.$, 0);
            a.c.position += b.d * 8;
            let d = new InformationBase_PropertyDefinition();
            d.a = a.c.position;
            d.b = 1;
            VariantUtilities.f(a, this.g, DocCoreUtils.q(this.g));
            b.a.add(d);
            for (let e of fromEnum(this.a)) {
                let f = new InformationBase_PropertyDefinition();
                f.a = a.c.position;
                f.b = e.key;
                VariantUtilities.f(a, this.g, e.value);
                b.a.add(f);
            }
        }
        else {
        }
    }
    get b() {
        return this.a;
    }
}
InformationBase.$t = markType(InformationBase, 'InformationBase');
//# sourceMappingURL=InformationBase.js.map