/*! grafana - v4.2.0 - 2017-03-24
 * Copyright (c) 2017 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["angular","app/core/core_module"],function(a,b){"use strict";var c,d,e;b&&b.id;return{setters:[function(a){c=a},function(a){d=a}],execute:function(){e={is:function(a,b){return Object.prototype.toString.call(a).slice(8,-1)===b},whatClass:function(a){return Object.prototype.toString.call(a).slice(8,-1)},forKeys:function(a,b){for(var c in a)if(a.hasOwnProperty(c)&&"function"!=typeof a[c]&&b(c,a[c]))break}},d.default.directive("jsonTree",[function(){return{restrict:"E",scope:{object:"=",startExpanded:"@",rootName:"@"},template:'<json-node key="rootName" value="object" start-expanded="startExpanded"></json-node>'}}]),d.default.directive("jsonNode",["ajsRecursiveDirectiveHelper",function(a){return{restrict:"E",scope:{key:"=",value:"=",startExpanded:"@"},compile:function(b){return a.compile(b,this)},template:' <span class="json-tree-key" ng-click="toggleExpanded()">{{key}}</span>       <span class="json-tree-leaf-value" ng-if="!isExpandable">{{value}}</span>       <span class="json-tree-branch-preview" ng-if="isExpandable" ng-show="!isExpanded" ng-click="toggleExpanded()">            {{preview}}</span>       <ul class="json-tree-branch-value" ng-if="isExpandable && shouldRender" ng-show="isExpanded">           <li ng-repeat="(subkey,subval) in value">               <json-node key="subkey" value="subval"></json-node>           </li>       </ul>',pre:function(a,b,c){if(b.addClass(e.whatClass(a.value).toLowerCase()),e.is(a.value,"Object")||e.is(a.value,"Array")){a.isExpandable=!0,b.addClass("expandable");var d=e.is(a.value,"Array");a.preview=d?"[ ":"{ ",e.forKeys(a.value,function(b,c){null===c&&(a.value[b]="null"),d?a.preview+=c+", ":a.preview+=b+": "+c+", "}),a.preview=a.preview.substring(0,a.preview.length-(a.preview.length>2?2:0))+(d?" ]":" }"),a.startExpanded&&(a.shouldRender=!0,b.addClass("expanded")),a.isExpanded=a.startExpanded,a.toggleExpanded=function(){a.isExpanded=!a.isExpanded,a.isExpanded?b.addClass("expanded"):b.removeClass("expanded"),a.shouldRender=!0}}else a.isExpandable=!1,b.addClass("not-expandable")}}}]),d.default.factory("ajsRecursiveDirectiveHelper",["$compile",function(a){return{compile:function(b,d){c.default.isFunction(d)&&(d={post:d});var e,f=b.contents().remove();return{pre:d&&d.pre?d.pre:null,post:function(b,c){e||(e=a(f)),e(b,function(a){c.append(a)}),d&&d.post&&d.post.apply(null,arguments)}}}}}])}}});