//>>built
define("dojox/dtl/tag/loop",["dojo/_base/lang","dojo/_base/array","dojo/_base/json","../_base","dojox/string/tokenize"],function(f,i,j,h,k){f.getObject("dojox.dtl.tag.loop",!0);var e=h.tag.loop;e.CycleNode=f.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){if(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 h._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)}});e.IfChangedNode=f.extend(function(b,c,a){this.nodes=b;this._vars=c;this.shared=a||{last:null,counter:0};this.vars=i.map(c,function(a){return new dojox.dtl._Filter(a)})},{render:function(b,c){if(b.forloop){if(b.forloop.counter<=
this.shared.counter)this.shared.last=null;this.shared.counter=b.forloop.counter}var a;a=this.vars.length?j.toJson(i.map(this.vars,function(a){return a.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)}});e.RegroupNode=f.extend(function(b,c,a){this._expression=b;this.expression=new h._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,g=[],e=0;e<a.length;e++){var f=a[e][this.key];d!==f?(this._push(b[this.alias],d,g),d=f,g=[a[e]]):g.push(a[e])}this._push(b[this.alias],d,g)}return c},unrender:function(b,c){return c},clone:function(){return this}});
f.mixin(e,{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(","))for(var d=a[1].split(","),a=[a[0]],g=0;g<d.length;g++)a.push('"'+d[g]+'"');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]}if(4<a.length&&"as"==a[a.length-2]){d=a[a.length-
1];a=new e.CycleNode(a.slice(1,a.length-2),d,b.create_text_node());if(!b._namedCycleNodes)b._namedCycleNodes={};b._namedCycleNodes[d]=a}else a=new e.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 e.IfChangedNode(d,a.slice(1))},regroup:function(b,c){var a=k(c.contents,/(\s+)/g,function(a){return a});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 e.RegroupNode(d,a[a.length-5],a[a.length-1])}});return dojox.dtl.tag.loop});