/*
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 { Base, runOn, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, enumGetBox, delegateCombine, EnumUtil, delegateRemove } from "igniteui-webcomponents-core";
import { RenderingContext } from "igniteui-webcomponents-core";
import { Path } from "igniteui-webcomponents-core";
import { GridStyleRepository } from "./GridStyleRepository";
import { KeyFrameAnimationFactory } from "igniteui-webcomponents-core";
import { AnimationKeyFrameEffect } from "igniteui-webcomponents-core";
import { AnimationKeyFrameEffectTiming } from "igniteui-webcomponents-core";
import { CanvasViewRenderer } from "igniteui-webcomponents-core";
import { truncate, intDivide, isNaN_ } from "igniteui-webcomponents-core";
import { CellContentHorizontalAlignment_$type } from "./CellContentHorizontalAlignment";
import { ElevationHelper } from "igniteui-webcomponents-core";
import { BaseDOMEventProxy } from "igniteui-webcomponents-core";
import { DeviceUtils } from "igniteui-webcomponents-core";
import { BrushUtil } from "igniteui-webcomponents-core";
import { GridFilterDialogOpeningEventArgs } from "./GridFilterDialogOpeningEventArgs";
import { AnimationKeyFrameProperty } from "igniteui-webcomponents-core";
import { GridFilterDialogFilterChangeEventArgs } from "./GridFilterDialogFilterChangeEventArgs";
import { ColumnFilterConditionGroup } from "./ColumnFilterConditionGroup";
import { Stack$1 } from "igniteui-webcomponents-core";
import { List$1 } from "igniteui-webcomponents-core";
import { GridFilterDialogViewModelRow } from "./GridFilterDialogViewModelRow";
import { GridFilterDialogViewModelGroupingLevel } from "./GridFilterDialogViewModelGroupingLevel";
import { GridFilterDialogViewModelGrouping } from "./GridFilterDialogViewModelGrouping";
import { ColumnComparisonFilterCondition } from "./ColumnComparisonFilterCondition";
import { ColumnComparisonConditionOperatorType_$type } from "./ColumnComparisonConditionOperatorType";
import { Geometry } from "igniteui-webcomponents-core";
import { NativeUI } from "igniteui-webcomponents-core";
import { FilterDialogRenderCompletedEventArgs } from "./FilterDialogRenderCompletedEventArgs";
import { stringIsNullOrEmpty } from "igniteui-webcomponents-core";
import { GridFilterDialogViewModelGroupingLevelCollection } from "./GridFilterDialogViewModelGroupingLevelCollection";
import { ObservableCollection$1 } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var GridFilterDialogView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridFilterDialogView, _super);
    function GridFilterDialogView(a) {
        var _this = _super.call(this) || this;
        _this.b = null;
        _this.q = null;
        _this.ad = new Path();
        _this.j = 0;
        _this.i = 0;
        _this.o = null;
        _this.d = null;
        _this.m = null;
        _this.n = null;
        _this.p = null;
        _this.g = 0;
        _this.f = 0;
        _this.h = 1;
        _this.l = 0;
        _this.k = 0;
        _this.e = false;
        _this.c = null;
        _this.b = a;
        return _this;
    }
    GridFilterDialogView.prototype.aa = function () {
        if (this.j != this.l || this.i != this.k) {
            this.v();
            this.j = this.l;
            this.j = this.k;
            this.o.setStyleProperty("width", this.l.toString() + "px");
            this.o.setStyleProperty("height", this.k.toString() + "px");
        }
        var a = Math.round(this.b.af * this.h);
        var b = Math.round(this.b.af * this.h);
        if (this.g != a || this.f != b) {
            this.o.setAttribute("width", a.toString());
            this.o.setAttribute("height", b.toString());
            this.g = truncate(Math.round(a));
            this.f = truncate(Math.round(b));
        }
        this.z();
        this.ad._fill = this.b.bp != null ? this.b.bp : GridStyleRepository.az;
        if (this.d.d && this.h != 1) {
            this.d.z();
            this.d.aa(this.h, this.h);
        }
        this.d.k(0, 0, this.l, this.k);
        this.d.s(this.ad);
        if (this.d.d && this.h != 1) {
            this.d.y();
        }
        this.b.bb();
    };
    GridFilterDialogView.prototype.v = function () {
        this.b.a6(this.l, this.k, this.ad);
    };
    GridFilterDialogView.prototype.u = function () {
        if (KeyFrameAnimationFactory.h == null) {
            KeyFrameAnimationFactory.h = this.m;
        }
    };
    GridFilterDialogView.prototype.a = function (a) {
        return new AnimationKeyFrameEffect(0, this.m.rootWrapper, 0, null, a);
    };
    GridFilterDialogView.prototype.x = function (a, b, c) {
        if (a == null) {
            if (this.o != null) {
                this.o.destroy();
            }
            this.o = null;
            this.m = null;
            this.n = null;
            this.d = null;
            return;
        }
        this.h = (isNaN_(this.b.ae) ? this.b.ad : this.b.ae);
        var d = a;
        this.m = d;
        this.n = c;
        this.p = b;
        this.m.rootWrapper.addClass("ig-filter-icon");
        this.m.rootWrapper.setStyleProperty("cursor", "pointer");
        this.q = this.m.rootWrapper;
        var e = this.h;
        var f = Math.round(d.rootWrapper.width());
        var g = Math.round(d.rootWrapper.height());
        var h = this.b.af * e;
        var i = this.b.af * e;
        var j = this.m.createElement("canvas");
        j.setStyleProperty("position", "absolute");
        j.setStyleProperty("left", "0");
        j.setStyleProperty("top", "0");
        this.m.append(j);
        this.g = truncate(Math.round(h));
        this.f = truncate(Math.round(i));
        j.setAttribute("width", this.g.toString());
        j.setAttribute("height", this.g.toString());
        j.setStyleProperty("width", f.toString() + "px");
        j.setStyleProperty("height", g.toString() + "px");
        this.z();
        j.listen("mousedown", runOn(this, this.r));
        j.listen("mouseup", runOn(this, this.s));
        this.l = f;
        this.k = g;
        this.o = j;
        var k = this.m.get2DCanvasContext(this.o);
        this.d = new RenderingContext(new CanvasViewRenderer(), k);
        if (isNaN_(this.b.ae)) {
            this.b.ad = window.devicePixelRatio;
            this.h = this.b.ad;
        }
        this.aa();
    };
    GridFilterDialogView.prototype.z = function () {
        if (this.b.k == this.b.l) {
            this.m.rootWrapper.setStyleProperty("position", "relative");
            this.m.rootWrapper.setStyleProperty("left", "0px");
            this.m.rootWrapper.setStyleProperty("top", "0px");
            return;
        }
        this.m.rootWrapper.setStyleProperty("position", "absolute");
        if (this.b.l == 2) {
            this.m.rootWrapper.setStyleProperty("left", "unset");
            this.m.rootWrapper.setStyleProperty("right", this.b.aj + "px");
        }
        else {
            this.m.rootWrapper.setStyleProperty("left", this.b.ai + "px");
        }
        var a = intDivide(this.p.height(), 2) - (this.k / 2);
        this.m.rootWrapper.setStyleProperty("top", a + "px");
    };
    GridFilterDialogView.prototype.r = function (a) {
    };
    GridFilterDialogView.prototype.s = function (a) {
        if (a.button == 2) {
            return;
        }
        if (!this.e) {
            this.b.bd();
        }
        else {
            this.b.a2();
        }
    };
    GridFilterDialogView.prototype.ab = function () {
        this.aa();
    };
    GridFilterDialogView.prototype.y = function (a, b) {
        if (isNaN_(this.b.ae)) {
            this.b.ad = window.devicePixelRatio;
            this.h = this.b.ad;
        }
        this.l = a;
        this.k = b;
        this.aa();
    };
    GridFilterDialogView.prototype.w = function () {
        if (isNaN_(this.b.ae)) {
            this.b.ad = window.devicePixelRatio;
            if (this.h != this.b.ad) {
                this.h = this.b.ad;
                this.aa();
                return;
            }
        }
        this.z();
    };
    GridFilterDialogView.prototype.ac = function (a) {
        this.e = true;
        var b = new GridFilterDialogPanel(this.b, this.o, this.m, this.n);
        b.a = this.b;
        b.s(a);
        this.c = b;
    };
    GridFilterDialogView.prototype.t = function () {
        this.e = false;
        if (this.c != null) {
            this.c.k();
            this.c.l();
            this.c = null;
        }
    };
    GridFilterDialogView.$t = markType(GridFilterDialogView, 'GridFilterDialogView');
    return GridFilterDialogView;
}(Base));
export { GridFilterDialogView };
/**
 * @hidden
 */
