//>>built
define("dojox/dtl/tag/loop",["dojo/_base/lang","dojo/_base/array","dojo/_base/json","../_base","dojox/string/tokenize"],function(g,l,n,k,p){var f=g.getObject("tag.loop",!0,k);f.CycleNode=g.extend(function(b,c,a,d){this.cyclevars=b;this.name=c;this.contents=a;this.shared=d||{counter:-1,map:{}}},{render:function(b,c){b.forloop&&!b.forloop.counter0&&(this.shared.counter=-1);++this.shared.counter;var a=this.cyclevars[this.shared.counter%this.cyclevars.length],d=this.shared.map;d[a]||(d[a]=new k._Filter(a));
a=d[a].resolve(b,c);this.name&&(b[this.name]=a);this.contents.set(a);return this.contents.render(b,c)},unrender:function(b,c){return this.contents.unrender(b,c)},clone:function(b){return new this.constructor(this.cyclevars,this.name,this.contents.clone(b),this.shared)}});f.IfChangedNode=g.extend(function(b,c,a){this.nodes=b;this._vars=c;this.shared=a||{last:null,counter:0};this.vars=l.map(c,function(d){return new dojox.dtl._Filter(d)})},{render:function(b,c){b.forloop&&(b.forloop.counter<=this.shared.counter&&
(this.shared.last=null),this.shared.counter=b.forloop.counter);var a=this.vars.length?n.toJson(l.map(this.vars,function(e){return e.resolve(b)})):this.nodes.dummyRender(b,c);if(a!=this.shared.last){var d=null===this.shared.last;this.shared.last=a;b=b.push();b.ifchanged={firstloop:d};c=this.nodes.render(b,c);b=b.pop()}else c=this.nodes.unrender(b,c);return c},unrender:function(b,c){return this.nodes.unrender(b,c)},clone:function(b){return new this.constructor(this.nodes.clone(b),this._vars,this.shared)}});
f.RegroupNode=g.extend(function(b,c,a){this._expression=b;this.expression=new k._Filter(b);this.key=c;this.alias=a},{_push:function(b,c,a){a.length&&b.push({grouper:c,list:a})},render:function(b,c){b[this.alias]=[];var a=this.expression.resolve(b);if(a){for(var d=null,e=[],h=0;h<a.length;h++){var m=a[h][this.key];d!==m?(this._push(b[this.alias],d,e),d=m,e=[a[h]]):e.push(a[h])}this._push(b[this.alias],d,e)}return c},unrender:function(b,c){return c},clone:function(b,c){return this}});g.mixin(f,{cycle:function(b,
c){var a=c.split_contents();if(2>a.length)throw Error("'cycle' tag requires at least two arguments");if(-1!=a[1].indexOf(",")){var d=a[1].split(",");a=[a[0]];for(var e=0;e<d.length;e++)a.push('"'+d[e]+'"')}if(2==a.length){d=a[a.length-1];if(!b._namedCycleNodes)throw Error("No named cycles in template: '"+d+"' is not defined");if(!b._namedCycleNodes[d])throw Error("Named cycle '"+d+"' does not exist");return b._namedCycleNodes[d]}4<a.length&&"as"==a[a.length-2]?(d=a[a.length-1],a=new f.CycleNode(a.slice(1,
a.length-2),d,b.create_text_node()),b._namedCycleNodes||(b._namedCycleNodes={}),b._namedCycleNodes[d]=a):a=new f.CycleNode(a.slice(1),null,b.create_text_node());return a},ifchanged:function(b,c){var a=c.contents.split(),d=b.parse(["endifchanged"]);b.delete_first_token();return new f.IfChangedNode(d,a.slice(1))},regroup:function(b,c){var a=p(c.contents,/(\s+)/g,function(e){return e});if(11>a.length||"as"!=a[a.length-3]||"by"!=a[a.length-7])throw Error("Expected the format: regroup list by key as newList");
var d=a.slice(2,-8).join("");return new f.RegroupNode(d,a[a.length-5],a[a.length-1])}});return f});