(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/animations'), require('@bravobit/bb-foundation/localize'), require('@bravobit/bb-foundation'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
    typeof define === 'function' && define.amd ? define('@bravobit/bb-foundation/notifications', ['exports', '@angular/core', '@angular/animations', '@bravobit/bb-foundation/localize', '@bravobit/bb-foundation', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
    (global = global || self, factory((global.bravobit = global.bravobit || {}, global.bravobit['bb-foundation'] = global.bravobit['bb-foundation'] || {}, global.bravobit['bb-foundation'].notifications = {}), global.ng.core, global.ng.animations, global.bravobit['bb-foundation'].localize, global.bravobit['bb-foundation'], global.rxjs, global.rxjs.operators, global.ng.common));
}(this, (function (exports, core, animations, localize, bbFoundation, rxjs, 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.
    ***************************************************************************** */
    /* 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 (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };

    function __extends(d, b) {
        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) {
        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) : new P(function (resolve) { resolve(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 };
        }
    }

    function __exportStar(m, exports) {
        for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
    }

    function __values(o) {
        var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
        if (m) return m.call(o);
        return {
            next: function () {
                if (o && i >= o.length) o = void 0;
                return { value: o && o[i++], done: !o };
            }
        };
    }

    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;
    }

    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 __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;
    };

    function __importStar(mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
        result.default = mod;
        return result;
    }

    function __importDefault(mod) {
        return (mod && mod.__esModule) ? mod : { default: mod };
    }

    /**
     * @fileoverview added by tsickle
     * Generated from: lib/notifications.interfaces.ts
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    /**
     * @record
     */
    function Notification() { }
    if (false) {
        /** @type {?} */
        Notification.prototype.content;
        /** @type {?|undefined} */
        Notification.prototype.id;
        /** @type {?|undefined} */
        Notification.prototype.timeout;
        /** @type {?|undefined} */
        Notification.prototype.localize;
        /** @type {?|undefined} */
        Notification.prototype.dismiss;
        /** @type {?|undefined} */
        Notification.prototype.dismissText;
        /** @type {?|undefined} */
        Notification.prototype.data;
        /** @type {?|undefined} */
        Notification.prototype.type;
        /** @type {?|undefined} */
        Notification.prototype.actions;
        /** @type {?|undefined} */
        Notification.prototype.color;
        /** @type {?|undefined} */
        Notification.prototype.backgroundColor;
        /** @type {?|undefined} */
        Notification.prototype.destroy;
    }
    /**
     * @record
     */
    function NotificationAction() { }
    if (false) {
        /** @type {?} */
        NotificationAction.prototype.title;
        /** @type {?|undefined} */
        NotificationAction.prototype.callback;
        /** @type {?|undefined} */
        NotificationAction.prototype.type;
    }
    /** @enum {string} */
    var NotificationType = {
        Success: "success",
        Error: "error",
        Warning: "warning",
        Info: "info",
        Custom: "custom",
    };
    var NotificationsConfig = /** @class */ (function () {
        function NotificationsConfig() {
        }
        return NotificationsConfig;
    }());
    if (false) {
        /** @type {?} */
        NotificationsConfig.prototype.mode;
        /** @type {?} */
        NotificationsConfig.prototype.position;
        /** @type {?} */
        NotificationsConfig.prototype.timeout;
        /** @type {?} */
        NotificationsConfig.prototype.dismiss;
        /** @type {?} */
        NotificationsConfig.prototype.localize;
        /** @type {?} */
        NotificationsConfig.prototype.dismissText;
    }
    /** @enum {string} */
    var NotificationsPosition = {
        TopRight: "flex-start|flex-end",
        BottomRight: "flex-end|flex-end",
        TopLeft: "flex-start|flex-start",
        BottomLeft: "flex-end|flex-start",
    };
    var NotificationsData = /** @class */ (function () {
        function NotificationsData() {
        }
        return NotificationsData;
    }());
    if (false) {
        /** @type {?} */
        NotificationsData.prototype.data;
        /** @type {?} */
        NotificationsData.prototype.dismissText;
        /** @type {?} */
        NotificationsData.prototype.position;
    }

    /**
     * @fileoverview added by tsickle
     * Generated from: lib/notifications.animations.ts
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    /** @type {?} */
    var s = '250ms cubic-bezier(0, 0, .2, 1)';
    /** @type {?} */
    var l = '400ms cubic-bezier(0, 0, .2, 1)';
    /** @type {?} */
    var notificationAnimation = animations.trigger('notificationListAnimation', [
        animations.transition('* => *', [
            animations.query(':enter', animations.group([
                // 1. Set the initial state.
                animations.style({ height: 0, opacity: 0, transform: 'translateX({{ to }}%) scale(0.95)' }),
                // 2. Start the animation to show the item.
                animations.stagger(0, [
                    animations.animate(s, animations.style({ height: '*' })),
                    animations.animate(l, animations.style({ opacity: 1, transform: 'translateX(0) scale(0.95)' })),
                    animations.animate(s, animations.style({ transform: 'translateX(0) scale(1)' }))
                ])
            ]), { optional: true }),
            animations.query(':leave', animations.group([
                // 1. Set the initial state.
                animations.style({ height: '*', opacity: 1, transform: 'translateX(0) scale(1)' }),
                // 2. Start the animation to hide the item.
                animations.stagger(0, [
                    animations.animate(s, animations.style({ transform: 'translateX(0) scale(0.95)' })),
                    animations.animate(l, animations.style({ opacity: 0, transform: 'translateX({{ to }}%) scale(0.95)' })),
                    animations.animate(s, animations.style({ height: 0 }))
                ])
            ]), { optional: true })
        ])
    ]);

    /**
     * @fileoverview added by tsickle
     * Generated from: lib/notifications-list/notifications-list.component.ts
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var BbNotificationsList = /** @class */ (function () {
        function BbNotificationsList(data) {
            this.data = data;
            // Data.
            this.position = null;
            // Track by function.
            this.trackByFn = (/**
             * @param {?} _
             * @param {?} item
             * @return {?}
             */
            function (_, item) { return item.id; });
        }
        Object.defineProperty(BbNotificationsList.prototype, "horizontalPosition", {
            get: /**
             * @return {?}
             */
            function () {
                return this.location.horizontal;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BbNotificationsList.prototype, "verticalPosition", {
            get: /**
             * @return {?}
             */
            function () {
                return this.location.vertical;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BbNotificationsList.prototype, "animation", {
            get: /**
             * @return {?}
             */
            function () {
                /** @type {?} */
                var to = this.horizontalPosition === 'flex-start'
                    ? -50
                    : 50;
                return { to: to };
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BbNotificationsList.prototype, "location", {
            get: /**
             * @private
             * @return {?}
             */
            function () {
                var _a = __read((this.data.position || '').split('|'), 2), y = _a[0], x = _a[1];
                return { vertical: y || null, horizontal: x || null };
            },
            enumerable: true,
            configurable: true
        });
        BbNotificationsList.decorators = [
            { type: core.Component, args: [{
                        selector: 'bb-notifications-list',
                        template: "<!--\r\n    The notifications list.\r\n\r\n    The list provides the animation effect for the\r\n    incoming notifications.\r\n-->\r\n<div *ngIf=\"data?.data | async as notifications\"\r\n     [@notificationListAnimation]=\"{value: notifications?.length, params: animation}\"\r\n     class=\"notifications-list-wrapper\">\r\n    <!--\r\n        The loop for the notifications.\r\n\r\n        All notifications will be displayed here. They\r\n        are wrapped within a wrapper which separates them.\r\n    -->\r\n    <div *ngFor=\"let notification of notifications; trackBy: trackByFn\"\r\n         class=\"notifications-item-wrapper\">\r\n        <bb-notifications-item [notification]=\"notification\"\r\n                               [dismissButtonText]=\"data?.dismissText\">\r\n        </bb-notifications-item>\r\n    </div>\r\n</div>\r\n",
                        animations: [notificationAnimation],
                        changeDetection: core.ChangeDetectionStrategy.OnPush,
                        encapsulation: core.ViewEncapsulation.None,
                        preserveWhitespaces: false,
                        host: {
                            'class': 'bb-notifications-list',
                            'role': 'list'
                        },
                        styles: [".bb-notifications-list{top:0;left:0;right:0;bottom:0;z-index:1100;padding:10px;display:-ms-flexbox;display:flex;position:fixed;pointer-events:none}.notifications-list-wrapper{width:100%;display:block;max-width:400px;position:relative}.notifications-item-wrapper{padding:0;margin:0 0 10px;pointer-events:all}"]
                    }] }
        ];
        /** @nocollapse */
        BbNotificationsList.ctorParameters = function () { return [
            { type: NotificationsData }
        ]; };
        BbNotificationsList.propDecorators = {
            horizontalPosition: [{ type: core.HostBinding, args: ['style.justify-content',] }],
            verticalPosition: [{ type: core.HostBinding, args: ['style.align-items',] }]
        };
        return BbNotificationsList;
    }());
    if (false) {
        /** @type {?} */
        BbNotificationsList.prototype.position;
        /** @type {?} */
        BbNotificationsList.prototype.trackByFn;
        /** @type {?} */
        BbNotificationsList.prototype.data;
    }

    /**
     * @fileoverview added by tsickle
     * Generated from: lib/notifications.injector.ts
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var NotificationsInjector = /** @class */ (function () {
        function NotificationsInjector(_parentInjector, _additionalTokens) {
            this._parentInjector = _parentInjector;
            this._additionalTokens = _additionalTokens;
        }
        /**
         * @param {?} token
         * @param {?=} notFoundValue
         * @return {?}
         */
        NotificationsInjector.prototype.get = /**
         * @param {?} token
         * @param {?=} notFoundValue
         * @return {?}
         */
        function (token, notFoundValue) {
            // First check if the additional token
            // contains the token.
            /** @type {?} */
            var value = this._additionalTokens.get(token);
            // If that value exists return it.
            if (value) {
                return value;
            }
            // Else query the parent injector.
            return this._parentInjector.get(token, notFoundValue);
        };
        return NotificationsInjector;
    }());
    if (false) {
        /**
         * @type {?}
         * @private
         */
        NotificationsInjector.prototype._parentInjector;
        /**
         * @type {?}
         * @private
         */
        NotificationsInjector.prototype._additionalTokens;
    }

    /**
     * @fileoverview added by tsickle
     * Generated from: lib/notifications.service.ts
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var Notifications = /** @class */ (function () {
        function Notifications(_injector, _platform, _applicationRef, _localize, _config, _componentFactoryResolver) {
            this._injector = _injector;
            this._platform = _platform;
            this._applicationRef = _applicationRef;
            this._localize = _localize;
            this._config = _config;
            this._componentFactoryResolver = _componentFactoryResolver;
            // The data containing the notifications.
            this._notifications$ = new rxjs.BehaviorSubject([]);
            this.getProperty = (/**
             * @param {?} property
             * @param {?} defaultValue
             * @return {?}
             */
            function (property, defaultValue) {
                return typeof property === 'undefined'
                    ? defaultValue
                    : property;
            });
            // Get the config.
            /** @type {?} */
            var config = this._config || {};
            // Set the config.
            this._defaultMode = this.getProperty(config.mode, 'prepend');
            this._defaultTimeout = this.getProperty(config.timeout, 8000);
            this._defaultLocalize = this.getProperty(config.localize, false);
            this._defaultDismiss = this.getProperty(config.dismiss, true);
            this._defaultDismissText = this.getProperty(config.dismissText, 'Dismiss');
            this._defaultPosition = this.getProperty(config.position, NotificationsPosition.TopRight);
            // Create the element that holds all notifications.
            this.createElement();
        }
        /**
         * @param {?} content
         * @param {?=} actions
         * @param {?=} timeout
         * @return {?}
         */
        Notifications.prototype.success = /**
         * @param {?} content
         * @param {?=} actions
         * @param {?=} timeout
         * @return {?}
         */
        function (content, actions, timeout) {
            if (actions === void 0) { actions = []; }
            if (timeout === void 0) { timeout = this._defaultTimeout; }
            return this.create({ content: content, timeout: timeout, actions: actions, type: NotificationType.Success });
        };
        /**
         * @param {?} content
         * @param {?=} actions
         * @param {?=} timeout
         * @return {?}
         */
        Notifications.prototype.error = /**
         * @param {?} content
         * @param {?=} actions
         * @param {?=} timeout
         * @return {?}
         */
        function (content, actions, timeout) {
            if (actions === void 0) { actions = []; }
            if (timeout === void 0) { timeout = this._defaultTimeout; }
            return this.create({ content: content, timeout: timeout, actions: actions, type: NotificationType.Error });
        };
        /**
         * @param {?} content
         * @param {?=} actions
         * @param {?=} timeout
         * @return {?}
         */
        Notifications.prototype.warn = /**
         * @param {?} content
         * @param {?=} actions
         * @param {?=} timeout
         * @return {?}
         */
        function (content, actions, timeout) {
            if (actions === void 0) { actions = []; }
            if (timeout === void 0) { timeout = this._defaultTimeout; }
            return this.create({ content: content, timeout: timeout, actions: actions, type: NotificationType.Warning });
        };
        /**
         * @param {?} content
         * @param {?=} actions
         * @param {?=} timeout
         * @return {?}
         */
        Notifications.prototype.info = /**
         * @param {?} content
         * @param {?=} actions
         * @param {?=} timeout
         * @return {?}
         */
        function (content, actions, timeout) {
            if (actions === void 0) { actions = []; }
            if (timeout === void 0) { timeout = this._defaultTimeout; }
            return this.create({ content: content, timeout: timeout, actions: actions, type: NotificationType.Info });
        };
        /**
         * @param {?} notification
         * @return {?}
         */
        Notifications.prototype.create = /**
         * @param {?} notification
         * @return {?}
         */
        function (notification) {
            var _this = this;
            // Compose a new notification item.
            /** @type {?} */
            var item = this.compose(notification);
            // Add the destroy function to the notification.
            item.destroy = (/**
             * @return {?}
             */
            function () { return _this.pull(item); });
            // Add the notification to the list
            // and return the item.
            return this.push(item);
        };
        /**
         * @private
         * @param {?} notification
         * @return {?}
         */
        Notifications.prototype.push = /**
         * @private
         * @param {?} notification
         * @return {?}
         */
        function (notification) {
            // Get the current list.
            /** @type {?} */
            var oldList = this._notifications$.getValue();
            // Check which mode is activated.
            /** @type {?} */
            var newList = __spread(oldList);
            switch (this._defaultMode) {
                case 'append':
                    newList = __spread(oldList, [notification]);
                    break;
                case 'prepend':
                default:
                    newList = __spread([notification], oldList);
            }
            // Push the new notifications.
            this._notifications$.next(newList);
            // Return the notification for further use.
            return notification;
        };
        /**
         * @private
         * @param {?} notification
         * @return {?}
         */
        Notifications.prototype.pull = /**
         * @private
         * @param {?} notification
         * @return {?}
         */
        function (notification) {
            // Get the current list.
            /** @type {?} */
            var newList = this._notifications$
                .getValue()
                .filter((/**
             * @param {?} item
             * @return {?}
             */
            function (item) { return item.id !== notification.id; }));
            // Push a new list.
            this._notifications$.next(newList);
        };
        /**
         * @private
         * @param {?} notification
         * @return {?}
         */
        Notifications.prototype.compose = /**
         * @private
         * @param {?} notification
         * @return {?}
         */
        function (notification) {
            // Attach a random id to the notification.
            notification.id = Math.random().toString(36).substr(2, 10);
            // Set all properties.
            notification.type = this.getProperty(notification.type, NotificationType.Custom);
            notification.content = this.getProperty(notification.content, null);
            notification.data = this.getProperty(notification.data, {});
            notification.timeout = this.getProperty(notification.timeout, this._defaultTimeout);
            notification.localize = this.getProperty(notification.localize, this._defaultLocalize);
            notification.dismiss = this.getProperty(notification.dismiss, this._defaultDismiss);
            // Dismiss text localization.
            /** @type {?} */
            var dismissText = this.getProperty(notification.dismissText, this._defaultDismissText);
            notification.dismissText = this._defaultLocalize && this._localize
                ? this._localize.translate(dismissText)
                : dismissText;
            // Return the composed notification.
            return notification;
        };
        /**
         * @private
         * @return {?}
         */
        Notifications.prototype.createElement = /**
         * @private
         * @return {?}
         */
        function () {
            // Create a map with the config.
            /** @type {?} */
            var map = new WeakMap();
            map.set(NotificationsData, {
                data: this._notifications$.pipe(operators.share()),
                dismissText: this._defaultDismissText,
                position: this._defaultPosition
            });
            // Create a custom injector.
            /** @type {?} */
            var notificationsInjector = new NotificationsInjector(this._injector, map);
            // Create the notification list and
            // get a reference to the component.
            this._ref = this._componentFactoryResolver
                .resolveComponentFactory(BbNotificationsList)
                .create(notificationsInjector);
            // Detect the changes.
            this._ref.changeDetectorRef.detectChanges();
            // Attach the component's view to the application
            // so that the change detection will run properly.
            this._applicationRef.attachView(this._ref.hostView);
            // If the platform is not a browser return.
            if (!this._platform.isBrowser) {
                return;
            }
            try {
                // Append the element to the DOM.
                document.body.appendChild(this._ref.location.nativeElement);
            }
            catch (_a) {
                // Don't do anything, because it must've failed.
            }
        };
        Notifications.decorators = [
            { type: core.Injectable }
        ];
        /** @nocollapse */
        Notifications.ctorParameters = function () { return [
            { type: core.Injector },
            { type: bbFoundation.Platform },
            { type: core.ApplicationRef },
            { type: localize.Localize, decorators: [{ type: core.Optional }] },
            { type: NotificationsConfig, decorators: [{ type: core.Optional }] },
            { type: core.ComponentFactoryResolver }
        ]; };
        return Notifications;
    }());
    if (false) {
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._ref;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._defaultMode;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._defaultTimeout;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._defaultLocalize;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._defaultDismiss;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._defaultDismissText;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._defaultPosition;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._notifications$;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype.getProperty;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._injector;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._platform;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._applicationRef;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._localize;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._config;
        /**
         * @type {?}
         * @private
         */
        Notifications.prototype._componentFactoryResolver;
    }

    /**
     * @fileoverview added by tsickle
     * Generated from: lib/notifications-item/notifications-item.component.ts
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var BbNotificationsItem = /** @class */ (function () {
        function BbNotificationsItem(_zone, _platform, _changeDetection) {
            var _this = this;
            this._zone = _zone;
            this._platform = _platform;
            this._changeDetection = _changeDetection;
            // Data.
            this._progress = 0;
            this._count = 0;
            // Data.
            this._radius = 19;
            this._circumference = this._radius * 2 * Math.PI;
            this.callActionAndDestroy = (/**
             * @param {?} notification
             * @param {?} action
             * @return {?}
             */
            function (notification, action) {
                // Perform the callback (if it exists).
                action && action.callback && action.callback();
                // Call the destroy method (if it exists).
                notification && notification.destroy && notification.destroy();
            });
            this.instance = (/**
             * @return {?}
             */
            function () {
                // Calculate the difference.
                _this._difference = (new Date().getTime() - _this._startTime) - (_this._count * _this._speed);
                // Add up the count.
                if (_this._count++ === _this._steps) {
                    _this.notification.destroy();
                }
                // Add the steps to the progress.
                _this._progress += 100 / _this._steps;
                // Set a new timer.
                _this._timer = _this.setTimeout(_this.instance, _this._speed - _this._difference);
                // Run a new change detection cycle.
                _this._zone.run((/**
                 * @return {?}
                 */
                function () { return _this._changeDetection.detectChanges(); }));
            });
            this.setTimeout = (/**
             * @param {?} method
             * @param {?} timeout
             * @return {?}
             */
            function (method, timeout) {
                // Check if the window and method exist.
                if (!window || !window.setTimeout) {
                    return null;
                }
                return window.setTimeout(method, timeout);
            });
        }
        Object.defineProperty(BbNotificationsItem.prototype, "getClass", {
            get: /**
             * @return {?}
             */
            function () {
                return "bb-notifications-item " + this.notification.type;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BbNotificationsItem.prototype, "progressStrokeArray", {
            get: /**
             * @return {?}
             */
            function () {
                /** @type {?} */
                var value = Math.floor(this._circumference);
                return value + ", " + value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BbNotificationsItem.prototype, "progressStrokeOffset", {
            get: /**
             * @return {?}
             */
            function () {
                return Math.floor(this._circumference - this._progress / 100 * this._circumference);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BbNotificationsItem.prototype, "isContentString", {
            get: /**
             * @return {?}
             */
            function () {
                return typeof this.notification.content === 'string';
            },
            enumerable: true,
            configurable: true
        });
        /**
         * @return {?}
         */
        BbNotificationsItem.prototype.ngOnInit = /**
         * @return {?}
         */
        function () {
            // Check if the notification timeout is not 0 and the platform is a browser.
            if (this.notification.timeout <= 0 || !this._platform.isBrowser) {
                this.notification.dismiss = true;
                return;
            }
            // Start the timeout.
            this.startTimeout();
        };
        /**
         * @return {?}
         */
        BbNotificationsItem.prototype.ngOnDestroy = /**
         * @return {?}
         */
        function () {
            // Clear the timeout if it was set.
            this._timer && window && window.clearTimeout && window.clearTimeout(this._timer);
        };
        /**
         * @private
         * @return {?}
         */
        BbNotificationsItem.prototype.startTimeout = /**
         * @private
         * @return {?}
         */
        function () {
            var _this = this;
            // Calculate the steps of the timeout.
            this._steps = this.notification.timeout / 10;
            // Calculate the speed of the timeout.
            this._speed = this.notification.timeout / this._steps;
            // Get the start time.
            this._startTime = new Date().getTime();
            // Set a new timer outside of Angular.
            this._zone.runOutsideAngular((/**
             * @return {?}
             */
            function () { return _this._timer = _this.setTimeout(_this.instance, _this._speed); }));
        };
        BbNotificationsItem.decorators = [
            { type: core.Component, args: [{
                        selector: 'bb-notifications-item',
                        template: "<div class=\"notification-content-wrapper\">\r\n    <!--\r\n        The icon for the notification.\r\n\r\n        The icon is reflected by the type of the\r\n        notification. Same goes for the color and\r\n        background-color.\r\n    -->\r\n    <div [style.color]=\"notification?.color\"\r\n         [style.background-color]=\"notification?.backgroundColor\"\r\n         class=\"notification-icon-wrapper\">\r\n        <svg xmlns=\"http://www.w3.org/2000/svg\"\r\n             viewBox=\"0 0 16 19.5\"\r\n             class=\"notification-icon\">\r\n            <path\r\n                d=\"M8 19.5c1.1 0 2-.9 2-2H6c0 1.1.9 2 2 2zM14 13.5v-5c0-3.1-1.6-5.6-4.5-6.3v-.7C9.5.7 8.8 0 8 0S6.5.7 6.5 1.5v.7C3.6 2.9 2 5.4 2 8.5v5l-2 2v1h16v-1l-2-2z\">\r\n            </path>\r\n        </svg>\r\n\r\n        <!--\r\n            The circular progress for the notification.\r\n\r\n            The progress is only visible when a timeout is\r\n            set. The progress adapts to the time remaining\r\n            for the notification.\r\n        -->\r\n        <svg *ngIf=\"notification?.timeout > 0\"\r\n             class=\"notification-progress-ring\"\r\n             viewBox=\"0 0 40 40\"\r\n             role=\"progressbar\">\r\n            <circle #progress\r\n                    [attr.stroke-dasharray]=\"progressStrokeArray\"\r\n                    [attr.stroke-dashoffset]=\"progressStrokeOffset\"\r\n                    [style.stroke]=\"notification?.color\"\r\n                    class=\"notification-progress-circle\"\r\n                    stroke-width=\"2\"\r\n                    fill=\"transparent\"\r\n                    r=\"19\"\r\n                    cx=\"20\"\r\n                    cy=\"20\">\r\n            </circle>\r\n        </svg>\r\n    </div>\r\n\r\n    <!--\r\n        The content for the notification.\r\n\r\n        This displays a string or a template based\r\n        on the given parameter by the user.\r\n    -->\r\n    <div class=\"notification-content\">\r\n        <ng-container *ngIf=\"isContentString; else templateContent\"\r\n                      [ngSwitch]=\"notification?.localize\">\r\n            <ng-container *ngSwitchCase=\"true\">\r\n                {{ notification?.content | bbLocalize:{data: notification?.data} }}\r\n            </ng-container>\r\n            <ng-container *ngSwitchDefault>\r\n                {{ notification?.content }}\r\n            </ng-container>\r\n        </ng-container>\r\n    </div>\r\n</div>\r\n\r\n<!--\r\n    The actions of the notification.\r\n\r\n    All actions are displayed here and are\r\n    based on the actions array the user provided.\r\n-->\r\n<div *ngIf=\"notification?.actions?.length > 0 || notification?.dismiss\"\r\n     class=\"notification-actions\">\r\n    <button *ngFor=\"let action of notification?.actions\"\r\n            (click)=\"callActionAndDestroy(notification, action)\"\r\n            type=\"button\"\r\n            [class.destructive]=\"action?.type === 'cancel'\"\r\n            class=\"notification-actions-button\">\r\n        <span [ngSwitch]=\"notification?.localize\"\r\n              class=\"notification-actions-button-highlight\">\r\n            <ng-container *ngSwitchCase=\"true\">\r\n                {{ action?.title | bbLocalize:{data: notification?.data} }}\r\n            </ng-container>\r\n            <ng-container *ngSwitchDefault>\r\n                {{ action?.title }}\r\n            </ng-container>\r\n        </span>\r\n    </button>\r\n    <button *ngIf=\"notification?.dismiss\"\r\n            (click)=\"notification?.destroy()\"\r\n            class=\"notification-actions-button destructive\"\r\n            type=\"button\">\r\n        <span class=\"notification-actions-button-highlight\">\r\n            {{ notification?.dismissText || dismissButtonText }}\r\n        </span>\r\n    </button>\r\n</div>\r\n\r\n<!--\r\n    The outlet for the notification content template ref.\r\n-->\r\n<ng-template #templateContent>\r\n    <ng-container *ngTemplateOutlet=\"notification?.content\"></ng-container>\r\n</ng-template>\r\n",
                        changeDetection: core.ChangeDetectionStrategy.OnPush,
                        encapsulation: core.ViewEncapsulation.None,
                        preserveWhitespaces: false,
                        host: {
                            'role': 'alert'
                        },
                        styles: [".bb-notifications-item{display:-ms-flexbox;display:flex;border-radius:4px;-ms-flex-direction:column;flex-direction:column;background-color:#fff;border:1px solid #d6dbe0}.bb-notifications-item.success .notification-icon-wrapper{color:#2dc05d;background-color:#ebfaf0}.bb-notifications-item.success .notification-progress-circle{stroke:#36d068}.bb-notifications-item.error .notification-icon-wrapper{color:#f43e3e;background-color:#feeeee}.bb-notifications-item.error .notification-progress-circle{stroke:#f55656}.bb-notifications-item.warning .notification-icon-wrapper{color:#f1ae00;background-color:#fff8e7}.bb-notifications-item.warning .notification-progress-circle{stroke:#ffbc0b}.bb-notifications-item.info .notification-icon-wrapper{color:#099bf6;background-color:#e9f6fe}.bb-notifications-item.info .notification-progress-circle{stroke:#22a5f7}.bb-notifications-item.custom .notification-icon-wrapper{color:#657385;background-color:#f3f5f6}.bb-notifications-item.custom .notification-progress-circle{stroke:#657385}.notification-content-wrapper{padding:20px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.notification-icon-wrapper{width:40px;height:40px;display:-ms-flexbox;display:flex;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:relative;border-radius:50%;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;color:#657385;background-color:#f3f5f6}.notification-icon{width:100%;height:100%;padding:10px;fill:currentColor}.notification-content{-ms-flex:1;flex:1;font-size:14px;line-height:1.5;font-weight:500;margin-left:20px;color:rgba(0,0,0,.85)}.notification-content i{font-style:italic}.notification-actions-button,.notification-content{font-family:inherit}.notification-actions{display:-ms-flexbox;display:flex;margin:0 20px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-top:1px solid #f3f5f6}.notification-actions-button{-ms-flex:1;flex:1;border:none;color:#22a5f7;cursor:pointer;font-size:14px;font-weight:500;padding:12px 2px;text-align:center;background-color:transparent}.notification-actions-button:focus>.notification-actions-button-highlight,.notification-actions-button:hover>.notification-actions-button-highlight{background-color:rgba(34,165,247,.1)}.notification-actions-button:active>.notification-actions-button-highlight{background-color:rgba(34,165,247,.2)}.notification-actions-button.destructive{color:#f55656}.notification-actions-button.destructive:focus>.notification-actions-button-highlight,.notification-actions-button.destructive:hover>.notification-actions-button-highlight{background-color:rgba(245,86,86,.1)}.notification-actions-button.destructive:active>.notification-actions-button-highlight{background-color:rgba(245,86,86,.2)}.notification-actions-button-highlight{padding:4px 12px;border-radius:12px;display:-ms-inline-flexbox;display:inline-flex;transition:background-color 150ms cubic-bezier(0,0,.2,1)}.notification-progress-ring{top:0;left:0;right:0;bottom:0;width:100%;height:100%;position:absolute}.notification-progress-circle{-ms-transform:rotate(-90deg);transform:rotate(-90deg);-ms-transform-origin:50% 50%;transform-origin:50% 50%;stroke:#657385}"]
                    }] }
        ];
        /** @nocollapse */
        BbNotificationsItem.ctorParameters = function () { return [
            { type: core.NgZone },
            { type: bbFoundation.Platform },
            { type: core.ChangeDetectorRef }
        ]; };
        BbNotificationsItem.propDecorators = {
            notification: [{ type: core.Input }],
            dismissButtonText: [{ type: core.Input }],
            progressElementRef: [{ type: core.ViewChild, args: ['progress', { static: false },] }],
            getClass: [{ type: core.HostBinding, args: ['class',] }]
        };
        return BbNotificationsItem;
    }());
    if (false) {
        /** @type {?} */
        BbNotificationsItem.prototype.notification;
        /** @type {?} */
        BbNotificationsItem.prototype.dismissButtonText;
        /** @type {?} */
        BbNotificationsItem.prototype.progressElementRef;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._progress;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._count;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._steps;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._speed;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._timer;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._startTime;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._difference;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._radius;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._circumference;
        /** @type {?} */
        BbNotificationsItem.prototype.callActionAndDestroy;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype.instance;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype.setTimeout;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._zone;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._platform;
        /**
         * @type {?}
         * @private
         */
        BbNotificationsItem.prototype._changeDetection;
    }

    /**
     * @fileoverview added by tsickle
     * Generated from: lib/notifications.module.ts
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    var NotificationsModule = /** @class */ (function () {
        function NotificationsModule() {
        }
        /**
         * @param {?=} config
         * @return {?}
         */
        NotificationsModule.forRoot = /**
         * @param {?=} config
         * @return {?}
         */
        function (config) {
            return {
                ngModule: NotificationsModule,
                providers: [
                    { provide: NotificationsConfig, useValue: config },
                    Notifications
                ]
            };
        };
        NotificationsModule.decorators = [
            { type: core.NgModule, args: [{
                        imports: [common.CommonModule, localize.LocalizeModule],
                        declarations: [BbNotificationsList, BbNotificationsItem],
                        entryComponents: [BbNotificationsList]
                    },] }
        ];
        return NotificationsModule;
    }());

    exports.NotificationType = NotificationType;
    exports.Notifications = Notifications;
    exports.NotificationsConfig = NotificationsConfig;
    exports.NotificationsData = NotificationsData;
    exports.NotificationsModule = NotificationsModule;
    exports.NotificationsPosition = NotificationsPosition;
    exports.ɵa = BbNotificationsList;
    exports.ɵb = notificationAnimation;
    exports.ɵc = BbNotificationsItem;

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

})));
//# sourceMappingURL=bravobit-bb-foundation-notifications.umd.js.map
