/*!
 * mustache.js - Logic-less {{mustache}} templates with JavaScript
 * http://github.com/janl/mustache.js
 */var x=Object.prototype.toString,k=Array.isArray||function(e){return x.call(e)==="[object Array]"};function j(n){return typeof n=="function"}function F(n){return k(n)?"array":typeof n}function I(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function W(n,e){return n!=null&&typeof n=="object"&&e in n}function M(n,e){return n!=null&&typeof n!="object"&&n.hasOwnProperty&&n.hasOwnProperty(e)}var N=RegExp.prototype.test;function $(n,e){return N.call(n,e)}var B=/\S/;function D(n){return!$(B,n)}var H={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function K(n){return String(n).replace(/[&<>"'`=\/]/g,function(r){return H[r]})}var z=/\s*/,G=/\s+/,q=/\s*=/,J=/\s*\}/,L=/#|\^|\/|>|\{|&|=|!/;function Q(n,e){if(!n)return[];var r=!1,t=[],s=[],a=[],i=!1,u=!1,o="",c=0;function l(){if(i&&!u)for(;a.length;)delete s[a.pop()];else a=[];i=!1,u=!1}var y,b,A;function O(g){if(typeof g=="string"&&(g=g.split(G,2)),!k(g)||g.length!==2)throw new Error("Invalid tags: "+g);y=new RegExp(I(g[0])+"\\s*"),b=new RegExp("\\s*"+I(g[1])),A=new RegExp("\\s*"+I("}"+g[1]))}O(e||d.tags);for(var f=new T(n),w,p,v,S,P,C;!f.eos();){if(w=f.pos,v=f.scanUntil(y),v)for(var U=0,_=v.length;U<_;++U)S=v.charAt(U),D(S)?(a.push(s.length),o+=S):(u=!0,r=!0,o+=" "),s.push(["text",S,w,w+1]),w+=1,S===`
`&&(l(),o="",c=0,r=!1);if(!f.scan(y))break;if(i=!0,p=f.scan(L)||"name",f.scan(z),p==="="?(v=f.scanUntil(q),f.scan(q),f.scanUntil(b)):p==="{"?(v=f.scanUntil(A),f.scan(J),f.scanUntil(b),p="&"):v=f.scanUntil(b),!f.scan(b))throw new Error("Unclosed tag at "+f.pos);if(p==">"?P=[p,v,w,f.pos,o,c,r]:P=[p,v,w,f.pos],c++,s.push(P),p==="#"||p==="^")t.push(P);else if(p==="/"){if(C=t.pop(),!C)throw new Error('Unopened section "'+v+'" at '+w);if(C[1]!==v)throw new Error('Unclosed section "'+C[1]+'" at '+w)}else p==="name"||p==="{"||p==="&"?u=!0:p==="="&&O(v)}if(l(),C=t.pop(),C)throw new Error('Unclosed section "'+C[1]+'" at '+f.pos);return X(V(s))}function V(n){for(var e=[],r,t,s=0,a=n.length;s<a;++s)r=n[s],r&&(r[0]==="text"&&t&&t[0]==="text"?(t[1]+=r[1],t[3]=r[3]):(e.push(r),t=r));return e}function X(n){for(var e=[],r=e,t=[],s,a,i=0,u=n.length;i<u;++i)switch(s=n[i],s[0]){case"#":case"^":r.push(s),t.push(s),r=s[4]=[];break;case"/":a=t.pop(),a[5]=s[2],r=t.length>0?t[t.length-1][4]:e;break;default:r.push(s)}return e}function T(n){this.string=n,this.tail=n,this.pos=0}T.prototype.eos=function(){return this.tail===""};T.prototype.scan=function(e){var r=this.tail.match(e);if(!r||r.index!==0)return"";var t=r[0];return this.tail=this.tail.substring(t.length),this.pos+=t.length,t};T.prototype.scanUntil=function(e){var r=this.tail.search(e),t;switch(r){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=t.length,t};function E(n,e){this.view=n,this.cache={".":this.view},this.parent=e}E.prototype.push=function(e){return new E(e,this)};E.prototype.lookup=function(e){var r=this.cache,t;if(r.hasOwnProperty(e))t=r[e];else{for(var s=this,a,i,u,o=!1;s;){if(e.indexOf(".")>0)for(a=s.view,i=e.split("."),u=0;a!=null&&u<i.length;)u===i.length-1&&(o=W(a,i[u])||M(a,i[u])),a=a[i[u++]];else a=s.view[e],o=W(s.view,e);if(o){t=a;break}s=s.parent}r[e]=t}return j(t)&&(t=t.call(this.view)),t};function h(){this.templateCache={_cache:{},set:function(e,r){this._cache[e]=r},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}h.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};h.prototype.parse=function(e,r){var t=this.templateCache,s=e+":"+(r||d.tags).join(":"),a=typeof t<"u",i=a?t.get(s):void 0;return i==null&&(i=Q(e,r),a&&t.set(s,i)),i};h.prototype.render=function(e,r,t,s){var a=this.getConfigTags(s),i=this.parse(e,a),u=r instanceof E?r:new E(r,void 0);return this.renderTokens(i,u,t,e,s)};h.prototype.renderTokens=function(e,r,t,s,a){for(var i="",u,o,c,l=0,y=e.length;l<y;++l)c=void 0,u=e[l],o=u[0],o==="#"?c=this.renderSection(u,r,t,s,a):o==="^"?c=this.renderInverted(u,r,t,s,a):o===">"?c=this.renderPartial(u,r,t,a):o==="&"?c=this.unescapedValue(u,r):o==="name"?c=this.escapedValue(u,r,a):o==="text"&&(c=this.rawValue(u)),c!==void 0&&(i+=c);return i};h.prototype.renderSection=function(e,r,t,s,a){var i=this,u="",o=r.lookup(e[1]);function c(b){return i.render(b,r,t,a)}if(o){if(k(o))for(var l=0,y=o.length;l<y;++l)u+=this.renderTokens(e[4],r.push(o[l]),t,s,a);else if(typeof o=="object"||typeof o=="string"||typeof o=="number")u+=this.renderTokens(e[4],r.push(o),t,s,a);else if(j(o)){if(typeof s!="string")throw new Error("Cannot use higher-order sections without the original template");o=o.call(r.view,s.slice(e[3],e[5]),c),o!=null&&(u+=o)}else u+=this.renderTokens(e[4],r,t,s,a);return u}};h.prototype.renderInverted=function(e,r,t,s,a){var i=r.lookup(e[1]);if(!i||k(i)&&i.length===0)return this.renderTokens(e[4],r,t,s,a)};h.prototype.indentPartial=function(e,r,t){for(var s=r.replace(/[^ \t]/g,""),a=e.split(`
`),i=0;i<a.length;i++)a[i].length&&(i>0||!t)&&(a[i]=s+a[i]);return a.join(`
`)};h.prototype.renderPartial=function(e,r,t,s){if(t){var a=this.getConfigTags(s),i=j(t)?t(e[1]):t[e[1]];if(i!=null){var u=e[6],o=e[5],c=e[4],l=i;o==0&&c&&(l=this.indentPartial(i,c,u));var y=this.parse(l,a);return this.renderTokens(y,r,t,l,s)}}};h.prototype.unescapedValue=function(e,r){var t=r.lookup(e[1]);if(t!=null)return t};h.prototype.escapedValue=function(e,r,t){var s=this.getConfigEscape(t)||d.escape,a=r.lookup(e[1]);if(a!=null)return typeof a=="number"&&s===d.escape?String(a):s(a)};h.prototype.rawValue=function(e){return e[1]};h.prototype.getConfigTags=function(e){return k(e)?e:e&&typeof e=="object"?e.tags:void 0};h.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!k(e))return e.escape};var d={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(n){R.templateCache=n},get templateCache(){return R.templateCache}},R=new h;d.clearCache=function(){return R.clearCache()};d.parse=function(e,r){return R.parse(e,r)};d.render=function(e,r,t,s){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+F(e)+'" was given as the first argument for mustache#render(template, view, partials)');return R.render(e,r,t,s)};d.escape=K;d.Scanner=T;d.Context=E;d.Writer=h;export{d as m};
