//>>built
define("dojox/dtl/tag/logic",["dojo/_base/lang","../_base"],function(l,n){var k=l.getObject("tag.logic",!0,n);k.IfNode=l.extend(function(a,b,d,c){this.bools=a;this.trues=b;this.falses=d;this.type=c},{render:function(a,b){var d,c;if("or"==this.type){for(d=0;c=this.bools[d];d++){var e=c[0];c=c[1];if((c=c.resolve(a))&&!e||e&&!c)return this.falses&&(b=this.falses.unrender(a,b)),this.trues?this.trues.render(a,b,this):b}this.trues&&(b=this.trues.unrender(a,b));return this.falses?this.falses.render(a,b,
this):b}for(d=0;c=this.bools[d];d++)if(e=c[0],c=c[1],c=c.resolve(a),c==e)return this.trues&&(b=this.trues.unrender(a,b)),this.falses?this.falses.render(a,b,this):b;this.falses&&(b=this.falses.unrender(a,b));return this.trues?this.trues.render(a,b,this):b},unrender:function(a,b){b=this.trues?this.trues.unrender(a,b):b;return b=this.falses?this.falses.unrender(a,b):b},clone:function(a){var b=this.trues?this.trues.clone(a):null;a=this.falses?this.falses.clone(a):null;return new this.constructor(this.bools,
b,a,this.type)}});k.IfEqualNode=l.extend(function(a,b,d,c,e){this.var1=new n._Filter(a);this.var2=new n._Filter(b);this.trues=d;this.falses=c;this.negate=e},{render:function(a,b){var d=this.var1.resolve(a),c=this.var2.resolve(a);d="undefined"!=typeof d?d:"";c="undefined"!=typeof d?c:"";if(this.negate&&d!=c||!this.negate&&d==c)return this.falses&&(b=this.falses.unrender(a,b,this)),this.trues?this.trues.render(a,b,this):b;this.trues&&(b=this.trues.unrender(a,b,this));return this.falses?this.falses.render(a,
b,this):b},unrender:function(a,b){return k.IfNode.prototype.unrender.call(this,a,b)},clone:function(a){var b=this.trues?this.trues.clone(a):null;a=this.falses?this.falses.clone(a):null;return new this.constructor(this.var1.getExpression(),this.var2.getExpression(),b,a,this.negate)}});k.ForNode=l.extend(function(a,b,d,c){this.assign=a;this.loop=new n._Filter(b);this.reversed=d;this.nodelist=c;this.pool=[]},{render:function(a,b){var d,c,e,f=!1,g=this.assign;for(e=0;e<g.length;e++)if("undefined"!=typeof a[g[e]]){f=
!0;a=a.push();break}!f&&a.forloop&&(f=!0,a=a.push());e=this.loop.resolve(a)||[];var h=[];if(l.isObject(e)&&!l.isArrayLike(e))for(d in e)h.push([d,e[d]]);else h=e;for(d=h.length;d<this.pool.length;d++)this.pool[d].unrender(a,b,this);this.reversed&&(h=h.slice(0).reverse());var m=a.forloop={parentloop:a.get("forloop",{})};for(d=c=0;d<h.length;d++){var p=h[d];m.counter0=c;m.counter=c+1;m.revcounter0=h.length-c-1;m.revcounter=h.length-c;m.first=!c;m.last=c==h.length-1;if(l.isArrayLike(p))if(1<g.length){f||
(f=!0,a=a.push());var q={};for(e=0;e<p.length&&e<g.length;e++)q[g[e]]=p[e];l.mixin(a,q)}else a[g[0]]=p[1];else a[g[0]]=p;c+1>this.pool.length&&this.pool.push(this.nodelist.clone(b));b=this.pool[c++].render(a,b,this)}delete a.forloop;if(f)a=a.pop();else for(e=0;e<g.length;e++)delete a[g[e]];return b},unrender:function(a,b){for(var d=0,c;c=this.pool[d];d++)b=c.unrender(a,b);return b},clone:function(a){return new this.constructor(this.assign,this.loop.getExpression(),this.reversed,this.nodelist.clone(a))}});
l.mixin(k,{if_:function(a,b){var d,c,e=[],f=b.contents.split();f.shift();b=f.join(" ");f=b.split(" and ");if(1==f.length){var g="or";f=b.split(" or ")}else for(g="and",d=0;d<f.length;d++)if(-1!=f[d].indexOf(" or "))throw Error("'if' tags can't mix 'and' and 'or'");for(d=0;c=f[d];d++){var h=!1;0==c.indexOf("not ")&&(c=c.slice(4),h=!0);e.push([h,new n._Filter(c)])}d=a.parse(["else","endif"]);c=!1;b=a.next_token();"else"==b.contents&&(c=a.parse(["endif"]),a.next_token());return new k.IfNode(e,d,c,g)},
_ifequal:function(a,b,d){var c=b.split_contents();if(3!=c.length)throw Error(c[0]+" takes two arguments");var e="end"+c[0],f=a.parse(["else",e]),g=!1;b=a.next_token();"else"==b.contents&&(g=a.parse([e]),a.next_token());return new k.IfEqualNode(c[1],c[2],f,g,d)},ifequal:function(a,b){return k._ifequal(a,b)},ifnotequal:function(a,b){return k._ifequal(a,b,!0)},for_:function(a,b){var d=b.contents.split();if(4>d.length)throw Error("'for' statements should have at least four words: "+b.contents);var c=
"reversed"==d[d.length-1],e=c?-3:-2;if("in"!=d[d.length+e])throw Error("'for' tag received an invalid argument: "+b.contents);for(var f=d.slice(1,e).join(" ").split(/ *, */),g=0;g<f.length;g++)if(!f[g]||-1!=f[g].indexOf(" "))throw Error("'for' tag received an invalid argument: "+b.contents);g=a.parse(["endfor"]);a.next_token();return new k.ForNode(f,d[d.length+e+1],c,g)}});return k});