/*
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, typeCast, markType, EnumUtil } from "./type";
import { ComponentRendererMethodHelperBuilder } from "./ComponentRendererMethodHelperBuilder";
import { JsonDictionaryParser } from "./JsonDictionaryParser";
import { JsonDictionaryObject } from "./JsonDictionaryObject";
import { EmbeddedRefDescription } from "./EmbeddedRefDescription";
import { PointDescription } from "./PointDescription";
import { SizeDescription } from "./SizeDescription";
import { RectDescription } from "./RectDescription";
import { truncate } from "./number";
/**
 * @hidden
 */
export let ComponentRendererMethodHelper = /*@__PURE__*/ (() => {
    class ComponentRendererMethodHelper extends Base {
        static call(a) {
            return new ComponentRendererMethodHelperBuilder(a);
        }
        static returnAsInt(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                return truncate(b);
            }
            return -2147483648;
        }
        static l(a) {
            let b = new JsonDictionaryParser();
            let c = b.parse(a);
            if (c != null && typeCast(JsonDictionaryObject.$, c) !== null) {
                let d = c;
                if (d.g("result")) {
                    return d.item("result").value;
                }
            }
            return null;
        }
        static returnAsDouble(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                return b;
            }
            return NaN;
        }
        static returnAsShort(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                return truncate(b);
            }
            return -32768;
        }
        static returnAsLong(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                return truncate(b);
            }
            return -9.2233720368547758E+18;
        }
        static returnAsFloat(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                return b;
            }
            return NaN;
        }
        static returnAsEnum(a, b) {
            let c = ComponentRendererMethodHelper.l(b);
            if (c != null) {
                return EnumUtil.parse(a, c, true);
            }
            return null;
        }
        static returnAsString(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                return b;
            }
            return null;
        }
        static returnAsAsPublicTypeRef(a, b) {
            let c = ComponentRendererMethodHelper.l(b);
            if (c != null) {
                let d = c;
                let e = ((() => {
                    let $ret = new EmbeddedRefDescription();
                    $ret.refType = "name";
                    $ret.name = d.item("id").value.toString();
                    return $ret;
                })());
                return e;
            }
            return null;
        }
        static returnAsPoint(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                let c = b;
                let d = new PointDescription();
                d.x = c.item("x").value;
                d.y = c.item("y").value;
                return d;
            }
            return null;
        }
        static returnAsSize(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                let c = b;
                let d = new SizeDescription();
                d.width = c.item("width").value;
                d.height = c.item("height").value;
                return d;
            }
            return null;
        }
        static returnAsRect(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                let c = b;
                let d = new RectDescription();
                d.width = c.item("width").value;
                d.height = c.item("height").value;
                return d;
            }
            return null;
        }
        static asMethodRef(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                let c = b;
                let d = ((() => {
                    let $ret = new EmbeddedRefDescription();
                    $ret.refType = "name";
                    $ret.name = c.item("id").value.toString();
                    return $ret;
                })());
                return d;
            }
            return null;
        }
        static returnAsBool(a) {
            let b = ComponentRendererMethodHelper.l(a);
            if (b != null) {
                return b;
            }
            return false;
        }
    }
    ComponentRendererMethodHelper.$t = /*@__PURE__*/ markType(ComponentRendererMethodHelper, 'ComponentRendererMethodHelper');
    return ComponentRendererMethodHelper;
})();
