/*
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, IEnumerable_$type, fromEnum, typeCast, Date_$type, Boolean_$type, Array_$type, runOn, Number_$type, String_$type, Delegate_$type, markType } from "./type";
import { TypeDescriptionContext } from "./TypeDescriptionContext";
import { TypeDescriptionCleanups } from "./TypeDescriptionCleanups";
import { Dictionary$2 } from "./Dictionary$2";
import { Description } from "./Description";
import { DescriptionTreeNode } from "./DescriptionTreeNode";
import { Queue$1 } from "./Queue$1";
import { DescriptionTreeAction } from "./DescriptionTreeAction";
import { DescriptionRef } from "./DescriptionRef";
import { List$1 } from "./List$1";
import { TypeDescriptionPropretyTransforms } from "./TypeDescriptionPropretyTransforms";
import { DescriptionSerializerBuilder } from "./DescriptionSerializerBuilder";
import { DescriptionSerializer } from "./DescriptionSerializer";
import { DataSourceLocalDataProvider } from "./DataSourceLocalDataProvider";
import { JsonDictionaryParser } from "./JsonDictionaryParser";
import { DescriptionTreeBuilder } from "./DescriptionTreeBuilder";
import { JsonDictionaryObject } from "./JsonDictionaryObject";
import { JsonDictionaryValue } from "./JsonDictionaryValue";
import { JsonDictionaryArray } from "./JsonDictionaryArray";
import { TypeDescriptionMetadata } from "./TypeDescriptionMetadata";
import { DescriptionTreeReconciler } from "./DescriptionTreeReconciler";
import { HashSet$1 } from "./HashSet$1";
import { Tuple$2 } from "./Tuple$2";
import { NotImplementedException } from "./NotImplementedException";
import { ComponentRendererAdapter } from "./ComponentRendererAdapter";
import { stringIsNullOrEmpty, stringStartsWith, stringEndsWith } from "./string";
/**
 * @hidden
 */
