forked from plumpNation/riot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriot+compiler.min.js
2 lines (2 loc) · 30.5 KB
/
riot+compiler.min.js
1
2
/* Riot v2.5.0, @license MIT */
!function(e,t){"use strict";function n(e,t,n){var r={};return r[e.key]=t,e.pos&&(r[e.pos]=n),r}function r(e,t){for(var n,r=t.length,o=e.length;r>o;)n=t[--r],t.splice(r,1),n.unmount()}function o(e,t){Object.keys(e.tags).forEach(function(n){var r=e.tags[n];A(r)?g(r,function(e){E(e,n,t)}):E(r,n,t)})}function i(e,t,n){var r,o=e._root;for(e._virts=[];o;)r=o.nextSibling,n?t.insertBefore(o,n._root):t.appendChild(o),e._virts.push(o),o=r}function a(e,t,n,r){for(var o,i=e._root,a=0;a<r;a++)o=i.nextSibling,t.insertBefore(i,n._root),i=o}function u(e,t,u){b(e,"each");var s,c=typeof _(e,"no-reorder")!==ne||b(e,"no-reorder"),l=M(e),p=X[l]||{tmpl:h(e)},d=ae.test(l),g=e.parentNode,m=document.createTextNode(""),v=S(e),x="option"===l.toLowerCase(),y=[],w=[],C="VIRTUAL"==e.tagName;u=pe.loopKeys(u),g.insertBefore(m,e),t.one("before-mount",function(){e.parentNode.removeChild(e),g.stub&&(g=t.root)}).on("update",function(){var h=pe(u.val,t),b=document.createDocumentFragment();A(h)||(s=h||!1,h=s?Object.keys(h).map(function(e){return n(u,e,h[e])}):[]);for(var _=0,S=h.length;_<S;_++){var O=h[_],E=c&&typeof O==re&&!s,N=w.indexOf(O),L=~N&&E?N:_,M=y[L];O=!s&&u.key?n(u,O,_):O,!E&&!M||E&&!~N||!M?(M=new f(p,{parent:t,isLoop:!0,hasImpl:!!X[l],root:d?g:e.cloneNode(),item:O},e.innerHTML),M.mount(),C&&(M._root=M.root.firstChild),_!=y.length&&y[_]?(C?i(M,g,y[_]):g.insertBefore(M.root,y[_].root),w.splice(_,0,O)):C?i(M,b):b.appendChild(M.root),y.splice(_,0,M),L=_):M.update(O,!0),L!==_&&E&&y[_]&&(C?a(M,g,y[_],e.childNodes.length):g.insertBefore(M.root,y[_].root),u.pos&&(M[u.pos]=_),y.splice(_,0,y.splice(L,1)[0]),w.splice(_,0,w.splice(L,1)[0]),!v&&M.tags&&o(M,_)),M._item=O,j(M,"_parent",t)}if(r(h,y),g.insertBefore(b,m),x&&fe&&!g.multiple)for(var T=0;T<g.length;T++)if(g[T].__riot1374){g.selectedIndex=T,delete g[T].__riot1374;break}v&&(t.tags[l]=y),w=h.slice()})}function s(e,t,n,r){k(e,function(e){if(1==e.nodeType){if(e.isLoop=e.isLoop||e.parentNode&&e.parentNode.isLoop||_(e,"each")?1:0,n){var o=S(e);o&&!e.isLoop&&n.push(N(o,{root:e,parent:t},e.innerHTML,t))}e.isLoop&&!r||K(e,t,[])}})}function c(e,t,n){function r(e,t,r){pe.hasExpr(t)&&n.push(T({dom:e,expr:t},r))}k(e,function(e){var n,o=e.nodeType;if(3==o&&"STYLE"!=e.parentNode.tagName&&r(e,e.nodeValue),1==o)return(n=_(e,"each"))?(u(e,t,n),!1):(g(e.attributes,function(t){var n=t.name,o=n.split("__")[1];if(r(e,t.value,{attr:o||n,bool:o}),o)return b(e,n),!1}),!S(e)&&void 0)})}function f(e,n,r){function o(){var e=_&&x?p:v||p;g(N.attributes,function(t){var n=t.value;h[w(t.name)]=pe.hasExpr(n)?pe(n,e):n}),g(Object.keys(k),function(t){h[w(t)]=pe(k[t],e)})}function i(e){for(var t in S)typeof p[t]!==oe&&I(p,t)&&(p[t]=e[t])}function a(){p.parent&&x&&g(Object.keys(p.parent),function(e){var t=!ue.test(e)&&R(H,e);(typeof p[e]===oe||t)&&(t||H.push(e),p[e]=p.parent[e])})}function u(e){p.update(e,!0)}function f(e){if(g(E,function(t){t[e?"mount":"unmount"]()}),v){var t=e?"on":"off";x?v[t]("unmount",p.unmount):v[t]("update",u)[t]("unmount",p.unmount)}}var l,p=V.observable(this),h=D(n.opts)||{},v=n.parent,x=n.isLoop,_=n.hasImpl,S=$(n.item),O=[],E=[],N=n.root,M=N.tagName.toLowerCase(),k={},H=[];e.name&&N._tag&&N._tag.unmount(!0),this.isMounted=!1,N.isLoop=x,N._tag=this,j(this,"_riot_id",++Q),T(this,{parent:v,root:N,opts:h},S),j(this,"tags",{}),g(N.attributes,function(e){var t=e.value;pe.hasExpr(t)&&(k[e.name]=t)}),l=de(e.tmpl,r),j(this,"update",function(e,t){return e=$(e),a(),e&&y(S)&&(i(e),S=e),T(p,e),o(),p.trigger("update",e),d(O,p),t&&p.parent?p.parent.one("updated",function(){p.trigger("updated")}):me(function(){p.trigger("updated")}),this}),j(this,"mixin",function(){return g(arguments,function(e){var t,n,r=[];e=typeof e===ne?V.mixin(e):e,t=m(e)?new e:e;do r=r.concat(Object.getOwnPropertyNames(n||t));while(n=Object.getPrototypeOf(n||t));g(r,function(e){"init"==e||p[e]||(p[e]=m(t[e])?t[e].bind(p):t[e])}),t.init&&t.init.bind(p)()}),this}),j(this,"mount",function(){o();var t=V.mixin(J);if(t)for(var n in t)t.hasOwnProperty(n)&&p.mixin(t[n]);if(e.fn&&e.fn.call(p,h),c(l,p,O),f(!0),e.attrs&&F(e.attrs,function(e,t){C(N,e,t)}),(e.attrs||_)&&c(p.root,p,O),p.parent&&!x||p.update(S),p.trigger("before-mount"),x&&!_)N=l.firstChild;else{for(;l.firstChild;)N.appendChild(l.firstChild);N.stub&&(N=v.root)}j(p,"root",N),x&&s(p.root,p.parent,null,!0),!p.parent||p.parent.isMounted?(p.isMounted=!0,p.trigger("mount")):p.parent.one("mount",function(){P(p.root)||(p.parent.isMounted=p.isMounted=!0,p.trigger("mount"))})}),j(this,"unmount",function(e){var n,r=N,o=r.parentNode,i=W.indexOf(p);if(p.trigger("before-unmount"),~i&&W.splice(i,1),o){if(v)n=L(v),A(n.tags[M])?g(n.tags[M],function(e,t){e._riot_id==p._riot_id&&n.tags[M].splice(t,1)}):n.tags[M]=t;else for(;r.firstChild;)r.removeChild(r.firstChild);e?(b(o,te),b(o,ee)):o.removeChild(r)}this._virts&&g(this._virts,function(e){e.parentNode&&e.parentNode.removeChild(e)}),p.trigger("unmount"),f(),p.off("*"),p.isMounted=!1,delete N._tag}),s(l,this,E)}function l(t,n,r,o){r[t]=function(t){var i,a=o._parent,u=o._item;if(!u)for(;a&&!u;)u=a._item,a=a._parent;t=t||e.event,I(t,"currentTarget")&&(t.currentTarget=r),I(t,"target")&&(t.target=t.srcElement),I(t,"which")&&(t.which=t.charCode||t.keyCode),t.item=u,n.call(o,t)===!0||/radio|check/.test(r.type)||(t.preventDefault&&t.preventDefault(),t.returnValue=!1),t.preventUpdate||(i=u?L(a):o,i.update())}}function p(e,t,n){e&&(e.insertBefore(n,t),e.removeChild(t))}function d(e,t){g(e,function(e,n){var r=e.dom,o=e.attr,i=pe(e.expr,t),a=e.dom.parentNode;if(e.bool?i=!!i:null==i&&(i=""),e.value!==i){if(e.value=i,!o)return i+="",void(a&&("TEXTAREA"===a.tagName?(a.value=i,ce||(r.nodeValue=i)):r.nodeValue=i));if("value"===o)return void(r.value=i);if(b(r,o),m(i))l(o,i,r,t);else if("if"==o){var u=e.stub,s=function(){p(u.parentNode,u,r)},c=function(){p(r.parentNode,r,u)};i?u&&(s(),r.inStub=!1,P(r)||k(r,function(e){e._tag&&!e._tag.isMounted&&(e._tag.isMounted=!!e._tag.trigger("mount"))})):(u=e.stub=u||document.createTextNode(""),r.parentNode?c():(t.parent||t).one("updated",c),r.inStub=!0)}else"show"===o?r.style.display=i?"":"none":"hide"===o?r.style.display=i?"none":"":e.bool?(r[o]=i,i&&C(r,o,o),fe&&"selected"===o&&"OPTION"===r.tagName&&(r.__riot1374=i)):(0===i||i&&typeof i!==re)&&(Z(o,Y)&&o!=ee&&(o=o.slice(Y.length)),C(r,o,i))}})}function g(e,t){for(var n,r=e?e.length:0,o=0;o<r;o++)n=e[o],null!=n&&t(n,o)===!1&&o--;return e}function m(e){return typeof e===ie||!1}function h(e){if(e.outerHTML)return e.outerHTML;var t=H("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}function v(e,t){if(typeof e.innerHTML!=oe)e.innerHTML=t;else{var n=(new DOMParser).parseFromString(t,"application/xml");e.appendChild(e.ownerDocument.importNode(n.documentElement,!0))}}function x(e){return~se.indexOf(e)}function y(e){return e&&typeof e===re}function b(e,t){e.removeAttribute(t)}function w(e){return e.replace(/-(\w)/g,function(e,t){return t.toUpperCase()})}function _(e,t){return e.getAttribute(t)}function C(e,t,n){e.setAttribute(t,n)}function S(e){return e.tagName&&X[_(e,te)||_(e,ee)||e.tagName.toLowerCase()]}function O(e,t,n){var r=n.tags[t];r?(A(r)||r!==e&&(n.tags[t]=[r]),R(n.tags[t],e)||n.tags[t].push(e)):n.tags[t]=e}function E(e,t,n){var r,o=e.parent;o&&(r=o.tags[t],A(r)?r.splice(n,0,r.splice(r.indexOf(e),1)[0]):O(e,t,o))}function N(e,t,n,r){var o=new f(e,t,n),i=M(t.root),a=L(r);return o.parent=a,o._parent=r,O(o,i,a),a!==r&&O(o,i,r),t.root.innerHTML="",o}function L(e){for(var t=e;!S(t.root)&&t.parent;)t=t.parent;return t}function j(e,t,n,r){return Object.defineProperty(e,t,T({value:n,enumerable:!1,writable:!1,configurable:!0},r)),e}function M(e){var t=S(e),n=_(e,"name"),r=n&&!pe.hasExpr(n)?n:t?t.name:e.tagName.toLowerCase();return r}function T(e){for(var t,n=arguments,r=1;r<n.length;++r)if(t=n[r])for(var o in t)I(e,o)&&(e[o]=t[o]);return e}function R(e,t){return~e.indexOf(t)}function A(e){return Array.isArray(e)||e instanceof Array}function I(e,t){var n=Object.getOwnPropertyDescriptor(e,t);return typeof e[t]===oe||n&&n.writable}function $(e){if(!(e instanceof f||e&&typeof e.trigger==ie))return e;var t={};for(var n in e)ue.test(n)||(t[n]=e[n]);return t}function k(e,t){if(e){if(t(e)===!1)return;for(e=e.firstChild;e;)k(e,t),e=e.nextSibling}}function F(e,t){for(var n,r=/([-\w]+) ?= ?(?:"([^"]*)|'([^']*)|({[^}]*}))/g;n=r.exec(e);)t(n[1].toLowerCase(),n[2]||n[3]||n[4])}function P(e){for(;e;){if(e.inStub)return!0;e=e.parentNode}return!1}function H(e,t){return t?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(e)}function B(e,t){return(t||document).querySelectorAll(e)}function q(e,t){return(t||document).querySelector(e)}function D(e){function t(){}return t.prototype=e,new t}function z(e){return _(e,"id")||_(e,"name")}function K(e,t,n){var r,o=z(e),i=function(i){R(n,o)||(r=A(i),i?(!r||r&&!R(i,e))&&(r?i.push(e):t[o]=[i,e]):t[o]=e)};o&&(pe.hasExpr(o)?t.one("mount",function(){o=z(e),i(t[o])}):i(t[o]))}function Z(e,t){return e.slice(0,t.length)===t}function G(e,t,n){var r=X[t],o=e._innerHTML=e._innerHTML||e.innerHTML;return e.innerHTML="",r&&e&&(r=new f(r,{root:e,opts:n},o)),r&&r.mount&&(r.mount(),R(W,r)||W.push(r)),r}function U(e){var t=e.source,n=e.global?"g":"";e.ignoreCase&&(n+="i"),e.multiline&&(n+="m");for(var r=1;r<arguments.length;r++)t=t.replace("@","\\"+arguments[r]);return new RegExp(t,n)}var V={version:"v2.5.0",settings:{}},Q=0,W=[],X={},J="__global_mixin",Y="riot-",ee=Y+"tag",te="data-is",ne="string",re="object",oe="undefined",ie="function",ae=/^(?:t(?:body|head|foot|[rhd])|caption|col(?:group)?|opt(?:ion|group))$/,ue=/^(?:_(?:item|id|parent)|update|root|(?:un)?mount|mixin|is(?:Mounted|Loop)|tags|parent|opts|trigger|o(?:n|ff|ne))$/,se=["altGlyph","animate","animateColor","circle","clipPath","defs","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","font","foreignObject","g","glyph","glyphRef","image","line","linearGradient","marker","mask","missing-glyph","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","tref","tspan","use"],ce=0|(e&&e.document||{}).documentMode,fe=e&&!!e.InstallTrigger;V.observable=function(e){function t(e,t){for(var n,r,o=e.split(" "),i=o.length,a=0;a<i;a++)n=o[a],r=n.indexOf("."),n&&t(~r?n.substring(0,r):n,a,~r?n.slice(r+1):null)}e=e||{};var n={},r=Array.prototype.slice;return Object.defineProperties(e,{on:{value:function(r,o){return"function"!=typeof o?e:(t(r,function(e,t,r){(n[e]=n[e]||[]).push(o),o.typed=t>0,o.ns=r}),e)},enumerable:!1,writable:!1,configurable:!1},off:{value:function(r,o){return"*"!=r||o?t(r,function(e,t,r){if(o||r)for(var i,a=n[e],u=0;i=a&&a[u];++u)(i==o||r&&i.ns==r)&&a.splice(u--,1);else delete n[e]}):n={},e},enumerable:!1,writable:!1,configurable:!1},one:{value:function(t,n){function r(){e.off(t,r),n.apply(e,arguments)}return e.on(t,r)},enumerable:!1,writable:!1,configurable:!1},trigger:{value:function(o){for(var i,a=arguments.length-1,u=new Array(a),s=0;s<a;s++)u[s]=arguments[s+1];return t(o,function(t,o,a){i=r.call(n[t]||[],0);for(var s,c=0;s=i[c];++c)s.busy||(s.busy=1,a&&s.ns!=a||s.apply(e,s.typed?[t].concat(u):u),i[c]!==s&&c--,s.busy=0);n["*"]&&"*"!=t&&e.trigger.apply(e,["*",t].concat(u))}),e},enumerable:!1,writable:!1,configurable:!1}}),e},function(t){function n(e){return e.split(/[\/?#]/)}function r(e,t){var n=new RegExp("^"+t[S](/\*/g,"([^/?#]+?)")[S](/\.\./,".*")+"$"),r=e.match(n);if(r)return r.slice(1)}function o(e,t){var n;return function(){clearTimeout(n),n=setTimeout(e,t)}}function i(e){g=o(l,1),j[_](O,g),j[_](E,g),M[_](I,p),e&&l(!0)}function a(){this.$=[],t.observable(this),k.on("stop",this.s.bind(this)),k.on("emit",this.e.bind(this))}function u(e){return e[S](/^\/|\/$/,"")}function s(e){return"string"==typeof e}function c(e){return(e||R.href)[S](y,"")}function f(e){return"#"==m[0]?(e||R.href||"").split(m)[1]||"":(R?c(e):e||"")[S](m,"")}function l(e){var t=0==H;if(!(L<=H)&&(H++,P.push(function(){var t=f();(e||t!=h)&&(k[N]("emit",t),h=t)}),t)){for(;P.length;)P[0](),P.shift();H=0}}function p(e){if(!(1!=e.which||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented)){for(var t=e.target;t&&"A"!=t.nodeName;)t=t.parentNode;!t||"A"!=t.nodeName||t[C]("download")||!t[C]("href")||t.target&&"_self"!=t.target||t.href.indexOf(R.href.match(y)[0])==-1||(t.href==R.href||t.href.split("#")[0]!=R.href.split("#")[0]&&("#"==m||0===c(t.href).indexOf(m))&&d(f(t.href),t.title||M.title))&&e.preventDefault()}}function d(e,t,n){return T?(e=m+u(e),t=t||M.title,n?T.replaceState(null,t,e):T.pushState(null,t,e),M.title=t,F=!1,l(),F):k[N]("emit",f(e))}var g,m,h,v,x,y=/^.+?\/\/+[^\/]+/,b="EventListener",w="remove"+b,_="add"+b,C="hasAttribute",S="replace",O="popstate",E="hashchange",N="trigger",L=3,j="undefined"!=typeof e&&e,M="undefined"!=typeof document&&document,T=j&&history,R=j&&(T.location||j.location),A=a.prototype,I=M&&M.ontouchstart?"touchstart":"click",$=!1,k=t.observable(),F=!1,P=[],H=0;A.m=function(e,t,n){!s(e)||t&&!s(t)?t?this.r(e,t):this.r("@",e):d(e,t,n||!1)},A.s=function(){this.off("*"),this.$=[]},A.e=function(e){this.$.concat("@").some(function(t){var n=("@"==t?v:x)(u(e),u(t));if("undefined"!=typeof n)return this[N].apply(null,[t].concat(n)),F=!0},this)},A.r=function(e,t){"@"!=e&&(e="/"+u(e),this.$.push(e)),this.on(e,t)};var B=new a,q=B.m.bind(B);q.create=function(){var e=new a,t=e.m.bind(e);return t.stop=e.s.bind(e),t},q.base=function(e){m=e||"#",h=f()},q.exec=function(){l(!0)},q.parser=function(e,t){e||t||(v=n,x=r),e&&(v=e),t&&(x=t)},q.query=function(){var e={},t=R.href||h;return t[S](/[?&](.+?)=([^&]*)/g,function(t,n,r){e[n]=r}),e},q.stop=function(){$&&(j&&(j[w](O,g),j[w](E,g),M[w](I,p)),k[N]("stop"),$=!1)},q.start=function(e){$||(j&&("complete"==document.readyState?i(e):j[_]("load",function(){setTimeout(function(){i(e)},1)})),$=!0)},q.base(),q.parser(),t.route=q}(V);var le=function(e){function t(e){return e}function n(e,t){return t||(t=v),new RegExp(e.source.replace(/{/g,t[2]).replace(/}/g,t[3]),e.global?c:"")}function r(e){if(e===g)return m;var t=e.split(" ");if(2!==t.length||/[\x00-\x1F<>a-zA-Z0-9'",;\\]/.test(e))throw new Error('Unsupported brackets "'+e+'"');return t=t.concat(e.replace(/(?=[[\]()*+?.^$|])/g,"\\").split(" ")),t[4]=n(t[1].length>1?/{[\S\s]*?}/:m[4],t),t[5]=n(e.length>3?/\\({|})/g:m[5],t),t[6]=n(m[6],t),t[7]=RegExp("\\\\("+t[3]+")|([[({])|("+t[3]+")|"+p,c),t[8]=e,t}function o(e){return e instanceof RegExp?u(e):v[e]}function i(e){(e||(e=g))!==v[8]&&(v=r(e),u=e===g?t:n,v[9]=u(m[9])),h=e}function a(e){var t;e=e||{},t=e.brackets,Object.defineProperty(e,"brackets",{set:i,get:function(){return h},enumerable:!0}),s=e,i(t)}var u,s,c="g",f=/\/\*[^*]*\*+(?:[^*\/][^*]*\*+)*\//g,l=/"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'/g,p=l.source+"|"+/(?:\breturn\s+|(?:[$\w\)\]]|\+\+|--)\s*(\/)(?![*\/]))/.source+"|"+/\/(?=[^*\/])[^[\/\\]*(?:(?:\[(?:\\.|[^\]\\]*)*\]|\\.)[^[\/\\]*)*?(\/)[gim]*/.source,d={"(":RegExp("([()])|"+p,c),"[":RegExp("([[\\]])|"+p,c),"{":RegExp("([{}])|"+p,c)},g="{ }",m=["{","}","{","}",/{[^}]*}/,/\\([{}])/g,/\\({)|{/g,RegExp("\\\\(})|([[({])|(})|"+p,c),g,/^\s*{\^?\s*([$\w]+)(?:\s*,\s*(\S+))?\s+in\s+(\S.*)\s*}/,/(^|[^\\]){=[\S\s]*?}/],h=e,v=[];return o.split=function(e,t,n){function r(e){t||a?c.push(e&&e.replace(n[5],"$1")):c.push(e)}function o(e,t,n){var r,o=d[t];for(o.lastIndex=n,n=1;(r=o.exec(e))&&(!r[1]||(r[1]===t?++n:--n)););return n?e.length:o.lastIndex}n||(n=v);var i,a,u,s,c=[],f=n[6];for(a=u=f.lastIndex=0;i=f.exec(e);){if(s=i.index,a){if(i[2]){f.lastIndex=o(e,i[2],f.lastIndex);continue}if(!i[3])continue}i[1]||(r(e.slice(u,s)),u=f.lastIndex,f=n[6+(a^=1)],f.lastIndex=u)}return e&&u<e.length&&r(e.slice(u)),c},o.hasExpr=function(e){return v[4].test(e)},o.loopKeys=function(e){var t=e.match(v[9]);return t?{key:t[1],pos:t[2],val:v[0]+t[3].trim()+v[1]}:{val:e.trim()}},o.array=function(e){return e?r(e):v},Object.defineProperty(o,"settings",{set:a,get:function(){return s}}),o.settings="undefined"!=typeof V&&V.settings||{},o.set=i,o.R_STRINGS=l,o.R_MLCOMMS=f,o.S_QBLOCKS=p,o}(),pe=function(){function t(e,t){return e?(u[e]||(u[e]=r(e))).call(t,n):e}function n(e,n){t.errorHandler&&(e.riotData={tagName:n&&n.root&&n.root.tagName,_riot_id:n&&n._riot_id},t.errorHandler(e))}function r(e){var t=o(e);return"try{return "!==t.slice(0,11)&&(t="return "+t),new Function("E",t+";")}function o(e){var t,n=[],r=le.split(e.replace(l,'"'),1);if(r.length>2||r[0]){var o,a,u=[];for(o=a=0;o<r.length;++o)t=r[o],t&&(t=1&o?i(t,1,n):'"'+t.replace(/\\/g,"\\\\").replace(/\r\n?|\n/g,"\\n").replace(/"/g,'\\"')+'"')&&(u[a++]=t);t=a<2?u[0]:"["+u.join(",")+'].join("")'}else t=i(r[1],0,n);return n[0]&&(t=t.replace(p,function(e,t){return n[t].replace(/\r/g,"\\r").replace(/\n/g,"\\n")})),t}function i(e,t,n){function r(t,n){var r,o=1,i=d[t];for(i.lastIndex=n.lastIndex;r=i.exec(e);)if(r[0]===t)++o;else if(!--o)break;n.lastIndex=o?e.length:i.lastIndex}if(e=e.replace(f,function(e,t){return e.length>2&&!t?s+(n.push(e)-1)+"~":e}).replace(/\s+/g," ").trim().replace(/\ ?([[\({},?\.:])\ ?/g,"$1")){for(var o,i=[],u=0;e&&(o=e.match(c))&&!o.index;){var l,p,g=/,|([[{(])|$/g;for(e=RegExp.rightContext,l=o[2]?n[o[2]].slice(1,-1).trim().replace(/\s+/g," "):o[1];p=(o=g.exec(e))[1];)r(p,g);p=e.slice(0,o.index),e=RegExp.rightContext,i[u++]=a(p,1,l)}e=u?u>1?"["+i.join(",")+'].join(" ").trim()':i[0]:a(e,t)}return e}function a(e,t,n){var r;return e=e.replace(m,function(e,t,n,o,i){return n&&(o=r?0:o+e.length,"this"!==n&&"global"!==n&&"window"!==n?(e=t+'("'+n+g+n,o&&(r="."===(i=i[o])||"("===i||"["===i)):o&&(r=!h.test(i.slice(o)))),e}),r&&(e="try{return "+e+"}catch(e){E(e,this)}"),n?e=(r?"function(){"+e+"}.call(this)":"("+e+")")+'?"'+n+'":""':t&&(e="function(v){"+(r?e.replace("return ","v="):"v=("+e+")")+';return v||v===0?v:""}.call(this)'),e}var u={};t.haveRaw=le.hasRaw,t.hasExpr=le.hasExpr,t.loopKeys=le.loopKeys,t.errorHandler=null;var s="⁗",c=/^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\u2057(\d+)~):/,f=RegExp(le.S_QBLOCKS,"g"),l=/\u2057/g,p=/\u2057(\d+)~/g,d={"(":/[()]/g,"[":/[[\]]/g,"{":/[{}]/g},g='"in this?this:'+("object"!=typeof e?"global":"window")+").",m=/[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g,h=/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/;return t.parse=function(e){return e},t.version=le.version="v2.4.0",t}(),de=function e(){function e(e,r){var o=e&&e.match(/^\s*<([-\w]+)/),i=o&&o[1].toLowerCase(),a=H("div",x(i));return e=n(e,r),s.test(i)?a=t(a,e,i):v(a,e),a.stub=!0,a}function t(e,t,n){var r="o"===n[0],o=r?"select>":"table>";if(e.innerHTML="<"+o+t.trim()+"</"+o,o=e.firstChild,r)o.selectedIndex=-1;else{var i=u[n];i&&1===o.childElementCount&&(o=q(i,o))}return o}function n(e,t){if(!r.test(e))return e;var n={};return t=t&&t.replace(i,function(e,t,r){return n[t]=n[t]||r,""}).trim(),e.replace(a,function(e,t,r){return n[t]||r||""}).replace(o,function(e,n){return t||n||""})}var r=/<yield\b/i,o=/<yield\s*(?:\/>|>([\S\s]*?)<\/yield\s*>|>)/gi,i=/<yield\s+to=['"]([^'">]*)['"]\s*>([\S\s]*?)<\/yield\s*>/gi,a=/<yield\s+from=['"]?([-\w]+)['"]?\s*(?:\/>|>([\S\s]*?)<\/yield\s*>)/gi,u={tr:"tbody",th:"tr",td:"tr",col:"colgroup"},s=ce&&ce<10?ae:/^(?:t(?:body|head|foot|[rhd])|caption|col(?:group)?)$/;return e}(),ge=function(t){if(!e)return{add:function(){},inject:function(){}};var n=function(){var e=H("style");C(e,"type","text/css");var t=q("style[type=riot]");return t?(t.id&&(e.id=t.id),t.parentNode.replaceChild(e,t)):document.getElementsByTagName("head")[0].appendChild(e),e}(),r=n.styleSheet,o="";return Object.defineProperty(t,"styleNode",{value:n,writable:!0}),{add:function(e){o+=e},inject:function(){o&&(r?r.cssText+=o:n.innerHTML+=o,o="")}}}(V),me=function(e){var t=e.requestAnimationFrame||e.mozRequestAnimationFrame||e.webkitRequestAnimationFrame;if(!t||/iP(ad|hone|od).*OS 6/.test(e.navigator.userAgent)){var n=0;t=function(e){var t=Date.now(),r=Math.max(16-(t-n),0);setTimeout(function(){e(n=t+r)},r)}}return t}(e||{});V.util={brackets:le,tmpl:pe},V.mixin=function(){var e={},t=e[J]={},n=0;return function(r,o,i){if(y(r))return void V.mixin("__unnamed_"+n++,r,!0);var a=i?t:e;if(!o){if(typeof a[r]===oe)throw new Error("Unregistered mixin: "+r);return a[r]}m(o)?(T(o.prototype,a[r]||{}),a[r]=o):a[r]=T(a[r]||{},o)}}(),V.tag=function(e,t,n,r,o){return m(r)&&(o=r,/^[\w\-]+\s?=/.test(n)?(r=n,n=""):r=""),n&&(m(n)?o=n:ge.add(n)),e=e.toLowerCase(),X[e]={name:e,tmpl:t,attrs:r,fn:o},e},V.tag2=function(e,t,n,r,o){return n&&ge.add(n),X[e]={name:e,tmpl:t,attrs:r,fn:o},e},V.mount=function(e,t,n){function r(e){var t="";return g(e,function(e){/[^-\w]/.test(e)||(e=e.trim().toLowerCase(),t+=",["+te+'="'+e+'"],['+ee+'="'+e+'"]')}),t}function o(){var e=Object.keys(X);return e+r(e)}function i(e){if(e.tagName){var r=_(e,te)||_(e,ee);t&&r!==t&&(r=t,C(e,te,t),C(e,ee,t));var o=G(e,r||e.tagName.toLowerCase(),n);o&&s.push(o)}else e.length&&g(e,i)}var a,u,s=[];if(ge.inject(),y(t)&&(n=t,t=0),typeof e===ne?("*"===e?e=u=o():e+=r(e.split(/, */)),a=e?B(e):[]):a=e,"*"===t){if(t=u||o(),a.tagName)a=B(t,a);else{var c=[];g(a,function(e){c.push(B(t,e))}),a=c}t=0}return i(a),s},V.update=function(){return g(W,function(e){e.update()})},V.vdom=W,V.Tag=f;var he=function(e){function t(t){var n=e[t];if(n)return n;throw new Error('Parser "'+t+'" not loaded.')}function n(e){var t=e.split(".");if(2!==t.length)throw new Error("Bad format for parsers._req");var n=i[t[0]][t[1]];if(n)return n;throw new Error('Parser "'+e+'" not found.')}function r(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function o(e,n,o,i){return o=r({pretty:!0,filename:i,doctype:"html"},o),t(e).render(n,o)}var i={};return i.html={jade:function(e,t,n){return console.log('DEPRECATION WARNING: jade was renamed "pug" - The jade parser will be removed in [email protected]!'),o("jade",e,t,n)},pug:function(e,t,n){return o("pug",e,t,n)}},i.css={less:function(e,n,o,i){var a;return o=r({sync:!0,syncImport:!0,filename:i},o),t("less").render(n,o,function(e,t){if(e)throw e;a=t.css}),a}},i.js={es6:function(e,n){return n=r({blacklist:["useStrict","strict","react"],sourceMaps:!1,comments:!1},n),t("babel").transform(e,n).code},babel:function(e,n,o){return t("babel").transform(e,r({filename:o},n)).code},coffee:function(e,n){return t("CoffeeScript").compile(e,r({bare:!0},n))},livescript:function(e,n){return t("livescript").compile(e,r({bare:!0,header:!1},n))},typescript:function(e,n){return t("typescript")(e,n)},none:function(e){return e}},i.js.javascript=i.js.none,i.js.coffeescript=i.js.coffee,i._req=n,i.utils={extend:r},i}(e||global);V.parsers=he;var ve=function(){function e(e){var t,n=j;for(~e.indexOf("\r")&&(e=e.replace(/\r\n?/g,"\n")),n.lastIndex=0;t=n.exec(e);)"<"===t[0][0]&&(e=RegExp.leftContext+RegExp.rightContext,n.lastIndex=t[3]+1);return e}function t(e,t){var n,r,o,i=[];for(L.lastIndex=0,e=e.replace(/\s+/g," ");n=L.exec(e);){var a=n[1].toLowerCase(),u=n[2];u?(u[0]!==z&&(u=z+(u[0]===K?u.slice(1,-1):u)+z),"type"===a&&k.test(u)?r=u:(H.test(u)&&("value"===a?o=1:R.test(a)?a="__"+a:~A.indexOf(a)&&(a="riot-"+a)),i.push(a+"="+u))):i.push(a)}return r&&(o&&(r=z+t._bp[0]+K+r.slice(1,-1)+K+t._bp[1]+z),i.push("type="+r)),i.join(" ")}function n(e,t,n){var r=n._bp;if(e&&r[4].test(e)){for(var o,i=t.expr&&(t.parser||t.type)?c:0,a=le.split(e,0,r),u=1;u<a.length;u+=2)o=a[u],"^"===o[0]?o=o.slice(1):i&&(o=i(o,t).trim(),";"===o.slice(-1)&&(o=o.slice(0,-1))),a[u]=q+(n.push(o)-1)+r[1];e=a.join("")}return e}function r(e,t){return t.length&&(e=e.replace(B,function(e,n){return t._bp[0]+t[n].trim().replace(/[\r\n]+/g," ").replace(/"/g,D)})),e}function o(e){for(var t=[],n="";t=F.exec(e);)n+=t[0].trim()+"\n";return n}function i(e){var t=e.replace(F,"");return t}function a(e,o,i){if(e=n(e,o,i).replace(M,function(e,n,r,o){return n=n.toLowerCase(),o=o&&!I.test(n)?"></"+n:"",r&&(n+=" "+t(r,i)),"<"+n+o+">"}),!o.whitespace){var a=[];/<pre[\s>]/.test(e)&&(e=e.replace($,function(e){return a.push(e),""})),e=e.trim().replace(/\s+/g," "),a.length&&(e=e.replace(/\u0002/g,function(){return a.shift()}))}return o.compact&&(e=e.replace(T,"><$1")),r(e,i).replace(P,"")}function u(t,n,r){return Array.isArray(n)?(r=n,n={}):(r||(r=[]),n||(n={})),r._bp=le.array(n.brackets),a(e(t),n,r)}function s(e){function t(e,t,n){for(t.lastIndex=0;n=t.exec(e);)"/"!==n[0][0]||n[1]||n[2]||(e=s.leftContext+" "+s.rightContext,t.lastIndex=n[3]+1);return e}function n(e,t){var n,r=1;for(t.lastIndex=0;r&&(n=t.exec(e));)"{"===n[0]?++r:"}"===n[0]&&--r;return r?e.length:t.lastIndex}var r,o,i,a,u=[],s=RegExp;for(~e.indexOf("/")&&(e=t(e,Q));r=e.match(Z);)u.push(s.leftContext),e=s.rightContext,i=n(e,G),a=r[1],o=!/^(?:if|while|for|switch|catch|function)$/.test(a),a=o?r[0].replace(a,"this."+a+" = function"):r[0],u.push(a,e.slice(0,i)),e=e.slice(i),o&&!/^\s*.\s*bind\b/.test(e)&&u.push(".bind(this)");return u.length?u.join("")+e:e}function c(e,t,n,r,o){if(!/\S/.test(e))return"";n||(n=t.type);var i=t.parser||n&&he._req("js."+n,!0)||s;return i(e,r,o).replace(/\r\n?/g,"\n").replace(P,"")}function f(e,t,n,r){return"string"==typeof t&&(r=n,n=t,t={}),n&&"object"==typeof n&&(r=n,n=""),r||(r={}),c(e,t||{},n,r.parserOptions,r.url)}function l(e,t){var n=":scope";return t.replace(W,function(t,r,o){return o?(o=o.replace(/[^,]+/g,function(t){var r=t.trim();return r&&"from"!==r&&"to"!==r&&"%"!==r.slice(-1)?r=r.indexOf(n)<0?e+" "+r+',[riot-tag="'+e+'"] '+r+',[data-is="'+e+'"] '+r:r.replace(n,e)+","+r.replace(n,'[riot-tag="'+e+'"]')+","+r.replace(n,'[data-is="'+e+'"]'):t}),r?r+" "+o:o):t})}function p(e,t,n,r){var o=(r||(r={})).scoped;if(n)if("scoped-css"===n)o=!0;else if("css"!==n){var i=he._req("css."+n,!0);e=i(t,e,r.parserOpts||{},r.url)}if(e=e.replace(le.R_MLCOMMS,"").replace(/\s+/g," ").trim(),o){if(!t)throw new Error("Can not parse scoped CSS without a tagName");e=l(t,e)}return e}function d(e,t,n){return t&&"object"==typeof t?(n=t,t=""):n||(n={}),p(e,n.tagName,t,n)}function g(e,t){return e?(e=K+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")+K,t&&~e.indexOf("\n")?e.replace(/\n/g,"\\n"):e):"''"}function m(e,t,n,r,o,i,a){var u=a.debug?",\n ":", ",s="});";return o&&"\n"!==o.slice(-1)&&(s="\n"+s),i+"riot.tag2('"+e+K+u+g(t,1)+u+g(n)+u+g(r)+", function(opts) {\n"+o+s}function h(e){if(/<[-\w]/.test(e))for(var t,n=e.lastIndexOf("<"),r=e.length;~n;){if(t=e.slice(n,r).match(Y))return n+=t.index+t[0].length,[e.slice(0,n),e.slice(n)];r=n,n=e.lastIndexOf("<",n-1)}return["",e]}function v(e){if(e){var t=e.match(X);if(t=t&&(t[2]||t[3]))return t.replace("text/","")}return""}function x(e,t){if(e){var n=e.match(RegExp("\\s"+t+J,"i"));if(n=n&&n[1])return/^['"]/.test(n)?n.slice(1,-1):n}return""}function y(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'")}function b(e){var t=y(x(e,"options"));return t?JSON.parse(t):null}function w(e,t,n,r){var o=v(n),i=x(n,"src"),a=O({},t.parserOptions.js);return!i&&c(e,t,o,O(a,b(n)),r)}function _(e,t,n,r,o){var i=O({},t.parserOptions.style),a={parserOpts:O(i,b(n)),scoped:n&&/\sscoped(\s|=|$)/i.test(n),url:r};return p(e,o,v(n)||t.style,a)}function C(e,t,n,r){var o=he._req("html."+n,!0);return o(e,r,t)}function S(u,s,f){var l,p=[],d={template:{},js:{},style:{}};s||(s={}),s.parserOptions=O(d,s.parserOptions||{}),l=s.exclude?function(e){return s.exclude.indexOf(e)<0}:function(){return 1},f||(f="");var g=le.array(s.brackets);return s.template&&(u=C(u,f,s.template,s.parserOptions.template)),u=e(u).replace(ee,function(e,u,d,v,x,y){var b="",C="",S="",O="",E=[];if(E._bp=g,d=d.toLowerCase(),v=v&&l("attribs")?r(t(n(v,s,E),E),E):"",(x||(x=y))&&/\S/.test(x))if(y)l("html")&&(S=a(y,s,E));else{x=x.replace(RegExp("^"+u,"gm"),""),x=x.replace(ne,function(e,t,n){return l("css")&&(C+=(C?" ":"")+_(n,s,t,f,d)),""}),x=x.replace(te,function(e,t,n){if(l("js")){var r=w(n,s,t,f);r&&(b+=(b?"\n":"")+r)}return""});var N=h(x.replace(P,""));l("html")&&(S=a(N[0],s,E)),l("js")&&(x=c(N[1],s,null,null,f),O=o(b),b=i(b),x&&(b+=(b?"\n":"")+x))}return b=/\S/.test(b)?b.replace(/\n{3,}/g,"\n\n"):"",s.entities?(p.push({tagName:d,html:S,css:C,attribs:v,js:b}),""):m(d,S,C,v,b,O,s)}),s.entities?p:u}var O=he.utils.extend,E=/"[^"\n\\]*(?:\\[\S\s][^"\n\\]*)*"|'[^'\n\\]*(?:\\[\S\s][^'\n\\]*)*'/.source,N=le.R_STRINGS.source,L=/ *([-\w:\xA0-\xFF]+) ?(?:= ?('[^']*'|"[^"]*"|\S+))?/g,j=RegExp(/<!--(?!>)[\S\s]*?-->/.source+"|"+E,"g"),M=/<(-?[A-Za-z][-\w\xA0-\xFF]*)(?:\s+([^"'\/>]*(?:(?:"[^"]*"|'[^']*'|\/[^>])[^'"\/>]*)*)|\s*)(\/?)>/g,T=/>[ \t]+<(-?[A-Za-z]|\/[-A-Za-z])/g,R=RegExp("^(?:disabled|checked|readonly|required|allowfullscreen|auto(?:focus|play)|compact|controls|default|formnovalidate|hidden|ismap|itemscope|loop|multiple|muted|no(?:resize|shade|validate|wrap)?|open|reversed|seamless|selected|sortable|truespeed|typemustmatch)$"),A=["style","src","d"],I=/^(?:input|img|br|wbr|hr|area|base|col|embed|keygen|link|meta|param|source|track)$/,$=/<pre(?:\s+(?:[^">]*|"[^"]*")*)?>([\S\s]+?)<\/pre\s*>/gi,k=/^"(?:number|date(?:time)?|time|month|email|color)\b/i,F=/^(?: )*(?:import)(?:(?:.*))*$/gm,P=/[ \t]+$/gm,H=U(/@#\d/,"x01"),B=U(/@#(\d+)/g,"x01"),q="#",D="⁗",z='"',K="'",Z=/^[ \t]*([$_A-Za-z][$\w]*)\s*\([^()]*\)\s*{/m,G=RegExp("[{}]|"+le.S_QBLOCKS,"g"),Q=RegExp(le.R_MLCOMMS.source+"|//[^\r\n]*|"+le.S_QBLOCKS,"g"),W=RegExp("([{}]|^)[ ;]*([^@ ;{}][^{}]*)(?={)|"+E,"g"),X=/\stype\s*=\s*(?:(['"])(.+?)\1|(\S+))/i,J="\\s*=\\s*("+N+"|{[^}]+}|\\S+)",Y=/\/>\n|^<(?:\/?-?[A-Za-z][-\w\xA0-\xFF]*\s*|-?[A-Za-z][-\w\xA0-\xFF]*\s+[-\w:\xA0-\xFF][\S\s]*?)>\n/,ee=RegExp(/^([ \t]*)<(-?[A-Za-z][-\w\xA0-\xFF]*)(?:\s+([^'"\/>]+(?:(?:@|\/[^>])[^'"\/>]*)*)|\s*)?(?:\/>|>[ \t]*\n?([\S\s]*)^\1<\/\2\s*>|>(.*)<\/\2\s*>)/.source.replace("@",N),"gim"),te=/<script(\s+[^>]*)?>\n?([\S\s]*?)<\/script\s*>/gi,ne=/<style(\s+[^>]*)?>\n?([\S\s]*?)<\/style\s*>/gi;return V.util.compiler={compile:S,html:u,css:d,js:f,version:"v2.5.2"},S}();V.compile=function(){function e(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){4===r.readyState&&(200===r.status||!r.status&&r.responseText.length)&&t(r.responseText,n,e)},r.open("GET",e,!0),r.send("")}function n(e,t){if(typeof e===ne){var n=H("script"),r=document.documentElement;t&&(e+="\n//# sourceURL="+t+".js"),n.text=e,r.appendChild(n),r.removeChild(n)}}function r(t,r){function a(){o.trigger("ready"),i=!0,t&&t()}function u(e,t,r){var o=ve(e,t,r);n(o,r),--c||a()}var s=B('script[type="riot/tag"]'),c=s.length;if(c)for(var f=0;f<s.length;++f){var l=s[f],p=T({template:_(l,"template")},r),d=_(l,"src");d?e(d,u,p):u(l.innerHTML,p)}else a()}var o,i;return function(a,u,s){if(typeof a===ne){if(y(u)&&(s=u,u=!1),/^\s*</m.test(a)){var c=ve(a,s);return u!==!0&&n(c),m(u)&&u(c,a,s),c}e(a,function(e,t,r){var o=ve(e,t,r);n(o,r),u&&u(o,e,t)})}else{if(m(a)?(s=u,u=a):(s=a,u=t),i)return u&&u();o?u&&o.on("ready",u):(o=V.observable(),r(u,s))}}}();var xe=V.mount;V.mount=function(e,t,n){var r;return V.compile(function(){r=xe(e,t,n)}),r},typeof exports===re?module.exports=V:typeof define===ie&&typeof define.amd!==oe?define(function(){return V}):e.riot=V}("undefined"!=typeof window?window:void 0);