var GridFilterDialogPanel = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridFilterDialogPanel, _super);
    function GridFilterDialogPanel(a, b, c, d) {
        var _this = _super.call(this) || this;
        _this.b = null;
        _this.j = null;
        _this.d = null;
        _this.i = 264;
        _this.a = null;
        _this.h = null;
        _this.f = null;
        _this.e = null;
        _this.g = null;
        _this.b = a;
        var e = c.createElement("div");
        var f = c.getSubRenderer(e);
        e.setStyleProperty("position", "absolute");
        e.setStyleProperty("width", _this.i + "px");
        e.setStyleProperty("top", "0px");
        e.setStyleProperty("left", "0px");
        e.setStyleProperty("display", "none");
        e.setStyleProperty("z-index", "10000");
        e.setStyleProperty("background-color", "#fff");
        e.setStyleProperty("border-radius", "3px");
        e.setStyleProperty("overflow", "auto");
        var g = ElevationHelper.e(12, _this.b.bo, _this.b.bn, _this.b.bm);
        e.setStyleProperty("boxShadow", g);
        e.listen("mousedown", runOn(_this, _this.n));
        _this.onDocumentKeyDown = _this.onDocumentKeyDown.bind(_this);
        _this.onDocumentMouseClick = _this.onDocumentMouseClick.bind(_this);
        _this.h = b;
        _this.f = f;
        _this.g = e;
        _this.e = d;
        return _this;
    }
    GridFilterDialogPanel.prototype.n = function (a) {
        a.stopPropagation();
    };
    GridFilterDialogPanel.prototype.onDocumentKeyDown = function (a) {
        if (BaseDOMEventProxy.cv(a) == 8) {
            this.b.a2();
        }
    };
    GridFilterDialogPanel.prototype.onDocumentMouseClick = function (e_) {
        var filterIconCanvas_ = this.b.aq();
        var a = (e_.srcElement === filterIconCanvas_ || e_.target === filterIconCanvas_);
        if (!a) {
            this.b.a2();
        }
    };
    GridFilterDialogPanel.prototype.onFilterApplyClick = function () {
        this.b.a2();
    };
    GridFilterDialogPanel.prototype.onFilterCancelClick = function () {
        this.b.a2();
    };
    GridFilterDialogPanel.prototype.s = function (a) {
        var _this = this;
        this.m();
        this.g.setStyleProperty("display", "block");
        this.f.appendToBody(this.g);
        if (this.j == null) {
            this.e.getPortal(this.g, "GridColumnOptions", function (b) {
                _this.d = b;
                var comp_ = b.componentRef;
                var col_ = a;
                var displayDensity_ = a.grid.fl;
                var buttonDensity_ = GridFilterDialogPanel.c(displayDensity_, true);
                var filterListDensity_ = GridFilterDialogPanel.c(displayDensity_, true);
                _this.j = comp_.i;
                var options_ = _this.j;
                options_.column = col_;
                options_.density = displayDensity_;
                options_.buttonDensity = buttonDensity_;
                options_.summaryListDensity = filterListDensity_;
                options_.filterListDensity = filterListDensity_;
                options_.filterApplyButtonClick = delegateCombine(options_.filterApplyButtonClick, runOn(_this, _this.onFilterApplyClick));
                options_.filterCancelButtonClick = delegateCombine(options_.filterCancelButtonClick, runOn(_this, _this.onFilterCancelClick));
            }, false);
        }
        document.addEventListener("keydown", this.onDocumentKeyDown, false);
        document.addEventListener("mousedown", this.onDocumentMouseClick, false);
    };
    GridFilterDialogPanel.prototype.m = function () {
        var a = this.h.width();
        var filterIcon_ = this.h.getNativeElement();
        var boundingRect_ = filterIcon_.getBoundingClientRect();
        var b = (boundingRect_.left);
        var c = (boundingRect_.right);
        var gridDiv_ = this.e.rootWrapper.getNativeElement();
        var gridBoundingRect_ = gridDiv_.getBoundingClientRect();
        var d = (gridBoundingRect_.right);
        var e = (window.innerWidth);
        var f = true;
        if (b > e - this.i - 10) {
            f = false;
        }
        if (f) {
            this.g.setStyleProperty("left", this.h.getOffset().left + "px");
        }
        else {
            var g = Math.max(10, this.h.getOffset().left - (this.i - a));
            this.g.setStyleProperty("left", g + "px");
        }
        this.g.setStyleProperty("top", (this.h.getOffset().top + this.h.outerHeight()) + "px");
    };
    GridFilterDialogPanel.prototype.k = function () {
        document.removeEventListener("keydown", this.onDocumentKeyDown, false);
        document.removeEventListener("mousedown", this.onDocumentMouseClick, false);
        var options_ = this.j;
        options_.filterApplyButtonClick = delegateRemove(options_.filterApplyButtonClick, runOn(this, this.onFilterApplyClick));
        options_.filterCancelButtonClick = delegateRemove(options_.filterCancelButtonClick, runOn(this, this.onFilterCancelClick));
        ;
        options_.column = null;
        this.g.setStyleProperty("display", "none");
        this.g.remove();
    };
    GridFilterDialogPanel.prototype.l = function () {
        this.f.destroy();
        this.g.unlistenAll();
        this.j = null;
        this.g = null;
        if (this.d != null) {
            this.d.destroy();
        }
    };
    GridFilterDialogPanel.c = function (a, b) {
        switch (a) {
            case 1: return b ? 2 : 1;
            case 2: return b ? 3 : 1;
            case 3: return b ? 3 : 2;
            case 0: return a;
            default: return a;
        }
    };
    GridFilterDialogPanel.$t = markType(GridFilterDialogPanel, 'GridFilterDialogPanel');
    return GridFilterDialogPanel;
}(Base));
export { GridFilterDialogPanel };
/**
 * @hidden
 */
