/*
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 * as tslib_1 from "tslib";
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
 */
var ComponentRenderer = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ComponentRenderer, _super);
    function ComponentRenderer() {
        var _this = _super.call(this) || this;
        _this.e = null;
        _this._context = null;
        _this._isProceedOnErrorEnabled = false;
        _this.g = null;
        _this.h = null;
        _this.ap = new Dictionary$2(Base.$, Description.$, 0);
        _this.aq = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.ar = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.ao = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.an = new Dictionary$2(Base.$, DescriptionTreeNode.$, 0);
        _this.au = new Dictionary$2(Base.$, ContainerState.$, 0);
        _this.as = new Dictionary$2(Base.$, Queue$1.$.specialize(Queue$1.$.specialize(DescriptionTreeAction.$)), 0);
        _this.am = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.at = new Dictionary$2(String_$type, DescriptionRef.$, 0);
        _this.av = new Dictionary$2(String_$type, Base.$, 0);
        _this.ax = new Dictionary$2(String_$type, Base.$, 0);
        _this.a1 = new List$1(Delegate_$type, 0);
        _this.aw = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0);
        _this.az = new List$1(Delegate_$type, 0);
        _this.a0 = new List$1(Delegate_$type, 0);
        _this._shouldNamespaceSystemRefValues = false;
        var a = _this.f();
        _this.e = a;
        var adapter_ = _this.e;
        var b = (adapter_._platform);
        if (b == "Igc") {
            ComponentRenderer.platform = 4;
        }
        else if (b == "Igr") {
            ComponentRenderer.platform = 2;
        }
        _this.context = new TypeDescriptionContext(_this.e, ComponentRenderer.platform);
        _this.g = new TypeDescriptionPropretyTransforms();
        _this.h = new TypeDescriptionCleanups();
        return _this;
    }
    Object.defineProperty(ComponentRenderer.prototype, "context", {
        get: function () {
            return this._context;
        },
        set: function (a) {
            this._context = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ComponentRenderer.prototype, "isProceedOnErrorEnabled", {
        get: function () {
            return this._isProceedOnErrorEnabled;
        },
        set: function (a) {
            this._isProceedOnErrorEnabled = a;
        },
        enumerable: true,
        configurable: true
    });
    ComponentRenderer.prototype.f = function () {
        return (new ComponentRendererAdapter());
    };
    ComponentRenderer.prototype.toJson = function (a) {
        var e_1, _a, e_2, _b;
        var b = new DescriptionSerializerBuilder();
        var c = new DescriptionSerializer();
        b.f("{");
        b.i();
        b.f("\"descriptions\": {");
        b.i();
        var d = true;
        try {
            for (var _c = tslib_1.__values(fromEnum(this.an.keys)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var e = _d.value;
                if (d) {
                    d = false;
                }
                else {
                    b.f(",");
                }
                var f = e;
                var g = this.an.item(e);
                var h = "root";
                h = a(f);
                if (stringIsNullOrEmpty(h)) {
                    h = "root";
                }
                b.e("\"" + h + "\"");
                b.e(": ");
                c.s(this.context, g, b);
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        b.f("");
        b.h();
        b.e("}");
        if (this.ax.count > 0) {
            b.e(",");
        }
        b.f("");
        if (this.ax.count > 0) {
            d = true;
            b.f("refs: {");
            b.i();
            try {
                for (var _e = tslib_1.__values(fromEnum(this.ax.keys)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var i = _f.value;
                    if (!this.l(i, this.ax.item(i))) {
                        continue;
                    }
                    if (d) {
                        d = false;
                    }
                    else {
                        b.f(",");
                    }
                    this.c6(b, i, this.ax.item(i));
                }
            }
            catch (e_2_1) {
                e_2 = { error: e_2_1 };
            }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return))
                        _b.call(_e);
                }
                finally {
                    if (e_2)
                        throw e_2.error;
                }
            }
            b.f("");
            b.h();
            b.f("}");
        }
        b.h();
        b.f("}");
        return b.toString();
    };
    ComponentRenderer.prototype.c6 = function (a, b, c) {
        a.e("\"" + b + "\": ");
        this.c7(a, c);
    };
    ComponentRenderer.prototype.c7 = function (a, b) {
        if (this.t(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) {
                var 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.r(b)) {
                a.f("[");
                a.i();
                var c = new DataSourceLocalDataProvider();
                c.dataSource = b;
                for (var d = 0; d < c.actualCount; d++) {
                    if (d > 0) {
                        a.f(",");
                    }
                    this.c5(a, c, d);
                }
                a.f("");
                a.h();
                a.e("]");
            }
            else {
                var e = [b];
                var f = new DataSourceLocalDataProvider();
                f.dataSource = e;
                this.c5(a, f, 0);
            }
        }
    };
    ComponentRenderer.prototype.t = function (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;
    };
    ComponentRenderer.prototype.r = function (a) {
        if (typeCast(Array_$type, a) !== null) {
            return true;
        }
        if (typeCast(IEnumerable_$type, a) !== null) {
            return true;
        }
        return false;
    };
    ComponentRenderer.prototype.c5 = function (a, b, c) {
        a.f("{");
        a.i();
        var d = b.actualSchema;
        for (var e = 0; e < d.propertyNames.length; e++) {
            if (e > 0) {
                a.f(",");
            }
            var f = d.propertyNames[e];
            if (stringStartsWith(f, "[")) {
                f = f.substr(1, f.length - 2);
            }
            a.e("\"" + f + "\"");
            a.e(": ");
            var 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:
                    var v_ = g;
                    a.e("\"" + (v_.toJSON()) + "\"");
                    break;
                case 11:
                    this.c7(a, g);
                    break;
            }
        }
        a.h();
        a.f("}");
    };
    ComponentRenderer.prototype.l = function (a, b) {
        if (b == null) {
            return true;
        }
        var v_ = b;
        if ((typeof v_ === 'function')) {
            return false;
        }
        return true;
    };
    ComponentRenderer.prototype.createObjectFromJson = function (a, b) {
        var c = new JsonDictionaryParser();
        var d = c.parse(a);
        var e = new DescriptionSerializer();
        var f = false;
        var g = e.d(this.context, d, f, null, false);
        if (g.result == null) {
            return null;
        }
        var h = DescriptionTreeBuilder.createTree(this.context, g.result);
        var i = this.au.item(b);
        if (h.b("Type")) {
            var j = h.a("Type").b;
            return this.bm(j, h, b, i, true, -1);
        }
        else {
            return this.bl(typeCast(JsonDictionaryObject.$, d));
        }
    };
    ComponentRenderer.prototype.loadJson = function (a, b) {
        this.cj(a, b, null, false, false, false);
    };
    ComponentRenderer.prototype.loadJsonOverlay = function (a, b, c) {
        this.cj(a, b, c, true, false, true);
    };
    ComponentRenderer.prototype.loadJsonDelta = function (a, b, c) {
        this.cj(a, b, null, true, c, false);
    };
    ComponentRenderer.prototype.aj = function () {
        return false;
    };
    ComponentRenderer.prototype.cj = function (a, b, c, d, e, f) {
        var g = new JsonDictionaryParser();
        var h = g.parse(a);
        var i = new DescriptionSerializer();
        i.h = this.isProceedOnErrorEnabled;
        i.g = this.aj();
        var j = null;
        if (typeCast(JsonDictionaryObject.$, h) !== null) {
            var k = h;
            if (k.g("descriptions")) {
                var l = k.item("descriptions");
                if (typeCast(JsonDictionaryObject.$, l) !== null) {
                    var m = l;
                    var n = m.e();
                    for (var o = 0; o < n.length; o++) {
                        var p = n[o];
                        var q = m.item(p);
                        var r = b(p);
                        if (r == null) {
                            continue;
                        }
                        j = r;
                        var s = false;
                        var t = this.a3();
                        if (t != null) {
                            s = true;
                        }
                        var 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.ay.containsKey(r)) {
                                var 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.c2(w.result, r, d, true, false);
                                var y = c(p);
                                var z = this.ay.item(r);
                                this.cf(this.an.item(r), y, z, r);
                            }
                        }
                        this.c2(u.result, r, d, e, false);
                    }
                }
            }
            if (k.g("refs") && j != null) {
                var aa = k.item("refs");
                var ab = this.z(aa);
                if (!ab && typeCast(JsonDictionaryObject.$, aa) !== null) {
                    var ac = aa;
                    var ad = ac.e();
                    for (var ae = 0; ae < ad.length; ae++) {
                        var af = ad[ae];
                        var ag = ac.item(af);
                        if (typeCast(JsonDictionaryValue.$, ag) !== null) {
                            var ah = ag;
                            this.provideRefValue(j, af, ah.value);
                        }
                        else if (typeCast(JsonDictionaryArray.$, ag) !== null) {
                            var ai = ag;
                            var aj = this.a(ai);
                            this.provideRefValue(j, af, aj);
                        }
                        else {
                            var ak = this.bl(ag);
                            this.provideRefValue(j, af, ak);
                        }
                    }
                }
            }
            if (k.g("modules") && j != null) {
                var al = k.item("modules");
                this.y(al);
            }
            if (k.g("strings") && j != null) {
                var am = k.item("strings");
                this.ad(am);
            }
        }
    };
    ComponentRenderer.prototype.provideRefValueFromJson = function (a, b, c) {
        var d = b;
        var e = new JsonDictionaryParser();
        var f = e.parse(c);
        if (typeCast(JsonDictionaryValue.$, f) !== null) {
            var g = f;
            this.provideRefValue(a, d, g.value);
        }
        else if (typeCast(JsonDictionaryArray.$, f) !== null) {
            var h = f;
            var i = this.a(h);
            this.provideRefValue(a, d, i);
        }
        else {
            var j = this.bl(f);
            this.provideRefValue(a, d, j);
        }
    };
    ComponentRenderer.prototype.a3 = function () {
        return null;
    };
    ComponentRenderer.prototype.z = function (a) {
        return false;
    };
    ComponentRenderer.prototype.y = function (a) {
        return false;
    };
    ComponentRenderer.prototype.ad = function (a) {
        return false;
    };
    ComponentRenderer.prototype.by = function (a, b, c) {
        var 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;
    };
    ComponentRenderer.prototype.cf = function (a, b, c, d) {
        var e_3, _a;
        if (!c.b(b)) {
            c.k(d, this.an.item(d).f, b, this.an.item(d), runOn(this, this.cp), -1);
        }
        try {
            for (var _b = tslib_1.__values(fromEnum(a.e())), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                this.cg(this.by(e.c, ComponentRenderer.platform, e.a), e.b, b, c, d, a.f);
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
    };
    ComponentRenderer.prototype.cg = function (a, b, c, d, e, f) {
        var e_4, _a;
        var _this = this;
        if (typeCast(DescriptionTreeNode.$, b) !== null) {
            var g = b;
            var h = this.e.getPropertyValue(c, a);
            if (!d.b(h) && !d.a(g.f)) {
                d.k(e, g.f, h, g, runOn(this, this.cp), f);
            }
            try {
                for (var _b = tslib_1.__values(fromEnum(g.e())), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var i = _c.value;
                    this.cg(a + "." + this.by(i.c, ComponentRenderer.platform, i.a), i.b, c, d, e, g.f);
                }
            }
            catch (e_4_1) {
                e_4 = { error: e_4_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_4)
                        throw e_4.error;
                }
            }
        }
        if (typeCast(Array_$type, b) !== null) {
            var j_1 = new Dictionary$2(Number_$type, DescriptionTreeNode.$, 0);
            var k_1 = 0;
            var l = b.length;
            var o = b;
            for (var n = 0; n < o.length; n++) {
                var m = o[n];
                if (typeCast(DescriptionTreeNode.$, m) !== null) {
                    var p = m;
                    j_1.item(k_1, p);
                }
                k_1++;
            }
            var q = this.e.getPropertyValue(c, a);
            k_1 = 0;
            this.e.forPropertyValueItem(c, a, function (r) {
                var e_5, _a;
                if (j_1.containsKey(k_1)) {
                    var s = j_1.item(k_1);
                    if (!d.b(r) && !d.a(s.f)) {
                        d.k(e, s.f, r, s, runOn(_this, _this.cp), f);
                    }
                    try {
                        for (var _b = tslib_1.__values(fromEnum(s.e())), _c = _b.next(); !_c.done; _c = _b.next()) {
                            var t = _c.value;
                            _this.cg(a + "." + t.c, t.b, c, d, e, s.f);
                        }
                    }
                    catch (e_5_1) {
                        e_5 = { error: e_5_1 };
                    }
                    finally {
                        try {
                            if (_c && !_c.done && (_a = _b.return))
                                _a.call(_b);
                        }
                        finally {
                            if (e_5)
                                throw e_5.error;
                        }
                    }
                }
                k_1++;
            });
            if (l > 0 && k_1 == 0) {
                var r_1 = this.b2(a);
                this.e.forPropertyValueItem(c, r_1, function (s) {
                    var e_6, _a;
                    if (j_1.containsKey(k_1)) {
                        var t = j_1.item(k_1);
                        if (!d.b(s) && !d.a(t.f)) {
                            d.k(e, t.f, s, t, runOn(_this, _this.cp), f);
                        }
                        try {
                            for (var _b = tslib_1.__values(fromEnum(t.e())), _c = _b.next(); !_c.done; _c = _b.next()) {
                                var u = _c.value;
                                _this.cg(r_1 + "." + u.c, u.b, c, d, e, t.f);
                            }
                        }
                        catch (e_6_1) {
                            e_6 = { error: e_6_1 };
                        }
                        finally {
                            try {
                                if (_c && !_c.done && (_a = _b.return))
                                    _a.call(_b);
                            }
                            finally {
                                if (e_6)
                                    throw e_6.error;
                            }
                        }
                    }
                    k_1++;
                });
            }
        }
    };
    ComponentRenderer.prototype.b2 = function (a) {
        var b = a.lastIndexOf('.');
        var c = null;
        var d = a;
        if (b > 0) {
            c = a.substr(0, b);
            d = a.substr(b + 1);
        }
        d = "actual" + this.b0(d);
        if (c != null) {
            return c + "." + d;
        }
        return d;
    };
    ComponentRenderer.prototype.b0 = function (a) {
        return a.substr(0, 1).toUpperCase() + a.substr(1);
    };
    ComponentRenderer.prototype.a = function (a) {
        var b = new Array(a.items.length);
        for (var c = 0; c < a.items.length; c++) {
            var d = this.bl(a.items[c]);
            b[c] = d;
        }
        return b;
    };
    ComponentRenderer.prototype.bl = function (a) {
        if (a == null) {
            return null;
        }
        var b = {};
        var dict_ = b;
        var c = a.e();
        for (var d = 0; d < c.length; d++) {
            var key_ = c[d];
            if (typeCast(JsonDictionaryObject.$, a.item(key_)) !== null) {
                var val_ = this.bl(a.item(key_));
                dict_[key_] = val_;
            }
            else if (typeCast(JsonDictionaryArray.$, a.item(key_)) !== null) {
                var val_ = this.a(a.item(key_));
                dict_[key_] = val_;
            }
            else {
                var val_ = a.item(key_).value;
                dict_[key_] = val_;
            }
        }
        return dict_;
    };
    Object.defineProperty(ComponentRenderer.prototype, "ay", {
        get: function () {
            return this.au;
        },
        enumerable: true,
        configurable: true
    });
    ComponentRenderer.prototype.cleanup = function (a, b) {
        this.c2(null, a, false, false, b);
    };
    ComponentRenderer.prototype.render = function (a, b) {
        this.c2(a, b, false, false, false);
    };
    ComponentRenderer.prototype.c2 = function (a, b, c, d, e) {
        var _this = this;
        if (!this.au.containsKey(b)) {
            this.au.item(b, new ContainerState());
            this.au.item(b).i = b;
        }
        this.ap.item(b, a);
        this.aq.item(b, c);
        this.ar.item(b, d);
        this.ao.item(b, e);
        this.cl(b, function () { return _this.c0(b); });
    };
    ComponentRenderer.prototype.cl = function (a, b) {
        this.e.onUIThread(a, b);
    };
    ComponentRenderer.prototype.c0 = function (a) {
        var e_7, _a, e_8, _b, e_9, _c, e_10, _d;
        var _this = this;
        if (this.ap.containsKey(a)) {
            var b = this.aq.containsKey(a) ? this.aq.item(a) : false;
            var c = this.ar.containsKey(a) ? this.ar.item(a) : false;
            var d = this.ap.item(a);
            this.ap.removeItem(a);
            var e = DescriptionTreeBuilder.createTree(this.context, d);
            var f = null;
            if (this.an.containsKey(a)) {
                f = this.an.item(a);
            }
            var g = DescriptionTreeReconciler.c(f, e, b);
            if (c) {
                var h = DescriptionTreeReconciler.a(f, g);
                if (!this.au.containsKey(a)) {
                    this.au.addItem(a, ((function () {
                        var $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                var i_1 = this.au.item(a);
                if (h.a.count > 0) {
                    try {
                        for (var _e = tslib_1.__values(fromEnum(h.a)), _f = _e.next(); !_f.done; _f = _e.next()) {
                            var j = _f.value;
                            if (i_1.a(j)) {
                                var k = i_1.j(j);
                                this.cd(a, k, i_1);
                            }
                        }
                    }
                    catch (e_7_1) {
                        e_7 = { error: e_7_1 };
                    }
                    finally {
                        try {
                            if (_f && !_f.done && (_a = _e.return))
                                _a.call(_e);
                        }
                        finally {
                            if (e_7)
                                throw e_7.error;
                        }
                    }
                }
                if (h.c.count > 0) {
                    try {
                        for (var _g = tslib_1.__values(fromEnum(h.c)), _h = _g.next(); !_h.done; _h = _g.next()) {
                            var l = _h.value;
                            var m = this.br(a, i_1, l);
                            var n = this.e.getPropertyValue(m, l.i);
                            if (n != null) {
                                if (!i_1.b(n)) {
                                    var o = l.f;
                                    if (typeCast(DescriptionTreeNode.$, o) !== null) {
                                        var p = o.f;
                                        i_1.k(a, p, n, o, runOn(this, this.cp), l.b.f);
                                    }
                                }
                            }
                        }
                    }
                    catch (e_8_1) {
                        e_8 = { error: e_8_1 };
                    }
                    finally {
                        try {
                            if (_h && !_h.done && (_b = _g.return))
                                _b.call(_g);
                        }
                        finally {
                            if (e_8)
                                throw e_8.error;
                        }
                    }
                }
                if (h.d.count > 0) {
                    try {
                        for (var _j = tslib_1.__values(fromEnum(h.d)), _k = _j.next(); !_k.done; _k = _j.next()) {
                            var q = _k.value;
                            var r = q.f;
                            if (r != null) {
                                if (!i_1.b(r)) {
                                    var s = q.f;
                                    if (typeCast(DescriptionTreeNode.$, s) !== null) {
                                        var t = s.f;
                                        this.an.item(a, s);
                                    }
                                }
                            }
                        }
                    }
                    catch (e_9_1) {
                        e_9 = { error: e_9_1 };
                    }
                    finally {
                        try {
                            if (_k && !_k.done && (_c = _j.return))
                                _c.call(_j);
                        }
                        finally {
                            if (e_9)
                                throw e_9.error;
                        }
                    }
                }
                if (h.b.count > 0) {
                    var _loop_1 = function (u) {
                        var v = u.b.a(u.i).b;
                        if (v == null) {
                            return "continue";
                        }
                        var w = new Dictionary$2(String_$type, DescriptionTreeNode.$, 0);
                        for (var x = 0; x < v.length; x++) {
                            var y = v[x];
                            if (typeCast(DescriptionTreeNode.$, y) !== null) {
                                var z = y;
                                if (z.b("Name")) {
                                    w.item(z.a("Name").b, z);
                                }
                            }
                        }
                        if (w.count == 0) {
                            return "continue";
                        }
                        var aa = this_1.br(a, i_1, u);
                        var ab = this_1.e.getPropertyValue(aa, u.i);
                        if (ab != null) {
                            var ac_1 = 0;
                            this_1.e.forPropertyValueItem(aa, u.i, function (ad) {
                                if (w.containsKey(_this.e.getPropertyValue(ad, "Name").toString())) {
                                    if (!i_1.b(ad)) {
                                        var ae = w.item(_this.e.getPropertyValue(ad, "Name").toString());
                                        if (typeCast(DescriptionTreeNode.$, ae) !== null) {
                                            var af = ae.f;
                                            i_1.k(a, af, ad, ae, runOn(_this, _this.cp), u.b.f);
                                        }
                                    }
                                }
                                ac_1++;
                            });
                        }
                    };
                    var this_1 = this;
                    try {
                        for (var _l = tslib_1.__values(fromEnum(h.b)), _m = _l.next(); !_m.done; _m = _l.next()) {
                            var u = _m.value;
                            _loop_1(u);
                        }
                    }
                    catch (e_10_1) {
                        e_10 = { error: e_10_1 };
                    }
                    finally {
                        try {
                            if (_m && !_m.done && (_d = _l.return))
                                _d.call(_l);
                        }
                        finally {
                            if (e_10)
                                throw e_10.error;
                        }
                    }
                }
            }
            else {
                this.an.item(a, e);
            }
            if (!c) {
                this.c1(a, g);
            }
            if (this.ao.item(a)) {
                this.cy(a);
                if (this.au.containsKey(a)) {
                    this.au.removeItem(a);
                }
            }
        }
    };
    ComponentRenderer.prototype.provideRefValue = function (a, b, c) {
        var _this = this;
        this.cl(a, function () {
            if (!_this.au.containsKey(a)) {
                _this.au.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var d = _this.au.item(a);
            _this.cp(a, b, c, true);
        });
    };
    ComponentRenderer.prototype.removeRefValue = function (a, b) {
        var _this = this;
        this.cl(a, function () {
            if (!_this.au.containsKey(a)) {
                _this.au.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var c = _this.au.item(a);
            _this.removeRefValueCore(a, b, true);
        });
    };
    ComponentRenderer.prototype.cy = function (a) {
        var e_11, _a;
        var b = this.au.item(a);
        var c = new List$1(String_$type, 0);
        try {
            for (var _b = tslib_1.__values(fromEnum(this.at.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                if (this.at.item(d).c == 0) {
                    c.add(d);
                }
            }
        }
        catch (e_11_1) {
            e_11 = { error: e_11_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_11)
                    throw e_11.error;
            }
        }
        for (var e = 0; e < c.count; e++) {
            var f = this.shouldNamespaceSystemRefValues;
            this.shouldNamespaceSystemRefValues = false;
            this.removeRefValueCore(a, c._inner[e], this.ax.containsKey(c._inner[e]));
            this.shouldNamespaceSystemRefValues = f;
        }
    };
    ComponentRenderer.prototype.clearRefValues = function (a) {
        var _this = this;
        this.cl(a, function () {
            if (!_this.au.containsKey(a)) {
                _this.au.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var b = _this.au.item(a);
            _this.clearUserRefValues();
        });
    };
    ComponentRenderer.prototype.c1 = function (a, b) {
        var c = this.au.item(a);
        this.cm(a, c, b);
    };
    ComponentRenderer.prototype.c4 = function (a, b) {
        if (this.isProceedOnErrorEnabled) {
            try {
                this.ce(a, b, true);
            }
            catch (c) {
                this.am.item(a, false);
            }
        }
        else {
            this.ce(a, b, true);
        }
    };
    ComponentRenderer.prototype.da = function (a, b) {
        if (this.isProceedOnErrorEnabled) {
            try {
                this.ce(a, b, false);
            }
            catch (c) {
                this.am.item(a, false);
            }
        }
        else {
            this.ce(a, b, false);
        }
    };
    ComponentRenderer.prototype.ce = function (a, b, c) {
        if (!c) {
            if (this.am.containsKey(a) && this.am.item(a)) {
                return;
            }
        }
        this.am.item(a, true);
        var d = true;
        while (d && this.as.item(a).count > 0) {
            while (this.as.item(a).count > 0 && this.as.item(a).c().count < 1) {
                this.as.item(a).b();
            }
            if (this.as.item(a).count < 1) {
                break;
            }
            var e = this.as.item(a).c();
            while (e.count > 0) {
                var f = e.b();
                d = this.v(a, b, f);
                if (!d) {
                    break;
                }
            }
        }
        if (d) {
            this.am.item(a, false);
        }
    };
    ComponentRenderer.prototype.cm = function (a, b, c) {
        var d = new Queue$1(DescriptionTreeAction.$);
        for (var e = 0; e < c.count; e++) {
            d.g(c._inner[e]);
        }
        if (!this.as.containsKey(a)) {
            this.as.addItem(a, new Queue$1(Queue$1.$.specialize(DescriptionTreeAction.$)));
        }
        this.as.item(a).g(d);
        this.da(a, b);
    };
    ComponentRenderer.prototype.cn = function (a, b, c) {
        for (var d = 0; d < c.count; d++) {
            this.v(a, b, c._inner[d]);
        }
    };
    ComponentRenderer.prototype.v = function (a, b, c) {
        switch (c.a) {
            case 5: return this.w(a, b, c);
            case 2: return this.x(a, b, c);
            case 4: return this.aa(a, b, c);
            case 3: return this.ab(a, b, c);
            case 1: return this.ac(a, b, c);
            case 0: return this.ae(a, b, c);
        }
        return true;
    };
    ComponentRenderer.prototype.ae = function (a, b, c) {
        var d = this.br(a, b, c);
        this.al(a, b, c, d);
        return true;
    };
    ComponentRenderer.prototype.al = function (a, b, c, d) {
        var e = this.bo(c, a, b);
        e = this.g.transform(ComponentRenderer.platform, e, c);
        var f = false;
        if (this.a1 != null && this.a1.count > 0) {
            for (var g = 0; g < this.a1.count; g++) {
                var h = this.a1._inner[g];
                var i = this.bz(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.ai(a, b, c.h(ComponentRenderer.platform), c.c, e, d);
        }
        else {
            this.c8(a, b, c.h(ComponentRenderer.platform), c.c, e, c.g, d);
        }
        return true;
    };
    ComponentRenderer.prototype.bz = function (a, b) {
        var c = b.b;
        var d = "";
        if (c != this.an.item(a)) {
            var e = this.bx(a, c);
            d = e;
        }
        if (d.length > 0) {
            d += ".";
        }
        d += b.i;
        return d;
    };
    ComponentRenderer.prototype.bx = function (a, b) {
        if (b == null) {
            return "";
        }
        var c = this.b3("", this.an.item(a), b);
        if (c.c) {
            return c.d;
        }
        return "";
    };
    ComponentRenderer.prototype.b3 = function (a, b, c) {
        if (b == c) {
            return new Tuple$2(Boolean_$type, String_$type, true, a);
        }
        if (a.length > 0) {
            a += ".";
        }
        var d = b.e();
        for (var e = 0; e < d.count; e++) {
            var 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 {
                    var g = a + f.c;
                    var h = this.b3(g, f.b, c);
                    if (h.c) {
                        return h;
                    }
                }
            }
            if (f.a != null && f.a.knownType == 9) {
                var i = f.b;
                for (var j = 0; j < i.length; j++) {
                    if (typeCast(DescriptionTreeNode.$, i[j]) !== null) {
                        var k = i[j];
                        if (k.f == c.f) {
                            a += f.c + "[" + j + "]";
                            return new Tuple$2(Boolean_$type, String_$type, true, a);
                        }
                        else {
                            var l = a + f.c + "[" + j + "]";
                            var m = this.b3(l, k, c);
                            if (m.c) {
                                return m;
                            }
                        }
                    }
                }
            }
        }
        return new Tuple$2(Boolean_$type, String_$type, false, a);
    };
    ComponentRenderer.prototype.ai = function (a, b, c, d, e, f) {
        var e_12, _a;
        if (this.aw.containsKey(c)) {
            try {
                for (var _b = tslib_1.__values(fromEnum(this.aw.item(c))), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var g = _c.value;
                    g(c, f, e);
                }
            }
            catch (e_12_1) {
                e_12 = { error: e_12_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_12)
                        throw e_12.error;
                }
            }
        }
        this.e.setOrUpdateCollectionOnTarget(a, c, d, this.context, f, e);
        return true;
    };
    ComponentRenderer.prototype.bo = function (a, b, c) {
        if (a.c == null) {
            return a.f;
        }
        switch (a.c.knownType) {
            case 10: return this.a5(a, b, c);
            case 7: return this.a6(a);
            case 4: return this.a7(a);
            case 6: return this.a8(a);
            case 9: return this.a5(a, b, c);
            case 5: return this.a9(a);
            case 16: return this.ba(a);
            case 20: return this.bs(a, c);
            case 15: return null;
            case 3: return this.bb(a);
            case 19: return this.bt(a, c);
            case 8: return this.bd(a, b, c);
            case 13: return null;
            case 18: return this.bu(a, c);
            case 1: return this.be(a);
            case 11: return this.bf(a);
            case 14: return this.bg(a);
            case 12: return this.bh(a);
            case 2: return this.bi(a);
            case 21: return this.bj(a);
            case 17: return this.bk(a, b, c);
            case 0: return null;
        }
        return null;
    };
    ComponentRenderer.prototype.bk = function (a, b, c) {
        if (typeCast(DescriptionTreeNode.$, a.f) !== null) {
            var d = a.f;
            if (d.h == "EmbeddedRef") {
                return this.bm(d.h, a.f, b, c, false, a.b.f);
            }
        }
        return a.f;
    };
    ComponentRenderer.prototype.bj = function (a) {
        return a.f;
    };
    ComponentRenderer.prototype.bi = function (a) {
        return a.f != null ? a.f.toString() : null;
    };
    ComponentRenderer.prototype.bh = function (a) {
        var b = a.f;
        var width_ = b.width;
        var height_ = b.height;
        var c = { width: width_, height: height_ };
        return c;
    };
    ComponentRenderer.prototype.bg = function (a) {
        var b = a.f;
        var top_ = b.top;
        var left_ = b.left;
        var width_ = b.width;
        var height_ = b.height;
        var c = { left: left_, top: top_, width: width_, height: height_ };
        return c;
    };
    ComponentRenderer.prototype.bf = function (a) {
        var b = a.f;
        var x_ = b.x;
        var y_ = b.y;
        var c = { x: x_, y: y_ };
        return c;
    };
    ComponentRenderer.prototype.be = function (a) {
        if (a.f == null) {
            if (a.c != null && (a.c.specificType == "double" || a.c.specificType == "float")) {
                return NaN;
            }
            return 0;
        }
        return a.f;
    };
    ComponentRenderer.prototype.c = function (a, b) {
        if (this.at.containsKey(a)) {
            var c = this.at.item(a);
            return c;
        }
        var d = new DescriptionRef(a);
        this.at.addItem(a, d);
        return d;
    };
    ComponentRenderer.prototype.bu = function (a, b) {
        return a.f == null ? null : this.c(a.f, b);
    };
    ComponentRenderer.prototype.bd = function (a, b, c) {
        var d = a.c.specificType;
        if (d == null) {
            d = a.c.specificExternalType;
        }
        if (typeCast(DescriptionTreeNode.$, a.f) !== null) {
            var e = a.f;
            if (e.b("Type")) {
                d = e.a("Type").b;
            }
        }
        var f = this.bm(d, a.f, b, c, false, a.b.f);
        return f;
    };
    ComponentRenderer.prototype.bt = function (a, b) {
        return a.f == null ? null : this.c(a.f, b);
    };
    ComponentRenderer.prototype.bb = function (a) {
        return a.f;
    };
    ComponentRenderer.prototype.bs = function (a, b) {
        return a.f == null ? null : this.c(a.f, b);
    };
    ComponentRenderer.prototype.bw = function (a) {
        return a;
    };
    ComponentRenderer.prototype.ba = function (a) {
        var b = a.f;
        if (b == null) {
            return null;
        }
        var c = new Array(b.length);
        for (var d = 0; d < b.length; d++) {
            c[d] = this.bw(b[d]);
        }
        return c;
    };
    ComponentRenderer.prototype.a9 = function (a) {
        return this.bw(a.f);
    };
    ComponentRenderer.prototype.a8 = function (a) {
        var b = a.f;
        if (b == null) {
            return null;
        }
        var c = new Array(b.length);
        for (var d = 0; d < b.length; d++) {
            c[d] = this.bv(b[d]);
        }
        return c;
    };
    ComponentRenderer.prototype.bv = function (a) {
        return a;
    };
    ComponentRenderer.prototype.a7 = function (a) {
        return this.bv(a.f);
    };
    ComponentRenderer.prototype.a6 = function (a) {
        return a.f;
    };
    ComponentRenderer.prototype.addTargetPropertyUpdatingListener = function (a) {
        this.a1.add(a);
    };
    ComponentRenderer.prototype.removeTargetPropertyUpdatingListener = function (a) {
        this.a1.remove(a);
    };
    ComponentRenderer.prototype.addPropertyUpdatingListener = function (a, b) {
        if (!this.aw.containsKey(a)) {
            this.aw.addItem(a, new List$1(Delegate_$type, 0));
        }
        this.aw.item(a).add(b);
    };
    ComponentRenderer.prototype.addReferenceLookupListener = function (a) {
        this.az.add(a);
    };
    ComponentRenderer.prototype.removeReferenceLookupListener = function (a) {
        this.az.remove(a);
    };
    ComponentRenderer.prototype.removePropertyUpdatingListener = function (a, b) {
        if (this.aw.containsKey(a)) {
            this.aw.item(a).remove(b);
            if (this.aw.item(a).count == 0) {
                this.aw.removeItem(a);
            }
        }
    };
    ComponentRenderer.prototype.addNamespaceLookupListener = function (a) {
        this.a0.add(a);
    };
    ComponentRenderer.prototype.removeNamespaceLookupListener = function (a) {
        this.a0.remove(a);
    };
    ComponentRenderer.prototype.a5 = function (a, b, c) {
        if (a.f == null) {
            return null;
        }
        var d = a.f;
        var e = new List$1(Base.$, 0);
        var 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 (var g = 0; g < d.length; g++) {
            var h = f;
            if (typeCast(DescriptionTreeNode.$, d[g]) !== null) {
                var i = d[g];
                if (i.b("Type")) {
                    h = i.a("Type").b;
                }
            }
            var j = this.bm(h, d[g], b, c, false, a.b.f);
            e.add1(j);
        }
        return e.toArray();
    };
    ComponentRenderer.prototype.c8 = function (a, b, c, d, e, f, g) {
        var _this = this;
        if (typeCast(DescriptionRef.$, e) !== null) {
            var h = e;
            var i = false;
            if (f != null && typeof f === 'string') {
                if (this.o(f)) {
                    var j = this.d(f);
                    if (Base.equalsStatic(j, e)) {
                        i = true;
                    }
                    else {
                        j.j(a, g, c);
                    }
                }
            }
            if (this.p(e)) {
                var k = e;
                if (k.e != null && k.e.length > 0 && this.av.containsKey(k.e)) {
                    k.a = true;
                }
                e = this.bq(e);
                this.c9(g, c, d, e, f, k);
            }
            else {
                this.e.onPendingRef(g, c, d, e);
            }
            var l = null;
            l = function (m, n) {
                var o = m;
                if (o.e != null && o.e.length > 0 && _this.av.containsKey(o.e)) {
                    o.a = true;
                }
                var p = _this.bq(m);
                _this.c9(g, c, d, p, f, o);
            };
            if (!i) {
                h.g(a, g, c, l);
            }
            return;
        }
        this.c9(g, c, d, e, f, null);
    };
    ComponentRenderer.prototype.hasUserRef = function (a) {
        return this.ax.containsKey(a);
    };
    Object.defineProperty(ComponentRenderer.prototype, "shouldNamespaceSystemRefValues", {
        get: function () {
            return this._shouldNamespaceSystemRefValues;
        },
        set: function (a) {
            this._shouldNamespaceSystemRefValues = a;
        },
        enumerable: true,
        configurable: true
    });
    ComponentRenderer.prototype.cp = function (a, b, c, d) {
        var e = null;
        if (d) {
            if (this.ax.containsKey(b)) {
                e = this.ax.item(b);
            }
            this.ax.item(b, c);
        }
        else {
            if (this.shouldNamespaceSystemRefValues) {
                var f = "";
                if (this.a0 != null && this.a0.count > 0) {
                    for (var g = 0; g < this.a0.count; g++) {
                        f = this.a0._inner[g](a);
                    }
                }
                if (!stringIsNullOrEmpty(f)) {
                    b = f + "/" + b;
                }
            }
            if (this.av.containsKey(b)) {
                e = this.av.item(b);
            }
            this.av.item(b, c);
            if (this.at.containsKey(b)) {
                this.at.item(b).a = true;
            }
        }
        if (this.at.containsKey(b)) {
            this.at.item(b).f(e, c);
        }
    };
    ComponentRenderer.prototype.removeRefValueCore = function (a, b, c) {
        var d = null;
        if (c) {
            if (this.ax.containsKey(b)) {
                d = this.ax.item(b);
            }
            this.ax.removeItem(b);
        }
        else {
            if (this.shouldNamespaceSystemRefValues) {
                var e = "";
                if (this.a0 != null && this.a0.count > 0) {
                    for (var f = 0; f < this.a0.count; f++) {
                        e = this.a0._inner[f](a);
                    }
                }
                if (!stringIsNullOrEmpty(e)) {
                    b = e + "/" + b;
                }
            }
            if (this.av.containsKey(b)) {
                d = this.av.item(b);
            }
            this.av.removeItem(b);
        }
        if (this.at.containsKey(b)) {
            this.at.item(b).f(d, this.bq(this.at.item(b)));
            if (this.at.item(b).c <= 0) {
                this.at.item(b).h();
                this.at.removeItem(b);
            }
        }
    };
    ComponentRenderer.prototype.clearUserRefValues = function () {
        var e_13, _a, e_14, _b;
        var a = new List$1(String_$type, 0);
        try {
            for (var _c = tslib_1.__values(fromEnum(this.ax.keys)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var b = _d.value;
                a.add(b);
            }
        }
        catch (e_13_1) {
            e_13 = { error: e_13_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_13)
                    throw e_13.error;
            }
        }
        try {
            for (var _e = tslib_1.__values(fromEnum(a)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var c = _f.value;
                this.removeRefValueCore(null, c, true);
            }
        }
        catch (e_14_1) {
            e_14 = { error: e_14_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_14)
                    throw e_14.error;
            }
        }
    };
    ComponentRenderer.prototype.p = function (a) {
        return this.ax.containsKey(a.e) || this.av.containsKey(a.e);
    };
    ComponentRenderer.prototype.bq = function (a) {
        if (this.ax.containsKey(a.e)) {
            return this.ax.item(a.e);
        }
        if (this.av.containsKey(a.e)) {
            return this.av.item(a.e);
        }
        return null;
    };
    ComponentRenderer.prototype.o = function (a) {
        return this.at.containsKey(a);
    };
    ComponentRenderer.prototype.d = function (a) {
        return this.at.item(a);
    };
    ComponentRenderer.prototype.getMissingRefs = function () {
        var e_15, _a;
        var a = new List$1(String_$type, 0);
        try {
            for (var _b = tslib_1.__values(fromEnum(this.at.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (!this.p(this.at.item(b))) {
                    a.add(b);
                }
            }
        }
        catch (e_15_1) {
            e_15 = { error: e_15_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_15)
                    throw e_15.error;
            }
        }
        return a.toArray();
    };
    ComponentRenderer.prototype.br = function (a, b, c) {
        return b.j(c.b.f);
    };
    ComponentRenderer.prototype.ac = function (a, b, c) {
        var d = this.br(a, b, c);
        this.ah(a, b, c, d);
        return true;
    };
    ComponentRenderer.prototype.ah = function (a, b, c, d) {
        this.e.resetPropertyOnTarget(a, c.h(ComponentRenderer.platform), c.c, d);
        return true;
    };
    ComponentRenderer.prototype.ab = function (a, b, c) {
        if (c.b == null) {
            return this.ag(a, b, c);
        }
        else {
            var d = this.br(a, b, c);
            this.c3(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.c3 = function (a, b, c, d) {
        var e = c.h(ComponentRenderer.platform);
        var f = c.c.collectionElementType;
        if (f == null) {
            f = c.c.specificExternalType;
        }
        var g = this.bm(f, c.f, a, b, false, c.b.f);
        this.e.replaceItemInCollection(e, c.c, d, c.d, g);
        if (c.g != null && typeCast(DescriptionTreeNode.$, c.g) !== null) {
            var h = c.g.f;
            if (h >= 0) {
                var i = b.j(h);
                if (i != null) {
                    this.cd(a, i, b);
                }
            }
        }
    };
    ComponentRenderer.prototype.ag = function (a, b, c) {
        var _this = this;
        var d = this.e.getRootObject(a);
        if (d != null) {
            this.cd(a, d, b);
        }
        if (!(typeCast(DescriptionTreeNode.$, c.f) !== null)) {
            throw new NotImplementedException(0);
        }
        var e = c.f;
        var f = false;
        this.e.replaceRootItem(a, e.h, this.context, function (g) {
            var h = _this.e.getRootObject(a);
            b.k(a, e.f, h, e, runOn(_this, _this.cp), -1);
            var i = _this.a2(e);
            _this.cn(a, b, i);
            f = true;
            if (g) {
                _this.c4(a, b);
            }
        });
        return f;
    };
    ComponentRenderer.prototype.cd = function (a, b, c) {
        var e_16, _a;
        var d = this.a4(a, b, c);
        try {
            for (var _b = tslib_1.__values(fromEnum(this.at.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                e.i(b);
            }
        }
        catch (e_16_1) {
            e_16 = { error: e_16_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_16)
                    throw e_16.error;
            }
        }
        if (d != -1) {
            c.l(this, a, d, runOn(this, this.removeRefValueCore));
        }
        this.h.b(ComponentRenderer.platform, b);
    };
    ComponentRenderer.prototype.a4 = function (a, b, c) {
        return c.h(b);
    };
    ComponentRenderer.prototype.aa = function (a, b, c) {
        if (c.b == null) {
            return this.af(a, b, c);
        }
        else {
            var d = this.br(a, b, c);
            this.cr(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.cr = function (a, b, c, d) {
        var e = c.h(ComponentRenderer.platform);
        this.e.removeItemFromCollection(e, c.c, d, c.e);
        if (c.g != null && typeCast(DescriptionTreeNode.$, c.g) !== null) {
            var f = c.g.f;
            if (f >= 0) {
                var g = b.j(f);
                if (g != null) {
                    this.cd(a, g, b);
                }
            }
        }
    };
    ComponentRenderer.prototype.af = function (a, b, c) {
        var _this = this;
        var d = this.e.getRootObject(a);
        if (d != null) {
            this.cd(a, d, b);
        }
        var e = false;
        this.e.removeRootItem(a, this.context, function (f) {
            e = true;
            if (f) {
                _this.c4(a, b);
            }
        });
        return e;
    };
    ComponentRenderer.prototype.x = function (a, b, c) {
        if (c.b == null) {
            return this.k(a, b, c);
        }
        else {
            var d = this.br(a, b, c);
            this.b4(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.k = function (a, b, c) {
        var _this = this;
        if (!(typeCast(DescriptionTreeNode.$, c.f) !== null)) {
            throw new NotImplementedException(0);
        }
        var d = c.f;
        var e = false;
        this.e.replaceRootItem(a, d.h, this.context, function (f) {
            var g = _this.e.getRootObject(a);
            b.k(a, d.f, g, d, runOn(_this, _this.cp), -1);
            var h = _this.a2(d);
            _this.cn(a, b, h);
            e = true;
            if (f) {
                _this.c4(a, b);
            }
        });
        return e;
    };
    ComponentRenderer.prototype.b4 = function (a, b, c, d) {
        var e = c.h(ComponentRenderer.platform);
        var f = c.c.collectionElementType;
        if (typeCast(DescriptionTreeNode.$, c.f) !== null) {
            var g = c.f;
            if (g.b("Type")) {
                f = g.a("Type").b;
            }
        }
        if (f == null) {
            f = c.c.specificExternalType;
        }
        var h = this.bm(f, c.f, a, b, false, c.b.f);
        this.e.addItemToCollection(e, c.c, d, c.d, h);
    };
    ComponentRenderer.prototype.bm = function (a, b, c, d, e, f) {
        if (this.s(a)) {
            return b;
        }
        var g = null;
        if (b != null && typeCast(DescriptionTreeNode.$, b) !== null) {
            var h = b;
            if (h.b("Name")) {
                var i = h.a("Name").b;
                if (!stringIsNullOrEmpty(i)) {
                    if (this.shouldNamespaceSystemRefValues) {
                        var j = "";
                        if (this.a0 != null && this.a0.count > 0) {
                            for (var k = 0; k < this.a0.count; k++) {
                                j = this.a0._inner[k](c);
                            }
                        }
                        if (!stringIsNullOrEmpty(j)) {
                            i = j + "/" + i;
                        }
                    }
                    if (this.av.containsKey(i)) {
                        var l = this.av.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) {
            var m = b;
            if (m.h == "EmbeddedRef") {
                var n = "uuid";
                var o = null;
                for (var 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 (var q = 0; q < this.az.count; q++) {
                        var r = this.az._inner[q](c, n, o);
                        if (r != null) {
                            return r;
                        }
                    }
                    return null;
                }
            }
            else {
                d.k(c, m.f, g, m, runOn(this, this.cp), f);
                var s = this.a2(m);
                this.cn(c, d, s);
                if (e) {
                    d.l(this, c, m.f, runOn(this, this.removeRefValueCore));
                }
            }
        }
        var t = (a == "object" || a == "Object");
        if (!t && typeof b === 'string' && a.toLowerCase() != "string") {
            return this.bc(a, b);
        }
        if (t) {
            return b;
        }
        return g;
    };
    ComponentRenderer.prototype.s = function (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";
    };
    ComponentRenderer.prototype.bc = function (a, b) {
        return this.context.l(a, b);
    };
    ComponentRenderer.prototype.a2 = function (a) {
        var b = a.e();
        var c = new List$1(DescriptionTreeAction.$, 0);
        for (var d = 0; d < b.count; d++) {
            var 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;
    };
    ComponentRenderer.prototype.w = function (a, b, c) {
        if (c.b == null) {
            return this.n(a, b, c);
        }
        else {
            var d = this.br(a, b, c);
            this.ca(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.ca = function (a, b, c, d) {
        var e = c.h(ComponentRenderer.platform);
        this.e.clearCollection(d, e, c.c);
        if (c.g != null && typeCast(Array_$type, c.g) !== null) {
            var f = c.g;
            for (var g = 0; g < f.length; g++) {
                var h = f[g];
                if (h != null && typeCast(DescriptionTreeNode.$, h) !== null) {
                    var i = h.f;
                    if (i >= 0) {
                        var j = b.j(i);
                        if (j != null) {
                            this.cd(a, j, b);
                        }
                    }
                }
            }
        }
    };
    ComponentRenderer.prototype.c9 = function (a, b, c, d, e, f) {
        var e_17, _a;
        if (this.aw.containsKey(b)) {
            try {
                for (var _b = tslib_1.__values(fromEnum(this.aw.item(b))), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var g = _c.value;
                    g(b, a, d);
                }
            }
            catch (e_17_1) {
                e_17 = { error: e_17_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_17)
                        throw e_17.error;
                }
            }
        }
        this.e.setPropertyValue(a, b, c, d, e, f);
    };
    ComponentRenderer.prototype.bp = function (a, b) {
        return this.e.getPropertyValue(a, b);
    };
    ComponentRenderer.prototype.n = function (a, b, c) {
        return this.m(a, b);
    };
    ComponentRenderer.prototype.m = function (a, b) {
        var _this = this;
        var c = this.e.getRootObject(a);
        if (c != null) {
            this.cd(a, c, b);
        }
        var d = false;
        this.e.clearContainer(a, this.context, function (e) {
            d = true;
            if (e) {
                _this.c4(a, b);
            }
        });
        return d;
    };
    ComponentRenderer.$t = markType(ComponentRenderer, 'ComponentRenderer');
    ComponentRenderer.platform = 3;
    return ComponentRenderer;
}(Base));
export { ComponentRenderer };
/**
 * @hidden
 */
var ContainerState = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ContainerState, _super);
    function ContainerState() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _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);
        return _this;
    }
    ContainerState.prototype.k = function (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);
        }
    };
    ContainerState.prototype.a = function (a) {
        return this.e.containsKey(a);
    };
    ContainerState.prototype.b = function (a) {
        return this.f.containsKey(a);
    };
    ContainerState.prototype.j = function (a) {
        return this.e.item(a);
    };
    ContainerState.prototype.l = function (a, b, c, d) {
        if (this.c.containsKey(c)) {
            var e = this.c.item(c);
            for (var 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.cd(b, this.e.item(e._inner[f]), this);
                    }
                }
            }
            this.c.removeItem(c);
        }
        var 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)) {
            var h = this.d.item(c);
            this.d.removeItem(c);
            d(b, h, false);
        }
    };
    ContainerState.prototype.h = function (a) {
        if (this.f.containsKey(a)) {
            return this.f.item(a);
        }
        return -1;
    };
    ContainerState.$t = markType(ContainerState, 'ContainerState');
    return ContainerState;
}(Base));
export { ContainerState };
//# sourceMappingURL=ComponentRenderer_combined.js.map
