/*
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, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, runOn, delegateRemove, delegateCombine, enumGetBox, fromEnum } from "igniteui-webcomponents-core";
import { SRProvider } from "igniteui-webcomponents-core";
import { BaseControlTheme_$type } from "igniteui-webcomponents-core";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { BrushUtil } from "igniteui-webcomponents-core";
import { ObservableCollection$1 } from "igniteui-webcomponents-core";
import { ColumnPinningInfo } from "./ColumnPinningInfo";
import { stringIsNullOrWhiteSpace } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var ColumnPinningView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ColumnPinningView, _super);
    function ColumnPinningView() {
        var _this = _super.call(this) || this;
        _this.c = null;
        _this.a = null;
        _this.b = null;
        return _this;
    }
    ColumnPinningView.prototype.f = function () {
    };
    ColumnPinningView.prototype.e = function (a) {
        if (a == null) {
            this.b = null;
            return;
        }
        this.b = a;
        var b = Math.round(a.rootWrapper.width());
        var c = Math.round(a.rootWrapper.height());
        this.b.rootWrapper.setStyleProperty("position", "relative");
        this.g();
        this.c = this.b.rootWrapper.getChildAt(0);
        this.c.setStyleProperty("margin", "4px 0px 4px 0px");
        this.i();
        this.h();
    };
    ColumnPinningView.prototype.g = function () {
        if (this.b != null) {
            this.b.rootWrapper.setStyleProperty("background-color", this.a.an._fill);
        }
    };
    ColumnPinningView.prototype.i = function () {
        if (this.c != null && this.a.v != null) {
            this.c.setText(this.a.v);
            this.c.setStyleProperty("font", "16px \"Segoe UI\", Verdana");
        }
        this.j();
        this.k();
        this.h();
    };
    ColumnPinningView.prototype.j = function () {
        if (this.c != null && this.a.ao != null) {
            this.c.setStyleProperty("color", this.a.ao._fill);
        }
    };
    ColumnPinningView.prototype.k = function () {
        if (this.c != null && this.a.j != null) {
            this.c.setStyleProperty("font", this.a.j.fontString);
        }
    };
    ColumnPinningView.prototype.h = function () {
        if (this.b != null) {
            var a = this.b.rootWrapper.getChildAt(1);
            a.setStyleProperty("width", "100%");
            if (this.a.v != null) {
                a.setStyleProperty("height", "calc(100% - 25px");
            }
            else {
                a.setStyleProperty("height", "calc(100% - 5px");
            }
        }
    };
    ColumnPinningView.prototype.d = function () {
    };
    ColumnPinningView.$t = markType(ColumnPinningView, 'ColumnPinningView');
    return ColumnPinningView;
}(Base));
export { ColumnPinningView };
/**
 * @hidden
 */
