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,EAAE,CAAC,CAAC,eAAe,GAAG,GAAG,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,OAAO,IAAI,eAAe,GAAG,GAAG,CAAC;QACxC,CAAC;IACH,CAAC;IACI,uBAAU,GAA0B;QAC3C,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oBACxB,QAAQ,EAAE,KAAK;oBACf,QAAQ,EAAE,6ZAUX;iBACA,EAAG,EAAE;KACL,CAAC;IACF,kBAAkB;IACX,2BAAc,GAAmE,cAAM,OAAA;QAC9F,EAAC,IAAI,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAG,EAAC;KACxD,EAF6F,CAE7F,CAAC;IACK,2BAAc,GAA2C;QAChE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC1B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;KAC1B,CAAC;IACF,mBAAC;AAAD,CAAC,AAxED,IAwEC","sourcesContent":["import { Component, Host, Input, OnDestroy, OnInit } from '@angular/core';\n\nimport { ProgressDirective } from './progress.directive';\n\n// todo: number pipe\n// todo: use query from progress?\n\nexport class BarComponent implements OnInit, OnDestroy {\n public max:number;\n\n /** provide one of the four supported contextual classes: `success`, `info`, `warning`, `danger` */\n public type:string;\n /** current value of progress bar */\n \n public get value():number {\n return this._value;\n }\n\n public set value(v:number) {\n if (!v && v !== 0) {\n return;\n }\n this._value = v;\n this.recalculatePercentage();\n }\n\n public percent:number = 0;\n public transition:string;\n public progress:ProgressDirective;\n\n protected _value:number;\n\n public constructor( progress:ProgressDirective) {\n this.progress = progress;\n }\n\n public ngOnInit():void {\n this.progress.addBar(this);\n }\n\n public ngOnDestroy():void {\n this.progress.removeBar(this);\n }\n\n public recalculatePercentage():void {\n this.percent = +(100 * this.value / this.progress.max).toFixed(2);\n\n let totalPercentage = this.progress.bars.reduce(function (total:number, bar:BarComponent):number {\n return total + bar.percent;\n }, 0);\n\n if (totalPercentage > 100) {\n this.percent -= totalPercentage - 100;\n }\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Component, args: [{\n selector: 'bar',\n template: `\n <div class=\"progress-bar\"\n style=\"min-width: 0;\"\n role=\"progressbar\"\n [ngClass]=\"type && 'progress-bar-' + type\"\n [ngStyle]=\"{width: (percent < 100 ? percent : 100) + '%', transition: transition}\"\n aria-valuemin=\"0\"\n [attr.aria-valuenow]=\"value\"\n [attr.aria-valuetext]=\"percent.toFixed(0) + '%'\"\n [attr.aria-valuemax]=\"max\"><ng-content></ng-content></div>\n`\n}, ] },\n];\n/** @nocollapse */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: ProgressDirective, decorators: [{ type: Host }, ]},\n];\nstatic propDecorators: {[key: string]: DecoratorInvocation[]} = {\n'type': [{ type: Input },],\n'value': [{ type: Input },],\n};\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file