import * as tslib_1 from "tslib";
/* tslint:disable:no-access-missing-member */
import { Input, Component, ViewChild, ViewEncapsulation, ChangeDetectionStrategy, ElementRef, Output, EventEmitter } from '@angular/core';
import { OnChange } from '../core/decorators';
import { fadeAnimation } from '../core/animation/fade-animations';
import { OverlayPositionService } from '../overlay/overlay-position.service';
import { OverlayComponent } from '../overlay';
var TiplayerComponent = /** @class */ (function (_super) {
    tslib_1.__extends(TiplayerComponent, _super);
    function TiplayerComponent() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**
         * 是否有箭头
         * @default false
         */
        _this.hasArrow = false;
        /**
         * 变更可见性时的延迟时间
         * @default 200
         */
        _this.delay = 200;
        /**
         * 需要重新定位的事件
         */
        _this.needReposition = new EventEmitter();
        return _this;
    }
    TiplayerComponent.prototype.ngOnInit = function () {
        _super.prototype.ngOnInit.call(this);
        this.container = this.embedded ? '' : 'body';
        // 由于tooltip可能出现在 select 选项中，因此要比 overlay 高
        this.el.nativeElement.style.zIndex = 1002;
    };
    /**
     * 变更提示框的内容，e.g slider的提示
     * @param { string } content
     */
    TiplayerComponent.prototype.changeContent = function (content) {
        this.content.nativeElement.innerHTML = content;
    };
    /**
     * 处理提示框中的mouseEnter事件
     */
    TiplayerComponent.prototype.onMouseEnter = function () {
        if (this.trigger !== 'hover') {
            return;
        }
        if (this.hideTimeoutId) {
            clearTimeout(this.hideTimeoutId);
        }
    };
    /**
     * 处理提示框中的mouseLeave事件
     */
    TiplayerComponent.prototype.onMouseLeave = function () {
        if (this.trigger !== 'hover') {
            return;
        }
        this.hide();
    };
    TiplayerComponent.prototype.ngOnDestroy = function () {
        var nativeElement = this.el.nativeElement;
        if (nativeElement && nativeElement.parentNode) {
            nativeElement.parentNode.removeChild(nativeElement);
        }
    };
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], TiplayerComponent.prototype, "nbWidth", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], TiplayerComponent.prototype, "nbHeight", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String)
    ], TiplayerComponent.prototype, "nbTooltipClass", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String)
    ], TiplayerComponent.prototype, "nbTooltipTheme", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String)
    ], TiplayerComponent.prototype, "trigger", void 0);
    tslib_1.__decorate([
        OnChange(true),
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], TiplayerComponent.prototype, "hasArrow", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], TiplayerComponent.prototype, "embedded", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], TiplayerComponent.prototype, "delay", void 0);
    tslib_1.__decorate([
        Output(),
        tslib_1.__metadata("design:type", EventEmitter)
    ], TiplayerComponent.prototype, "needReposition", void 0);
    tslib_1.__decorate([
        ViewChild('arrow', { static: false }),
        tslib_1.__metadata("design:type", ElementRef)
    ], TiplayerComponent.prototype, "arrow", void 0);
    tslib_1.__decorate([
        ViewChild('content', { static: true }),
        tslib_1.__metadata("design:type", ElementRef)
    ], TiplayerComponent.prototype, "content", void 0);
    TiplayerComponent = tslib_1.__decorate([
        Component({
            selector: 'nb-tiplayer',
            template: "<div class=\"nb-tiplayer-box nb-tiplayer-{{nbTooltipClass}} nb-tiplayer-theme-{{nbTooltipTheme}}\" [class.invisible]=\"!visibility\" [@fadeAnimation]=\"visibility\" [style.width.px]=\"nbWidth\" [style.max-width.px]=\"nbWidth\" [style.height.px]=\"nbHeight\"><div class=\"nb-tiplayer-arrow\" *ngIf=\"hasArrow\" #arrow></div><div class=\"nb-tiplayer-content\" #content><ng-content></ng-content></div></div>",
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.OnPush,
            providers: [OverlayPositionService],
            animations: [fadeAnimation],
            exportAs: 'nbTiplayer',
            host: {
                'class': 'nb-widget nb-tiplayer',
                '[class.invisible]': '!visibility',
                '[class.nb-tiplayer-embedded]': 'embedded',
                '(mouseenter)': 'this.onMouseEnter()',
                '(mouseleave)': 'this.onMouseLeave()',
                '(click)': '_preventDefault($event)'
            }
        })
    ], TiplayerComponent);
    return TiplayerComponent;
}(OverlayComponent));
export { TiplayerComponent };
//# sourceMappingURL=tiplayer.js.map