-
Notifications
You must be signed in to change notification settings - Fork 0
/
riot+compiler.min.js
2 lines (2 loc) · 25.2 KB
/
riot+compiler.min.js
1
2
/* Riot v2.3.1, @license MIT, (c) 2015 Muut Inc. + contributors */
(function(e,t){"use strict";var n={version:"v2.3.1",settings:{}},r=0,i=[],o={},f="riot-",a=f+"tag",u="string",s="object",c="undefined",l="function",p=/^(?:opt(ion|group)|tbody|col|t[rhd])$/,d=["_item","_id","_parent","update","root","mount","unmount","mixin","isMounted","isLoop","tags","parent","opts","trigger","on","off","one"],g=(e&&e.document||{}).documentMode|0;n.observable=function(e){e=e||{};var t={},n=function(e,t){e.replace(/\S+/g,t)},r=function(t,n){Object.defineProperty(e,t,{value:n,enumerable:false,writable:false,configurable:false})};r("on",function(r,i){if(typeof i!="function")return e;n(r,function(e,n){(t[e]=t[e]||[]).push(i);i.typed=n>0});return e});r("off",function(r,i){if(r=="*")t={};else{n(r,function(e){if(i){var n=t[e];for(var r=0,o;o=n&&n[r];++r){if(o==i)n.splice(r--,1)}}else delete t[e]})}return e});r("one",function(t,n){function r(){e.off(t,r);n.apply(e,arguments)}return e.on(t,r)});r("trigger",function(r){var i=arguments.length-1,o=new Array(i);for(var f=0;f<i;f++){o[f]=arguments[f+1]}n(r,function(n){var r=(t[n]||[]).slice(0);for(var i=0,f;f=r[i];++i){if(f.busy)return;f.busy=1;try{f.apply(e,f.typed?[n].concat(o):o)}catch(a){}if(r[i]!==f){i--}f.busy=0}if(t.all&&n!="all")e.trigger.apply(e,["all",n].concat(o))});return e});return e};(function(t){if(!e)return;var n=/^.+?\/+[^\/]+/,r="EventListener",i="remove"+r,o="add"+r,f="hasAttribute",a="replace",u="popstate",s="trigger",c=3,l=e,p=document,d=l.history.location||l.location,g=N.prototype,h=p&&p.ontouchstart?"touchstart":"click",v=false,m=t.observable(),b,y,w,x,_=[],S=0;function C(e){return e.split(/[\/?#]/)}function L(e,t){var n=new RegExp("^"+t[a](/\*/g,"([^/?#]+?)")[a](/\.\./,".*")+"$"),r=e.match(n);if(r)return r.slice(1)}function N(){this.$=[];t.observable(this);m.on("stop",this.s.bind(this));m.on("emit",this.e.bind(this))}function M(e){return e[a](/^\/|\/$/,"")}function E(e){return typeof e=="string"}function T(e){return(e||d.href)[a](n,"")}function $(e){return b[0]=="#"?(e||d.href).split(b)[1]||"":T(e)[a](b,"")}function O(e){var t=S==0;if(c<=S)return;S++;_.push(function(){var t=$();if(e||t!=y){m[s]("emit",t);y=t}});if(t){while(_.length){_[0]();_.shift()}S=0}}function k(e){if(e.which!=1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented)return;var t=e.target;while(t&&t.nodeName!="A")t=t.parentNode;if(!t||t.nodeName!="A"||t[f]("download")||!t[f]("href")||t.target&&t.target!="_self"||t.href.indexOf(d.href.match(n)[0])==-1)return;if(t.href!=d.href){if(t.href.split("#")[0]==d.href.split("#")[0])return;A($(t.href),t.title||p.title)}e.preventDefault()}function A(e,t){t=t||p.title;history.pushState(null,t,b+M(e));p.title=t;O()}g.m=function(e,t){if(E(e)&&(!t||E(t)))A(e,t);else if(t)this.r(e,t);else this.r("@",e)};g.s=function(){this.off("*");this.$=[]};g.e=function(e){this.$.concat("@").some(function(t){var n=(t=="@"?w:x)(M(e),M(t));if(n){this[s].apply(null,[t].concat(n));return true}},this)};g.r=function(e,t){if(e!="@"){e="/"+M(e);this.$.push(e)}this.on(e,t)};var j=new N;var R=j.m.bind(j);R.create=function(){var e=new N;e.m.stop=e.s.bind(e);return e.m.bind(e)};R.base=function(e){b=e||"#";y=$()};R.exec=function(){O(true)};R.parser=function(e,t){if(!e&&!t){w=C;x=L}if(e)w=e;if(t)x=t};R.query=function(){var e={};d.href[a](/[?&](.+?)=([^&]*)/g,function(t,n,r){e[n]=r});return e};R.stop=function(){if(v){l[i](u,O);p[i](h,k);m[s]("stop");v=false}};R.start=function(e){if(!v){l[o](u,O);p[o](h,k);v=true}if(e)O(true)};R.base();R.parser();t.route=R})(n);var h=function(e){var t="g",r=/\/\*[^*]*\*+(?:[^*\/][^*]*\*+)*\//g,i=/"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'/g,o=i.source+"|"+/(?:[$\w\)\]]|\+\+|--)\s*(\/)(?![*\/])/.source+"|"+/\/(?=[^*\/])[^[\/\\]*(?:(?:\[(?:\\.|[^\]\\]*)*\]|\\.)[^[\/\\]*)*?(\/)[gim]*/.source,f="{ }",a={"(":l("([()])|"+o,t),"[":l("([[\\]])|"+o,t),"{":l("([{}])|"+o,t)};var u=e,s,c=[];function l(e,t){return new RegExp(e,t)}function p(e){return e}function d(e){return new RegExp(e.source.replace(/{/g,c[2]).replace(/}/g,c[3]),e.global?t:"")}function g(e){e=e||f;if(e!==c[8]){var n=e.split(" ");if(e===f){c=n.concat(n);s=p}else{if(n.length!==2||/[\x00-\x1F<>a-zA-Z0-9'",;\\]/.test(e)){throw new Error('Unsupported brackets "'+e+'"')}c=n.concat(e.replace(/(?=[[\]()*+?.^$|])/g,"\\").split(" "));s=d}c[4]=s(c[1].length>1?/(?:^|[^\\]){[\S\s]*?}/:/(?:^|[^\\]){[^}]*}/);c[5]=s(/\\({|})/g);c[6]=s(/(\\?)({)/g);c[7]=l("(\\\\?)(?:([[({])|("+c[3]+"))|"+o,t);c[9]=l(/^\s*{\^?\s*([$\w]+)(?:\s*,\s*(\S+))?\s+in\s+(\S+)\s*}/);c[8]=e}v.settings.brackets=u=e}function h(e){if(u!==e){g(e)}}function v(e){h(v.settings.brackets);return e instanceof RegExp?s(e):c[e]}v.split=function m(e,t){var n=[],r,i,o,f,u=v(6);i=o=u.lastIndex=0;while(r=u.exec(e)){f=r.index;if(i){if(r[2]){u.lastIndex=l(r[2],u.lastIndex);continue}if(!r[3])continue}if(!r[1]){s(e.slice(o,f));o=u.lastIndex;u=c[6+(i^=1)];u.lastIndex=o}}if(e&&o<e.length){s(e.slice(o))}return n;function s(e){if(t||i)n.push(e&&e.replace(c[5],"$1"));else n.push(e)}function l(t,n){var r,i=a[t],o=1;i.lastIndex=n;while(r=i.exec(e)){if(r[1]&&!(r[1]===t?++o:--o))break}return r?i.lastIndex:e.length}};v.hasExpr=function b(e){return v(4).test(e)};v.loopKeys=function y(e){var t=e.match(v(9));return t?{key:t[1],pos:t[2],val:c[0]+t[3]+c[1]}:{val:e.trim()}};v.array=function w(e){if(e!=null)g(e);return c};v.settings=typeof n!=="undefined"&&n.settings||{};v.set=h;v.R_STRINGS=i;v.R_MLCOMMS=r;v.S_QBLOCKS=o;g(v.settings.brackets);return v}();var v=function(){var t=!1,n={};function r(e,t){if(!e)return e;return(n[e]||(n[e]=o(e))).call(t,i)}r.hasExpr=h.hasExpr;r.loopKeys=h.loopKeys;r.errorHandler=t;function i(e,t){if(r.errorHandler){e.riotData={tagName:t&&t.root&&t.root.tagName,_riot_id:t&&t._riot_id};r.errorHandler(e)}}function o(e){var t=u(e);if(t.slice(0,11)!=="try{return ")t="return "+t;return new Function("E",t+";")}var f=new RegExp(h.S_QBLOCKS,"g"),a=/\x01(\d+)~/g;function u(e){var t=[],n,r=h.split(e,1);if(r.length>2||r[0]){var i,o,f=[];for(i=o=0;i<r.length;++i){n=r[i];if(n&&(n=i&1?l(n,1,t):'"'+n.replace(/\\/g,"\\\\").replace(/\r\n?|\n/g,"\\n").replace(/"/g,'\\"')+'"'))f[o++]=n}n=o<2?f[0]:"["+f.join(",")+'].join("")'}else{n=l(r[1],0,t)}if(t[0])n=n.replace(a,function(e,n){return t[n].replace(/\r/g,"\\r").replace(/\n/g,"\\n")});return n}var s=/^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/,c=/,|([[{(])|$/g;function l(e,t,n){e=e.replace(f,function(e,t){return e.length>2&&!t?""+(n.push(e)-1)+"~":e}).replace(/\s+/g," ").trim().replace(/\ ?([[\({},?\.:])\ ?/g,"$1");if(e){var r=[],i=0,o;while(e&&(o=e.match(s))&&!o.index){var a,u,c=/,|([[{(])|$/g;e=RegExp.rightContext;a=o[2]?n[o[2]].slice(1,-1).trim().replace(/\s+/g," "):o[1];while(u=(o=c.exec(e))[1])l(u,c);u=e.slice(0,o.index);e=RegExp.rightContext;r[i++]=g(u,1,a)}e=!i?g(e,t):i>1?"["+r.join(",")+'].join(" ").trim()':r[0]}return e;function l(t,n){var r,i=1,o=t==="("?/[()]/g:t==="["?/[[\]]/g:/[{}]/g;o.lastIndex=n.lastIndex;while(r=o.exec(e)){if(r[0]===t)++i;else if(!--i)break}n.lastIndex=i?e.length:o.lastIndex}}var p='"in this?this:'+(typeof e!=="object"?"global":"window")+").";var d=/[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g;function g(e,n,r){var i=t;e=e.replace(d,function(e,t,n,r,o){if(n){r=i?0:r+e.length;if(n!=="this"&&n!=="global"&&n!=="window"){e=t+'("'+n+p+n;if(r)i=(o=o[r])==="."||o==="("||o==="["}else if(r)i=!/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/.test(o.slice(r))}return e});if(i){e="try{return "+e+"}catch(e){E(e,this)}"}if(r){e=(i?"function(){"+e+"}.call(this)":"("+e+")")+'?"'+r+'":""'}else if(n){e="function(v){"+(i?e.replace("return ","v="):"v=("+e+")")+';return v||v===0?v:""}.call(this)'}return e}r.parse=function(e){return e};return r}();var m=function(e){var t={tr:"tbody",th:"tr",td:"tr",tbody:"table",col:"colgroup"},n="div";e=e&&e<10;function r(r){var o=r&&r.match(/^\s*<([-\w]+)/),f=o&&o[1].toLowerCase(),a=t[f]||n,u=X(a);u.stub=true;if(e&&f&&(o=f.match(p)))i(u,r,f,!!o[1]);else u.innerHTML=r;return u}function i(e,t,r,i){var o=X(n),f=i?"select>":"table>",a;o.innerHTML="<"+f+t+"</"+f;a=ee(r,o);if(a)e.appendChild(a)}return r}(g);function b(e,t,n){var r={};r[e.key]=t;if(e.pos)r[e.pos]=n;return r}function y(e,t){var n=t.length,r=e.length;while(n>r){var i=t[--n];t.splice(n,1);i.unmount()}}function w(e,t){Object.keys(e.tags).forEach(function(n){var r=e.tags[n];if(Q(r))$(r,function(e){B(e,n,t)});else B(r,n,t)})}function x(e,t,n){var r=e._root;e._virts=[];while(r){var i=r.nextSibling;if(n)t.insertBefore(r,n._root);else t.appendChild(r);e._virts.push(r);r=i}}function _(e,t,n,r){var i=e._root;for(var o=0;o<r;o++){var f=i.nextSibling;t.insertBefore(i,n._root);i=f}}function S(e,t,n){k(e,"each");var r=typeof j(e,"no-reorder")!==u||k(e,"no-reorder"),i=D(e),f=o[i]||{tmpl:e.outerHTML},a=p.test(i),s=e.parentNode,c=p.test(i),l=document.createTextNode(""),d=I(e),g=[],h=[],m,S=e.tagName=="VIRTUAL";n=v.loopKeys(n);s.insertBefore(l,e);t.one("before-mount",function(){e.parentNode.removeChild(e);if(s.stub)s=t.root}).on("update",function(){var u=v(n.val,t),p=document.createDocumentFragment();if(!Q(u)){m=u?JSON.stringify(u):"";u=!u?[]:Object.keys(u).map(function(e){return b(n,e,u[e])})}$(u,function(u,c){var l=r&&u instanceof Object,v=h.indexOf(u),y=~v&&l?v:c,C=g[y];u=!m&&n.key?b(n,u,c):u;if(!l&&!C||l&&!~v||!C){C=new N(f,{parent:t,isLoop:true,hasImpl:!!o[i],root:a?s:e.cloneNode(),item:u},e.innerHTML);C.mount();if(S)C._root=C.root.firstChild;if(c==g.length){if(S)x(C,p);else p.appendChild(C.root)}else{if(S)x(C,s,g[c]);else s.insertBefore(C.root,g[c].root);h.splice(c,0,u)}g.splice(c,0,C);y=c}else C.update(u);if(y!==c&&l){if(S)_(C,s,g[c],e.childNodes.length);else s.insertBefore(C.root,g[c].root);if(n.pos)C[n.pos]=c;g.splice(c,0,g.splice(y,1)[0]);h.splice(c,0,h.splice(y,1)[0]);if(!d)w(C,c)}C._item=u;q(C,"_parent",t)});y(u,g);if(c)s.appendChild(p);else s.insertBefore(p,l);if(d)t.tags[i]=g;h=u.slice()})}function C(e,t,n,r){Z(e,function(e){if(e.nodeType==1){e.isLoop=e.isLoop||(e.parentNode&&e.parentNode.isLoop||j(e,"each"))?1:0;if(n){var i=I(e);if(i&&!e.isLoop)n.push(F(i,{root:e,parent:t},e.innerHTML,t))}if(!e.isLoop||r)re(e,t,[])}})}function L(e,t,n){function r(e,t,r){if(v.hasExpr(t)){var i={dom:e,expr:t};n.push(P(i,r))}}Z(e,function(e){var n=e.nodeType;if(n==3&&e.parentNode.tagName!="STYLE")r(e,e.nodeValue);if(n!=1)return;var i=j(e,"each");if(i){S(e,t,i);return false}$(e.attributes,function(t){var n=t.name,i=n.split("__")[1];r(e,t.value,{attr:i||n,bool:i});if(i){k(e,n);return false}});if(I(e))return false})}function N(e,o,f){var a=n.observable(this),l=te(o.opts)||{},p=m(e.tmpl),g=o.parent,h=o.isLoop,b=o.hasImpl,y=V(o.item),w=[],x=[],_=o.root,S=e.fn,N=_.tagName.toLowerCase(),M={},E=[];if(S&&_._tag)_._tag.unmount(true);this.isMounted=false;_.isLoop=h;_._tag=this;q(this,"_riot_id",++r);P(this,{parent:g,root:_,opts:l,tags:{}},y);$(_.attributes,function(e){var t=e.value;if(v.hasExpr(t))M[e.name]=t});if(p.innerHTML&&!/^(select|optgroup|table|tbody|tr|col(?:group)?)$/.test(N))p.innerHTML=W(p.innerHTML,f);function j(){var e=b&&h?a:g||a;$(_.attributes,function(t){l[A(t.name)]=v(t.value,e)});$(Object.keys(M),function(t){l[A(t)]=v(M[t],e)})}function I(e){for(var t in y){if(typeof a[t]!==c&&U(a,t))a[t]=e[t]}}function H(){if(!a.parent||!h)return;$(Object.keys(a.parent),function(e){var t=!z(d,e)&&z(E,e);if(typeof a[e]===c||t){if(!t)E.push(e);a[e]=a.parent[e]}})}q(this,"update",function(e){e=V(e);H();if(e&&typeof y===s){I(e);y=e}P(a,e);j();a.trigger("update",e);T(w,a);a.trigger("updated");return this});q(this,"mixin",function(){$(arguments,function(e){e=typeof e===u?n.mixin(e):e;$(Object.keys(e),function(t){if(t!="init")a[t]=O(e[t])?e[t].bind(a):e[t]});if(e.init)e.init.bind(a)()});return this});q(this,"mount",function(){j();if(S)S.call(a,l);L(p,a,w);B(true);if(e.attrs||b){G(e.attrs,function(e,t){R(_,e,t)});L(a.root,a,w)}if(!a.parent||h)a.update(y);a.trigger("before-mount");if(h&&!b){a.root=_=p.firstChild}else{while(p.firstChild)_.appendChild(p.firstChild);if(_.stub)a.root=_=g.root}if(h)C(a.root,a.parent,null,true);if(!a.parent||a.parent.isMounted){a.isMounted=true;a.trigger("mount")}else a.parent.one("mount",function(){if(!J(a.root)){a.parent.isMounted=a.isMounted=true;a.trigger("mount")}})});q(this,"unmount",function(e){var n=_,r=n.parentNode,o;a.trigger("before-unmount");i.splice(i.indexOf(a),1);if(this._virts){$(this._virts,function(e){e.parentNode.removeChild(e)})}if(r){if(g){o=K(g);if(Q(o.tags[N]))$(o.tags[N],function(e,t){if(e._riot_id==a._riot_id)o.tags[N].splice(t,1)});else o.tags[N]=t}else while(n.firstChild)n.removeChild(n.firstChild);if(!e)r.removeChild(n);else k(r,"riot-tag")}a.trigger("unmount");B();a.off("*");a.isMounted=false;_._tag=null});function B(e){$(x,function(t){t[e?"mount":"unmount"]()});if(g){var t=e?"on":"off";if(h)g[t]("unmount",a.unmount);else g[t]("update",a.update)[t]("unmount",a.unmount)}}C(p,this,x)}function M(t,n,r,i){r[t]=function(t){var o=i._parent,f=i._item,a;if(!f)while(o&&!f){f=o._item;o=o._parent}t=t||e.event;if(U(t,"currentTarget"))t.currentTarget=r;if(U(t,"target"))t.target=t.srcElement;if(U(t,"which"))t.which=t.charCode||t.keyCode;t.item=f;if(n.call(i,t)!==true&&!/radio|check/.test(r.type)){if(t.preventDefault)t.preventDefault();t.returnValue=false}if(!t.preventUpdate){a=f?K(o):i;a.update()}}}function E(e,t,n){if(e){e.insertBefore(n,t);e.removeChild(t)}}function T(e,t){$(e,function(e,n){var r=e.dom,i=e.attr,o=v(e.expr,t),u=e.dom.parentNode;if(e.bool)o=o?i:false;else if(o==null)o="";if(u&&u.tagName=="TEXTAREA")o=(""+o).replace(/riot-/g,"");if(e.value===o)return;e.value=o;if(!i){r.nodeValue=""+o;return}k(r,i);if(O(o)){M(i,o,r,t)}else if(i=="if"){var c=e.stub,l=function(){E(c.parentNode,c,r)},p=function(){E(r.parentNode,r,c)};if(o){if(c){l();r.inStub=false;if(!J(r)){Z(r,function(e){if(e._tag&&!e._tag.isMounted)e._tag.isMounted=!!e._tag.trigger("mount")})}}}else{c=e.stub=c||document.createTextNode("");if(r.parentNode)p();else(t.parent||t).one("updated",p);r.inStub=true}}else if(/^(show|hide)$/.test(i)){if(i=="hide")o=!o;r.style.display=o?"":"none"}else if(i=="value"){r.value=o}else if(ie(i,f)&&i!=a){if(o)R(r,i.slice(f.length),o)}else{if(e.bool){r[i]=o;if(!o)return}if(typeof o!==s)R(r,i,o)}})}function $(e,t){for(var n=0,r=(e||[]).length,i;n<r;n++){i=e[n];if(i!=null&&t(i,n)===false)n--}return e}function O(e){return typeof e===l||false}function k(e,t){e.removeAttribute(t)}function A(e){return e.replace(/(\-\w)/g,function(e){return e.toUpperCase().replace("-","")})}function j(e,t){return e.getAttribute(t)}function R(e,t,n){e.setAttribute(t,n)}function I(e){return e.tagName&&o[j(e,a)||e.tagName.toLowerCase()]}function H(e,t,n){var r=n.tags[t];if(r){if(!Q(r))if(r!==e)n.tags[t]=[r];if(!z(n.tags[t],e))n.tags[t].push(e)}else{n.tags[t]=e}}function B(e,t,n){var r=e.parent,i;if(!r)return;i=r.tags[t];if(Q(i))i.splice(n,0,i.splice(i.indexOf(e),1)[0]);else H(e,t,r)}function F(e,t,n,r){var i=new N(e,t,n),o=D(t.root),f=K(r);i.parent=f;i._parent=r;H(i,o,f);if(f!==r)H(i,o,r);t.root.innerHTML="";return i}function K(e){var t=e;while(!I(t.root)){if(!t.parent)break;t=t.parent}return t}function q(e,t,n,r){Object.defineProperty(e,t,P({value:n,enumerable:false,writable:false,configurable:false},r));return e}function D(e){var t=I(e),n=j(e,"name"),r=n&&!v.hasExpr(n)?n:t?t.name:e.tagName.toLowerCase();return r}function P(e){var t,n=arguments;for(var r=1;r<n.length;++r){if(t=n[r]){for(var i in t){if(U(e,i))e[i]=t[i]}}}return e}function z(e,t){return~e.indexOf(t)}function Q(e){return Array.isArray(e)||e instanceof Array}function U(e,t){var n=Object.getOwnPropertyDescriptor(e,t);return typeof e[t]===c||n&&n.writable}function V(e){if(!(e instanceof N)&&!(e&&typeof e.trigger==l))return e;var t={};for(var n in e){if(!z(d,n))t[n]=e[n]}return t}function Z(e,t){if(e){if(t(e)===false)return;else{e=e.firstChild;while(e){Z(e,t);e=e.nextSibling}}}}function G(e,t){var n,r=/([-\w]+) ?= ?(?:"([^"]*)|'([^']*)|({[^}]*}))/g;while(n=r.exec(e)){t(n[1].toLowerCase(),n[2]||n[3]||n[4])}}function J(e){while(e){if(e.inStub)return true;e=e.parentNode}return false}function X(e){return document.createElement(e)}function W(e,t){return e.replace(/<(yield)\/?>(<\/\1>)?/gi,t||"")}function Y(e,t){return(t||document).querySelectorAll(e)}function ee(e,t){return(t||document).querySelector(e)}function te(e){function t(){}t.prototype=e;return new t}function ne(e){return j(e,"id")||j(e,"name")}function re(e,t,n){var r=ne(e),i=function(i){if(z(n,r))return;var o=Q(i);if(!i)t[r]=e;else if(!o||o&&!z(i,e)){if(o)i.push(e);else t[r]=[i,e]}};if(!r)return;if(v.hasExpr(r))t.one("updated",function(){r=ne(e);i(t[r])});else i(t[r])}function ie(e,t){return e.slice(0,t.length)===t}var oe=function(){if(!e)return;var t=X("style"),n=ee("style[type=riot]");R(t,"type","text/css");if(n){n.parentNode.replaceChild(t,n);n=null}else document.getElementsByTagName("head")[0].appendChild(t);return t.styleSheet?function(e){t.styleSheet.cssText+=e}:function(e){t.innerHTML+=e}}();function fe(e,t,n){var r=o[t],f=e._innerHTML=e._innerHTML||e.innerHTML;e.innerHTML="";if(r&&e)r=new N(r,{root:e,opts:n},f);if(r&&r.mount){r.mount();if(!z(i,r))i.push(r)}return r}n.util={brackets:h,tmpl:v};n.mixin=function(){var e={};return function(t,n){if(!n)return e[t];e[t]=n}}();n.tag=function(e,t,n,r,i){if(O(r)){i=r;if(/^[\w\-]+\s?=/.test(n)){r=n;n=""}else r=""}if(n){if(O(n))i=n;else if(oe)oe(n)}o[e]={name:e,tmpl:t,attrs:r,fn:i};return e};n.tag2=function(e,t,n,r,i,f){if(n&&oe)oe(n);o[e]={name:e,tmpl:t,attrs:r,fn:i};return e};n.mount=function(e,t,n){var r,i,f=[];function c(e){var t="";$(e,function(e){t+=", *["+a+'="'+e.trim()+'"]'});return t}function l(){var e=Object.keys(o);return e+c(e)}function p(e){var r;if(e.tagName){if(t&&(!(r=j(e,a))||r!=t))R(e,a,t);var i=fe(e,t||e.getAttribute(a)||e.tagName.toLowerCase(),n);if(i)f.push(i)}else if(e.length)$(e,p)}if(typeof t===s){n=t;t=0}if(typeof e===u){if(e==="*")e=i=l();else e+=c(e.split(","));r=e?Y(e):[]}else r=e;if(t==="*"){t=i||l();if(r.tagName)r=Y(t,r);else{var d=[];$(r,function(e){d.push(Y(t,e))});r=d}t=0}if(r.tagName)p(r);else $(r,p);return f};n.update=function(){return $(i,function(e){e.update()})};n.Tag=N;var ae=function(){var t={};function n(n,r){switch(n){case"coffee":r="CoffeeScript";break;case"es6":r="babel";break;default:if(!r)r=n;break}return t[n]=e[r]}function r(e,r){return e in t?t[e]:n(e,r)}var i={jade:function(e,t){return r("jade").render(e,P({pretty:true,doctype:"html"},t))}};var o={stylus:function(e,t,n){var i=r("stylus"),o=r("nib");return o?i(t).use(o()).import("nib").render():i.render(t)}};var f={none:function(e,t){return e},livescript:function(e,t){return r("livescript").compile(e,P({bare:true,header:false},t))},typescript:function(e,t){return r("typescript")(e,t).replace(/\r\n?/g,"\n")},es6:function(e,t){return r("es6").transform(e,P({blacklist:["useStrict","strict","react"],sourceMaps:false,comments:false},t)).code},babel:function(e,t){e="function __parser_babel_wrapper__(){"+e+"}";return r("babel").transform(e,P({presets:["es2015"]},t)).code.replace(/["']use strict["'];[\r\n]+/,"").slice(38,-2)},coffee:function(e,t){return r("coffee").compile(e,P({bare:true},t))}};f.javascript=f.none;f.coffeescript=f.coffee;return{html:i,css:o,js:f,_req:r}}();n.parsers=ae;var ue=function(){var e=n.util.brackets;function t(e,t){return new RegExp(e,t)}var r=t("^(?:disabled|checked|readonly|required|allowfullscreen|auto(?:focus|play)|"+"compact|controls|default|formnovalidate|hidden|inert|ismap|itemscope|loop|"+"multiple|muted|no(?:resize|shade|validate|wrap)?|open|reversed|seamless|"+"selected|sortable|truespeed|typemustmatch)$"),i=["style","src","d"],o=/^(?:input|img|br|wbr|hr|area|base|col|embed|keygen|link|meta|param|source|track)$/,f=/\s*([-\w:\.\xA0-\xFF]+)\s*(?:=\s*('[^']+'|"[^"]+"|\S+))?/g,a=/[ \t]+$/gm,u=null;function s(e){return"'"+(e?e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"):"")+"'"}function c(e,t,n,r,i,o){var f=", ",a="}"+(o.length?", "+s(u[8]):"")+");";if(/\S/.test(i)){i=i.replace(/\n{3,}/g,"\n\n");if(i.slice(-1)!=="\n")a="\n"+a}else i="";return"riot.tag2("+s(e)+f+s(t)+f+s(n)+f+s(r)+", function(opts) {\n"+i+a}function l(e,t){for(var n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function p(e){var t=[],n,o,a,s='"';f.lastIndex=0;while(n=f.exec(e)){o=n[1].toLowerCase();a=n[2];if(!a){t.push(o)}else{if(a[0]!==s)a=s+(a[0]==="'"?a.slice(1,-1):a)+s;if(o==="type"&&a.toLowerCase()==='"number"'){a=s+u[0]+"'number'"+u[1]+s}else if(/\u0001\d/.test(a)){if(r.test(o)){o="__"+o}else if(~i.indexOf(o)){o="riot-"+o}}t.push(o+"="+a)}}return t.join(" ")}function d(t,n,r){if(t&&u[4].test(t)){var i=n.expr&&(n.parser||n.type)?x:0,o=e.split(t),f;for(var a=1;a<o.length;a+=2){f=o[a];if(f[0]==="^")f=f.slice(1);else if(i){f=i(f,n);if(/;\s*$/.test(f))f=f.slice(0,f.search(/;\s*$/))}o[a]=""+(r.push(f.replace(/[\r\n]+/g," ").trim())-1)+u[1]}t=o.join("")}return t}function g(e,t){if(t.length){e=e.replace(/\u0001(\d+)/g,function(e,n){return u[0]+t[n].replace(/"/g,""")})}return e}var h=/<!--(?!>)[\S\s]*?-->/g,v=/<([-\w]+)\s*([^"'\/>]*(?:(?:"[^"]*"|'[^']*'|\/[^>])[^'"\/>]*)*)(\/?)>/g;function m(t,n,r,i){if(!i){u=e.array(n.brackets);t=t.replace(h,"").replace(a,"")}if(!r)r=[];t=d(t,n,r).replace(v,function(e,t,n,r){t=t.toLowerCase();r=r&&!o.test(t)?"></"+t:"";if(n)t+=" "+p(n);return"<"+t+r+">"});t=n.whitespace?t.replace(/\r\n?|\n/g,"\\n"):t.trim().replace(/\s+/g," ");if(n.compact)t=t.replace(/> <([-\w\/])/g,"><$1");return g(t,r)}var b=t("("+e.S_QBLOCKS+")|"+e.R_MLCOMMS.source+"|//[^\r\n]*","g"),y=/^([ \t]*)([$_A-Za-z][$\w]*)\s*(\([^()]*\)\s*{)/m;function w(n){var r,i,o=[],f;n=n.replace(b,function(e,t){return t?e:" "});while(r=n.match(y)){o.push(RegExp.leftContext);n=RegExp.rightContext;f=a(n);i=!/^(?:if|while|for|switch|catch|function)$/.test(r[2]);if(i)r[0]=r[1]+"this."+r[2]+" = function"+r[3];o.push(r[0],n.slice(0,f));n=n.slice(f);if(i&&!/^\s*.\s*bind\b/.test(n))o.push(".bind(this)")}return o.length?o.join("")+n:n;function a(n){var r=t("([{}])|"+e.S_QBLOCKS,"g"),i=1,o;while(i&&(o=r.exec(n))){if(o[1])o[1]==="{"?++i:--i}return i?n.length:r.lastIndex}}function x(e,t,n,r){if(!n)n=t.type;var i=t.parser||(n?ae.js[n]:w);if(!i)throw new Error('JS parser not found: "'+n+'"');return i(e,r).replace(a,"")}var _=t("(}|{|^)[ ;]*([^@ ;][^{}]*)(?={)|"+e.R_STRINGS.source,"g");function S(e,t){var n=":scope";return t.replace(_,function(t,r,i){if(!i)return t;i=i.replace(/[^,]+/g,function(t){var r=t.trim();if(r&&r!=="from"&&r!=="to"&&r.slice(-1)!=="%"){if(r.indexOf(n)<0)r=n+" "+r;r=r.replace(n,e)+","+r.replace(n,'[riot-tag="'+e+'"]')}return t.slice(-1)===" "?r+" ":r});return r?r+" "+i:i})}function C(t,n,r,i,o){if(r){if(r==="scoped-css"){i=true}else if(ae.css[r]){t=ae.css[r](n,t,o)}else if(r!=="css"){throw new Error('CSS parser not found: "'+r+'"')}}t=t.replace(e.R_MLCOMMS,"").replace(/\s+/g," ").trim();return i?S(n,t):t}var L=/\stype\s*=\s*(?:['"]([^'"]+)['"]|(\S+))/i;function N(e){if(e){var t=e.match(L);e=t&&(t[1]||t[2])}return e?e.replace("text/",""):""}function M(e,n){if(e){var r=t(L.source.replace("type",n),"i"),i=e&&e.match(r);e=i&&(i[1]||i[2])}return e||""}function E(e){var t=M(e,"options");if(t)t=JSON.parse(parserOpts);return t}function T(e,t,n){var r=N(n),i=E(n);return x(e,t,r,i)}var $=/\/>\n|^<(?:\/[\w\-]+\s*|[\w\-]+(?:\s+(?:[-\w:\xA0-\xFF][\S\s]*?)?)?)>\n/;function O(e){var t,n;if(e[e.length-1]===">")return[e,""];t=e.lastIndexOf("<");while(~t){if(n=e.slice(t).match($)){t+=n.index+n[0].length;return[e.slice(0,t),e.slice(t)]}t=e.lastIndexOf("<",t-1)}return["",e]}function k(e,t,n){var r=ae.html[e];if(!r)throw new Error('Template parser not found: "'+e+'"');return r(t,n)}var A=/^<([-\w]+)(?:\s+([^'"\/>]+(?:(?:"[^"]*"|'[^']*'|\/[^>])[^'"\/>]*)*)|\s*)?(?:\/>|>[ \t]*\n?([\s\S]*)^<\/\1\s*>|>(.*)<\/\1\s*>)/gim,j=/<style(\s+[^>]*)?>\n?([^<]*(?:<(?!\/style\s*>)[^<]*)*)<\/style\s*>/gi,R=t(j.source.replace(/tyle/g,"cript"),"gi");function I(t,n,r){var i;if(!n)n={};u=e.array(n.brackets);if(n.template)t=k(n.template,t,n.templateOptions);i=r?"//src: "+r+"\n":"";return i+t.replace(/\r\n?/g,"\n").replace(A,function(e,t,r,i,o){var f="",u="",s="",l=[];t=t.toLowerCase();if(r)r=g(p(d(r,n,l)),l);if(o)i=o;if(i&&(i=i.replace(h,""))&&/\S/.test(i)){if(o)s=m(o,n,l,1);else{i=i.replace(j,function(e,n,r){var i=n&&/\sscoped(\s|=|$)/i.test(n);u+=(u?" ":"")+C(r,t,N(n),i,E(n));return""});i=i.replace(R,function(e,t,r){f+=(f?"\n":"")+T(r,n,t);return""});var v=O(i.replace(a,""));i=v[0];if(i)s=m(i,n,l,1);i=v[1];if(/\S/.test(i))f+=(f?"\n":"")+x(i,n)}}return c(t,s,u,r,f,l)})}return I}();n.compile=function(){var r=e.document,i,o;function f(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===4&&(r.status===200||!r.status&&r.responseText.length))t(r.responseText,n,e)};r.open("GET",e,true);r.send("")}function a(e,t){var n=e.match(/^([ \t]*)</m);return n&&n[1]?e.replace(new RegExp("^"+n[1],"gm"),""):e}function u(e,t,n){var i=r.createElement("script"),o=r.documentElement;i.text=e;o.appendChild(i);o.removeChild(i)}function s(e){var t=r.querySelectorAll('script[type="riot/tag"]'),n=t.length;function s(){i.trigger("ready");o=true;if(e)e()}function c(e,t,r){u(ue(e,t,r));if(!--n)s()}if(!n)s();else{for(var l=0;l<t.length;++l){var p=t[l],d={template:p.getAttribute("template")},g=p.getAttribute("src");g?f(g,c,d):c(a(p.innerHTML),d)}}}return function(e,r){if(typeof e==="string"){if(/^\s*</.test(e)){var c=ue(a(e));if(!r)u(c);return c}f(e,function(t){var n=ue(t,{},e);u(n);if(r)r(n,t)})}else{r=typeof e!=="function"?t:e;if(o)return r&&r();if(i){if(r)i.on("ready",r)}else{i=n.observable();s(r)}}}}();var se=n.mount;n.mount=function(e,t,r){var i;n.compile(function(){i=se(e,t,r)});return i};if(typeof exports===s)module.exports=n;else if(typeof define==="function"&&define.amd)define(function(){return e.riot=n});else e.riot=n})(typeof window!="undefined"?window:void 0);