/*
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 { __extends, __values } from "tslib";
import { Base, IEnumerable_$type, fromEnum, typeCast, Date_$type, Boolean_$type, Array_$type, runOn, Number_$type, Delegate_$type, String_$type, EnumUtil, typeGetValue, 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 { List$1 } from "./List$1";
import { DescriptionRef } from "./DescriptionRef";
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 { TypeDescriptionWellKnownType_$type } from "./TypeDescriptionWellKnownType";
import { Tuple$2 } from "./Tuple$2";
import { DescriptionRefTargetInfo } from "./DescriptionRefTargetInfo";
import { NotImplementedException } from "./NotImplementedException";
import { truncate } from "./number";
import { ComponentRendererAdapter } from "./ComponentRendererAdapter";
import { stringIsNullOrEmpty, stringStartsWith, stringEndsWith } from "./string";
/**
 * @hidden
 */
var ComponentRenderer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ComponentRenderer, _super);
    function ComponentRenderer() {
        var _this = _super.call(this) || this;
        _this._adapter = null;
        _this._context = null;
        _this._isProceedOnErrorEnabled = false;
        _this.j = null;
        _this.k = null;
        _this._preserveKeyOrder = false;
        _this.ay = new Dictionary$2(Base.$, Description.$, 0);
        _this.az = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.a0 = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.ax = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.av = new Dictionary$2(Base.$, DescriptionTreeNode.$, 0);
        _this.a3 = new Dictionary$2(Base.$, ContainerState.$, 0);
        _this.a1 = new Dictionary$2(Base.$, Queue$1.$.specialize(Queue$1.$.specialize(DescriptionTreeAction.$)), 0);
        _this.aw = new Dictionary$2(Base.$, List$1.$.specialize(Delegate_$type), 0);
        _this.au = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.a2 = new Dictionary$2(String_$type, DescriptionRef.$, 0);
        _this.a4 = new Dictionary$2(String_$type, Base.$, 0);
        _this.a6 = new Dictionary$2(String_$type, Base.$, 0);
        _this.ba = new List$1(Delegate_$type, 0);
        _this.a5 = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0);
        _this.a8 = new List$1(Delegate_$type, 0);
        _this.a9 = new List$1(Delegate_$type, 0);
        _this._shouldNamespaceSystemRefValues = false;
        var a = _this.i();
        _this.adapter = a;
        var adapter_ = _this.adapter;
        var b = (adapter_._platform);
        if (b == "Igc") {
            ComponentRenderer.platform = 4;
        }
        else if (b == "Igr") {
            ComponentRenderer.platform = 2;
        }
        _this.context = new TypeDescriptionContext(_this.adapter, ComponentRenderer.platform);
        _this.j = new TypeDescriptionPropretyTransforms();
        _this.k = new TypeDescriptionCleanups();
        return _this;
    }
    Object.defineProperty(ComponentRenderer, "defaultInstance", {
        get: function () {
            return ComponentRenderer._defaultInstance;
        },
        set: function (a) {
            ComponentRenderer._defaultInstance = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ComponentRenderer.prototype, "adapter", {
        get: function () {
            return this._adapter;
        },
        set: function (a) {
            this._adapter = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ComponentRenderer.prototype, "context", {
        get: function () {
            return this._context;
        },
        set: function (a) {
            this._context = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ComponentRenderer.prototype, "isProceedOnErrorEnabled", {
        get: function () {
            return this._isProceedOnErrorEnabled;
        },
        set: function (a) {
            this._isProceedOnErrorEnabled = a;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.i = 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 = __values(fromEnum(this.av.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.av.item(e);
                var h = "root";
                h = a(f);
                if (stringIsNullOrEmpty(h)) {
                    h = "root";
                }
                b.e("\"" + h + "\"");
                b.e(": ");
                c.t(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.a6.count > 0) {
            b.e(",");
        }
        b.f("");
        if (this.a6.count > 0) {
            d = true;
            b.f("refs: {");
            b.i();
            try {
                for (var _e = __values(fromEnum(this.a6.keys)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var i = _f.value;
                    if (!this.p(i, this.a6.item(i))) {
                        continue;
                    }
                    if (d) {
                        d = false;
                    }
                    else {
                        b.f(",");
                    }
                    this.d2(b, i, this.a6.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.d2 = function (a, b, c) {
        a.e("\"" + b + "\": ");
        this.d3(a, c);
    };
    ComponentRenderer.prototype.d3 = function (a, b) {
        if (this.y(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.v(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.d1(a, c, d);
                }
                a.f("");
                a.h();
                a.e("]");
            }
            else {
                var e = [b];
                var f = new DataSourceLocalDataProvider();
                f.dataSource = e;
                this.d1(a, f, 0);
            }
        }
    };
    ComponentRenderer.prototype.y = 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.v = function (a) {
        if (typeCast(Array_$type, a) !== null) {
            return true;
        }
        if (typeCast(IEnumerable_$type, a) !== null) {
            return true;
        }
        return false;
    };
    ComponentRenderer.prototype.d1 = 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.d3(a, g);
                    break;
            }
        }
        a.h();
        a.f("}");
    };
    ComponentRenderer.prototype.p = 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.a3.item(b);
        if (h.c("Type")) {
            var j = h.a("Type").b;
            return this.bz(j, h, b, i, true, -1, null);
        }
        else {
            return this.by(typeCast(JsonDictionaryObject.$, d));
        }
    };
    ComponentRenderer.prototype.loadJson = function (a, b) {
        this.dc(a, b, null, false, false, false);
    };
    ComponentRenderer.prototype.loadJsonOverlay = function (a, b, c) {
        this.dc(a, b, c, true, false, true);
    };
    ComponentRenderer.prototype.loadJsonDelta = function (a, b, c) {
        this.dc(a, b, null, true, c, false);
    };
    Object.defineProperty(ComponentRenderer.prototype, "preserveKeyOrder", {
        get: function () {
            return this._preserveKeyOrder;
        },
        set: function (a) {
            this._preserveKeyOrder = a;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.ar = function () {
        return false;
    };
    ComponentRenderer.prototype.de = function (a) {
    };
    ComponentRenderer.prototype.dc = 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.ar();
        var j = null;
        if (typeCast(JsonDictionaryObject.$, h) !== null) {
            var k = h;
            if (k.g("skipAlterDataCasing")) {
                var l = k.item("skipAlterDataCasing");
                if (l.value) {
                    this.de(true);
                }
            }
            else {
                this.de(false);
            }
            if (k.g("descriptions")) {
                var m = k.item("descriptions");
                if (typeCast(JsonDictionaryObject.$, m) !== null) {
                    var n = m;
                    var o = n.e();
                    for (var p = 0; p < o.length; p++) {
                        var q = o[p];
                        var r = n.item(q);
                        var s = b(q);
                        if (s == null) {
                            continue;
                        }
                        j = s;
                        var t = false;
                        var u = this.bd();
                        if (u != null) {
                            t = true;
                        }
                        var v = null;
                        if (this.isProceedOnErrorEnabled) {
                            try {
                                v = i.d(this.context, r, t, u, false);
                            }
                            catch (w) {
                                return;
                            }
                        }
                        else {
                            v = i.d(this.context, r, t, u, false);
                        }
                        if (v.result == null) {
                            continue;
                        }
                        if (f) {
                            if (!this.a7.containsKey(s)) {
                                var x = null;
                                if (this.isProceedOnErrorEnabled) {
                                    try {
                                        x = i.d(this.context, r, t, u, true);
                                    }
                                    catch (y) {
                                        return;
                                    }
                                }
                                else {
                                    x = i.d(this.context, r, t, u, true);
                                }
                                this.dy(x.result, s, d, true, false);
                                var z = c(q);
                                var aa = this.a7.item(s);
                                this.c6(this.av.item(s), z, aa, s);
                            }
                        }
                        this.dy(v.result, s, d, e, false);
                    }
                }
            }
            if (k.g("refs") && j != null) {
                var ab = k.item("refs");
                var ac = this.ah(ab);
                if (!ac && typeCast(JsonDictionaryObject.$, ab) !== null) {
                    var ad = ab;
                    var ae = ad.e();
                    for (var af = 0; af < ae.length; af++) {
                        var ag = ae[af];
                        var ah = ad.item(ag);
                        if (typeCast(JsonDictionaryValue.$, ah) !== null) {
                            var ai = ah;
                            this.provideRefValue(j, ag, ai.value);
                        }
                        else if (typeCast(JsonDictionaryArray.$, ah) !== null) {
                            var aj = ah;
                            var ak = this.a(aj);
                            this.provideRefValue(j, ag, ak);
                        }
                        else {
                            var al = this.by(ah);
                            this.provideRefValue(j, ag, al);
                        }
                    }
                }
            }
            if (k.g("modules") && j != null) {
                var am = k.item("modules");
                this.ae(am);
            }
            if (k.g("strings") && j != null) {
                var an = k.item("strings");
                this.al(an);
            }
            if (k.g("onInit") && j != null) {
                var ao = k.item("onInit");
                this.af(ao);
            }
            if (k.g("onViewInit") && j != null) {
                var ap = k.item("onViewInit");
                this.ag(ap);
            }
        }
    };
    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.by(f);
            this.provideRefValue(a, d, j);
        }
    };
    ComponentRenderer.prototype.bd = function () {
        return null;
    };
    ComponentRenderer.prototype.ah = function (a) {
        return false;
    };
    ComponentRenderer.prototype.ae = function (a) {
        return false;
    };
    ComponentRenderer.prototype.al = function (a) {
        return false;
    };
    ComponentRenderer.prototype.af = function (a) {
        return false;
    };
    ComponentRenderer.prototype.ag = function (a) {
        return false;
    };
    ComponentRenderer.prototype.co = function (a, b, c) {
        var d = a;
        if (c != null) {
            d = c.j(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.c6 = function (a, b, c, d) {
        var e_3, _a;
        if (!c.b(b)) {
            c.k(d, this.av.item(d).g, b, this.av.item(d), runOn(this, this.dj), -1);
        }
        try {
            for (var _b = __values(fromEnum(a.f())), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                this.c7(this.co(e.c, ComponentRenderer.platform, e.a), e.b, b, c, d, a.g);
            }
        }
        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.c7 = 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.adapter.getPropertyValue(c, a);
            if (!d.b(h) && !d.a(g.g)) {
                d.k(e, g.g, h, g, runOn(this, this.dj), f);
            }
            try {
                for (var _b = __values(fromEnum(g.f())), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var i = _c.value;
                    this.c7(a + "." + this.co(i.c, ComponentRenderer.platform, i.a), i.b, c, d, e, g.g);
                }
            }
            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.adapter.getPropertyValue(c, a);
            k_1 = 0;
            this.adapter.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.g)) {
                        d.k(e, s.g, r, s, runOn(_this, _this.dj), f);
                    }
                    try {
                        for (var _b = __values(fromEnum(s.f())), _c = _b.next(); !_c.done; _c = _b.next()) {
                            var t = _c.value;
                            _this.c7(a + "." + t.c, t.b, c, d, e, s.g);
                        }
                    }
                    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.ct(a);
                this.adapter.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.g)) {
                            d.k(e, t.g, s, t, runOn(_this, _this.dj), f);
                        }
                        try {
                            for (var _b = __values(fromEnum(t.f())), _c = _b.next(); !_c.done; _c = _b.next()) {
                                var u = _c.value;
                                _this.c7(r_1 + "." + u.c, u.b, c, d, e, t.g);
                            }
                        }
                        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.ct = 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.cq(d);
        if (c != null) {
            return c + "." + d;
        }
        return d;
    };
    ComponentRenderer.prototype.cq = 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.by(a.items[c]);
            b[c] = d;
        }
        return b;
    };
    ComponentRenderer.prototype.by = 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.by(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, "a7", {
        get: function () {
            return this.a3;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.cleanup = function (a, b) {
        this.dy(null, a, false, false, b);
    };
    ComponentRenderer.prototype.render = function (a, b) {
        this.dy(a, b, false, false, false);
    };
    ComponentRenderer.prototype.dy = function (a, b, c, d, e) {
        var _this = this;
        if (!this.a3.containsKey(b)) {
            this.a3.item(b, new ContainerState());
            this.a3.item(b).i = b;
        }
        this.ay.item(b, a);
        this.az.item(b, c);
        this.a0.item(b, d);
        this.ax.item(b, e);
        this.df(b, function () { return _this.dw(b); });
    };
    ComponentRenderer.prototype.df = function (a, b) {
        this.adapter.onUIThread(a, b);
    };
    ComponentRenderer.prototype.dw = function (a) {
        var e_7, _a, e_8, _b, e_9, _c, e_10, _d;
        var _this = this;
        if (this.ay.containsKey(a)) {
            var b = this.az.containsKey(a) ? this.az.item(a) : false;
            var c = this.a0.containsKey(a) ? this.a0.item(a) : false;
            var d = this.ay.item(a);
            this.ay.removeItem(a);
            var e = DescriptionTreeBuilder.createTreeWithOptions(this.context, d, this.preserveKeyOrder);
            var f = null;
            if (this.av.containsKey(a)) {
                f = this.av.item(a);
            }
            var g = DescriptionTreeReconciler.c(f, e, b);
            if (!c && b) {
                e = f.b();
                DescriptionTreeReconciler.a(f, g);
                var h = f;
                f = e;
                e = h;
                g = DescriptionTreeReconciler.c(f, e, false);
            }
            if (c) {
                var i = DescriptionTreeReconciler.a(f, g);
                if (!this.a3.containsKey(a)) {
                    this.a3.addItem(a, ((function () {
                        var $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                var j_2 = this.a3.item(a);
                if (i.a.count > 0) {
                    try {
                        for (var _e = __values(fromEnum(i.a)), _f = _e.next(); !_f.done; _f = _e.next()) {
                            var k = _f.value;
                            if (j_2.a(k)) {
                                var l = j_2.j(k);
                                this.c4(a, l, j_2);
                            }
                        }
                    }
                    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 (i.c.count > 0) {
                    try {
                        for (var _g = __values(fromEnum(i.c)), _h = _g.next(); !_h.done; _h = _g.next()) {
                            var m = _h.value;
                            var n = this.b5(a, j_2, m);
                            var o = this.adapter.getPropertyValue(n, m.j);
                            if (o != null) {
                                if (!j_2.b(o)) {
                                    var p = m.g;
                                    if (typeCast(DescriptionTreeNode.$, p) !== null) {
                                        var q = p.g;
                                        j_2.k(a, q, o, p, runOn(this, this.dj), m.c.g);
                                    }
                                }
                            }
                        }
                    }
                    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 (i.d.count > 0) {
                    try {
                        for (var _j = __values(fromEnum(i.d)), _k = _j.next(); !_k.done; _k = _j.next()) {
                            var r = _k.value;
                            var s = r.g;
                            if (s != null) {
                                if (!j_2.b(s)) {
                                    var t = r.g;
                                    if (typeCast(DescriptionTreeNode.$, t) !== null) {
                                        var u = t.g;
                                        this.av.item(a, t);
                                    }
                                }
                            }
                        }
                    }
                    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 (i.b.count > 0) {
                    var _loop_1 = function (v) {
                        var w = v.c.a(v.j).b;
                        if (w == null) {
                            return "continue";
                        }
                        var x = new Dictionary$2(String_$type, DescriptionTreeNode.$, 0);
                        for (var y = 0; y < w.length; y++) {
                            var z = w[y];
                            if (typeCast(DescriptionTreeNode.$, z) !== null) {
                                var aa = z;
                                if (aa.c("Name")) {
                                    x.item(aa.a("Name").b, aa);
                                }
                            }
                        }
                        if (x.count == 0) {
                            return "continue";
                        }
                        var ab = this_1.b5(a, j_2, v);
                        var ac = this_1.adapter.getPropertyValue(ab, v.j);
                        if (ac != null) {
                            var ad_1 = 0;
                            this_1.adapter.forPropertyValueItem(ab, v.j, function (ae) {
                                if (x.containsKey(_this.adapter.getPropertyValue(ae, "Name").toString())) {
                                    if (!j_2.b(ae)) {
                                        var af = x.item(_this.adapter.getPropertyValue(ae, "Name").toString());
                                        if (typeCast(DescriptionTreeNode.$, af) !== null) {
                                            var ag = af.g;
                                            j_2.k(a, ag, ae, af, runOn(_this, _this.dj), v.c.g);
                                        }
                                    }
                                }
                                ad_1++;
                            });
                        }
                    };
                    var this_1 = this;
                    try {
                        for (var _l = __values(fromEnum(i.b)), _m = _l.next(); !_m.done; _m = _l.next()) {
                            var v = _m.value;
                            _loop_1(v);
                        }
                    }
                    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.av.item(a, e);
            }
            if (!c) {
                this.dx(a, g);
            }
            if (this.ax.item(a)) {
                this.du(a);
                if (this.a3.containsKey(a)) {
                    this.a3.removeItem(a);
                }
            }
        }
    };
    ComponentRenderer.prototype.executeMethod = function (a, b, c) {
        var _this = this;
        var d = new JsonDictionaryParser();
        var e = d.parse(b);
        if (!this.a3.containsKey(a)) {
            this.a3.item(a, new ContainerState());
            this.a3.item(a).i = a;
        }
        var f = this.a3.item(a);
        var g = new DescriptionSerializer();
        g.h = this.isProceedOnErrorEnabled;
        g.g = this.ar();
        var h = this.av.item(a);
        var i = null;
        var j = new List$1(Base.$, 0);
        var k = new List$1(TypeDescriptionMetadata.$, 0);
        if (typeCast(JsonDictionaryObject.$, e) !== null) {
            var l = null;
            var m = e;
            if (m.g("targetRef")) {
                l = this.cm(m, "targetRef");
            }
            var n = null;
            if (m.g("methodName")) {
                n = this.cm(m, "methodName");
            }
            if (l != null) {
                if (this.a4.containsKey(l)) {
                    i = this.a4.item(l);
                }
            }
            else {
                i = f.j(h.g);
            }
            if (m.g("args")) {
                var o = m.item("args");
                for (var p = 0; p < o.items.length; p++) {
                    var q = o.items[p];
                    var r = this.g(h, q, g);
                    var s = null;
                    if (typeCast(DescriptionTreeNode.$, r.g) !== null && r.g.i == "EmbeddedRef") {
                        s = this.b6(a, r.g);
                    }
                    else {
                        s = this.b2(r, a, f);
                    }
                    if (r.d.knownType == 8 && r.d.specificType == "string") {
                        s = this.bn(r.d.specificExternalType, s, r.d);
                    }
                    j.add1(s);
                    k.add(r.d);
                }
            }
            var t_1 = null;
            if (m.g("return")) {
                var u = m.item("return");
                var v = this.g(h, u, g);
                t_1 = v.d;
            }
            this.adapter.executeMethod(i, n, j.toArray(), k.toArray(), function (w) {
                var x = _this.cr(w, t_1);
                c(x);
            });
        }
    };
    ComponentRenderer.prototype.b6 = function (a, b) {
        if (b.i == "EmbeddedRef") {
            var c = "uuid";
            var d = null;
            for (var e = 0; e < b.f().count; e++) {
                if (b.f()._inner[e].c == "RefType") {
                    c = b.f()._inner[e].b;
                }
                if (b.f()._inner[e].c == "Value") {
                    d = b.f()._inner[e].b;
                }
            }
            if (d != null) {
                for (var f = 0; f < this.a8.count; f++) {
                    var g = this.a8._inner[f](a, c, d);
                    if (g != null) {
                        return g;
                    }
                }
                if (c == "name") {
                    var h = d;
                    if (this.a4.containsKey(h)) {
                        return this.a4.item(h);
                    }
                    if (this.a6.containsKey(h)) {
                        return this.a6.item(h);
                    }
                }
                return null;
            }
        }
        return null;
    };
    ComponentRenderer.bc = function (a) {
        if (typeCast(Date_$type, a) !== null) {
            return a.getTime();
        }
        if (a == null) {
            return 0;
        }
        return a;
    };
    ComponentRenderer.prototype.cr = function (a, b) {
        var _this = this;
        var c = new JsonDictionaryObject();
        c.item("knownType", ((function () {
            var $ret = new JsonDictionaryValue();
            $ret.e = 2;
            $ret.value = EnumUtil.getName(TypeDescriptionWellKnownType_$type, b.knownType);
            return $ret;
        })()));
        if (b.specificType != null) {
            c.item("specificType", ((function () {
                var $ret = new JsonDictionaryValue();
                $ret.e = 2;
                $ret.value = b.specificType;
                return $ret;
            })()));
        }
        if (b.specificExternalType != null) {
            c.item("specificExternalType", ((function () {
                var $ret = new JsonDictionaryValue();
                $ret.e = 2;
                $ret.value = b.specificExternalType;
                return $ret;
            })()));
        }
        if (b.collectionElementType != null) {
            c.item("collectionElementType", ((function () {
                var $ret = new JsonDictionaryValue();
                $ret.e = 2;
                $ret.value = b.collectionElementType;
                return $ret;
            })()));
        }
        switch (b.knownType) {
            case 0: break;
            case 1:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 0;
                    $ret.value = ComponentRenderer.bc(a);
                    return $ret;
                })()));
                break;
            case 2:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = a != null ? a.toString() : null;
                    return $ret;
                })()));
                break;
            case 3:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = a != null ? a.toString() : null;
                    return $ret;
                })()));
                break;
            case 4:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.b7(a);
                    return $ret;
                })()));
                break;
            case 5:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.b9(a);
                    return $ret;
                })()));
                break;
            case 6:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.b8(a);
                    return $ret;
                })()));
                break;
            case 7:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 1;
                    $ret.value = a;
                    return $ret;
                })()));
                break;
            case 8: break;
            case 9: break;
            case 10: break;
            case 11:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cc(a);
                    return $ret;
                })()));
                break;
            case 12:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.ce(a);
                    return $ret;
                })()));
                break;
            case 13: break;
            case 14:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cd(a);
                    return $ret;
                })()));
                break;
            case 15: break;
            case 16:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.ca(a);
                    return $ret;
                })()));
                break;
            case 17: break;
            case 18: break;
            case 19: break;
            case 20: break;
            case 21:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cf(a);
                    return $ret;
                })()));
                break;
            case 22: break;
            case 23:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cb(a);
                    return $ret;
                })()));
                break;
        }
        return c.b();
    };
    ComponentRenderer.prototype.cb = function (a) {
        return this.adapter.serializeDoubleCollection(a);
    };
    ComponentRenderer.prototype.cf = function (a) {
        return this.adapter.serializeTimespan(a);
    };
    ComponentRenderer.prototype.ca = function (a) {
        return this.adapter.serializeColorCollection(a);
    };
    ComponentRenderer.prototype.cd = function (a) {
        return this.adapter.serializeRect(a);
    };
    ComponentRenderer.prototype.ce = function (a) {
        return this.adapter.serializeSize(a);
    };
    ComponentRenderer.prototype.cc = function (a) {
        return this.adapter.serializePoint(a);
    };
    ComponentRenderer.prototype.b8 = function (a) {
        return this.adapter.serializeBrushCollection(a);
    };
    ComponentRenderer.prototype.b9 = function (a) {
        return this.adapter.serializeColor(a);
    };
    ComponentRenderer.prototype.b7 = function (a) {
        return this.adapter.serializeBrush(a);
    };
    ComponentRenderer.prototype.g = function (a, b, c) {
        var d = new DescriptionTreeAction();
        d.a = 0;
        d.c = a;
        d.j = "*argument";
        var e = new TypeDescriptionMetadata();
        e.propertyName = "*argument";
        var f;
        var g = this.cm(b, "knownType");
        var h = EnumUtil.tryParse$1(TypeDescriptionWellKnownType_$type, g, true, f);
        f = h.p2;
        e.knownType = f;
        e.specificExternalType = this.cm(b, "specificExternalType");
        e.specificType = this.cm(b, "specificType");
        e.collectionElementType = this.cm(b, "collectionElementType");
        d.d = e;
        var i = null;
        i = this.b1(e, b, c);
        d.g = i;
        return d;
    };
    ComponentRenderer.prototype.cm = function (a, b) {
        if (typeCast(JsonDictionaryObject.$, a) !== null) {
            var c = a;
            if (c.g(b)) {
                return c.item(b).value != null ? c.item(b).value.toString() : null;
            }
        }
        return null;
    };
    ComponentRenderer.prototype.b1 = function (a, b, c) {
        if (typeCast(JsonDictionaryObject.$, b) !== null) {
            var d = b;
            if (d.g("value")) {
                var e = (d.item("value")) != null ? (d.item("value")) : null;
                return this.bx(a.knownType, a.specificType, a.specificExternalType, a.collectionElementType, e, c);
            }
        }
        return null;
    };
    ComponentRenderer.prototype.bx = function (a, b, c, d, e, f) {
        if (typeCast(JsonDictionaryObject.$, e) !== null) {
            var g = e;
            if (g.g("type") || g.g("refType")) {
                var h = f.c(this.context, g.b());
                if (h != null) {
                    var i = h.result;
                    if (i == null) {
                        return null;
                    }
                    return DescriptionTreeBuilder.createTreeWithOptions(this.context, i, this.preserveKeyOrder);
                }
                return null;
            }
            else if (a == 11) {
                var j = DescriptionSerializer.k(this.context, g);
                return DescriptionTreeBuilder.createTreeWithOptions(this.context, j, this.preserveKeyOrder);
            }
            else if (a == 14) {
                var k = DescriptionSerializer.k(this.context, g);
                return DescriptionTreeBuilder.createTreeWithOptions(this.context, k, this.preserveKeyOrder);
            }
            else if (a == 12) {
                var l = DescriptionSerializer.k(this.context, g);
                return DescriptionTreeBuilder.createTreeWithOptions(this.context, l, this.preserveKeyOrder);
            }
        }
        else if (typeCast(JsonDictionaryArray.$, e) !== null) {
            var m = e;
            var n = "string";
            var o = false;
            if (a == 10) {
                n = c;
            }
            if (a == 9) {
                o = true;
                n = d;
            }
            var p = new Array(m.items.length);
            var q = void 0;
            var r = void 0;
            var s = void 0;
            var t = void 0;
            var u = this.c9(o, n, b, c, q, r, s, t);
            q = u.p4;
            r = u.p5;
            s = u.p6;
            t = u.p7;
            if (m.items != null) {
                for (var v = 0; v < m.items.length; v++) {
                    var w = m.items[v];
                    var x = this.bx(q, r, s, t, w, f);
                }
            }
        }
        else if (typeCast(JsonDictionaryValue.$, e) !== null) {
            return e.value;
        }
        return e;
    };
    ComponentRenderer.prototype.c9 = function (a, b, c, d, e, f, g, h) {
        if (a) {
            e = 8;
            f = b;
            g = null;
            h = null;
            return {
                p4: e,
                p5: f,
                p6: g,
                p7: h
            };
        }
        var i = c;
        if (d != null) {
            i = d;
        }
        h = null;
        switch (d) {
            case "string":
                if (c != null && c != "string") {
                    e = 8;
                    f = "string";
                    g = d;
                }
                else {
                    e = 2;
                    f = null;
                    g = null;
                }
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
            case "double":
                e = 1;
                f = "double";
                g = "double";
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
            case "int":
                e = 1;
                f = "double";
                g = "double";
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
            case "long":
                e = 1;
                f = "double";
                g = "double";
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
            case "bool":
                e = 1;
                f = "double";
                g = "double";
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
        }
        e = 8;
        f = c;
        g = d;
        return {
            p4: e,
            p5: f,
            p6: g,
            p7: h
        };
    };
    ComponentRenderer.prototype.provideRefValue = function (a, b, c) {
        var _this = this;
        this.df(a, function () {
            if (!_this.a3.containsKey(a)) {
                _this.a3.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var d = _this.a3.item(a);
            _this.dj(a, b, c, true);
        });
    };
    ComponentRenderer.prototype.removeRefValue = function (a, b) {
        var _this = this;
        this.df(a, function () {
            if (!_this.a3.containsKey(a)) {
                _this.a3.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var c = _this.a3.item(a);
            _this.removeRefValueCore(a, b, true);
        });
    };
    ComponentRenderer.prototype.du = function (a) {
        var e_11, _a;
        var b = this.a3.item(a);
        var c = new List$1(String_$type, 0);
        try {
            for (var _b = __values(fromEnum(this.a2.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                if (this.a2.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.a6.containsKey(c._inner[e]));
            this.shouldNamespaceSystemRefValues = f;
        }
    };
    ComponentRenderer.prototype.clearRefValues = function (a) {
        var _this = this;
        this.df(a, function () {
            if (!_this.a3.containsKey(a)) {
                _this.a3.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var b = _this.a3.item(a);
            _this.clearUserRefValues();
        });
    };
    ComponentRenderer.prototype.w = function (a) {
        if (this.au.containsKey(a) && this.au.item(a)) {
            return false;
        }
        if (this.a1.containsKey(a) && this.a1.item(a).count > 0) {
            return false;
        }
        return true;
    };
    ComponentRenderer.prototype.queueForIdle = function (a, b) {
        var _this = this;
        this.df(a, function () {
            if (_this.w(a)) {
                b();
            }
            else {
                if (!_this.aw.containsKey(a)) {
                    _this.aw.item(a, new List$1(Delegate_$type, 0));
                }
                _this.aw.item(a).add(b);
            }
        });
    };
    ComponentRenderer.prototype.tryFlushIdleActions = function (a) {
        if (this.w(a)) {
            if (this.aw.containsKey(a)) {
                var b = new List$1(Delegate_$type, 1, this.aw.item(a));
                this.aw.item(a).clear();
                for (var c = 0; c < b.count; c++) {
                    b._inner[c]();
                }
            }
        }
    };
    ComponentRenderer.prototype.dx = function (a, b) {
        var c = this.a3.item(a);
        this.dg(a, c, b);
    };
    ComponentRenderer.prototype.d0 = function (a, b) {
        if (this.isProceedOnErrorEnabled) {
            try {
                this.c5(a, b, true);
            }
            catch (c) {
                this.au.item(a, false);
            }
        }
        else {
            this.c5(a, b, true);
        }
    };
    ComponentRenderer.prototype.d6 = function (a, b) {
        if (this.isProceedOnErrorEnabled) {
            try {
                this.c5(a, b, false);
            }
            catch (c) {
                this.au.item(a, false);
            }
        }
        else {
            this.c5(a, b, false);
        }
    };
    ComponentRenderer.prototype.c5 = function (a, b, c) {
        if (!c) {
            if (this.au.containsKey(a) && this.au.item(a)) {
                return;
            }
        }
        this.au.item(a, true);
        var d = true;
        while (d && this.a1.item(a).count > 0) {
            while (this.a1.item(a).count > 0 && this.a1.item(a).c().count < 1) {
                this.a1.item(a).b();
            }
            if (this.a1.item(a).count < 1) {
                break;
            }
            var e = this.a1.item(a).c();
            while (e.count > 0) {
                var f = e.b();
                d = this.ab(a, b, f);
                if (!d) {
                    break;
                }
            }
        }
        if (d) {
            this.au.item(a, false);
        }
        if (this.w(a)) {
            this.tryFlushIdleActions(a);
        }
    };
    ComponentRenderer.prototype.dg = 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.a1.containsKey(a)) {
            this.a1.addItem(a, new Queue$1(Queue$1.$.specialize(DescriptionTreeAction.$)));
        }
        this.a1.item(a).g(d);
        this.d6(a, b);
    };
    ComponentRenderer.prototype.dh = function (a, b, c) {
        for (var d = 0; d < c.count; d++) {
            this.ab(a, b, c._inner[d]);
        }
    };
    ComponentRenderer.prototype.ab = function (a, b, c) {
        switch (c.a) {
            case 5: return this.ac(a, b, c);
            case 2: return this.ad(a, b, c);
            case 4: return this.ai(a, b, c);
            case 3: return this.aj(a, b, c);
            case 1: return this.ak(a, b, c);
            case 0: return this.am(a, b, c);
        }
        return true;
    };
    ComponentRenderer.prototype.am = function (a, b, c) {
        var d = this.b5(a, b, c);
        this.at(a, b, c, d);
        return true;
    };
    ComponentRenderer.prototype.at = function (a, b, c, d) {
        var e = this.b2(c, a, b);
        e = this.j.transform(ComponentRenderer.platform, e, c);
        var f = false;
        if (this.ba != null && this.ba.count > 0) {
            for (var g = 0; g < this.ba.count; g++) {
                var h = this.ba._inner[g];
                var i = this.cp(a, c);
                if (h(i, d, e)) {
                    f = true;
                }
            }
        }
        if (c.j == "Type" || c.j == "type") {
            f = true;
        }
        if (f) {
            return true;
        }
        if (c.d != null && c.d.knownType == 9) {
            this.aq(a, b, c.i(ComponentRenderer.platform), c.d, e, d);
        }
        else {
            this.d4(a, b, c.i(ComponentRenderer.platform), c.d, e, c.h, d);
        }
        return true;
    };
    ComponentRenderer.prototype.cp = function (a, b) {
        var c = b.c;
        var d = "";
        if (c != this.av.item(a)) {
            var e = this.cn(a, c);
            d = e;
        }
        if (d.length > 0) {
            d += ".";
        }
        d += b.j;
        return d;
    };
    ComponentRenderer.prototype.cn = function (a, b) {
        if (b == null) {
            return "";
        }
        var c = this.cu("", this.av.item(a), b);
        if (c.c) {
            return c.d;
        }
        return "";
    };
    ComponentRenderer.prototype.cu = 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.f();
        for (var e = 0; e < d.count; e++) {
            var f = d._inner[e];
            if (typeCast(DescriptionTreeNode.$, f.b) !== null) {
                if (f.b.g == c.g) {
                    a += f.c;
                    return new Tuple$2(Boolean_$type, String_$type, true, a);
                }
                else {
                    var g = a + f.c;
                    var h = this.cu(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.g == c.g) {
                            a += f.c + "[" + j + "]";
                            return new Tuple$2(Boolean_$type, String_$type, true, a);
                        }
                        else {
                            var l = a + f.c + "[" + j + "]";
                            var m = this.cu(l, k, c);
                            if (m.c) {
                                return m;
                            }
                        }
                    }
                }
            }
        }
        return new Tuple$2(Boolean_$type, String_$type, false, a);
    };
    ComponentRenderer.prototype.aq = function (a, b, c, d, e, f) {
        var e_12, _a;
        if (this.a5.containsKey(c)) {
            try {
                for (var _b = __values(fromEnum(this.a5.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.adapter.setOrUpdateCollectionOnTarget(a, c, d, this.context, f, e);
        return true;
    };
    ComponentRenderer.prototype.b2 = function (a, b, c) {
        if (a.d == null) {
            return a.g;
        }
        switch (a.d.knownType) {
            case 10: return this.bf(a, b, c);
            case 7: return this.bg(a);
            case 4: return this.bh(a);
            case 6: return this.bi(a);
            case 23: return this.bm(a);
            case 9: return this.bf(a, b, c);
            case 5: return this.bj(a);
            case 16: return this.bk(a);
            case 20: return this.cg(a, c);
            case 22: return this.cj(a, c);
            case 15: return null;
            case 3: return this.bl(a);
            case 19: return this.ch(a, c);
            case 8: return this.bo(a, b, c);
            case 13: return null;
            case 18: return this.ci(a, c);
            case 1: return this.bp(a);
            case 11: return this.bq(a);
            case 14: return this.br(a);
            case 12: return this.bs(a);
            case 2: return this.bt(a);
            case 21: return this.bu(a);
            case 17: return this.bv(a, b, c);
            case 0: return null;
        }
        return null;
    };
    ComponentRenderer.prototype.bv = function (a, b, c) {
        var d = this.bw(a.g, a, b, c);
        return d;
    };
    ComponentRenderer.prototype.bw = function (a, b, c, d) {
        if (typeof a === 'string') {
            if (stringStartsWith(a, "@d:")) {
                var v_ = a.substr(3);
                a = new Date(v_);
            }
        }
        if (typeCast(Array_$type, a) !== null) {
            var e = a;
            var f = new Array(e.length);
            for (var g = 0; g < e.length; g++) {
                var h = this.bw(e[g], b, c, d);
                f[g] = h;
            }
            a = f;
        }
        if (typeCast(DescriptionTreeNode.$, a) !== null) {
            var i = a;
            if (i.i == "EmbeddedRef") {
                return this.bz(i.i, a, c, d, false, b.c.g, b.d);
            }
        }
        return a;
    };
    ComponentRenderer.prototype.bu = function (a) {
        return a.g;
    };
    ComponentRenderer.prototype.bt = function (a) {
        return a.g != null ? a.g.toString() : null;
    };
    ComponentRenderer.prototype.bs = function (a) {
        var b = a.g;
        var width_ = b.width;
        var height_ = b.height;
        var c = { width: width_, height: height_ };
        return c;
    };
    ComponentRenderer.prototype.br = function (a) {
        var b = a.g;
        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.bq = function (a) {
        var b = a.g;
        var x_ = b.x;
        var y_ = b.y;
        var c = { x: x_, y: y_ };
        return c;
    };
    ComponentRenderer.prototype.bp = function (a) {
        if (a.g == null) {
            if (a.d != null && ((a.d.specificType == "double" || a.d.specificType == "float") || (a.d.specificExternalType == "double" || a.d.specificExternalType == "float"))) {
                return NaN;
            }
            return 0;
        }
        var b = a.g;
        if (typeof b === 'number') {
            b = typeGetValue(b);
        }
        if (a.d != null && a.d.specificExternalType != null) {
            switch (a.d.specificExternalType) {
                case "int":
                    b = truncate(b);
                    break;
                case "float":
                    b = b;
                    break;
                case "short":
                    b = truncate(b);
                    break;
                case "long":
                    b = truncate(b);
                    break;
            }
        }
        return b;
    };
    ComponentRenderer.prototype.e = function (a, b) {
        if (this.a2.containsKey(a)) {
            var c = this.a2.item(a);
            return c;
        }
        var d = new DescriptionRef(a);
        this.a2.addItem(a, d);
        return d;
    };
    ComponentRenderer.prototype.ci = function (a, b) {
        return a.g == null ? null : this.e(a.g, b);
    };
    ComponentRenderer.prototype.bo = function (a, b, c) {
        var d = a.d.specificType;
        if (d == null) {
            d = a.d.specificExternalType;
        }
        if (typeCast(DescriptionTreeNode.$, a.g) !== null) {
            var e = a.g;
            if (e.c("Type")) {
                d = e.a("Type").b;
            }
        }
        var f = this.bz(d, a.g, b, c, false, a.c.g, a.d);
        return f;
    };
    ComponentRenderer.prototype.ch = function (a, b) {
        return a.g == null ? null : this.e(a.g, b);
    };
    ComponentRenderer.prototype.bl = function (a) {
        if (typeof a.g === 'string') {
            var v_ = a.g;
            a.g = new Date(v_);
        }
        return a.g;
    };
    ComponentRenderer.prototype.cg = function (a, b) {
        return a.g == null ? null : this.e(a.g, b);
    };
    ComponentRenderer.prototype.cj = function (a, b) {
        return a.g == null ? null : this.e(a.g, b);
    };
    ComponentRenderer.prototype.cl = function (a) {
        return a;
    };
    ComponentRenderer.prototype.bk = function (a) {
        var b = a.g;
        if (b == null) {
            return null;
        }
        var c = new Array(b.length);
        for (var d = 0; d < b.length; d++) {
            c[d] = this.cl(b[d]);
        }
        return c;
    };
    ComponentRenderer.prototype.bj = function (a) {
        return this.cl(a.g);
    };
    ComponentRenderer.prototype.bi = function (a) {
        var b = a.g;
        if (b == null) {
            return null;
        }
        var c = new Array(b.length);
        for (var d = 0; d < b.length; d++) {
            c[d] = this.ck(b[d]);
        }
        return c;
    };
    ComponentRenderer.prototype.bm = function (a) {
        var b = a.g;
        if (b == null) {
            return null;
        }
        var c = new Array(b.length);
        for (var d = 0; d < b.length; d++) {
            c[d] = b[d];
        }
        return c;
    };
    ComponentRenderer.prototype.ck = function (a) {
        return a;
    };
    ComponentRenderer.prototype.bh = function (a) {
        return this.ck(a.g);
    };
    ComponentRenderer.prototype.bg = function (a) {
        return a.g;
    };
    ComponentRenderer.prototype.addTargetPropertyUpdatingListener = function (a) {
        this.ba.add(a);
    };
    ComponentRenderer.prototype.removeTargetPropertyUpdatingListener = function (a) {
        this.ba.remove(a);
    };
    ComponentRenderer.prototype.addPropertyUpdatingListener = function (a, b) {
        if (!this.a5.containsKey(a)) {
            this.a5.addItem(a, new List$1(Delegate_$type, 0));
        }
        this.a5.item(a).add(b);
    };
    ComponentRenderer.prototype.addReferenceLookupListener = function (a) {
        this.a8.add(a);
    };
    ComponentRenderer.prototype.removeReferenceLookupListener = function (a) {
        this.a8.remove(a);
    };
    ComponentRenderer.prototype.removePropertyUpdatingListener = function (a, b) {
        if (this.a5.containsKey(a)) {
            this.a5.item(a).remove(b);
            if (this.a5.item(a).count == 0) {
                this.a5.removeItem(a);
            }
        }
    };
    ComponentRenderer.prototype.addNamespaceLookupListener = function (a) {
        this.a9.add(a);
    };
    ComponentRenderer.prototype.removeNamespaceLookupListener = function (a) {
        this.a9.remove(a);
    };
    ComponentRenderer.prototype.bf = function (a, b, c) {
        if (a.g == null) {
            return null;
        }
        var d = a.g;
        var e = new List$1(Base.$, 0);
        var f = a.d.specificType;
        if (f == null) {
            f = a.d.specificExternalType;
        }
        if (a.d.knownType == 9) {
            f = a.d.collectionElementType;
            if (f == null) {
                f = a.d.specificExternalType;
            }
        }
        for (var g = 0; g < d.length; g++) {
            var h = f;
            if (typeCast(DescriptionTreeNode.$, d[g]) !== null) {
                var i = d[g];
                if (i.c("Type")) {
                    h = i.a("Type").b;
                }
            }
            var j = this.bz(h, d[g], b, c, false, a.c.g, a.d);
            e.add1(j);
        }
        return e.toArray();
    };
    ComponentRenderer.prototype.d4 = 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.s(f)) {
                    var j = this.f(f);
                    if (Base.equalsStatic(j, e)) {
                        i = true;
                    }
                    else {
                        j.j(a, g, c);
                    }
                }
            }
            if (this.t(e)) {
                var k = e;
                if (k.e != null && k.e.length > 0 && this.a4.containsKey(k.e)) {
                    k.a = true;
                }
                e = this.b4(e);
                this.d5(g, c, d, e, f, k);
            }
            else {
                this.adapter.onPendingRef(g, c, d, e);
            }
            var l = null;
            l = function (m, n) {
                var o = m;
                if (o.e != null && o.e.length > 0 && _this.a4.containsKey(o.e)) {
                    o.a = true;
                }
                var p = _this.b4(m);
                _this.d5(g, c, d, p, f, o);
            };
            if (!i) {
                h.g(a, g, c, l);
            }
            return;
        }
        this.d5(g, c, d, e, f, null);
    };
    ComponentRenderer.prototype.hasUserRef = function (a) {
        return this.a6.containsKey(a);
    };
    Object.defineProperty(ComponentRenderer.prototype, "shouldNamespaceSystemRefValues", {
        get: function () {
            return this._shouldNamespaceSystemRefValues;
        },
        set: function (a) {
            this._shouldNamespaceSystemRefValues = a;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.dj = function (a, b, c, d) {
        var e = null;
        if (d) {
            if (this.a6.containsKey(b)) {
                e = this.a6.item(b);
            }
            this.a6.item(b, c);
        }
        else {
            if (this.shouldNamespaceSystemRefValues) {
                var f = "";
                if (this.a9 != null && this.a9.count > 0) {
                    for (var g = 0; g < this.a9.count; g++) {
                        f = this.a9._inner[g](a);
                    }
                }
                if (!stringIsNullOrEmpty(f)) {
                    b = f + "/" + b;
                }
            }
            if (this.a4.containsKey(b)) {
                e = this.a4.item(b);
            }
            this.a4.item(b, c);
            if (this.a2.containsKey(b)) {
                this.a2.item(b).a = true;
            }
        }
        if (this.a2.containsKey(b)) {
            this.a2.item(b).f(e, c);
        }
    };
    ComponentRenderer.prototype.removeRefValueCore = function (a, b, c) {
        var d = null;
        if (c) {
            if (this.a6.containsKey(b)) {
                d = this.a6.item(b);
            }
            this.a6.removeItem(b);
        }
        else {
            if (this.shouldNamespaceSystemRefValues) {
                var e = "";
                if (this.a9 != null && this.a9.count > 0) {
                    for (var f = 0; f < this.a9.count; f++) {
                        e = this.a9._inner[f](a);
                    }
                }
                if (!stringIsNullOrEmpty(e)) {
                    b = e + "/" + b;
                }
            }
            if (this.a4.containsKey(b)) {
                d = this.a4.item(b);
            }
            this.a4.removeItem(b);
        }
        if (this.a2.containsKey(b)) {
            this.a2.item(b).f(d, this.b4(this.a2.item(b)));
            if (this.a2.item(b).c <= 0) {
                this.a2.item(b).h();
                this.a2.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 = __values(fromEnum(this.a6.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 = __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.t = function (a) {
        return this.a6.containsKey(a.e) || this.a4.containsKey(a.e);
    };
    ComponentRenderer.prototype.b4 = function (a) {
        if (this.a6.containsKey(a.e)) {
            return this.a6.item(a.e);
        }
        if (this.a4.containsKey(a.e)) {
            return this.a4.item(a.e);
        }
        return null;
    };
    ComponentRenderer.prototype.s = function (a) {
        return this.a2.containsKey(a);
    };
    ComponentRenderer.prototype.f = function (a) {
        return this.a2.item(a);
    };
    ComponentRenderer.prototype.getMissingRefs = function () {
        var e_15, _a;
        var a = new List$1(String_$type, 0);
        try {
            for (var _b = __values(fromEnum(this.a2.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (!this.t(this.a2.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.getRefChangeInfos = function (a) {
        var e_16, _a;
        var b = new List$1(DescriptionRefTargetInfo.$, 0);
        if (this.a2.containsKey(a)) {
            var _loop_2 = function (c) {
                b.add(((function () {
                    var $ret = new DescriptionRefTargetInfo();
                    $ret.container = c.b;
                    $ret.propertyName = c.d;
                    $ret.target = c.c;
                    return $ret;
                })()));
            };
            try {
                for (var _b = __values(fromEnum(this.a2.item(a).b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var c = _c.value;
                    _loop_2(c);
                }
            }
            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;
                }
            }
        }
        return b.toArray();
    };
    ComponentRenderer.prototype.b5 = function (a, b, c) {
        return b.j(c.c.g);
    };
    ComponentRenderer.prototype.ak = function (a, b, c) {
        var d = this.b5(a, b, c);
        this.ap(a, b, c, d);
        return true;
    };
    ComponentRenderer.prototype.ap = function (a, b, c, d) {
        this.adapter.resetPropertyOnTarget(a, c.i(ComponentRenderer.platform), c.d, d);
        return true;
    };
    ComponentRenderer.prototype.aj = function (a, b, c) {
        if (c.c == null) {
            return this.ao(a, b, c);
        }
        else {
            var d = this.b5(a, b, c);
            this.dz(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.dz = function (a, b, c, d) {
        var e = c.i(ComponentRenderer.platform);
        var f = c.d.collectionElementType;
        if (f == null) {
            f = c.d.specificExternalType;
        }
        var g = this.bz(f, c.g, a, b, false, c.c.g, c.d);
        this.adapter.replaceItemInCollection(e, c.d, d, c.e, g);
        if (c.h != null && typeCast(DescriptionTreeNode.$, c.h) !== null) {
            var h = c.h.g;
            if (h >= 0) {
                var i = b.j(h);
                if (i != null) {
                    this.c4(a, i, b);
                }
            }
        }
    };
    ComponentRenderer.prototype.ao = function (a, b, c) {
        var _this = this;
        var d = this.adapter.getRootObject(a);
        if (d != null) {
            this.c4(a, d, b);
        }
        if (!(typeCast(DescriptionTreeNode.$, c.g) !== null)) {
            throw new NotImplementedException(0);
        }
        var e = c.g;
        var f = false;
        this.adapter.replaceRootItem(a, e.i, this.context, function (g) {
            var h = _this.adapter.getRootObject(a);
            b.k(a, e.g, h, e, runOn(_this, _this.dj), -1);
            var i = _this.bb(e);
            _this.dh(a, b, i);
            f = true;
            if (g) {
                _this.d0(a, b);
            }
        });
        return f;
    };
    ComponentRenderer.prototype.c4 = function (a, b, c) {
        var e_17, _a;
        var d = this.be(a, b, c);
        try {
            for (var _b = __values(fromEnum(this.a2.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                e.i(b);
            }
        }
        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;
            }
        }
        if (d != -1) {
            c.l(this, a, d, runOn(this, this.removeRefValueCore));
        }
        this.k.b(ComponentRenderer.platform, b);
    };
    ComponentRenderer.prototype.be = function (a, b, c) {
        return c.h(b);
    };
    ComponentRenderer.prototype.ai = function (a, b, c) {
        if (c.c == null) {
            return this.an(a, b, c);
        }
        else {
            var d = this.b5(a, b, c);
            this.dm(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.dm = function (a, b, c, d) {
        var e = c.i(ComponentRenderer.platform);
        this.adapter.removeItemFromCollection(e, c.d, d, c.f);
        if (c.h != null && typeCast(DescriptionTreeNode.$, c.h) !== null) {
            var f = c.h.g;
            if (f >= 0) {
                var g = b.j(f);
                if (g != null) {
                    this.c4(a, g, b);
                }
            }
        }
    };
    ComponentRenderer.prototype.an = function (a, b, c) {
        var _this = this;
        var d = this.adapter.getRootObject(a);
        if (d != null) {
            this.c4(a, d, b);
        }
        var e = false;
        this.adapter.removeRootItem(a, this.context, function (f) {
            e = true;
            if (f) {
                _this.d0(a, b);
            }
        });
        return e;
    };
    ComponentRenderer.prototype.ad = function (a, b, c) {
        if (c.c == null) {
            return this.n(a, b, c);
        }
        else {
            var d = this.b5(a, b, c);
            this.cv(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.n = function (a, b, c) {
        var _this = this;
        if (!(typeCast(DescriptionTreeNode.$, c.g) !== null)) {
            throw new NotImplementedException(0);
        }
        var d = c.g;
        var e = false;
        this.adapter.replaceRootItem(a, d.i, this.context, function (f) {
            var g = _this.adapter.getRootObject(a);
            b.k(a, d.g, g, d, runOn(_this, _this.dj), -1);
            var h = _this.bb(d);
            _this.dh(a, b, h);
            e = true;
            if (f) {
                _this.d0(a, b);
            }
        });
        return e;
    };
    ComponentRenderer.prototype.cv = function (a, b, c, d) {
        var e = c.i(ComponentRenderer.platform);
        var f = c.d.collectionElementType;
        if (typeCast(DescriptionTreeNode.$, c.g) !== null) {
            var g = c.g;
            if (g.c("Type")) {
                f = g.a("Type").b;
            }
        }
        if (f == null) {
            f = c.d.specificExternalType;
        }
        var h = this.bz(f, c.g, a, b, false, c.c.g, c.d);
        this.adapter.addItemToCollection(e, c.d, d, c.e, h);
    };
    ComponentRenderer.prototype.bz = function (a, b, c, d, e, f, g) {
        if (this.x(a)) {
            return b;
        }
        var h = null;
        if (b != null && typeCast(DescriptionTreeNode.$, b) !== null) {
            var i = b;
            var j = null;
            if (i.c("Name")) {
                j = i.a("Name").b;
                if (!stringIsNullOrEmpty(j)) {
                    if (this.shouldNamespaceSystemRefValues) {
                        var k = "";
                        if (this.a9 != null && this.a9.count > 0) {
                            for (var l = 0; l < this.a9.count; l++) {
                                k = this.a9._inner[l](c);
                            }
                        }
                        if (!stringIsNullOrEmpty(k)) {
                            j = k + "/" + j;
                        }
                    }
                    if (this.a4.containsKey(j)) {
                        var m = this.a4.item(j);
                        h = m;
                    }
                }
            }
            if (h == null) {
                h = this.context.x(a, c, j);
            }
        }
        else if (b != null) {
            h = this.context.x(a, c, null);
        }
        if (b == null) {
            return h;
        }
        if (typeCast(DescriptionTreeNode.$, b) !== null) {
            var n = b;
            if (n.i == "EmbeddedRef") {
                var o = "uuid";
                var p = null;
                for (var q = 0; q < n.f().count; q++) {
                    if (n.f()._inner[q].c == "RefType") {
                        o = n.f()._inner[q].b;
                    }
                    if (n.f()._inner[q].c == "Value") {
                        p = n.f()._inner[q].b;
                    }
                }
                if (p != null) {
                    for (var r = 0; r < this.a8.count; r++) {
                        var s = this.a8._inner[r](c, o, p);
                        if (s != null) {
                            return s;
                        }
                    }
                    if (o == "name") {
                        var t = p;
                        if (this.a4.containsKey(t)) {
                            return this.a4.item(t);
                        }
                    }
                    return null;
                }
            }
            else {
                d.k(c, n.g, h, n, runOn(this, this.dj), f);
                var u = this.bb(n);
                this.dh(c, d, u);
                if (e) {
                    d.l(this, c, n.g, runOn(this, this.removeRefValueCore));
                }
            }
        }
        var v = (a == "object" || a == "Object");
        var w = v && typeof b === 'string' && stringStartsWith(b.toString(), "[") && stringEndsWith(b.toString(), "]");
        if (w) {
            var newVal_ = b;
            var x = JSON.parse(newVal_);
            return x;
        }
        if (!v && typeof b === 'string' && a.toLowerCase() != "string") {
            return this.bn(a, b, g);
        }
        if (v) {
            return b;
        }
        return h;
    };
    ComponentRenderer.prototype.x = 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.bn = function (a, b, c) {
        return this.context.s(a, b, c, this.o());
    };
    ComponentRenderer.prototype.o = function () {
        return true;
    };
    ComponentRenderer.prototype.bb = function (a) {
        var b = a.f();
        var c = new List$1(DescriptionTreeAction.$, 0);
        for (var d = 0; d < b.count; d++) {
            var e = new DescriptionTreeAction();
            e.a = 0;
            e.j = b._inner[d].c;
            e.d = b._inner[d].a;
            e.c = a;
            e.b = a;
            e.g = b._inner[d].b;
            if (e.d != null && e.d.mustBeFirst) {
                c.insert(0, e);
            }
            else {
                c.add(e);
            }
        }
        return c;
    };
    ComponentRenderer.prototype.ac = function (a, b, c) {
        if (c.c == null) {
            return this.r(a, b, c);
        }
        else {
            var d = this.b5(a, b, c);
            this.c1(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.c1 = function (a, b, c, d) {
        var e = c.i(ComponentRenderer.platform);
        this.adapter.clearCollection(d, e, c.d);
        if (c.h != null && typeCast(Array_$type, c.h) !== null) {
            var f = c.h;
            for (var g = 0; g < f.length; g++) {
                var h = f[g];
                if (h != null && typeCast(DescriptionTreeNode.$, h) !== null) {
                    var i = h.g;
                    if (i >= 0) {
                        var j = b.j(i);
                        if (j != null) {
                            this.c4(a, j, b);
                        }
                    }
                }
            }
        }
    };
    ComponentRenderer.prototype.d5 = function (a, b, c, d, e, f) {
        var e_18, _a;
        if (this.a5.containsKey(b)) {
            try {
                for (var _b = __values(fromEnum(this.a5.item(b))), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var g = _c.value;
                    g(b, a, d);
                }
            }
            catch (e_18_1) {
                e_18 = { error: e_18_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_18)
                        throw e_18.error;
                }
            }
        }
        this.adapter.setPropertyValue(a, b, c, d, e, f);
    };
    ComponentRenderer.prototype.b3 = function (a, b) {
        return this.adapter.getPropertyValue(a, b);
    };
    ComponentRenderer.prototype.r = function (a, b, c) {
        return this.q(a, b);
    };
    ComponentRenderer.prototype.q = function (a, b) {
        var _this = this;
        var c = this.adapter.getRootObject(a);
        if (c != null) {
            this.c4(a, c, b);
        }
        var d = false;
        this.adapter.clearContainer(a, this.context, function (e) {
            d = true;
            if (e) {
                _this.d0(a, b);
            }
        });
        return d;
    };
    ComponentRenderer.$t = markType(ComponentRenderer, 'ComponentRenderer');
    ComponentRenderer._defaultInstance = null;
    ComponentRenderer.platform = 3;
    return ComponentRenderer;
}(Base));
export { ComponentRenderer };
/**
 * @hidden
 */
var ContainerState = /** @class */ /*@__PURE__*/ (function (_super) {
    __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.c("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.c4(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 };