var GridFilterDialog = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridFilterDialog, _super);
    function GridFilterDialog() {
        var _this = _super.call(this) || this;
        _this.am = null;
        _this.w = true;
        _this.propertyChanged = null;
        _this.ab = NaN;
        _this.aa = 1;
        _this.j = 2;
        _this.i = 0;
        _this.ag = 0;
        _this.ah = 0;
        _this.bl = null;
        _this.ac = DeviceUtils.g(24);
        _this.bo = null;
        _this.bn = null;
        _this.bm = null;
        _this.m = null;
        _this.u = null;
        _this.v = false;
        _this.f = null;
        _this.dialogOpening = null;
        _this.filterChanging = null;
        _this.filterChanged = null;
        _this.r = null;
        _this.renderCompleted = null;
        _this.r = new GridFilterDialogView(_this);
        _this.bo = BrushUtil.g(66, 0, 0, 0);
        _this.bn = BrushUtil.g(30, 0, 0, 0);
        _this.bm = BrushUtil.g(20, 0, 0, 0);
        return _this;
    }
    Object.defineProperty(GridFilterDialog.prototype, "an", {
        get: function () {
            return this.am;
        },
        set: function (a) {
            this.am = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "x", {
        get: function () {
            return this.w;
        },
        set: function (a) {
            var b = this.w;
            this.w = a;
            if (b != this.w) {
                this.ba("IsAnimationEnabled", b, this.w);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "ae", {
        get: function () {
            return this.ab;
        },
        set: function (a) {
            var b = this.ab;
            this.ab = a;
            this.ba("PixelScalingRatio", b, this.ab);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "ad", {
        get: function () {
            return this.aa;
        },
        set: function (a) {
            var b = this.aa;
            this.aa = a;
            this.ba("ActualPixelScalingRatio", b, this.aa);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "l", {
        get: function () {
            return this.j;
        },
        set: function (a) {
            var b = this.j;
            this.j = a;
            if (b != this.j) {
                this.ba("IconHorizontalAlignment", enumGetBox(CellContentHorizontalAlignment_$type, b), enumGetBox(CellContentHorizontalAlignment_$type, this.j));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "k", {
        get: function () {
            return this.i;
        },
        set: function (a) {
            var b = this.i;
            this.i = a;
            if (b != this.i) {
                this.ba("HeaderTextALignment", enumGetBox(CellContentHorizontalAlignment_$type, b), enumGetBox(CellContentHorizontalAlignment_$type, this.i));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "ai", {
        get: function () {
            return this.ag;
        },
        set: function (a) {
            var b = this.ag;
            this.ag = a;
            if (b != this.ag) {
                this.ba("CellPaddingLeft", b, this.ag);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "aj", {
        get: function () {
            return this.ah;
        },
        set: function (a) {
            var b = this.ah;
            this.ah = a;
            if (b != this.ah) {
                this.ba("CellPaddingRight", b, this.ah);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "bp", {
        get: function () {
            return this.bl;
        },
        set: function (a) {
            var b = this.bl;
            this.bl = a;
            if (b != this.bl) {
                this.ba("IconColor", b, this.bl);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "af", {
        get: function () {
            return this.ac;
        },
        set: function (a) {
            var b = this.ac;
            this.ac = a;
            if (b != this.ac) {
                this.ba("ViewSize", b, this.ac);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridFilterDialog.prototype, "y", {
        get: function () {
            return this.r.e;
        },
        enumerable: true,
        configurable: true
    });
    GridFilterDialog.prototype.ba = function (a, b, c) {
        this.be(a, b, c);
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
    };
    GridFilterDialog.prototype.be = function (a, b, c) {
        switch (a) {
            case "PixelScalingRatio":
                this.ad = this.ae;
                break;
            case "ActualPixelScalingRatio":
                this.r.ab();
                break;
            case "IconHorizontalAlignment":
            case "IconColor":
            case "HeaderTextALignment":
            case "CellPaddingLeft":
            case "CellPaddingRight":
            case "ViewSize":
                this.r.ab();
                break;
        }
    };
    GridFilterDialog.prototype.bf = function (a, b, c) {
        this.r.x(a, b, c);
    };
    GridFilterDialog.prototype.bd = function () {
        var a = null;
        var b = 0;
        if (this.dialogOpening != null) {
            var c = new GridFilterDialogOpeningEventArgs();
            this.dialogOpening(this, c);
            this.m = c.a;
        }
        this.bj(this.m);
        if (this.m != null) {
            var d = this.m;
            d.propertyChanged = delegateCombine(d.propertyChanged, runOn(this, this.a3));
        }
    };
    GridFilterDialog.prototype.a3 = function (a, b) {
        switch (b.propertyName) {
            case "IsHidden":
                this.a2();
                break;
        }
    };
    GridFilterDialog.prototype.bj = function (a) {
        this.r.ac(a);
    };
    GridFilterDialog.prototype.a9 = function () {
    };
    GridFilterDialog.prototype.a4 = function () {
        this.r.u();
        if (this.u == null) {
            var a = new AnimationKeyFrameEffectTiming();
            a.g = 200;
            a.b = 0;
            this.u = KeyFrameAnimationFactory.f.c(this.r.a(a).m(new AnimationKeyFrameProperty(1, 0)).m(new AnimationKeyFrameProperty(1, 1)));
        }
    };
    GridFilterDialog.prototype.bi = function () {
        var _this = this;
        if (this.filterChanged != null) {
            this.filterChanged(this, ((function () {
                var $ret = new GridFilterDialogFilterChangeEventArgs();
                $ret.a = _this.f;
                return $ret;
            })()));
        }
    };
    GridFilterDialog.prototype.bh = function () {
        if (this.filterChanged != null) {
            this.filterChanged(this, ((function () {
                var $ret = new GridFilterDialogFilterChangeEventArgs();
                $ret.a = null;
                return $ret;
            })()));
        }
    };
    GridFilterDialog.prototype.bg = function (a, b) {
        var c = this.e(a);
        if (b) {
            if (this.filterChanged != null) {
                this.filterChanged(this, ((function () {
                    var $ret = new GridFilterDialogFilterChangeEventArgs();
                    $ret.a = c;
                    return $ret;
                })()));
            }
        }
        else {
            if (this.filterChanging != null) {
                this.filterChanging(this, ((function () {
                    var $ret = new GridFilterDialogFilterChangeEventArgs();
                    $ret.a = c;
                    return $ret;
                })()));
            }
        }
    };
    GridFilterDialog.prototype.e = function (a) {
        var b = new ColumnFilterConditionGroup();
        b.f = a.k;
        var c = new Stack$1(ColumnFilterConditionGroup.$);
        var d = 0;
        var e = b;
        for (var f = 0; f < a.f.count; f++) {
            var g = this.h(d, c, a, f);
            while (g != null) {
                e.h(g);
                e = g;
                d++;
                g = this.h(d, c, a, f);
            }
            g = this.g(d, c, a, f);
            while (g != null) {
                e = g;
                d--;
                g = this.g(d, c, a, f);
            }
            if (e == null) {
                e = b;
            }
            if (this.z(a, a.f._inner[f])) {
                continue;
            }
            e.h(this.d(a.f._inner[f]));
        }
        if (b.g == 0) {
            return null;
        }
        return b;
    };
    GridFilterDialog.prototype.z = function (a, b) {
        var c = 0;
        for (var d = 0; d < b.e.length; d++) {
            if (b.e[d] == b.l) {
                c = d;
                break;
            }
        }
        if (b.d[c] > 0 && b.i == null) {
            return true;
        }
        if (a.a != 0 && b.d[c] > 0 && typeof b.i === 'string' && stringIsNullOrEmpty(b.i)) {
            return true;
        }
        return false;
    };
    GridFilterDialog.prototype.g = function (a, b, c, d) {
        var e = this.al(c, d);
        if (a > e) {
            b.e();
            return b.d();
        }
        return null;
    };
    GridFilterDialog.prototype.al = function (a, b) {
        var c = a.c(b);
        if (c == null) {
            return 0;
        }
        return a.e.indexOf(c);
    };
    GridFilterDialog.prototype.h = function (a, b, c, d) {
        var e = this.al(c, d);
        if (a < e) {
            var f = c.b(d);
            var g = new ColumnFilterConditionGroup();
            g.f = f.a;
            b.h(g);
            return g;
        }
        return null;
    };
    GridFilterDialog.prototype.d = function (a) {
        var b = new ColumnComparisonFilterCondition();
        b.e = this.c(a.l);
        b.j = a.i;
        return b;
    };
    GridFilterDialog.prototype.c = function (a) {
        return EnumUtil.getEnumValue(ColumnComparisonConditionOperatorType_$type, EnumUtil.parse(ColumnComparisonConditionOperatorType_$type, a, true));
    };
    GridFilterDialog.prototype.bc = function (a) {
        this.bg(a, false);
    };
    GridFilterDialog.prototype.s = function (a, b) {
        var c = new GridFilterDialogViewModel();
        if (a != null) {
            this.a1(c, a, b);
        }
        else {
            var d = new GridFilterDialogViewModelRow();
            d.f = b;
            d.e = GridFilterDialog.a(b);
            d.d = GridFilterDialog.b(b);
            d.l = GridFilterDialog.au(b[0]);
            c.f.add(d);
        }
        return c;
    };
    GridFilterDialog.prototype.a1 = function (a, b, c) {
        if (b.b()) {
            var d = b;
            for (var e = 0; e < d.g; e++) {
                var f = d.item(e);
                this.a1(a, f, c);
            }
        }
        else {
            a.f.add(this.t(b, c));
        }
    };
    GridFilterDialog.prototype.t = function (a, b) {
        var c = new GridFilterDialogViewModelRow();
        c.l = GridFilterDialog.au(a.e);
        c.f = b;
        c.e = GridFilterDialog.a(b);
        c.i = GridFilterDialog.ao(GridFilterDialog.ak(a.e), a.e, a);
        c.j = GridFilterDialog.ap(GridFilterDialog.ak(a.e), a.e, a);
        c.d = GridFilterDialog.b(b);
        return c;
    };
    GridFilterDialog.ak = function (a) {
        return ColumnComparisonFilterCondition.h(a);
    };
    GridFilterDialog.ao = function (a, b, c) {
        if (a == 0) {
            return "";
        }
        return c.j != null ? c.j.toString() : "";
    };
    GridFilterDialog.ap = function (a, b, c) {
        return "";
    };
    GridFilterDialog.b = function (a) {
        return ColumnComparisonFilterCondition.d(a);
    };
    GridFilterDialog.a = function (a) {
        var b = new Array(a.length);
        for (var c = 0; c < a.length; c++) {
            b[c] = EnumUtil.getName(ColumnComparisonConditionOperatorType_$type, a[c]);
        }
        return b;
    };
    GridFilterDialog.au = function (a) {
        return EnumUtil.getName(ColumnComparisonConditionOperatorType_$type, a);
    };
    GridFilterDialog.prototype.a8 = function (a, b) {
        this.r.y(a, b);
    };
    GridFilterDialog.prototype.a7 = function () {
        this.r.w();
    };
    GridFilterDialog.prototype.a6 = function (a, b, c) {
        var d = Geometry.a("M12 14c -1.1 0 -2 -0.9 -2 -2 s0.9 -2 2 -2 s2 0.9 2 2 S13.1 14 12 14 z M12 8c -1.1 0 -2 -0.9 -2 -2 s0.9 -2 2 -2 s2 0.9 2 2 S13.1 8 12 8z M12 16 c1.1 0 2 0.9 2 2s -0.9 2 -2 2 s-2 -0.9 -2 -2 S10.9 16 12 16z");
        c.ak = d;
        c._fill = this.bp == null ? GridStyleRepository.az : this.bp;
    };
    GridFilterDialog.prototype.bk = function () {
        var _this = this;
        this.v = false;
        if (NativeUI.e(this.r.q) == 1) {
            return;
        }
        if (this.x) {
            this.a4();
            if (this.u.playbackRate < 0) {
                this.u.reverse();
            }
            else {
                this.u.play();
            }
            this.u.finished.f(function (a) { return _this.u.commitStyles(); });
        }
        else {
            NativeUI.t(this.r.q, 1);
        }
    };
    GridFilterDialog.prototype.a5 = function () {
        var _this = this;
        this.v = true;
        if (!this.y) {
            if (this.x) {
                this.a4();
                if (this.u.playbackRate < 0) {
                    this.u.play();
                }
                else {
                    this.u.reverse();
                }
                this.u.finished.f(function (a) { return _this.u.commitStyles(); });
            }
            else {
                NativeUI.t(this.r.q, 0);
            }
            this.v = false;
        }
    };
    GridFilterDialog.prototype.a2 = function () {
        this.r.t();
        this.a9();
        if (this.v) {
            this.a5();
        }
        if (this.m != null) {
            var a = this.m;
            a.propertyChanged = delegateRemove(a.propertyChanged, runOn(this, this.a3));
            this.m = null;
        }
    };
    GridFilterDialog.prototype.aq = function () {
        return this.r.o.getNativeElement();
    };
    GridFilterDialog.prototype.bb = function () {
        if (this.renderCompleted != null) {
            this.renderCompleted(this, new FilterDialogRenderCompletedEventArgs());
        }
    };
    GridFilterDialog.$t = markType(GridFilterDialog, 'GridFilterDialog', Base.$, [INotifyPropertyChanged_$type]);
    return GridFilterDialog;
}(Base));
export { GridFilterDialog };
/**
 * @hidden
 */
var GridFilterDialogViewModel = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridFilterDialogViewModel, _super);
    function GridFilterDialogViewModel() {
        var _this = _super.call(this) || this;
        _this.a = 0;
        _this.e = null;
        _this.k = false;
        _this.m = 0;
        _this.f = null;
        _this.onModified = null;
        _this.k = false;
        _this.f = new GridFilterDialogViewModelRowCollection();
        _this.f.ae = _this;
        _this.e = new GridFilterDialogViewModelGroupingLevelCollection();
        _this.f.ag = runOn(_this, _this.u);
        var a = _this.f;
        a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.t));
        return _this;
    }
    GridFilterDialogViewModel.prototype.n = function () {
        var a = new GridFilterDialogViewModelRow();
        var b = ColumnComparisonFilterCondition.c(this.a);
        a.f = b;
        a.e = GridFilterDialog.a(b);
        a.d = GridFilterDialog.b(b);
        a.l = GridFilterDialog.au(b[0]);
        this.f.add(a);
    };
    GridFilterDialogViewModel.prototype.u = function (a) {
        if (this.onModified != null) {
            this.onModified(this);
        }
    };
    GridFilterDialogViewModel.prototype.t = function (a, b) {
        switch (b.action) {
            case 0:
                if (b.newItems != null) {
                    for (var c = 0; c < b.newItems.count; c++) {
                        var d = b.newItems.item(c);
                        this.q(c + b.newStartingIndex, d);
                    }
                }
                break;
            case 1:
                if (b.oldItems != null) {
                    for (var e = 0; e < b.oldItems.count; e++) {
                        this.r(b.oldStartingIndex);
                    }
                }
                break;
            case 2:
                if (b.oldItems != null) {
                    for (var f = 0; f < b.oldItems.count; f++) {
                        this.r(b.oldStartingIndex);
                    }
                }
                if (b.newItems != null) {
                    for (var g = 0; g < b.newItems.count; g++) {
                        var h = b.newItems.item(g);
                        this.q(g + b.newStartingIndex, b.newItems.item(g));
                    }
                }
                break;
            case 4:
                this.s();
                break;
        }
        if (this.onModified != null) {
            this.onModified(this);
        }
    };
    GridFilterDialogViewModel.prototype.r = function (a) {
        var b = this.c(a);
        if (b == null) {
            return;
        }
        var c = this.b(a);
        if (c == null) {
            return;
        }
        this.w(c, a);
        for (var d = b.indexOf(c) + 1; d < b.count; d++) {
            this.v(b._inner[d], -1);
        }
    };
    GridFilterDialogViewModel.prototype.w = function (a, b) {
        a.b--;
    };
    GridFilterDialogViewModel.prototype.s = function () {
        this.e.clear();
    };
    GridFilterDialogViewModel.prototype.q = function (a, b) {
        var c = this.c(a);
        if (c == null) {
            return;
        }
        var d = this.b(a);
        if (d == null) {
            return;
        }
        this.p(d, a);
        for (var e = c.indexOf(d) + 1; e < c.count; e++) {
            this.v(c._inner[e], +1);
        }
    };
    GridFilterDialogViewModel.prototype.v = function (a, b) {
        a.c += b;
        a.b -= b;
    };
    GridFilterDialogViewModel.prototype.p = function (a, b) {
        a.b++;
    };
    GridFilterDialogViewModel.prototype.b = function (a) {
        for (var b = this.e.count - 1; b >= 0; b--) {
            for (var c = 0; c < this.e._inner[b].count; c--) {
                if (this.e._inner[b]._inner[c].c <= a && this.e._inner[b]._inner[c].b >= a) {
                    return this.e._inner[b]._inner[c];
                }
            }
        }
        return null;
    };
    GridFilterDialogViewModel.prototype.c = function (a) {
        for (var b = this.e.count - 1; b >= 0; b--) {
            for (var c = 0; c < this.e._inner[b].count; c--) {
                if (this.e._inner[b]._inner[c].c <= a && this.e._inner[b]._inner[c].b >= a) {
                    return this.e._inner[b];
                }
            }
        }
        return null;
    };
    GridFilterDialogViewModel.prototype.h = function (a, b) {
        var c = this.d(a, b);
        if (this.i(c, a, b)) {
            if (this.e.count < this.m) {
                return true;
            }
            else {
                return false;
            }
        }
        return true;
    };
    GridFilterDialogViewModel.prototype.i = function (a, b, c) {
        if (a == null) {
            return false;
        }
        for (var d = 0; d < a.count; d++) {
            if (this.j(a._inner[d], b, c)) {
                return true;
            }
        }
        return false;
    };
    GridFilterDialogViewModel.prototype.j = function (a, b, c) {
        if (c > a.c || b > a.b) {
            return false;
        }
        return true;
    };
    GridFilterDialogViewModel.prototype.d = function (a, b) {
        if (this.e.count == 0) {
            return null;
        }
        for (var c = 0; c < this.e.count; c++) {
            if (!this.i(this.e._inner[c], a, b)) {
                return this.e._inner[c];
            }
        }
        return this.e._inner[this.e.count - 1];
    };
    GridFilterDialogViewModel.prototype.aa = function (a, b) {
        for (var c = 0; c < this.e.count; c++) {
            for (var d = 0; d < this.e._inner[c].count; d++) {
                if (this.e._inner[c]._inner[d].c == a && this.e._inner[c]._inner[d].b == b) {
                    this.e._inner[c].removeAt(d);
                    break;
                }
            }
        }
        this.x();
        if (this.onModified != null) {
            this.onModified(this);
        }
    };
    GridFilterDialogViewModel.prototype.x = function () {
        for (var a = this.e.count - 1; a >= 0; a--) {
            var b = new List$1(GridFilterDialogViewModelGrouping.$, 0);
            for (var c = 0; c < this.e._inner[a].count; c++) {
                var d = this.e._inner[a]._inner[c];
                if (a > 0) {
                    if (!this.i(this.e._inner[a - 1], d.c, d.b)) {
                        b.add(d);
                    }
                }
            }
            for (var e = 0; e < b.count; e++) {
                this.e._inner[a].remove(b._inner[e]);
                this.e._inner[a - 1].add(b._inner[e]);
            }
            if (this.e._inner[a].count == 0) {
                this.e.removeAt(a);
            }
        }
        this.y();
    };
    GridFilterDialogViewModel.prototype.y = function () {
        for (var a = this.e.count - 1; a >= 0; a--) {
            var b = new List$1(GridFilterDialogViewModelGrouping.$, 0);
            for (var c = 0; c < this.e._inner[a].count; c++) {
                b.add(this.e._inner[a]._inner[c]);
            }
            b.aa(function (d, e) { return Base.compareSimple(d.c, e.c); });
            this.e._inner[a].clear();
            for (var d = 0; d < this.e._inner[a].count; d++) {
                this.e._inner[a].add(b._inner[d]);
            }
        }
    };
    GridFilterDialogViewModel.prototype.l = function (a, b) {
        for (var c = 0; c < this.e.count; c++) {
            for (var d = 0; d < this.e._inner[c].count; d++) {
                if (this.e._inner[c]._inner[d].c == a && this.e._inner[c]._inner[d].b == b) {
                    return true;
                }
            }
        }
        return false;
    };
    GridFilterDialogViewModel.prototype.z = function (a, b) {
        for (var c = 0; c < this.e.count; c++) {
            for (var d = 0; d < this.e._inner[c].count; d++) {
                if (this.e._inner[c]._inner[d].c == a && this.e._inner[c]._inner[d].b == b) {
                    this.e._inner[c]._inner[d].a = !this.e._inner[c]._inner[d].a;
                }
            }
        }
        if (this.onModified != null) {
            this.onModified(this);
        }
    };
    GridFilterDialogViewModel.prototype.o = function (a, b, c) {
        if (!this.h(a, b)) {
            return;
        }
        var d = this.d(a, b);
        var e = d;
        if (this.i(d, a, b)) {
            this.e.add(new GridFilterDialogViewModelGroupingLevel());
            e = this.d(a, b);
        }
        e.add(((function () {
            var $ret = new GridFilterDialogViewModelGrouping();
            $ret.c = a;
            $ret.b = b;
            $ret.a = c;
            return $ret;
        })()));
        this.y();
        if (this.onModified != null) {
            this.onModified(this);
        }
    };
    GridFilterDialogViewModel.$t = markType(GridFilterDialogViewModel, 'GridFilterDialogViewModel');
    return GridFilterDialogViewModel;
}(Base));
export { GridFilterDialogViewModel };
/**
 * @hidden
 */
var GridFilterDialogViewModelRowCollection = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridFilterDialogViewModelRowCollection, _super);
    function GridFilterDialogViewModelRowCollection() {
        var _this = _super.call(this, GridFilterDialogViewModelRow.$, 0) || this;
        _this.ae = null;
        _this.af = null;
        _this.collectionChanged = delegateCombine(_this.collectionChanged, runOn(_this, _this.ah));
        return _this;
    }
    GridFilterDialogViewModelRowCollection.prototype.ah = function (a, b) {
        if (b.oldItems != null) {
            for (var c = 0; c < b.oldItems.count; c++) {
                var d = b.oldItems.item(c);
                d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.ai));
            }
        }
        if (b.newItems != null) {
            for (var e = 0; e < b.newItems.count; e++) {
                var f = b.newItems.item(e);
                f.propertyChanged = delegateCombine(f.propertyChanged, runOn(this, this.ai));
            }
        }
    };
    GridFilterDialogViewModelRowCollection.prototype.ai = function (a, b) {
        if (this.af != null) {
            this.af(this.ae);
        }
    };
    Object.defineProperty(GridFilterDialogViewModelRowCollection.prototype, "ag", {
        get: function () {
            return this.af;
        },
        set: function (a) {
            this.af = a;
        },
        enumerable: true,
        configurable: true
    });
    GridFilterDialogViewModelRowCollection.$t = markType(GridFilterDialogViewModelRowCollection, 'GridFilterDialogViewModelRowCollection', ObservableCollection$1.$.specialize(GridFilterDialogViewModelRow.$));
    return GridFilterDialogViewModelRowCollection;
}(ObservableCollection$1));
export { GridFilterDialogViewModelRowCollection };
//# sourceMappingURL=GridFilterDialogView_combined.js.map
