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

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation. All rights reserved.
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of the
    License at http://www.apache.org/licenses/LICENSE-2.0

    THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
    WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
    MERCHANTABLITY OR NON-INFRINGEMENT.

    See the Apache Version 2.0 License for specific language governing permissions
    and limitations under the License.
    ***************************************************************************** */

    function __read(o, n) {
        var m = typeof Symbol === "function" && o[Symbol.iterator];
        if (!m) return o;
        var i = m.call(o), r, ar = [], e;
        try {
            while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
        }
        catch (error) { e = { error: error }; }
        finally {
            try {
                if (r && !r.done && (m = i["return"])) m.call(i);
            }
            finally { if (e) throw e.error; }
        }
        return ar;
    }

    function __spread() {
        for (var ar = [], i = 0; i < arguments.length; i++)
            ar = ar.concat(__read(arguments[i]));
        return ar;
    }

    /**
     * @fileoverview added by tsickle
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var NzToolTipComponent = /** @class */ (function () {
        function NzToolTipComponent(cdr, noAnimation) {
            this.cdr = cdr;
            this.noAnimation = noAnimation;
            this._hasBackdrop = false;
            this._prefix = 'ant-tooltip-placement';
            this._positions = __spread(core$1.DEFAULT_TOOLTIP_POSITIONS);
            this._classMap = {};
            this._placement = 'top';
            this._trigger = 'hover';
            this.visibleSource = new rxjs.BehaviorSubject(false);
            this.visible$ = this.visibleSource.asObservable();
            this.nzOverlayClassName = '';
            this.nzOverlayStyle = {};
            this.nzMouseEnterDelay = 0.15; // second
            // second
            this.nzMouseLeaveDelay = 0.1; // second
            this.nzVisibleChange = new core.EventEmitter();
        }
        Object.defineProperty(NzToolTipComponent.prototype, "nzVisible", {
            get: /**
             * @return {?}
             */
            function () {
                return this.visibleSource.value;
            },
            set: 
            // second
            /**
             * @param {?} value
             * @return {?}
             */
            function (value) {
                /** @type {?} */
                var visible = core$1.toBoolean(value);
                if (this.visibleSource.value !== visible) {
                    this.visibleSource.next(visible);
                    this.nzVisibleChange.emit(visible);
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NzToolTipComponent.prototype, "nzTrigger", {
            get: /**
             * @return {?}
             */
            function () {
                return this._trigger;
            },
            set: /**
             * @param {?} value
             * @return {?}
             */
            function (value) {
                this._trigger = value;
                this._hasBackdrop = this._trigger === 'click';
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NzToolTipComponent.prototype, "nzPlacement", {
            get: /**
             * @return {?}
             */
            function () {
                return this._placement;
            },
            set: /**
             * @param {?} value
             * @return {?}
             */
            function (value) {
                if (value !== this._placement) {
                    this._placement = value;
                    this._positions = __spread([core$1.POSITION_MAP[this.nzPlacement]], this._positions);
                }
            },
            enumerable: true,
            configurable: true
        });
        /**
         * @return {?}
         */
        NzToolTipComponent.prototype.ngOnChanges = /**
         * @return {?}
         */
        function () {
            var _this = this;
            Promise.resolve().then((/**
             * @return {?}
             */
            function () {
                _this.updatePosition();
            }));
        };
        // Manually force updating current overlay's position
        // Manually force updating current overlay's position
        /**
         * @return {?}
         */
        NzToolTipComponent.prototype.updatePosition = 
        // Manually force updating current overlay's position
        /**
         * @return {?}
         */
        function () {
            if (this.overlay && this.overlay.overlayRef) {
                this.overlay.overlayRef.updatePosition();
            }
        };
        /**
         * @param {?} position
         * @return {?}
         */
        NzToolTipComponent.prototype.onPositionChange = /**
         * @param {?} position
         * @return {?}
         */
        function (position) {
            this.nzPlacement = (/** @type {?} */ (core$1.getPlacementName(position)));
            this.setClassMap();
            this.cdr.detectChanges(); // TODO: performance?
        };
        /**
         * @return {?}
         */
        NzToolTipComponent.prototype.show = /**
         * @return {?}
         */
        function () {
            if (!this.isContentEmpty()) {
                this.nzVisible = true;
            }
        };
        /**
         * @return {?}
         */
        NzToolTipComponent.prototype.hide = /**
         * @return {?}
         */
        function () {
            this.nzVisible = false;
        };
        /**
         * @param {?} e
         * @return {?}
         */
        NzToolTipComponent.prototype._afterVisibilityAnimation = /**
         * @param {?} e
         * @return {?}
         */
        function (e) {
            if (e.toState === 'false' && !this.nzVisible) {
                this.nzVisibleChange.emit(false);
            }
            if (e.toState === 'true' && this.nzVisible) {
                this.nzVisibleChange.emit(true);
            }
        };
        /**
         * @return {?}
         */
        NzToolTipComponent.prototype.setClassMap = /**
         * @return {?}
         */
        function () {
            var _a;
            this._classMap = (_a = {},
                _a[this.nzOverlayClassName] = true,
                _a[this._prefix + "-" + this._placement] = true,
                _a);
        };
        /**
         * @param {?} origin
         * @return {?}
         */
        NzToolTipComponent.prototype.setOverlayOrigin = /**
         * @param {?} origin
         * @return {?}
         */
        function (origin) {
            this.overlayOrigin = origin;
        };
        /**
         * @protected
         * @return {?}
         */
        NzToolTipComponent.prototype.isContentEmpty = /**
         * @protected
         * @return {?}
         */
        function () {
            return this.nzTitle instanceof core.TemplateRef ? false : this.nzTitle === '' || !core$1.isNotNil(this.nzTitle);
        };
        NzToolTipComponent.decorators = [
            { type: core.Component, args: [{
                        selector: 'nz-tooltip',
                        exportAs: 'nzTooltipComponent',
                        changeDetection: core.ChangeDetectionStrategy.OnPush,
                        encapsulation: core.ViewEncapsulation.None,
                        animations: [core$1.zoomBigMotion],
                        template: "<ng-content></ng-content>\n<ng-template\n  #overlay=\"cdkConnectedOverlay\"\n  cdkConnectedOverlay\n  nzConnectedOverlay\n  [cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n  [cdkConnectedOverlayOpen]=\"visible$ | async\"\n  [cdkConnectedOverlayHasBackdrop]=\"_hasBackdrop\"\n  [cdkConnectedOverlayPositions]=\"_positions\"\n  (backdropClick)=\"hide()\"\n  (detach)=\"hide()\"\n  (positionChange)=\"onPositionChange($event)\">\n  <div\n    class=\"ant-tooltip\"\n    [ngClass]=\"_classMap\"\n    [ngStyle]=\"nzOverlayStyle\"\n    [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n    [@zoomBigMotion]=\"'active'\"\n    (@zoomBigMotion.done)=\"_afterVisibilityAnimation($event)\">\n    <div class=\"ant-tooltip-content\">\n      <div class=\"ant-tooltip-arrow\"></div>\n      <div class=\"ant-tooltip-inner\">\n        <ng-container *nzStringTemplateOutlet=\"nzTitle\">{{ nzTitle }}</ng-container>\n      </div>\n    </div>\n  </div>\n</ng-template>",
                        preserveWhitespaces: false,
                        styles: ["\n      .ant-tooltip {\n        position: relative;\n      }\n    "]
                    }] }
        ];
        /** @nocollapse */
        NzToolTipComponent.ctorParameters = function () { return [
            { type: core.ChangeDetectorRef },
            { type: core$1.NzNoAnimationDirective, decorators: [{ type: core.Host }, { type: core.Optional }] }
        ]; };
        NzToolTipComponent.propDecorators = {
            overlay: [{ type: core.ViewChild, args: ['overlay', { static: false },] }],
            nzTitle: [{ type: core.Input }, { type: core.ContentChild, args: ['nzTemplate', { static: true },] }],
            nzOverlayClassName: [{ type: core.Input }],
            nzOverlayStyle: [{ type: core.Input }],
            nzMouseEnterDelay: [{ type: core.Input }],
            nzMouseLeaveDelay: [{ type: core.Input }],
            nzVisible: [{ type: core.Input }],
            nzTrigger: [{ type: core.Input }],
            nzPlacement: [{ type: core.Input }],
            nzVisibleChange: [{ type: core.Output }]
        };
        return NzToolTipComponent;
    }());

    /**
     * @fileoverview added by tsickle
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var NzTooltipDirective = /** @class */ (function () {
        function NzTooltipDirective(elementRef, hostView, resolver, renderer, tooltip, noAnimation) {
            this.elementRef = elementRef;
            this.hostView = hostView;
            this.resolver = resolver;
            this.renderer = renderer;
            this.tooltip = tooltip;
            this.noAnimation = noAnimation;
            // [NOTE] Here hard coded, and nzTitle used only under NzTooltipDirective currently.
            this.isTooltipOpen = false;
            this.isDynamicTooltip = false; // Indicate whether current tooltip is dynamic created
            this.factory = this.resolver.resolveComponentFactory(NzToolTipComponent);
            /**
             * Names of properties that should be proxy to child component.
             */
            this.needProxyProperties = [
                'nzTitle',
                'nzContent',
                'nzOverlayClassName',
                'nzOverlayStyle',
                'nzMouseEnterDelay',
                'nzMouseLeaveDelay',
                'nzVisible',
                'nzTrigger',
                'nzPlacement'
            ];
            this.subs_ = new rxjs.Subscription();
            this.listeners = [];
            this.nzVisibleChange = new core.EventEmitter();
        }
        Object.defineProperty(NzTooltipDirective.prototype, "setTitle", {
            set: /**
             * @param {?} title
             * @return {?}
             */
            function (title) {
                this.nzTitle = title;
            },
            enumerable: true,
            configurable: true
        });
        /**
         * @param {?} changes
         * @return {?}
         */
        NzTooltipDirective.prototype.ngOnChanges = /**
         * @param {?} changes
         * @return {?}
         */
        function (changes) {
            this.updateProxies(changes);
        };
        /**
         * @return {?}
         */
        NzTooltipDirective.prototype.ngOnInit = /**
         * @return {?}
         */
        function () {
            var _this = this;
            // Support faster tooltip mode: <a nz-tooltip="xxx"></a>. [NOTE] Used only under NzTooltipDirective currently.
            if (!this.tooltip) {
                /** @type {?} */
                var tooltipComponent = this.hostView.createComponent(this.factory);
                this.tooltip = tooltipComponent.instance;
                this.tooltip.noAnimation = this.noAnimation;
                // Remove element when use directive https://github.com/NG-ZORRO/ng-zorro-antd/issues/1967
                this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement), tooltipComponent.location.nativeElement);
                this.isDynamicTooltip = true;
                this.needProxyProperties.forEach((/**
                 * @param {?} property
                 * @return {?}
                 */
                function (property) { return _this.updateCompValue(property, _this[property]); }));
                /** @type {?} */
                var visible_ = this.tooltip.nzVisibleChange.pipe(operators.distinctUntilChanged()).subscribe((/**
                 * @param {?} data
                 * @return {?}
                 */
                function (data) {
                    _this.visible = data;
                    _this.nzVisibleChange.emit(data);
                }));
                this.subs_.add(visible_);
            }
            this.tooltip.setOverlayOrigin(this);
        };
        /**
         * @return {?}
         */
        NzTooltipDirective.prototype.ngAfterViewInit = /**
         * @return {?}
         */
        function () {
            var _this = this;
            if (this.tooltip.nzTrigger === 'hover') {
                /** @type {?} */
                var overlayElement_1;
                /** @type {?} */
                var listenerMouseEnter = this.renderer.listen(this.elementRef.nativeElement, 'mouseenter', (/**
                 * @return {?}
                 */
                function () {
                    return _this.delayEnterLeave(true, true, _this.tooltip.nzMouseEnterDelay);
                }));
                this.listeners.push(listenerMouseEnter);
                /** @type {?} */
                var listenerMouseLeave = this.renderer.listen(this.elementRef.nativeElement, 'mouseleave', (/**
                 * @return {?}
                 */
                function () {
                    _this.delayEnterLeave(true, false, _this.tooltip.nzMouseLeaveDelay);
                    if (_this.tooltip.overlay.overlayRef && !overlayElement_1) {
                        // NOTE: we bind events under "mouseleave" due to the overlayRef is only created after the overlay was completely shown up
                        overlayElement_1 = _this.tooltip.overlay.overlayRef.overlayElement;
                        /** @type {?} */
                        var listenerOverlayMouseEnter = _this.renderer.listen(overlayElement_1, 'mouseenter', (/**
                         * @return {?}
                         */
                        function () {
                            return _this.delayEnterLeave(false, true);
                        }));
                        _this.listeners.push(listenerOverlayMouseEnter);
                        /** @type {?} */
                        var listenerOverlayMouseLeave = _this.renderer.listen(overlayElement_1, 'mouseleave', (/**
                         * @return {?}
                         */
                        function () {
                            return _this.delayEnterLeave(false, false);
                        }));
                        _this.listeners.push(listenerOverlayMouseLeave);
                    }
                }));
                this.listeners.push(listenerMouseLeave);
            }
            else if (this.tooltip.nzTrigger === 'focus') {
                /** @type {?} */
                var listenerFocus = this.renderer.listen(this.elementRef.nativeElement, 'focus', (/**
                 * @return {?}
                 */
                function () { return _this.show(); }));
                this.listeners.push(listenerFocus);
                /** @type {?} */
                var listenerBlur = this.renderer.listen(this.elementRef.nativeElement, 'blur', (/**
                 * @return {?}
                 */
                function () { return _this.hide(); }));
                this.listeners.push(listenerBlur);
            }
            else if (this.tooltip.nzTrigger === 'click') {
                /** @type {?} */
                var listenerClick = this.renderer.listen(this.elementRef.nativeElement, 'click', (/**
                 * @param {?} e
                 * @return {?}
                 */
                function (e) {
                    e.preventDefault();
                    _this.show();
                }));
                this.listeners.push(listenerClick);
            }
        };
        /**
         * @return {?}
         */
        NzTooltipDirective.prototype.ngOnDestroy = /**
         * @return {?}
         */
        function () {
            this.subs_.unsubscribe();
            this.listeners.forEach((/**
             * @param {?} listener
             * @return {?}
             */
            function (listener) {
                listener();
            }));
        };
        // tslint:disable-next-line:no-any
        // tslint:disable-next-line:no-any
        /**
         * @protected
         * @param {?} key
         * @param {?} value
         * @return {?}
         */
        NzTooltipDirective.prototype.updateCompValue = 
        // tslint:disable-next-line:no-any
        /**
         * @protected
         * @param {?} key
         * @param {?} value
         * @return {?}
         */
        function (key, value) {
            var _this = this;
            if (this.isDynamicTooltip && core$1.isNotNil(value)) {
                this.tooltip[key] = value;
                this.tooltip.setClassMap();
                Promise.resolve().then((/**
                 * @return {?}
                 */
                function () {
                    _this.tooltip.updatePosition();
                }));
            }
        };
        /**
         * @private
         * @return {?}
         */
        NzTooltipDirective.prototype.show = /**
         * @private
         * @return {?}
         */
        function () {
            this.tooltip.show();
            this.isTooltipOpen = true;
        };
        /**
         * @private
         * @return {?}
         */
        NzTooltipDirective.prototype.hide = /**
         * @private
         * @return {?}
         */
        function () {
            this.tooltip.hide();
            this.isTooltipOpen = false;
        };
        /**
         * @private
         * @param {?} isOrigin
         * @param {?} isEnter
         * @param {?=} delay
         * @return {?}
         */
        NzTooltipDirective.prototype.delayEnterLeave = /**
         * @private
         * @param {?} isOrigin
         * @param {?} isEnter
         * @param {?=} delay
         * @return {?}
         */
        function (isOrigin, isEnter, delay) {
            var _this = this;
            if (delay === void 0) { delay = -1; }
            if (this.delayTimer) {
                // Clear timer during the delay time
                clearTimeout(this.delayTimer);
                this.delayTimer = null;
            }
            else if (delay > 0) {
                this.delayTimer = setTimeout((/**
                 * @return {?}
                 */
                function () {
                    _this.delayTimer = null;
                    isEnter ? _this.show() : _this.hide();
                }), delay * 1000);
            }
            else {
                isEnter && isOrigin ? this.show() : this.hide(); // [Compatible] The "isOrigin" is used due to the tooltip will not hide immediately (may caused by the fade-out animation)
            }
        };
        /**
         * Set inputs of child components when this component's inputs change.
         * @param changes
         */
        /**
         * Set inputs of child components when this component's inputs change.
         * @private
         * @param {?} changes
         * @return {?}
         */
        NzTooltipDirective.prototype.updateProxies = /**
         * Set inputs of child components when this component's inputs change.
         * @private
         * @param {?} changes
         * @return {?}
         */
        function (changes) {
            var _this = this;
            if (this.tooltip) {
                Object.keys(changes).forEach((/**
                 * @param {?} key
                 * @return {?}
                 */
                function (key) {
                    /** @type {?} */
                    var change = changes[key];
                    if (change) {
                        _this.updateCompValue(key, change.currentValue);
                    }
                }));
                if (changes.setTitle) {
                    this.nzTitle = changes.setTitle.currentValue;
                    this.updateCompValue('nzTitle', changes.setTitle.currentValue);
                }
                this.tooltip.cdr.markForCheck(); // Manually trigger change detection of component.
            }
        };
        NzTooltipDirective.decorators = [
            { type: core.Directive, args: [{
                        selector: '[nz-tooltip]',
                        exportAs: 'nzTooltip',
                        host: {
                            '[class.ant-tooltip-open]': 'isTooltipOpen'
                        }
                    },] }
        ];
        /** @nocollapse */
        NzTooltipDirective.ctorParameters = function () { return [
            { type: core.ElementRef },
            { type: core.ViewContainerRef },
            { type: core.ComponentFactoryResolver },
            { type: core.Renderer2 },
            { type: NzToolTipComponent, decorators: [{ type: core.Optional }] },
            { type: core$1.NzNoAnimationDirective, decorators: [{ type: core.Host }, { type: core.Optional }] }
        ]; };
        NzTooltipDirective.propDecorators = {
            nzVisibleChange: [{ type: core.Output }],
            nzTitle: [{ type: core.Input, args: ['nz-tooltip',] }],
            setTitle: [{ type: core.Input, args: ['nzTitle',] }],
            nzContent: [{ type: core.Input }],
            nzMouseEnterDelay: [{ type: core.Input }],
            nzMouseLeaveDelay: [{ type: core.Input }],
            nzOverlayClassName: [{ type: core.Input }],
            nzOverlayStyle: [{ type: core.Input }],
            nzTrigger: [{ type: core.Input }],
            nzVisible: [{ type: core.Input }],
            nzPlacement: [{ type: core.Input }]
        };
        return NzTooltipDirective;
    }());

    /**
     * @fileoverview added by tsickle
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var NzToolTipModule = /** @class */ (function () {
        function NzToolTipModule() {
        }
        NzToolTipModule.decorators = [
            { type: core.NgModule, args: [{
                        declarations: [NzToolTipComponent, NzTooltipDirective],
                        exports: [NzToolTipComponent, NzTooltipDirective],
                        imports: [common.CommonModule, overlay.OverlayModule, core$1.NzAddOnModule, core$1.NzOverlayModule, core$1.NzNoAnimationModule],
                        entryComponents: [NzToolTipComponent]
                    },] }
        ];
        return NzToolTipModule;
    }());

    exports.NzToolTipComponent = NzToolTipComponent;
    exports.NzToolTipModule = NzToolTipModule;
    exports.NzTooltipDirective = NzTooltipDirective;

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

}));
//# sourceMappingURL=ng-zorro-antd-tooltip.umd.js.map
