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);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { ChangeDetectionStrategy, Component, ElementRef, HostListener, Inject, Input } from '@angular/core';
import { Subject, timer } from 'rxjs';
import { take, takeUntil } from 'rxjs/operators';
import { ElCdkFooterRow, ElCdkHeaderRow, ElCdkRow } from '../cdk/table/type-mappings';
import { ElFooterRowComponent, ElHeaderRowComponent, ElRowComponent } from '../cdk/table/row';
import { EL_TREE_GRID } from './tree-grid-injection-tokens';
export var EL_ROW_DOUBLE_CLICK_DELAY = 200;
/**
 * Cells container. Adds the right class and role.
 */
var ElTreeGridRowComponent = /** @class */ (function (_super) {
    __extends(ElTreeGridRowComponent, _super);
    function ElTreeGridRowComponent(tree, elementRef) {
        var _this = _super.call(this) || this;
        _this.elementRef = elementRef;
        _this.doubleClick$ = new Subject();
        /**
         * Time to wait for second click to expand row deeply.
         * 200ms by default.
         */
        _this.doubleClickDelay = EL_ROW_DOUBLE_CLICK_DELAY;
        /**
         * Toggle row on click. Enabled by default.
         */
        _this.clickToToggle = true;
        _this.tree = tree;
        return _this;
    }
    ElTreeGridRowComponent_1 = ElTreeGridRowComponent;
    ElTreeGridRowComponent.prototype.toggleIfEnabledNode = function () {
        var _this = this;
        if (!this.clickToToggle) {
            return;
        }
        timer(EL_ROW_DOUBLE_CLICK_DELAY)
            .pipe(take(1), takeUntil(this.doubleClick$))
            .subscribe(function () { return _this.tree.toggleRow(_this); });
    };
    ElTreeGridRowComponent.prototype.toggleIfEnabledNodeDeep = function () {
        if (!this.clickToToggle) {
            return;
        }
        this.doubleClick$.next();
        this.tree.toggleRow(this, { deep: true });
    };
    ElTreeGridRowComponent.prototype.ngOnDestroy = function () {
        this.doubleClick$.complete();
    };
    var ElTreeGridRowComponent_1;
    __decorate([
        Input(),
        __metadata("design:type", Number)
    ], ElTreeGridRowComponent.prototype, "doubleClickDelay", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Boolean)
    ], ElTreeGridRowComponent.prototype, "clickToToggle", void 0);
    __decorate([
        HostListener('click'),
        __metadata("design:type", Function),
        __metadata("design:paramtypes", []),
        __metadata("design:returntype", void 0)
    ], ElTreeGridRowComponent.prototype, "toggleIfEnabledNode", null);
    __decorate([
        HostListener('dblclick'),
        __metadata("design:type", Function),
        __metadata("design:paramtypes", []),
        __metadata("design:returntype", void 0)
    ], ElTreeGridRowComponent.prototype, "toggleIfEnabledNodeDeep", null);
    ElTreeGridRowComponent = ElTreeGridRowComponent_1 = __decorate([
        Component({
            selector: 'tr[elTreeGridRow]',
            template: "<ng-container elCellOutlet></ng-container>",
            host: {
                'class': 'el-tree-grid-row',
                'role': 'row',
            },
            providers: [{ provide: ElCdkRow, useExisting: ElTreeGridRowComponent_1 }],
            changeDetection: ChangeDetectionStrategy.OnPush
        }),
        __param(0, Inject(EL_TREE_GRID)),
        __metadata("design:paramtypes", [Object, ElementRef])
    ], ElTreeGridRowComponent);
    return ElTreeGridRowComponent;
}(ElRowComponent));
export { ElTreeGridRowComponent };
var ElTreeGridHeaderRowComponent = /** @class */ (function (_super) {
    __extends(ElTreeGridHeaderRowComponent, _super);
    function ElTreeGridHeaderRowComponent() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ElTreeGridHeaderRowComponent_1 = ElTreeGridHeaderRowComponent;
    var ElTreeGridHeaderRowComponent_1;
    ElTreeGridHeaderRowComponent = ElTreeGridHeaderRowComponent_1 = __decorate([
        Component({
            selector: 'tr[elTreeGridHeaderRow]',
            template: "\n    <ng-container elCellOutlet></ng-container>",
            host: {
                'class': 'el-tree-grid-header-row',
                'role': 'row',
            },
            changeDetection: ChangeDetectionStrategy.OnPush,
            providers: [{ provide: ElCdkHeaderRow, useExisting: ElTreeGridHeaderRowComponent_1 }]
        })
    ], ElTreeGridHeaderRowComponent);
    return ElTreeGridHeaderRowComponent;
}(ElHeaderRowComponent));
export { ElTreeGridHeaderRowComponent };
var ElTreeGridFooterRowComponent = /** @class */ (function (_super) {
    __extends(ElTreeGridFooterRowComponent, _super);
    function ElTreeGridFooterRowComponent() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ElTreeGridFooterRowComponent_1 = ElTreeGridFooterRowComponent;
    var ElTreeGridFooterRowComponent_1;
    ElTreeGridFooterRowComponent = ElTreeGridFooterRowComponent_1 = __decorate([
        Component({
            selector: 'tr[elTreeGridFooterRow]',
            template: "\n    <ng-container elCellOutlet></ng-container>",
            host: {
                'class': 'el-tree-grid-footer-row',
                'role': 'row',
            },
            changeDetection: ChangeDetectionStrategy.OnPush,
            providers: [{ provide: ElCdkFooterRow, useExisting: ElTreeGridFooterRowComponent_1 }]
        })
    ], ElTreeGridFooterRowComponent);
    return ElTreeGridFooterRowComponent;
}(ElFooterRowComponent));
export { ElTreeGridFooterRowComponent };
//# sourceMappingURL=tree-grid-row.component.js.map