export let ComponentRenderer = /*@__PURE__*/ (() => {
    class ComponentRenderer extends Base {
        constructor() {
            super();
            this.f = null;
            this._context = null;
            this._isProceedOnErrorEnabled = false;
            this.h = null;
            this.i = null;
            this.aq = new Dictionary$2(Base.$, Description.$, 0);
            this.ar = new Dictionary$2(Base.$, Boolean_$type, 0);
            this.as = new Dictionary$2(Base.$, Boolean_$type, 0);
            this.ap = new Dictionary$2(Base.$, Boolean_$type, 0);
            this.ao = new Dictionary$2(Base.$, DescriptionTreeNode.$, 0);
            this.av = new Dictionary$2(Base.$, ContainerState.$, 0);
            this.at = new Dictionary$2(Base.$, Queue$1.$.specialize(Queue$1.$.specialize(DescriptionTreeAction.$)), 0);
            this.an = new Dictionary$2(Base.$, Boolean_$type, 0);
            this.au = new Dictionary$2(String_$type, DescriptionRef.$, 0);
            this.aw = new Dictionary$2(String_$type, Base.$, 0);
            this.ay = new Dictionary$2(String_$type, Base.$, 0);
            this.a2 = new List$1(Delegate_$type, 0);
            this.ax = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0);
            this.a0 = new List$1(Delegate_$type, 0);
            this.a1 = new List$1(Delegate_$type, 0);
            this._shouldNamespaceSystemRefValues = false;
            let a = this.g();
            this.f = a;
            let adapter_ = this.f;
            let b = (adapter_._platform);
            if (b == "Igc") {
                ComponentRenderer.platform = 4;
            }
            else if (b == "Igr") {
                ComponentRenderer.platform = 2;
            }
            this.context = new TypeDescriptionContext(this.f, ComponentRenderer.platform);
            this.h = new TypeDescriptionPropretyTransforms();
            this.i = new TypeDescriptionCleanups();
        }
        static get defaultInstance() {
            return ComponentRenderer._defaultInstance;
        }
        static set defaultInstance(a) {
            ComponentRenderer._defaultInstance = a;
        }
        get context() {
            return this._context;
        }
        set context(a) {
            this._context = a;
        }
        get isProceedOnErrorEnabled() {
            return this._isProceedOnErrorEnabled;
        }
        set isProceedOnErrorEnabled(a) {
            this._isProceedOnErrorEnabled = a;
        }
        g() {
            return (new ComponentRendererAdapter());
        }
        toJson(a) {
            let b = new DescriptionSerializerBuilder();
            let c = new DescriptionSerializer();
            b.f("{");
            b.i();
            b.f("\"descriptions\": {");
            b.i();
            let d = true;
            for (let e of fromEnum(this.ao.keys)) {
                if (d) {
                    d = false;
                }
                else {
                    b.f(",");
                }
                let f = e;
                let g = this.ao.item(e);
                let h = "root";
                h = a(f);
                if (stringIsNullOrEmpty(h)) {
                    h = "root";
                }
                b.e("\"" + h + "\"");
                b.e(": ");
                c.s(this.context, g, b);
            }
            b.f("");
            b.h();
            b.e("}");
            if (this.ay.count > 0) {
                b.e(",");
            }
            b.f("");
            if (this.ay.count > 0) {
                d = true;
                b.f("refs: {");
                b.i();
                for (let i of fromEnum(this.ay.keys)) {
                    if (!this.m(i, this.ay.item(i))) {
                        continue;
                    }
                    if (d) {
                        d = false;
                    }
                    else {
                        b.f(",");
                    }
                    this.c8(b, i, this.ay.item(i));
                }
                b.f("");
                b.h();
                b.f("}");
            }
            b.h();
            b.f("}");
            return b.toString();
        }
        c8(a, b, c) {
            a.e("\"" + b + "\": ");
            this.c9(a, c);
        }
        c9(a, b) {
            if (this.u(b)) {
                if (typeof b === 'string') {
                    a.e(b == null ? "null" : "\"" + b.toString() + "\"");
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeCast(Date_$type, b) !== null) {
                    let v_ = b;
                    a.e("\"" + (v_.toJSON()) + "\"");
                }
                else if (typeCast(Boolean_$type, b) !== null) {
                    a.e(b == null ? "null" : b.toString().toLowerCase());
                }
                else {
                    a.e("null");
                }
            }
            else {
                if (b == null) {
                    a.e("null");
                    return;
                }
                if (this.s(b)) {
                    a.f("[");
                    a.i();
                    let c = new DataSourceLocalDataProvider();
                    c.dataSource = b;
                    for (let d = 0; d < c.actualCount; d++) {
                        if (d > 0) {
                            a.f(",");
                        }
                        this.c7(a, c, d);
                    }
                    a.f("");
                    a.h();
                    a.e("]");
                }
                else {
                    let e = [b];
                    let f = new DataSourceLocalDataProvider();
                    f.dataSource = e;
                    this.c7(a, f, 0);
                }
            }
        }
        u(a) {
            if (typeof a === 'string') {
                return true;
            }
            if (typeof a === 'number' || typeof a === 'number' || typeof a === 'number' || typeof a === 'number' || typeof a === 'number' || typeof a === 'number' || typeof a === 'number') {
                return true;
            }
            if (typeCast(Date_$type, a) !== null) {
                return true;
            }
            if (typeCast(Boolean_$type, a) !== null) {
                return true;
            }
            return false;
        }
        s(a) {
            if (typeCast(Array_$type, a) !== null) {
                return true;
            }
            if (typeCast(IEnumerable_$type, a) !== null) {
                return true;
            }
            return false;
        }
        c7(a, b, c) {
            a.f("{");
            a.i();
            let d = b.actualSchema;
            for (let e = 0; e < d.propertyNames.length; e++) {
                if (e > 0) {
                    a.f(",");
                }
                let f = d.propertyNames[e];
                if (stringStartsWith(f, "[")) {
                    f = f.substr(1, f.length - 2);
                }
                a.e("\"" + f + "\"");
                a.e(": ");
                let g = b.getItemValue(b.getItemAtIndex(c), d.propertyNames[e]);
                switch (d.propertyTypes[e]) {
                    case 0:
                        a.e(g == null ? "null" : "\"" + g.toString() + "\"");
                        break;
                    case 2:
                        a.e(g == null ? "null" : "\"" + g.toString() + "\"");
                        break;
                    case 10:
                    case 6:
                    case 5:
                    case 1:
                    case 3:
                    case 4:
                    case 7:
                        a.e(g == null ? "null" : g.toString());
                        break;
                    case 8:
                        let v_ = g;
                        a.e("\"" + (v_.toJSON()) + "\"");
                        break;
                    case 11:
                        this.c9(a, g);
                        break;
                }
            }
            a.h();
            a.f("}");
        }
        m(a, b) {
            if (b == null) {
                return true;
            }
            let v_ = b;
            if ((typeof v_ === 'function')) {
                return false;
            }
            return true;
        }
        createObjectFromJson(a, b) {
            let c = new JsonDictionaryParser();
            let d = c.parse(a);
            let e = new DescriptionSerializer();
            let f = false;
            let g = e.d(this.context, d, f, null, false);
            if (g.result == null) {
                return null;
            }
            let h = DescriptionTreeBuilder.createTree(this.context, g.result);
            let i = this.av.item(b);
            if (h.b("Type")) {
                let j = h.a("Type").b;
                return this.bo(j, h, b, i, true, -1);
            }
            else {
                return this.bn(typeCast(JsonDictionaryObject.$, d));
            }
        }
        loadJson(a, b) {
            this.cl(a, b, null, false, false, false);
        }
        loadJsonOverlay(a, b, c) {
            this.cl(a, b, c, true, false, true);
        }
        loadJsonDelta(a, b, c) {
            this.cl(a, b, null, true, c, false);
        }
        ak() {
            return false;
        }
        cl(a, b, c, d, e, f) {
            let g = new JsonDictionaryParser();
            let h = g.parse(a);
            let i = new DescriptionSerializer();
            i.h = this.isProceedOnErrorEnabled;
            i.g = this.ak();
            let j = null;
            if (typeCast(JsonDictionaryObject.$, h) !== null) {
                let k = h;
                if (k.g("descriptions")) {
                    let l = k.item("descriptions");
                    if (typeCast(JsonDictionaryObject.$, l) !== null) {
                        let m = l;
                        let n = m.e();
                        for (let o = 0; o < n.length; o++) {
                            let p = n[o];
                            let q = m.item(p);
                            let r = b(p);
                            if (r == null) {
                                continue;
                            }
                            j = r;
                            let s = false;
                            let t = this.a4();
                            if (t != null) {
                                s = true;
                            }
                            let u = null;
                            if (this.isProceedOnErrorEnabled) {
                                try {
                                    u = i.d(this.context, q, s, t, false);
                                }
                                catch (v) {
                                    return;
                                }
                            }
                            else {
                                u = i.d(this.context, q, s, t, false);
                            }
                            if (u.result == null) {
                                continue;
                            }
                            if (f) {
                                if (!this.az.containsKey(r)) {
                                    let w = null;
                                    if (this.isProceedOnErrorEnabled) {
                                        try {
                                            w = i.d(this.context, q, s, t, true);
                                        }
                                        catch (x) {
                                            return;
                                        }
                                    }
                                    else {
                                        w = i.d(this.context, q, s, t, true);
                                    }
                                    this.c4(w.result, r, d, true, false);
                                    let y = c(p);
                                    let z = this.az.item(r);
                                    this.ch(this.ao.item(r), y, z, r);
                                }
                            }
                            this.c4(u.result, r, d, e, false);
                        }
                    }
                }
                if (k.g("refs") && j != null) {
                    let aa = k.item("refs");
                    let ab = this.aa(aa);
                    if (!ab && typeCast(JsonDictionaryObject.$, aa) !== null) {
                        let ac = aa;
                        let ad = ac.e();
                        for (let ae = 0; ae < ad.length; ae++) {
                            let af = ad[ae];
                            let ag = ac.item(af);
                            if (typeCast(JsonDictionaryValue.$, ag) !== null) {
                                let ah = ag;
                                this.provideRefValue(j, af, ah.value);
                            }
                            else if (typeCast(JsonDictionaryArray.$, ag) !== null) {
                                let ai = ag;
                                let aj = this.a(ai);
                                this.provideRefValue(j, af, aj);
                            }
                            else {
                                let ak = this.bn(ag);
                                this.provideRefValue(j, af, ak);
                            }
                        }
                    }
                }
                if (k.g("modules") && j != null) {
                    let al = k.item("modules");
                    this.z(al);
                }
                if (k.g("strings") && j != null) {
                    let am = k.item("strings");
                    this.ae(am);
                }
            }
        }
        provideRefValueFromJson(a, b, c) {
            let d = b;
            let e = new JsonDictionaryParser();
            let f = e.parse(c);
            if (typeCast(JsonDictionaryValue.$, f) !== null) {
                let g = f;
                this.provideRefValue(a, d, g.value);
            }
            else if (typeCast(JsonDictionaryArray.$, f) !== null) {
                let h = f;
                let i = this.a(h);
                this.provideRefValue(a, d, i);
            }
            else {
                let j = this.bn(f);
                this.provideRefValue(a, d, j);
            }
        }
        a4() {
            return null;
        }
        aa(a) {
            return false;
        }
        z(a) {
            return false;
        }
        ae(a) {
            return false;
        }
        b0(a, b, c) {
            let d = a;
            if (c != null) {
                d = c.g(b);
            }
            else {
                if (TypeDescriptionMetadata.shouldCamelize(b)) {
                    d = TypeDescriptionMetadata.camelize(d);
                }
            }
            if (stringEndsWith(d, "Ref")) {
                d = d.substr(0, d.length - ("Ref").length);
            }
            return d;
        }
        ch(a, b, c, d) {
            if (!c.b(b)) {
                c.k(d, this.ao.item(d).f, b, this.ao.item(d), runOn(this, this.cr), -1);
            }
            for (let e of fromEnum(a.e())) {
                this.ci(this.b0(e.c, ComponentRenderer.platform, e.a), e.b, b, c, d, a.f);
            }
        }
        ci(a, b, c, d, e, f) {
            if (typeCast(DescriptionTreeNode.$, b) !== null) {
                let g = b;
                let h = this.f.getPropertyValue(c, a);
                if (!d.b(h) && !d.a(g.f)) {
                    d.k(e, g.f, h, g, runOn(this, this.cr), f);
                }
                for (let i of fromEnum(g.e())) {
                    this.ci(a + "." + this.b0(i.c, ComponentRenderer.platform, i.a), i.b, c, d, e, g.f);
                }
            }
            if (typeCast(Array_$type, b) !== null) {
                let j = new Dictionary$2(Number_$type, DescriptionTreeNode.$, 0);
                let k = 0;
                let l = b.length;
                let o = b;
                for (let n = 0; n < o.length; n++) {
                    let m = o[n];
                    if (typeCast(DescriptionTreeNode.$, m) !== null) {
                        let p = m;
                        j.item(k, p);
                    }
                    k++;
                }
                let q = this.f.getPropertyValue(c, a);
                k = 0;
                this.f.forPropertyValueItem(c, a, (r) => {
                    if (j.containsKey(k)) {
                        let s = j.item(k);
                        if (!d.b(r) && !d.a(s.f)) {
                            d.k(e, s.f, r, s, runOn(this, this.cr), f);
                        }
                        for (let t of fromEnum(s.e())) {
                            this.ci(a + "." + t.c, t.b, c, d, e, s.f);
                        }
                    }
                    k++;
                });
                if (l > 0 && k == 0) {
                    let r = this.b4(a);
                    this.f.forPropertyValueItem(c, r, (s) => {
                        if (j.containsKey(k)) {
                            let t = j.item(k);
                            if (!d.b(s) && !d.a(t.f)) {
                                d.k(e, t.f, s, t, runOn(this, this.cr), f);
                            }
                            for (let u of fromEnum(t.e())) {
                                this.ci(r + "." + u.c, u.b, c, d, e, t.f);
                            }
                        }
                        k++;
                    });
                }
            }
        }
        b4(a) {
            let b = a.lastIndexOf('.');
            let c = null;
            let d = a;
            if (b > 0) {
                c = a.substr(0, b);
                d = a.substr(b + 1);
            }
            d = "actual" + this.b2(d);
            if (c != null) {
                return c + "." + d;
            }
            return d;
        }
        b2(a) {
            return a.substr(0, 1).toUpperCase() + a.substr(1);
        }
        a(a) {
            let b = new Array(a.items.length);
            for (let c = 0; c < a.items.length; c++) {
                let d = this.bn(a.items[c]);
                b[c] = d;
            }
            return b;
        }
        bn(a) {
            if (a == null) {
                return null;
            }
            let b = {};
            let dict_ = b;
            let c = a.e();
            for (let d = 0; d < c.length; d++) {
                let key_ = c[d];
                if (typeCast(JsonDictionaryObject.$, a.item(key_)) !== null) {
                    let val_ = this.bn(a.item(key_));
                    dict_[key_] = val_;
                }
                else if (typeCast(JsonDictionaryArray.$, a.item(key_)) !== null) {
                    let val_ = this.a(a.item(key_));
                    dict_[key_] = val_;
                }
                else {
                    let val_ = a.item(key_).value;
                    dict_[key_] = val_;
                }
            }
            return dict_;
        }
        get az() {
            return this.av;
        }
        cleanup(a, b) {
            this.c4(null, a, false, false, b);
        }
        render(a, b) {
            this.c4(a, b, false, false, false);
        }
        c4(a, b, c, d, e) {
            if (!this.av.containsKey(b)) {
                this.av.item(b, new ContainerState());
                this.av.item(b).i = b;
            }
            this.aq.item(b, a);
            this.ar.item(b, c);
            this.as.item(b, d);
            this.ap.item(b, e);
            this.cn(b, () => this.c2(b));
        }
        cn(a, b) {
            this.f.onUIThread(a, b);
        }
        c2(a) {
            if (this.aq.containsKey(a)) {
                let b = this.ar.containsKey(a) ? this.ar.item(a) : false;
                let c = this.as.containsKey(a) ? this.as.item(a) : false;
                let d = this.aq.item(a);
                this.aq.removeItem(a);
                let e = DescriptionTreeBuilder.createTree(this.context, d);
                let f = null;
                if (this.ao.containsKey(a)) {
                    f = this.ao.item(a);
                }
                let g = DescriptionTreeReconciler.c(f, e, b);
                if (c) {
                    let h = DescriptionTreeReconciler.a(f, g);
                    if (!this.av.containsKey(a)) {
                        this.av.addItem(a, ((() => {
                            let $ret = new ContainerState();
                            $ret.i = a;
                            return $ret;
                        })()));
                    }
                    let i = this.av.item(a);
                    if (h.a.count > 0) {
                        for (let j of fromEnum(h.a)) {
                            if (i.a(j)) {
                                let k = i.j(j);
                                this.cf(a, k, i);
                            }
                        }
                    }
                    if (h.c.count > 0) {
                        for (let l of fromEnum(h.c)) {
                            let m = this.bt(a, i, l);
                            let n = this.f.getPropertyValue(m, l.i);
                            if (n != null) {
                                if (!i.b(n)) {
                                    let o = l.f;
                                    if (typeCast(DescriptionTreeNode.$, o) !== null) {
                                        let p = o.f;
                                        i.k(a, p, n, o, runOn(this, this.cr), l.b.f);
                                    }
                                }
                            }
                        }
                    }
                    if (h.d.count > 0) {
                        for (let q of fromEnum(h.d)) {
                            let r = q.f;
                            if (r != null) {
                                if (!i.b(r)) {
                                    let s = q.f;
                                    if (typeCast(DescriptionTreeNode.$, s) !== null) {
                                        let t = s.f;
                                        this.ao.item(a, s);
                                    }
                                }
                            }
                        }
                    }
                    if (h.b.count > 0) {
                        for (let u of fromEnum(h.b)) {
                            let v = u.b.a(u.i).b;
                            if (v == null) {
                                continue;
                            }
                            let w = new Dictionary$2(String_$type, DescriptionTreeNode.$, 0);
                            for (let x = 0; x < v.length; x++) {
                                let y = v[x];
                                if (typeCast(DescriptionTreeNode.$, y) !== null) {
                                    let z = y;
                                    if (z.b("Name")) {
                                        w.item(z.a("Name").b, z);
                                    }
                                }
                            }
                            if (w.count == 0) {
                                continue;
                            }
                            let aa = this.bt(a, i, u);
                            let ab = this.f.getPropertyValue(aa, u.i);
                            if (ab != null) {
                                let ac = 0;
                                this.f.forPropertyValueItem(aa, u.i, (ad) => {
                                    if (w.containsKey(this.f.getPropertyValue(ad, "Name").toString())) {
                                        if (!i.b(ad)) {
                                            let ae = w.item(this.f.getPropertyValue(ad, "Name").toString());
                                            if (typeCast(DescriptionTreeNode.$, ae) !== null) {
                                                let af = ae.f;
                                                i.k(a, af, ad, ae, runOn(this, this.cr), u.b.f);
                                            }
                                        }
                                    }
                                    ac++;
                                });
                            }
                        }
                    }
                }
                else {
                    this.ao.item(a, e);
                }
                if (!c) {
                    this.c3(a, g);
                }
                if (this.ap.item(a)) {
                    this.c0(a);
                    if (this.av.containsKey(a)) {
                        this.av.removeItem(a);
                    }
                }
            }
        }
        provideRefValue(a, b, c) {
            this.cn(a, () => {
                if (!this.av.containsKey(a)) {
                    this.av.addItem(a, ((() => {
                        let $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                let d = this.av.item(a);
                this.cr(a, b, c, true);
            });
        }
        removeRefValue(a, b) {
            this.cn(a, () => {
                if (!this.av.containsKey(a)) {
                    this.av.addItem(a, ((() => {
                        let $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                let c = this.av.item(a);
                this.removeRefValueCore(a, b, true);
            });
        }
        c0(a) {
            let b = this.av.item(a);
            let c = new List$1(String_$type, 0);
            for (let d of fromEnum(this.au.keys)) {
                if (this.au.item(d).c == 0) {
                    c.add(d);
                }
            }
            for (let e = 0; e < c.count; e++) {
                let f = this.shouldNamespaceSystemRefValues;
                this.shouldNamespaceSystemRefValues = false;
                this.removeRefValueCore(a, c._inner[e], this.ay.containsKey(c._inner[e]));
                this.shouldNamespaceSystemRefValues = f;
            }
        }
        clearRefValues(a) {
            this.cn(a, () => {
                if (!this.av.containsKey(a)) {
                    this.av.addItem(a, ((() => {
                        let $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                let b = this.av.item(a);
                this.clearUserRefValues();
            });
        }
        c3(a, b) {
            let c = this.av.item(a);
            this.co(a, c, b);
        }
        c6(a, b) {
            if (this.isProceedOnErrorEnabled) {
                try {
                    this.cg(a, b, true);
                }
                catch (c) {
                    this.an.item(a, false);
                }
            }
            else {
                this.cg(a, b, true);
            }
        }
        dc(a, b) {
            if (this.isProceedOnErrorEnabled) {
                try {
                    this.cg(a, b, false);
                }
                catch (c) {
                    this.an.item(a, false);
                }
            }
            else {
                this.cg(a, b, false);
            }
        }
        cg(a, b, c) {
            if (!c) {
                if (this.an.containsKey(a) && this.an.item(a)) {
                    return;
                }
            }
            this.an.item(a, true);
            let d = true;
            while (d && this.at.item(a).count > 0) {
                while (this.at.item(a).count > 0 && this.at.item(a).c().count < 1) {
                    this.at.item(a).b();
                }
                if (this.at.item(a).count < 1) {
                    break;
                }
                let e = this.at.item(a).c();
                while (e.count > 0) {
                    let f = e.b();
                    d = this.w(a, b, f);
                    if (!d) {
                        break;
                    }
                }
            }
            if (d) {
                this.an.item(a, false);
            }
        }
        co(a, b, c) {
            let d = new Queue$1(DescriptionTreeAction.$);
            for (let e = 0; e < c.count; e++) {
                d.g(c._inner[e]);
            }
            if (!this.at.containsKey(a)) {
                this.at.addItem(a, new Queue$1(Queue$1.$.specialize(DescriptionTreeAction.$)));
            }
            this.at.item(a).g(d);
            this.dc(a, b);
        }
        cp(a, b, c) {
            for (let d = 0; d < c.count; d++) {
                this.w(a, b, c._inner[d]);
            }
        }
        w(a, b, c) {
            switch (c.a) {
                case 5: return this.x(a, b, c);
                case 2: return this.y(a, b, c);
                case 4: return this.ab(a, b, c);
                case 3: return this.ac(a, b, c);
                case 1: return this.ad(a, b, c);
                case 0: return this.af(a, b, c);
            }
            return true;
        }
        af(a, b, c) {
            let d = this.bt(a, b, c);
            this.am(a, b, c, d);
            return true;
        }
        am(a, b, c, d) {
            let e = this.bq(c, a, b);
            e = this.h.transform(ComponentRenderer.platform, e, c);
            let f = false;
            if (this.a2 != null && this.a2.count > 0) {
                for (let g = 0; g < this.a2.count; g++) {
                    let h = this.a2._inner[g];
                    let i = this.b1(a, c);
                    if (h(i, d, e)) {
                        f = true;
                    }
                }
            }
            if (c.i == "Type" || c.i == "type") {
                f = true;
            }
            if (f) {
                return true;
            }
            if (c.c != null && c.c.knownType == 9) {
                this.aj(a, b, c.h(ComponentRenderer.platform), c.c, e, d);
            }
            else {
                this.da(a, b, c.h(ComponentRenderer.platform), c.c, e, c.g, d);
            }
            return true;
        }
        b1(a, b) {
            let c = b.b;
            let d = "";
            if (c != this.ao.item(a)) {
                let e = this.bz(a, c);
                d = e;
            }
            if (d.length > 0) {
                d += ".";
            }
            d += b.i;
            return d;
        }
        bz(a, b) {
            if (b == null) {
                return "";
            }
            let c = this.b5("", this.ao.item(a), b);
            if (c.c) {
                return c.d;
            }
            return "";
        }
        b5(a, b, c) {
            if (b == c) {
                return new Tuple$2(Boolean_$type, String_$type, true, a);
            }
            if (a.length > 0) {
                a += ".";
            }
            let d = b.e();
            for (let e = 0; e < d.count; e++) {
                let f = d._inner[e];
                if (typeCast(DescriptionTreeNode.$, f.b) !== null) {
                    if (f.b.f == c.f) {
                        a += f.c;
                        return new Tuple$2(Boolean_$type, String_$type, true, a);
                    }
                    else {
                        let g = a + f.c;
                        let h = this.b5(g, f.b, c);
                        if (h.c) {
                            return h;
                        }
                    }
                }
                if (f.a != null && f.a.knownType == 9) {
                    let i = f.b;
                    for (let j = 0; j < i.length; j++) {
                        if (typeCast(DescriptionTreeNode.$, i[j]) !== null) {
                            let k = i[j];
                            if (k.f == c.f) {
                                a += f.c + "[" + j + "]";
                                return new Tuple$2(Boolean_$type, String_$type, true, a);
                            }
                            else {
                                let l = a + f.c + "[" + j + "]";
                                let m = this.b5(l, k, c);
                                if (m.c) {
                                    return m;
                                }
                            }
                        }
                    }
                }
            }
            return new Tuple$2(Boolean_$type, String_$type, false, a);
        }
        aj(a, b, c, d, e, f) {
            if (this.ax.containsKey(c)) {
                for (let g of fromEnum(this.ax.item(c))) {
                    g(c, f, e);
                }
            }
            this.f.setOrUpdateCollectionOnTarget(a, c, d, this.context, f, e);
            return true;
        }
        bq(a, b, c) {
            if (a.c == null) {
                return a.f;
            }
            switch (a.c.knownType) {
                case 10: return this.a6(a, b, c);
                case 7: return this.a7(a);
                case 4: return this.a8(a);
                case 6: return this.a9(a);
                case 9: return this.a6(a, b, c);
                case 5: return this.ba(a);
                case 16: return this.bb(a);
                case 20: return this.bu(a, c);
                case 15: return null;
                case 3: return this.bc(a);
                case 19: return this.bv(a, c);
                case 8: return this.be(a, b, c);
                case 13: return null;
                case 18: return this.bw(a, c);
                case 1: return this.bf(a);
                case 11: return this.bg(a);
                case 14: return this.bh(a);
                case 12: return this.bi(a);
                case 2: return this.bj(a);
                case 21: return this.bk(a);
                case 17: return this.bl(a, b, c);
                case 0: return null;
            }
            return null;
        }
        bl(a, b, c) {
            let d = this.bm(a.f, a, b, c);
            return d;
        }
        bm(a, b, c, d) {
            if (typeof a === 'string') {
                if (stringStartsWith(a, "@d:")) {
                    let v_ = a.substr(3);
                    a = new Date(v_);
                }
            }
            if (typeCast(Array_$type, a) !== null) {
                let e = a;
                let f = new Array(e.length);
                for (let g = 0; g < e.length; g++) {
                    let h = this.bm(e[g], b, c, d);
                    f[g] = h;
                }
                a = f;
            }
            if (typeCast(DescriptionTreeNode.$, a) !== null) {
                let i = a;
                if (i.h == "EmbeddedRef") {
                    return this.bo(i.h, a, c, d, false, b.b.f);
                }
            }
            return a;
        }
        bk(a) {
            return a.f;
        }
        bj(a) {
            return a.f != null ? a.f.toString() : null;
        }
        bi(a) {
            let b = a.f;
            let width_ = b.width;
            let height_ = b.height;
            let c = { width: width_, height: height_ };
            return c;
        }
        bh(a) {
            let b = a.f;
            let top_ = b.top;
            let left_ = b.left;
            let width_ = b.width;
            let height_ = b.height;
            let c = { left: left_, top: top_, width: width_, height: height_ };
            return c;
        }
        bg(a) {
            let b = a.f;
            let x_ = b.x;
            let y_ = b.y;
            let c = { x: x_, y: y_ };
            return c;
        }
        bf(a) {
            if (a.f == null) {
                if (a.c != null && (a.c.specificType == "double" || a.c.specificType == "float")) {
                    return NaN;
                }
                return 0;
            }
            return a.f;
        }
        d(a, b) {
            if (this.au.containsKey(a)) {
                let c = this.au.item(a);
                return c;
            }
            let d = new DescriptionRef(a);
            this.au.addItem(a, d);
            return d;
        }
        bw(a, b) {
            return a.f == null ? null : this.d(a.f, b);
        }
        be(a, b, c) {
            let d = a.c.specificType;
            if (d == null) {
                d = a.c.specificExternalType;
            }
            if (typeCast(DescriptionTreeNode.$, a.f) !== null) {
                let e = a.f;
                if (e.b("Type")) {
                    d = e.a("Type").b;
                }
            }
            let f = this.bo(d, a.f, b, c, false, a.b.f);
            return f;
        }
        bv(a, b) {
            return a.f == null ? null : this.d(a.f, b);
        }
        bc(a) {
            if (typeof a.f === 'string') {
                let v_ = a.f;
                a.f = new Date(v_);
            }
            return a.f;
        }
        bu(a, b) {
            return a.f == null ? null : this.d(a.f, b);
        }
        by(a) {
            return a;
        }
        bb(a) {
            let b = a.f;
            if (b == null) {
                return null;
            }
            let c = new Array(b.length);
            for (let d = 0; d < b.length; d++) {
                c[d] = this.by(b[d]);
            }
            return c;
        }
        ba(a) {
            return this.by(a.f);
        }
        a9(a) {
            let b = a.f;
            if (b == null) {
                return null;
            }
            let c = new Array(b.length);
            for (let d = 0; d < b.length; d++) {
                c[d] = this.bx(b[d]);
            }
            return c;
        }
        bx(a) {
            return a;
        }
        a8(a) {
            return this.bx(a.f);
        }
        a7(a) {
            return a.f;
        }
        addTargetPropertyUpdatingListener(a) {
            this.a2.add(a);
        }
        removeTargetPropertyUpdatingListener(a) {
            this.a2.remove(a);
        }
        addPropertyUpdatingListener(a, b) {
            if (!this.ax.containsKey(a)) {
                this.ax.addItem(a, new List$1(Delegate_$type, 0));
            }
            this.ax.item(a).add(b);
        }
        addReferenceLookupListener(a) {
            this.a0.add(a);
        }
        removeReferenceLookupListener(a) {
            this.a0.remove(a);
        }
        removePropertyUpdatingListener(a, b) {
            if (this.ax.containsKey(a)) {
                this.ax.item(a).remove(b);
                if (this.ax.item(a).count == 0) {
                    this.ax.removeItem(a);
                }
            }
        }
        addNamespaceLookupListener(a) {
            this.a1.add(a);
        }
        removeNamespaceLookupListener(a) {
            this.a1.remove(a);
        }
        a6(a, b, c) {
            if (a.f == null) {
                return null;
            }
            let d = a.f;
            let e = new List$1(Base.$, 0);
            let f = a.c.specificType;
            if (f == null) {
                f = a.c.specificExternalType;
            }
            if (a.c.knownType == 9) {
                f = a.c.collectionElementType;
                if (f == null) {
                    f = a.c.specificExternalType;
                }
            }
            for (let g = 0; g < d.length; g++) {
                let h = f;
                if (typeCast(DescriptionTreeNode.$, d[g]) !== null) {
                    let i = d[g];
                    if (i.b("Type")) {
                        h = i.a("Type").b;
                    }
                }
                let j = this.bo(h, d[g], b, c, false, a.b.f);
                e.add1(j);
            }
            return e.toArray();
        }
        da(a, b, c, d, e, f, g) {
            if (typeCast(DescriptionRef.$, e) !== null) {
                let h = e;
                let i = false;
                if (f != null && typeof f === 'string') {
                    if (this.p(f)) {
                        let j = this.e(f);
                        if (Base.equalsStatic(j, e)) {
                            i = true;
                        }
                        else {
                            j.j(a, g, c);
                        }
                    }
                }
                if (this.q(e)) {
                    let k = e;
                    if (k.e != null && k.e.length > 0 && this.aw.containsKey(k.e)) {
                        k.a = true;
                    }
                    e = this.bs(e);
                    this.db(g, c, d, e, f, k);
                }
                else {
                    this.f.onPendingRef(g, c, d, e);
                }
                let l = null;
                l = (m, n) => {
                    let o = m;
                    if (o.e != null && o.e.length > 0 && this.aw.containsKey(o.e)) {
                        o.a = true;
                    }
                    let p = this.bs(m);
                    this.db(g, c, d, p, f, o);
                };
                if (!i) {
                    h.g(a, g, c, l);
                }
                return;
            }
            this.db(g, c, d, e, f, null);
        }
        hasUserRef(a) {
            return this.ay.containsKey(a);
        }
        get shouldNamespaceSystemRefValues() {
            return this._shouldNamespaceSystemRefValues;
        }
        set shouldNamespaceSystemRefValues(a) {
            this._shouldNamespaceSystemRefValues = a;
        }
        cr(a, b, c, d) {
            let e = null;
            if (d) {
                if (this.ay.containsKey(b)) {
                    e = this.ay.item(b);
                }
                this.ay.item(b, c);
            }
            else {
                if (this.shouldNamespaceSystemRefValues) {
                    let f = "";
                    if (this.a1 != null && this.a1.count > 0) {
                        for (let g = 0; g < this.a1.count; g++) {
                            f = this.a1._inner[g](a);
                        }
                    }
                    if (!stringIsNullOrEmpty(f)) {
                        b = f + "/" + b;
                    }
                }
                if (this.aw.containsKey(b)) {
                    e = this.aw.item(b);
                }
                this.aw.item(b, c);
                if (this.au.containsKey(b)) {
                    this.au.item(b).a = true;
                }
            }
            if (this.au.containsKey(b)) {
                this.au.item(b).f(e, c);
            }
        }
        removeRefValueCore(a, b, c) {
            let d = null;
            if (c) {
                if (this.ay.containsKey(b)) {
                    d = this.ay.item(b);
                }
                this.ay.removeItem(b);
            }
            else {
                if (this.shouldNamespaceSystemRefValues) {
                    let e = "";
                    if (this.a1 != null && this.a1.count > 0) {
                        for (let f = 0; f < this.a1.count; f++) {
                            e = this.a1._inner[f](a);
                        }
                    }
                    if (!stringIsNullOrEmpty(e)) {
                        b = e + "/" + b;
                    }
                }
                if (this.aw.containsKey(b)) {
                    d = this.aw.item(b);
                }
                this.aw.removeItem(b);
            }
            if (this.au.containsKey(b)) {
                this.au.item(b).f(d, this.bs(this.au.item(b)));
                if (this.au.item(b).c <= 0) {
                    this.au.item(b).h();
                    this.au.removeItem(b);
                }
            }
        }
        clearUserRefValues() {
            let a = new List$1(String_$type, 0);
            for (let b of fromEnum(this.ay.keys)) {
                a.add(b);
            }
            for (let c of fromEnum(a)) {
                this.removeRefValueCore(null, c, true);
            }
        }
        q(a) {
            return this.ay.containsKey(a.e) || this.aw.containsKey(a.e);
        }
        bs(a) {
            if (this.ay.containsKey(a.e)) {
                return this.ay.item(a.e);
            }
            if (this.aw.containsKey(a.e)) {
                return this.aw.item(a.e);
            }
            return null;
        }
        p(a) {
            return this.au.containsKey(a);
        }
        e(a) {
            return this.au.item(a);
        }
        getMissingRefs() {
            let a = new List$1(String_$type, 0);
            for (let b of fromEnum(this.au.keys)) {
                if (!this.q(this.au.item(b))) {
                    a.add(b);
                }
            }
            return a.toArray();
        }
        bt(a, b, c) {
            return b.j(c.b.f);
        }
        ad(a, b, c) {
            let d = this.bt(a, b, c);
            this.ai(a, b, c, d);
            return true;
        }
        ai(a, b, c, d) {
            this.f.resetPropertyOnTarget(a, c.h(ComponentRenderer.platform), c.c, d);
            return true;
        }
        ac(a, b, c) {
            if (c.b == null) {
                return this.ah(a, b, c);
            }
            else {
                let d = this.bt(a, b, c);
                this.c5(a, b, c, d);
            }
            return true;
        }
        c5(a, b, c, d) {
            let e = c.h(ComponentRenderer.platform);
            let f = c.c.collectionElementType;
            if (f == null) {
                f = c.c.specificExternalType;
            }
            let g = this.bo(f, c.f, a, b, false, c.b.f);
            this.f.replaceItemInCollection(e, c.c, d, c.d, g);
            if (c.g != null && typeCast(DescriptionTreeNode.$, c.g) !== null) {
                let h = c.g.f;
                if (h >= 0) {
                    let i = b.j(h);
                    if (i != null) {
                        this.cf(a, i, b);
                    }
                }
            }
        }
        ah(a, b, c) {
            let d = this.f.getRootObject(a);
            if (d != null) {
                this.cf(a, d, b);
            }
            if (!(typeCast(DescriptionTreeNode.$, c.f) !== null)) {
                throw new NotImplementedException(0);
            }
            let e = c.f;
            let f = false;
            this.f.replaceRootItem(a, e.h, this.context, (g) => {
                let h = this.f.getRootObject(a);
                b.k(a, e.f, h, e, runOn(this, this.cr), -1);
                let i = this.a3(e);
                this.cp(a, b, i);
                f = true;
                if (g) {
                    this.c6(a, b);
                }
            });
            return f;
        }
        cf(a, b, c) {
            let d = this.a5(a, b, c);
            for (let e of fromEnum(this.au.values)) {
                e.i(b);
            }
            if (d != -1) {
                c.l(this, a, d, runOn(this, this.removeRefValueCore));
            }
            this.i.b(ComponentRenderer.platform, b);
        }
        a5(a, b, c) {
            return c.h(b);
        }
        ab(a, b, c) {
            if (c.b == null) {
                return this.ag(a, b, c);
            }
            else {
                let d = this.bt(a, b, c);
                this.ct(a, b, c, d);
            }
            return true;
        }
        ct(a, b, c, d) {
            let e = c.h(ComponentRenderer.platform);
            this.f.removeItemFromCollection(e, c.c, d, c.e);
            if (c.g != null && typeCast(DescriptionTreeNode.$, c.g) !== null) {
                let f = c.g.f;
                if (f >= 0) {
                    let g = b.j(f);
                    if (g != null) {
                        this.cf(a, g, b);
                    }
                }
            }
        }
        ag(a, b, c) {
            let d = this.f.getRootObject(a);
            if (d != null) {
                this.cf(a, d, b);
            }
            let e = false;
            this.f.removeRootItem(a, this.context, (f) => {
                e = true;
                if (f) {
                    this.c6(a, b);
                }
            });
            return e;
        }
        y(a, b, c) {
            if (c.b == null) {
                return this.l(a, b, c);
            }
            else {
                let d = this.bt(a, b, c);
                this.b6(a, b, c, d);
            }
            return true;
        }
        l(a, b, c) {
            if (!(typeCast(DescriptionTreeNode.$, c.f) !== null)) {
                throw new NotImplementedException(0);
            }
            let d = c.f;
            let e = false;
            this.f.replaceRootItem(a, d.h, this.context, (f) => {
                let g = this.f.getRootObject(a);
                b.k(a, d.f, g, d, runOn(this, this.cr), -1);
                let h = this.a3(d);
                this.cp(a, b, h);
                e = true;
                if (f) {
                    this.c6(a, b);
                }
            });
            return e;
        }
        b6(a, b, c, d) {
            let e = c.h(ComponentRenderer.platform);
            let f = c.c.collectionElementType;
            if (typeCast(DescriptionTreeNode.$, c.f) !== null) {
                let g = c.f;
                if (g.b("Type")) {
                    f = g.a("Type").b;
                }
            }
            if (f == null) {
                f = c.c.specificExternalType;
            }
            let h = this.bo(f, c.f, a, b, false, c.b.f);
            this.f.addItemToCollection(e, c.c, d, c.d, h);
        }
        bo(a, b, c, d, e, f) {
            if (this.t(a)) {
                return b;
            }
            let g = null;
            if (b != null && typeCast(DescriptionTreeNode.$, b) !== null) {
                let h = b;
                if (h.b("Name")) {
                    let i = h.a("Name").b;
                    if (!stringIsNullOrEmpty(i)) {
                        if (this.shouldNamespaceSystemRefValues) {
                            let j = "";
                            if (this.a1 != null && this.a1.count > 0) {
                                for (let k = 0; k < this.a1.count; k++) {
                                    j = this.a1._inner[k](c);
                                }
                            }
                            if (!stringIsNullOrEmpty(j)) {
                                i = j + "/" + i;
                            }
                        }
                        if (this.aw.containsKey(i)) {
                            let l = this.aw.item(i);
                            g = l;
                        }
                    }
                }
                if (g == null) {
                    g = this.context.p(a, c);
                }
            }
            else if (b != null) {
                g = this.context.p(a, c);
            }
            if (b == null) {
                return g;
            }
            if (typeCast(DescriptionTreeNode.$, b) !== null) {
                let m = b;
                if (m.h == "EmbeddedRef") {
                    let n = "uuid";
                    let o = null;
                    for (let p = 0; p < m.e().count; p++) {
                        if (m.e()._inner[p].c == "RefType") {
                            n = m.e()._inner[p].b;
                        }
                        if (m.e()._inner[p].c == "Value") {
                            o = m.e()._inner[p].b;
                        }
                    }
                    if (o != null) {
                        for (let q = 0; q < this.a0.count; q++) {
                            let r = this.a0._inner[q](c, n, o);
                            if (r != null) {
                                return r;
                            }
                        }
                        return null;
                    }
                }
                else {
                    d.k(c, m.f, g, m, runOn(this, this.cr), f);
                    let s = this.a3(m);
                    this.cp(c, d, s);
                    if (e) {
                        d.l(this, c, m.f, runOn(this, this.removeRefValueCore));
                    }
                }
            }
            let t = (a == "object" || a == "Object");
            if (!t && typeof b === 'string' && a.toLowerCase() != "string") {
                return this.bd(a, b);
            }
            if (t) {
                return b;
            }
            return g;
        }
        t(a) {
            return a == "int" || a == "Int32" || a == "short" || a == "Int16" || a == "double" || a == "Double" || a == "float" || a == "Float" || a == "Single" || a == "single" || a == "DateTime" || a == "decimal" || a == "Decimal" || a == "long" || a == "Int64" || a == "byte" || a == "bool" || a == "string" || a == "String";
        }
        bd(a, b) {
            return this.context.l(a, b);
        }
        a3(a) {
            let b = a.e();
            let c = new List$1(DescriptionTreeAction.$, 0);
            for (let d = 0; d < b.count; d++) {
                let e = new DescriptionTreeAction();
                e.a = 0;
                e.i = b._inner[d].c;
                e.c = b._inner[d].a;
                e.b = a;
                e.f = b._inner[d].b;
                c.add(e);
            }
            return c;
        }
        x(a, b, c) {
            if (c.b == null) {
                return this.o(a, b, c);
            }
            else {
                let d = this.bt(a, b, c);
                this.cc(a, b, c, d);
            }
            return true;
        }
        cc(a, b, c, d) {
            let e = c.h(ComponentRenderer.platform);
            this.f.clearCollection(d, e, c.c);
            if (c.g != null && typeCast(Array_$type, c.g) !== null) {
                let f = c.g;
                for (let g = 0; g < f.length; g++) {
                    let h = f[g];
                    if (h != null && typeCast(DescriptionTreeNode.$, h) !== null) {
                        let i = h.f;
                        if (i >= 0) {
                            let j = b.j(i);
                            if (j != null) {
                                this.cf(a, j, b);
                            }
                        }
                    }
                }
            }
        }
        db(a, b, c, d, e, f) {
            if (this.ax.containsKey(b)) {
                for (let g of fromEnum(this.ax.item(b))) {
                    g(b, a, d);
                }
            }
            this.f.setPropertyValue(a, b, c, d, e, f);
        }
        br(a, b) {
            return this.f.getPropertyValue(a, b);
        }
        o(a, b, c) {
            return this.n(a, b);
        }
        n(a, b) {
            let c = this.f.getRootObject(a);
            if (c != null) {
                this.cf(a, c, b);
            }
            let d = false;
            this.f.clearContainer(a, this.context, (e) => {
                d = true;
                if (e) {
                    this.c6(a, b);
                }
            });
            return d;
        }
    }
    ComponentRenderer.$t = markType(ComponentRenderer, 'ComponentRenderer');
    ComponentRenderer._defaultInstance = null;
    ComponentRenderer.platform = 3;
    return ComponentRenderer;
})();
/**
 * @hidden
 */
export let ContainerState = /*@__PURE__*/ (() => {
    class ContainerState extends Base {
        constructor() {
            super(...arguments);
            this.i = null;
            this.e = new Dictionary$2(Number_$type, Base.$, 0);
            this.f = new Dictionary$2(Base.$, Number_$type, 0);
            this.d = new Dictionary$2(Number_$type, String_$type, 0);
            this.g = new Dictionary$2(Number_$type, HashSet$1.$.specialize(Number_$type), 0);
            this.c = new Dictionary$2(Number_$type, List$1.$.specialize(Number_$type), 0);
        }
        k(a, b, c, d, e, f) {
            if (d.b("Name")) {
                this.d.item(b, d.a("Name").b);
                e(a, this.d.item(b), c, false);
            }
            this.e.item(b, c);
            this.f.item(c, b);
            if (!this.g.containsKey(b)) {
                this.g.item(b, new HashSet$1(Number_$type, 0));
            }
            this.g.item(b).add_1(f);
            if (f >= 0) {
                if (!this.c.containsKey(f)) {
                    this.c.item(f, new List$1(Number_$type, 0));
                }
                this.c.item(f).add(b);
            }
        }
        a(a) {
            return this.e.containsKey(a);
        }
        b(a) {
            return this.f.containsKey(a);
        }
        j(a) {
            return this.e.item(a);
        }
        l(a, b, c, d) {
            if (this.c.containsKey(c)) {
                let e = this.c.item(c);
                for (let f = 0; f < e.count; f++) {
                    if (!this.g.containsKey(e._inner[f]) || this.g.item(e._inner[f]).count < 1 || (this.g.item(e._inner[f]).count == 1 && this.g.item(e._inner[f]).contains(c))) {
                        if (this.e.containsKey(e._inner[f])) {
                            a.cf(b, this.e.item(e._inner[f]), this);
                        }
                    }
                }
                this.c.removeItem(c);
            }
            let g = this.e.item(c);
            this.f.removeItem(g);
            this.e.removeItem(c);
            if (this.g.containsKey(c)) {
                this.g.removeItem(c);
            }
            if (this.d.containsKey(c)) {
                let h = this.d.item(c);
                this.d.removeItem(c);
                d(b, h, false);
            }
        }
        h(a) {
            if (this.f.containsKey(a)) {
                return this.f.item(a);
            }
            return -1;
        }
    }
    ContainerState.$t = markType(ContainerState, 'ContainerState');
    return ContainerState;
})();
