/*! grafana - v3.1.0 - 2016-07-18
 * Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["lodash","app/core/components/query_part/query_part"],function(a){function b(a){var b=m[a.type];if(!b)throw{message:"Could not find query part "+a.type};return new l.QueryPart(a,b)}function c(a){m[a.type]=new l.QueryPartDef(a),a.category.push(m[a.type])}function d(a,b){return b+' AS "'+a.params[0]+'"'}function e(a,b){return"*"===a.params[0]?"*":'"'+a.params[0]+'"'}function f(a,b){for(var c=0;c<a.length;c++){var d=a[c];if(d.def.category===n.Aggregations)return void(a[c]=b);if(d.def.category===n.Selectors)return void(a[c]=b)}a.splice(1,0,b)}function g(a,b){var c;for(c=0;c<a.length;c++){var d=a[c];if(d.def.category===n.Math||d.def.category===n.Aliasing)break}a.splice(c,0,b)}function h(a,b){var c=a.length;if(c>0){if("math"===a[c-1].def.type)return void(a[c-1]=b);if("math"===a[c-2].def.type)return void(a[c-2]=b);if("alias"===a[c-1].def.type)return void a.splice(c-1,0,b)}a.push(b)}function i(a,b){var c=a.length;return c>0&&"alias"===a[c-1].def.type?void(a[c-1]=b):void a.push(b)}function j(a,c,d){var e=k["default"].map(a,function(a){return b({type:a.def.type,params:k["default"].clone(a.params)})});d.selectModels.push(e)}var k,l,m,n,o;return{setters:[function(a){k=a},function(a){l=a}],execute:function(){m=[],n={Aggregations:[],Selectors:[],Transformations:[],Math:[],Aliasing:[],Fields:[]},o=[],c({type:"field",addStrategy:j,category:n.Fields,params:[{type:"field",dynamicLookup:!0}],defaultParams:["value"],renderer:e}),c({type:"count",addStrategy:f,category:n.Aggregations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"distinct",addStrategy:f,category:n.Aggregations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"integral",addStrategy:f,category:n.Aggregations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"mean",addStrategy:f,category:n.Aggregations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"median",addStrategy:f,category:n.Aggregations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"sum",addStrategy:f,category:n.Aggregations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"derivative",addStrategy:g,category:n.Transformations,params:[{name:"duration",type:"interval",options:["1s","10s","1m","5m","10m","15m","1h"]}],defaultParams:["10s"],renderer:l.functionRenderer}),c({type:"spread",addStrategy:g,category:n.Transformations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"non_negative_derivative",addStrategy:g,category:n.Transformations,params:[{name:"duration",type:"interval",options:["1s","10s","1m","5m","10m","15m","1h"]}],defaultParams:["10s"],renderer:l.functionRenderer}),c({type:"difference",addStrategy:g,category:n.Transformations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"moving_average",addStrategy:g,category:n.Transformations,params:[{name:"window",type:"number",options:[5,10,20,30,40]}],defaultParams:[10],renderer:l.functionRenderer}),c({type:"stddev",addStrategy:g,category:n.Transformations,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"time",category:o,params:[{name:"interval",type:"time",options:["auto","1s","10s","1m","5m","10m","15m","1h"]}],defaultParams:["auto"],renderer:l.functionRenderer}),c({type:"fill",category:o,params:[{name:"fill",type:"string",options:["none","null","0","previous"]}],defaultParams:["null"],renderer:l.functionRenderer}),c({type:"bottom",addStrategy:f,category:n.Selectors,params:[{name:"count",type:"int"}],defaultParams:[3],renderer:l.functionRenderer}),c({type:"first",addStrategy:f,category:n.Selectors,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"last",addStrategy:f,category:n.Selectors,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"max",addStrategy:f,category:n.Selectors,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"min",addStrategy:f,category:n.Selectors,params:[],defaultParams:[],renderer:l.functionRenderer}),c({type:"percentile",addStrategy:f,category:n.Selectors,params:[{name:"nth",type:"int"}],defaultParams:[95],renderer:l.functionRenderer}),c({type:"top",addStrategy:f,category:n.Selectors,params:[{name:"count",type:"int"}],defaultParams:[3],renderer:l.functionRenderer}),c({type:"tag",category:o,params:[{name:"tag",type:"string",dynamicLookup:!0}],defaultParams:["tag"],renderer:e}),c({type:"math",addStrategy:h,category:n.Math,params:[{name:"expr",type:"string"}],defaultParams:[" / 100"],renderer:l.suffixRenderer}),c({type:"alias",addStrategy:i,category:n.Aliasing,params:[{name:"name",type:"string",quote:"double"}],defaultParams:["alias"],renderMode:"suffix",renderer:d}),a("default",{create:b,getCategories:function(){return n}})}}});