var ColumnPinning = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ColumnPinning, _super);
    function ColumnPinning() {
        var _this = _super.call(this) || this;
        _this.c = null;
        _this.h = null;
        _this.propertyChanged = null;
        _this.m = false;
        _this.k = null;
        _this.a = null;
        _this.o = null;
        _this.i = null;
        _this.am = BrushUtil.g(255, 0, 153, 255);
        _this.n = null;
        _this.d = 1;
        _this.f = 2;
        _this.al = BrushUtil.g(255, 248, 248, 248);
        _this.m = false;
        var a = new ColumnPinningView();
        a.a = _this;
        _this.c = a;
        _this.c.f();
        return _this;
    }
    ColumnPinning.prototype.ak = function (a) {
        if (this.h != null) {
            this.h.updateHrMargin(a);
        }
    };
    ColumnPinning.prototype.notifySizeChanged = function () {
        this.c.d();
    };
    ColumnPinning.prototype.destroy = function () {
        if (this.h != null) {
            var a = this.h;
            a.checkedChanged = delegateRemove(a.checkedChanged, runOn(this, this.ae));
        }
        this.provideContainer(null, null);
        if (this.a != null) {
            var b = this.a.actualColumns;
            b.collectionChanged = delegateRemove(b.collectionChanged, runOn(this, this.z));
            var c = this.a;
            c.columnPinnedChanged = delegateRemove(c.columnPinnedChanged, runOn(this, this.aj));
        }
    };
    ColumnPinning.prototype.provideContainer = function (a, b) {
        this.h = b;
        if (this.h != null) {
            var c = this.h;
            c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.ae));
        }
        this.aa();
        this.c.e(a);
    };
    Object.defineProperty(ColumnPinning.prototype, "l", {
        get: function () {
            if (this.k == null) {
                this.k = new SRProvider(this.c.b);
                this.k.cb("DataGrid");
            }
            return this.k;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnPinning.prototype, "b", {
        get: function () {
            return this.a;
        },
        set: function (a) {
            var b = this.a;
            this.a = a;
            if (b != this.a) {
                this.ad("TargetGrid", b, this.a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnPinning.prototype, "v", {
        get: function () {
            return this.o;
        },
        set: function (a) {
            var b = this.o;
            this.o = a;
            if (b != this.o) {
                this.ad("Title", b, this.o);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnPinning.prototype, "j", {
        get: function () {
            return this.i;
        },
        set: function (a) {
            var b = this.i;
            this.i = a;
            if (b != this.i) {
                this.ad("TitleStyle", b, this.i);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnPinning.prototype, "ao", {
        get: function () {
            return this.am;
        },
        set: function (a) {
            var b = this.am;
            this.am = a;
            if (b != this.am) {
                this.ad("TitleColor", b, this.am);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnPinning.prototype, "s", {
        get: function () {
            return this.n != null ? this.n : !stringIsNullOrWhiteSpace(this.l.b1("Filter_Columns_List")) ? this.l.b1("Filter_Columns_List") : "Filter columns list ...";
        },
        set: function (a) {
            var b = this.n;
            this.n = a;
            if (b != this.n) {
                this.ad("FilterPlaceholderText", b, this.n);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnPinning.prototype, "e", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            var b = this.d;
            this.d = a;
            if (b != this.d) {
                this.ad("BaseTheme", enumGetBox(BaseControlTheme_$type, b), enumGetBox(BaseControlTheme_$type, this.d));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnPinning.prototype, "g", {
        get: function () {
            return this.f;
        },
        set: function (a) {
            var b = this.f;
            this.f = a;
            if (b != this.f) {
                this.ad("Density", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.f));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnPinning.prototype, "an", {
        get: function () {
            return this.al;
        },
        set: function (a) {
            var b = this.al;
            this.al = a;
            if (b != this.al) {
                this.ad("BackgroundColor", b, this.al);
            }
        },
        enumerable: true,
        configurable: true
    });
    ColumnPinning.prototype.ad = function (a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        this.af(a, b, c);
    };
    ColumnPinning.prototype.af = function (a, b, c) {
        switch (a) {
            case "TargetGrid":
                if (b != null) {
                    var d = b.actualColumns;
                    d.collectionChanged = delegateRemove(d.collectionChanged, runOn(this, this.z));
                    var e = b;
                    e.columnPinnedChanged = delegateRemove(e.columnPinnedChanged, runOn(this, this.aj));
                }
                if (this.a != null) {
                    var f = this.a.actualColumns;
                    f.collectionChanged = delegateCombine(f.collectionChanged, runOn(this, this.z));
                    var g = this.a;
                    g.columnPinnedChanged = delegateCombine(g.columnPinnedChanged, runOn(this, this.aj));
                }
                this.aa();
                break;
            case "Title":
                this.c.i();
                break;
            case "TitleStyle":
                this.c.k();
                break;
            case "TitleColor":
                this.c.j();
                break;
            case "FilterPlaceholderText":
                if (this.h != null) {
                    this.h.a6 = this.s;
                }
                break;
            case "BaseTheme":
                this.ai();
                break;
            case "Density":
                this.ah();
                break;
            case "BackgroundColor":
                if (this.h != null) {
                    this.h.cr = this.an;
                }
                this.c.g();
                break;
        }
    };
    ColumnPinning.prototype.ai = function () {
        if (this.h != null) {
            this.h.l = this.e;
        }
    };
    ColumnPinning.prototype.ah = function () {
        if (this.h != null) {
            this.h.n = this.g;
        }
    };
    ColumnPinning.prototype.aj = function (a, b) {
        if (this.m == false) {
            this.aa();
        }
        this.m = false;
    };
    ColumnPinning.prototype.z = function (a, b) {
        this.aa();
    };
    ColumnPinning.prototype.aa = function () {
        var e_1, _a;
        if (this.a != null && this.h != null) {
            this.h.l = this.e;
            this.h.n = this.g;
            this.h.cr = this.an;
            var a = void 0;
            var b = new ObservableCollection$1(ColumnPinningInfo.$, 0);
            try {
                for (var _b = tslib_1.__values(fromEnum(this.a.actualColumns)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var c = _c.value;
                    a = new ColumnPinningInfo();
                    var d = c.h4;
                    if (c.h8 != null) {
                        d = c.h8;
                    }
                    a.columnName = d;
                    if (c.fk == 1) {
                        a.isPinned = true;
                    }
                    else {
                        a.isPinned = false;
                    }
                    b.add(a);
                }
            }
            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.h.ao = false;
            if (this.s != null) {
                this.h.a6 = this.s;
            }
            this.h.itemsSource = b;
            var e = "";
            var f = "";
            e = "columnName";
            f = "isPinned";
            this.h.bj = f;
            this.h.a2 = e;
        }
    };
    ColumnPinning.prototype.ae = function (a, b) {
        this.m = true;
        var c = this.h.h.actualDataSource.getItemAtIndex(b.b);
        var d = this.a.actualColumns.count;
        for (var e = 0; e < d; e++) {
            if (this.a.actualColumns._inner[e].h4 == c.columnName || this.a.actualColumns._inner[e].il == c.columnName || this.a.actualColumns._inner[e].h8 == c.columnName) {
                if (this.a.actualColumns._inner[e].fk == 0) {
                    this.a.actualColumns._inner[e].fk = 1;
                }
                else if (this.a.actualColumns._inner[e].fk == 2) {
                    this.a.actualColumns._inner[e].fk = 1;
                }
                else {
                    this.a.actualColumns._inner[e].fk = 0;
                }
                break;
            }
        }
    };
    ColumnPinning.$t = markType(ColumnPinning, 'ColumnPinning', Base.$, [INotifyPropertyChanged_$type]);
    return ColumnPinning;
}(Base));
export { ColumnPinning };
//# sourceMappingURL=ColumnPinningView_combined.js.map
