/*
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 { ColumnFilterCondition } from "./ColumnFilterCondition";
import { ColumnComparisonConditionOperatorType_$type } from "./ColumnComparisonConditionOperatorType";
import { Base, typeCast, enumGetBox, Date_$type, markType } from "igniteui-webcomponents-core";
import { DataSourceSchemaPropertyType_$type } from "igniteui-webcomponents-core";
import { List$1 } from "igniteui-webcomponents-core";
import { FilterFactory } from "igniteui-webcomponents-core";
import { dateTryParse } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
export let ColumnComparisonFilterCondition = /*@__PURE__*/ (() => {
    class ColumnComparisonFilterCondition extends ColumnFilterCondition {
        constructor() {
            super();
            this.e = 0;
            this.j = null;
            this.g = false;
            this.g = true;
        }
        static c(a) {
            let b = new List$1(ColumnComparisonConditionOperatorType_$type, 0);
            switch (a) {
                case 11: break;
                case 2: break;
                case 10:
                case 6:
                case 5:
                case 1:
                case 3:
                case 8:
                    b.add(6);
                    b.add(7);
                    b.add(8);
                    b.add(9);
                    break;
                case 0:
                    b.add(11);
                    b.add(3);
                    b.add(4);
                    b.add(2);
                    b.add(0);
                    b.add(1);
                    b.add(6);
                    b.add(7);
                    b.add(8);
                    b.add(9);
                    break;
            }
            b.add(5);
            b.add(10);
            b.add(12);
            b.add(13);
            return b.toArray();
        }
        equals(a) {
            if (a == null) {
                return false;
            }
            if (!(typeCast(ColumnComparisonFilterCondition.$, a) !== null)) {
                return false;
            }
            let b = a;
            if (b.e != this.e) {
                return false;
            }
            if (!Base.equalsStatic(b.j, this.j)) {
                return false;
            }
            if (!Base.equalsStatic(b.g, this.g)) {
                return false;
            }
            return true;
        }
        a(a, b) {
            switch (this.e) {
                case 0:
                    {
                        if (this.j == null) {
                            return null;
                        }
                        let c = FilterFactory.instance.property(a);
                        let d = FilterFactory.instance.literal(this.j);
                        c = ColumnComparisonFilterCondition.f(b, c);
                        if (null == c) {
                            return null;
                        }
                        if (!this.g) {
                            c = c.toLower();
                            d = d.toLower();
                        }
                        return c.contains(d);
                    }
                case 1:
                    {
                        if (this.j == null) {
                            return null;
                        }
                        let e = FilterFactory.instance.property(a);
                        let f = FilterFactory.instance.literal(this.j);
                        e = ColumnComparisonFilterCondition.f(b, e);
                        if (null == e) {
                            return null;
                        }
                        if (!this.g) {
                            e = e.toLower();
                            f = f.toLower();
                        }
                        return e.contains(f).not();
                    }
                case 2:
                    {
                        if (this.j == null) {
                            return null;
                        }
                        let g = FilterFactory.instance.property(a);
                        let h = FilterFactory.instance.literal(this.j);
                        g = ColumnComparisonFilterCondition.f(b, g);
                        if (null == g) {
                            return null;
                        }
                        if (!this.g) {
                            g = g.toLower();
                            h = h.toLower();
                        }
                        return g.endsWith(h).not();
                    }
                case 3:
                    {
                        if (this.j == null) {
                            return null;
                        }
                        let i = FilterFactory.instance.property(a);
                        let j = FilterFactory.instance.literal(this.j);
                        i = ColumnComparisonFilterCondition.f(b, i);
                        if (null == i) {
                            return null;
                        }
                        if (!this.g) {
                            i = i.toLower();
                            j = j.toLower();
                        }
                        return i.startsWith(j).not();
                    }
                case 4:
                    {
                        if (this.j == null) {
                            return null;
                        }
                        let k = FilterFactory.instance.property(a);
                        let l = FilterFactory.instance.literal(this.j);
                        k = ColumnComparisonFilterCondition.f(b, k);
                        if (null == k) {
                            return null;
                        }
                        if (!this.g) {
                            k = k.toLower();
                            l = l.toLower();
                        }
                        return k.endsWith(l);
                    }
                case 5:
                    {
                        let m = FilterFactory.instance.property(a);
                        let n = FilterFactory.instance.literal(this.i(this.j, b));
                        if (b == 0 && !this.g) {
                            m = m.toLower();
                            n = n.toLower();
                        }
                        return m.isEqualTo(n);
                    }
                case 6:
                    {
                        let o = FilterFactory.instance.property(a);
                        let p = FilterFactory.instance.literal(this.i(this.j, b));
                        if (b == 0 && !this.g) {
                            o = o.toLower();
                            p = p.toLower();
                        }
                        return o.isGreaterThan(p);
                    }
                case 7:
                    {
                        let q = FilterFactory.instance.property(a);
                        let r = FilterFactory.instance.literal(this.i(this.j, b));
                        if (b == 0 && !this.g) {
                            q = q.toLower();
                            r = r.toLower();
                        }
                        return q.isGreaterThanOrEqualTo(r);
                    }
                case 8:
                    {
                        let s = FilterFactory.instance.property(a);
                        let t = FilterFactory.instance.literal(this.i(this.j, b));
                        if (b == 0 && !this.g) {
                            s = s.toLower();
                            t = t.toLower();
                        }
                        return s.isLessThan(t);
                    }
                case 9:
                    {
                        let u = FilterFactory.instance.property(a);
                        let v = FilterFactory.instance.literal(this.i(this.j, b));
                        if (b == 0 && !this.g) {
                            u = u.toLower();
                            v = v.toLower();
                        }
                        return u.isLessThanOrEqualTo(v);
                    }
                case 10:
                    {
                        let w = FilterFactory.instance.property(a);
                        let x = FilterFactory.instance.literal(this.i(this.j, b));
                        if (b == 0 && !this.g) {
                            w = w.toLower();
                            x = x.toLower();
                        }
                        return w.isNotEqualTo(x);
                    }
                case 11:
                    {
                        if (this.j == null) {
                            return null;
                        }
                        let y = FilterFactory.instance.property(a);
                        let z = FilterFactory.instance.literal(this.j);
                        y = ColumnComparisonFilterCondition.f(b, y);
                        if (null == y) {
                            return null;
                        }
                        if (!this.g) {
                            y = y.toLower();
                            z = z.toLower();
                        }
                        return y.startsWith(z);
                    }
                case 12:
                    {
                        let aa = FilterFactory.instance.property(a);
                        let ab = FilterFactory.instance.literal(null);
                        return aa.isNotEqualTo(ab);
                    }
                case 13:
                    {
                        let ac = FilterFactory.instance.property(a);
                        let ad = FilterFactory.instance.literal(null);
                        return ac.isEqualTo(ad);
                    }
            }
            return null;
        }
        static f(a, b) {
            switch (a) {
                case 9:
                case 8:
                case 2:
                case 11: return null;
                case 10:
                case 6:
                case 5:
                case 1:
                case 3:
                case 4:
                case 7: return b.cast(enumGetBox(DataSourceSchemaPropertyType_$type, 0));
                case 0: break;
                default: break;
            }
            return b;
        }
        static h(a) {
            if (a == 12 || a == 13) {
                return 0;
            }
            else {
                return 1;
            }
        }
        static d(a) {
            let b = new Array(a.length);
            for (let c = 0; c < a.length; c++) {
                b[c] = ColumnComparisonFilterCondition.h(a[c]);
            }
            return b;
        }
        i(value_, a) {
            if (value_ == null) {
                return null;
            }
            switch (a) {
                case 2: return (!!value_);
                case 10: return (+value_);
                case 8:
                    if (typeCast(Date_$type, value_) !== null) {
                        return value_;
                    }
                    if (typeof value_ === 'string') {
                        let b;
                        if (((() => { let c = dateTryParse(value_, b); b = c.p1; return c.ret; })())) {
                            return b;
                        }
                        else {
                            return null;
                        }
                    }
                    return (new Date(+value_));
                case 6: return (+value_);
                case 5: return (+value_);
                case 1: return (+value_);
                case 3: return (+value_);
                case 11: return value_;
                case 4: return (+value_);
                case 7: return (+value_);
                case 0: return value_ != null ? value_.toString() : value_;
            }
            return value_;
        }
    }
    ColumnComparisonFilterCondition.$t = /*@__PURE__*/ markType(ColumnComparisonFilterCondition, 'ColumnComparisonFilterCondition', ColumnFilterCondition.$);
    return ColumnComparisonFilterCondition;
})();
//# sourceMappingURL=ColumnComparisonFilterCondition.js.map
