/*! grafana - v3.0.4 - 2016-06-01
 * Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["app/core/config","app/core/store","lodash","angular","jquery","app/core/core_module"],function(a){function b(a,b){return{restrict:"E",controller:i,link:function(c,d){var e,f=g["default"]("body");c.$watch("contextSrv.sidemenu",function(a){void 0!==a&&(f.toggleClass("sidemenu-open",c.contextSrv.sidemenu),a||b.setPinnedState(!1)),b.sidemenu&&(e=!0,setTimeout(function(){e=!1},300))}),c.$watch("contextSrv.pinned",function(a){void 0!==a&&f.toggleClass("sidemenu-pinned",a)});var h;c.$on("$routeChangeSuccess",function(a,b){h&&f.removeClass(h),h=b.$$route.pageClass,h&&f.addClass(h),g["default"]("#tooltip, .tooltip").remove()}),f.click(function(h){var i=g["default"](h.target);if(0!==i.parents().length){0===i.parents(".dash-playlist-actions").length&&a.stop(),f.find(".search-container").length>0&&0===i.parents(".search-container").length&&c.$apply(function(){c.appEvent("hide-dash-search")}),!e&&!b.pinned&&f.find(".sidemenu").length>0&&0===i.parents(".sidemenu").length&&c.$apply(function(){c.contextSrv.toggleSideMenu()});var j=d.find(".popover");j.length>0&&0===i.parents(".graph-legend").length&&j.hide()}})}}}b.$inject=["playlistSrv","contextSrv"];var c,d,e,f,g,h,i;return a("grafanaAppDirective",b),{setters:[function(a){c=a},function(a){d=a},function(a){e=a},function(a){f=a},function(a){g=a},function(a){h=a}],execute:function(){i=function(){function a(a,b,h,i,j,k){a.init=function(){a.contextSrv=k,a._=e["default"],i.profilingEnabled=d["default"].getBool("profilingEnabled"),i.performance={loadStart:(new Date).getTime()},i.appSubUrl=c["default"].appSubUrl,i.profilingEnabled&&a.initProfiling(),b.init(),h.init(),a.dashAlerts=b},a.initDashboard=function(a,b){j("DashboardCtrl",{$scope:b}).init(a)},i.onAppEvent=function(a,b,c){var d=i.$on(a,b),e=this;1!==e.$id||c||console.log("warning rootScope onAppEvent called without localscope"),c&&(e=c),e.$on("$destroy",d)},i.appEvent=function(a,b){i.$emit(a,b)},i.colors=["#7EB26D","#EAB839","#6ED0E0","#EF843C","#E24D42","#1F78C1","#BA43A9","#705DA0","#508642","#CCA300","#447EBC","#C15C17","#890F02","#0A437C","#6D1F62","#584477","#B7DBAB","#F4D598","#70DBED","#F9BA8F","#F29191","#82B5D8","#E5A8E2","#AEA2E0","#629E51","#E5AC0E","#64B0C8","#E0752D","#BF1B00","#0A50A1","#962D82","#614D93","#9AC48A","#F2C96D","#65C5DB","#F9934E","#EA6460","#5195CE","#D683CE","#806EB7","#3F6833","#967302","#2F575E","#99440A","#58140C","#052B51","#511749","#3F2B5B","#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7"],a.getTotalWatcherCount=function(){var a=0,b=0,c=g["default"](document.getElementsByTagName("body")),d=function(c){c.data().hasOwnProperty("$scope")&&(b++,f["default"].forEach(c.data().$scope.$$watchers,function(){a++})),f["default"].forEach(c.children(),function(a){d(g["default"](a))})};return d(c),i.performance.scopeCount=b,a},a.initProfiling=function(){var b=0;a.$watch(function(){b++},function(){}),i.performance.panels=[],a.$on("refresh",function(){if(i.performance.panels.length>0){var a=0,b=0;e["default"].each(i.performance.panels,function(c){a+=c.render,b+=c.query}),console.log("total query: "+b),console.log("total render: "+a),console.log("avg render: "+a/i.performance.panels.length)}i.performance.panels=[]}),a.onAppEvent("dashboard-loaded",function(){b=0,setTimeout(function(){console.log("Dashboard::Performance Total Digests: "+b),console.log("Dashboard::Performance Total Watchers: "+a.getTotalWatcherCount()),console.log("Dashboard::Performance Total ScopeCount: "+i.performance.scopeCount);var c=i.performance.allPanelsInitialized-i.performance.dashboardLoadStart;console.log("Dashboard::Performance - All panels initialized in "+c+" ms");for(var d=window.performance.now(),e=0;30>e;e++)i.$apply();console.log("Dashboard::Performance Root Digest "+(window.performance.now()-d)/30)},3e3)})},a.init()}return a.$inject=["$scope","alertSrv","utilSrv","$rootScope","$controller","contextSrv"],a}(),a("GrafanaCtrl",i),h["default"].directive("grafanaApp",b)}}});