(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/Subject'), require('rxjs/BehaviorSubject'), require('rxjs/Observable'), require('rxjs/add/observable/timer'), require('rxjs/add/operator/switchMap'), require('rxjs/add/operator/do'), require('rxjs/add/operator/takeWhile'), require('@angular/http'), require('rxjs/add/operator/finally'), require('@angular/common')) : typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/Subject', 'rxjs/BehaviorSubject', 'rxjs/Observable', 'rxjs/add/observable/timer', 'rxjs/add/operator/switchMap', 'rxjs/add/operator/do', 'rxjs/add/operator/takeWhile', '@angular/http', 'rxjs/add/operator/finally', '@angular/common'], factory) : (factory((global.ng = global.ng || {}, global.ng.ngxProgressbar = global.ng.ngxProgressbar || {}),global.ng.core,global.Rx,global.Rx,global.Rx,global.Rx.Observable,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.ng.http,global.Rx.Observable.prototype,global.ng.common)); }(this, (function (exports,_angular_core,rxjs_Subject,rxjs_BehaviorSubject,rxjs_Observable,rxjs_add_observable_timer,rxjs_add_operator_switchMap,rxjs_add_operator_do,rxjs_add_operator_takeWhile,_angular_http,rxjs_add_operator_finally,_angular_common) { 'use strict'; var __extends = (undefined && undefined.__extends) || (function () { var 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 function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); /** * Helper */ var clamp = function (n, min, max) { if (n < min) { return min; } if (n > max) { return max; } return n; }; var NgProgress = (function () { function NgProgress() { var _this = this; /** * Initial state */ this.initState = { active: false, value: 0 }; /** * Progress state */ this.state = new rxjs_BehaviorSubject.BehaviorSubject(this.initState); /** * Trickling stream */ this.trickling = new rxjs_Subject.Subject(); this.progress = 0; this.maximum = 1; this.minimum = 0.08; this.speed = 200; this.trickleSpeed = 300; this.trickling.switchMap(function () { return rxjs_Observable.Observable .timer(0, _this.trickleSpeed) .takeWhile(function () { return _this.isStarted(); }) .do(function () { return _this.inc(); }); }).subscribe(); } /** * Start * @return {?} */ NgProgress.prototype.start = function () { if (!this.isStarted()) { this.set(this.minimum); } this.trickling.next(); }; /** * Done * @return {?} */ NgProgress.prototype.done = function () { /** if started, complete the progress */ if (this.isStarted()) { this.set(.3 + .5 * Math.random()); this.set(this.maximum); } }; /** * Increment the progress * @param {?=} amount * @return {?} */ NgProgress.prototype.inc = function (amount) { var /** @type {?} */ n = this.progress; /** if it hasn't start, start */ if (!this.isStarted()) { this.start(); } else { if (typeof amount !== 'number') { if (n >= 0 && n < 0.2) { amount = 0.1; } else if (n >= 0.2 && n < 0.5) { amount = 0.04; } else if (n >= 0.5 && n < 0.8) { amount = 0.02; } else if (n >= 0.8 && n < 0.99) { amount = 0.005; } else { amount = 0; } } n = clamp(n + amount, 0, 0.994); this.set(n); } }; /** * Set the progress * @param {?} n * @return {?} */ NgProgress.prototype.set = function (n) { var _this = this; this.progress = clamp(n, this.minimum, this.maximum); this.updateState(this.progress, true); /** if progress completed */ if (n === this.maximum) { var /** @type {?} */ hide_1 = function () { /** * reset the progress * Keep it { 0, false } to fadeOut progress-bar after complete */ if (_this.progress >= _this.maximum) { _this.progress = 0; _this.updateState(_this.progress, false); } }; var /** @type {?} */ complete = function () { /** * complete the progress * { 1, false } to complete progress-bar before hiding */ if (_this.progress >= _this.maximum) { _this.updateState(_this.progress, false); setTimeout(hide_1, _this.speed); } }; setTimeout(complete, this.speed); } }; /** * Is progress started \@return {boolean} * @return {?} */ NgProgress.prototype.isStarted = function () { return this.progress > 0 && this.progress < this.maximum; }; /** * Update the progress * @param {?} progress * @param {?} isActive * @return {?} */ NgProgress.prototype.updateState = function (progress, isActive) { this.state.next({ active: isActive, value: progress }); }; return NgProgress; }()); NgProgress.decorators = [ { type: _angular_core.Injectable }, ]; /** * @nocollapse */ NgProgress.ctorParameters = function () { return []; }; var NgProgressBrowserXhr = (function (_super) { __extends(NgProgressBrowserXhr, _super); /** * @param {?} ngProgress */ function NgProgressBrowserXhr(ngProgress) { var _this = _super.call(this) || this; _this.ngProgress = ngProgress; _this.currentRequest = 0; return _this; } /** * @return {?} */ NgProgressBrowserXhr.prototype.build = function () { var _this = this; var /** @type {?} */ xhr = _super.prototype.build.call(this); xhr.onload = function (evt) { return _this.done(); }; xhr.onerror = function (evt) { return _this.done(); }; xhr.onabort = function (evt) { return _this.done(); }; xhr.onloadstart = function (event) { _this.currentRequest++; if (!_this.ngProgress.isStarted()) { _this.ngProgress.start(); } }; return xhr; }; /** * @return {?} */ NgProgressBrowserXhr.prototype.done = function () { this.currentRequest--; if (this.currentRequest === 0) { this.ngProgress.done(); } }; return NgProgressBrowserXhr; }(_angular_http.BrowserXhr)); NgProgressBrowserXhr.decorators = [ { type: _angular_core.Injectable }, ]; /** * @nocollapse */ NgProgressBrowserXhr.ctorParameters = function () { return [ { type: NgProgress, }, ]; }; var NgProgressInterceptor = (function () { /** * @param {?} ngProgress */ function NgProgressInterceptor(ngProgress) { this.ngProgress = ngProgress; } /** * @param {?} req * @param {?} next * @return {?} */ NgProgressInterceptor.prototype.intercept = function (req, next) { var _this = this; this.ngProgress.start(); return next.handle(req).finally(function () { _this.ngProgress.done(); }); }; return NgProgressInterceptor; }()); NgProgressInterceptor.decorators = [ { type: _angular_core.Injectable }, ]; /** * @nocollapse */ NgProgressInterceptor.ctorParameters = function () { return [ { type: NgProgress, }, ]; }; var ProgressBarComponent = (function () { function ProgressBarComponent() { } /** * Styles for progressbar * @return {?} */ ProgressBarComponent.prototype.barStyles = function () { var /** @type {?} */ styles = { transition: "all " + this.speed + "ms " + this.ease, backgroundColor: this.color }; /** * Get positioning value */ var n = (!this.state.value) ? { leftToRightIncreased: -100, leftToRightReduced: 0, rightToLeftIncreased: 100, rightToLeftReduced: 0 }[this.direction] : this.toPercentage(this.state.value); switch (this.positionUsing) { case 'translate3d': styles = Object.assign({}, styles, { transform: "translate3d(" + n + "%,0,0)", '-webkit-transform': "translate3d(" + n + "%,0,0)", '-moz-transform': "translate3d(" + n + "%,0,0)", '-o-transform': "translate3d(" + n + "%,0,0)", '-ms-transform': "translate3d(" + n + "%,0,0)" }); break; case 'translate': styles = Object.assign({}, styles, { transform: "translate(" + n + "%,0)", '-webkit-transform': "translate(" + n + "%,0)", '-moz-transform': "translate(" + n + "%,0)", '-o-transform': "translate(" + n + "%,0)", '-ms-transform': "translate(" + n + "%,0)" }); break; default: styles = Object.assign({}, styles, { marginLeft: n + "%" }); } return styles; }; /** * Styles for progressbar tail * @return {?} */ ProgressBarComponent.prototype.shadowStyles = function () { return { boxShadow: "0 0 10px " + this.color + ", 0 0 5px " + this.color }; }; /** * @param {?} n * @return {?} */ ProgressBarComponent.prototype.toPercentage = function (n) { return ({ leftToRightIncreased: -1 + n, leftToRightReduced: -n, rightToLeftIncreased: 1 - n, rightToLeftReduced: n }[this.direction]) * 100; }; /** * @return {?} */ ProgressBarComponent.prototype.spinnerClasses = function () { return { leftToRightIncreased: 'clockwise', leftToRightReduced: 'anti-clockwise', rightToLeftIncreased: 'anti-clockwise', rightToLeftReduced: 'clockwise' }[this.direction]; }; return ProgressBarComponent; }()); ProgressBarComponent.decorators = [ { type: _angular_core.Component, args: [{ selector: 'ng-progress-bar', template: "\n