/*
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 { IFilterExpression_$type } from "./IFilterExpression";
import { Convert } from "./Convert";
import { DataSourceSchemaPropertyType_$type } from "./DataSourceSchemaPropertyType";
import { Base, enumGetBox, markType, IComparable_$type, typeCast, typeGetValue, String_$type, Number_$type, Boolean_$type, Date_$type, getInstanceType } from "./type";
import { NotImplementedException } from "./NotImplementedException";
import { InvalidOperationException } from "./InvalidOperationException";
import { intDivide, isNaN_ } from "./number";
import { CompareUtil } from "./compareUtil";
import { stringCompareTo, stringConcat, stringEndsWith, stringReplace, stringStartsWith, stringContains } from "./string";
import { IFunctionFilterExpression_$type } from "./IFunctionFilterExpression";
import { FilterExpressionCollection } from "./FilterExpressionCollection";
import { dateGetMonth, dateGetDate, dateNow } from "./date";
export class FilterExpression extends Base {
    constructor() {
        super(...arguments);
        this.bv = false;
    }
    static operation3(a, b, c) {
        return new OperationFilterExpression(4, a, b, c);
    }
    static operation(a, b, c) {
        return new OperationFilterExpression(1, a, b, c);
    }
    static operation2(a, b, c) {
        return new OperationFilterExpression(2, a, b, c);
    }
    static operation1(a, b, c) {
        return new OperationFilterExpression(3, a, b, c);
    }
    static $function(a, ...b) {
        return new FunctionFilterExpression(1, a, ...b);
    }
    bz() {
        this.bv = this.bx();
    }
    static property(a) {
        if (a == null) {
            return null;
        }
        let b = new PropertyReferenceFilterExpression(0);
        b.propertyReference = a;
        return b;
    }
    static nullLiteral() {
        let a = new LiteralFilterExpression(0);
        return a;
    }
    static literal(a) {
        let b = new LiteralFilterExpression(1, a);
        return b;
    }
    static unquotedLiteral(a) {
        let b = new LiteralFilterExpression(2, a, true);
        return b;
    }
    match(a, b, c) {
        let d = this.evaluate(a, b, c);
        return this.by(d, b, c);
    }
    by(a, b, c) {
        if (!this.bv) {
            return this.bw(a, b, c);
        }
        return a;
    }
    bw(a, b, c) {
        return Convert.toBoolean(a);
    }
    get_isPropertyReference() {
        return false;
    }
    get isPropertyReference() {
        return this.get_isPropertyReference();
    }
    get_isOperation() {
        return false;
    }
    get isOperation() {
        return this.get_isOperation();
    }
    get_isFunction() {
        return false;
    }
    get isFunction() {
        return this.get_isFunction();
    }
    get_isLiteral() {
        return false;
    }
    get isLiteral() {
        return this.get_isLiteral();
    }
    get_isNull() {
        return false;
    }
    get isNull() {
        return this.get_isNull();
    }
    group() {
        return FilterExpression.operation(this, 15, null);
    }
    and(a) {
        return FilterExpression.operation(this, 7, a);
    }
    or(a) {
        return FilterExpression.operation(this, 8, a);
    }
    not() {
        return FilterExpression.operation(this, 9, null);
    }
    add(a) {
        return FilterExpression.operation(this, 10, a);
    }
    add1(a) {
        return FilterExpression.operation(this, 10, FilterExpression.literal(a));
    }
    plus(a) {
        return FilterExpression.operation(this, 10, a);
    }
    plus1(a) {
        return FilterExpression.operation(this, 10, FilterExpression.literal(a));
    }
    divide(a) {
        return FilterExpression.operation(this, 13, a);
    }
    divide1(a) {
        return FilterExpression.operation(this, 13, FilterExpression.literal(a));
    }
    dividedBy(a) {
        return FilterExpression.operation(this, 13, a);
    }
    dividedBy1(a) {
        return FilterExpression.operation(this, 13, FilterExpression.literal(a));
    }
    isEqualTo(a) {
        return FilterExpression.operation(this, 1, a);
    }
    isEqualTo1(a) {
        return FilterExpression.operation(this, 1, FilterExpression.literal(a));
    }
    isGreaterThan(a) {
        return FilterExpression.operation(this, 3, a);
    }
    isGreaterThan1(a) {
        return FilterExpression.operation(this, 3, FilterExpression.literal(a));
    }
    isGreaterThanOrEqualTo(a) {
        return FilterExpression.operation(this, 4, a);
    }
    isGreaterThanOrEqualTo1(a) {
        return FilterExpression.operation(this, 4, FilterExpression.literal(a));
    }
    isLessThan(a) {
        return FilterExpression.operation(this, 5, a);
    }
    isLessThan1(a) {
        return FilterExpression.operation(this, 5, FilterExpression.literal(a));
    }
    isLessThanOrEqualTo(a) {
        return FilterExpression.operation(this, 6, a);
    }
    isLessThanOrEqualTo1(a) {
        return FilterExpression.operation(this, 6, FilterExpression.literal(a));
    }
    modulo(a) {
        return FilterExpression.operation(this, 14, a);
    }
    modulo1(a) {
        return FilterExpression.operation(this, 14, FilterExpression.literal(a));
    }
    multiply(a) {
        return FilterExpression.operation(this, 12, a);
    }
    multiply1(a) {
        return FilterExpression.operation(this, 12, FilterExpression.literal(a));
    }
    times(a) {
        return FilterExpression.operation(this, 12, a);
    }
    times1(a) {
        return FilterExpression.operation(this, 12, FilterExpression.literal(a));
    }
    isNotEqualTo(a) {
        return FilterExpression.operation(this, 2, a);
    }
    isNotEqualTo1(a) {
        return FilterExpression.operation(this, 2, FilterExpression.literal(a));
    }
    subtract(a) {
        return FilterExpression.operation(this, 11, a);
    }
    subtract1(a) {
        return FilterExpression.operation(this, 11, FilterExpression.literal(a));
    }
    minus(a) {
        return FilterExpression.operation(this, 11, a);
    }
    minus1(a) {
        return FilterExpression.operation(this, 11, FilterExpression.literal(a));
    }
    ceiling() {
        return FilterExpression.$function(19, this);
    }
    concat(a) {
        return FilterExpression.$function(10, this, a);
    }
    concat1(a) {
        return FilterExpression.$function(10, this, FilterExpression.literal(a));
    }
    contains(a) {
        return FilterExpression.$function(0, this, a);
    }
    contains1(a) {
        return FilterExpression.$function(0, this, FilterExpression.literal(a));
    }
    day() {
        return FilterExpression.$function(11, this);
    }
    endsWith(a) {
        return FilterExpression.$function(1, this, a);
    }
    endsWith1(a) {
        return FilterExpression.$function(1, this, FilterExpression.literal(a));
    }
    floor() {
        return FilterExpression.$function(18, this);
    }
    hour() {
        return FilterExpression.$function(12, this);
    }
    indexOf(a) {
        return FilterExpression.$function(4, this, a);
    }
    indexOf1(a) {
        return FilterExpression.$function(4, this, FilterExpression.literal(a));
    }
    length() {
        return FilterExpression.$function(3, this);
    }
    minute() {
        return FilterExpression.$function(13, this);
    }
    month() {
        return FilterExpression.$function(14, this);
    }
    replace(a, b) {
        return FilterExpression.$function(5, this, a, b);
    }
    replace2(a, b) {
        return FilterExpression.$function(5, this, FilterExpression.literal(a), b);
    }
    replace1(a, b) {
        return FilterExpression.$function(5, this, a, FilterExpression.literal(b));
    }
    replace3(a, b) {
        return FilterExpression.$function(5, this, FilterExpression.literal(a), FilterExpression.literal(b));
    }
    round() {
        return FilterExpression.$function(17, this);
    }
    second() {
        return FilterExpression.$function(15, this);
    }
    startsWith(a) {
        return FilterExpression.$function(2, this, a);
    }
    startsWith1(a) {
        return FilterExpression.$function(2, this, FilterExpression.literal(a));
    }
    substring(a) {
        return FilterExpression.$function(6, this, a);
    }
    substring3(a) {
        return FilterExpression.$function(6, this, FilterExpression.literal(a));
    }
    substring1(a, b) {
        return FilterExpression.$function(6, this, a, b);
    }
    substring4(a, b) {
        return FilterExpression.$function(6, this, FilterExpression.literal(a), b);
    }
    substring2(a, b) {
        return FilterExpression.$function(6, this, a, FilterExpression.literal(b));
    }
    substring5(a, b) {
        return FilterExpression.$function(6, this, FilterExpression.literal(a), FilterExpression.literal(b));
    }
    toLower() {
        return FilterExpression.$function(7, this);
    }
    toUpper() {
        return FilterExpression.$function(8, this);
    }
    trim() {
        return FilterExpression.$function(9, this);
    }
    year() {
        return FilterExpression.$function(16, this);
    }
    date() {
        return FilterExpression.$function(20, this);
    }
    time() {
        return FilterExpression.$function(21, this);
    }
    now() {
        return FilterExpression.$function(22);
    }
    isOf(a) {
        return FilterExpression.$function(23, FilterExpression.literal(enumGetBox(DataSourceSchemaPropertyType_$type, a)));
    }
    cast(a) {
        return FilterExpression.$function(24, FilterExpression.literal(enumGetBox(DataSourceSchemaPropertyType_$type, a)));
    }
    isOf1(a) {
        return FilterExpression.$function(23, FilterExpression.literal(a));
    }
    cast1(a) {
        return FilterExpression.$function(24, FilterExpression.literal(a));
    }
}
FilterExpression.$t = markType(FilterExpression, 'FilterExpression', Base.$, [IFilterExpression_$type]);
export class OperationFilterExpression extends FilterExpression {
    constructor(a, ..._rest) {
        super();
        this.b2 = null;
        this.b6 = false;
        this.b3 = null;
        this.b7 = false;
        this.b0 = 0;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0: break;
            case 1:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    this.b2 = c;
                    this.b0 = d;
                    this.b3 = e;
                }
                break;
            case 2:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    this.propertyName = c;
                    this.b0 = d;
                    this.b3 = e;
                }
                break;
            case 3:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    this.b2 = c;
                    this.b0 = d;
                    this.value = e;
                }
                break;
            case 4:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    this.propertyName = c;
                    this.b0 = d;
                    this.value = e;
                }
                break;
        }
    }
    get_isOperation() {
        return true;
    }
    get isOperation() {
        return this.get_isOperation();
    }
    bx() {
        return this.cd;
    }
    get isComparisonOperation() {
        let a = this.operator;
        switch (a) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 5:
            case 6:
            case 4: return true;
        }
        return false;
    }
    get propertyName() {
        if (this.b2 == null || !this.b2.isPropertyReference) {
            return null;
        }
        return this.b2.propertyReference;
    }
    set propertyName(a) {
        this.left = FilterExpression.property(a);
    }
    get hasPropertyName() {
        return this.b2 != null && this.b2.isPropertyReference;
    }
    get value() {
        if (this.b3 == null) {
            return null;
        }
        if (this.b3.isNull) {
            return null;
        }
        if (!this.b3.isLiteral) {
            return null;
        }
        return this.b3.literalValue;
    }
    set value(a) {
        if (a == null) {
            this.right = FilterExpression.nullLiteral();
            return;
        }
        this.right = FilterExpression.literal(a);
    }
    get hasValue() {
        return this.b3 != null;
    }
    get left() {
        return this.b2;
    }
    set left(a) {
        this.b2 = a;
        this.b6 = true;
        this.bz();
    }
    get hasLeft() {
        return this.b6;
    }
    get right() {
        return this.b3;
    }
    set right(a) {
        this.b3 = a;
        this.b7 = true;
        this.bz();
    }
    get hasRight() {
        return this.b7;
    }
    get operator() {
        return this.b0;
    }
    set operator(a) {
        this.b0 = a;
        this.bz();
    }
    get hasOperator() {
        return this.b0 != 0;
    }
    get cd() {
        switch (this.operator) {
            case 7:
            case 1:
            case 3:
            case 4:
            case 5:
            case 6:
            case 9:
            case 2:
            case 8: return true;
        }
        return false;
    }
    evaluate(a, b, c) {
        switch (this.operator) {
            case 10:
            case 13:
            case 14:
            case 12:
            case 11: return this.cf(a, b, c);
            case 0:
            case 1:
            case 3:
            case 4:
            case 5:
            case 6:
            case 2: return this.cg(a, b, c);
            case 7:
            case 9:
            case 8: return this.ch(a, b, c);
            case 15: if (this.left != null) {
                return this.left.evaluate(a, b, c);
            }
            else {
                if (this.right == null) {
                    return null;
                }
                return this.right.evaluate(a, b, c);
            }
        }
        throw new NotImplementedException(0);
    }
    cg(a, b, c) {
        let d = null;
        let e = null;
        let f = -1;
        if (this.left != null) {
            d = this.left.evaluate(a, b, c);
        }
        if (this.right != null) {
            e = this.right.evaluate(a, b, c);
        }
        if (d == null && e == null) {
            f = 0;
        }
        let g = null;
        let h = null;
        if (typeCast(IComparable_$type, d) !== null) {
            g = d;
        }
        if (typeCast(IComparable_$type, e) !== null) {
            h = e;
        }
        if (typeof d === 'number' && isNaN_(d) || typeof e === 'number' && isNaN_(e) || typeof d === 'number' && isNaN_(d) || typeof e === 'number' && isNaN_(e)) {
            return false;
        }
        if (g != null) {
            if (e == null) {
                f = CompareUtil.compareToObject(g, 0);
                if (f == 0) {
                    f = -1;
                }
            }
            else {
                f = CompareUtil.compareToObject(g, e);
            }
        }
        else if (h != null) {
            if (d == null) {
                let i = CompareUtil.compareToObject(h, 0);
                if (i == 0) {
                    f = 1;
                }
                else {
                    f = 1;
                    if (i == 0) {
                        f = 0;
                    }
                    if (i > 0) {
                        f = -1;
                    }
                }
            }
            else {
                let j = CompareUtil.compareToObject(h, d);
                f = 1;
                if (j == 0) {
                    f = 0;
                }
                if (j > 0) {
                    f = -1;
                }
            }
        }
        else {
            let k = null;
            let l = null;
            if (d != null) {
                k = d.toString();
            }
            if (e != null) {
                l = e.toString();
            }
            if (k != null) {
                if (l == null) {
                    f = 1;
                }
                else {
                    f = stringCompareTo(k, l);
                }
            }
            else if (l != null) {
                if (k == null) {
                    f = -1;
                }
                else {
                    let m = stringCompareTo(l, k);
                    f = 1;
                    if (m == 0) {
                        f = 0;
                    }
                    if (m > 0) {
                        f = -1;
                    }
                }
            }
            else {
                f = 0;
            }
        }
        switch (this.operator) {
            case 0:
            case 1: return f == 0;
            case 3: return f > 0;
            case 4: return f >= 0;
            case 5: return f < 0;
            case 6: return f <= 0;
            case 2: return f != 0;
        }
        throw new InvalidOperationException(0);
    }
    ch(a, b, c) {
        let d = null;
        let e = null;
        if (this.left != null) {
            d = this.left.evaluate(a, b, c);
        }
        if (this.right != null) {
            e = this.right.evaluate(a, b, c);
        }
        if (e == null && d == null) {
            return false;
        }
        if (e == null) {
            e = false;
        }
        if (d == null) {
            d = false;
        }
        switch (this.operator) {
            case 7: return d && e;
            case 9: if (this.left == null) {
                return !e;
            }
            else {
                return !d;
            }
            case 8: return d || e;
        }
        return false;
    }
    cf(a, b, c) {
        let d = null;
        let e = null;
        if (this.left != null) {
            d = this.left.evaluate(a, b, c);
        }
        if (this.right != null) {
            e = this.right.evaluate(a, b, c);
        }
        if (d == null) {
            return e;
        }
        if (e == null) {
            return d;
        }
        if (d == null && e == null) {
            return 0;
        }
        if (typeof d === 'number' || typeof e === 'number') {
            switch (this.operator) {
                case 10: return d + e;
                case 13: return d / e;
                case 14: return d % e;
                case 12: return d * e;
                case 11: return d - e;
            }
        }
        if (typeof d === 'number' || typeof e === 'number') {
            switch (this.operator) {
                case 10: return d + e;
                case 13: return d / e;
                case 14: return d % e;
                case 12: return d * e;
                case 11: return d - e;
            }
        }
        if (typeof d === 'number' || typeof e === 'number') {
            switch (this.operator) {
                case 10: return d + e;
                case 13: return d / e;
                case 14: return d % e;
                case 12: return d * e;
                case 11: return d - e;
            }
        }
        if (typeof d === 'number' || typeof e === 'number') {
            switch (this.operator) {
                case 10: return typeGetValue(d) + typeGetValue(e);
                case 13: return intDivide(typeGetValue(d), typeGetValue(e));
                case 14: return typeGetValue(d) % typeGetValue(e);
                case 12: return typeGetValue(d) * typeGetValue(e);
                case 11: return typeGetValue(d) - typeGetValue(e);
            }
        }
        if (typeof d === 'number' || typeof e === 'number') {
            switch (this.operator) {
                case 10: return typeGetValue(d) + typeGetValue(e);
                case 13: return intDivide(typeGetValue(d), typeGetValue(e));
                case 14: return typeGetValue(d) % typeGetValue(e);
                case 12: return typeGetValue(d) * typeGetValue(e);
                case 11: return typeGetValue(d) - typeGetValue(e);
            }
        }
        if (typeof d === 'number' || typeof e === 'number') {
            switch (this.operator) {
                case 10: return typeGetValue(d) + typeGetValue(e);
                case 13: return intDivide(typeGetValue(d), typeGetValue(e));
                case 14: return typeGetValue(d) % typeGetValue(e);
                case 12: return typeGetValue(d) * typeGetValue(e);
                case 11: return typeGetValue(d) - typeGetValue(e);
            }
        }
        if (typeof d === 'number' || typeof e === 'number') {
            switch (this.operator) {
                case 10: return typeGetValue(d) + typeGetValue(e);
                case 13: return intDivide(typeGetValue(d), typeGetValue(e));
                case 14: return typeGetValue(d) % typeGetValue(e);
                case 12: return typeGetValue(d) * typeGetValue(e);
                case 11: return typeGetValue(d) - typeGetValue(e);
            }
        }
        throw new NotImplementedException(0);
    }
}
OperationFilterExpression.$t = markType(OperationFilterExpression, 'OperationFilterExpression', FilterExpression.$);
export class FunctionFilterExpression extends FilterExpression {
    constructor(a, ..._rest) {
        super();
        this.b1 = 19;
        this.b0 = new FilterExpressionCollection();
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0: break;
            case 1:
                {
                    let c = _rest[0];
                    let d = [];
                    for (let b = 1; b < _rest.length; b++) {
                        d[b - 1] = _rest[b];
                    }
                    this.b1 = c;
                    for (let e = 0; e < d.length; e++) {
                        this.b0.g(d[e]);
                    }
                }
                break;
        }
    }
    get_isFunction() {
        return true;
    }
    get isFunction() {
        return this.get_isFunction();
    }
    bx() {
        return this.b2;
    }
    get functionType() {
        return this.b1;
    }
    set functionType(a) {
        this.b1 = a;
        this.bz();
    }
    get b2() {
        switch (this.functionType) {
            case 1:
            case 2:
            case 0: return true;
        }
        return false;
    }
    get functionArguments() {
        return this.b0;
    }
    get hasFunctionArguments() {
        return this.b0.i.count > 0;
    }
    evaluate(a, b, c) {
        let d = null;
        let e = null;
        let f = null;
        let g = null;
        let h = this.functionArguments.i;
        if (h.count > 0) {
            for (let i = 0; i < h.count; i++) {
                let j = null;
                if (h.item(i) != null) {
                    j = h.item(i).evaluate(a, b, c);
                }
                switch (i) {
                    case 0:
                        d = j;
                        break;
                    case 1:
                        e = j;
                        break;
                    case 2:
                        f = j;
                        break;
                    case 3:
                        g = j;
                        break;
                }
                if (i > 3) {
                    break;
                }
            }
        }
        switch (this.functionType) {
            case 19:
                if (d == null) {
                    d = 0;
                }
                return Math.ceil(d);
            case 18:
                if (d == null) {
                    d = 0;
                }
                return Math.floor(d);
            case 17:
                if (d == null) {
                    d = 0;
                }
                if (typeof d === 'number') {
                    return Math.round(d);
                }
                return Math.round(d);
            case 11:
                if (d == null) {
                    return 0;
                }
                return d.getDate();
            case 12:
                if (d == null) {
                    return 0;
                }
                return d.getHours();
            case 13:
                if (d == null) {
                    return 0;
                }
                return d.getMinutes();
            case 14:
                if (d == null) {
                    return 0;
                }
                return dateGetMonth(d);
            case 16:
                if (d == null) {
                    return 0;
                }
                return d.getFullYear();
            case 15:
                if (d == null) {
                    return 0;
                }
                return d.getSeconds();
            case 20:
                if (d == null) {
                    return 0;
                }
                return dateGetDate(d);
            case 21:
                if (d == null) {
                    return 0;
                }
                return d;
            case 22: return dateNow();
            case 23:
                let k = this.b5(e, f);
                let l = d;
                if (l == null) {
                    return true;
                }
                if (k == null) {
                    return false;
                }
                if (k.isAssignableFrom(getInstanceType(l))) {
                    return true;
                }
                return false;
            case 24:
                let m = this.b5(e, f);
                let n = d;
                if (n == null) {
                    return true;
                }
                if (m == null) {
                    return false;
                }
                if (!m.isAssignableFrom(getInstanceType(n))) {
                    return null;
                }
                return this.b3(n, m);
            case 10:
                if (d == null) {
                    d = "";
                }
                if (e == null) {
                    e = "";
                }
                return stringConcat(d, e);
            case 1:
                if (d == null) {
                    d = "";
                }
                if (e == null) {
                    e = "";
                }
                return stringEndsWith(d, e);
            case 4:
                if (d == null) {
                    d = "";
                }
                if (e == null) {
                    e = "";
                }
                return d.indexOf(e);
            case 3:
                if (d == null) {
                    d = "";
                }
                return d.length;
            case 5:
                if (d == null) {
                    d = "";
                }
                if (e == null) {
                    e = "";
                }
                if (f == null) {
                    f = "";
                }
                return stringReplace(d, e, f);
            case 2:
                if (d == null) {
                    d = "";
                }
                if (e == null) {
                    e = "";
                }
                return stringStartsWith(d, e);
            case 6:
                if (d == null) {
                    d = "";
                }
                if (e == null) {
                    e = 0;
                }
                if (f != null) {
                    return d.substr(typeGetValue(e), typeGetValue(f));
                }
                else {
                    return d.substr(typeGetValue(e));
                }
            case 0:
                if (d == null) {
                    d = "";
                }
                if (e == null) {
                    e = "";
                }
                return stringContains(d, e);
            case 7:
                if (d == null) {
                    d = "";
                }
                return d.toLowerCase();
            case 8:
                if (d == null) {
                    d = "";
                }
                return d.toUpperCase();
            case 9:
                if (d == null) {
                    d = "";
                }
                return d.trim();
        }
        throw new NotImplementedException(0);
    }
    b3(a, b) {
        if (b == String_$type) {
            if (a == null) {
                return "";
            }
            return a.toString();
        }
        else if (b == Number_$type || b == Number_$type || b == Number_$type) {
            return Convert.toInt321(a);
        }
        else if (b == Boolean_$type) {
            return Convert.toBoolean(a);
        }
        else if (b == Number_$type) {
            return Convert.toByte1(a);
        }
        else if (b == Date_$type) {
            return Convert.toDateTime(a);
        }
        else if (b == Number_$type || b == Number_$type) {
            return Convert.toInt64(a);
        }
        else if (b == Number_$type) {
            return Convert.toDecimal2(a);
        }
        else {
            return a;
        }
    }
    b5(a, b) {
        if (typeCast(DataSourceSchemaPropertyType_$type, a) !== null || typeof a === 'number') {
            let c = typeGetValue(a);
            switch (c) {
                case 2: return Boolean_$type;
                case 10: return Number_$type;
                case 9: return Date_$type;
                case 8: return Date_$type;
                case 6: return Number_$type;
                case 5: return Number_$type;
                case 1: return Number_$type;
                case 3: return Number_$type;
                case 11:
                    if (b != null && typeof b === 'string') {
                        return this.b4(b);
                    }
                    return Base.$;
                case 4: return Number_$type;
                case 7: return Number_$type;
                case 0: return String_$type;
            }
        }
        if (typeof a === 'string') {
            return this.b4(b);
        }
        return Base.$;
    }
    b4(a) {
        switch (a) {
            case "Edm.Boolean":
            case "Boolean":
            case "bool":
            case "boolean": return Boolean_$type;
            case "Edm.Byte":
            case "Byte":
            case "byte":
            case "Edm.SByte":
            case "SByte": return Number_$type;
            case "Edm.DateTimeOffset":
            case "DateTimeOffset": return Date_$type;
            case "Edm.DateTime":
            case "DateTime":
            case "Calendar":
            case "datetime":
            case "calendar":
            case "Edm.Time":
            case "Time":
            case "time": return Date_$type;
            case "Edm.Decimal":
            case "Decimal":
            case "decimal": return Number_$type;
            case "Edm.Double":
            case "Double":
            case "double": return Number_$type;
            case "Edm.Float":
            case "Float":
            case "float":
            case "Edm.Single":
            case "Single":
            case "single": return Number_$type;
            case "Edm.Int16":
            case "Int16":
            case "Short":
            case "short": return Number_$type;
            case "Edm.Int32":
            case "Int32":
            case "int":
            case "Integer": return Number_$type;
            case "Edm.Int64":
            case "Int64":
            case "long":
            case "Long": return Number_$type;
            case "Edm.String":
            case "String":
            case "string": return String_$type;
        }
        return Base.$;
    }
}
FunctionFilterExpression.$t = markType(FunctionFilterExpression, 'FunctionFilterExpression', FilterExpression.$, [IFunctionFilterExpression_$type]);
export class PropertyReferenceFilterExpression extends FilterExpression {
    constructor(a, ..._rest) {
        super();
        this.b0 = null;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0: break;
            case 1:
                {
                    let c = _rest[0];
                    this.b0 = c;
                }
                break;
        }
    }
    get_isPropertyReference() {
        return true;
    }
    get isPropertyReference() {
        return this.get_isPropertyReference();
    }
    bx() {
        return false;
    }
    get propertyReference() {
        return this.b0;
    }
    set propertyReference(a) {
        this.b0 = a;
    }
    evaluate(a, b, c) {
        let d = b.getItemValue(a, this.propertyReference);
        return d;
    }
}
PropertyReferenceFilterExpression.$t = markType(PropertyReferenceFilterExpression, 'PropertyReferenceFilterExpression', FilterExpression.$);
export class LiteralFilterExpression extends FilterExpression {
    constructor(a, ..._rest) {
        super();
        this.b2 = null;
        this.b0 = false;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0: break;
            case 1:
                {
                    let c = _rest[0];
                    this.b2 = c;
                }
                break;
            case 2:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    this.b2 = c;
                    this.b0 = d;
                }
                break;
        }
    }
    get_isLiteral() {
        return true;
    }
    get isLiteral() {
        return this.get_isLiteral();
    }
    get_isNull() {
        return this.literalValue == null;
    }
    get isNull() {
        return this.get_isNull();
    }
    get literalValue() {
        return this.b2;
    }
    set literalValue(a) {
        this.b2 = a;
    }
    get leaveUnquoted() {
        return this.b0;
    }
    set leaveUnquoted(a) {
        this.b0 = a;
    }
    bx() {
        return typeCast(Boolean_$type, this.literalValue) !== null;
    }
    evaluate(a, b, c) {
        return this.literalValue;
    }
}
LiteralFilterExpression.$t = markType(LiteralFilterExpression, 'LiteralFilterExpression', FilterExpression.$);
//# sourceMappingURL=FilterExpression_combined.js.map