var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Directive, Input } from '@angular/core';
import { ElCdkColumnDef } from '../cdk/table/type-mappings';
import { EL_SORT_HEADER_COLUMN_DEF, ElColumnDefDirective } from '../cdk/table/cell';
/**
 * Column definition for the tree-grid.
 * Defines a set of cells available for a table column.
 */
var ElTreeGridColumnDefDirective = /** @class */ (function (_super) {
    __extends(ElTreeGridColumnDefDirective, _super);
    function ElTreeGridColumnDefDirective() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.hideOnValue = null;
        _this.showOnValue = null;
        return _this;
    }
    ElTreeGridColumnDefDirective_1 = ElTreeGridColumnDefDirective;
    Object.defineProperty(ElTreeGridColumnDefDirective.prototype, "hideOn", {
        /**
         * Amount of pixels of viewport at which column should be hidden.
         * type number
         */
        get: function () {
            return this.hideOnValue;
        },
        set: function (value) {
            this.hideOnValue = !value && value !== 0
                ? null
                : parseInt(value, 10);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElTreeGridColumnDefDirective.prototype, "showOn", {
        /**
         * Amount of pixels of viewport at which column should be shown.
         * type number
         */
        get: function () {
            return this.showOnValue;
        },
        set: function (value) {
            this.showOnValue = !value && value !== 0
                ? null
                : parseInt(value, 10);
        },
        enumerable: true,
        configurable: true
    });
    ElTreeGridColumnDefDirective.prototype.ngOnChanges = function () {
        if (this.hideOn != null && this.showOn != null) {
            throw new Error("hideOn and showOn are mutually exclusive and can't be used simultaneously.");
        }
    };
    ElTreeGridColumnDefDirective.prototype.shouldHide = function (width) {
        return !this.shouldShow(width);
    };
    ElTreeGridColumnDefDirective.prototype.shouldShow = function (width) {
        if (this.hideOn == null && this.showOn == null) {
            return true;
        }
        if (this.hideOn != null) {
            return width > this.hideOn;
        }
        return width >= this.showOn;
    };
    var ElTreeGridColumnDefDirective_1;
    __decorate([
        Input('elTreeGridColumnDef'),
        __metadata("design:type", String)
    ], ElTreeGridColumnDefDirective.prototype, "name", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Number),
        __metadata("design:paramtypes", [Number])
    ], ElTreeGridColumnDefDirective.prototype, "hideOn", null);
    __decorate([
        Input(),
        __metadata("design:type", Number),
        __metadata("design:paramtypes", [Number])
    ], ElTreeGridColumnDefDirective.prototype, "showOn", null);
    ElTreeGridColumnDefDirective = ElTreeGridColumnDefDirective_1 = __decorate([
        Directive({
            selector: '[elTreeGridColumnDef]',
            providers: [
                { provide: ElCdkColumnDef, useExisting: ElTreeGridColumnDefDirective_1 },
                { provide: EL_SORT_HEADER_COLUMN_DEF, useExisting: ElTreeGridColumnDefDirective_1 },
            ],
        })
    ], ElTreeGridColumnDefDirective);
    return ElTreeGridColumnDefDirective;
}(ElColumnDefDirective));
export { ElTreeGridColumnDefDirective };
//# sourceMappingURL=tree-grid-column-def.directive.js.map