/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { Base, EnumUtil, fromEnum, typeCast, markType } from "./type";
import { CodeGenerationLibraryItemType_$type } from "./CodeGenerationLibraryItemType";
import { CodeGenerationLibraryItemContent } from "./CodeGenerationLibraryItemContent";
import { CodeGenerationTargetPlatforms_$type } from "./CodeGenerationTargetPlatforms";
import { List$1 } from "./List$1";
import { CodeGenerationLibraryItemPlatform_$type } from "./CodeGenerationLibraryItemPlatform";
import { Dictionary$2 } from "./Dictionary$2";
import { JsonDictionaryItem } from "./JsonDictionaryItem";
import { JsonDictionaryObject } from "./JsonDictionaryObject";
import { JsonDictionaryArray } from "./JsonDictionaryArray";
import { JsonDictionaryValue } from "./JsonDictionaryValue";
/**
 * @hidden
 */
export let CodeGenerationLibraryItem = /*@__PURE__*/ (() => {
    class CodeGenerationLibraryItem extends Base {
        constructor() {
            super(...arguments);
            this._name = null;
            this._type = 0;
            this.i = new Dictionary$2(CodeGenerationLibraryItemPlatform_$type, CodeGenerationLibraryItemContent.$, 0);
            this.j = new List$1(CodeGenerationLibraryItemContent.$, 0);
        }
        get name() {
            return this._name;
        }
        set name(a) {
            this._name = a;
        }
        get type() {
            return this._type;
        }
        set type(a) {
            this._type = a;
        }
        getContentForPlatformString(a) {
            let b;
            b = EnumUtil.getEnumValue(CodeGenerationTargetPlatforms_$type, EnumUtil.parse(CodeGenerationTargetPlatforms_$type, a, true));
            return this.getContentForPlatform(b);
        }
        getContentForPlatform(a) {
            for (let b of fromEnum(this.j)) {
                if (this.h(b, a)) {
                    return b;
                }
            }
            return null;
        }
        h(a, b) {
            switch (a.platform) {
                case 11: return true;
                case 7: return b == 1 || b == 2 || b == 3;
                case 0: return b == 1;
                case 8: return b == 0 || b == 4;
                case 3: return false;
                case 1: return b == 2;
                case 12: return false;
                case 6: return b == 1 || b == 2 || b == 3;
                case 2: return b == 3;
                case 9: return b == 0 || b == 4;
                case 5: return b == 4;
                case 4: return b == 0;
                case 10: return true;
            }
            return false;
        }
        addPlatformContent(a, b) {
            if (b == null) {
                return;
            }
            this.i.item(a, b);
            b.platform = a;
            this.j.add(b);
        }
        b(a) {
            if (a == null) {
                return null;
            }
            return ((() => {
                let $ret = new CodeGenerationLibraryItemContent();
                $ret.content = a;
                return $ret;
            })());
        }
        e(a) {
            if (a == null) {
                return null;
            }
            return ((() => {
                let $ret = new CodeGenerationLibraryItemContent();
                $ret.content = a;
                $ret.isJson = true;
                return $ret;
            })());
        }
        static a(a) {
            let b = new CodeGenerationLibraryItem();
            if (typeCast(JsonDictionaryObject.$, a) !== null) {
                let c = a;
                if (c.g("name")) {
                    b.name = c.item("name").value.toString();
                }
                if (c.g("type")) {
                    let d = c.item("type").value.toString();
                    let e = EnumUtil.getEnumValue(CodeGenerationLibraryItemType_$type, EnumUtil.parse(CodeGenerationLibraryItemType_$type, d, true));
                    b.type = e;
                }
                if (c.g("content")) {
                    let f = c.item("content");
                    if (typeCast(JsonDictionaryArray.$, f) !== null) {
                        let g = f;
                        if (g.items != null && g.items.length > 0) {
                            for (let h = 0; h < g.items.length; h++) {
                                let i = CodeGenerationLibraryItemContent.a(g.items[h]);
                                b.j.add(i);
                                b.i.addItem(i.platform, i);
                            }
                        }
                    }
                }
            }
            return b;
        }
        g() {
            let a = new JsonDictionaryObject();
            a.item("name", ((() => {
                let $ret = new JsonDictionaryValue();
                $ret.e = 2;
                $ret.value = this.name;
                return $ret;
            })()));
            let b = new JsonDictionaryArray();
            a.item("content", b);
            a.item("type", ((() => {
                let $ret = new JsonDictionaryValue();
                $ret.e = 2;
                $ret.value = EnumUtil.getName(CodeGenerationLibraryItemType_$type, this.type);
                return $ret;
            })()));
            let c = new List$1(JsonDictionaryItem.$, 0);
            for (let d of fromEnum(this.j)) {
                let e = d.d();
                c.add(e);
            }
            b.items = c.toArray();
            return a;
        }
    }
    CodeGenerationLibraryItem.$t = markType(CodeGenerationLibraryItem, 'CodeGenerationLibraryItem');
    return CodeGenerationLibraryItem;
})();
