(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@ng-tangram/components/core'), require('@angular/cdk/overlay')) :
    typeof define === 'function' && define.amd ? define('@ng-tangram/components/tooltip', ['exports', '@angular/common', '@angular/core', '@ng-tangram/components/core', '@angular/cdk/overlay'], factory) :
    (global = global || self, factory((global.nt = global.nt || {}, global.nt.components = global.nt.components || {}, global.nt.components.tooltip = {}), global.ng.common, global.ng.core, global.nt.components.core, global.ng.cdk.overlay));
}(this, (function (exports, common, core, core$1, overlay) { 'use strict';

    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 NtTooltipComponent = (function () {
        function NtTooltipComponent(_elementRef) {
            this._elementRef = _elementRef;
            this._title = '';
            this.position = core$1.NtOverlayPosition.Top;
            this.afterOpen = new core.EventEmitter();
            this.afterClosed = new core.EventEmitter();
            this.beforeOpen = new core.EventEmitter();
            this.beforeClosed = new core.EventEmitter();
            this.positionChange = new core.EventEmitter();
            this.origin = new overlay.CdkOverlayOrigin(_elementRef);
        }
        Object.defineProperty(NtTooltipComponent.prototype, "title", {
            get: function () { return this._title; },
            set: function (value) { this._title = value; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NtTooltipComponent.prototype, "template", {
            get: function () { return this._template; },
            set: function (value) { this._template = value; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NtTooltipComponent.prototype, "tooltip", {
            set: function (value) {
                if (value instanceof core.TemplateRef) {
                    this._template = value;
                }
                else {
                    this._title = value;
                    this._template = null;
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NtTooltipComponent.prototype, "_isDirective", {
            get: function () {
                var attributes = this._elementRef.nativeElement.attributes;
                return attributes && attributes['nt-tooltip'];
            },
            enumerable: true,
            configurable: true
        });
        NtTooltipComponent.prototype.ngOnChanges = function (changes) {
            var _this = this;
            var change = changes.title || changes.template || changes.tooltip;
            if (change && !change.firstChange) {
                Promise.resolve().then(function () {
                    _this.overlay.cdkConnectedOverlay.overlayRef.updatePosition();
                });
            }
        };
        NtTooltipComponent.prototype._afterOpen = function (event) {
            this.afterOpen.next(event);
        };
        NtTooltipComponent.prototype._afterClosed = function (event) {
            this.afterClosed.next(event);
        };
        NtTooltipComponent.prototype._beforeOpen = function (event) {
            this.beforeOpen.next(event);
        };
        NtTooltipComponent.prototype._beforeClosed = function (event) {
            this.beforeClosed.next(event);
        };
        NtTooltipComponent.prototype._positionChange = function (change) {
            this.positionChange.next(change);
        };
        NtTooltipComponent.ctorParameters = function () { return [
            { type: core.ElementRef }
        ]; };
        __decorate([
            core.Input()
        ], NtTooltipComponent.prototype, "title", null);
        __decorate([
            core.Input()
        ], NtTooltipComponent.prototype, "template", null);
        __decorate([
            core.Input('nt-tooltip')
        ], NtTooltipComponent.prototype, "tooltip", null);
        __decorate([
            core.Input()
        ], NtTooltipComponent.prototype, "position", void 0);
        __decorate([
            core.Output()
        ], NtTooltipComponent.prototype, "afterOpen", void 0);
        __decorate([
            core.Output()
        ], NtTooltipComponent.prototype, "afterClosed", void 0);
        __decorate([
            core.Output()
        ], NtTooltipComponent.prototype, "beforeOpen", void 0);
        __decorate([
            core.Output()
        ], NtTooltipComponent.prototype, "beforeClosed", void 0);
        __decorate([
            core.Output()
        ], NtTooltipComponent.prototype, "positionChange", void 0);
        __decorate([
            core.ViewChild(core$1.NtOverlayComponent, { static: true })
        ], NtTooltipComponent.prototype, "overlay", void 0);
        NtTooltipComponent = __decorate([
            core.Component({
                selector: 'nt-tooltip, [nt-tooltip]',
                template: "<ng-content></ng-content>\n<nt-overlay\n  overlayClass=\"tootip-overlay\"\n  arrow\n  [origin]=\"origin\"\n  [position]=\"position\"\n  (afterOpen)=\"_afterOpen($event)\"\n  (afterClosed)=\"_afterClosed($event)\"\n  (beforeOpen)=\"_beforeOpen($event)\"\n  (beforeClosed)=\"_beforeClosed($event)\"\n  (overlayEnter)=\"overlay.markOpen()\"\n  (overlayLeave)=\"overlay.markClose()\"\n  (positionChange)=\"_positionChange($event)\">\n  <div class=\"tooltip\" *ngIf=\"template\">\n    <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n  </div>\n  <div class=\"tooltip\" *ngIf=\"!template\" [innerHtml]=\"title\"></div>\n</nt-overlay>\n",
                encapsulation: core.ViewEncapsulation.None,
                host: {
                    '[class.tooltip-trigger]': '!_isDirective',
                    '(mouseenter)': 'overlay.markOpen()',
                    '(mouseleave)': 'overlay.markClose()'
                }
            })
        ], NtTooltipComponent);
        return NtTooltipComponent;
    }());

    var __decorate$1 = (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 NtTooltipModule = (function () {
        function NtTooltipModule() {
        }
        NtTooltipModule = __decorate$1([
            core.NgModule({
                imports: [common.CommonModule, core$1.NtOverlayModule],
                exports: [NtTooltipComponent],
                declarations: [NtTooltipComponent]
            })
        ], NtTooltipModule);
        return NtTooltipModule;
    }());

    exports.NtTooltipComponent = NtTooltipComponent;
    exports.NtTooltipModule = NtTooltipModule;

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=tooltip.umd.js.map
