/*
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 * as tslib_1 from "tslib";
import { GridColumnOptionsViewBase } from "./GridColumnOptionsViewBase";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { GridColumnOptionsUtilities } from "./GridColumnOptionsUtilities";
import { EventArgs, runOn, delegateCombine, markType, enumGetBox, fromEnum, toNullable, typeCast } from "igniteui-webcomponents-core";
import { Size } from "igniteui-webcomponents-core";
import { GridColumnOptionsSectionBase } from "./GridColumnOptionsSectionBase";
import { StringComparer } from "igniteui-webcomponents-core";
import { ColumnComparisonConditionOperatorType_$type } from "./ColumnComparisonConditionOperatorType";
import { List$1 } from "igniteui-webcomponents-core";
import { ColumnComparisonFilterCondition } from "./ColumnComparisonFilterCondition";
import { ColumnFilterConditionGroup } from "./ColumnFilterConditionGroup";
import { PrimaryKeyValue } from "./PrimaryKeyValue";
import { SortDescription } from "igniteui-webcomponents-core";
import { Thickness } from "igniteui-webcomponents-core";
import { FilterApplyButtonClickEventArgs } from "./FilterApplyButtonClickEventArgs";
import { FilterCancelButtonClickEventArgs } from "./FilterCancelButtonClickEventArgs";
import { nullableEquals } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var GridColumnFilterOptionsView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridColumnFilterOptionsView, _super);
    function GridColumnFilterOptionsView() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.y = null;
        _this.z = null;
        _this.u = null;
        _this.x = null;
        _this.aa = null;
        _this.t = null;
        _this.v = null;
        _this.w = null;
        _this.q = null;
        _this.o = null;
        _this.p = null;
        _this.applyButtonClick = null;
        _this.cancelButtonClick = null;
        return _this;
    }
    GridColumnFilterOptionsView.prototype.m = function () {
        _super.prototype.m.call(this);
        var a = this.n;
        a.bf(this.q);
        a.bf(this.o);
        a.bf(this.p);
        if (null != this.w && null != this.x) {
            this.w.setStyleProperty("padding-bottom", "5px");
            this.w.setStyleProperty("margin", "0 -8px");
            switch (this.q.g) {
                case 2:
                    this.x.setStyleProperty("margin", "0 -.25rem");
                    break;
                case 1:
                case 3:
                    this.x.setStyleProperty("margin", "0 -.5rem");
                    break;
            }
            this.x.setRawText(a.cf);
            this.x.setStyleProperty("font", a.aa.fontString);
        }
        if (null != this.aa) {
            this.aa.setRawText(a.co);
            this.aa.setStyleProperty("font", a.aa.fontString);
            GridColumnOptionsUtilities.j(this.aa, false);
        }
        if (null != this.t) {
            this.t.setRawText(a.b7);
        }
        if (null != this.v) {
            this.v.setRawText(a.cb);
        }
    };
    Object.defineProperty(GridColumnFilterOptionsView.prototype, "n", {
        get: function () {
            return this.b;
        },
        enumerable: true,
        configurable: true
    });
    GridColumnFilterOptionsView.prototype.al = function (a) {
        this.o.disabled = !a;
    };
    GridColumnFilterOptionsView.prototype.am = function (a) {
        if (null != this.q) {
            this.q.disabled = !a;
        }
    };
    GridColumnFilterOptionsView.prototype.ah = function (a) {
        var _this = this;
        var b = this.e;
        var c = this.n;
        this.y = a;
        var d;
        var e;
        this.w = ((function () { var f = GridColumnOptionsUtilities.g(b, GridColumnFilterOptionsView.ab, 1, c.p, c.j, new Size(1, 24, 24), _this.q, d, _this.x, e, false, true); _this.q = f.p6; d = f.p7; _this.x = f.p8; e = f.p9; return f.ret; })());
        var f = this.q;
        f.clicked = delegateCombine(f.clicked, runOn(this, this.ae));
        this.y.append(this.w);
    };
    GridColumnFilterOptionsView.prototype.aj = function (a) {
        var b = this.e;
        this.z = a;
        this.aa = b.createElement("span");
        this.aa.setRawText(this.n.co);
        this.z.append(this.aa);
    };
    GridColumnFilterOptionsView.prototype.ai = function (a) {
        var _this = this;
        var b = this.e;
        var c = this.n;
        this.u = a;
        var d = b.createElement("hr");
        d.setStyleProperty("margin", "3px -7px");
        d.setStyleProperty("border-top", "1px solid #dde2eb");
        d.setStyleProperty("border-left", "0px");
        d.setStyleProperty("border-right", "0px");
        d.setStyleProperty("border-bottom", "0px");
        this.u.append(d);
        var e;
        var f = ((function () { var g = GridColumnOptionsUtilities.f(b, null, c.p, c.j, Size.empty, _this.o, e, _this.t); _this.o = g.p5; e = g.p6; _this.t = g.p7; return g.ret; })());
        f.setStyleProperty("margin-left", "1rem");
        var g = this.o;
        g.clicked = delegateCombine(g.clicked, runOn(this, this.ac));
        this.o.hg = "1";
        var h;
        var i = ((function () { var j = GridColumnOptionsUtilities.f(b, null, c.p, c.j, Size.empty, _this.p, h, _this.v); _this.p = j.p5; h = j.p6; _this.v = j.p7; return j.ret; })());
        var j = this.p;
        j.clicked = delegateCombine(j.clicked, runOn(this, this.ad));
        this.p.hg = "1";
        this.p.s = 2;
        var k = b.createElement("div");
        k.setStyleProperty("display", "flex");
        k.setStyleProperty("justify-content", "space-between");
        k.append(i);
        k.append(f);
        this.u.append(k);
    };
    GridColumnFilterOptionsView.prototype.ak = function (a) {
        this.h(a);
    };
    GridColumnFilterOptionsView.prototype.af = function () {
        if (null != this.applyButtonClick) {
            this.applyButtonClick(this, EventArgs.empty);
        }
    };
    GridColumnFilterOptionsView.prototype.ag = function () {
        if (null != this.cancelButtonClick) {
            this.cancelButtonClick(this, EventArgs.empty);
        }
    };
    GridColumnFilterOptionsView.prototype.ac = function (a, b) {
        this.af();
    };
    GridColumnFilterOptionsView.prototype.ad = function (a, b) {
        this.ag();
    };
    GridColumnFilterOptionsView.prototype.ae = function (a, b) {
        this.n.ct();
    };
    GridColumnFilterOptionsView.$t = markType(GridColumnFilterOptionsView, 'GridColumnFilterOptionsView', GridColumnOptionsViewBase.$);
    GridColumnFilterOptionsView.ab = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";
    return GridColumnFilterOptionsView;
}(GridColumnOptionsViewBase));
export { GridColumnFilterOptionsView };
/**
 * @hidden
 */
