(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/observers'), require('@angular/common'), require('@angular/core'), require('@ng-tangram/components/core'), require('rxjs'), require('@angular/cdk/coercion'), require('@angular/cdk/overlay')) :
    typeof define === 'function' && define.amd ? define('@ng-tangram/components/dropdown', ['exports', '@angular/cdk/observers', '@angular/common', '@angular/core', '@ng-tangram/components/core', 'rxjs', '@angular/cdk/coercion', '@angular/cdk/overlay'], factory) :
    (global = global || self, factory((global.nt = global.nt || {}, global.nt.components = global.nt.components || {}, global.nt.components.dropdown = {}), global.ng.cdk.observers, global.ng.common, global.ng.core, global.nt.components.core, global.rxjs, global.ng.cdk.coercion, global.ng.cdk.overlay));
}(this, (function (exports, observers, common, core, core$1, rxjs, coercion, 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 __param = (this && this.__param) || function (paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); }
    };
    var NT_DROPDOWN_PARENT_COMPONENT = new core.InjectionToken('nt-dropdown-parent-component');
    var NtDropdownPaneComponent = (function () {
        function NtDropdownPaneComponent(_contentObserver, _elementRef, _parent) {
            this._contentObserver = _contentObserver;
            this._elementRef = _elementRef;
            this._parent = _parent;
            this._arrow = false;
            this._autosize = false;
            this.size = 'small';
            this.class = '';
            this._contentChange = new rxjs.Subject();
        }
        Object.defineProperty(NtDropdownPaneComponent.prototype, "autosize", {
            get: function () { return this._autosize; },
            set: function (value) {
                this._autosize = coercion.coerceBooleanProperty(value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NtDropdownPaneComponent.prototype, "arrow", {
            get: function () { return this._arrow; },
            set: function (value) { this._arrow = coercion.coerceBooleanProperty(value); },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NtDropdownPaneComponent.prototype, "contentChanged", {
            get: function () {
                return this._contentChange.asObservable();
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NtDropdownPaneComponent.prototype, "textContent", {
            get: function () {
                return (this._elementRef.nativeElement.textContent || '').trim();
            },
            enumerable: true,
            configurable: true
        });
        NtDropdownPaneComponent.prototype.ngAfterContentInit = function () {
            var _this = this;
            this._contentSubscription = this._contentObserver
                .observe(this._elementRef)
                .subscribe(function () { return _this._checkContentChange(); });
        };
        NtDropdownPaneComponent.prototype.ngOnDestroy = function () {
            if (this._contentSubscription) {
                this._contentSubscription.unsubscribe();
            }
        };
        NtDropdownPaneComponent.prototype._checkContentChange = function () {
            if (this._parent.overlay.opened) {
                var cdkConnectedOverlay = this._parent.overlay.cdkConnectedOverlay;
                if (cdkConnectedOverlay && cdkConnectedOverlay.overlayRef) {
                    cdkConnectedOverlay.overlayRef.updatePosition();
                }
            }
        };
        NtDropdownPaneComponent.ctorParameters = function () { return [
            { type: observers.ContentObserver },
            { type: core.ElementRef },
            { type: undefined, decorators: [{ type: core.Inject, args: [NT_DROPDOWN_PARENT_COMPONENT,] }] }
        ]; };
        __decorate([
            core.Input()
        ], NtDropdownPaneComponent.prototype, "size", void 0);
        __decorate([
            core.Input()
        ], NtDropdownPaneComponent.prototype, "class", void 0);
        __decorate([
            core.Input()
        ], NtDropdownPaneComponent.prototype, "autosize", null);
        __decorate([
            core.Input()
        ], NtDropdownPaneComponent.prototype, "arrow", null);
        NtDropdownPaneComponent = __decorate([
            core.Component({
                selector: 'nt-dropdown-pane, [nt-dropdown-pane]',
                template: '<ng-content></ng-content>',
                encapsulation: core.ViewEncapsulation.None,
                host: {
                    '[class]': '["nt-dropdown-pane", size, class].join(" ")',
                    '[class.autosize]': 'autosize'
                }
            }),
            __param(2, core.Inject(NT_DROPDOWN_PARENT_COMPONENT))
        ], NtDropdownPaneComponent);
        return NtDropdownPaneComponent;
    }());

    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 NtDropdownComponent = (function () {
        function NtDropdownComponent(_elementRef) {
            this.position = core$1.NtOverlayPosition.BottomLeft;
            this.trigger = 'hover';
            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);
        }
        NtDropdownComponent_1 = NtDropdownComponent;
        NtDropdownComponent.prototype._onClick = function (_) {
            if (this.trigger === 'click') {
                this.overlay.toggle();
            }
        };
        NtDropdownComponent.prototype._onMouseEnter = function (_) {
            if (this.trigger === 'hover') {
                this.overlay.markOpen();
            }
        };
        NtDropdownComponent.prototype._onMouseLeave = function (_) {
            if (this.trigger === 'hover') {
                this.overlay.markClose();
            }
        };
        NtDropdownComponent.prototype._afterOpen = function (event) {
            this.afterOpen.next(event);
        };
        NtDropdownComponent.prototype._afterClosed = function (event) {
            this.afterClosed.next(event);
        };
        NtDropdownComponent.prototype._beforeOpen = function (event) {
            this.beforeOpen.next(event);
        };
        NtDropdownComponent.prototype._beforeClosed = function (event) {
            this.beforeClosed.next(event);
        };
        NtDropdownComponent.prototype._positionChange = function (change) {
            this.positionChange.next(change);
        };
        var NtDropdownComponent_1;
        NtDropdownComponent.ctorParameters = function () { return [
            { type: core.ElementRef }
        ]; };
        __decorate$1([
            core.Input()
        ], NtDropdownComponent.prototype, "position", void 0);
        __decorate$1([
            core.Input()
        ], NtDropdownComponent.prototype, "trigger", void 0);
        __decorate$1([
            core.Output()
        ], NtDropdownComponent.prototype, "afterOpen", void 0);
        __decorate$1([
            core.Output()
        ], NtDropdownComponent.prototype, "afterClosed", void 0);
        __decorate$1([
            core.Output()
        ], NtDropdownComponent.prototype, "beforeOpen", void 0);
        __decorate$1([
            core.Output()
        ], NtDropdownComponent.prototype, "beforeClosed", void 0);
        __decorate$1([
            core.Output()
        ], NtDropdownComponent.prototype, "positionChange", void 0);
        __decorate$1([
            core.ViewChild(core$1.NtOverlayComponent, { static: true })
        ], NtDropdownComponent.prototype, "overlay", void 0);
        __decorate$1([
            core.ContentChild(NtDropdownPaneComponent)
        ], NtDropdownComponent.prototype, "pane", void 0);
        NtDropdownComponent = NtDropdownComponent_1 = __decorate$1([
            core.Component({
                selector: 'nt-dropdown, [nt-dropdown]',
                template: "<ng-content></ng-content>\n<nt-overlay\n  [origin]=\"origin\"\n  [position]=\"position\"\n  [arrow]=\"pane?.arrow\"\n  (afterOpen)=\"_afterOpen($event)\"\n  (afterClosed)=\"_afterClosed($event)\"\n  (beforeOpen)=\"_beforeOpen($event)\"\n  (beforeClosed)=\"_beforeClosed($event)\"\n  (overlayEnter)=\"_onMouseEnter($event)\"\n  (overlayLeave)=\"_onMouseLeave($event)\"\n  (positionChange)=\"_positionChange($event)\">\n  <ng-content select=\"nt-dropdown-pane\"></ng-content>\n</nt-overlay>\n",
                encapsulation: core.ViewEncapsulation.None,
                host: {
                    '(click)': '_onClick($event)',
                    '(mouseenter)': '_onMouseEnter($event)',
                    '(mouseleave)': '_onMouseLeave($event)'
                },
                providers: [
                    { provide: NT_DROPDOWN_PARENT_COMPONENT, useExisting: NtDropdownComponent_1 }
                ]
            })
        ], NtDropdownComponent);
        return NtDropdownComponent;
    }());

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

    exports.NT_DROPDOWN_PARENT_COMPONENT = NT_DROPDOWN_PARENT_COMPONENT;
    exports.NtDropdownComponent = NtDropdownComponent;
    exports.NtDropdownModule = NtDropdownModule;
    exports.NtDropdownPaneComponent = NtDropdownPaneComponent;

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

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