(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular-ru/cdk/string'), require('@ngx-translate/core'), require('@angular-ru/cdk/utils'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
    typeof define === 'function' && define.amd ? define('@angular-ru/cdk/tooltip', ['exports', '@angular/core', '@angular-ru/cdk/string', '@ngx-translate/core', '@angular-ru/cdk/utils', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['angular-ru'] = global['angular-ru'] || {}, global['angular-ru'].cdk = global['angular-ru'].cdk || {}, global['angular-ru'].cdk.tooltip = {}), global.ng.core, global['angular-ru'].cdk.string, global.i1, global['angular-ru'].cdk.utils, global.rxjs, global.rxjs.operators, global.ng.common));
}(this, (function (exports, i0, string, i1, utils, rxjs, operators, common) { 'use strict';

    function _interopNamespace(e) {
        if (e && e.__esModule) return e;
        var n = Object.create(null);
        if (e) {
            Object.keys(e).forEach(function (k) {
                if (k !== 'default') {
                    var d = Object.getOwnPropertyDescriptor(e, k);
                    Object.defineProperty(n, k, d.get ? d : {
                        enumerable: true,
                        get: function () {
                            return e[k];
                        }
                    });
                }
            });
        }
        n['default'] = e;
        return Object.freeze(n);
    }

    var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
    var i1__namespace = /*#__PURE__*/_interopNamespace(i1);

    var NgxTooltipTextInterceptor = /** @class */ (function () {
        function NgxTooltipTextInterceptor(translate) {
            this.translate = translate;
        }
        NgxTooltipTextInterceptor.prototype.instant = function (value) {
            return string.isString(value) ? this.translate.instant(value) : value;
        };
        return NgxTooltipTextInterceptor;
    }());
    /** @nocollapse */ /** @nocollapse */ NgxTooltipTextInterceptor.ɵfac = function NgxTooltipTextInterceptor_Factory(t) { return new (t || NgxTooltipTextInterceptor)(i0__namespace.ɵɵinject(i1__namespace.TranslateService)); };
    /** @nocollapse */ /** @nocollapse */ NgxTooltipTextInterceptor.ɵprov = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjectable({ token: NgxTooltipTextInterceptor, factory: NgxTooltipTextInterceptor.ɵfac });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(NgxTooltipTextInterceptor, [{
                type: i0.Injectable
            }], function () { return [{ type: i1__namespace.TranslateService }]; }, null);
    })();

    var TooltipDefaultTextInterceptor = /** @class */ (function () {
        function TooltipDefaultTextInterceptor() {
        }
        return TooltipDefaultTextInterceptor;
    }());
    /** @nocollapse */ /** @nocollapse */ TooltipDefaultTextInterceptor.ɵfac = function TooltipDefaultTextInterceptor_Factory(t) { return new (t || TooltipDefaultTextInterceptor)(); };
    /** @nocollapse */ /** @nocollapse */ TooltipDefaultTextInterceptor.ɵprov = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjectable({ token: TooltipDefaultTextInterceptor, factory: TooltipDefaultTextInterceptor.ɵfac });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(TooltipDefaultTextInterceptor, [{
                type: i0.Injectable
            }], null, null);
    })();

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */
    /* global Reflect, Promise */
    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 (Object.prototype.hasOwnProperty.call(b, p))
                    d[p] = b[p]; };
        return extendStatics(d, b);
    };
    function __extends(d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }
    var __assign = function () {
        __assign = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s)
                    if (Object.prototype.hasOwnProperty.call(s, p))
                        t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };
    function __rest(s, e) {
        var t = {};
        for (var p in s)
            if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
                t[p] = s[p];
        if (s != null && typeof Object.getOwnPropertySymbols === "function")
            for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
                if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                    t[p[i]] = s[p[i]];
            }
        return t;
    }
    function __decorate(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;
    }
    function __param(paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); };
    }
    function __metadata(metadataKey, metadataValue) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
            return Reflect.metadata(metadataKey, metadataValue);
    }
    function __awaiter(thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    }
    function __generator(thisArg, body) {
        var _ = { label: 0, sent: function () { if (t[0] & 1)
                throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f)
                throw new TypeError("Generator is already executing.");
            while (_)
                try {
                    if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
                        return t;
                    if (y = 0, t)
                        op = [op[0] & 2, t.value];
                    switch (op[0]) {
                        case 0:
                        case 1:
                            t = op;
                            break;
                        case 4:
                            _.label++;
                            return { value: op[1], done: false };
                        case 5:
                            _.label++;
                            y = op[1];
                            op = [0];
                            continue;
                        case 7:
                            op = _.ops.pop();
                            _.trys.pop();
                            continue;
                        default:
                            if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                                _ = 0;
                                continue;
                            }
                            if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
                                _.label = op[1];
                                break;
                            }
                            if (op[0] === 6 && _.label < t[1]) {
                                _.label = t[1];
                                t = op;
                                break;
                            }
                            if (t && _.label < t[2]) {
                                _.label = t[2];
                                _.ops.push(op);
                                break;
                            }
                            if (t[2])
                                _.ops.pop();
                            _.trys.pop();
                            continue;
                    }
                    op = body.call(thisArg, _);
                }
                catch (e) {
                    op = [6, e];
                    y = 0;
                }
                finally {
                    f = t = 0;
                }
            if (op[0] & 5)
                throw op[1];
            return { value: op[0] ? op[1] : void 0, done: true };
        }
    }
    var __createBinding = Object.create ? (function (o, m, k, k2) {
        if (k2 === undefined)
            k2 = k;
        Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
    }) : (function (o, m, k, k2) {
        if (k2 === undefined)
            k2 = k;
        o[k2] = m[k];
    });
    function __exportStar(m, o) {
        for (var p in m)
            if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
                __createBinding(o, m, p);
    }
    function __values(o) {
        var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
        if (m)
            return m.call(o);
        if (o && typeof o.length === "number")
            return {
                next: function () {
                    if (o && i >= o.length)
                        o = void 0;
                    return { value: o && o[i++], done: !o };
                }
            };
        throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
    }
    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;
    }
    /** @deprecated */
    function __spread() {
        for (var ar = [], i = 0; i < arguments.length; i++)
            ar = ar.concat(__read(arguments[i]));
        return ar;
    }
    /** @deprecated */
    function __spreadArrays() {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++)
            s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++)
            for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
                r[k] = a[j];
        return r;
    }
    function __spreadArray(to, from, pack) {
        if (pack || arguments.length === 2)
            for (var i = 0, l = from.length, ar; i < l; i++) {
                if (ar || !(i in from)) {
                    if (!ar)
                        ar = Array.prototype.slice.call(from, 0, i);
                    ar[i] = from[i];
                }
            }
        return to.concat(ar || Array.prototype.slice.call(from));
    }
    function __await(v) {
        return this instanceof __await ? (this.v = v, this) : new __await(v);
    }
    function __asyncGenerator(thisArg, _arguments, generator) {
        if (!Symbol.asyncIterator)
            throw new TypeError("Symbol.asyncIterator is not defined.");
        var g = generator.apply(thisArg, _arguments || []), i, q = [];
        return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
        function verb(n) { if (g[n])
            i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
        function resume(n, v) { try {
            step(g[n](v));
        }
        catch (e) {
            settle(q[0][3], e);
        } }
        function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
        function fulfill(value) { resume("next", value); }
        function reject(value) { resume("throw", value); }
        function settle(f, v) { if (f(v), q.shift(), q.length)
            resume(q[0][0], q[0][1]); }
    }
    function __asyncDelegator(o) {
        var i, p;
        return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
        function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
    }
    function __asyncValues(o) {
        if (!Symbol.asyncIterator)
            throw new TypeError("Symbol.asyncIterator is not defined.");
        var m = o[Symbol.asyncIterator], i;
        return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
        function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
        function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
    }
    function __makeTemplateObject(cooked, raw) {
        if (Object.defineProperty) {
            Object.defineProperty(cooked, "raw", { value: raw });
        }
        else {
            cooked.raw = raw;
        }
        return cooked;
    }
    ;
    var __setModuleDefault = Object.create ? (function (o, v) {
        Object.defineProperty(o, "default", { enumerable: true, value: v });
    }) : function (o, v) {
        o["default"] = v;
    };
    function __importStar(mod) {
        if (mod && mod.__esModule)
            return mod;
        var result = {};
        if (mod != null)
            for (var k in mod)
                if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
                    __createBinding(result, mod, k);
        __setModuleDefault(result, mod);
        return result;
    }
    function __importDefault(mod) {
        return (mod && mod.__esModule) ? mod : { default: mod };
    }
    function __classPrivateFieldGet(receiver, state, kind, f) {
        if (kind === "a" && !f)
            throw new TypeError("Private accessor was defined without a getter");
        if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
            throw new TypeError("Cannot read private member from an object whose class did not declare it");
        return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
    }
    function __classPrivateFieldSet(receiver, state, value, kind, f) {
        if (kind === "m")
            throw new TypeError("Private method is not writable");
        if (kind === "a" && !f)
            throw new TypeError("Private accessor was defined without a setter");
        if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
            throw new TypeError("Cannot write private member to an object whose class did not declare it");
        return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
    }

    var TOOLTIP_TEXT_INTERCEPTOR_TOKEN = new i0.InjectionToken('TOOLTIP_TEXT_INTERCEPTOR_TOKEN');
    var TOOLTIP_OPTIONS_TOKEN = new i0.InjectionToken('TOOLTIP_OPTIONS_TOKEN');

    var TooltipDomLeakService = /** @class */ (function () {
        function TooltipDomLeakService() {
            var _this = this;
            this.domMemoryLeakTicker$ = new rxjs.Subject();
            this.timeoutCheck = 500;
            this.actualContainsInDomUidCollections = new Set();
            this.domMemoryLeakTicker$.pipe(operators.debounceTime(this.timeoutCheck)).subscribe(function () {
                Array.from(new Set(_this.actualContainsInDomUidCollections)).forEach(function (uid) {
                    var _a;
                    var notExistParent = !document.querySelector("[data-tooltip-uid=\"" + uid + "\"]");
                    if (notExistParent) {
                        (_a = document.getElementById(uid)) === null || _a === void 0 ? void 0 : _a.remove();
                    }
                });
            });
        }
        TooltipDomLeakService.prototype.invalidationOfIrrelevantNodes = function () {
            this.domMemoryLeakTicker$.next();
        };
        return TooltipDomLeakService;
    }());
    /** @nocollapse */ /** @nocollapse */ TooltipDomLeakService.ɵfac = function TooltipDomLeakService_Factory(t) { return new (t || TooltipDomLeakService)(); };
    /** @nocollapse */ /** @nocollapse */ TooltipDomLeakService.ɵprov = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjectable({ token: TooltipDomLeakService, factory: TooltipDomLeakService.ɵfac });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(TooltipDomLeakService, [{
                type: i0.Injectable
            }], function () { return []; }, null);
    })();

    var TooltipDirective = /** @class */ (function () {
        function TooltipDirective(el, renderer, ngZone, options, interceptor, domLeak) {
            this.el = el;
            this.renderer = renderer;
            this.ngZone = ngZone;
            this.options = options;
            this.interceptor = interceptor;
            this.domLeak = domLeak;
            this.delta = 2;
            this.layoutMinDuration = 100;
            this.tooltipDomElement = null;
            this.timeoutId = null;
            this.frameId = null;
            this.createLayoutId = null;
            this.hideId = null;
            this.mouseLeaveTooltipId = null;
            this.tooltipMouseenter = null;
            this.tooltipMouseleave = null;
            this.handlerOptions = { passive: true };
            this.internalTooltipValue = null;
            this.internalContext = null;
            this.placement = 'top';
            this.localCssStyle = null;
            this.size = 'small';
            this.uid = string.generateQuickGuid();
            this.addUidToElement();
            this.connectMouseEvents();
        }
        Object.defineProperty(TooltipDirective.prototype, "context", {
            set: function (contextValue) {
                this.internalContext = contextValue;
                this.refreshTooltipContent();
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(TooltipDirective.prototype, "tooltip", {
            set: function (tooltipValue) {
                this.internalTooltipValue = tooltipValue;
                this.refreshTooltipContent();
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(TooltipDirective.prototype, "offsetElementHeight", {
            get: function () {
                var _a, _b;
                return (_b = (_a = this.tooltipDomElement) === null || _a === void 0 ? void 0 : _a.clientHeight) !== null && _b !== void 0 ? _b : 0;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(TooltipDirective.prototype, "offsetElementWidth", {
            get: function () {
                var _a, _b;
                return (_b = (_a = this.tooltipDomElement) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 0;
            },
            enumerable: false,
            configurable: true
        });
        TooltipDirective.getScrollPos = function () {
            return window.scrollY || document.documentElement.scrollTop || document.body.scrollTop || 0;
        };
        TooltipDirective.prototype.onMouseenterHandler = function () {
            if (this.tooltipDisabled) {
                return;
            }
            this.domLeak.invalidationOfIrrelevantNodes();
            this.showTooltip();
        };
        TooltipDirective.prototype.onMouseleaveHandler = function () {
            if (this.tooltipDisabled) {
                return;
            }
            this.destroyAllTimeouts();
            this.hideTooltip();
        };
        TooltipDirective.prototype.ngOnDestroy = function () {
            this.disconnectMouseEvents();
            this.destroyAllTimeouts();
            this.removeOldNodes();
        };
        TooltipDirective.prototype.showTooltip = function () {
            this.destroyAllTimeouts();
            if (utils.isNotNil(this.tooltipDomElement)) {
                this.addTooltipShowClass();
                return;
            }
            this.addTooltipToBodyWithAnimation();
        };
        TooltipDirective.prototype.hideTooltip = function () {
            var _this = this;
            this.ngZone.runOutsideAngular(function () {
                window.clearTimeout(_this.hideId);
                // eslint-disable-next-line no-restricted-properties
                _this.hideId = window.setTimeout(function () {
                    _this.removeTooltipShowClass();
                    // eslint-disable-next-line no-restricted-properties
                    _this.timeoutId = window.setTimeout(function () { return _this.removeOldNodes(); }, _this.options.durationAfterDestroy);
                }, _this.layoutMinDuration);
            });
        };
        TooltipDirective.prototype.addTooltipElementToBody = function () {
            this.tooltipDomElement = this.createTooltipElement();
            if (utils.isNotNil(this.tooltipDomElement)) {
                this.renderer.appendChild(document.body, this.tooltipDomElement);
                this.renderer.setAttribute(this.tooltipDomElement, 'id', this.uid);
                this.renderer.addClass(this.tooltipDomElement, 'ng-tooltip');
                this.renderer.addClass(this.tooltipDomElement, "ng-tooltip-" + this.placement);
                this.renderer.addClass(this.tooltipDomElement, "ng-tooltip-" + this.size);
            }
        };
        TooltipDirective.prototype.setPosition = function () {
            var _a;
            var hostPos = this.el.nativeElement.getBoundingClientRect();
            var tooltipPos = (_a = this.tooltipDomElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
            var scrollPos = TooltipDirective.getScrollPos();
            if (this.placement === 'top') {
                var _f = this.calculateByTop(hostPos, tooltipPos), top = _f.top, left = _f.left;
                this.setStyle(top, left, scrollPos);
            }
            else if (this.placement === 'bottom') {
                var _g = this.calculateByBottom(hostPos, tooltipPos), top = _g.top, left = _g.left;
                this.setStyle(top, left, scrollPos);
            }
            else if (this.placement === 'left') {
                var _h = this.calculateByLeft(hostPos, tooltipPos), top = _h.top, left = _h.left;
                this.setStyle(top, left, scrollPos);
            }
            else if (this.placement === 'right') {
                var _j = this.calculateByRight(hostPos, tooltipPos), top = _j.top, left = _j.left;
                this.setStyle(top, left, scrollPos);
            }
        };
        TooltipDirective.prototype.addTooltipToBodyWithAnimation = function () {
            var _this = this;
            this.ngZone.runOutsideAngular(function () {
                // eslint-disable-next-line no-restricted-properties
                _this.frameId = window.setTimeout(function () {
                    _this.addTooltipElementToBody();
                    if (utils.isNotNil(_this.tooltipDomElement)) {
                        _this.tooltipListenOnHoverEvent();
                        // eslint-disable-next-line no-restricted-properties
                        _this.createLayoutId = window.setTimeout(function () {
                            _this.setPosition();
                            _this.addTooltipShowClass();
                            _this.markElementAddInDom();
                        }, _this.layoutMinDuration);
                    }
                }, _this.options.durationBeforeCreate);
            });
        };
        TooltipDirective.prototype.refreshTooltipContent = function () {
            var e_1, _f;
            if (utils.isNotNil(this.tooltipDomElement)) {
                var contentDomElement = this.createTooltipContent();
                if (utils.isNotNil(contentDomElement)) {
                    var childElements = this.tooltipDomElement.children;
                    try {
                        for (var _g = __values(Array.from(childElements)), _h = _g.next(); !_h.done; _h = _g.next()) {
                            var child = _h.value;
                            this.renderer.removeChild(this.tooltipDomElement, child);
                        }
                    }
                    catch (e_1_1) { e_1 = { error: e_1_1 }; }
                    finally {
                        try {
                            if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
                        }
                        finally { if (e_1) throw e_1.error; }
                    }
                    this.renderer.appendChild(this.tooltipDomElement, contentDomElement);
                }
            }
        };
        TooltipDirective.prototype.markElementAddInDom = function () {
            if (utils.isNotNil(this.tooltipDomElement)) {
                this.domLeak.actualContainsInDomUidCollections.add(this.uid);
            }
        };
        TooltipDirective.prototype.markElementRemoveFromDom = function () {
            if (utils.isFalsy(this.tooltipDomElement)) {
                this.domLeak.actualContainsInDomUidCollections.delete(this.uid);
            }
        };
        TooltipDirective.prototype.connectMouseEvents = function () {
            var _this = this;
            this.ngZone.runOutsideAngular(function () {
                _this.el.nativeElement.addEventListener('mouseenter', function () { return _this.onMouseenterHandler(); }, _this.handlerOptions);
                _this.el.nativeElement.addEventListener('mouseleave', function () { return _this.onMouseleaveHandler(); }, _this.handlerOptions);
            });
        };
        TooltipDirective.prototype.disconnectMouseEvents = function () {
            var _this = this;
            this.el.nativeElement.removeEventListener('mouseenter', function () { return _this.onMouseenterHandler(); }, this.handlerOptions);
            this.el.nativeElement.removeEventListener('mouseleave', function () { return _this.onMouseleaveHandler(); }, this.handlerOptions);
        };
        TooltipDirective.prototype.addUidToElement = function () {
            this.el.nativeElement.setAttribute('data-tooltip-uid', this.uid);
        };
        TooltipDirective.prototype.addTooltipShowClass = function () {
            if (utils.isNotNil(this.tooltipDomElement)) {
                this.renderer.addClass(this.tooltipDomElement, 'ng-tooltip-show');
            }
        };
        TooltipDirective.prototype.removeTooltipShowClass = function () {
            if (utils.isNotNil(this.tooltipDomElement)) {
                this.renderer.removeClass(this.tooltipDomElement, 'ng-tooltip-show');
            }
        };
        TooltipDirective.prototype.tooltipListenOnHoverEvent = function () {
            var _this = this;
            var _a, _b;
            window.clearTimeout(this.mouseLeaveTooltipId);
            if (utils.isNotNil(this.tooltipDomElement)) {
                (_a = this.tooltipMouseenter) === null || _a === void 0 ? void 0 : _a.unsubscribe();
                (_b = this.tooltipMouseleave) === null || _b === void 0 ? void 0 : _b.unsubscribe();
                this.tooltipMouseenter = rxjs.fromEvent(this.tooltipDomElement, 'mouseenter').subscribe(function () {
                    window.clearTimeout(_this.hideId);
                    window.clearTimeout(_this.mouseLeaveTooltipId);
                });
                this.tooltipMouseleave = rxjs.fromEvent(this.tooltipDomElement, 'mouseleave').subscribe(function () {
                    window.clearTimeout(_this.mouseLeaveTooltipId);
                    // eslint-disable-next-line no-restricted-properties
                    _this.mouseLeaveTooltipId = window.setTimeout(function () { return _this.hideTooltip(); }, _this.options.timeoutForWaitAfterBlurTooltip);
                });
            }
        };
        TooltipDirective.prototype.createTooltipContent = function () {
            var _a, _b, _c, _d, _e;
            var content = document.createElement('div');
            if (this.internalTooltipValue instanceof i0.TemplateRef) {
                var view = this.internalTooltipValue.createEmbeddedView({
                    $implicit: this.internalContext
                });
                view.detectChanges();
                content.append.apply(content, __spreadArray([], __read(view.rootNodes), false));
            }
            else if (utils.checkValueIsEmpty(this.internalTooltipValue)) {
                return null;
            }
            else if (utils.isNotNil(this.internalTooltipValue)) {
                var value = (_a = this.internalTooltipValue) === null || _a === void 0 ? void 0 : _a.toString();
                content.innerHTML = (_d = (_c = (_b = this.interceptor).instant) === null || _c === void 0 ? void 0 : _c.call(_b, value)) !== null && _d !== void 0 ? _d : value;
            }
            content.style.cssText = (_e = this.localCssStyle) !== null && _e !== void 0 ? _e : this.options.cssStyle;
            return content;
        };
        TooltipDirective.prototype.createTooltipElement = function () {
            var contentDomElement = this.createTooltipContent();
            if (utils.isNotNil(contentDomElement)) {
                var tooltipDomElement = this.renderer.createElement('div');
                this.renderer.appendChild(tooltipDomElement, contentDomElement);
                return tooltipDomElement;
            }
            return null;
        };
        TooltipDirective.prototype.destroyAllTimeouts = function () {
            window.clearTimeout(this.frameId);
            window.clearTimeout(this.createLayoutId);
            window.clearTimeout(this.mouseLeaveTooltipId);
            window.clearTimeout(this.timeoutId);
            window.clearTimeout(this.hideId);
        };
        TooltipDirective.prototype.removeOldNodes = function () {
            if (utils.isNotNil(this.tooltipDomElement)) {
                var element = document.getElementById(this.uid);
                element === null || element === void 0 ? void 0 : element.remove();
                this.tooltipDomElement = null;
            }
            this.markElementRemoveFromDom();
        };
        TooltipDirective.prototype.setStyle = function (top, left, scrollPos) {
            this.renderer.setStyle(this.tooltipDomElement, 'top', top + scrollPos + "px");
            this.renderer.setStyle(this.tooltipDomElement, 'left', left + "px");
        };
        TooltipDirective.prototype.calculateByTop = function (hostPos, tooltipPos) {
            var _a;
            var top = hostPos.top - this.offsetElementHeight;
            var left = hostPos.left + (hostPos.width - ((_a = tooltipPos === null || tooltipPos === void 0 ? void 0 : tooltipPos.width) !== null && _a !== void 0 ? _a : 0)) / this.delta;
            return { top: top, left: left };
        };
        TooltipDirective.prototype.calculateByBottom = function (hostPos, tooltipPos) {
            var _a;
            var top = hostPos.bottom;
            var left = hostPos.left + (hostPos.width - ((_a = tooltipPos === null || tooltipPos === void 0 ? void 0 : tooltipPos.width) !== null && _a !== void 0 ? _a : 0)) / this.delta;
            return { top: top, left: left };
        };
        TooltipDirective.prototype.calculateByLeft = function (hostPos, tooltipPos) {
            var _a;
            var top = hostPos.top + (hostPos.height - ((_a = tooltipPos === null || tooltipPos === void 0 ? void 0 : tooltipPos.height) !== null && _a !== void 0 ? _a : 0)) / this.delta;
            var left = hostPos.left - this.offsetElementWidth;
            return { top: top, left: left };
        };
        TooltipDirective.prototype.calculateByRight = function (hostPos, tooltipPos) {
            var _a;
            var top = hostPos.top + (hostPos.height - ((_a = tooltipPos === null || tooltipPos === void 0 ? void 0 : tooltipPos.height) !== null && _a !== void 0 ? _a : 0)) / this.delta;
            var left = hostPos.right;
            return { top: top, left: left };
        };
        return TooltipDirective;
    }());
    /** @nocollapse */ /** @nocollapse */ TooltipDirective.ɵfac = function TooltipDirective_Factory(t) { return new (t || TooltipDirective)(i0__namespace.ɵɵdirectiveInject(i0__namespace.ElementRef), i0__namespace.ɵɵdirectiveInject(i0__namespace.Renderer2), i0__namespace.ɵɵdirectiveInject(i0__namespace.NgZone), i0__namespace.ɵɵdirectiveInject(TOOLTIP_OPTIONS_TOKEN), i0__namespace.ɵɵdirectiveInject(TOOLTIP_TEXT_INTERCEPTOR_TOKEN), i0__namespace.ɵɵdirectiveInject(TooltipDomLeakService)); };
    /** @nocollapse */ /** @nocollapse */ TooltipDirective.ɵdir = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineDirective({ type: TooltipDirective, selectors: [["", "tooltip", ""]], inputs: { tooltipDisabled: ["tooltip-disabled", "tooltipDisabled"], placement: ["tooltip-placement", "placement"], localCssStyle: ["tooltip-css-style", "localCssStyle"], size: ["tooltip-size", "size"], context: ["tooltip-context", "context"], tooltip: "tooltip" } });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(TooltipDirective, [{
                type: i0.Directive,
                args: [{ selector: '[tooltip]' }]
            }], function () {
            return [{ type: i0__namespace.ElementRef }, { type: i0__namespace.Renderer2 }, { type: i0__namespace.NgZone }, { type: undefined, decorators: [{
                            type: i0.Inject,
                            args: [TOOLTIP_OPTIONS_TOKEN]
                        }] }, { type: undefined, decorators: [{
                            type: i0.Inject,
                            args: [TOOLTIP_TEXT_INTERCEPTOR_TOKEN]
                        }] }, { type: TooltipDomLeakService }];
        }, { tooltipDisabled: [{
                    type: i0.Input,
                    args: ['tooltip-disabled']
                }], placement: [{
                    type: i0.Input,
                    args: ['tooltip-placement']
                }], localCssStyle: [{
                    type: i0.Input,
                    args: ['tooltip-css-style']
                }], size: [{
                    type: i0.Input,
                    args: ['tooltip-size']
                }], context: [{
                    type: i0.Input,
                    args: ['tooltip-context']
                }], tooltip: [{
                    type: i0.Input
                }] });
    })();

    var TOOLTIP_DEFAULT_OPTIONS = {
        cssStyle: '',
        durationBeforeCreate: 200,
        durationAfterDestroy: 1500,
        timeoutForWaitAfterBlurTooltip: 400
    };
    var NGX_TOOLTIP_FALLBACK_PROVIDER = {
        provide: TOOLTIP_TEXT_INTERCEPTOR_TOKEN,
        useClass: NgxTooltipTextInterceptor
    };

    var TooltipModule = /** @class */ (function () {
        function TooltipModule() {
        }
        TooltipModule.forRoot = function (options) {
            if (options === void 0) { options = {}; }
            return {
                ngModule: TooltipModule,
                providers: [
                    { provide: TOOLTIP_OPTIONS_TOKEN, useValue: Object.assign(Object.assign({}, TOOLTIP_DEFAULT_OPTIONS), options) },
                    { provide: TOOLTIP_TEXT_INTERCEPTOR_TOKEN, useClass: TooltipDefaultTextInterceptor }
                ]
            };
        };
        return TooltipModule;
    }());
    /** @nocollapse */ /** @nocollapse */ TooltipModule.ɵfac = function TooltipModule_Factory(t) { return new (t || TooltipModule)(); };
    /** @nocollapse */ /** @nocollapse */ TooltipModule.ɵmod = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineNgModule({ type: TooltipModule });
    /** @nocollapse */ /** @nocollapse */ TooltipModule.ɵinj = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjector({ providers: [TooltipDomLeakService], imports: [[common.CommonModule]] });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(TooltipModule, [{
                type: i0.NgModule,
                args: [{
                        imports: [common.CommonModule],
                        exports: [TooltipDirective],
                        declarations: [TooltipDirective],
                        providers: [TooltipDomLeakService]
                    }]
            }], null, null);
    })();
    (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0__namespace.ɵɵsetNgModuleScope(TooltipModule, { declarations: [TooltipDirective], imports: [common.CommonModule], exports: [TooltipDirective] }); })();

    /**
     * Generated bundle index. Do not edit.
     */

    exports.NGX_TOOLTIP_FALLBACK_PROVIDER = NGX_TOOLTIP_FALLBACK_PROVIDER;
    exports.NgxTooltipTextInterceptor = NgxTooltipTextInterceptor;
    exports.TOOLTIP_DEFAULT_OPTIONS = TOOLTIP_DEFAULT_OPTIONS;
    exports.TOOLTIP_OPTIONS_TOKEN = TOOLTIP_OPTIONS_TOKEN;
    exports.TOOLTIP_TEXT_INTERCEPTOR_TOKEN = TOOLTIP_TEXT_INTERCEPTOR_TOKEN;
    exports.TooltipDefaultTextInterceptor = TooltipDefaultTextInterceptor;
    exports.TooltipDirective = TooltipDirective;
    exports.TooltipModule = TooltipModule;

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

})));
//# sourceMappingURL=angular-ru-cdk-tooltip.umd.js.map
