/*! grafana - v4.5.1 - 2017-09-19
 * Copyright (c) 2017 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["angular","lodash","app/core/core_module","app/core/app_events"],function(a,b){"use strict";var c,d,e,f,g;b&&b.id;return{setters:[function(a){c=a},function(a){d=a},function(a){e=a},function(a){f=a}],execute:function(){g=function(){function a(a,b,c,d){this.$timeout=a,this.$sce=b,this.$rootScope=c,this.$modal=d,this.list=[]}return a.$inject=["$timeout","$sce","$rootScope","$modal"],a.prototype.init=function(){var a=this;this.$rootScope.onAppEvent("alert-error",function(b,c){a.set(c[0],c[1],"error",12e3)},this.$rootScope),this.$rootScope.onAppEvent("alert-warning",function(b,c){a.set(c[0],c[1],"warning",5e3)},this.$rootScope),this.$rootScope.onAppEvent("alert-success",function(b,c){a.set(c[0],c[1],"success",3e3)},this.$rootScope),f.default.on("alert-warning",function(b){return a.set(b[0],b[1],"warning",5e3)}),f.default.on("alert-success",function(b){return a.set(b[0],b[1],"success",3e3)}),f.default.on("alert-error",function(b){return a.set(b[0],b[1],"error",7e3)}),f.default.on("confirm-modal",this.showConfirmModal.bind(this))},a.prototype.getIconForSeverity=function(a){switch(a){case"success":return"fa fa-check";case"error":return"fa fa-exclamation-triangle";default:return"fa fa-exclamation"}},a.prototype.set=function(a,b,e,f){var g=this;d.default.isObject(b)&&(console.log("alert error",b),b.statusText&&(b="HTTP Error ("+b.status+") "+b.statusText));var h={title:a||"",text:b||"",severity:e||"info",icon:this.getIconForSeverity(e)},i=c.default.toJson(h);return d.default.remove(this.list,function(a){return c.default.toJson(a)===i}),this.list.push(h),f>0&&this.$timeout(function(){g.list=d.default.without(g.list,h)},f),this.$rootScope.$$phase||this.$rootScope.$digest(),h},a.prototype.clear=function(a){this.list=d.default.without(this.list,a)},a.prototype.clearAll=function(){this.list=[]},a.prototype.showConfirmModal=function(a){var b=this.$rootScope.$new();b.onConfirm=function(){a.onConfirm(),b.dismiss()},b.updateConfirmText=function(c){b.confirmTextValid=a.confirmText.toLowerCase()===c.toLowerCase()},b.title=a.title,b.text=a.text,b.text2=a.text2,b.confirmText=a.confirmText,b.onConfirm=a.onConfirm,b.onAltAction=a.onAltAction,b.altActionText=a.altActionText,b.icon=a.icon||"fa-check",b.yesText=a.yesText||"Yes",b.noText=a.noText||"Cancel",b.confirmTextValid=!b.confirmText;var c=this.$modal({template:"public/app/partials/confirm_modal.html",persist:!1,modalClass:"confirm-modal",show:!1,scope:b,keyboard:!1});c.then(function(a){a.modal("show")})},a}(),a("AlertSrv",g),e.default.service("alertSrv",g)}}});