(()=>{function t(o,i){function n(t){this.mostRecentKpi=null,this.$scope=t}return n.prototype.onDestroy=function(){this.mostRecentKpi&&this.mostRecentKpi.stop(),this.unwatchConfig&&this.unwatchConfig(),this.unwatchDestroy&&this.unwatchDestroy()},n.prototype.init=function(){var t=this.$scope.child,i=t.config,n=(this.onDestroy(),this.unwatchDestroy=this.$scope.$on("$destroy",_.bind(this.onDestroy,this)),this.unwatchConfig=this.$scope.$watch("child.config",_.bind(function(t,i){t&&!_.isEqual(t,i)&&this.init()},this)),o.createInstance(i,this.$scope.$id,t));return n.onNotification(_.bind(this.onNotification,this)),n.start().then(_.bind(function(){this.mostRecentKpi=n,this.refresh()},this)).catch(_.bind(this.onError,this))},n.prototype.refresh=function(){throw new Error("refresh function needs to be overriden")},n.prototype.onError=function(t){t&&t.data&&t.data.message&&(t={text:i.getString(t.data.message),type:"danger",detailedData:t.data},this.$scope.child.alerts.addAlerts(t))},n.prototype.onNotification=function(){throw new Error("onNotification function needs to be overriden")},{createWidget:function(t){t=new n(t);return t.__super=n.prototype,t}}}t.$inject=["mostRecentKpiSvc","gettextCatalog"],angular.module("c8y.parts.kpi").factory("baseWidgetSvc",t)})();