*/var t=Object.prototype.toString,e=Array.isArray||function(e){return"[object Array]"===t.call(e)};function r(t){return"function"==typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}functiona(t,e){returnnull!=t&&"object"==typeoft&&eint}vari=RegExp.prototype.test,s=/\S/;functiono(t){return!function(t,e){returni.call(t,e)}(s,t)}varl={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},c=/\s*/,u=/\s+/,g=/\s*=/,p=/\s*\}/,h=/#|\^|\/|>|\{|&|=|!/;functionf(t){this.string=t,this.tail=t,this.pos=0}functiond(t,e){this.view=t,this.cache={".":this.view},this.parent=e}functionw(){this.templateCache={_cache:{},set:function(t,e){this._cache[t]=e},get:function(t){returnthis._cache[t]},clear:function(){this._cache={}}}}f.prototype.eos=function(){return""===this.tail},f.prototype.scan=function(t){vare=this.tail.match(t);if(!e||0!==e.index)return"";varr=e[0];returnthis.tail=this.tail.substring(r.length),this.pos+=r.length,r},f.prototype.scanUntil=function(t){vare,r=this.tail.search(t);switch(r){case-1:e=this.tail,this.tail="";break;case0:e="";break;default:e=this.tail.substring(0,r),this.tail=this.tail.substring(r)}returnthis.pos+=e.length,e},d.prototype.push=function(t){returnnewd(t,this)},d.prototype.lookup=function(t){vare,n,i,s=this.cache;if(s.hasOwnProperty(t))e=s[t];else{for(varo,l,c,u=this,g=!1;u;){if(t.indexOf(".")>0)for(o=u.view,l=t.split("."),c=0;null!=o&&c<l.length;)c===l.length-1&&(g=a(o,l[c])||(n=o,i=l[c],null!=n&&"object"!=typeofn&&n.hasOwnProperty&&n.hasOwnProperty(i))),o=o[l[c++]];elseo=u.view[t],g=a(u.view,t);if(g){e=o;break}u=u.parent}s[t]=e}returnr(e)&&(e=e.call(this.view)),e},w.prototype.clearCache=function(){void0!==this.templateCache&&this.templateCache.clear()},w.prototype.parse=function(t,r){vara=this.templateCache,i=t+":"+(r||y.tags).join(":"),s=void0!==a,l=s?a.get(i):void0;returnnull==l&&(l=function(t,r){if(!t)return[];vara,i,s,l=!1,d=[],w=[],m=[],S=!1,T=!1,v="",O=0;functionE(){if(S&&!T)for(;m.length;)deletew[m.pop()];elsem=[];S=!1,T=!1}function_(t){if("string"==typeoft&&(t=t.split(u,2)),!e(t)||2!==t.length)thrownewError("Invalid tags: "+t);a=newRegExp(n(t[0])+"\\s*"),i=newRegExp("\\s*"+n(t[1])),s=newRegExp("\\s*"+n("}"+t[1]))}_(r||y.tags);for(varb,L,D,M,x,k,P=newf(t);!P.eos();){if(b=P.pos,D=P.scanUntil(a))for(varU=0,N=D.length;U<N;++U)o(M=D.charAt(U))?(m.push(w.length),v+=M):(T=!0,l=!0,v+=" "),w.push(["text",M,b,b+1]),b+=1,"\n"===M&&(E(),v="",O=0,l=!1);if(!P.scan(a))break;if(S=!0,L=P.scan(h)||"name",P.scan(c),"="===L?(D=P.scanUntil(g),P.scan(g),P.scanUntil(i)):"{"===L?(D=P.scanUntil(s),P.scan(p),P.scanUntil(i),L="&"):D=P.scanUntil(i),!P.scan(i))thrownewError("Unclosed tag at "+P.pos);if(x=">"==L?[L,D,b,P.pos,v,O,l]:[L,D,b,P.pos],O++,w.push(x),"#"===L||"^"===L)d.push(x);elseif("/"===L){if(!(k=d.pop()))thrownewError('Unopened section "'+D+'" at '+b);if(k[1]!==D)thrownewError('Unclosed section "'+k[1]+'" at '+b)}else"name"===L||"{"===L||"&"===L?T=!0:"="===L&&_(D)}if(E(),k=d.pop())thrownewError('Unclosed section "'+k[1]+'" at '+P.pos);returnfunction(t){for(vare,r=[],n=r,a=[],i=0,s=t.length;i<s;++i)switch((e=t[i])[0]){case"#":case"^":n.push(e),a.push(e),n=e[4]=[];break;case"/":a.pop()[5]=e[2],n=a.length>0?a[a.length-1][4]:r;break;default:n.push(e)}returnr}(function(t){for(vare,r,n=[],a=0,i=t.length;a<i;++a)(e=t[a])&&("text"===e[0]&&r&&"text"===r[0]?(r[1]+=e[1],r[3]=e[3]):(n.push(e),r=e));returnn}(w))}(t,r),s&&a.set(i,l)),l},w.prototype.render=function(t,e,r,n){vara=this.getConfigTags(n),i=this.parse(t,a),s=einstanceofd?e:newd(e,void0);returnthis.renderTokens(i,s,r,t,n)},w.prototype.renderTokens=function(t,e,r,n,a){for(vari,s,o,l="",c=0,u=t.length;c<u;++c)o=void0,"#"===(s=(i=t[c])[0])?o=this.renderSection(i,e,r,n,a):"^"===s?o=this.renderInverted(i,e,r,n,a):">"===s?o=this.renderPartial(i,e,r,a):"&"===s?o=this.unescapedValue(i,e):"name"===s?o=this.escapedValue(i,e,a):"text"===s&&(o=this.rawValue(i)),void0!==o&&(l+=o);returnl},w.prototype.renderSection=function(t,n,a,i,s){varo