var GridColumnFilterOptions = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridColumnFilterOptions, _super);
    function GridColumnFilterOptions() {
        var _this = _super.call(this) || this;
        _this.b2 = null;
        _this.b6 = "Apply";
        _this.ca = "Cancel";
        _this.ce = "Clear column filters";
        _this.cj = "Search";
        _this.by = 0;
        _this.bx = 0;
        _this.cn = "Text filter";
        _this.applyButtonClick = null;
        _this.cancelButtonClick = null;
        return _this;
    }
    GridColumnFilterOptions.prototype.f = function () {
        return new GridColumnFilterOptionsView();
    };
    GridColumnFilterOptions.prototype.bq = function () {
        if (null == this.column) {
            return false;
        }
        if (!this.column.gf) {
            return false;
        }
        if (this.c == null || this.c.actualDataSource == null || !this.c.actualDataSource.isGroupingSupported) {
            return false;
        }
        return true;
    };
    GridColumnFilterOptions.prototype.a5 = function () {
        _super.prototype.a5.call(this);
        this.cy();
        this.c4();
    };
    GridColumnFilterOptions.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        switch (b.propertyName) {
            case "Filter":
                this.c4();
                break;
        }
    };
    GridColumnFilterOptions.prototype.onViewInitialized = function () {
        _super.prototype.onViewInitialized.call(this);
        var a = this.bw;
        a.applyButtonClick = delegateCombine(a.applyButtonClick, runOn(this, this.c8));
        var b = this.bw;
        b.cancelButtonClick = delegateCombine(b.cancelButtonClick, runOn(this, this.c9));
    };
    GridColumnFilterOptions.prototype.bc = function (a, b, c) {
        _super.prototype.bc.call(this, a, b, c);
        switch (a) {
            case "ApplyButtonCaption":
            case "CancelButtonCaption":
            case "ClearColumnFiltersCaption":
            case "TextFilterCaption":
                this.bw.m();
                break;
            case "ActualBaseTheme":
            case "ActualDensity":
            case "ActualFilterListDensity":
            case "FilterListPlaceholderText":
            case "BackgroundColor":
            case "TextColor":
                this.c6();
                break;
            case "FilterListDensity":
                this.bz = this.b1 == 0 ? this.q : this.b1;
                break;
        }
    };
    Object.defineProperty(GridColumnFilterOptions.prototype, "bw", {
        get: function () {
            return this.e;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridColumnFilterOptions.prototype, "b7", {
        get: function () {
            return this.b6;
        },
        set: function (a) {
            if (0 == StringComparer.b.compare(a, this.b6)) {
                return;
            }
            var b = this.b6;
            this.b6 = a;
            this.ba("ApplyButtonCaption", b, this.b6);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridColumnFilterOptions.prototype, "cb", {
        get: function () {
            return this.ca;
        },
        set: function (a) {
            if (0 == StringComparer.b.compare(a, this.ca)) {
                return;
            }
            var b = this.ca;
            this.ca = a;
            this.ba("CancelButtonCaption", b, this.ca);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridColumnFilterOptions.prototype, "cf", {
        get: function () {
            return this.ce;
        },
        set: function (a) {
            if (0 == StringComparer.b.compare(a, this.ce)) {
                return;
            }
            var b = this.ce;
            this.ce = a;
            this.ba("ClearColumnFiltersCaption", b, this.ce);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridColumnFilterOptions.prototype, "ck", {
        get: function () {
            return this.cj;
        },
        set: function (a) {
            if (0 == StringComparer.b.compare(a, this.cj)) {
                return;
            }
            var b = this.cj;
            this.cj = a;
            this.ba("FilterListPlaceholderText", b, this.cj);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridColumnFilterOptions.prototype, "b1", {
        get: function () {
            return this.by;
        },
        set: function (a) {
            var b = this.by;
            this.by = a;
            if (b != this.by) {
                this.ba("FilterListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, a));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridColumnFilterOptions.prototype, "bz", {
        get: function () {
            return this.bx;
        },
        set: function (a) {
            var b = this.bx;
            this.bx = a;
            if (b != this.bx) {
                this.ba("ActualFilterListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, a));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridColumnFilterOptions.prototype, "co", {
        get: function () {
            return this.cn;
        },
        set: function (a) {
            if (0 == StringComparer.b.compare(a, this.cn)) {
                return;
            }
            var b = this.cn;
            this.cn = a;
            this.ba("TextFilterCaption", b, this.cn);
        },
        enumerable: true,
        configurable: true
    });
    GridColumnFilterOptions.prototype.c4 = function () {
        var a = this.b2.ah();
        this.bw.al(!a);
        var b = this.b3();
        this.bw.am(b);
    };
    GridColumnFilterOptions.prototype.cr = function () {
        var e_1, _a;
        if (0 == this.b2.g.count) {
            this.ct();
            return;
        }
        var a;
        var b;
        if (this.b2.p == 0) {
            b = false;
            a = 10;
        }
        else {
            b = true;
            a = 5;
        }
        var c = new List$1(ColumnComparisonFilterCondition.$, 0);
        var d = this.b2.g;
        for (var e = 0; e < d.count; e++) {
            var f = d._inner[e];
            var g = f.value[0];
            var h = GridColumnFilterOptions.bt(a, g);
            c.add(h);
        }
        if (c.count == 1) {
            this.column.eo = c._inner[0];
        }
        else {
            var i = new ColumnFilterConditionGroup();
            i.f = b;
            try {
                for (var _b = tslib_1.__values(fromEnum(c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var j = _c.value;
                    i.h(j);
                }
            }
            catch (e_1_1) {
                e_1 = { error: e_1_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_1)
                        throw e_1.error;
                }
            }
            this.column.eo = i;
        }
    };
    GridColumnFilterOptions.prototype.provideClearFiltersSection = function (a) {
        this.bw.ah(a);
    };
    GridColumnFilterOptions.prototype.provideFilterSection = function (a) {
        this.bw.aj(a);
    };
    GridColumnFilterOptions.prototype.provideFilterCheckboxListSection = function (a) {
        this.b2 = a;
        this.c6();
        var b = this.b2;
        b.selectAllCheckboxChanged = delegateCombine(b.selectAllCheckboxChanged, runOn(this, this.cs));
        var c = this.b2;
        c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.cv));
    };
    GridColumnFilterOptions.prototype.provideFilterButtonSection = function (a) {
        this.bw.ai(a);
    };
    GridColumnFilterOptions.prototype.provideMainDiv = function (a) {
        this.bw.ak(a);
    };
    GridColumnFilterOptions.prototype.ct = function () {
        this.column.eo = null;
        this.c5();
    };
    GridColumnFilterOptions.bt = function (a, b) {
        var c = new ColumnComparisonFilterCondition();
        c.e = a;
        c.j = b;
        return c;
    };
    GridColumnFilterOptions.prototype.b3 = function () {
        var a = this.column;
        if (null == a) {
            return false;
        }
        return null != a.eo;
    };
    GridColumnFilterOptions.prototype.cy = function () {
        var a = this.column;
        var b = this.c;
        var c = (null != a) ? a.h4 : null;
        var d = (null != b) ? b.actualDataSource.clone() : null;
        if (null != d) {
            this.c7(b.actualDataSource, d);
            d.summaryDescriptions.clear();
            d.groupDescriptions.clear();
            var e = new SortDescription();
            e.propertyName = c;
            e.direction = 0;
            d.groupDescriptions.add(e);
            var f = b.z(a);
            var g = d.filterExpressions;
            for (var h = g.j.count - 1; h >= 0; h--) {
                var i = g.j.item(h);
                if (i.isAutoGenerated) {
                    if (null != f) {
                        g.j.item(h, f);
                    }
                    else {
                        d.filterExpressions.removeAt(h);
                    }
                    break;
                }
            }
            this.b2.itemsSource = d;
            this.b2.a2 = c;
            this.b2.b = [c];
            d.isSectionHeaderNormalRow = true;
            d.isSectionExpandedDefault = false;
            d.isSectionCollapsable = true;
            d.isSectionContentVisible = false;
            this.c5();
        }
    };
    GridColumnFilterOptions.prototype.c7 = function (a, b) {
        if (a != null && a.actualSchema != null && b != null && b.actualSchema != null) {
            var c = b.actualSchema.propertyTypes;
            var d = a.actualSchema.propertyTypes;
            for (var e = 0; e < c.length; e++) {
                if (c[e] != d[e]) {
                    c[e] = d[e];
                }
            }
        }
    };
    GridColumnFilterOptions.prototype.c5 = function () {
        var e_2, _a;
        var a = this.column;
        var b = (null != a) ? a.h4 : null;
        var c = true;
        var d = toNullable(ColumnComparisonConditionOperatorType_$type, null);
        var e = this.b4();
        for (var f = e.count - 1; f >= 0; f--) {
            var g = e._inner[f];
            switch (g.e) {
                case 5:
                case 10: break;
                default:
                    e.removeAt(f);
                    continue;
            }
            if (nullableEquals(d, null)) {
                d = toNullable(ColumnComparisonConditionOperatorType_$type, g.e);
            }
            else if (d.value != g.e) {
                c = false;
                break;
            }
        }
        if (e.count == 0 || !c) {
            this.b2.ch();
            return;
        }
        switch (d.value) {
            case 5:
                this.b2.bs();
                break;
            case 10:
                this.b2.ch();
                break;
        }
        var h = this.b2.g;
        try {
            for (var _b = tslib_1.__values(fromEnum(e)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var i = _c.value;
                h.add(new PrimaryKeyValue([b], [i.j]));
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
        this.c4();
    };
    GridColumnFilterOptions.prototype.b4 = function () {
        var a = new List$1(ColumnComparisonFilterCondition.$, 0);
        var b = this.column;
        if (null == b) {
            return a;
        }
        if (null != b.eo) {
            var c = GridColumnFilterOptions.cu(b.eo, a);
            a = c.p1;
        }
        return a;
    };
    GridColumnFilterOptions.cu = function (a, b) {
        var c = typeCast(ColumnFilterConditionGroup.$, a);
        if (null != c) {
            for (var d = 0; d < c.g; d++) {
                var e = c.item(d);
                var f = GridColumnFilterOptions.cu(e, b);
                b = f.p1;
            }
        }
        else if (null != a) {
            b.add1(a);
        }
        return {
            p1: b
        };
    };
    GridColumnFilterOptions.prototype.c6 = function () {
        if (null != this.b2) {
            this.b2.n = this.bz;
            this.b2.a6 = this.ck;
            this.b2.cr = this.bm;
            this.b2.cw = this.bp;
            this.b2.l = this.i;
            this.b2.updateHrMargin(new Thickness(1, -7, 3, -7, 3));
        }
    };
    GridColumnFilterOptions.prototype.cs = function (a, b) {
        this.c4();
    };
    GridColumnFilterOptions.prototype.cv = function (a, b) {
        this.c4();
    };
    GridColumnFilterOptions.prototype.c8 = function (a, b) {
        this.cr();
        this.cw();
    };
    GridColumnFilterOptions.prototype.c9 = function (a, b) {
        this.cx();
    };
    GridColumnFilterOptions.prototype.cw = function () {
        if (null != this.applyButtonClick) {
            this.applyButtonClick(this, new FilterApplyButtonClickEventArgs());
        }
    };
    GridColumnFilterOptions.prototype.cx = function () {
        if (null != this.cancelButtonClick) {
            this.cancelButtonClick(this, new FilterCancelButtonClickEventArgs());
        }
    };
    GridColumnFilterOptions.$t = markType(GridColumnFilterOptions, 'GridColumnFilterOptions', GridColumnOptionsSectionBase.$);
    return GridColumnFilterOptions;
}(GridColumnOptionsSectionBase));
export { GridColumnFilterOptions };
//# sourceMappingURL=GridColumnFilterOptionsView_combined.js.map
